<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FiddyP &#187; wp_content_dir</title>
	<atom:link href="http://fiddyp.co.uk/tag/wp_content_dir/feed/" rel="self" type="application/rss+xml" />
	<link>http://fiddyp.co.uk</link>
	<description>The personal blog of Andy Bailey</description>
	<lastBuildDate>Sun, 13 May 2012 15:28:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Some important things to note for WordPress plugin Authors</title>
		<link>http://fiddyp.co.uk/some-important-things-to-note-for-wordpress-plugin-authors/</link>
		<comments>http://fiddyp.co.uk/some-important-things-to-note-for-wordpress-plugin-authors/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 11:33:30 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[profit]]></category>
		<category><![CDATA[wp_content_dir]]></category>
		<category><![CDATA[wp_enqueue_script]]></category>
		<category><![CDATA[wp_plugin_dir]]></category>

		<guid isPermaLink="false">http://www.fiddyp.co.uk/?p=886</guid>
		<description><![CDATA[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 [..]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ffiddyp.co.uk%2Fsome-important-things-to-note-for-wordpress-plugin-authors%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ffiddyp.co.uk%2Fsome-important-things-to-note-for-wordpress-plugin-authors%2F&amp;source=commentluv&amp;style=normal&amp;service=bit.ly&amp;service_api=R_259b4e5679e2c431cca1f989e158bba4&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>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.</p>
<h3>Including jQuery with wp_enqueue_script</h3>
<p>This seems to be simple at first but there is an important caveat to note.</p>
<p>You can include the jQuery library manually by echoing out a <strong>&lt;script src=&#8221;&#8230;</strong> 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&#8217;t ideal.</p>
<p>The solution is to use <strong>wp_enqueue_script</strong> but, it needs to be put in the right place!</p>
<p>If you use the <strong>wp_head</strong> 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.</p>
<p>Instead, I put <strong>wp_enqueue_script(&#8216;jquery&#8217;);</strong> under the actions and hooks commands so it is run as early as possible in the execution of the plugin.<br />
<img src="http://fiddyp.co.uk/wp-content/uploads/2008/09/wp_enqueue_script.gif" alt="" width="500" height="178" class="aligncenter size-full wp-image-887" /></p>
<h3>The plugins directory constant wp_plugin_dir</h3>
<p>This has always tripped me up for some reason but it all became clear recently.</p>
<p>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 <strong>WP_PLUGIN_DIR</strong> which works with WP2.6 and up but doesn&#8217;t work with WP2.5.1 <img src='http://fiddyp.co.uk/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>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</p>
<p><code>if ( ! defined( 'WP_CONTENT_URL' ) )<br />
	define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );<br />
	if ( ! defined( 'WP_CONTENT_DIR' ) )<br />
	define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );<br />
	if ( ! defined( 'WP_PLUGIN_URL' ) )<br />
	define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );<br />
	if ( ! defined( 'WP_PLUGIN_DIR' ) )<br />
	define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );</code></p>
]]></content:encoded>
			<wfw:commentRss>http://fiddyp.co.uk/some-important-things-to-note-for-wordpress-plugin-authors/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

