Disconnected ShareThis plugin for WordPress
Posted in: Technical
I see the ShareThis plugin on tons of WordPress blogs — and with reason, because the presentation is quite nice. You don’t have to take up a chunk of the screen listing all of the different social networks (and they keep multiplying…) or offering the option to email this post to a friend; instead you have a simple link that shows all of the useful detail in a little popup.
ShareThis was so popular, in fact, that a business has sprouted up around it — and current versions of the plugin are tightly bound into the ShareThis.com website. They collect data every time anyone even clicks the link to open the ShareThis window, the social networks links all redirect through the ShareThis.com servers, and all that data (associated with your website) is there for detailed reporting if you register with them. They now also encourage your visitors to sign up. I’m sure it has its uses, and they’re supported by advertising revenue, so they want lots of people to sign up and I imagine they use all that data in conjunction with showing those ads.
…by posting or submitting content or materials on public areas of the service, such as public message boards, etc., you are giving us permission to use your submission in connection with the operation of ShareThis, including the right to copy, transmit, publicly display and reformat your submissions on ShareThis.
And “ShareThis is supported by advertising revenue. Some of the advertisements may be targeted.” Etc..
Unfortunately, the tracking features slow down the process (there’s a delay while it opens the window, visitors have to wait for the redirects, etc.)… but more importantly, they creep me out (I want control of my data!), and you can’t turn them off even if you aren’t interested in all the related features. Each time someone clicks the icon, forwards an email, submits a link, etc. there’s a step in there that goes through r.sharethis.com, and it’s all tracked and associated with your blog.
You can still download older versions (since before all of the tracking features were added) from here… but then you’re missing out on bug fixes.
My personal solution was to download the “ShareThis Classic” plugin from the website of Alex King (the original creator) — since it includes bugfixes and is the last version before the entire ShareThis popup started to be loaded directly from ShareThis.com. It does include the tracking features, but it’s pretty easy to disable them if you know at least minimal PHP:
- First, make sure you have a backup of the zip file (to reinstall if needed)
- Visit the Plugins page in wp-admin
- Make sure ShareThis Classic is deactivated (click Deactivate if not)
- Click Edit
- Search the page for references to “r.sharethis.com”
- Update the code to remove the redirects and links (more details below)
- Click “Update File”, reactive the plugin, and make sure you haven’t broken anything!
Remove the redirect from a link:
return 'http://r.sharethis.com/web?destination=' + encodeURIComponent(base) + '&publisher=' + pubid;
Remove the image (which identifies you when it’s loaded)…
<img src="http://r.sharethis.com/powered-by?publisher=<?php print(get_option('st_pubid')); ?>" alt="Powered by ShareThis" />
Powered by ShareThis
Remove the reporting of an email submission:
require_once(ABSPATH.WPINC.'/class-snoopy.php'); $snoop = new Snoopy; $snoop->agent = 'ShareThis Classic for WordPress'; $snoop->fetch('http://r.sharethis.com/email?url='.urlencode(get_permalink($post_id)).'&publisher='.get_option('st_pubid'));
[Just remove those lines.]
…and remove another redirect:
print(' <li><a href="http://r.sharethis.com/web?destination='.urlencode($link).'&publisher='.get_option('st_pubid').'" id="akst_'.$key.'">'.$data['name'].'</a></li>'."\n");
print(' <li><a href="'.$link.'" id="akst_'.$key.'">'.$data['name'].'</a></li>'."\n");
That one’s a bit ugly….
Might as well fix a bug while we’re here…
If you use any version of ShareThis Classic, there’s a bug in sharing via email: it returns a page with “WordPress Error” as the title (though the sending actually worked), and in the current version of ShareThis Classic the link back to the post is broken.
To fix these bugs find this code:
wp_die(__('Thanks, we\'ve sent this article to your recipients via e-mail. <a href="'.get_permalink($post_id).'">Return to original page</a>.', 'share-this'));
wp_die(__('Thanks, we\'ve sent this article to your recipients via e-mail.', 'share-this').' <a href="'.get_permalink($post_id).'">'.__('Return to original page', 'share-this').'</a>.', 'Article shared successfully!');
Is it legal to make these changes?
Short answer: Yes.
Longer answer: The PHP code is licensed under the open source GPL (GNU Public License). That means you can edit it however you like, and you can even redistribute your changed source code — though I’m not redistributing the whole plugin right now, since it’s trivial to make these changes yourself, and I haven’t looked up the licensing for that ShareThis image.
I also notice that the terms in ShareThis.com include a lot of restrictions that are NOT allowed by the GPL, even though the PHP itself is still licensed that way — they make claims like this:
You may not reverse engineer, decompile, or disassemble any aspect of ShareThis Widgets. You may not modify, adapt, or create derivative works from the ShareThis Widgets. Do not remove proprietary notices. Do not help any one else to do any of the things prohibited in this paragraph.
…which, frankly, are nonsense, assuming “ShareThis Widgets” comprise the PHP plugin… and what other code would they mean? Huh. Anyway — GPL. Go read it if you aren’t sure (perhaps the ShareThis lawyers ought to read it… it’s in the header of the PHP file).
Return to: Disconnected ShareThis plugin for WordPress