code Archive

Enabling Twitter avatars within BuddyPress

Article
02Mar
17

First up, the first step in this process is to install the Twit Connect plugin which you can do by following these instructions, then you can proceed with enabling Twitter avatars.

First up, the first step in this process is to install the Twit Connect plugin which you can do by following these instructions, then you can proceed with enabling Twitter avatars.

This is just a quick filter that I wrote while I was setting up help.deanjrobinson.com last week after I discovered that the twitter avatars weren’t working because of a different function/filter being used by BuddyPress.

I make no claims that this additional function is perfect, but I haven’t come across any problems with it yet, and I only knocked it together quickly. If you find anything wrong with it, or have any suggestions as to how it could be improved/simplified please let me know.

This new function based on one of the original functions that comes with the Twit Connect plugin which enables twitter avatars on regular WordPress blogs, just a with a few tweaks.

What you need to do is add the following code to the functions.php in your current BuddyPress theme. You can download a plain text copy of this function here (it’ll probably more reliable than copy-and-pasting from this page). Remember to backup your functions.php file before making any changes… just in case.

UPDATE: Appears some people who added this function the functions.php file in the default BuddyPress theme were seeing some error messages (I have not yet been able to recreate this error, but more than one user has reported it). Ideally you shouldn’t be modifying the default BP theme directly, you should be doing it via a child theme (find out how), so this code should be then added to the functions.php in your child theme.

7th March, UPDATE I’ve updated the function below (and the downloadable version above) to use http://tweetimag.es for the static twitter avatar URLs, it looks like it might a more reliable/consistent service.

<?php

 function bp_twc_get_avatar($avatar, $id_or_email='') {
  global $comment, $twc_user_login_suffix;

  if(is_object($comment)) {
   $user_id = $comment->user_id;
  }

  if (is_object($id_or_email)) {
   $user_id = $id_or_email->user_id;
  }

  if (is_array($id_or_email)) {
   if ($id_or_email['object']=='user') {
    $user_id = $id_or_email['item_id'];
   }
  }

  if (get_usermeta($user_id, 'twcid')) {
   $user_info = get_userdata($user_id);
   $twav_suffix = '';

   if ( $id_or_email['width'] ) {
    $twav_size = $id_or_email['width'];
    if( $twav_size < 32 ) {
     $twav_suffix = 'm';
    } else if ( $twav_suffix < 64 ) {
     $twav_suffix = 'n';
    } else {
     $twav_suffix = 'b';
    }
   } else if ( 'full' == $id_or_email['type'] ) {
    $twav_size = BP_AVATAR_FULL_WIDTH;
    $twav_suffix = 'b';
   } else if ( 'thumb' == $id_or_email['type'] ) {
    $twav_size = BP_AVATAR_THUMB_WIDTH;
    $twav_suffix = 'n';
   }

   $out = 'http://img.tweetimag.es/i/'. str_replace($twc_user_login_suffix,"",$user_info->user_login) . '_' .$twav_suffix;

   $avatar = "<img alt='Twitter Avatar' src='{$out}' class='avatar avatar-{$twav_size}' height='{$twav_size}' width='{$twav_size}' />";
   return $avatar;

  } else {
   return $avatar;
  }

 }

 // Check if Twit Connect exists (since its without it this function is pointless)
 if( function_exists( 'twit_connect' ) ) {

  add_filter( 'bp_core_fetch_avatar', 'bp_twc_get_avatar',10,4);

 }

?>

Show me the original version

I will add an explanation of what its doing if people are interested/curious.

••••

Introducing WPAPI.ORG

Article
18Oct
0

Ok, so I actually launched this last weekend, but I’m only just now getting around to writing (briefly) about it. WPAPI.ORG is a super easy to use API which you can use to retrieve stats for all those great plugins and themes that you’ve got hosted on WordPress.org. Why would you want to do this?

Ok, so I actually launched this last weekend, but I’m only just now getting around to writing (briefly) about it. WPAPI.ORG is a super easy to use API which you can use to retrieve stats for all those great plugins and themes that you’ve got hosted on WordPress.org. Why would you want to do this?

WPapi.org

Why did I build this thing?

Because I could. No, seriously, the reason that I’ve built this (and made it available to everyone else) is that I was looking for ways to pull back the stats from WordPress.org and display them on the project pages here on my site, maybe even with some sexy graphs using something like Raphaël JS. After some investigation I found the xml feed that powers the graphs on WordPress.org, but that didn’t really help me. What I really wanted was JSON.

» Continue reading “Introducing WPAPI.ORG

••••

How to add clickable hashtags to your twitter widget

Article
26Jul
3

