Freshy 2 and WP 2.7 Beta 3

  • Unknown's avatar

    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;
    }

    }

  • Unknown's avatar

    I think… and I may be wrong… but I think you should be at wordpress.org.

  • Unknown's avatar

    *sigh*

    See, this is why sleep > energy drinks.

  • The topic ‘Freshy 2 and WP 2.7 Beta 3’ is closed to new replies.