Fixed. Unwakeable 2.0 will include this fix.
My Unwakeable WordPress theme doesn’t play nicely with Alex King’s Share This WordPress plugin. When Share This is being used, the livesearch feature of Unwakeable doesn’t work in Internet Explorer 6 or 7. I’m willing to bet K2 has the same issue. I know for a fact that Redoable had this problem at one point.
Livesearch breaks because prototype.js gets loaded twice, first by Unwakeable, then again by Share This. Now, Share This uses the prototype.js that will be included in WordPress 2.1, located at wp-includes/js/prototype.js. We use a custom prototype.js file for Unwakeable. The prototype.js file in Unwakeable will still provide all the functionality needed by Share This.
I’ve spent a few days thinking of possible solutions that could be implemented from within Unwakeable. That’s not possible though, unfortunately. Well, it is possible, but would require filtering all the HTML output by WordPress before it’s sent to the browser so we could strip out the prototype.js included by Share This. Doing something like that would probably result in a fairly dramatic decrease in performance, so it’s not an option.
Fortunately, it’s extremely easy to modify Share This to not load prototype.js. Here’s what you need to do:
- Open wp-content/plugins/share-this/share-this.php
- Go to line 352:
- Delete all of line 352 (code above) and you should be left with this on line 351 to line 354
- Save share-this.php and upload it to wp-content/plugins/share-this/
That’s all there is to do to stop Share This from loading prototype.js. It sorta sucks having to ignore the prototype.js that’s already included with WordPress 2.1. I will probably start working on making Unwakeable work with the prototype.js included in WordPress 2.1.
Sorry for the scattered thoughts, this has really been bugging me lately. Anyway, you should be able to make your livesearch work with Share This in Internet Explorer now. This probably applies to most K2 based WordPress themes, but I’m not sure.
Well, now what?
Work with Me
I'm available for hire and always taking new clients, big and small. Got a project or an idea you'd like to discuss? Startup plan but no developer to make it happen? Just get in touch, I'd love to see if I can help you out!
Leave some Feedback
Got a question or some updated information releavant to this post? Please, leave a comment! The comments are a great way to get help, I read them all and reply to nearly every comment. Let's talk. 😀
7 thoughts on “Make Alex King’s Share This Plugin Play Nice With Unwakeable”
It’s relatively trivial for you to solve this in your theme – I don’t understand why you’re trying to solve it by altering plugins.
Right on Alex. I was over-thinking the whole thing way too much. Someone else mentioned to me they had to remove that line from Share This, so I guess I just assumed it was more difficult than it really was.
I’ve modified Unwakeable to use wp-includes/js/prototype.js as the default prototype file for WordPress versions greater than or equal to 2.1. If 2.0 is still in use it’ll use the old prototype.js.php file from K2.
Basically, what I did was remove_action(‘wp_head’, ‘akst_head’). With that gone, I’m free to include wp-content/plugins/share-this/share-this.php?akst_action=js and wp-content/plugins/share-this/share-this.php?akst_action=css at my will.
So, yah, seems to be a pretty good fix. Everything about Share This still seems to work, even the pages.
That’s definitely an improvement, but I still think you’re looking at this the wrong way. Coding in exceptions for individual plugins isn’t a solution; it’s a hack and it isn’t forward-compatible.
Plugins don’t have some of the luxuries that themes do. One of these is the ability to see what other JS files have been included. Since themes can see this data and plugins can’t, it only makes sense for the *theme* to deal with the issue – not by modifying plugins.
Here is some sample code.
 Note, WP 2.1 includes a mechanism for plugins to avoid this – yay 2.1!
Alex, I love you. That code is pretty much exactly what I was looking for. I will work on implementing something similar in Unwakeable. Thanks for all your help Alex!
Thank you for addressing this issue!:D Although I’m not using your theme, I also use a theme (not K2)which already calls upon prototype.js so calling it twice just wouldn’t work.
With regards to Alex’s code – where would I place this in the theme?
Mosey, if you’re using WordPress 2.1, you should remove the code in you theme that includes prototype.js and replace it wp_enqueue_script(‘prototype’). wp_enqueue_script is a new function in WordPress 2.1 that will make sure scripts such as prototype only get loaded once.
Let me know if you’ve got any questions.
Thanks again! 😀 Your help has been really appreciated – wp_enqueue_script is a seriously useful new addition 🙂