Ticket #11817: nav-menu-cleanup.diff
File nav-menu-cleanup.diff, 37.6 KB (added by , 15 years ago) |
---|
-
wp-admin/css/custom-navigation.dev.css
161 161 .ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } 162 162 .ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .60;filter:Alpha(Opacity=60); } 163 163 .ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .60;filter:Alpha(Opacity=60); -moz-border-radius: 8px; -webkit-border-radius: 8px; } 164 165 166 #reset_wp_menu { background:#c77 none !important;color:white!important;text-shadow:0 1px 0 #555 !important;} -
wp-admin/nav-menus.php
31 31 32 32 function wp_reset_nav_menu() { 33 33 wp_nav_menu_setup(true); 34 35 34 return true; 36 35 } 37 36 38 $messages div = '';37 $messages_div = ''; 39 38 $menu_id_in_edit = 0; 40 39 $updated = false; 40 $advanced_option_descriptions = 'no'; 41 41 42 42 // Check which menu is selected and if menu is in edit already 43 if ( isset( $_GET['edit _menu'] ) ) {44 $menu_selected_id = (int) $_GET['edit _menu'];43 if ( isset( $_GET['edit-menu'] ) ) { 44 $menu_selected_id = (int) $_GET['edit-menu']; 45 45 $updated = true; 46 } elseif ( isset( $_POST[ 'menu _id_in_edit' ] ) ) {47 $menu_selected_id = (int) $_POST[ 'menu _id_in_edit' ];46 } elseif ( isset( $_POST[ 'menu-id-in-edit' ] ) ) { 47 $menu_selected_id = (int) $_POST[ 'menu-id-in-edit' ]; 48 48 } else { 49 49 $menu_selected_id = 0; 50 50 } 51 51 52 if ( isset( $_POST[ 'delete _menu' ] ) && $menu_selected_id > 0 ) {52 if ( isset( $_POST[ 'delete-menu' ] ) && $menu_selected_id > 0 ) { 53 53 wp_delete_nav_menu( $menu_selected_id ); 54 54 $menu_selected_id = 0; 55 55 $updated = true; … … 70 70 } 71 71 } 72 72 73 if ( isset( $_POST['li count'] ) )74 $post Counter = $_POST['licount'];73 if ( isset( $_POST['li-count'] ) ) 74 $post_counter = $_POST['li-count']; 75 75 else 76 $post Counter = 0;76 $post_counter = 0; 77 77 78 78 // Create a new menu. Menus are stored as terms in the 'menu' taxonomy. 79 if ( isset( $_POST['add_menu'] ) && ! $updated ) { 80 update_option( 'wp_custom_nav_menu', $_POST['enable_wp_menu'] ); // Do we need this? 81 $insert_menu_name = $_POST['add_menu_name']; 79 if ( isset( $_POST['add-menu'] ) && ! $updated ) { 80 $insert_menu_name = $_POST['add-menu-name']; 82 81 83 if ( $insert_menu_name != '') {84 $menu = wp_create_nav_menu( $insert_menu_name);85 if ( is_wp_error( $menu) ) {86 $messages div = '<div id="message" class="error fade below-h2"><p>' . esc_html( $menu->get_error_message()) . '</p></div>';82 if ( $insert_menu_name ) { 83 $menu = wp_create_nav_menu( $insert_menu_name ); 84 if ( is_wp_error( $menu ) ) { 85 $messages_div = '<div id="message" class="error fade below-h2"><p>' . $menu->get_error_message() . '</p></div>'; 87 86 } else { 88 87 $custom_menus[$menu->term_id] = $menu; 89 88 $menu_selected_id = $menu->term_id; 90 89 $menu_id_in_edit = $menu_selected_id; 91 90 $menu_title = $menu->name; 92 $messages div = '<div id="message" class="updated fade below-h2"><p>' . esc_html( sprintf( __('"%s" menu has been created!'),$menu->name ) ) . '</p></div>';93 $post Counter = 0;91 $messages_div = '<div id="message" class="updated fade below-h2"><p>' . sprintf( __('“%s” menu has been created.'), esc_html( $menu->name ) ) . '</p></div>'; 92 $post_counter = 0; 94 93 } 95 94 } else { 96 $messages div = '<div id="message" class="error fade below-h2"><p>' . __('Please enter a valid menu name.') . '</p></div>';95 $messages_div = '<div id="message" class="error fade below-h2"><p>' . __('Please enter a valid menu name.') . '</p></div>'; 97 96 } 98 97 $updated = true; 99 98 } 100 99 101 if ( $post Counter > 0 && $menu_selected_id > 0 && ! $updated ) {100 if ( $post_counter > 0 && $menu_selected_id > 0 && ! $updated ) { 102 101 $menu_items = wp_get_nav_menu_items( $menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') ); 103 102 $parent_menu_ids = array(); 104 103 105 104 // Loop through all POST variables 106 for ( $k = 1; $k <= $post Counter; $k++ ) {107 if (isset($_POST['dbid'.$k])) { $db_id = $_POST['dbid'.$k]; } else { $db_id = 0; }108 if (isset($_POST['postmenu'.$k])) { $object_id = $_POST['postmenu'.$k]; } else { $object_id = 0; }109 if (isset($_POST['parent'.$k])) { $parent_id = $_POST['parent'.$k]; } else { $parent_id = 0; }110 if (isset($_POST['title'.$k])) { $custom_title = $_POST['title'.$k]; } else { $custom_title = ''; }111 if (isset($_POST['linkurl'.$k])) { $custom_linkurl = $_POST['linkurl'.$k]; } else { $custom_linkurl = ''; }112 if (isset($_POST['description'.$k])) { $custom_description = $_POST['description'.$k]; } else { $custom_description = ''; }105 for ( $k = 1; $k <= $post_counter; $k++ ) { 106 $db_id = isset( $_POST['dbid'.$k] )? $_POST['dbid'.$k] : 0; 107 $object_id = isset( $_POST['postmenu'.$k] )? $_POST['postmenu'.$k] : 0; 108 $parent_id = isset( $_POST['parent'.$k] )? $_POST['parent'.$k] : 0; 109 $custom_title = isset( $_POST['title'.$k] )? $_POST['title'.$k] : ''; 110 $custom_linkurl = isset( $_POST['linkurl'.$k] )? $_POST['linkurl'.$k] : ''; 111 $custom_description = isset( $_POST['description'.$k] )? $_POST['description'.$k] : ''; 113 112 // doesn't seem to be used by UI 114 if (isset($_POST['icon'.$k])) { $icon = $_POST['icon'.$k]; } else { $icon = 0; }115 if (isset($_POST['position'.$k])) { $position = $_POST['position'.$k]; } else { $position = 0; }116 if (isset($_POST['linktype'.$k])) { $linktype = $_POST['linktype'.$k]; } else { $linktype = 'custom'; }117 if (isset($_POST['anchortitle'.$k])) { $custom_anchor_title = $_POST['anchortitle'.$k]; } else { $custom_anchor_title = $custom_title; }118 if (isset($_POST['newwindow'.$k])) { $new_window = $_POST['newwindow'.$k]; } else { $new_window = 0; }113 $icon = isset( $_POST['icon'.$k] )? $_POST['icon'.$k] : 0; 114 $position = isset( $_POST['position'.$k] )? $_POST['position'.$k] : 0; 115 $linktype = isset( $_POST['linktype'.$k] )? $_POST['linktype'.$k] : 'custom'; 116 $custom_anchor_title = isset( $_POST['anchortitle'.$k] )? $_POST['anchortitle'.$k] : $custom_title; 117 $new_window = isset( $_POST['newwindow'.$k] )? $_POST['newwindow'.$k] : 0; 119 118 120 119 $post = array( 'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'post_author' => $user_ID, 121 120 'ping_status' => 0, 'post_parent' => 0, 'menu_order' => $position, … … 125 124 $post['post_content_filtered'] = '_blank'; 126 125 else 127 126 $post['post_content_filtered'] = ''; 128 if ( $parent_id > 0 && isset( $parent_menu_ids[ $parent_id] ) )129 $post[ 'post_parent' ] = $parent_menu_ids[ $parent_id];127 if ( $parent_id > 0 && isset( $parent_menu_ids[$parent_id] ) ) 128 $post['post_parent'] = $parent_menu_ids[$parent_id]; 130 129 131 130 // New menu item 132 131 if ( $db_id == 0 ) { … … 138 137 } 139 138 $parent_menu_ids[ $k ] = $db_id; 140 139 141 update_post_meta( $db_id, 'menu_type', $linktype);142 update_post_meta( $db_id, 'object_id', $object_id);140 update_post_meta( $db_id, 'menu_type', $linktype ); 141 update_post_meta( $db_id, 'object_id', $object_id ); 143 142 } 144 143 if ( !empty( $menu_items ) ) { 145 144 foreach ( array_keys( $menu_items ) as $menu_id ) { 146 145 wp_delete_post( $menu_id ); 147 146 } 148 147 } 149 // DISPLAY SUCCESS MESSAGE IF POST CORRECT 150 $messagesdiv = '<div id="message" class="updated fade below-h2"><p>' . __('The menu has been updated.') . '</p></div>'; 148 $messages_div = '<div id="message" class="updated fade below-h2"><p>' . __('The menu has been updated.') . '</p></div>'; 151 149 } 152 150 153 151 ?> … … 155 153 <?php screen_icon(); ?> 156 154 <h2><?php esc_html_e('Menus') ?></h2> 157 155 <form onsubmit="updatepostdata()" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data"> 158 <?php if ( ! empty( $custom_menus ) && count( $custom_menus ) > 1 ) {?>156 <?php if ( ! empty( $custom_menus ) && count( $custom_menus ) > 1 ): ?> 159 157 <ul class="subsubsub"> 160 158 <?php 161 159 foreach ( $custom_menus as $menu ) { 162 $sep = end($custom_menus) == $menu ? '' : ' | '; 163 // $menu_term = get_term( $menu, 'nav_menu' ); 160 $sep = end( $custom_menus ) == $menu ? '' : ' | '; 164 161 if ( ( $menu_id_in_edit == $menu->term_id ) || ( $menu_selected_id == $menu->term_id ) ) { ?> 165 <li><a href='nav-menus.php?edit _menu=<?php echo esc_attr($menu->term_id); ?>' class="current"><?php echo esc_html( $menu->name ); ?></a><?php echo $sep; ?></li>162 <li><a href='nav-menus.php?edit-menu=<?php echo esc_attr($menu->term_id); ?>' class="current"><?php echo esc_html( $menu->name ); ?></a><?php echo $sep; ?></li> 166 163 <?php } else { ?> 167 <li><a href='nav-menus.php?edit _menu=<?php echo esc_attr($menu->term_id); ?>'><?php echo esc_html( $menu->name ); ?></a><?php echo $sep; ?></li>164 <li><a href='nav-menus.php?edit-menu=<?php echo esc_attr($menu->term_id); ?>'><?php echo esc_html( $menu->name ); ?></a><?php echo $sep; ?></li> 168 165 <?php } 169 166 } 170 167 ?> 171 168 </ul> 172 169 <div class="clear"></div> 173 <?php }?>170 <?php endif ?> 174 171 175 172 <div class="hide-if-js error"><p><?php _e('You do not have JavaScript enabled in your browser. Please enable it to access the Menus functionality.'); ?></p></div> 176 173 <div class="hide-if-no-js"> 177 174 <div id="pages-left"> 178 175 <div class="inside"> 179 176 <?php if ( ! empty( $custom_menus ) ) : ?> 180 <?php echo $messages div; ?>177 <?php echo $messages_div; ?> 181 178 182 <input type="hidden" name="li count" id="licount" value="0" />183 <input type="hidden" name="menu _id_in_edit" id="menu_id_in_edit" value="<?php echo esc_attr($menu_selected_id); ?>" />179 <input type="hidden" name="li-count" id="li-count" value="0" /> 180 <input type="hidden" name="menu-id-in-edit" id="menu-id-in-edit" value="<?php echo esc_attr( $menu_selected_id ); ?>" /> 184 181 185 182 <div class="sidebar-name"> 186 183 <div class="sidebar-name-arrow"> 187 184 <br/> 188 185 </div> 189 <h3><?php echo esc_html( $menu_title); ?></h3>186 <h3><?php echo esc_html( $menu_title ); ?></h3> 190 187 191 188 </div> 192 189 193 190 <div id="nav-container"> 194 191 <ul id="custom-nav"> 195 192 196 <?php 197 //DISPLAY existing menu 193 <?php 198 194 if ( $menu_selected_id > 0 ) { 199 wp_print_nav_menu( 'type=backend&name='.$menu_title.'&id='.$menu_selected_id);195 wp_print_nav_menu( array( 'type' => 'backend', 'name' => $menu_title, 'id' => $menu_selected_id ) ); 200 196 } 201 ?> 202 197 ?> 203 198 </ul> 204 199 </div><!-- /#nav-container --> 205 200 … … 209 204 updatepostdata(); 210 205 </script> 211 206 <input id="save_bottom" name="save_bottom" type="submit" value="<?php esc_attr_e('Save All Changes'); ?>" /> 212 <input id="delete _menu" name="delete_menu" type="submit" value="<?php esc_attr_e('Delete This Menu'); ?>" />207 <input id="delete-menu" name="delete-menu" type="submit" value="<?php esc_attr_e('Delete This Menu'); ?>" /> 213 208 </p> 214 209 215 210 <?php else : ?> … … 227 222 <div class="widget-holder"> 228 223 229 224 <span> 230 <input id="add _menu_name" name="add_menu_name" type="text" value="" />231 <input id="add _menu" type="submit" value="<?php esc_attr_e('Add Menu'); ?>" name="add_menu" class="button" />225 <input id="add-menu-name" name="add-menu-name" type="text" value="" /> 226 <input id="add-menu" type="submit" value="<?php esc_attr_e('Add Menu'); ?>" name="add-menu" class="button" /> 232 227 </span> 233 228 </div> 234 229 </div><!-- /.widgets-holder-wrap --> 235 <?php /* ?>236 <?php $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options'); ?>237 <div class="widgets-holder-wrap" style="display:none;">238 <div class="sidebar-name">239 <div class="sidebar-name-arrow"></div>240 <h3><?php esc_html_e('Top Level Menu Descriptions'); ?></h3>241 </div>242 <div class="widget-holder">243 <span><?php _e('Display Descriptions in Top Level Menu?'); ?></span>244 245 <?php246 // UPDATE and DISPLAY Menu Description Option247 if ( isset($_POST['menu-descriptions']) ) {248 if ( !isset($_POST['switch_menu']) ) {249 $menu_options_to_edit = $_POST['menu_id_in_edit'];250 update_option('wp_settings_custom_nav_'.$menu_options_to_edit.'_descriptions',$_POST['menu-descriptions']);251 }252 }253 254 if ( $menu_id_in_edit > 0 )255 $checkedraw = get_option('wp_settings_custom_nav_'.$menu_id_in_edit.'_descriptions');256 else257 $checkedraw = get_option('wp_settings_custom_nav_'.$menu_selected_id.'_descriptions');258 259 $checked = strtolower($checkedraw);260 261 if ( $advanced_option_descriptions == 'no' )262 $checked = 'no';263 ?>264 265 <span class="checkboxes">266 <label><?php _e('Yes'); ?></label><input type="radio" name="menu-descriptions" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />267 <label><?php _e('No'); ?></label><input type="radio" name="menu-descriptions" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />268 </span><!-- /.checkboxes -->269 </form>270 <div class="fix"></div>271 </div>272 </div><!-- /.widgets-holder-wrap -->273 <?php */ ?>274 230 <div class="widgets-holder-wrap"> 275 231 <div class="sidebar-name"> 276 232 <div class="sidebar-name-arrow"></div> 277 233 <h3><?php esc_html_e('Add an Existing Page'); ?></h3> 278 234 </div> 279 235 <div class="widget-holder"> 280 281 <?php 282 $pages_args = array( 283 'child_of' => 0, 284 'sort_order' => 'ASC', 285 'sort_column' => 'post_title', 286 'hierarchical' => 1, 287 'exclude' => '', 288 'include' => '', 289 'meta_key' => '', 290 'meta_value' => '', 291 'authors' => '', 292 'parent' => -1, 293 'exclude_tree' => '', 294 'number' => '', 295 'offset' => 0 ); 296 297 //GET all pages 298 $pages_array = get_pages($pages_args); 299 $page_name = ''; 300 //CHECK if pages exist 301 if ( $pages_array ) { 302 foreach ( $pages_array as $post ) { 303 //Add page name to 304 $page_name .= htmlentities($post->post_title).'|'; 305 } 306 } else { 307 $page_name = __('No pages available'); 308 } 309 ?> 310 311 <script> 236 <?php 237 $pages_args = array( 238 'child_of' => 0, 239 'sort_order' => 'ASC', 240 'sort_column' => 'post_title', 241 'hierarchical' => 1, 242 'exclude' => '', 243 'include' => '', 244 'meta_key' => '', 245 'meta_value' => '', 246 'authors' => '', 247 'parent' => -1, 248 'exclude_tree' => '', 249 'number' => '', 250 'offset' => 0 251 ); 252 $page_name = ''; 253 $pages_array = get_pages($pages_args); 254 if ( $pages_array ) { 255 foreach ( $pages_array as $post ) { 256 $page_name .= $post->post_title . '|'; 257 } 258 } else { 259 $page_name = __('No pages available'); 260 } 261 ?> 262 <script type="text/javascript" charset="<?php bloginfo('charset'); ?>"> 312 263 jQuery(document).ready(function(){ 313 314 //GET PHP pages 315 var dataposts = "<?php echo esc_js($page_name); ?>".split("|"); 316 317 //Set autocomplete 318 jQuery("#page-search").autocomplete(dataposts); 319 320 //Handle autocomplete result 264 var posts = "<?php echo esc_js( $page_name ); ?>".split("|"); 265 jQuery("#page-search").autocomplete(posts); 321 266 jQuery("#page-search").result(function(event, data, formatted) { 322 267 jQuery('#existing-pages').css('display','block'); 323 268 jQuery("#existing-pages dt:contains('" + data + "')").css("display", "block"); 324 325 269 jQuery('#show-pages').hide(); 326 270 jQuery('#hide-pages').show(); 327 328 271 }); 329 272 jQuery('#existing-pages').css('display','none'); 330 273 }); 331 274 </script> 332 333 275 <input type="text" onfocus="jQuery('#page-search').attr('value','');" id="page-search" value="<?php esc_attr_e('Search Pages'); ?>" /> 334 276 335 <a id="show-pages" style="cursor:pointer;" onclick="jQuery('#existing-pages').css('display','block');jQuery('#page-search').attr('value','');jQuery('#existing-pages dt').css('display','block');jQuery('#show-pages').hide();jQuery('#hide-pages').show();"> View All</a>336 <a id="hide-pages" style="cursor:pointer;" onclick="jQuery('#existing-pages').css('display','none');jQuery('#page-search').attr('value','Search Pages');jQuery('#existing-pages dt').css('display','none');jQuery('#show-pages').show();jQuery('#hide-pages').hide();"> Hide All</a>277 <a id="show-pages" style="cursor:pointer;" onclick="jQuery('#existing-pages').css('display','block');jQuery('#page-search').attr('value','');jQuery('#existing-pages dt').css('display','block');jQuery('#show-pages').hide();jQuery('#hide-pages').show();"><?php _e('View All'); ?></a> 278 <a id="hide-pages" style="cursor:pointer;" onclick="jQuery('#existing-pages').css('display','none');jQuery('#page-search').attr('value','Search Pages');jQuery('#existing-pages dt').css('display','none');jQuery('#show-pages').show();jQuery('#hide-pages').hide();"><?php _e('Hide All'); ?></a> 337 279 338 280 <script type="text/javascript"> 339 281 jQuery('#hide-pages').hide(); 340 282 </script> 341 283 342 284 <ul id="existing-pages" class="list"> 343 <?php 344 $intCounter = 0; 345 //Get default Pages 346 $intCounter = wp_nav_menu_get_pages($intCounter,'default'); 347 ?> 285 <?php 286 $items_counter = wp_nav_menu_get_pages( 0,'default' ); 287 ?> 348 288 </ul> 349 350 289 <div class="fix"></div> 351 352 290 </div> 353 291 </div><!-- /.widgets-holder-wrap --> 354 292 … … 359 297 </div> 360 298 <div class="widget-holder"> 361 299 362 <?php 363 // Custom GET categories query 364 // @todo Use API 365 $categories = $wpdb->get_results("SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category' ORDER BY term_id ASC"); 366 $cat_name = ''; 367 //CHECK for results 368 if ( $categories ) { 369 foreach ( $categories as $category ) { 370 $cat_id = $category->term_id; 371 372 $cat_args = array( 373 'orderby' => 'name', 374 'include' => $cat_id, 375 'hierarchical' => 1, 376 'order' => 'ASC' 377 ); 378 379 $category_names=get_categories($cat_args); 380 381 if ( isset($category_names[0]->name) ) { 382 // Add category name to data string 383 $cat_name .= htmlentities($category_names[0]->name).'|'; 384 } 385 } 386 } else { 387 $cat_name = __('No categories available'); 388 } 389 ?> 390 391 <script> 300 <?php 301 // Custom GET categories query 302 // @todo Use API 303 $categories = $wpdb->get_results("SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category' ORDER BY term_id ASC"); 304 $cat_name = ''; 305 if ( $categories ) { 306 foreach ( $categories as $category ) { 307 $cat_id = $category->term_id; 308 $cat_args = array( 309 'orderby' => 'name', 310 'include' => $cat_id, 311 'hierarchical' => 1, 312 'order' => 'ASC', 313 ); 314 $category_names = get_categories( $cat_args ); 315 if ( isset( $category_names[0]->name ) ) { 316 $cat_name .= htmlentities( $category_names[0]->name ).'|'; 317 } 318 } 319 } else { 320 $cat_name = __('No categories available'); 321 } 322 ?> 323 <script type="text/javascript" charset="<?php bloginfo('charset'); ?>"> 392 324 jQuery(document).ready(function(){ 393 394 //GET PHP categories 395 var datacats = "<?php echo esc_js($cat_name); ?>".split("|"); 396 397 //Set autocomplete 398 jQuery("#cat-search").autocomplete(datacats); 399 400 //Handle autocomplete result 325 var categories = "<?php echo esc_js($cat_name); ?>".split("|"); 326 jQuery("#cat-search").autocomplete(categories); 401 327 jQuery("#cat-search").result(function(event, data, formatted) { 402 328 jQuery('#existing-categories').css('display','block'); 403 329 jQuery("#existing-categories dt:contains('" + data + "')").css("display", "block"); 404 405 330 jQuery('#show-cats').hide(); 406 331 jQuery('#hide-cats').show(); 407 408 332 }); 409 333 jQuery('#existing-categories').css('display','none'); 410 411 334 }); 412 335 </script> 413 336 414 337 <input type="text" onfocus="jQuery('#cat-search').attr('value','');" id="cat-search" value="<?php esc_attr_e('Search Categories'); ?>" /> 415 338 416 <a id="show-cats" style="cursor:pointer;" onclick="jQuery('#existing-categories').css('display','block');jQuery('#cat-search').attr('value','');jQuery('#existing-categories dt').css('display','block');jQuery('#show-cats').hide();jQuery('#hide-cats').show();"> View All</a>417 <a id="hide-cats" style="cursor:pointer;" onclick="jQuery('#existing-categories').css('display','none');jQuery('#cat-search').attr('value','Search Categories');jQuery('#existing-categories dt').css('display','none');jQuery('#show-cats').show();jQuery('#hide-cats').hide();"> Hide All</a>339 <a id="show-cats" style="cursor:pointer;" onclick="jQuery('#existing-categories').css('display','block');jQuery('#cat-search').attr('value','');jQuery('#existing-categories dt').css('display','block');jQuery('#show-cats').hide();jQuery('#hide-cats').show();"><?php _e('View All'); ?></a> 340 <a id="hide-cats" style="cursor:pointer;" onclick="jQuery('#existing-categories').css('display','none');jQuery('#cat-search').attr('value','Search Categories');jQuery('#existing-categories dt').css('display','none');jQuery('#show-cats').show();jQuery('#hide-cats').hide();"><?php _e('Hide All'); ?></a> 418 341 419 342 <script type="text/javascript"> 420 343 jQuery('#hide-cats').hide(); 421 344 </script> 422 345 423 346 <ul id="existing-categories" class="list"> 424 <?php 425 // Get default Categories 426 $intCounter = wp_nav_menu_get_categories($intCounter, 'default'); 427 ?> 347 <?php 348 $items_counter = wp_nav_menu_get_categories( $items_counter, 'default' ); 349 ?> 428 350 </ul> 429 351 430 352 <div class="fix"></div> 431 432 353 </div> 433 354 </div><!-- /.widgets-holder-wrap --> 434 355 … … 438 359 <h3><?php esc_html_e('Add a Custom Url'); ?></h3> 439 360 </div> 440 361 <div class="widget-holder"> 441 <input id="custom _menu_item_url" type="text" value="http://" />442 <label ><?php _e('URL'); ?></label><br />443 <?php $template dir = get_bloginfo('url'); ?>444 <input type="hidden" id="template dir" value="<?php echo esc_attr($templatedir); ?>" />445 <input id="custom _menu_item_name" type="text" value="Menu Item" onfocus="jQuery('#custom_menu_item_name').attr('value','');" />446 <label ><?php _e('Menu Text'); ?></label><br />362 <input id="custom-menu-item-url" type="text" value="http://" /> 363 <label for="custom-menu-item-url"><?php _e('URL'); ?></label><br /> 364 <?php $template_dir = get_bloginfo('url'); ?> 365 <input type="hidden" id="template-dir" value="<?php echo esc_attr($template_dir); ?>" /> 366 <input id="custom-menu-item-name" type="text" value="<?php echo esc_attr( __('Menu Item') ); ?>" onfocus="jQuery('#custom-menu-item-name').attr('value','');" /> 367 <label for="custom-menu-item-name"><?php _e('Menu Text'); ?></label><br /> 447 368 <input id="custom_menu_item_description" type="text" value="<?php esc_attr_e('A description'); ?>" <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?> onfocus="jQuery('#custom_menu_item_description').attr('value','');" /> 448 369 <label <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?> ><?php _e('Description'); ?></label> 449 <a class="addtomenu" onclick="appendToList('<?php echo $template dir; ?>','Custom','','','','0','');jQuery('#custom_menu_item_name').attr('value','Menu Item');jQuery('#custom_menu_item_description').attr('value','A description');"><?php _e('Add to menu'); ?></a>370 <a class="addtomenu" onclick="appendToList('<?php echo $template_dir; ?>','<?php echo esc_js( _x('Custom', 'menu nav item type') ); ?>','','','','0','');jQuery('#custom-menu-item-name').attr('value','<?php echo esc_js( __('Menu Item') ); ?>');jQuery('#custom_menu_item_description').attr('value','<?php echo esc_js( __('A description') ); ?>');"><?php _e('Add to menu'); ?></a> 450 371 <div class="fix"></div> 451 372 </div> 452 373 </div><!-- /.widgets-holder-wrap --> … … 455 376 </div> 456 377 457 378 <div id="dialog-confirm" style="display:none;" title="<?php esc_attr_e('Edit Menu Item'); ?>"> 458 < /label><input id="edittitle" type="text" name="edittitle" value="" /><label class="editlabel" for="edittitle"><?php _e('Menu Title'); ?></label><br />379 <input id="edittitle" type="text" name="edittitle" value="" /><label class="editlabel" for="edittitle"><?php _e('Menu Title'); ?></label><br /> 459 380 <input id="editlink" type="text" name="editlink" value="" /><label class="editlabel" for="editlink"><?php _e('URL'); ?></label><br /> 460 381 <input id="editanchortitle" type="text" name="editanchortitle" value="" /><label class="editlabel" for="editanchortitle"><?php _e('Link Title'); ?></label><br /> 461 382 <select id="editnewwindow" name="editnewwindow"> … … 467 388 468 389 <?php 469 390 470 include("admin-footer.php"); 391 include("admin-footer.php"); 392 No newline at end of file -
wp-admin/js/custom-navigation-dynamic-functions.dev.js
115 115 jQuery(this).find('dl > dt > span > #remove' + j).attr('onClick', 'removeitem(' + i + ')'); 116 116 jQuery(this).find('dl > dt > span > #remove' + j).attr('id','remove' + i); 117 117 118 jQuery('#li count').attr('value',i);118 jQuery('#li-count').attr('value',i); 119 119 120 120 }); 121 121 … … 142 142 var inputdescription = ''; 143 143 var inputicon = ''; 144 144 145 if (additemtype == 'Custom')145 if (additemtype == navMenuL10n.custom) 146 146 { 147 inputvaluevarname = document.getElementById('custom _menu_item_name').value;148 inputvaluevarurl = document.getElementById('custom _menu_item_url').value;147 inputvaluevarname = document.getElementById('custom-menu-item-name').value; 148 inputvaluevarurl = document.getElementById('custom-menu-item-url').value; 149 149 inputitemid = ''; 150 150 inputparentid = ''; 151 151 inputlinktype = 'custom'; 152 inputdescription = document.getElementById('custom_menu_item_description').value;152 inputdescription = ''; 153 153 } 154 else if (additemtype == 'Page')154 else if (additemtype == navMenuL10n.page) 155 155 { 156 156 inputvaluevarname = htmlentities(itemtext.toString()); 157 157 inputvaluevarurl = itemurl.toString(); … … 161 161 inputdescription = htmlentities(itemdescription.toString()); 162 162 163 163 } 164 else if (additemtype == 'Category')164 else if (additemtype == navMenuL10n.category) 165 165 { 166 166 inputvaluevarname = htmlentities(itemtext.toString()); 167 167 inputvaluevarurl = itemurl.toString(); -
wp-admin/includes/nav-menu.php
29 29 //GET all pages 30 30 $pages_array = get_pages($pages_args); 31 31 32 $i ntCounter = $counter;33 $parentli = $i ntCounter;32 $items_counter = $counter; 33 $parentli = $items_counter; 34 34 35 35 if ( !$pages_array ) { 36 echo 'Not Found';37 return $i ntCounter;36 echo __('Not Found'); 37 return $items_counter; 38 38 } 39 39 40 40 // Display Loop 41 41 foreach ( $pages_array as $post ) { 42 42 if ( $post->post_parent == 0 ) { 43 $post = wp_setup_nav_menu_item($post, 'page', $i ntCounter);43 $post = wp_setup_nav_menu_item($post, 'page', $items_counter); 44 44 if ( $type == 'menu' ) { 45 45 ?> 46 46 47 <li id="menu-<?php echo $i ntCounter; ?>" value="<?php echo $intCounter; ?>">47 <li id="menu-<?php echo $items_counter; ?>" value="<?php echo $items_counter; ?>"> 48 48 <?php 49 wp_print_nav_menu_item($post, 'menu', $i ntCounter);49 wp_print_nav_menu_item($post, 'menu', $items_counter); 50 50 $parentli = $post->ID; 51 $i ntCounter++;52 $i ntCounter = wp_custom_navigation_default_sub_items($post->ID, $intCounter, $parentli, 'pages', 'menu');51 $items_counter++; 52 $items_counter = wp_custom_navigation_default_sub_items($post->ID, $items_counter, $parentli, 'pages', 'menu'); 53 53 ?> 54 54 </li> 55 55 … … 61 61 <?php 62 62 wp_print_nav_menu_item($post, 'default'); 63 63 $parentli = $post->ID; 64 $i ntCounter++;65 $i ntCounter = wp_nav_menu_sub_items($post->ID, $intCounter, $parentli, 'pages', 'default');64 $items_counter++; 65 $items_counter = wp_nav_menu_sub_items($post->ID, $items_counter, $parentli, 'pages', 'default'); 66 66 ?> 67 67 </li> 68 68 … … 71 71 } 72 72 } 73 73 74 return $i ntCounter;74 return $items_counter; 75 75 } 76 76 77 77 // Outputs All Categories and Sub Items … … 90 90 'number' => '', 91 91 'pad_counts' => false ); 92 92 93 $i ntCounter = $counter;93 $items_counter = $counter; 94 94 95 95 // Get all categories 96 96 $categories_array = get_categories($category_args); 97 97 98 98 if ( !$categories_array ) { 99 99 _e('Not Found'); 100 return $i ntCounter;100 return $items_counter; 101 101 } 102 102 103 103 // Display Loop 104 104 foreach ( $categories_array as $cat_item ) { 105 105 if ( $cat_item->parent == 0 ) { 106 $cat_item = wp_setup_nav_menu_item($cat_item, 'category', $i ntCounter);106 $cat_item = wp_setup_nav_menu_item($cat_item, 'category', $items_counter); 107 107 // Custom Menu 108 108 if ( $type == 'menu' ) { 109 109 ?> 110 110 111 <li id="menu-<?php echo $i ntCounter; ?>" value="<?php echo $intCounter; ?>">111 <li id="menu-<?php echo $items_counter; ?>" value="<?php echo $items_counter; ?>"> 112 112 <?php 113 113 wp_print_nav_menu_item($cat_item, 'menu'); 114 114 $parentli = $cat_item->cat_ID; 115 $i ntCounter++;116 $i ntCounter = wp_nav_menu_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories', 'menu');115 $items_counter++; 116 $items_counter = wp_nav_menu_sub_items($cat_item->cat_ID, $items_counter, $parentli, 'categories', 'menu'); 117 117 ?> 118 118 119 119 </li> … … 126 126 <?php 127 127 wp_print_nav_menu_item($cat_item, 'default'); 128 128 $parentli = $cat_item->cat_ID; 129 $i ntCounter++;130 $i ntCounter = wp_nav_menu_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories', 'default');129 $items_counter++; 130 $items_counter = wp_nav_menu_sub_items($cat_item->cat_ID, $items_counter, $parentli, 'categories', 'default'); 131 131 ?> 132 132 133 133 </li> … … 137 137 } 138 138 } 139 139 140 return $i ntCounter;140 return $items_counter; 141 141 } 142 142 143 143 //RECURSIVE Sub Menu Items of default categories and pages 144 function wp_nav_menu_sub_items($childof, $i ntCounter, $parentli, $type, $output_type) {144 function wp_nav_menu_sub_items($childof, $items_counter, $parentli, $type, $output_type) { 145 145 146 $counter = $i ntCounter;146 $counter = $items_counter; 147 147 148 148 // Custom Menu 149 149 if ( $output_type == 'menu' ) { -
wp-includes/nav-menu-template.php
104 104 <?php if ( 'backend' == $context ) { ?> 105 105 <a><span class=""></span></a> 106 106 <?php } else { ?> 107 <a class="hide" href="<?php echo $menu_item->link; ?>"><?php echo $menu_item->title; ?></a>107 <a class="hide" href="<?php echo $menu_item->link; ?>"><?php echo esc_html( $menu_item->title ); ?></a> 108 108 <?php } ?> 109 109 <input type="hidden" name="dbid<?php echo $menu_item->menu_order; ?>" id="dbid<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->ID; ?>" /> 110 110 <input type="hidden" name="postmenu<?php echo $menu_item->menu_order; ?>" id="postmenu<?php echo $menu_item->menu_order; ?>" value="<?php echo esc_attr( get_post_meta( $menu_item->ID, 'object_id', true ) ); ?>" /> … … 148 148 break; 149 149 150 150 case 'default': 151 $template dir = get_bloginfo('url');151 $template_dir = get_bloginfo('url'); 152 152 ?> 153 153 <dl> 154 <dt> 155 <span class="title"><?php echo $menu_item->title; ?></span> <a onclick="appendToList('<?php echo esc_js( esc_url_raw( $templatedir ) ); ?>','<?php echo esc_js( $menu_item->append ); ?>','<?php echo esc_js( $menu_item->title ); ?>','<?php echo esc_js( $menu_item->link ); ?>','<?php echo esc_js( $menu_item->ID ); ?>','<?php echo esc_js( $menu_item->parent_item ); ?>','<?php echo esc_js( $menu_item->description ); ?>')" name="<?php echo esc_attr( $menu_item->title ); ?>" value="<?php echo esc_attr( $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> 154 <dt> 155 <span class="title"><?php echo $menu_item->title; ?></span> 156 <a onclick="appendToList('<?php echo esc_js( esc_url_raw( $template_dir ) ); ?>','<?php echo esc_js( $menu_item->append ); ?>','<?php echo esc_js( $menu_item->title ); ?>','<?php echo esc_js( $menu_item->link ); ?>','<?php echo esc_js( $menu_item->ID ); ?>','<?php echo esc_js( $menu_item->parent_item ); ?>','<?php echo esc_js( $menu_item->description ); ?>')" name="<?php echo esc_attr( $menu_item->title ); ?>" value="<?php echo esc_attr( $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> 157 </dt> 156 158 </dl> 157 159 <?php 158 160 break; -
wp-includes/nav-menu.php
25 25 $menu_exists = get_term_by( 'name', $menu_name, 'nav_menu' ); 26 26 27 27 if ( $menu_exists ) 28 return WP_Error('menu_exists', sprintf( __('A menu named "%s" already exists; please try another name.'), $menu_exists->name ));28 return new WP_Error('menu_exists', sprintf( __('A menu named “%s” already exists; please try another name.'), esc_html( $menu_exists->name ) ) ); 29 29 30 30 $menu = wp_insert_term( $menu_name, 'nav_menu' ); 31 31 if ( is_wp_error($menu) ) … … 97 97 $menu_item->link = get_page_link( $menu_item->object_id ); 98 98 99 99 if ( $menu_item->post_title == '' ) 100 $menu_item->title = htmlentities( get_the_title( $menu_item->object_id ));100 $menu_item->title = get_the_title( $menu_item->object_id ); 101 101 else 102 $menu_item->title = htmlentities( $menu_item->post_title );102 $menu_item->title = $menu_item->post_title; 103 103 104 104 if ( $menu_item->post_content == '' ) 105 $menu_item->description = htmlentities( get_post_meta( $menu_item->ID, 'page-description', true ));105 $menu_item->description = get_post_meta( $menu_item->ID, 'page-description', true ); 106 106 else 107 $menu_item->description = htmlentities( $menu_item->post_content );107 $menu_item->description = $menu_item->post_content; 108 108 $menu_item->target = ''; 109 $menu_item->append = 'Page';109 $menu_item->append = _x('Page', 'menu nav item type'); 110 110 break; 111 111 // Category Menu Item 112 112 case 'category': … … 114 114 115 115 if ( empty($menu_item->post_title) ) { 116 116 $title_raw = get_category( $menu_item->object_id ); 117 $menu_item->title = htmlentities($title_raw->cat_name);117 $menu_item->title = $title_raw->cat_name; 118 118 } else { 119 $menu_item->title = htmlentities( $menu_item->post_title );119 $menu_item->title = $menu_item->post_title; 120 120 } 121 121 122 122 if ( empty($menu_item->post_content) ) 123 $menu_item->description = htmlentities( strip_tags( category_description( $menu_item->object_id )) );123 $menu_item->description = strip_tags( category_description( $menu_item->object_id ) ); 124 124 else 125 $menu_item->description = htmlentities( $menu_item->post_content );125 $menu_item->description = $menu_item->post_content; 126 126 $menu_item->target = ''; 127 $menu_item->append = 'Category';127 $menu_item->append = _x('Category', 'menu nav item type'); 128 128 break; 129 129 default: 130 130 // Custom Menu Item 131 131 $menu_item->link = $menu_item->guid; 132 $menu_item->title = htmlentities( $menu_item->post_title );133 $menu_item->description = htmlentities( $menu_item->post_content );132 $menu_item->title = $menu_item->post_title; 133 $menu_item->description = $menu_item->post_content; 134 134 $menu_item->target = 'target="_blank"'; 135 $menu_item->append = 'Custom';135 $menu_item->append = _x('Custom', 'menu nav item type'); 136 136 break; 137 137 } 138 138 … … 146 146 147 147 //SET anchor title 148 148 if (isset($wp_custom_nav_menu_items->custom_anchor_title)) { 149 $anchor_title = htmlentities($wp_custom_nav_menu_items->custom_anchor_title);149 $anchor_title = $wp_custom_nav_menu_items->custom_anchor_title; 150 150 } 151 151 else { 152 152 $anchor_title = $title; -
wp-includes/script-loader.php
398 398 399 399 // Custom Navigation 400 400 $scripts->add( 'custom-navigation-default-items', "/wp-admin/js/custom-navigation-default-items$suffix.js", false, '20100223' ); 401 $scripts->add( 'custom-navigation-dynamic-functions', "/wp-admin/js/custom-navigation-dynamic-functions$suffix.js", false, '20100220' ); 401 $scripts->add( 'custom-navigation-dynamic-functions', "/wp-admin/js/custom-navigation-dynamic-functions$suffix.js", false, '20100224' ); 402 $scripts->localize( 'custom-navigation-dynamic-functions', 'navMenuL10n', array( 403 'custom' => _x('Custom', 'menu nav item type'), 404 'page' => _x('Page', 'menu nav item type'), 405 'category' => _x('Category', 'menu nav item type') 406 ) ); 407 402 408 $scripts->add( 'custom-navigation-php-functions', "/wp-admin/js/custom-navigation-php-functions$suffix.js", false, '20100220' ); 403 409 } 404 410 } … … 468 474 $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.2' ); 469 475 $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' ); 470 476 $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.1' ); 471 $styles->add( 'custom-navigation', "/wp-admin/css/custom-navigation$suffix.css", array(), '2010022 3' );477 $styles->add( 'custom-navigation', "/wp-admin/css/custom-navigation$suffix.css", array(), '20100224' ); 472 478 473 479 foreach ( $rtl_styles as $rtl_style ) { 474 480 $styles->add_data( $rtl_style, 'rtl', true ); -
wp-includes/default-widgets.php
1120 1120 <ul class="custom-nav"> 1121 1121 <?php 1122 1122 } 1123 1124 ?> 1125 1126 <?php 1127 //DISPLAY custom navigation menu 1128 if ( get_option('wp_custom_nav_menu') == 'true' ) 1129 wp_nav_menu( array('id' => $navmenu, 'name' => $wp_custom_nav_menu_name, 'desc' => $navwidgetdescription, 'format' => 'widget') ); 1130 ?> 1131 1132 <?php 1133 1134 //DEVELOPER settings enabled 1123 wp_nav_menu( array('id' => $navmenu, 'name' => $wp_custom_nav_menu_name, 'desc' => $navwidgetdescription, 'format' => 'widget') ); 1124 //DEVELOPER settings enabled 1135 1125 if ( $navdeveloper == 'yes' ) { 1136 1126 //DISPLAY Custom UL 1137 1127 if ( $navul == 'yes' ) {