<!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>[13388] trunk/wp-includes/default-widgets.php:
Formatting cleanups for the nav menu widget.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13388">13388</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-02-24 21:33:27 +0000 (Wed, 24 Feb 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Formatting cleanups for the nav menu widget. see <a href="http://trac.wordpress.org/ticket/11817">#11817</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesdefaultwidgetsphp">trunk/wp-includes/default-widgets.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesdefaultwidgetsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/default-widgets.php (13387 => 13388)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/default-widgets.php        2010-02-24 21:30:13 UTC (rev 13387)
+++ trunk/wp-includes/default-widgets.php        2010-02-24 21:33:27 UTC (rev 13388)
</span><span class="lines">@@ -1066,11 +1066,8 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         $navwidgetdescription = $instance['navwidgetdescription'];
</span><span class="cx">                 }
</span><del>-                $menuexists = false;
</del><span class="cx">
</span><del>-                global $wpdb;
-
-                // GET menu name
</del><ins>+                // Get menu
</ins><span class="cx">                 if ( $navmenu > 0 ) {
</span><span class="cx">                         $custom_menu = get_term( (int) $nav_menu, 'nav_menu' );
</span><span class="cx">                         $wp_custom_nav_menu_name = $custom_menu->name;
</span><span class="lines">@@ -1078,98 +1075,72 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         $menuexists = false;
</span><span class="cx">                 }
</span><del>-                ?>
</del><span class="cx">
</span><del>-                <?php
-                        //DEVELOPER settings enabled
-                        if ( $navdeveloper == 'yes' ) {
-                                //DISPLAY Custom DIV
-                                if ( $navdiv == 'yes' ) {
-                                        ?>
-                                        <div id="<?php echo $navdivid; ?>" class="<?php echo $navdivclass; ?>">
-                                        <?php
</del><ins>+                if ( $navdeveloper == 'yes' ) {
+                        // DISPLAY Custom DIV
+                        if ( $navdiv == 'yes' ) {
+                        ?>
+                                <div id="<?php echo $navdivid; ?>" class="<?php echo $navdivclass; ?>">
+                        <?php
</ins><span class="cx">                                 }
</span><del>-                        }
-                        //DISPLAY default DIV
-                        else {
</del><ins>+                        } else {
+                                //DISPLAY default DIV
</ins><span class="cx">                                 ?>
</span><span class="cx">                                 <div class="widget">
</span><span class="cx">                                 <?php
</span><span class="cx">                         }
</span><span class="cx">                 ?>
</span><span class="cx">
</span><del>-                        <h3><?php echo $navtitle; ?></h3>
-                        <?php
-
-                        if ( $menuexists ) {
-                                ?>
-                 <?php
-
-                 //DEVELOPER settings enabled
-                                if ( $navdeveloper == 'yes' ) {
-                                        //DISPLAY Custom UL
-                                        if ( $navul == 'yes' ) {
-                                                ?>
-                                                <ul id="<?php echo $navulid; ?>" class="<?php echo $navulclass; ?>">
-                                                <?php
-                                        }
-                                }
-                                //DISPLAY default UL
-                                else {
</del><ins>+                <h3><?php echo $navtitle; ?></h3>
+                <?php
+                if ( $menuexists ) {
+                        if ( $navdeveloper == 'yes' ) {
+                                //DISPLAY Custom UL
+                                if ( $navul == 'yes' ) {
</ins><span class="cx">                                         ?>
</span><del>-                                        <ul class="custom-nav">
</del><ins>+                                        <ul id="<?php echo $navulid; ?>" class="<?php echo $navulclass; ?>">
</ins><span class="cx">                                         <?php
</span><span class="cx">                                 }
</span><del>-                                wp_nav_menu( array('id' => $navmenu, 'name' => $wp_custom_nav_menu_name, 'desc' => $navwidgetdescription, 'format' => 'widget') );
-                                //DEVELOPER settings enabled
-                                        if ( $navdeveloper == 'yes' ) {
-                                                //DISPLAY Custom UL
-                                                if ( $navul == 'yes' ) {
-                                                        ?>
-                                                        </ul>
-                                                        <?php
-                                                }
-                                        }
-                                        //DISPLAY default UL
-                                        else {
-                                                ?>
-                                                </ul>
-                                                <?php
-                                        }
-
-                                ?>
-                        <?php
</del><span class="cx">                         } else {
</span><del>-                                _e('You have not setup the custom navigation widget correctly, please check your settings in the backend.');
</del><ins>+                                // DISPLAY default UL
+                                ?>
+                                <ul class="custom-nav">
+                                <?php
</ins><span class="cx">                         }
</span><del>-                        ?>
-                <?php
-                        //DEVELOPER settings enabled
-                        if ($navdeveloper == 'yes') {
-                                //DISPLAY Custom DIV
-                                if ($navdiv == 'yes')
-                                {
</del><ins>+                        wp_nav_menu( array('id' => $navmenu, 'name' => $wp_custom_nav_menu_name, 'desc' => $navwidgetdescription, 'format' => 'widget') );
+                        if ( $navdeveloper == 'yes' ) {
+                                //DISPLAY Custom UL
+                                if ( $navul == 'yes' ) {
</ins><span class="cx">                                         ?>
</span><del>-                                        </div>
</del><ins>+                                        </ul>
</ins><span class="cx">                                         <?php
</span><span class="cx">                                 }
</span><del>-                                //Do NOT display DIV
-                                else
-                                {
-
-                                }
-
</del><ins>+                        } else {
+                                //DISPLAY default UL
+                                ?>
+                                </ul>
+                                <?php
</ins><span class="cx">                         }
</span><del>-                        //DISPLAY default DIV
-                        else
-                        {
</del><ins>+                } else {
+                        _e('You have not setup the custom navigation widget correctly, please check your settings in the backend.');
+                }
+
+                //DEVELOPER settings enabled
+                if ($navdeveloper == 'yes') {
+                        // DISPLAY Custom DIV
+                        if ( $navdiv == 'yes' ) {
</ins><span class="cx">                                 ?>
</span><span class="cx">                                 </div>
</span><span class="cx">                                 <?php
</span><span class="cx">                         }
</span><del>-                ?><!-- /#nav-container -->
-
</del><ins>+                } else {
+                        // DISPLAY default DIV
+                        ?>
+                        </div>
</ins><span class="cx">                         <?php
</span><ins>+                }
+                ?><!-- /#nav-container -->
+                <?php
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         function update($new_instance, $old_instance) {
</span><span class="lines">@@ -1193,162 +1164,112 @@
</span><span class="cx">                 // Get menus
</span><span class="cx">                 $custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
</span><span class="cx">
</span><del>-                if ( $custom_menus ) {
-                        ?>
</del><ins>+                if ( !$custom_menus) {
+                ?>
+                        <p>
+                         <label><?php printf(__('No menus have been created yet. <a href="%s">Creat some</a>.'), admin_url('nav-menus.php')); ?></label>
+                        </p>
+                <?php
+                        return;
+                }
+                ?>
</ins><span class="cx">
</span><del>-                         <p>
-         <label for="<?php echo $this->get_field_id('navmenu'); ?>"><?php _e('Select Menu:'); ?></label>
</del><ins>+                <p>
+                        <label for="<?php echo $this->get_field_id('navmenu'); ?>"><?php _e('Select Menu:'); ?></label>
</ins><span class="cx">
</span><del>-                                <select id="<?php echo $this->get_field_id('navmenu'); ?>" name="<?php echo $this->get_field_name('navmenu'); ?>">
</del><ins>+                        <select id="<?php echo $this->get_field_id('navmenu'); ?>" name="<?php echo $this->get_field_name('navmenu'); ?>">
+                                <?php
+                                foreach ( $custom_menus as $menu ) {
+                                        if ( $navmenu == $menu->term_id )
+                                                $selected_option = 'selected="selected"';
+                                        else
+                                                $selected_option = '';
+                                        ?>
+                                        <option value="<?php echo $menu->term_id; ?>" <?php echo $selected_option; ?>><?php echo $menu->name; ?></option>
</ins><span class="cx">                                         <?php
</span><ins>+                                }
+                                ?>
+                        </select>
+                </p>
</ins><span class="cx">
</span><del>-                                        //DISPLAY SELECT OPTIONS
-                                        foreach ( $custom_menus as $menu ) {
-                                                if ( $navmenu == $menu->term_id) {
-                                                        $selected_option = 'selected="selected"';
-                                                } else {
-                                                        $selected_option = '';
-                                                }
-                                                ?>
-                                                <option value="<?php echo $menu->term_id; ?>" <?php echo $selected_option; ?>><?php echo $menu->name; ?></option>
-                                                <?php
</del><ins>+                <p>
+                        <label for="<?php echo $this->get_field_id('navtitle'); ?>"><?php _e('Title:'); ?></label>
+                        <input type="text" name="<?php echo $this->get_field_name('navtitle'); ?>" value="<?php echo $navtitle; ?>" class="widefat" id="<?php echo $this->get_field_id('navtitle'); ?>" />
+                </p>
</ins><span class="cx">
</span><del>-                                        }
-                                        ?>
-                                </select>
-
-                        </p>
-
-                        <p>
-                 <label for="<?php echo $this->get_field_id('navtitle'); ?>"><?php _e('Title:'); ?></label>
-                         <input type="text" name="<?php echo $this->get_field_name('navtitle'); ?>" value="<?php echo $navtitle; ?>" class="widefat" id="<?php echo $this->get_field_id('navtitle'); ?>" />
-                 </p>
-
-                 <p>
-                        <?php
-                         $checked = strtolower($navdeveloper);
-                        ?>
-
</del><ins>+                <?php $checked = strtolower($navdeveloper); ?>
+                <p>
</ins><span class="cx">                         <label for="<?php echo $this->get_field_id('navdeveloper'); ?>"><?php _e('Advanced Options:'); ?></label><br />
</span><span class="cx">                         <span class="checkboxes">
</span><del>-                                 <label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navdeveloper'); ?>" name="<?php echo $this->get_field_name('navdeveloper'); ?>" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
-                         <label>No</label><input type="radio" id="<?php echo $this->get_field_name('navdeveloper'); ?>" name="<?php echo $this->get_field_name('navdeveloper'); ?>" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
</del><ins>+                                <label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navdeveloper'); ?>" name="<?php echo $this->get_field_name('navdeveloper'); ?>" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
+                                <label>No</label><input type="radio" id="<?php echo $this->get_field_name('navdeveloper'); ?>" name="<?php echo $this->get_field_name('navdeveloper'); ?>" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
</ins><span class="cx">                         </span><!-- /.checkboxes -->
</span><ins>+                </p>
</ins><span class="cx">
</span><del>-                        </p>
</del><ins>+                <?php
+                // Advanced settings
+                if ( $checked == 'yes' ) :
+                ?>
+                <p>
+                <?php $checked = strtolower($navdiv); ?>
+                        <label for="<?php echo $this->get_field_id('navdiv'); ?>"><?php _e('Wrap in container DIV:'); ?></label><br />
+                        <span class="checkboxes">
+                                <label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navdiv'); ?>" name="<?php echo $this->get_field_name('navdiv'); ?>" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
+                                <label>No</label><input type="radio" id="<?php echo $this->get_field_name('navdiv'); ?>" name="<?php echo $this->get_field_name('navdiv'); ?>" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
+                        </span><!-- /.checkboxes -->
+                </p>
+                <?php
+                if ( $checked == 'yes' ) {
+                ?>
</ins><span class="cx">
</span><del>-                 <?php
-
-                 //DEVELOPER settings
-                 if ($checked == 'yes')
-                 {
-                         ?>
-
-                         <p>
-                                <?php
-                                 $checked = strtolower($navdiv);
-                                ?>
-
-                                <label for="<?php echo $this->get_field_id('navdiv'); ?>"><?php _e('Wrap in container DIV:'); ?></label><br />
-                                <span class="checkboxes">
-                                         <label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navdiv'); ?>" name="<?php echo $this->get_field_name('navdiv'); ?>" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
-                                 <label>No</label><input type="radio" id="<?php echo $this->get_field_name('navdiv'); ?>" name="<?php echo $this->get_field_name('navdiv'); ?>" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
-                                </span><!-- /.checkboxes -->
-
</del><ins>+                        <p>
+                                <label for="<?php echo $this->get_field_id('navdivid'); ?>"><?php _e('DIV id:'); ?></label>
+                                <input type="text" name="<?php echo $this->get_field_name('navdivid'); ?>" value="<?php echo $navdivid; ?>" class="widefat" id="<?php echo $this->get_field_id('navdivid'); ?>" />
</ins><span class="cx">                         </p>
</span><del>-
-                        <?php
-
-                        if ( $checked == 'yes' ) {
-
-                                ?>
-
-                                <p>
-
-                 <label for="<?php echo $this->get_field_id('navdivid'); ?>"><?php _e('DIV id:'); ?></label>
-                 <input type="text" name="<?php echo $this->get_field_name('navdivid'); ?>" value="<?php echo $navdivid; ?>" class="widefat" id="<?php echo $this->get_field_id('navdivid'); ?>" />
-                 </p>
-                 <p>
-
-                 <label for="<?php echo $this->get_field_id('navdivclass'); ?>"><?php _e('DIV class:'); ?></label>
-                 <input type="text" name="<?php echo $this->get_field_name('navdivclass'); ?>" value="<?php echo $navdivclass; ?>" class="widefat" id="<?php echo $this->get_field_id('navdivclass'); ?>" />
-                 </p>
-
-                                <?php
-
-                        }
-
-                        ?>
-
</del><span class="cx">                         <p>
</span><del>-                                <?php
-                                 $checked = strtolower($navul);
-                                ?>
-
-                                <label for="<?php echo $this->get_field_id('navul'); ?>"><?php _e('Wrap in container UL:'); ?></label><br />
-                                <span class="checkboxes">
-                                         <label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navul'); ?>" name="<?php echo $this->get_field_name('navul'); ?>" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
-                                 <label>No</label><input type="radio" id="<?php echo $this->get_field_name('navul'); ?>" name="<?php echo $this->get_field_name('navul'); ?>" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
-                                </span><!-- /.checkboxes -->
-
</del><ins>+                                <label for="<?php echo $this->get_field_id('navdivclass'); ?>"><?php _e('DIV class:'); ?></label>
+                                <input type="text" name="<?php echo $this->get_field_name('navdivclass'); ?>" value="<?php echo $navdivclass; ?>" class="widefat" id="<?php echo $this->get_field_id('navdivclass'); ?>" />
</ins><span class="cx">                         </p>
</span><ins>+                <?php
+                }
+                
+                $checked = strtolower($navul);
+                ?>
</ins><span class="cx">
</span><del>-                        <?php
</del><ins>+                <p>
+                        <label for="<?php echo $this->get_field_id('navul'); ?>"><?php _e('Wrap in container UL:'); ?></label><br />
+                        <span class="checkboxes">
+                                <label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navul'); ?>" name="<?php echo $this->get_field_name('navul'); ?>" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
+                                <label>No</label><input type="radio" id="<?php echo $this->get_field_name('navul'); ?>" name="<?php echo $this->get_field_name('navul'); ?>" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
+                        </span><!-- /.checkboxes -->
+                </p>
</ins><span class="cx">
</span><del>-                        if ($checked == 'yes')
-                        {
-
-                                ?>
-
-                                <p>
-
-                 <label for="<?php echo $this->get_field_id('navulid'); ?>"><?php _e('UL id:'); ?></label>
-                 <input type="text" name="<?php echo $this->get_field_name('navulid'); ?>" value="<?php echo $navulid; ?>" class="widefat" id="<?php echo $this->get_field_id('navulid'); ?>" />
-                 </p>
-                 <p>
-
-                 <label for="<?php echo $this->get_field_id('navulclass'); ?>"><?php _e('UL class:'); ?></label>
-                 <input type="text" name="<?php echo $this->get_field_name('navulclass'); ?>" value="<?php echo $navulclass; ?>" class="widefat" id="<?php echo $this->get_field_id('navulclass'); ?>" />
-                 </p>
-
-                                <?php
-
-                        }
-
-                        ?>
-                        <?php $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options'); ?>
-                        <p <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?>>
-
-         <?php
-                                 $checked = strtolower($navwidgetdescription);
-                                ?>
-
-                                <label for="<?php echo $this->get_field_id('navwidgetdescription'); ?>"><?php _e('Show Top Level Descriptions:'); ?></label><br />
-                                <span class="checkboxes">
-                                         <label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navwidgetdescription'); ?>" name="<?php echo $this->get_field_name('navwidgetdescription'); ?>" value="1" <?php if ($checked=='1') { echo 'checked="checked"'; } ?> />
-                                 <label>No</label><input type="radio" id="<?php echo $this->get_field_name('navwidgetdescription'); ?>" name="<?php echo $this->get_field_name('navwidgetdescription'); ?>" value="2" <?php if ($checked=='1') { } else { echo 'checked="checked"'; } ?> />
-                                </span><!-- /.checkboxes -->
-         </p>
-                         <?php
-                 }
-                 //Do nothing
-                 else
-                 {
-
-                 }
-
-                }
-                //Error message for menus not existing
-                else
-                {
-                        ?>
</del><ins>+                <?php
+                if ( $checked == 'yes' ) {
+                ?>
</ins><span class="cx">                         <p>
</span><del>-                         <label><?php _e('The Custom Navigation has not been configured correctly. Please check your Custom Navigation settings before adding this widget.'); ?></label>
</del><ins>+                                <label for="<?php echo $this->get_field_id('navulid'); ?>"><?php _e('UL id:'); ?></label>
+                                <input type="text" name="<?php echo $this->get_field_name('navulid'); ?>" value="<?php echo $navulid; ?>" class="widefat" id="<?php echo $this->get_field_id('navulid'); ?>" />
</ins><span class="cx">                         </p>
</span><del>-                        <?php
</del><ins>+                        <p>
+                                <label for="<?php echo $this->get_field_id('navulclass'); ?>"><?php _e('UL class:'); ?></label>
+                                <input type="text" name="<?php echo $this->get_field_name('navulclass'); ?>" value="<?php echo $navulclass; ?>" class="widefat" id="<?php echo $this->get_field_id('navulclass'); ?>" />
+                        </p>
+                <?php
</ins><span class="cx">                 }
</span><ins>+                $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
+                ?>
+                <p <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?>>
+                 <?php $checked = strtolower($navwidgetdescription); ?>
+                        <label for="<?php echo $this->get_field_id('navwidgetdescription'); ?>"><?php _e('Show Top Level Descriptions:'); ?></label><br />
+                        <span class="checkboxes">
+                                <label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navwidgetdescription'); ?>" name="<?php echo $this->get_field_name('navwidgetdescription'); ?>" value="1" <?php if ($checked=='1') { echo 'checked="checked"'; } ?> />
+                                <label>No</label><input type="radio" id="<?php echo $this->get_field_name('navwidgetdescription'); ?>" name="<?php echo $this->get_field_name('navwidgetdescription'); ?>" value="2" <?php if ($checked=='1') { } else { echo 'checked="checked"'; } ?> />
+                        </span><!-- /.checkboxes -->
+                </p>
+                <?php
+                endif;
</ins><span class="cx">         }
</span><del>-
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre>
</div>
</div>
</body>
</html>