Index: classes.php
===================================================================
--- classes.php (revision 6666)
+++ classes.php (working copy)
@@ -529,10 +529,18 @@
class Walker_Page extends Walker {
var $tree_type = 'page';
var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
+ var $marker_page_parent;
+ var $_current_page;
- function start_lvl($output, $depth) {
+ function start_lvl($output, $depth, $current_page) {
$indent = str_repeat("\t", $depth);
- $output .= "\n$indent
\n";
+
+ $this->page_marker( $current_page );
+
+ if ( $depth == 1 && $this->marker_page_parent != 0 ) $css_class .= ' current_page_root';
+ if ( $css_class != '' ) $class = ' class="' . $css_class . '"';
+
+ $output .= "\n$indent\n";
return $output;
}
@@ -550,12 +558,16 @@
extract($args, EXTR_SKIP);
$css_class = 'page_item page-item-'.$page->ID;
- $_current_page = get_page( $current_page );
+
+ $this->page_marker( $current_page ); // Just in case start_lvl didn't invoke spirits
+
if ( $page->ID == $current_page )
$css_class .= ' current_page_item ';
- elseif ( $_current_page && $page->ID == $_current_page->post_parent )
+ elseif ( $this->_current_page && $page->ID == $this->marker_page_parent )
$css_class .= ' current_page_parent';
+ if ( $depth == 1 && $this->marker_page_parent != 0 ) $css_class .= ' current_page_branch';
+
$output .= $indent . '- ' . apply_filters('the_title', $page->post_title) . '';
if ( !empty($show_date) ) {
@@ -572,9 +584,18 @@
function end_el($output, $page, $depth) {
$output .= "
\n";
-
return $output;
}
+
+ function page_marker( $current_page ) {
+ if ( empty( $this->marker_page_parent ) ) {
+ $this->_current_page = get_page( $current_page );
+ $this->marker_page_parent = $this->_current_page->post_parent;
+ return $this->marker_page_parent;
+ } else {
+ return $this->marker_page_parent;
+ }
+ }
}