From ef3504a37272157d07a122a0f9312c98aa40a24a Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 8 Sep 2008 18:56:54 +0000 Subject: [PATCH] wp_page_menu(). see #7698 git-svn-id: http://svn.automattic.com/wordpress/trunk@8848 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-template.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index cdc821bba..e1cf67cbf 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -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 = '
  • ' . $text . '
  • '; + } + + $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($args) ); + + if ( $menu ) + $menu = ''; + + $menu = '
    ' . $menu . "
    \n"; + echo apply_filters( 'wp_page_menu', $menu ); +} + // // Page helpers //