<?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: [WordPress Plugin Development] How To Include CSS and JavaScript Conditionally And Only When Needed By The Posts</title> <atom:link href="http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/feed/" rel="self" type="application/rss+xml" /><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/</link> <description>where things have nothing to do with beer - tutorials, tips, how-tos, thoughts, hacks, and other techy nonsense</description> <lastBuildDate>Tue, 22 May 2012 20:57:44 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: bfintal</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52426</link> <dc:creator>bfintal</dc:creator> <pubDate>Thu, 08 Mar 2012 17:14:07 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52426</guid> <description>Typo. WP 3.3 now allows*</description> <content:encoded><![CDATA[<p>Typo. WP 3.3 now allows*</p> ]]></content:encoded> </item> <item><title>By: bfintal</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52425</link> <dc:creator>bfintal</dc:creator> <pubDate>Thu, 08 Mar 2012 17:13:04 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52425</guid> <description>WP 3.3 can now allows the calling of wp_enqueue_scripts() inside an add_shortcode()</description> <content:encoded><![CDATA[<p>WP 3.3 can now allows the calling of wp_enqueue_scripts() inside an add_shortcode()</p> ]]></content:encoded> </item> <item><title>By: CP Treasures</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52387</link> <dc:creator>CP Treasures</dc:creator> <pubDate>Thu, 16 Feb 2012 01:13:44 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52387</guid> <description>I really respect the opinion of the writer here. This article is thought provoking, to say the least...</description> <content:encoded><![CDATA[<p>I really respect the opinion of the writer here. This article is thought provoking, to say the least&#8230;</p> ]]></content:encoded> </item> <item><title>By: dentists london</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52325</link> <dc:creator>dentists london</dc:creator> <pubDate>Thu, 29 Dec 2011 10:00:25 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52325</guid> <description>A really helpfull post - A big thank you I hope you dont mind me blogging about this post on my website I will also leave a linkback Thanks</description> <content:encoded><![CDATA[<p>A really helpfull post &#8211; A big thank you I hope you dont mind me blogging about this post on my website I will also leave a linkback Thanks</p> ]]></content:encoded> </item> <item><title>By: Matth</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52289</link> <dc:creator>Matth</dc:creator> <pubDate>Sun, 11 Dec 2011 20:22:19 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52289</guid> <description>Phillip - this is awesome! Should save a lot of work and speed up the site quite a bit. Thanks for sharing your work!</description> <content:encoded><![CDATA[<p>Phillip &#8211; this is awesome! Should save a lot of work and speed up the site quite a bit. Thanks for sharing your work!</p> ]]></content:encoded> </item> <item><title>By: Matth</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52280</link> <dc:creator>Matth</dc:creator> <pubDate>Thu, 08 Dec 2011 20:44:15 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52280</guid> <description>I think the subject was once unpublished here:
http://www.position-relative.com/2010/01/wordpress-only-load-plugins-on-pages-that-need-them/</description> <content:encoded><![CDATA[<p>I think the subject was once unpublished here:<br
/> <a
href="http://www.position-relative.com/2010/01/wordpress-only-load-plugins-on-pages-that-need-them/" rel="nofollow">http://www.position-relative.com/2010/01/wordpress-only-load-plugins-on-pages-that-need-them/</a></p> ]]></content:encoded> </item> <item><title>By: Artem Russakovskii</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52222</link> <dc:creator>Artem Russakovskii</dc:creator> <pubDate>Sun, 13 Nov 2011 16:53:39 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52222</guid> <description>I&#039;ve updated the snippet.</description> <content:encoded><![CDATA[<p>I&#039;ve updated the snippet.</p> ]]></content:encoded> </item> <item><title>By: yzlow</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52221</link> <dc:creator>yzlow</dc:creator> <pubDate>Sun, 13 Nov 2011 12:34:05 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52221</guid> <description>this is very helpful and extremely important. webmaster, please correct your post.</description> <content:encoded><![CDATA[<p>this is very helpful and extremely important. webmaster, please correct your post.</p> ]]></content:encoded> </item> <item><title>By: adrian</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52206</link> <dc:creator>adrian</dc:creator> <pubDate>Mon, 07 Nov 2011 05:38:41 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52206</guid> <description>I would consider any such method that slims down the content delivered to all users, particularly at what seems like a small cost.
But it gets better. Given that anyone interested in performance installs caching of one sort or another, the overhead for your excellent method is near negligible.
The more users per cached content the better.</description> <content:encoded><![CDATA[<p>I would consider any such method that slims down the content delivered to all users, particularly at what seems like a small cost.<br
/> But it gets better. Given that anyone interested in performance installs caching of one sort or another, the overhead for your excellent method is near negligible.<br
/> The more users per cached content the better.</p> ]]></content:encoded> </item> <item><title>By: Saroj</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52085</link> <dc:creator>Saroj</dc:creator> <pubDate>Sat, 01 Oct 2011 17:12:15 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52085</guid> <description>Thanks Rickard, now its working</description> <content:encoded><![CDATA[<p>Thanks Rickard, now its working</p> ]]></content:encoded> </item> <item><title>By: Philip</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52073</link> <dc:creator>Philip</dc:creator> <pubDate>Wed, 28 Sep 2011 15:55:02 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52073</guid> <description>I was having a similar issue the other day, and all the existing plugins sucked, so I decided to write my own. I hope this helps someone!
http://philipwalton.com/2011/09/25/per-post-scripts-and-styles/</description> <content:encoded><![CDATA[<p>I was having a similar issue the other day, and all the existing plugins sucked, so I decided to write my own. I hope this helps someone!</p><p><a
href="http://philipwalton.com/2011/09/25/per-post-scripts-and-styles/" rel="nofollow">http://philipwalton.com/2011/09/25/per-post-scripts-and-styles/</a></p> ]]></content:encoded> </item> <item><title>By: 荒野无灯</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52072</link> <dc:creator>荒野无灯</dc:creator> <pubDate>Wed, 28 Sep 2011 11:55:20 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-52072</guid> <description>great idea.I&#039;ve translate this article to my language and modify some plugins I&#039;ve used now.</description> <content:encoded><![CDATA[<p>great idea.I&#039;ve translate this article to my language and modify some plugins I&#039;ve used now.</p> ]]></content:encoded> </item> <item><title>By: randy4</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51897</link> <dc:creator>randy4</dc:creator> <pubDate>Tue, 16 Aug 2011 11:14:21 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51897</guid> <description>Thanks for sharing your website with all of us, rather informative</description> <content:encoded><![CDATA[<p>Thanks for sharing your website with all of us, rather informative</p> ]]></content:encoded> </item> <item><title>By: The-Di-Lab</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51807</link> <dc:creator>The-Di-Lab</dc:creator> <pubDate>Tue, 19 Jul 2011 05:53:26 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51807</guid> <description>In official WordPress codex, it says &quot;Do not use wp_print_scripts.&quot;.
http://codex.wordpress.org/Function_Reference/wp_enqueue_script
But I see you are using this action over and over, can you explain why? Or it is a version sensitive issue?</description> <content:encoded><![CDATA[<p>In official WordPress codex, it says &#034;Do not use wp_print_scripts.&#034;.</p><p><a
href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" rel="nofollow">http://codex.wordpress.org/Function_Reference/wp_enqueue_script</a></p><p>But I see you are using this action over and over, can you explain why? Or it is a version sensitive issue?</p> ]]></content:encoded> </item> <item><title>By: Ian Dunn</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51761</link> <dc:creator>Ian Dunn</dc:creator> <pubDate>Fri, 01 Jul 2011 20:57:51 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51761</guid> <description>I found a way to deal with that problem. There isn&#039;t a practical way to detect if do_shortcode() is being called, so inside the shortcode handler you can just check if the scripts/styles have been enqueued. If they haven&#039;t then output an error message so that the theme developer knows they can&#039;t call do_shortcode() without also enqueueing the scripts manually, or telling the plugin which pages to load them on.
I&#039;ve written a more detailed explanation along with some code samples at http://iandunn.name/conditionally-loading-javascript-and-css-in-wordpress-plugins/.</description> <content:encoded><![CDATA[<p>I found a way to deal with that problem. There isn&#039;t a practical way to detect if do_shortcode() is being called, so inside the shortcode handler you can just check if the scripts/styles have been enqueued. If they haven&#039;t then output an error message so that the theme developer knows they can&#039;t call do_shortcode() without also enqueueing the scripts manually, or telling the plugin which pages to load them on.</p><p>I&#039;ve written a more detailed explanation along with some code samples at <a
href="http://iandunn.name/conditionally-loading-javascript-and-css-in-wordpress-plugins/" rel="nofollow">http://iandunn.name/conditionally-loading-javascript-and-css-in-wordpress-plugins/</a>.</p> ]]></content:encoded> </item> <item><title>By: สนามฟุตบอล</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51727</link> <dc:creator>สนามฟุตบอล</dc:creator> <pubDate>Tue, 21 Jun 2011 03:25:05 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51727</guid> <description>the only issue is that is seems to remove the new line to BR, so all th eformatign goes.</description> <content:encoded><![CDATA[<p>the only issue is that is seems to remove the new line to BR, so all th eformatign goes.</p> ]]></content:encoded> </item> <item><title>By: สนามฟุตบอล</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51726</link> <dc:creator>สนามฟุตบอล</dc:creator> <pubDate>Tue, 21 Jun 2011 03:23:25 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51726</guid> <description>loosely based on a post about conditionally loading JavaScript and CSS by Artem Russakovskii. He has a somewhat more com</description> <content:encoded><![CDATA[<p>loosely based on a post about conditionally loading JavaScript and CSS by Artem Russakovskii. He has a somewhat more com</p> ]]></content:encoded> </item> <item><title>By: Ronak</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51717</link> <dc:creator>Ronak</dc:creator> <pubDate>Fri, 17 Jun 2011 12:17:27 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51717</guid> <description>Great article.  Thank you so much.</description> <content:encoded><![CDATA[<p>Great article.  Thank you so much.</p> ]]></content:encoded> </item> <item><title>By: Ian Dunn</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51697</link> <dc:creator>Ian Dunn</dc:creator> <pubDate>Sat, 11 Jun 2011 20:04:12 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51697</guid> <description>The problem with this method is that it doesn&#039;t detect when people call do_shortcode() inside a template rather than inserting it into a post.</description> <content:encoded><![CDATA[<p>The problem with this method is that it doesn&#039;t detect when people call do_shortcode() inside a template rather than inserting it into a post.</p> ]]></content:encoded> </item> <item><title>By: Roger</title><link>http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51568</link> <dc:creator>Roger</dc:creator> <pubDate>Wed, 04 May 2011 18:42:16 +0000</pubDate> <guid
isPermaLink="false">http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/#comment-51568</guid> <description>Be aware that if your post contains just &quot;[code]&quot; and nothing else, then
stripos($post-&gt;post_content, &#039;[code]&#039;)
will return 0 (because the string is at position 0) which is evaluated to false. Try the following instead:
if (stripos($post-&gt;post_content, &#039;[code]&#039;) === false) {
$shortcode_found = false;
}
else
{
$shortcode_found = true; // bingo!
break;
}</description> <content:encoded><![CDATA[<p>Be aware that if your post contains just &#034;[code]" and nothing else, then</p><p> stripos($post-&gt;post_content, '[code]')</p><p>will return 0 (because the string is at position 0) which is evaluated to false. Try the following instead:</p><p> if (stripos($post-&gt;post_content, '[code]') === false) {<br
/> $shortcode_found = false;<br
/> }<br
/> else<br
/> {<br
/> $shortcode_found = true; // bingo!<br
/> break;<br
/> }</p> ]]></content:encoded> </item> </channel> </rss>
