<?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: Load A Stylesheet Only If Use Gallery</title>
	<atom:link href="http://wpengineer.com/1949/load-a-stylesheet-only-if-use-gallery/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com/1949/load-a-stylesheet-only-if-use-gallery/</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Tue, 22 May 2012 12:01:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Adamski</title>
		<link>http://wpengineer.com/1949/load-a-stylesheet-only-if-use-gallery/#comment-6753</link>
		<dc:creator>Adamski</dc:creator>
		<pubDate>Mon, 14 Mar 2011 03:47:35 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=1949#comment-6753</guid>
		<description>I just had to do something similar - check if gallery is being used on a page and output a div if not.

I put this within

                                       &lt;code&gt; $page_data = get_page( $post-&gt;ID );
                                        $content = $page_data-&gt;post_content;
                                        $pos = strpos($content, &#039;[gallery]&#039; );
                                        if( $pos === false ) {
                                                $found = false;
                                        } else {
                                                $found = true;
                                        }&lt;/code&gt;


Then you can do your conditionals..</description>
		<content:encoded><![CDATA[<p>I just had to do something similar - check if gallery is being used on a page and output a div if not.</p>
<p>I put this within</p>
<p>                                       <code> $page_data = get_page( $post-&gt;ID );<br />
                                        $content = $page_data-&gt;post_content;<br />
                                        $pos = strpos($content, '[gallery]' );<br />
                                        if( $pos === false ) {<br />
                                                $found = false;<br />
                                        } else {<br />
                                                $found = true;<br />
                                        }</code></p>
<p>Then you can do your conditionals..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Numaga</title>
		<link>http://wpengineer.com/1949/load-a-stylesheet-only-if-use-gallery/#comment-6552</link>
		<dc:creator>Numaga</dc:creator>
		<pubDate>Wed, 16 Feb 2011 22:28:00 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=1949#comment-6552</guid>
		<description>So were do I put those codes exactly? I&#039;m looking for ways to minimize the pageload on my home page and this gallery plugin is the first thing that needs to go. Thing is I&#039;m not really a coding guru, I would like to have a file and location where to put it and I&#039;ll be okay ;)

Thanks in advance.</description>
		<content:encoded><![CDATA[<p>So were do I put those codes exactly? I'm looking for ways to minimize the pageload on my home page and this gallery plugin is the first thing that needs to go. Thing is I'm not really a coding guru, I would like to have a file and location where to put it and I'll be okay <img src='http://wpengineer.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://wpengineer.com/1949/load-a-stylesheet-only-if-use-gallery/#comment-6335</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Sat, 15 Jan 2011 21:13:40 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=1949#comment-6335</guid>
		<description>Found one trivial little fix.  This fails if the shortcode is the first thing in the post content.  stripos would return 0 so the if wouldn&#039;t fire.  Changing it to !== false fixed it. 

Admittedly a pretty unlikely deal, but I&#039;m working on a plugin and the test post had the shortcode as the only content.</description>
		<content:encoded><![CDATA[<p>Found one trivial little fix.  This fails if the shortcode is the first thing in the post content.  stripos would return 0 so the if wouldn't fire.  Changing it to !== false fixed it. </p>
<p>Admittedly a pretty unlikely deal, but I'm working on a plugin and the test post had the shortcode as the only content.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: beachbum</title>
		<link>http://wpengineer.com/1949/load-a-stylesheet-only-if-use-gallery/#comment-4783</link>
		<dc:creator>beachbum</dc:creator>
		<pubDate>Fri, 13 Aug 2010 20:13:58 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=1949#comment-4783</guid>
		<description>Trying to get this technique to work with the Audio-player plugin( http://wordpress.org/extend/plugins/audio-player/ ).

It uses addHeaderCode() and addFooterCode() too insert.

Could you point me in the right direction please?</description>
		<content:encoded><![CDATA[<p>Trying to get this technique to work with the Audio-player plugin( <a href="http://wordpress.org/extend/plugins/audio-player/" rel="nofollow">http://wordpress.org/extend/plugins/audio-player/</a> ).</p>
<p>It uses addHeaderCode() and addFooterCode() too insert.</p>
<p>Could you point me in the right direction please?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://wpengineer.com/1949/load-a-stylesheet-only-if-use-gallery/#comment-3369</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Tue, 26 Jan 2010 15:04:09 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=1949#comment-3369</guid>
		<description>@Ted: yes, correctly and how you load your css, always or only when you add the shortcode in the content?</description>
		<content:encoded><![CDATA[<p>@Ted: yes, correctly and how you load your css, always or only when you add the shortcode in the content?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://wpengineer.com/1949/load-a-stylesheet-only-if-use-gallery/#comment-3367</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Tue, 26 Jan 2010 14:49:06 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=1949#comment-3367</guid>
		<description>@Justin: thanks for your reply and your hint to this small code tipps. Yes, you have right, this works only when use the shortcode on post content: On my own solutions i add a metabox to the editor with a radiobutton or checkbox to add js or css for custom solutions.</description>
		<content:encoded><![CDATA[<p>@Justin: thanks for your reply and your hint to this small code tipps. Yes, you have right, this works only when use the shortcode on post content: On my own solutions i add a metabox to the editor with a radiobutton or checkbox to add js or css for custom solutions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ted</title>
		<link>http://wpengineer.com/1949/load-a-stylesheet-only-if-use-gallery/#comment-3366</link>
		<dc:creator>Ted</dc:creator>
		<pubDate>Tue, 26 Jan 2010 14:48:31 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=1949#comment-3366</guid>
		<description>I put this code in function.php

&lt;code&gt;
function remove_gallery_css()
{
	return &quot;&quot;;
}
add_filter(&#039;gallery_style&#039;, &#039;remove_gallery_css&#039;);


&lt;/code&gt;

so I can style my gallery in my stylesheet</description>
		<content:encoded><![CDATA[<p>I put this code in function.php</p>
<p><code><br />
function remove_gallery_css()<br />
{<br />
	return "";<br />
}<br />
add_filter('gallery_style', 'remove_gallery_css');</code></p>
<p></p>
<p>so I can style my gallery in my stylesheet</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin Tadlock</title>
		<link>http://wpengineer.com/1949/load-a-stylesheet-only-if-use-gallery/#comment-3365</link>
		<dc:creator>Justin Tadlock</dc:creator>
		<pubDate>Tue, 26 Jan 2010 14:04:52 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=1949#comment-3365</guid>
		<description>This only works in the case of the shortcode being in the post content.  It doesn&#039;t take into account that users may put the gallery in other places on their page (other shortcode-ready areas).  I&#039;ve seen a few posts on checking the post content before loading JavaScript and CSS lately.  All of them make the assumption that users only add stuff to their post content.

But, the solution I like the most is to simply add the gallery styles to the theme&#039;s &lt;code&gt;style.css&lt;/code&gt; file.  I also like just making one JavaScript file (jQuery, usually), and only having to load it.

Also, for anyone using child themes, you need to replace &lt;code&gt;get_bloginfo(&#039;template_directory&#039;)&lt;/code&gt; with &lt;code&gt;get_stylesheet_directory_uri()&lt;/code&gt; for this tutorial.  This also works when not using a child theme.</description>
		<content:encoded><![CDATA[<p>This only works in the case of the shortcode being in the post content.  It doesn't take into account that users may put the gallery in other places on their page (other shortcode-ready areas).  I've seen a few posts on checking the post content before loading JavaScript and CSS lately.  All of them make the assumption that users only add stuff to their post content.</p>
<p>But, the solution I like the most is to simply add the gallery styles to the theme's <code>style.css</code> file.  I also like just making one JavaScript file (jQuery, usually), and only having to load it.</p>
<p>Also, for anyone using child themes, you need to replace <code>get_bloginfo('template_directory')</code> with <code>get_stylesheet_directory_uri()</code> for this tutorial.  This also works when not using a child theme.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