A few weeks ago Twitter finally added clickable hashtags to twitter.com. However if your one of the many people who make use of the html/js widget provided by twitter to display recent tweet on your own website then you will have noticed that you still don’t get clickable hashtags in the list of tweets that get displayed. Luckily this is pretty easy to fix if you want to, and you aren’t freaked out at the thought of modifying a little javascript.

A few weeks ago Twitter finally added clickable hashtags to twitter.com. However if your one of the many people who make use of the html/js widget provided by twitter to display recent tweet on your own website then you will have noticed that you still don’t get clickable hashtags in the list of tweets that get displayed. Luckily this is pretty easy to fix if you want to, and you aren’t freaked out at the thought of modifying a little javascript.

UPDATE: This article is no longer relevant, twitter have completely changed their widgets (which you can grab here), and the new widgets now support hashtags out of the box. Looks like any existing widgets should continue working as they just use the user_timeline API method which hasn’t changed.

Below is the default javascript function that is called by the default HTML Twitter widget, you can grab the widget code here or look at the full javascript file here.

There isn’t much to it, just the callback function, and a function to format the timestamp for each tweet. I’m only focusing on the callback in this post as that is all we need to play with to get clickable hashtags working. The default callback runs through the list of tweets that have been returned and using a couple of regular expressions (regex) it pulls out urls and @mentions and links them up.
» Continue reading “How to add clickable hashtags to your twitter widget”

••••
Link
02Jul

Modernizr is a small and simple JavaScript library that helps you take advantage of emerging web technologies (CSS3, HTML 5) while still maintaining a fine level of control over older browsers that may not yet support these new technologies. Could possibly be made even more powerful if combined with something like this CSS browser selector

••••

DotNetNuke – Not Good Enough

Article
14Feb
30

See what happens when you ask for a discussion around something that’s really been getting up my nose for the last 6 months, I go and write. I vent. I rant. But that’s what my blog is for, and thankfully it doesn’t run on DotNetNuke. So you want to know what I really think, keep reading.

Background

It all started with a tweet, the intention wasn’t to cause trouble, but to simply highlight what I thought of the contents of the post in question. I got a reply surprisingly quick from the co-founder who suggested “It is easy to take a shot at someone in abstract…”, and then “how bout a real discussion on the merits or lack thereof of his points”. Ok, let me elaborate.

Disclaimer
I’ll get this out of the way now, this is my blog so I’m entitled to my opinion, but so are you. If you don’t agree with my opinion, that’s fine with me, I don’t care at all. However, if you’ve never tried to use/customise/configure/upgrade/install this steaming p.o.s. then hold back any disagreement with me until after you have. Note: I’m not forcing you to try it out, that would be mean..

Retort - ask and ye shall receive

Those who work on DotNetNuke seem to be constantly defending themselves over the openness of their open-source project, so much so that I’m sure there are more defensive efforts than actual attacks. Despite what I think of their “openness”, I’m not here to specifically attack how open it is. Well not to begin with anyway, we’ll see what happens once I get going.
» Continue reading “DotNetNuke – Not Good Enough”

••••
Link
15Jan

jQuery 1.3 released jQuery was already super fast, but check out those graphs its even faster again. Can’t wait to start playing with it. Awesome.

••••
Link
09Jan

Push Your Web Design Into The Future With CSS3 The sooner more CSS3 properties become available across all browsers the better. I wasn’t aware that ‘box-shadow’, ‘text-shadow’ and ‘@font-face’ worked in Firefox 3.1, no real reason not to use them now.

••••

Easy CSS Drop Caps

Article
02Jan
6

Adding drop caps to the beginning of a paragraph, as I did with my latest redesign, is actually a pretty simple and straight-forward process. The effect can be achieved with just a couple of lines of CSS making use of two special ‘pseudo-elements’.

This effect should work in most browsers (yes, even Internet Explorer, according to MSDN both ‘elements’ should work in IE5.5+), the only real variation may be which font is displayed for the drop cap, and the way the specific browser interprets ‘em’ font-sizes. Alternatively pixel sizes could be used for the drop cap font, which should allow you to get greater consistency between browsers.

As mentioned we’re going to use two pseudo-elements as outlined in the CSS2 specification, the two ‘elements’ in question are :first-line and :first-letter. If you’re curious and want to know more about these ‘elements’ or the concept of ‘pseudo-elements’ feel free to follow the links and have a read of the specification, its not necessary for the purposes of this brief how-to, but some people are into that sort of thing.

» Continue reading “Easy CSS Drop Caps”

••••

Racesquad

Sidenote
07Feb
1

Just after Christmas I began work on my most recent project (yes I probably should have been doing one of the other dozen projects I’m always talking about). RaceSquad is a fantasy motorsport manager/game that I’ve built from the ground up based on the things I’ve liked and disliked in the many other similar ‘programs’ I participated in over the years. If you’re a motorsport fan, why not sign up to see what you think, feedback is more than welcome. http://racesquad.com

••••

Gazing into my crystal ball

Article
18Oct
16

Ok, so there hasn’t been as much activity on here in recent months as I would like, but finding time to do all the things I want (and need) to do is the problem. With a bit of luck I will be able to recapture some time to work on projects in the next month […]

Ok, so there hasn’t been as much activity on here in recent months as I would like, but finding time to do all the things I want (and need) to do is the problem. With a bit of luck I will be able to recapture some time to work on projects in the next month or so. I am now inside my final month of University (finally), with a handful of fairly large assignments to complete, but no end of year exams to worry about. However also over the next month I also need to find somewhere to live which will no doubt consume a fair amount of time. But then, hopefully, I should be able to get back to work on my side projects. Lets have a quick look at those projects.

Redoable

I have received so many requests for me to update Redoable, initially for Wordpress 2.2 (which only introduced a couple of small issues) and more recently for Wordpress 2.3 compatibility. This one is a bigger issue since the way that categories are handled has changed completely. Then there are all the little bits and pieces that were never really “just right”, most probably due to Redoable being my first Wordpress theme, or in this case theme modification (Redoable is based on the code of K2). Mind you these ‘issues’ haven’t stopped over 30,000 downloads.but with the last update way back in April it really is time for some progress to be made.

So where do I begin. Well, it just so happens that Michael Heilemann and co are into the ‘release candidate’ stages of K2 1.0. K2 has become even greater over the last 10 months, and it is already Wordpress 2.3 compatible. Tyler Longren (creator of Unwakeable, another K2-based theme) recently announced that he planned on basing the next version of Unwakeable on K2 1.0 when it was released. A couple of months ago I had planned to do Redoable 1.3 and fix some of the main issues that had come up since the release of 1.2, but I simply couldn’t find the time that I wanted to spend on it. I can now say that there will be no Redoable 1.3.

Nope, I will be jumping straight to Redoable 2.0. Again I’ll be using K2 as the base, and although I have started some initially work, the main body of work on 2.0 won’t begin until the final stable release of K2 1.0 is available. While its not going to be exactly the same as 1.x, it will keep a lot of the ‘flavour’ of it since that seems to be what people want. I’m still thinking through about which additional plugin support, and other features I’ll add to the K2 base, but hopefully before Christmas there will be a new version of Redoable for you all the play with.

Wordpress Plugins

I am well aware that just about all of my plugins need to be updated to work with the latest Wordpress 2.3. In particular Ultimate Category Cloud, which no longer works due to the previously mentioned category changes in WP2.3. Other plugins just need a tidy up, and general bug fixing. I will hopefully get at least some of the plugins updated to go along with the release of Redoable 2.0

More Wordpress themes

I didn’t take long for people to start requesting a download of the ‘Pipedream’ theme that I am currently using. The thing is that Pipedream was designed for my site and my site only, its not really ready for a public release (yet). It doesn’t really work like a normal theme, due to the number of customisations that are built in. Beside the idea was that I wanted my site to be unique, which I had lost while I was still using Redoable. However I have begun thinking about a ‘Public’ version of Pipedream, but as far as a release date it probably won’t be until the new year.

A couple of weeks ago, I was sick of doing uni work one night and just started playing around with a magazine style layout which has kind of progressed into the beginnings of another new Wordpress theme. Unlike Redoable and Pipedream this new theme is going to be much lighter and brighter, with a slightly different approach to the way that posts are arranged and displayed. More about this new theme in the coming months.

Hahlo

Although I’ve only just rolled out the new version of Hahlo I’ve still got a list of things “to-do” which just didn’t make it into 2.0. Most of them are minor behind the scenes things, but there are also several things that have been requested by users. Things such as an quicker way to refresh the current timeline, currently it takes two ‘taps’, one would be ideal. Another thing I would like to try and get working is some form of user options to allow people to customise their Hahlo experience. For example some people would like to login and be taken straight to their friends timeline, other would like to be taken to their favourites list, I would love to be able to implement this.

I also have plans to release a very simple Hahlo desktop application, still using the webapp but in a standalone webkit-based application. I had considered turning Hahlo into an Adobe AIR application, they seem to be all the rage at the moment, but since just about everything in Hahlo relies pretty heavily on php and the functions within, and AIR doesn’t support php that pretty much canned that idea. In the meantime if you really want a Twitter app running on AIR, I suggest trying out Snitter.

Others…

And on top of all that I’ve got a couple of other things that I’m working on, one of which I’m working on at the moment as part of a University assignment. Plus no doubt I’ll run off on a tangent and end up working on things that aren’t on the list above as well.

deanjrobinson.com
twitter was not updated. | tumblr was not updated. | lastfm was not updated. |