mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-23 06:55:28 +00:00
Give CSS class to parent of current page/cat. Props mdawaffe. fixes #3253
git-svn-id: http://svn.automattic.com/wordpress/trunk@4576 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0bcce8aad3
commit
ec850c8478
@ -503,8 +503,11 @@ class Walker_Page extends Walker {
|
|||||||
$indent = str_repeat("\t", $depth);
|
$indent = str_repeat("\t", $depth);
|
||||||
|
|
||||||
$css_class = 'page_item';
|
$css_class = 'page_item';
|
||||||
|
$_current_page = get_page( $current_page );
|
||||||
if ( $page->ID == $current_page )
|
if ( $page->ID == $current_page )
|
||||||
$css_class .= ' current_page_item';
|
$css_class .= ' current_page_item';
|
||||||
|
elseif ( $_current_page && $page->ID == $_current_page->post_parent )
|
||||||
|
$css_class .= ' current_page_parent';
|
||||||
|
|
||||||
$output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . wp_specialchars($page->post_title, 1) . '">' . $page->post_title . '</a>';
|
$output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . wp_specialchars($page->post_title, 1) . '">' . $page->post_title . '</a>';
|
||||||
|
|
||||||
@ -613,10 +616,14 @@ class Walker_Category extends Walker {
|
|||||||
$link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
|
$link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$_current_category = get_category( $current_category );
|
||||||
|
|
||||||
if ( 'list' == $args['style'] ) {
|
if ( 'list' == $args['style'] ) {
|
||||||
$output .= "\t<li";
|
$output .= "\t<li";
|
||||||
if ( ($category->cat_ID == $current_category) && is_category() )
|
if ( ($category->cat_ID == $current_category) && is_category() )
|
||||||
$output .= ' class="current-cat"';
|
$output .= ' class="current-cat"';
|
||||||
|
elseif ( ($category->cat_ID == $_current_category->category_parent) && is_category() )
|
||||||
|
$output .= ' class="current-cat-parent"';
|
||||||
$output .= ">$link\n";
|
$output .= ">$link\n";
|
||||||
} else {
|
} else {
|
||||||
$output .= "\t$link<br />\n";
|
$output .= "\t$link<br />\n";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user