Fallback to wp_page_menu() from wp_nav_menu() if no menus are setup. Use wp_nav_menu() in twentyten. see #11817

git-svn-id: http://svn.automattic.com/wordpress/trunk@13368 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-02-24 08:45:26 +00:00
parent ee734e1e68
commit 091d1150d3
4 changed files with 33 additions and 3 deletions

View File

@ -30,7 +30,7 @@ require_once('admin-header.php');
require_once(ABSPATH . 'wp-admin/includes/nav-menu.php'); require_once(ABSPATH . 'wp-admin/includes/nav-menu.php');
function wp_reset_nav_menu() { function wp_reset_nav_menu() {
wp_custom_navigation_setup(true); wp_nav_menu_setup(true);
return true; return true;
} }

View File

@ -50,7 +50,7 @@
<div id="access"> <div id="access">
<div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>"><?php _e( 'Skip to content', 'twentyten' ); ?></a></div> <div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>"><?php _e( 'Skip to content', 'twentyten' ); ?></a></div>
<?php wp_page_menu( 'sort_column=menu_order' ); ?> <?php wp_nav_menu( 'sort_column=menu_order' ); ?>
</div><!-- #access --> </div><!-- #access -->
</div><!-- #masthead --> </div><!-- #masthead -->

View File

@ -1126,7 +1126,7 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
<?php <?php
//DISPLAY custom navigation menu //DISPLAY custom navigation menu
if ( get_option('wp_custom_nav_menu') == 'true' ) if ( get_option('wp_custom_nav_menu') == 'true' )
wp_nav_menu( array('id' => $navmenu, 'name' => $wp_custom_nav_menu_name, 'desc' => $navwidgetdescription) ); wp_nav_menu( array('id' => $navmenu, 'name' => $wp_custom_nav_menu_name, 'desc' => $navwidgetdescription, 'format' => 'widget') );
?> ?>
<?php <?php

View File

@ -8,7 +8,37 @@
* @param array $args Arguments * @param array $args Arguments
*/ */
function wp_nav_menu( $args = array() ) { function wp_nav_menu( $args = array() ) {
$defaults = array('id' => '', 'slug' => '', 'menu_class' => 'menu', 'format' => 'div');
$args = wp_parse_args($args, $defaults);
$args = (object) $args;
$menu = null;
if ( !empty($args->id) ) {
$menu = wp_get_nav_menu( $args->id );
} elseif ( !empty($args->slug) ) {
$menu = get_term_by('slug', $args->slug, 'nav_menu');
} else {
$menus = wp_get_nav_menus();
foreach ( $menus as $menu_maybe ) {
if ( wp_get_nav_menu_items($menu_maybe->term_id) ) {
$menu = $menu_maybe;
break;
}
}
}
if ( !$menu || is_wp_error($menu) )
return wp_page_menu( $args );
if ( 'div' == $args->format )
echo '<div class="' . esc_attr($args->menu_class) . '"><ul>';
$args->id = $menu->term_id;
wp_print_nav_menu($args); wp_print_nav_menu($args);
if ( 'div' == $args->format )
echo '</ul></div>';
} }
function wp_print_nav_menu( $args = array() ) { function wp_print_nav_menu( $args = array() ) {