Articles Comments

Marco Luthe Online! » WordPress Stuff » And Plugin Trouble And Plugin Trouble

I stumbled upon accidently on a blog when I was kind of randomly surfing the web, looking for blog designs. The “ShareThis” button really caught my attention: one click on the button opens a new container with several social bookmarking services where you can add the URL of the current post you view. You can even send the URL via mail or instant messenger – that way, I could get rid of one more plugin (WP-EMail).Up to that point, I was still using the WordPress plugin Social Bookmarks, but I did not quite like the way all icons where shown – it was kind of “too much”.

The way ShareThis handles this is – in my opinion – much more elegant and eye-catching.

As I am using WordPress (surprise!), the question “Looking for ShareThis WordPress plugin?” made me click, download and install the plugin (version 2.0) which was released by Alex King.

Well, what can I say?
There are still some improvements to make on this one, because…

  • … the code that is produced by the plugin is not XHMTL valid.
    The reason for that is that ampersands are not integrated as HTML entities (& + amp;) – which is a breach of validation rules. One must mention that the JavaScript code is provided by ShareThis itself and has to be copied into a (much too small) textarea field within the WordPress options panel. Nevertheless, I was unable to change the ampersands within that textarea field – a “&publisher=” was always added at the end of the string – I guess that has something to do with the RegEx. Each time after I had entered the options panel, several “&publisher=” were added to that code which all were identical. So, to get the code right, I actually had to change it in the wp_options table – and remember not to visit the options panel again.
  • … the plugin messes with the Slickr Gallery plugin.
    I found this out by accident, because after installing the ShareThis plugin, I looked at several posts and pages of my blog to see if everything goes well – it didn’t: Slickr Gallery was not presenting my flickr photos on my photos page within Firefox any longer, it was stuck within the loading progress. Firebug told me there was a problem with the JavaScript. Somehow, embedding the JavaScript by the ShareThis plugin in each page seems to have messed things up.
  • … the button is added everywhere.
    By default, the “ShareThis” button is shown everywhere – in posts as well as in excerpts (and I believe in RSS feeds as well). Options are not available to control this behaviour. You manually have to comment out the “add_action” parts in the core plugin file to get rid of this.

As can be seen, I am not that convinced of this plugin by now.

Sorry for this, Alex – but I still like your Popularity Contest plugin very much. ;-)

[Update from 2007-11-17]

OK, I managed to include ShareThis into my template without the plugin.

First of all, be sure to include the JavaScript code provided by ShareThis into the header template. I do this after finding out if the main page or a single post is viewed. Otherwise, no code will be included. This way I can prevent it from messing up the Slickr code on the photos page.

<?php if(is_home() || is_single()) { ?>
    ... put the JavaScript code provided by ShareThis here ...
<?php } ?>
<?php wp_head(); ?>

Then, within The Loop, put this JavaScript wherever you want the button to appear (this is actually taken from the plugin mentioned above):

global $post;
$sharethis = '
    <script type="text/javascript">
        title: "'.str_replace('"', '\"', get_the_title()).'",
        url: "'.get_permalink($post->ID).'"
echo $sharethis;

This should work fine now.

[Update from 2007-11-25]

Hmm… the ShareThis plugin does not seem to be the only one messing around with the Slickr Gallery plugin.

[Update from 2008-04-14]

I decided to get rid of the ShareThis button, as I want to minimize embedding external scripts. The Digg-button and “add to” should be sufficient for social bookmarking. It does not make any sense to have 20 different services shown.

Filed under: WordPress Stuff · Tags: , , , ,

  • Jen Parga

    Hi Marco!

    I work at ShareThis and collaborated with Alex King on the ShareThis 2.0 plugin. I noticed in your post that you were having some problems with it. In particular, I’d like to take a look at the bug with multiple “&publisher=” querystring arguments being added. I’d previously debugged that issue, so if you’re willing to share, I’d like to get some debugging info from you. Also, I’d like to take a look at the ShareThis plugin’s interaction with your Slickr Gallery plugin.

    1. Could you verify what version of WordPress you’re using? It looks like 2.1.3.

    2. Could you tell me what other plugins you’re using on your site?

    3. Could you send me the /wp-content/plugins/share-this/sharethis.php file that you’re using?

    The best way for me to duplicate your environment would be for you to zip up your whole WordPress installation and send it to me. That way I would have a snapshot of your whole configuration including your other plugins and template. I don’t need the database, and you can remove the database connection info from the wp-config.php file.

    The good news is that we have fixed the “button added everywhere” issue in the next version, which should be available in a week or so. We’ll be adding a template tag so that you can place the button where you want and a switch to turn it on and off.


  • Marco

    Hi Jen!

    Of course, I am willing to help you optimizing your plugin – I hope I can be of any help.

    First of all, please make sure the ampersands in the JavaScript are properly masked as html entities (& amp;) – that way, the XHTML-isssue should be solved.

    Yes, I am currently still using 2.1.3. I am willing to upgrade, but that’s gonna happen later, I guess. :-)

    If you want to know what plugins I am using, just take a look at the ‘Blog-Info’ site where all the used plugins are listed.

    The sharethis.php is on its way to your eMail-address – I am not using the plugin any longer, as I managed to do without.

    I am not quite sure why the Slickr plugin does not work with the ShareThis plugin installed – somehow, it does not proceed further than the “loading” screen. You should implement it yourself to see what the problem is. It might have to do with the prototype library. As described above: if I do not load the ShareThis JavaScript inside the header, everything works fine.

    Please understand that I am not willing to give away my WP installation – but if you have further questions, don’t be shy. ;-)

    Good luck with debugging!

blog comments powered by Disqus