wp_page_menu(). see #7698
git-svn-id: http://svn.automattic.com/wordpress/trunk@8848 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a39f651a85
commit
ef3504a372
|
@ -621,6 +621,41 @@ function wp_list_pages($args = '') {
|
|||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create menu of pages
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param array|string $args
|
||||
*/
|
||||
function wp_page_menu( $args = array() ) {
|
||||
$defaults = array('title_li' => '', 'sort_column' => 'menu_order', 'menu_class' => 'menu', 'echo' => false);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
$args = apply_filters( 'wp_page_menu_args', $args );
|
||||
|
||||
$menu = '';
|
||||
|
||||
// Show Home in the menu
|
||||
if ( !empty($args['show_home']) ) {
|
||||
if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] )
|
||||
$text = __('Home');
|
||||
else
|
||||
$text = $args['show_home'];
|
||||
$class = '';
|
||||
if ( is_home() && !is_paged() )
|
||||
$class = 'class="current_page_item"';
|
||||
$menu = '<li ' . $class . '><a href="' . get_option('home') . '">' . $text . '</a></li>';
|
||||
}
|
||||
|
||||
$menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($args) );
|
||||
|
||||
if ( $menu )
|
||||
$menu = '<ul>' . $menu . '</ul>';
|
||||
|
||||
$menu = '<div id="' . $args['menu_class'] . '">' . $menu . "</div>\n";
|
||||
echo apply_filters( 'wp_page_menu', $menu );
|
||||
}
|
||||
|
||||
//
|
||||
// Page helpers
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue