WordPress.org

Ready to get started?Download WordPress

Forums

Pagebar plugin in 2.7 ruining my site (1 post)

  1. truetrev
    Member
    Posted 5 years ago #

    My site is breaking at the pagebar plugin point in my template. When I have the pagebar active my site doesnt even load an endless loop keeps going on and on. When I deactivate the pagebar plugin the site loads but stops at the pagebar point near the footer (see: http://70.32.94.182/). When I remove the pagebar code from index the site refuses to load as well. I can't seem to figure it out hellllllp.

    CODE:
    INDEX.PHP

    <?php get_header(); ?>
    
    <!-- Main Column -->
    <?php include (TEMPLATEPATH . '/leftbar.php'); ?>
    <div id="main"><img src="<?php bloginfo('template_url'); ?>/images/blog.gif" alt="" width="420" height="10" /><div id="content"><div id="primarycontainer">
    
    <?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
    
    <?php if(function_exists('cmd_show_avatar')){ cmd_show_avatar(); } ?><h1><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('<h2>', '</h2>'); ?></a><span class="sub">Author: <b><?php the_author() ?> </b> ||  </span>
              <span class="sub"><?php the_time('d. F Y') ?></span></h1><br />
    
    <div class="contentarea"><div class="entry"><?php the_content('Read More &raquo;'); ?></div>
    
                              <div style="text-align:right">
                                <p><span class="minihead_news"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permalink">Permalink</a> | <?php comments_popup_link('Add A Comment', '1 Comment', '% Comments'); ?></span></p>    </div>
                           </div>
    				<div class="divider2"></div>
    
    				<?php endwhile; ?>
                    <div style="margin-bottom:10px;">
    				 <?php wp_pagebar(array('before'=>'Pages: '))?></div>
    				 <div class="divider2"></div>
    				<p><a href="#">Contact</a> | &copy; Copyright by <?php bloginfo('name'); ?>. Design by <a href="http://www.eatskeet.com" target="blank" >DJ Skeet Skeet</a>.</p><br />
    				<?php else : ?>
    
    				<h2 class="center">Not Found</h2>
    				<p class="center">Sorry, but you are looking for something that isn't here.</p>
    				<?php endif; ?>
    
    				<!-- Primary content area end -->
    
    		</div></div></div>
      <br />
    
    <?php get_footer(); ?>
    
    <?php get_sidebar(); ?>
    </div></div>
    </body>
    </html>

    PAGEBAR PLUGIN CODE

    -------------------------------------------------------------------------------------------- */
    function pb_transit($place) {
    	global $pbOptions;
    
    	if ($place > 0)
    		echo '<span class="break">';
    	echo $pbOptions ["connect"] !== "" ? $pbOptions ["connect"] : '...';
    	echo '</span>';
    }
    // -----------------------------------------------------------------------------
    function pb_replaceFirstLast($page) {
    	global $pbOptions, $max_page;
    	switch ( $page) {
    		case 1 :
    			return $pbOptions ['first'];
    		case $max_page :
    			return $pbOptions ['last'];
    		default :
    			return $page;
    	}
    }
    // -----------------------------------------------------------------------------
    function pb_tagReplace($text,$page) {
    	global $max_page;
    
    	$text = str_replace ( "{page}", $page, $text );
    	$text = str_replace ( "{current}", $page, $text );
    	$text = str_replace ( "{total}", $max_page, $text );
    	return $text;
    }
    // -----------------------------------------------------------------------------
    // display tooltips
    function pb_tooltip($page) {
    	global $pbOptions;
    	if ($pbOptions ["tooltips"])
    		return ' title="' . pb_tagReplace ( $pbOptions ["tooltipText"], $page ) . '"';
    	return "";
    }
    // -----------------------------------------------------------------------------
    function page($page) {
    
    	echo pb_tagReplace ( '<a href="' . get_pagenum_link ( $page ) . '"' . pb_tooltip ( $page ) . '>' . pb_replaceFirstLast ( $page ) . "</a>\n", $page );
    }
    // -----------------------------------------------------------------------------
    function pb_thisPage($page) {
    
    	echo pb_tagReplace ( '<span class="this-page">' . pb_replaceFirstLast ( $page ) . "</span>\n", $page );
    }
    // -----------------------------------------------------------------------------
    function pb_previousPage($paged) {
    	global $pbOptions;
    
    	if ($pbOptions ["pdisplay"] == "never")
    		return;
    
    	if (($paged == 1) && ($pbOptions ["pdisplay"] == "auto"))
    		return;
    
    	$text = $pbOptions ["prev"];
    	echo ($paged == 1) ? '<span class="inactive">' . $text . "</span>\n" : '<a href="' . get_pagenum_link ( $paged - 1 ) . '"' . pb_tooltip ( $paged - 1 ) . '>' . $text . "</a>\n";
    }
    // -----------------------------------------------------------------------------
    function pb_nextPage($paged,$max_page) {
    	global $pbOptions;
    
    	if ($pbOptions ["pdisplay"] == "never")
    		return;
    	if (($paged == $max_page) && ($pbOptions ["ndisplay"] == "auto"))
    		return;
    	$text = $pbOptions ["next"];
    	echo ($paged == $max_page) ? '<span class="inactive">' . $text . "</span>\n" : '<a href="' . get_pagenum_link ( $paged + 1 ) . '"' . pb_tooltip ( $paged + 1 ) . '>' . $text . "</a>\n";
    }
    // -----------------------------------------------------------------------------
    
    // -----------------------------------------------------------------------------
    
    function wp_pagebar() {
    	global $paged, $wp_query, $pbOptions, $max_page,$dir;
    
    	if ($wp_query->is_feed) // no need for pagebar in feed
    		return;
    
      if (is_admin())
        return;   // since WP2.5 got it's own admin pagebar
    
    	$showAll = 0;
    	$left = $pbOptions ["left"];
    	$center = $pbOptions ["center"];
    	$right = $pbOptions ["right"];
    
    	if (is_single () || is_page ()) //no need to display pagebar on a single post page
    		return;
    
    	$max_page = $wp_query->max_num_pages; // get number of pages. ONLY WP >= 2.1!!!
    
    	if ($max_page <= 1) // only one page -> don't display pagebar
    		return;
    
    	if (empty ( $paged )) // If we're on the first page the var $paged is not set.
    		$paged = 1;
    
    	echo "<!-- pb221 -->";
    	echo '<div class="pagebar">';
    
    	echo pb_tagReplace ( $pbOptions ["pbText"], $paged ) . '&nbsp;';
    
    	// it's easy to show all page numbers:
    	// simply loop and  exit
    	if (($showAll) || ($max_page <= $left + $center + $right)) {
    		pb_previousPage ( $paged );
    		for($i = 1; $i <= $max_page; $i ++)
    			if ($i == $paged)
    				pb_thisPage ( $i ); else
    				page ( $i );
    		pb_nextPage ( $paged, $max_page );
    		echo "</div>";
    		return;
    	} //if
    
    	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    
    	// left and right
    	if ($paged < $left + $center) {
    		//left
    		pb_previousPage ( $paged );
    		$lc = $left + $center;
    		for($i = 1; $i <= ($lc); $i ++)
    			if ($i == $paged)
    				pb_thisPage ( $i ); else
    				page ( $i );
    
    		// right
    		pb_transit ( $right );
    		for($i = $max_page - $right + 1; $i <= $max_page; $i ++)
    			page ( $i );
    		pb_nextPage ( $paged, $max_page );
    	} else 
    
    	// left, right and center
    	if (($paged >= $left + $center) && ($paged < $max_page - $right - $center + 1)) {
    		//left
    		pb_previousPage ( $paged );
    		for($i = 1; $i <= $left; $i ++)
    			page ( $i );
    		pb_transit ( $left );
    
    		//center
    		$c = floor ( $center / 2 );
    		for($i = $paged - $c; $i <= $paged + $c; $i ++)
    			if ($i == $paged)
    				pb_thisPage ( $i ); else
    				page ( $i );
    
    		// right
    		pb_transit ( $right );
    		for($i = $max_page - $right + 1; $i <= $max_page; $i ++)
    			page ( $i );
    		pb_nextPage ( $paged, $max_page );
    	} else 
    
    	// only left and right
    	{
    		//left
    		pb_previousPage ( $paged );
    		for($i = 1; $i <= $left; $i ++)
    			page ( $i );
    		pb_transit ( $left );
    
    		// right
    		for($i = $max_page - $right - $center; $i <= $max_page; $i ++)
    			if ($i == $paged)
    				pb_thisPage ( $i ); else
    				page ( $i );
    		pb_nextPage ( $paged, $max_page );
    	}
    
    	echo "</div>";
    
    } //function
    
    /* --------------------------------------------------------------------------- */
    function pb_admin_menu() {
      global $dir;
    
    	if (function_exists ( 'add_options_page' ))
    		add_options_page ( 'Pagebar', 'Pagebar', 'manage_options', $dir.'/pboptions.php' );
    }
    /* ---------------------------------------------------------------------------- */
    function pb_remove_nav() {
    	if (! is_single ())
    		echo "\n<style type=\"text/css\">.navigation{display: none;}</style>\n";
    }
    /* ---------------------------------------------------------------------------- */
    function pb_add_stylesheet() {
    	global $pbOptions;
    
    	if ($pbOptions ["stylesheet"] == "styleCss")
    		return;
    	$url = get_bloginfo ( 'stylesheet_directory' ) . '/' . $pbOptions ["cssFilename"];
    	echo "\n\t<link rel=\"stylesheet\" href=\"" . $url . '" ' . "type=\"text/css\" media=\"screen\" />\n";
    }
    /* ---------------------------------------------------------------------------- */
    function pagebar_activate() {
    
    	if (! get_option ( 'pagebar' ))
    		add_option ( 'pagebar', array ("left" => 3, "center" => 5, "right" => 3, "pbText" => "Pages:", "remove" => "on", "standard" => "{page}", "current" => "{page}", "first" => "{page}", "last" => "{page}", "connect" => "...", "next" => "Next", "prev" => "Prev", "auto" => "", "tooltipText" => "Page {page}", "tooltips" => "on", "bef_loop" => "", "aft_loop" => "on", "footer" => "", "pdisplay" => "auto", "ndisplay" => "auto", "stylesheet" => "styleCss", "cssFilename" => "pagebar.css" ) );
    
    }
    /* ---------------------------------------------------------------------------- */
    function pagebar_init() {
    	global $dir;
    	load_plugin_textdomain ( 'pagebar', 'wp-content/plugins/'.$dir.'/language' );
    }
    
    /* ---------------------------------------------------------------------------- */
    function pb_load_jquery() {
      wp_enqueue_script ( 'jquery' );
    }
    /* ---------------------------------------------------------------------------- */
    
    {
    
      $pbOptions = get_option ( 'pagebar' );
      $dir = (file_exists( ABSPATH . PLUGINDIR . '/pagebar2/pboptions.php'))?'pagebar2':'pagebar';
    
    	add_action ( 'activate_'.$dir.'/pagebar2.php', 'pagebar_activate' );
    	add_action ( 'init', 'pagebar_init' );
    	add_action ( 'admin_menu', 'pb_admin_menu');
    	add_action ( 'wp_head', 'pb_add_stylesheet' );
    
    	add_action ( 'admin_print_scripts', 'pb_load_jquery' );
    
    	if ($pbOptions ['auto']) {
    		if ($pbOptions ["bef_loop"] == "on")
    			add_action ( 'loop_start', 'wp_pagebar' );
    		if ($pbOptions ["aft_loop"] == "on")
    			add_action ( 'loop_end', 'wp_pagebar' );
    		if ($pbOptions ["footer"] == "on")
    			add_action ( 'wp_footer', 'wp_pagebar' );
    		if ($pbOptions ["remove"] == "on")
    			add_action ( 'wp_head', 'pb_remove_nav' );
    	}
    } //main
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic