(DFFRP)
Over on the post announcing my “Read More Right Here” wordpress plugin, an interesting few comments popped up by Thijs (I love these drawings). He found that the plugin breaks when a domain lets wordpress run its root, but the actual Wordpress files are stored in a subdirectory (see this codex article for the how to).
And awesomely enough, he found the cause of the problem!
I was constructing the path to the plugin’s directory using the Wordpress function get_bloginfo, and passing to that function the value 'url'. However, the doc shows that value will result in Wordpress returning the blog home URL, and not the location of the actual core Wordpress files (which is what I needed). To get that path, you have to send in 'wpurl'.
But this fix uncovered another problem. That same path I assumed to be correct is hardcoded in the javascript function used to create the “loading” animated gif that appears while the “read more” content is being pulled. I fixed this issue by having the javascript asynchronously (ajax) ask Wordpress for the correct path (using the now updated function I described in the previous section). But that’s not really how I wanted to do it.
WOW, I FEEL STUPID.. I just typed a whole section here describing how I would rather have the javascript value used as the plugin URL somehow set by Wordpress. I envisioned something similar to wp_enqueue_script that could be used to inject some javascript value to the header along with the linked script sources.
So of course, after I’ve spent loads o’ time trying to find such a solution, figured “maybe next time” and officially updated the plugin, now I find this article (and I quote):
WordPress provides an elegant way to pass parameters to your JavaScript code using
wp_localize_scriptfunction.
Arg and Doh and all that. Be on the lookout for another release!
6 Comments
yep the new version works great, nice work.
Thanks for the kind words about my drawings, too. If you’ve got any favorite ones, I can pop a nice print in the mail, I’m printing a bunch up next week.
Am trying to use the plugin but getting an error message: Sorry! There was an error retrieving content.
Click again to be taken to this entry’s page.
My Wordpress is in the root directory, does your recent update correct this issue?
thanks
ken
(never replied directly in the admin area of WP, so not sure how this is going to turn out)
Sorry to hear that Ken. If WP is in your website’s root directory, then things should work just fine. Any more details about your setup you can share so that (when I get a chance) I can try and reproduce it? I couldn’t find anything but WP “pages” and links that indicated a full post at the website you gave (cynthiacreel.com). In other words, where at that site would this issue show itself?
i had a similar errormessage to the one ken had: after clicking on a more-link the last one on a page of ten posts was expanded and showed the errormessage. although the text expanded properly, clicking the more-link again expanded the text again and again (instead of collapsing it).
i fixed this problem by updating the jquery.js in my rather old version wordpress (2.2) – i hope it’s okay i took a copy from your blog. [-;
however a new problem appeared: the special characters like ö or ü – and they are quite often in the german language – are not shown properly.
do you have any suggestions on fixing this?
thanks, calibretto.
i fixed the problem by converting the database to utf8.
I just thought I’d let you know that (a) I love your plugin! and (b) unfortunately it doesn’t work with the WP Smilies themer plugin. Clicking more on a post that contains a smiley creates errors that say this:
Warning: preg_replace() [function.preg-replace]: Empty regular expression in /home/..etc../wp-content/plugins/smilies-themer/smilies-themer.php on line 95
Thoughts?