• Hi,

    I am currently using the FeaturedContentGallery.com plugin. The script files are pretty big and putting a lot of load on my hosts GPUs. This scripts are only used on the homepage where the the content gallery is but the plugin is inserting them on every page. I found the code that inserts them and am trying to change it to only display on the homepage. Heres the code:

    function gallery_styles() {
    
        /* The next lines figures out where the javascripts and images and CSS are installed,
    
        relative to your wordpress server's root: */
    
        $gallery_path =  get_bloginfo('wpurl')."/wp-content/plugins/featured-content-gallery/";
    
        /* The xhtml header code needed for gallery to work: */
    
    	$galleryscript = "
    
    	<!-- begin gallery scripts -->
    
        <link rel=\"stylesheet\" href=\"".$gallery_path."css/jd.gallery.css.php\" type=\"text/css\" media=\"screen\" charset=\"utf-8\"/>
    
    	<link rel=\"stylesheet\" href=\"".$gallery_path."css/jd.gallery.css\" type=\"text/css\" media=\"screen\" charset=\"utf-8\"/>
    
    	<script type=\"text/javascript\" src=\"".$gallery_path."scripts/mootools.v1.11.js\"></script>
    
    	<script type=\"text/javascript\" src=\"".$gallery_path."scripts/jd.gallery.js.php\"></script>
    
    	<script type=\"text/javascript\" src=\"".$gallery_path."scripts/jd.gallery.transitions.js\"></script>
    
    	<!-- end gallery scripts -->\n";
    
    	/* Output $galleryscript as text for our web pages: */
    
    	echo($galleryscript);
    
    }

    And heres the code I tried but it didn’t work:

    function gallery_styles() {
    
        /* The next lines figures out where the javascripts and images and CSS are installed,
    
        relative to your wordpress server's root: */
    
        $gallery_path =  get_bloginfo('wpurl')."/wp-content/plugins/featured-content-gallery/";
    
        /* The xhtml header code needed for gallery to work: */
    
    	$galleryscript = "
    	<?php if is_home() { ?>
    	<!-- begin gallery scripts -->
    
        <link rel=\"stylesheet\" href=\"".$gallery_path."css/jd.gallery.css.php\" type=\"text/css\" media=\"screen\" charset=\"utf-8\"/>
    
    	<link rel=\"stylesheet\" href=\"".$gallery_path."css/jd.gallery.css\" type=\"text/css\" media=\"screen\" charset=\"utf-8\"/>
    
    	<script type=\"text/javascript\" src=\"".$gallery_path."scripts/mootools.v1.11.js\"></script>
    
    	<script type=\"text/javascript\" src=\"".$gallery_path."scripts/jd.gallery.js.php\"></script>
    
    	<script type=\"text/javascript\" src=\"".$gallery_path."scripts/jd.gallery.transitions.js\"></script>
    
    	<!-- end gallery scripts -->\n
    	<?php } else { } ?>";
    
    	/* Output $galleryscript as text for our web pages: */
    
    	echo($galleryscript);
    
    }

    Any suggestions or solutions?

    Thanks
    Grant

Viewing 2 replies - 1 through 2 (of 2 total)
  • BLichtenwalner

    (@blichtenwalner)

    I’m facing the same issue and have not found a solution yet. I planned to use is_Template() rather than is_Home() and will take a look at this area of code tonight. Any chance you’ve been successful since posting this and if so, can you share your solution here?

    BLichtenwalner

    (@blichtenwalner)

    This worked for me:

    Replaced this line from content-gallery.php:
    echo($galleryscript);
    With this line:
    if(is_home() || is_front_page()) echo($galleryscript);

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Featured Content Gallery Scripts in Header’ is closed to new replies.