<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[15191] trunk/wp-admin: Don'
t show an error when the theme supports widgets but not menus.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/15191">15191</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-06-10 17:37:15 +0000 (Thu, 10 Jun 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Don't show an error when the theme supports widgets but not menus. see <a href="http://trac.wordpress.org/ticket/13825">#13825</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesnavmenuphp">trunk/wp-admin/includes/nav-menu.php</a></li>
<li><a href="#trunkwpadminnavmenusphp">trunk/wp-admin/nav-menus.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesnavmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/nav-menu.php (15190 => 15191)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/nav-menu.php        2010-06-10 16:07:33 UTC (rev 15190)
+++ trunk/wp-admin/includes/nav-menu.php        2010-06-10 17:37:15 UTC (rev 15191)
</span><span class="lines">@@ -365,7 +365,7 @@
</span><span class="cx"> **/
</span><span class="cx"> function wp_nav_menu_setup() {
</span><span class="cx">         // Register meta boxes
</span><del>-        if ( get_registered_nav_menus() && wp_get_nav_menus() )
</del><ins>+        if ( ( current_theme_supports( 'widgets' ) || get_registered_nav_menus() ) && wp_get_nav_menus() )
</ins><span class="cx">                 add_meta_box( 'nav-menu-theme-locations', __( 'Theme Locations' ), 'wp_nav_menu_locations_meta_box' , 'nav-menus', 'side', 'default' );
</span><span class="cx">         add_meta_box( 'add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
</span><span class="cx">         wp_nav_menu_post_type_meta_boxes();
</span><span class="lines">@@ -461,6 +461,13 @@
</span><span class="cx"> function wp_nav_menu_locations_meta_box() {
</span><span class="cx">         global $nav_menu_selected_id;
</span><span class="cx">         $locations = get_registered_nav_menus();
</span><ins>+
+        if ( empty( $locations ) ) {
+                // We must only support widgets. Leave a message and bail.
+                echo '<p class="howto">' . __('The current theme does not natively support menus, but you can use the &#8220;Custom Menu&#8221; widget to add any menus you create here to the theme&#8217;s sidebar.') . '</p>';
+                return;
+        }
+
</ins><span class="cx">         $menus = wp_get_nav_menus();
</span><span class="cx">         $menu_locations = get_nav_menu_locations();
</span><span class="cx">         $num_locations = count( array_keys($locations) );
</span></span></pre></div>
<a id="trunkwpadminnavmenusphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/nav-menus.php (15190 => 15191)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/nav-menus.php        2010-06-10 16:07:33 UTC (rev 15190)
+++ trunk/wp-admin/nav-menus.php        2010-06-10 17:37:15 UTC (rev 15191)
</span><span class="lines">@@ -248,7 +248,7 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 // Remove this menu from any locations.
</span><span class="cx">                                 $locations = get_theme_mod( 'nav_menu_locations' );
</span><del>-                                foreach ( $locations as $location => $menu_id ) {
</del><ins>+                                foreach ( (array) $locations as $location => $menu_id ) {
</ins><span class="cx">                                         if ( $menu_id == $nav_menu_selected_id )
</span><span class="cx">                                                 $locations[ $location ] = 0;
</span><span class="cx">                                 }
</span><span class="lines">@@ -430,20 +430,12 @@
</span><span class="cx">         $nav_menus[$key]->truncated_name = $_nav_menu->truncated_name;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// The theme supports menus
-if ( current_theme_supports('nav-menus') ) {
-        // Set up nav menu
-        wp_nav_menu_setup();
-
-// The theme does not support menus but supports widgets
-} elseif ( current_theme_supports('widgets') ) {
-        // Set up nav menu
-        wp_nav_menu_setup();
-        $messages[] = '<div id="message" class="error"><p>' . __('The current theme does not natively support menus, but you can use the &#8220;Custom Menu&#8221; widget to add any menus you create here to the theme&#8217;s sidebar.') . '</p></div>';
-}
-
</del><ins>+wp_nav_menu_setup();
</ins><span class="cx"> wp_initial_nav_menu_meta_boxes();
</span><span class="cx">
</span><ins>+if ( ! get_registered_nav_menus() && ! wp_get_nav_menus() )
+        echo '<div id="message" class="updated"><p>' . __('The current theme does not natively support menus, but you can use the &#8220;Custom Menu&#8221; widget to add any menus you create here to the theme&#8217;s sidebar.') . '</p></div>';
+
</ins><span class="cx"> $help = '<p>' . __('This feature is new in version 3.0; to use a custom menu in place of your theme&#8217;s default menus, support for this feature must be registered in the theme&#8217;s functions.php file. If your theme does not support the custom menus feature yet (the new default theme, Twenty Ten, does), you can learn about adding support yourself by following the below link.') . '</p>';
</span><span class="cx"> $help .= '<p>' . __('You can create custom menus for your site. These menus may contain links to pages, categories, custom links or other content types (use the Screen Options tab to decide which ones to show on the screen). You can specify a different navigation label for a menu item as well as other attributes. You can create multiple menus. If your theme includes more than one menu, you can choose which custom menu to associate with each. You can also use custom menus in conjunction with the Custom Menus widget.') . '</p>';
</span><span class="cx"> $help .= '<p>' . __('To create a new custom menu, click on the + tab, give the menu a name, and click Create Menu. Next, add menu items from the appropriate boxes. You&#8217;ll be able to edit the information for each menu item, and can drag and drop to put them in order. You can also drag a menu item a little to the right to make it a submenu, to create menus with hierarchy. You&#8217;ll see when the position of the drop target shifts over to create the nested placement. Don&#8217;t forget to click Save when you&#8217;re finished.') . '</p>';
</span></span></pre>
</div>
</div>
</body>
</html>