Changeset 13336 for trunk/wp-includes/default-widgets.php
- Timestamp:
- 02/23/2010 07:28:41 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.