Allow `wp_page_menu()` to accept `'walker'`, `'before'`, and `'after'` to allow custom markup.

Fixes #11095.


git-svn-id: https://develop.svn.wordpress.org/trunk@34200 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-09-15 15:05:34 +00:00
parent acbeef27b9
commit b5b07ca329
1 changed files with 13 additions and 4 deletions

View File

@ -1204,7 +1204,16 @@ function wp_list_pages( $args = '' ) {
* @return string|void HTML menu * @return string|void HTML menu
*/ */
function wp_page_menu( $args = array() ) { function wp_page_menu( $args = array() ) {
$defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => ''); $defaults = array(
'sort_column' => 'menu_order, post_title',
'menu_class' => 'menu',
'echo' => true,
'link_before' => '',
'link_after' => '',
'before' => '<ul>',
'after' => '</ul>',
'walker' => ''
);
$args = wp_parse_args( $args, $defaults ); $args = wp_parse_args( $args, $defaults );
/** /**
@ -1247,9 +1256,9 @@ function wp_page_menu( $args = array() ) {
$list_args['title_li'] = ''; $list_args['title_li'] = '';
$menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) ); $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) );
if ( $menu ) if ( $menu ) {
$menu = '<ul>' . $menu . '</ul>'; $menu = $args['before'] . $menu . $args['after'];
}
$menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n"; $menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";
/** /**