<?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, 23 May 2012 13:43:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Alex</title>
		<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/comment-page-2/#comment-198083</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Wed, 23 May 2012 13:43:53 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-198083</guid>
		<description>Hi,
I was wondering if my method is good.
I am using :
add_options_page(&#039;Plugin settings&#039;, &#039;my plugin&#039;, &#039;manage_options&#039;, &#039;my-plugin&#039;, array(&amp;$this,&#039;adk_pro_setting&#039;) );

so when i add the options page in the settings i also have the callback function which is adding all the css and js:
      wp_enqueue_script(&#039;itoggle&#039;,plugins_url(&#039;js/jquery.ibutton.min.js&#039;, __FILE__), array(&#039;jquery&#039;));
      wp_register_style( &#039;fbc-style&#039;, plugins_url(&#039;css/backend.css&#039;, __FILE__) );
      wp_enqueue_style( &#039;fbc-style&#039; );
      include &#039;settings.php&#039;;
I checked out and it seems like i have the css and js only in my plugin pages.
Any suggestions?
Thank you</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I was wondering if my method is good.<br />
I am using :<br />
add_options_page(&#8216;Plugin settings&#8217;, &#8216;my plugin&#8217;, &#8216;manage_options&#8217;, &#8216;my-plugin&#8217;, array(&amp;$this,&#8217;adk_pro_setting&#8217;) );</p>
<p>so when i add the options page in the settings i also have the callback function which is adding all the css and js:<br />
      wp_enqueue_script(&#8216;itoggle&#8217;,plugins_url(&#8216;js/jquery.ibutton.min.js&#8217;, __FILE__), array(&#8216;jquery&#8217;));<br />
      wp_register_style( &#8216;fbc-style&#8217;, plugins_url(&#8216;css/backend.css&#8217;, __FILE__) );<br />
      wp_enqueue_style( &#8216;fbc-style&#8217; );<br />
      include &#8216;settings.php&#8217;;<br />
I checked out and it seems like i have the css and js only in my plugin pages.<br />
Any suggestions?<br />
Thank you</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-2/#comment-197874</link>
		<dc:creator>Brian Hogg</dc:creator>
		<pubDate>Thu, 15 Mar 2012 11:33:59 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-197874</guid>
		<description>@ Martin

Have you tried doing something like this for your other scripts?

[php]
	wp_register_script( &#039;yourscript.js&#039;, plugins_url( &#039;static/js/yourscript.js&#039;, __FILE__ ), array( &#039;jquery&#039;, &#039;jquery-ui-core&#039; ), VERSION );
	wp_enqueue_script( &#039;yourscript.js&#039; );
[/php]

This ensures the scripts you&#039;ve created that depend on jquery-ui-core and others get loaded in the proper order.</description>
		<content:encoded><![CDATA[<p>@ Martin</p>
<p>Have you tried doing something like this for your other scripts?</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;">wp_register_script<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'yourscript.js'</span>, plugins_url<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'static/js/yourscript.js'</span>, <span style="color:#000000; font-weight:bold;">__FILE__</span> <span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#000066;">array</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'jquery'</span>, <span style="color:#FF0000;">'jquery-ui-core'</span> <span style="color:#006600; font-weight:bold;">&#41;</span>, VERSION <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_script<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'yourscript.js'</span> <span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This ensures the scripts you've created that depend on jquery-ui-core and others get loaded in the proper order.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/comment-page-2/#comment-197873</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Thu, 15 Mar 2012 04:43:27 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-197873</guid>
		<description>Great post have been looking for this.  I did run into an issue though using your exact word for word plugin I tried to load 

	wp_enqueue_script( &#039;jquery-ui-core&#039; );
	wp_enqueue_script( &#039;jquery-ui-accordion&#039; );

which I&#039;ve been having a hell of a time loading in my plugin page and it still doesn&#039;t work.  Any ideas why this might be I can&#039;t find a solution anywhere and yours seemed soooo right... almost :)  Only if you have time, thanks either way I&#039;ve started loading my custom scripts like you&#039;ve posted.</description>
		<content:encoded><![CDATA[<p>Great post have been looking for this.  I did run into an issue though using your exact word for word plugin I tried to load </p>
<p>	wp_enqueue_script( 'jquery-ui-core' );<br />
	wp_enqueue_script( 'jquery-ui-accordion' );</p>
<p>which I've been having a hell of a time loading in my plugin page and it still doesn't work.  Any ideas why this might be I can't find a solution anywhere and yours seemed soooo right... almost :)  Only if you have time, thanks either way I've started loading my custom scripts like you've posted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: satya</title>
		<link>http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/comment-page-1/#comment-197820</link>
		<dc:creator>satya</dc:creator>
		<pubDate>Sat, 03 Mar 2012 20:58:50 +0000</pubDate>
		<guid isPermaLink="false">http://planetozh.com/blog/?p=784#comment-197820</guid>
		<description>I&#039;ve some problem with the plugin. Can someone have time to take a look at what am I doing wrong? :(

I would appreciate all your help.

Thanks
Satya</description>
		<content:encoded><![CDATA[<p>I've some problem with the plugin. Can someone have time to take a look at what am I doing wrong? :(</p>
<p>I would appreciate all your help.</p>
<p>Thanks<br />
Satya</p>
]]></content:encoded>
	</item>
	<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-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;"><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>
</channel>
</rss>

