I have learned a gadoodle of information over the past 3 weeks of coding the update to CommentLuv and it would have gone a lot smoother had I known these 2 things.
Including jQuery with wp_enqueue_script
This seems to be simple at first but there is an important caveat to note.
You can include the jQuery library manually by echoing out a <script src=”… in your plugin code which works but could cause a problem if a user has changed their wp-content location or there are other plugins including jquery which would mean it gets loaded twice or more which isn’t ideal.
The solution is to use wp_enqueue_script but, it needs to be put in the right place!
If you use the wp_head action to call a function that has wp_enqueue_script in it then the library wont be included, using wp_head is too late in the render process for WP to put in the include.
Instead, I put wp_enqueue_script(‘jquery’); under the actions and hooks commands so it is run as early as possible in the execution of the plugin.

The plugins directory constant wp_plugin_dir
This has always tripped me up for some reason but it all became clear recently.
If you want to reference an image or js file in your plugins directory it is a lot better to use a constant than to put in an absolute url. I thought I had solved everything by using the constant WP_PLUGIN_DIR which works with WP2.6 and up but doesn’t work with WP2.5.1
What if you want to make it compatible with wp2.5? simple!, use this code in your plugin and you can use all the constants for WP2.6
if ( ! defined( 'WP_CONTENT_URL' ) )
define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
if ( ! defined( 'WP_CONTENT_DIR' ) )
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
if ( ! defined( 'WP_PLUGIN_URL' ) )
define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
if ( ! defined( 'WP_PLUGIN_DIR' ) )
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
23
New plugin to add snazziness to commentluv links
September29
I had a eureka! moment this morning as I was fighting to stay asleep even though I was busting for a pee, those moments in semi-dream state where if you’re careful you can ‘watch’ the dream happen
before you piss your pants.I get this quite a lot but people I tell don’t seem to (I’m sure witchypoo would know someone) so maybe I’m as nutty as the floor on a pistachio eating contest.
but back to eureka!… I saw a tooltip thing on someones name at a German blog last night, I couldn’t understand it but it must have stuck in my head because this morning I was dreaming of a big floaty tooltip with a spinning Gravatar in it and I couldn’t get it back in the net which, in the way that dreams like to play things, was representative of a folder of old code.
Now, a whole load more boring stuff happened too but, that was the bit that (with hindsight) got me tinkering with a jquery plugin called Jtip as soon as the coco-pops had been finished. I failed miserably and in desperation opened up Dreamweaver to try some javascript things only to find that the last file I had opened in the big D was a page I made that used Jtip! haha, I normally do all my coding in ZendStudio. I don’t know why I used Dreamweaver this time.. woooOHHHHoooo
Anyhooo, You can see the result of staying up too late doing code for too long and then getting psychotic with weird dreams where you’re a purple triangle and trying to turn it into a plugin….

When you hover over the little heart on the CommentLuv last blog posts, you get to see the members Gravatar and profile at commentluv.com if they’re a member and see how many times that link has been clicked before.
If the link owner isn’t a member of commentluv.com, they get how many times that link has been clicked and a message about commentluv.com
leave a comment and try it below!
Please note
If you use feedburner and your links point to your feedburner link then it wont be able to know who you are. See this post to switch off feedburner redirects.
Will be integrated to CommentLuv as an option
This should take about a day but I think it’s better to combine the two and have the little hearts as an option to be switched on by the user (not everyone likes tooltips!)
Blog News, Blog Tools, Code, PHP, Wordpress, ajax