Changeset 13336
- Timestamp:
- 02/23/2010 07:28:41 PM (15 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/custom-navigation.php
r13334 r13336 137 137 $menu_item->li_class = 'class="current_page_item"'; 138 138 139 $menu_item->anchor_title = ''; 139 140 /* @todo: update to use tax/post data 140 141 … … 164 165 } 165 166 166 function output_menu_item($menu_item, $context ) {167 function output_menu_item($menu_item, $context, $args = array() ) { 167 168 switch( $context ) { 168 169 case 'backend': … … 198 199 <?php 199 200 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; 200 239 } 201 240 } … … 228 267 $menu_objects = get_objects_in_term( $id, 'nav_menu' ); 229 268 $menu_items = wp_custom_navigation_get_menu_items( $menu_objects, 'menu_order' ); 230 // Override for menu descriptions231 $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');232 if ( $advanced_option_descriptions == 'no' )233 $desc = 2;234 269 235 270 $parent_stack = array(); … … 246 281 // List Items 247 282 ?><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); 273 284 // Indent children 274 285 $last_item = ( count( $menu_items ) == $menu_item->menu_order ); -
trunk/wp-includes/default-widgets.php
r13328 r13336 1045 1045 1046 1046 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); 1049 1049 } 1050 1050 … … 1060 1060 $navulclass = $instance['navulclass']; 1061 1061 1062 // Override for menu descriptions1062 // Override for menu descriptions 1063 1063 $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options'); 1064 if ($advanced_option_descriptions == 'no') 1065 { 1064 if ( $advanced_option_descriptions == 'no' ) { 1066 1065 $navwidgetdescription = 2; 1067 } 1068 else 1069 { 1066 } else { 1070 1067 $navwidgetdescription = $instance['navwidgetdescription']; 1071 1068 } … … 1074 1071 global $wpdb; 1075 1072 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; 1082 1077 $menuexists = true; 1083 } 1084 //Do nothing 1085 else 1086 { 1078 } else { 1087 1079 $menuexists = false; 1088 1080 } … … 1091 1083 <?php 1092 1084 //DEVELOPER settings enabled 1093 if ($navdeveloper == 'yes') 1094 { 1085 if ( $navdeveloper == 'yes' ) { 1095 1086 //DISPLAY Custom DIV 1096 if ($navdiv == 'yes') 1097 { 1087 if ( $navdiv == 'yes' ) { 1098 1088 ?> 1099 1089 <div id="<?php echo $navdivid; ?>" class="<?php echo $navdivclass; ?>"> 1100 1090 <?php 1101 1091 } 1102 //Do NOT display DIV1103 else1104 {1105 1106 }1107 1108 1092 } 1109 1093 //DISPLAY default DIV 1110 else 1111 { 1094 else { 1112 1095 ?> 1113 1096 <div class="widget"> … … 1119 1102 <?php 1120 1103 1121 if ($menuexists) 1122 { 1104 if ( $menuexists ) { 1123 1105 ?> 1124 1106 <?php 1125 1107 1126 1108 //DEVELOPER settings enabled 1127 if ($navdeveloper == 'yes') 1128 { 1109 if ( $navdeveloper == 'yes' ) { 1129 1110 //DISPLAY Custom UL 1130 if ($navul == 'yes') 1131 { 1111 if ( $navul == 'yes' ) { 1132 1112 ?> 1133 1113 <ul id="<?php echo $navulid; ?>" class="<?php echo $navulclass; ?>"> 1134 1114 <?php 1135 1115 } 1136 //Do NOT display UL1137 else1138 {1139 1140 }1141 1142 1116 } 1143 1117 //DISPLAY default UL 1144 else 1145 { 1118 else { 1146 1119 ?> 1147 1120 <ul class="custom-nav"> … … 1153 1126 <?php 1154 1127 //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) ); 1158 1130 ?> 1159 1131 … … 1161 1133 1162 1134 //DEVELOPER settings enabled 1163 if ($navdeveloper == 'yes') 1164 { 1135 if ( $navdeveloper == 'yes' ) { 1165 1136 //DISPLAY Custom UL 1166 if ($navul == 'yes') 1167 { 1137 if ( $navul == 'yes' ) { 1168 1138 ?> 1169 1139 </ul> 1170 1140 <?php 1171 1141 } 1172 //Do NOT display UL1173 else1174 {1175 1176 }1177 1178 1142 } 1179 1143 //DISPLAY default UL 1180 else 1181 { 1144 else { 1182 1145 ?> 1183 1146 </ul> … … 1187 1150 ?> 1188 1151 <?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.'); 1193 1154 } 1194 1155 ?> 1195 1156 <?php 1196 1157 //DEVELOPER settings enabled 1197 if ($navdeveloper == 'yes') 1198 { 1158 if ($navdeveloper == 'yes') { 1199 1159 //DISPLAY Custom DIV 1200 1160 if ($navdiv == 'yes') … … 1241 1201 global $wpdb; 1242 1202 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 ) { 1251 1207 ?> 1252 1208 … … 1258 1214 1259 1215 //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) { 1263 1218 $selected_option = 'selected="selected"'; 1264 } 1265 else { 1219 } else { 1266 1220 $selected_option = ''; 1267 1221 } 1268 1222 ?> 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> 1270 1224 <?php 1271 1225 … … 1277 1231 1278 1232 <p> 1279 1280 1233 <label for="<?php echo $this->get_field_id('navtitle'); ?>"><?php _e('Title:'); ?></label> 1281 1234 <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'); ?>" /> … … 1317 1270 <?php 1318 1271 1319 if ($checked == 'yes') 1320 { 1272 if ( $checked == 'yes' ) { 1321 1273 1322 1274 ?>
Note: See TracChangeset
for help on using the changeset viewer.