Conditional Plugin Hack for Main page
-
Im trying to hack a plugin so that it only initiates on the home page by using an ‘is_home()’ conditional statement. It conflicts with a script I am trying to use on post pages. Unfortunately it doesn’t seem to be working and I don’t know why, here is the modified code I have been trying to use:
<?php if ( is_home() ) { 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); } function get_a_post($id='GETPOST') { global $post, $tableposts, $tablepostmeta, $wp_version, $wpdb; if($wp_version < 1.5) $table = $tableposts; else $table = $wpdb->posts; $now = current_time('mysql'); $name_or_id = ''; $orderby = 'post_date'; if( !$id || 'GETPOST' == $id || 'GETRANDOM' == $id ) { if( $wp_version < 2.1 ) $query_suffix = "post_status = 'publish'"; else $query_suffix = "post_type = 'post' AND post_status = 'publish'"; } elseif('GETPAGE' == $id) { if($wp_version < 2.1) $query_suffix = "post_status = 'static'"; else $query_suffix = "post_type = 'page' AND post_status = 'publish'"; } elseif('GETSTICKY' == $id) { if($wp_version < 1.5) $table .= ', ' . $tablepostmeta; else $table .= ', ' . $wpdb->postmeta; $query_suffix = "ID = post_id AND meta_key = 'sticky' AND meta_value = 1"; } else { $query_suffix = "(post_status = 'publish' OR post_status = 'static')"; if(is_numeric($id)) { $name_or_id = "ID = '$id' AND"; } else { $name_or_id = "post_name = '$id' AND"; } } if('GETRANDOM' == $id) $orderby = 'RAND()'; $post = $wpdb->get_row("SELECT * FROM $table WHERE $name_or_id post_date <= '$now' AND $query_suffix ORDER BY $orderby DESC LIMIT 1"); get_post_custom($post->ID); if($wp_version < 1.5) start_wp(); else setup_postdata($post); } /* we want to add the above xhtml to the header of our pages: */ add_action('wp_head', 'gallery_styles'); add_action('admin_menu', 'gallery_options_page'); } ?>Im not an experienced developer so I am sure my problem is probably pretty simple… Any ideas?
The topic ‘Conditional Plugin Hack for Main page’ is closed to new replies.