Make WordPress Core

Changeset 13336


Ignore:
Timestamp:
02/23/2010 07:28:41 PM (17 years ago)
Author:
ryan
Message:

More output consolidation. see #11817

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/custom-navigation.php

    r13334 r13336  
    137137                $menu_item->li_class = 'class="current_page_item"';
    138138
     139        $menu_item->anchor_title = '';
    139140/* @todo: update to use tax/post data
    140141
     
    164165}
    165166
    166 function output_menu_item($menu_item, $context) {
     167function output_menu_item($menu_item, $context, $args = array() ) {
    167168        switch( $context ) {
    168169                case 'backend':
     
    198199<?php
    199200                break;
     201
     202                case 'frontend':
     203                        // Override for menu descriptions
     204                        $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
     205                        if ( $advanced_option_descriptions == 'no' )
     206                                $args['desc'] = 2;
     207?>
     208                        <a title="<?php echo $menu_item->anchor_title; ?>" href="<?php echo $menu_item->link; ?>" <?php echo $menu_item->target; ?>><?php echo $args['before_title'] . $menu_item->title . $args['after_title']; ?><?php
     209
     210                                                        if ( $advanced_option_descriptions == 'no' ) {
     211                                                                // 2 widget override do NOT display descriptions
     212                                                                // 1 widget override display descriptions
     213                                                                // 0 widget override not set
     214                                                                if ( ($args['desc'] == 1) || ($args['desc'] == 0) ) {
     215                                                                        ?><span class="nav-description"><?php echo $menu_item->description; ?></span><?php
     216                                                                }
     217                                                        } else {
     218                                                                // 2 widget override do NOT display descriptions
     219                                                                // 1 widget override display descriptions
     220                                                                // 0 widget override not set
     221                                                                if ( $args['desc'] == 1 ) {
     222                                                                        ?><span class="nav-description"><?php echo $menu_item->description; ?></span><?php
     223                                                                }
     224                                                        }
     225                                                ?></a>
     226<?php
     227                break;
     228
     229                case 'default':
     230?>
     231                                        <dl>
     232                                        <dt>
     233
     234                                        <?php $templatedir = get_bloginfo('url'); ?>
     235                                        <span class="title"><?php echo $menu_item->title; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','<?php echo $menu_item->append; ?>','<?php echo $menu_item->title; ?>','<?php echo $menu_item->link; ?>','<?php echo $menu_item->ID; ?>','<?php echo $menu_item->parent_item ?>','<?php echo $menu_item->description; ?>')" name="<?php echo $menu_item->title; ?>" value="<?php echo $menu_item->link; ?>"><img alt="<?php esc_attr_e('Add to Custom Menu'); ?>" title="<?php esc_attr_e('Add to Custom Menu'); ?>" src="<?php echo admin_url('images/ico-add.png'); ?>" /></a> </dt>
     236                                        </dl>
     237<?php
     238                break;
    200239        }
    201240}
     
    228267                $menu_objects = get_objects_in_term( $id, 'nav_menu' );
    229268                $menu_items = wp_custom_navigation_get_menu_items( $menu_objects, 'menu_order' );
    230                 // Override for menu descriptions
    231                 $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
    232                 if ( $advanced_option_descriptions == 'no' )
    233                         $desc = 2;
    234269
    235270                $parent_stack = array();
     
    246281                        // List Items
    247282                        ?><li id="menu-<?php echo $menu_item->ID; ?>" value="<?php echo $menu_item->ID; ?>" <?php echo $menu_item->li_class; ?>><?php
    248                                         //@todo: update front end to use post data
    249                                         //FRONTEND Link
    250                                         if ( $type == 'frontend' ) {
    251                                                 ?><a title="<?php echo $menu_item->anchor_title; ?>" href="<?php echo $menu_item->link; ?>" <?php echo $menu_item->target; ?>><?php echo $before_title.$menu_item->title.$after_title; ?><?php
    252 
    253                                                         if ( $advanced_option_descriptions == 'no' ) {
    254                                                                 // 2 widget override do NOT display descriptions
    255                                                                 // 1 widget override display descriptions
    256                                                                 // 0 widget override not set
    257                                                                 if ( ($desc == 1) || ($desc == 0) ) {
    258                                                                         ?><span class="nav-description"><?php echo $menu_item->description; ?></span><?php
    259                                                                 }
    260                                                         } else {
    261                                                                 // 2 widget override do NOT display descriptions
    262                                                                 // 1 widget override display descriptions
    263                                                                 // 0 widget override not set
    264                                                                 if ( $desc == 1 ) {
    265                                                                         ?><span class="nav-description"><?php echo $menu_item->description; ?></span><?php
    266                                                                 }
    267                                                         }
    268 
    269                                                 ?></a><?php
    270                                         } elseif ( $type == 'backend' ) {
    271                                                 output_menu_item($menu_item, 'backend');
    272                                         }
     283                        output_menu_item($menu_item, $type, $args);
    273284                        // Indent children
    274285                        $last_item = ( count( $menu_items ) == $menu_item->menu_order );
  • trunk/wp-includes/default-widgets.php

    r13328 r13336  
    10451045
    10461046        function WP_CustomNavWidget() {
    1047                 $widget_ops = array('description' => 'Use this widget to add one of your Custom Navigation Menus as a widget.' );
    1048                 parent::WP_Widget(false, __('Custom Navigation Menu'),$widget_ops);
     1047                $widget_ops = array('description' => __('Use this widget to add one of your Custom Navigation Menus as a widget.') );
     1048                parent::WP_Widget(false, __('Custom Navigation Menu'), $widget_ops);
    10491049        }
    10501050
     
    10601060                $navulclass = $instance['navulclass'];
    10611061
    1062                 //Override for menu descriptions
     1062                // Override for menu descriptions
    10631063                $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
    1064                 if ($advanced_option_descriptions == 'no')
    1065                 {
     1064                if ( $advanced_option_descriptions == 'no' ) {
    10661065                        $navwidgetdescription = 2;
    1067                 }
    1068                 else
    1069                 {
     1066                } else {
    10701067                        $navwidgetdescription = $instance['navwidgetdescription'];
    10711068                }
     
    10741071                global $wpdb;
    10751072
    1076                 //GET menu name
    1077                 if ($navmenu > 0)
    1078                 {
    1079                         $table_name_menus = $wpdb->prefix . "custom_nav_menus";
    1080                         $wp_result = $wpdb->get_results("SELECT menu_name FROM ".$table_name_menus." WHERE id='".$navmenu."'");
    1081                         $wp_custom_nav_menu_name = $wp_result[0]->menu_name;
     1073                // GET menu name
     1074                if ( $navmenu > 0 ) {
     1075                        $custom_menu = get_term( (int) $nav_menu, 'nav_menu' );
     1076                        $wp_custom_nav_menu_name = $custom_menu->name;
    10821077                        $menuexists = true;
    1083                 }
    1084                 //Do nothing
    1085                 else
    1086                 {
     1078                } else {
    10871079                        $menuexists = false;
    10881080                }
     
    10911083                <?php
    10921084                        //DEVELOPER settings enabled
    1093                         if ($navdeveloper == 'yes')
    1094                         {
     1085                        if ( $navdeveloper == 'yes' ) {
    10951086                                //DISPLAY Custom DIV
    1096                                 if ($navdiv == 'yes')
    1097                                 {
     1087                                if ( $navdiv == 'yes' ) {
    10981088                                        ?>
    10991089                                        <div id="<?php echo $navdivid;  ?>" class="<?php echo $navdivclass; ?>">
    11001090                                        <?php
    11011091                                }
    1102                                 //Do NOT display DIV
    1103                                 else
    1104                                 {
    1105 
    1106                                 }
    1107 
    11081092                        }
    11091093                        //DISPLAY default DIV
    1110                         else
    1111                         {
     1094                        else {
    11121095                                ?>
    11131096                                <div class="widget">
     
    11191102                        <?php
    11201103
    1121                         if ($menuexists)
    1122                         {
     1104                        if ( $menuexists ) {
    11231105                                ?>
    11241106                        <?php
    11251107
    11261108                        //DEVELOPER settings enabled
    1127                                 if ($navdeveloper == 'yes')
    1128                                 {
     1109                                if ( $navdeveloper == 'yes' ) {
    11291110                                        //DISPLAY Custom UL
    1130                                         if ($navul == 'yes')
    1131                                         {
     1111                                        if ( $navul == 'yes' ) {
    11321112                                                ?>
    11331113                                                <ul id="<?php echo $navulid;  ?>" class="<?php echo $navulclass; ?>">
    11341114                                                <?php
    11351115                                        }
    1136                                         //Do NOT display UL
    1137                                         else
    1138                                         {
    1139 
    1140                                         }
    1141 
    11421116                                }
    11431117                                //DISPLAY default UL
    1144                                 else
    1145                                 {
     1118                                else {
    11461119                                        ?>
    11471120                                        <ul class="custom-nav">
     
    11531126                                                <?php
    11541127                                                        //DISPLAY custom navigation menu
    1155                                                         if (get_option('wp_custom_nav_menu') == 'true') {
    1156                                                         custom_nav('name='.$wp_custom_nav_menu_name.'&desc='.$navwidgetdescription);
    1157                                                 }
     1128                                                        if ( get_option('wp_custom_nav_menu') == 'true' )
     1129                                                        custom_nav( array('id' => $navmenu, 'name' => $wp_custom_nav_menu_name, 'desc' => $navwidgetdescription) );
    11581130                                                ?>
    11591131
     
    11611133
    11621134                                        //DEVELOPER settings enabled
    1163                                         if ($navdeveloper == 'yes')
    1164                                         {
     1135                                        if ( $navdeveloper == 'yes' ) {
    11651136                                                //DISPLAY Custom UL
    1166                                                 if ($navul == 'yes')
    1167                                                 {
     1137                                                if ( $navul == 'yes' ) {
    11681138                                                        ?>
    11691139                                                        </ul>
    11701140                                                        <?php
    11711141                                                }
    1172                                                 //Do NOT display UL
    1173                                                 else
    1174                                                 {
    1175 
    1176                                                 }
    1177 
    11781142                                        }
    11791143                                        //DISPLAY default UL
    1180                                         else
    1181                                         {
     1144                                        else {
    11821145                                                ?>
    11831146                                                </ul>
     
    11871150                                ?>
    11881151                        <?php
    1189                         }
    1190                         else
    1191                         {
    1192                                 echo "You have not setup the custom navigation widget correctly, please check your settings in the backend.";
     1152                        } else {
     1153                                _e('You have not setup the custom navigation widget correctly, please check your settings in the backend.');
    11931154                        }
    11941155                        ?>
    11951156                <?php
    11961157                        //DEVELOPER settings enabled
    1197                         if ($navdeveloper == 'yes')
    1198                         {
     1158                        if ($navdeveloper == 'yes') {
    11991159                                //DISPLAY Custom DIV
    12001160                                if ($navdiv == 'yes')
     
    12411201                global $wpdb;
    12421202
    1243                 //GET Menu Items for SELECT OPTIONS
    1244                 $table_name_custom_menus = $wpdb->prefix . "custom_nav_menus";
    1245                 $custom_menu_records = $wpdb->get_results("SELECT id,menu_name FROM ".$table_name_custom_menus);
    1246 
    1247                 //CHECK if menus exist
    1248                 if ($custom_menu_records > 0)
    1249                 {
    1250 
     1203                // Get menus
     1204                $custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
     1205
     1206                if ( $custom_menus ) {
    12511207                        ?>
    12521208
     
    12581214
    12591215                                        //DISPLAY SELECT OPTIONS
    1260                                         foreach ($custom_menu_records as $custom_menu_record)
    1261                                         {
    1262                                                 if ($navmenu == $custom_menu_record->id) {
     1216                                        foreach ( $custom_menus as $menu ) {
     1217                                                if ( $navmenu == $menu->term_id) {
    12631218                                                        $selected_option = 'selected="selected"';
    1264                                                 }
    1265                                                 else {
     1219                                                } else {
    12661220                                                        $selected_option = '';
    12671221                                                }
    12681222                                                ?>
    1269                                                 <option value="<?php echo $custom_menu_record->id; ?>" <?php echo $selected_option; ?>><?php echo $custom_menu_record->menu_name; ?></option>
     1223                                                <option value="<?php echo $menu->term_id; ?>" <?php echo $selected_option; ?>><?php echo $menu->name; ?></option>
    12701224                                                <?php
    12711225
     
    12771231
    12781232                        <p>
    1279 
    12801233                        <label for="<?php echo $this->get_field_id('navtitle'); ?>"><?php _e('Title:'); ?></label>
    12811234                        <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'); ?>" />
     
    13171270                        <?php
    13181271
    1319                         if ($checked == 'yes')
    1320                         {
     1272                        if ( $checked == 'yes' ) {
    13211273
    13221274                                ?>
Note: See TracChangeset for help on using the changeset viewer.