• Resolved iamnickarmstrong

    (@iamnickarmstrong)


    Hey all,

    I’m currently using Freshy 2 by Jide.

    I’ve noticed a problem between my 2.7 Beta 3 blog and my 2.6.5 blog. The 2.7 does not add “current_page_item” to the class. The 2.6 does.

    Any ideas?

    The code to determine the page you’re looking at (for menu highlighting) is as follows:

    function freshy_wp_list_pages($args = '') {
    $defaults = array(
    'depth' => 0, 'show_date' => '',
    'date_format' => get_option('date_format'),
    'child_of' => 0, 'exclude' => '',
    'title_li' => __('Pages'), 'echo' => 1,
    'authors' => '', 'sort_column' => 'menu_order, post_title'
    );
    
    $r = wp_parse_args( $args, $defaults );
    extract( $r, EXTR_SKIP );
    
    $output = '';
    $current_page = 0;
    
    // sanitize, mostly to keep spaces out
    $r['exclude'] = preg_replace('[^0-9,]', '', $r['exclude']);
    
    // Allow plugins to filter an array of excluded pages
    $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude'])));
    
    // Query pages.
    $pages = get_pages($r);
    
    if ( !empty($pages) ) {
    if ( $r['title_li'] )
    $output .= '<li class="pagenav">' . $r['title_li'] . '
    
          ';
    
          global $wp_query;
          if ( is_page() )
          $current_page = $wp_query->get_queried_object_id();
          $output .= freshy_walk_page_tree($pages, $r['depth'], $current_page, $r);
    
          if ( $r['title_li'] )
          $output .= '
    
    ';
    }
    
    $output = apply_filters('wp_list_pages', $output);
    
    if ( $r['echo'] )
    echo $output;
    else
    return $output;
    }
    
    function freshy_walk_page_tree() {
    $walker = new freshy_Walker_Page;
    $args = func_get_args();
    return call_user_func_array(array(&$walker, 'walk'), $args);
    }
    
    class freshy_Walker_Page extends Walker {
    var $tree_type = 'page';
    var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
    
    function start_lvl($output, $depth) {
    $indent = str_repeat("\t", $depth);
    $output .= "\n$indent
    
          \n";
          return $output;
          }
    
          function end_lvl($output, $depth) {
          $indent = str_repeat("\t", $depth);
          $output .= "$indent
    
    \n";
    return $output;
    }
    
    function start_el($output, $page, $depth, $current_page, $args) {
    global $post;
    if ( $depth )
    $indent = str_repeat("\t", $depth);
    extract($args, EXTR_SKIP);
    $css_class = 'page_item page-item-'.$page->ID;
    $_current_page = get_page( $current_page );
    if ( $page->ID == $current_page || $page->ID == $_current_page )
    $css_class .= ' current_page_item ';
    elseif ( $_current_page && $page->ID == $_current_page->post_parent )
    $css_class .= ' current_page_parent';
    elseif ( $page->ID == freshy_get_page_root($_current_page->post_parent) )
    $css_class .= ' current_page_parent';
    elseif ( get_option('page_for_posts') == $page->ID && $_GET['page_id'] == $page->ID ) // a little hacky
    $css_class .= ' current_page_parent';
    elseif ( get_option('page_for_posts') == $page->ID && $post->post_type == 'post' ) // a little hacky
    $css_class .= ' current_page_parent';
    
    $output .= $indent . '<li class="' . $css_class . '">ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '">' . apply_filters('the_title', $page->post_title) . '';
    
    if ( !empty($show_date) ) {
    if ( 'modified' == $show_date )
    $time = $page->post_modified;
    else
    $time = $page->post_date;
    
    $output .= " " . mysql2date($date_format, $time);
    }
    
    return $output;
    }
    
    function end_el($output, $page, $depth) {
    $output .= "\n";
    
    return $output;
    }
    
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter iamnickarmstrong

    (@iamnickarmstrong)

    Bump.

    Thread Starter iamnickarmstrong

    (@iamnickarmstrong)

    I’ve fixed this issue. Somehow this (before 2.7)

    $_current_page = get_page( $current_page );
    if ( $page->ID == $current_page || $page->ID == $_current_page )
    $css_class .= ' current_page_item ';
    elseif ( $_current_page && $page->ID == $_current_page->post_parent )
    $css_class .= ' current_page_parent';
    elseif ( $page->ID == freshy_get_page_root($_current_page->post_parent) )
    $css_class .= ' current_page_parent';
    elseif ( get_option('page_for_posts') == $page->ID && $_GET['page_id'] == $page->ID ) // a little hacky
    $css_class .= ' current_page_parent';
    elseif ( get_option('page_for_posts') == $page->ID && $post->post_type == 'post' ) // a little hacky
    $css_class .= ' current_page_parent';

    became this after I upgraded:

    $_current_page = get_page( $current_page );
    if ( $page->ID == $current_page || $page->ID == $_current_page )
    if (is_home())
    $css_class .= ' current_page_item ';
    elseif ( $_current_page && $page->ID == $_current_page->post_parent )
    $css_class .= ' current_page_parent';
    elseif ( $page->ID == freshy_get_page_root($_current_page->post_parent) )
    $css_class .= ' current_page_parent';
    elseif ( get_option('page_for_posts') == $page->ID && $_GET['page_id'] == $page->ID ) // a little hacky
    $css_class .= ' current_page_parent';
    elseif ( get_option('page_for_posts') == $page->ID && $post->post_type == 'post' ) // a little hacky
    $css_class .= ' current_page_parent';

    Anybody else had this problem?

    Yup, the 2.7 RC1 still has the same problem. I really hope this will be fixed for the final release.

    Thread Starter iamnickarmstrong

    (@iamnickarmstrong)

    Did you see my fix?

    So the same thing happened to you, eh? Was it right after you’d upgraded or upon installation of Freshy 2?

    Oh, sorry. It seems I was too hasty posting on this thread. Yes, I’m having the same problem, but with different theme, Sandbox. And now that I tested, with the default theme Kubrick as well.

    This does seem to be a general problem with 2.7 beta3 and rc1. Searched the forum and found more on the topic in this thread.

    Just updated to WP 2.7 RC2. Fixed!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Freshy 2 – Current Page Highlight Problem, WP 2.7 Beta 3’ is closed to new replies.