Arts
Graphics 049
Comics 017
Writing 009
Video 137
Music 124
Movie 052
Radio 008
Photo 049
Book 048
Scifi 021
Art 047
Tv 030
Computers
Hardware 010
Software 202
Microsoft 037
Synology 035
Google 093
Firefox 023
Coding 149
Kiss 013
Wifi 001
Pda 060
Internet
Webmoney 056
Webgoodie 054
Webdesign 035
Wordpress 051
Socialweb 165
Webtools 129
Blogging 078
Hosting 015
Links 373
Home
Household 044
Sonicare 008
Finance 035
Fashion 010
Gadget 066
Baby 018
Health 008
Travel 016
Food 020
Car 032
Game+Rec
Game 070
Xbox 017
Risk 092
Cool 075
Free 035
Humor 139
Society
Brights 138
Skeptic 052
Human 092
Politics 071
Green 015
Celebrities 008
Private
Thisweblog 101
Genealogy 013
Brainstorm 015
Maarten 029
Private 275
Nikon 011
Bali 030
Idea 137
Indo 012
More
News 046
Shop 076
Science 100
Reference 049
It 039
Subs
Lost 014
Howto 042
Wikipedia 017
History 028
Review 015
Xara 029

·  Search:  
?

The WordPress StumbleUpon plugin displays if a link has been stumbled. It can also display how many reviews it has in the RSS feed of the SU page of the link.

You can download it here:  http://wordpress.org/extend/plugins/stumbleupon-wordpress-plugin

As I have explained in my last blogposting I need to do something about the stumble upon plugin. It takes up 55% of all traffic to my little spot on the Grid  .

image

Some people would like 120.000 requests but I don’t. Even with the caching it’s not programmed that smartly I think. I am thinking to complete change it. Instead of making requests to my own server maybe I could use the WordPress build-in /wp-includes/class-snoopy.php 0 and /wp-includes/rss.php (which is simply magpie). Actually this was in one of my first versions but I forgot why I dropped it or even where these older sources are…..

Currently the plugin consists of a server part and a client part. The client part is simple. It just searches for all your urls and then does a call to the server per url, the replacer is completely ripped from php.net, pretty default.

   1: //strxchr(string haystack, string needle [, bool int leftinclusive [, bool int rightinclusive ]])
   2: function strxchr($haystack, $needle, $l_inclusive = 0, $r_inclusive = 0){
   3:    //Note our use of !==. Now work if the position of $needle in $haystack was the 0th (first) character.
   4:    if(strrpos($haystack, $needle) !== false){
   5:        //Everything before last $needle in $haystack.
   6:        $left =  substr($haystack, 0, strrpos($haystack, $needle) + $l_inclusive);
   7:        //Switch value of $r_inclusive from 0 to 1 and viceversa.
   8:        $r_inclusive = ($r_inclusive == 0) ? 1 : 0;
   9:        //Everything after last $needle in $haystack.
  10:        $right =  substr(strrchr($haystack, $needle), $r_inclusive);
  11:        //Return $left and $right into an array.
  12:        $a = array($left, $right);
  13:        return $a;
  14:    }else{
  15:        return false;
  16:    }
  17: }
  18:  
  19:  
  20: function Replacer($matches) {
  21:     $or_string  = '<a href="' . $matches[1] . '">' . $matches[2] . '</a>';
  22:     $st_string  = '<a href="http://www.stumbleupon.com/url/' . $matches[1] . '">' .
  23:  
  24:     $st_string  = $st_string .  '<script src="http://leau.net/su/su.php?' .  $matches[1] . '" type="text/javascript"></script>';
  25:  
  26:     $st_string  = $st_string . '</a>';
  27:  
  28:     // if the string contains any html tags we'll skip it, doesnt look good
  29:     if (strstr ( $matches[2], '<' )) {
  30:       return $or_string;
  31:     } else {
  32:       // if the url is a zip, pdf, etc... also skip it
  33:       $foundstr = strxchr($matches[1], ".", 1, 1);
  34:       if ($foundstr && (stristr('.zip .pdf .arj', $foundstr[1]) != FALSE)) {
  35:             return $or_string;
  36:       }
  37:       return $or_string . $st_string;
  38:     }
  39: }
  40:  
  41: function add_stumble_icon ($text) {
  42:     return preg_replace_callback('/<a href="(.*?)">(.*?)<\\/a>/i', 'Replacer', $text);
  43: }
  44:  
  45: add_filter('the_content', 'add_stumble_icon', 9);

Now I need to change the “Replacer($matches)” function so that instead of it calling my server “http://leau.net/su/su.php?’   .  $matches[1] ” it will call a function which will call the build-in WordPress magpie. I had this version before but somehow I stopped working on that approach. But I can not really remember why.

But with a little fiddling its in: http://wordpress.org/extend/plugins/stumbleupon-wordpress-plugin/ 1

I have given the new a href link to the stumblepage its own class (wpsulink) so you can style to the link in whatever form you want (I yet have to do this for this blog).

update: the plugin 0.5 does not yet make a difference between *not stumbled* and *0 stumbles”…. let me fix that. I also notice that there are a lot of calls to the javascript displayer directly, I will also find something else for that. I will add the icons or text with and admin panel option.

update: version 0.7 focuses on the graphical button, the past ones were little rounds that could not be read, I now made a span which contain both the icon and a text. I tested it with various designs e.g.:

image

But I made it much softer to finally this:

http://populair.eu   or http://www.wikipedia.nl 1  or http://www.wikipedia.com 2 or http://leau.net   or http://win2vnc.sourceforge.net/  

There is an administration panel on which I would advise to take the following setings:

image

If you really do not want to display the icon there is always the possibility to turn it off and add your own text description e.g. (22 reviews). Note that the reviews are from the RSS feed not the actual reviews from the su url itself. That makes it a more up2date rating.

update: version 0.8 will contain a function that you can past in your sidebar or under a post for a specific permalink along with a “+” sign so users can add it.

update: version 0.9 brings it to a stable thing again. Read http://leau.net/su   for the stumble upon wordpress plugin description.

Related posts