Formatting cleanups for the nav menu widget. see #11817

git-svn-id: http://svn.automattic.com/wordpress/trunk@13388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-02-24 21:33:27 +00:00
parent e50b8fa348
commit 730f87bf97
1 changed files with 141 additions and 220 deletions

View File

@ -1066,11 +1066,8 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
} else {
$navwidgetdescription = $instance['navwidgetdescription'];
}
$menuexists = false;
global $wpdb;
// GET menu name
// Get menu
if ( $navmenu > 0 ) {
$custom_menu = get_term( (int) $nav_menu, 'nav_menu' );
$wp_custom_nav_menu_name = $custom_menu->name;
@ -1078,20 +1075,16 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
} else {
$menuexists = false;
}
?>
<?php
//DEVELOPER settings enabled
if ( $navdeveloper == 'yes' ) {
//DISPLAY Custom DIV
// DISPLAY Custom DIV
if ( $navdiv == 'yes' ) {
?>
<div id="<?php echo $navdivid; ?>" class="<?php echo $navdivclass; ?>">
<?php
}
}
} else {
//DISPLAY default DIV
else {
?>
<div class="widget">
<?php
@ -1100,12 +1093,7 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
<h3><?php echo $navtitle; ?></h3>
<?php
if ( $menuexists ) {
?>
<?php
//DEVELOPER settings enabled
if ( $navdeveloper == 'yes' ) {
//DISPLAY Custom UL
if ( $navul == 'yes' ) {
@ -1113,15 +1101,13 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
<ul id="<?php echo $navulid; ?>" class="<?php echo $navulclass; ?>">
<?php
}
}
//DISPLAY default UL
else {
} else {
// DISPLAY default UL
?>
<ul class="custom-nav">
<?php
}
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' ) {
@ -1129,46 +1115,31 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
</ul>
<?php
}
}
} else {
//DISPLAY default UL
else {
?>
</ul>
<?php
}
?>
<?php
} else {
_e('You have not setup the custom navigation widget correctly, please check your settings in the backend.');
}
?>
<?php
//DEVELOPER settings enabled
if ($navdeveloper == 'yes') {
//DISPLAY Custom DIV
if ($navdiv == 'yes')
{
// DISPLAY Custom DIV
if ( $navdiv == 'yes' ) {
?>
</div>
<?php
}
//Do NOT display DIV
else
{
}
}
//DISPLAY default DIV
else
{
} else {
// DISPLAY default DIV
?>
</div>
<?php
}
?><!-- /#nav-container -->
<?php
}
@ -1193,7 +1164,14 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
// Get menus
$custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
if ( $custom_menus ) {
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;
}
?>
<p>
@ -1201,22 +1179,17 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
<select id="<?php echo $this->get_field_id('navmenu'); ?>" name="<?php echo $this->get_field_name('navmenu'); ?>">
<?php
//DISPLAY SELECT OPTIONS
foreach ( $custom_menus as $menu ) {
if ( $navmenu == $menu->term_id) {
if ( $navmenu == $menu->term_id )
$selected_option = 'selected="selected"';
} else {
else
$selected_option = '';
}
?>
<option value="<?php echo $menu->term_id; ?>" <?php echo $selected_option; ?>><?php echo $menu->name; ?></option>
<?php
}
?>
</select>
</p>
<p>
@ -1224,105 +1197,70 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
<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>
<?php $checked = strtolower($navdeveloper); ?>
<p>
<?php
$checked = strtolower($navdeveloper);
?>
<label for="<?php echo $this->get_field_id('navdeveloper'); ?>"><?php _e('Advanced Options:'); ?></label><br />
<span class="checkboxes">
<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"'; } ?> />
</span><!-- /.checkboxes -->
</p>
<?php
//DEVELOPER settings
if ($checked == 'yes')
{
// Advanced settings
if ( $checked == 'yes' ) :
?>
<p>
<?php
$checked = strtolower($navdiv);
?>
<?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' ) {
?>
<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
}
?>
<p>
<?php
$checked = strtolower($navul);
?>
<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>
<?php
if ($checked == 'yes')
{
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
}
$advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
?>
<?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);
?>
<?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"'; } ?> />
@ -1330,25 +1268,8 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
</span><!-- /.checkboxes -->
</p>
<?php
endif;
}
//Do nothing
else
{
}
}
//Error message for menus not existing
else
{
?>
<p>
<label><?php _e('The Custom Navigation has not been configured correctly. Please check your Custom Navigation settings before adding this widget.'); ?></label>
</p>
<?php
}
}
}
/**