<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: How To: Load Javascript With Your WordPress Plugin</title>
	<atom:link href="http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/?source=rss</link>
	<description>A bit of my personal life, mainly focused on my kids. A bit of code, mainly focused on Wordpress and PHP. Overall, bits of nothing in particular.</description>
	<lastBuildDate>Wed, 08 Feb 2012 20:57:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Boyko Todorov</title>
		<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/comment-page-1/#comment-197662</link>
		<dc:creator>Boyko Todorov</dc:creator>
		<pubDate>Sat, 21 Jan 2012 18:24:11 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-197662</guid>
		<description>Hey man,
Thanks! Your post helped me!
Take care!</description>
		<content:encoded><![CDATA[<p>Hey man,<br />
Thanks! Your post helped me!<br />
Take care!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Hogg</title>
		<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/comment-page-1/#comment-197379</link>
		<dc:creator>Brian Hogg</dc:creator>
		<pubDate>Sun, 18 Dec 2011 21:52:47 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-197379</guid>
		<description>@ Steve

Thanks for the heads up!</description>
		<content:encoded><![CDATA[<p>@ Steve</p>
<p>Thanks for the heads up!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve B.</title>
		<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/comment-page-1/#comment-197378</link>
		<dc:creator>Steve B.</dc:creator>
		<pubDate>Sun, 18 Dec 2011 15:34:54 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-197378</guid>
		<description>Brian, instead of admin_print_style-, you might start moving toward using the admin_enqueue_scripts instead, according to the update to WP:

http://wpdevel.wordpress.com/2011/12/12/use-wp_enqueue_scripts-not-wp_print_styles-to-enqueue-scripts-and-styles-for-the-frontend/

Just a thought
Steve</description>
		<content:encoded><![CDATA[<p>Brian, instead of admin_print_style-, you might start moving toward using the admin_enqueue_scripts instead, according to the update to WP:</p>
<p><a href="http://wpdevel.wordpress.com/2011/12/12/use-wp_enqueue_scripts-not-wp_print_styles-to-enqueue-scripts-and-styles-for-the-frontend/" rel="nofollow">http://wpdevel.wordpress.com/2011/12/12/use-wp_enqueue_scripts-not-wp_print_styles-to-enqueue-scripts-and-styles-for-the-frontend/</a></p>
<p>Just a thought<br />
Steve</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Hogg</title>
		<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/comment-page-1/#comment-193126</link>
		<dc:creator>Brian Hogg</dc:creator>
		<pubDate>Sat, 17 Sep 2011 22:46:25 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-193126</guid>
		<description>Rather than hard-coding the style HTML in the example, can use the admin_print_styles-$mypage hook instead.  Something like:

[php]
function ozh_loadjs_add_page() {
	$mypage = add_options_page(&#039;Load JS Example&#039;, &#039;Load JS Example&#039;, 8, &#039;loadjsexample&#039;, &#039;ozh_loadjs_options_page&#039;);
	add_action( &quot;admin_print_scripts-$mypage&quot;, &#039;ozh_loadjs_admin_head&#039; );
	add_action( &quot;admin_print_styles-$mypage&quot;, &#039;ozh_loadcss_admin_head&#039; );
}

function ozh_loadjs_admin_head() {
	$plugindir = get_settings(&#039;home&#039;).&#039;/wp-content/plugins/&#039;.dirname(plugin_basename(__FILE__));
	wp_enqueue_script(&#039;loadjs&#039;, $plugindir . &#039;/example.js&#039;);
}

function ozh_loadcss_admin_head() {
	$plugindir = get_settings(&#039;home&#039;).&#039;/wp-content/plugins/&#039;.dirname(plugin_basename(__FILE__));
	wp_enqueue_style(&#039;loadcss&#039;, $plugindir . &#039;/example.css&#039;);
}
[/php]</description>
		<content:encoded><![CDATA[<p>Rather than hard-coding the style HTML in the example, can use the admin_print_styles-$mypage hook instead.  Something like:</p>
<div class="igBar"><span id="lphp-1"><a href="#" onclick="javascript:showPlainTxt('php-1'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-1">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> ozh_loadjs_add_page<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$mypage</span> = add_options_page<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Load JS Example'</span>, <span style="color:#FF0000;">'Load JS Example'</span>, <span style="color:#CC66CC;color:#800000;">8</span>, <span style="color:#FF0000;">'loadjsexample'</span>, <span style="color:#FF0000;">'ozh_loadjs_options_page'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; add_action<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"admin_print_scripts-$mypage"</span>, <span style="color:#FF0000;">'ozh_loadjs_admin_head'</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; add_action<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"admin_print_styles-$mypage"</span>, <span style="color:#FF0000;">'ozh_loadcss_admin_head'</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> ozh_loadjs_admin_head<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$plugindir</span> = get_settings<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'home'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#FF0000;">'/wp-content/plugins/'</span>.<span style="color:#000066;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span>plugin_basename<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; wp_enqueue_script<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'loadjs'</span>, <span style="color:#0000FF;">$plugindir</span> . <span style="color:#FF0000;">'/example.js'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> ozh_loadcss_admin_head<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$plugindir</span> = get_settings<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'home'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#FF0000;">'/wp-content/plugins/'</span>.<span style="color:#000066;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span>plugin_basename<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; wp_enqueue_style<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'loadcss'</span>, <span style="color:#0000FF;">$plugindir</span> . <span style="color:#FF0000;">'/example.css'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brasofilo</title>
		<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/comment-page-1/#comment-190242</link>
		<dc:creator>brasofilo</dc:creator>
		<pubDate>Sat, 10 Sep 2011 21:37:17 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-190242</guid>
		<description>cool, i was using some &#039;brute force&#039; methods to avoid loading in pages where my plugin doesn&#039;t belong... now it&#039;s crystal clear, thX!</description>
		<content:encoded><![CDATA[<p>cool, i was using some 'brute force' methods to avoid loading in pages where my plugin doesn't belong... now it's crystal clear, thX!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anjan Bhowmik</title>
		<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/comment-page-1/#comment-172292</link>
		<dc:creator>Anjan Bhowmik</dc:creator>
		<pubDate>Mon, 18 Jul 2011 04:12:26 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-172292</guid>
		<description>Hi!

Thanks for the info, i have found it very useful. Now i have a question. 

How do i add my scripts to the public pages containing my plugin only? so if only in one page/post my plugin is used, the plugin script will be added only on that page/post and nowhere else.

Thanks,
Anjan</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>Thanks for the info, i have found it very useful. Now i have a question. </p>
<p>How do i add my scripts to the public pages containing my plugin only? so if only in one page/post my plugin is used, the plugin script will be added only on that page/post and nowhere else.</p>
<p>Thanks,<br />
Anjan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Born</title>
		<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/comment-page-1/#comment-155845</link>
		<dc:creator>Matthew Born</dc:creator>
		<pubDate>Tue, 10 May 2011 20:40:46 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-155845</guid>
		<description>This is exactly what I have been looking for. Thanks!</description>
		<content:encoded><![CDATA[<p>This is exactly what I have been looking for. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ozh</title>
		<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/comment-page-1/#comment-140330</link>
		<dc:creator>Ozh</dc:creator>
		<pubDate>Mon, 31 Jan 2011 21:49:21 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-140330</guid>
		<description>Rem » there might be a more elegant &amp; concise solution (I&#039;ll dig) but this is pretty good I think: load a custom JS on the write page of a custom post type &#039;my_cpt&#039;:

[php]
add_action( &#039;load-post-new.php&#039;, &#039;ozh_insertjs_on_cpt&#039; );
function ozh_insertjs_on_cpt() {
	global $current_screen;
	if( $current_screen-&gt;post_type == &#039;my_cpt&#039; );
	      wp_enqueue_script( &#039;ozh_cpt_js&#039;, &#039;http://bleh/script.js&#039; );
}
[/php]</description>
		<content:encoded><![CDATA[<p>Rem » there might be a more elegant &#038; concise solution (I'll dig) but this is pretty good I think: load a custom JS on the write page of a custom post type 'my_cpt':</p>
<div class="igBar"><span id="lphp-2"><a href="#" onclick="javascript:showPlainTxt('php-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-2">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">add_action<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'load-post-new.php'</span>, <span style="color:#FF0000;">'ozh_insertjs_on_cpt'</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> ozh_insertjs_on_cpt<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000066;">global</span> <span style="color:#0000FF;">$current_screen</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$current_screen</span>-&gt;<span style="color:#006600;">post_type</span> == <span style="color:#FF0000;">'my_cpt'</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;wp_enqueue_script<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'ozh_cpt_js'</span>, <span style="color:#FF0000;">'<a href="http://bleh/script.js&#039;" rel="nofollow">http://bleh/script.js&#039;</a></span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rem</title>
		<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/comment-page-1/#comment-140305</link>
		<dc:creator>Rem</dc:creator>
		<pubDate>Mon, 31 Jan 2011 16:59:53 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-140305</guid>
		<description>Hi,

Love this post, have been using this information with great success for my plugin development. I would need to ask a question though: in order to add Javascript or CSS to plugin pages only it is very easy indeed to do it with admin_print_scripts-(page_hook) when using functions like add_options_page() . What about if I am registering a new post type ( register_post_type() ) ?

Thanks!</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Love this post, have been using this information with great success for my plugin development. I would need to ask a question though: in order to add Javascript or CSS to plugin pages only it is very easy indeed to do it with admin_print_scripts-(page_hook) when using functions like add_options_page() . What about if I am registering a new post type ( register_post_type() ) ?</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/comment-page-1/#comment-122234</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Sat, 04 Sep 2010 02:56:20 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-122234</guid>
		<description>Helpful post, but not great by any means.  You should edit this post to include Artem Russakovskii&#039;s comments in the actual post.  Where you are telling people to echo the link tag in the header, the proper way to do it as Artem showed is to use the  admin_print_styles-[name] action and wp_enqueue_style.

Also, you incorrectly replied to Matt &quot;This doesnt make a difference&quot; with his question about how this changes when using a class -- also addressed in Artem&#039;s comment by passing an array with a reference to the class instance to the wp_enqueue_[*] function.</description>
		<content:encoded><![CDATA[<p>Helpful post, but not great by any means.  You should edit this post to include Artem Russakovskii's comments in the actual post.  Where you are telling people to echo the link tag in the header, the proper way to do it as Artem showed is to use the  admin_print_styles-[name] action and wp_enqueue_style.</p>
<p>Also, you incorrectly replied to Matt "This doesnt make a difference" with his question about how this changes when using a class -- also addressed in Artem's comment by passing an array with a reference to the class instance to the wp_enqueue_[*] function.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

