| 1 | --- classes.php.orig 2007-09-11 17:20:49.000000000 +0100 |
|---|
| 2 | +++ classes.php 2007-09-11 17:24:13.000000000 +0100 |
|---|
| 3 | @@ -507,15 +507,27 @@ |
|---|
| 4 | return $output; |
|---|
| 5 | } |
|---|
| 6 | |
|---|
| 7 | + function parent_level($page, $current_page, $level=0) { |
|---|
| 8 | + $_current_page = get_page($current_page); |
|---|
| 9 | + if ( $page->ID == $current_page ) |
|---|
| 10 | + return $level; |
|---|
| 11 | + elseif ( $_current_page && $page->ID == $_current_page->post_parent ) |
|---|
| 12 | + return ++$level; |
|---|
| 13 | + elseif ( is_object($_current_page) ) |
|---|
| 14 | + return ( $this->parent_level($page, $_current_page->post_parent, ++$level ) ); |
|---|
| 15 | + else |
|---|
| 16 | + return false; |
|---|
| 17 | + } |
|---|
| 18 | + |
|---|
| 19 | function start_el($output, $page, $depth, $current_page, $args) { |
|---|
| 20 | if ( $depth ) |
|---|
| 21 | $indent = str_repeat("\t", $depth); |
|---|
| 22 | extract($args, EXTR_SKIP); |
|---|
| 23 | $css_class = 'page_item page-item-'.$page->ID; |
|---|
| 24 | - $_current_page = get_page( $current_page ); |
|---|
| 25 | - if ( $page->ID == $current_page ) |
|---|
| 26 | - $css_class .= ' current_page_item '; |
|---|
| 27 | - elseif ( $_current_page && $page->ID == $_current_page->post_parent ) |
|---|
| 28 | + $parent_level = $this->parent_level($page, $current_page); |
|---|
| 29 | + if ( $parent_level === 0 ) |
|---|
| 30 | + $css_class .= ' current_page_item'; |
|---|
| 31 | + elseif ( $parent_level > 0 ) |
|---|
| 32 | $css_class .= ' current_page_parent'; |
|---|
| 33 | |
|---|
| 34 | $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '">' . apply_filters('the_title', $page->post_title) . '</a>'; |
|---|
| 35 | @@ -581,6 +593,18 @@ |
|---|
| 36 | return $output; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | + function parent_level($category, $current_category, $level=0) { |
|---|
| 40 | + $_current_category = get_category( $current_category ); |
|---|
| 41 | + if ( $category->term_id == $current_category ) |
|---|
| 42 | + return $level; |
|---|
| 43 | + elseif ( $_current_category && $category->term_id == $_current_category->parent ) |
|---|
| 44 | + return ++$level; |
|---|
| 45 | + elseif ( is_object($_current_category) ) |
|---|
| 46 | + return ( $this->parent_level($category, $_current_category->parent, ++$level )); |
|---|
| 47 | + else |
|---|
| 48 | + return false; |
|---|
| 49 | + } |
|---|
| 50 | + |
|---|
| 51 | function start_el($output, $category, $depth, $args) { |
|---|
| 52 | extract($args); |
|---|
| 53 | |
|---|
| 54 | @@ -629,18 +653,16 @@ |
|---|
| 55 | $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp); |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | - if ( $current_category ) |
|---|
| 59 | - $_current_category = get_category( $current_category ); |
|---|
| 60 | - |
|---|
| 61 | if ( 'list' == $args['style'] ) { |
|---|
| 62 | - $output .= "\t<li"; |
|---|
| 63 | - $class = 'cat-item cat-item-'.$category->term_id; |
|---|
| 64 | - if ( $current_category && ($category->term_id == $current_category) ) |
|---|
| 65 | - $class .= ' current-cat'; |
|---|
| 66 | - elseif ( $_current_category && ($category->term_id == $_current_category->parent) ) |
|---|
| 67 | - $class .= ' current-cat-parent'; |
|---|
| 68 | - $output .= ' class="'.$class.'"'; |
|---|
| 69 | - $output .= ">$link\n"; |
|---|
| 70 | + $css_class = 'cat-item cat-item-'.$category->term_id; |
|---|
| 71 | + if ( $current_category ) { |
|---|
| 72 | + $parent_level = $this->parent_level($category, $current_category); |
|---|
| 73 | + if ( $parent_level === 0 ) |
|---|
| 74 | + $css_class .= ' current-cat'; |
|---|
| 75 | + elseif ( $parent_level > 0 ) |
|---|
| 76 | + $css_class .= ' current-cat-parent'; |
|---|
| 77 | + } |
|---|
| 78 | + $output .= "\t" . '<li class="' . $css_class . '">$link' . "\n"; |
|---|
| 79 | } else { |
|---|
| 80 | $output .= "\t$link<br />\n"; |
|---|
| 81 | } |
|---|