Allow a plugin to filter the classes applied in wp_list_pages. Fixes #9304 props willnorris.

git-svn-id: http://svn.automattic.com/wordpress/trunk@10814 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2009-03-18 21:43:51 +00:00
parent 789522a21a
commit 5258242b98
1 changed files with 7 additions and 5 deletions

View File

@ -1172,18 +1172,20 @@ class Walker_Page extends Walker {
$indent = '';
extract($args, EXTR_SKIP);
$css_class = 'page_item page-item-'.$page->ID;
$css_class = array('page_item', 'page-item-'.$page->ID);
if ( !empty($current_page) ) {
$_current_page = get_page( $current_page );
if ( isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors) )
$css_class .= ' current_page_ancestor';
$css_class[] = 'current_page_ancestor';
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';
$css_class[] = 'current_page_parent';
} elseif ( $page->ID == get_option('page_for_posts') ) {
$css_class .= ' current_page_parent';
$css_class[] = 'current_page_parent';
}
$css_class = implode(' ', apply_filters('page_css_class', $css_class, $page));
$output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '">' . $link_before . apply_filters('the_title', $page->post_title) . $link_after . '</a>';