Changeset 42343 for trunk/src/wp-admin/includes/nav-menu.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/nav-menu.php
r42217 r42343 22 22 */ 23 23 function _wp_ajax_menu_quick_search( $request = array() ) { 24 $args = array();25 $type = isset( $request['type'] ) ? $request['type'] : '';26 $object_type = isset( $request['object_type'] ) ? $request['object_type'] : '';27 $query = isset( $request['q'] ) ? $request['q'] : '';24 $args = array(); 25 $type = isset( $request['type'] ) ? $request['type'] : ''; 26 $object_type = isset( $request['object_type'] ) ? $request['object_type'] : ''; 27 $query = isset( $request['q'] ) ? $request['q'] : ''; 28 28 $response_format = isset( $request['response-format'] ) && in_array( $request['response-format'], array( 'json', 'markup' ) ) ? $request['response-format'] : 'json'; 29 29 … … 37 37 $object_id = (int) $request['ID']; 38 38 if ( 'markup' == $response_format ) { 39 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args );39 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args ); 40 40 } elseif ( 'json' == $response_format ) { 41 41 echo wp_json_encode( 42 42 array( 43 'ID' => $object_id,43 'ID' => $object_id, 44 44 'post_title' => get_the_title( $object_id ), 45 'post_type' => get_post_type( $object_id ),45 'post_type' => get_post_type( $object_id ), 46 46 ) 47 47 ); … … 53 53 $object_id = (int) $request['ID']; 54 54 if ( 'markup' == $response_format ) { 55 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args );55 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args ); 56 56 } elseif ( 'json' == $response_format ) { 57 57 $post_obj = get_term( $object_id, $object_type ); 58 58 echo wp_json_encode( 59 59 array( 60 'ID' => $object_id,60 'ID' => $object_id, 61 61 'post_title' => $post_obj->name, 62 'post_type' => $object_type,62 'post_type' => $object_type, 63 63 ) 64 64 ); … … 66 66 } 67 67 } 68 69 } 70 71 } elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches) ) { 68 } 69 } elseif ( preg_match( '/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches ) ) { 72 70 if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) { 73 71 $post_type_obj = _wp_nav_menu_meta_box_object( get_post_type_object( $matches[2] ) ); 74 $args = array_merge(72 $args = array_merge( 75 73 $args, 76 74 array( … … 94 92 if ( 'markup' == $response_format ) { 95 93 $var_by_ref = $post->ID; 96 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args );94 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args ); 97 95 } elseif ( 'json' == $response_format ) { 98 96 echo wp_json_encode( 99 97 array( 100 'ID' => $post->ID,98 'ID' => $post->ID, 101 99 'post_title' => get_the_title( $post->ID ), 102 'post_type' => $matches[2],100 'post_type' => $matches[2], 103 101 ) 104 102 ); … … 107 105 } 108 106 } elseif ( 'taxonomy' == $matches[1] ) { 109 $terms = get_terms( $matches[2], array( 110 'name__like' => $query, 111 'number' => 10, 112 )); 113 if ( empty( $terms ) || is_wp_error( $terms ) ) 107 $terms = get_terms( 108 $matches[2], array( 109 'name__like' => $query, 110 'number' => 10, 111 ) 112 ); 113 if ( empty( $terms ) || is_wp_error( $terms ) ) { 114 114 return; 115 } 115 116 foreach ( (array) $terms as $term ) { 116 117 if ( 'markup' == $response_format ) { 117 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );118 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args ); 118 119 } elseif ( 'json' == $response_format ) { 119 120 echo wp_json_encode( 120 121 array( 121 'ID' => $term->term_id,122 'ID' => $term->term_id, 122 123 'post_title' => $term->name, 123 'post_type' => $matches[2],124 'post_type' => $matches[2], 124 125 ) 125 126 ); … … 135 136 * 136 137 * @since 3.0.0 137 * */138 */ 138 139 function wp_nav_menu_setup() { 139 140 // Register meta boxes … … 148 149 if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) { 149 150 $user = wp_get_current_user(); 150 update_user_option($user->ID, 'managenav-menuscolumnshidden', 151 array( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute', ), 152 true); 151 update_user_option( 152 $user->ID, 'managenav-menuscolumnshidden', 153 array( 154 0 => 'link-target', 155 1 => 'css-classes', 156 2 => 'xfn', 157 3 => 'description', 158 4 => 'title-attribute', 159 ), 160 true 161 ); 153 162 } 154 163 } … … 160 169 * 161 170 * @global array $wp_meta_boxes 162 * */171 */ 163 172 function wp_initial_nav_menu_meta_boxes() { 164 173 global $wp_meta_boxes; 165 174 166 if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array( $wp_meta_boxes) )175 if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array( $wp_meta_boxes ) ) { 167 176 return; 177 } 168 178 169 179 $initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' ); 170 $hidden_meta_boxes = array();171 172 foreach ( array_keys( $wp_meta_boxes['nav-menus']) as $context ) {173 foreach ( array_keys( $wp_meta_boxes['nav-menus'][$context]) as $priority ) {174 foreach ( $wp_meta_boxes['nav-menus'][ $context][$priority] as $box ) {180 $hidden_meta_boxes = array(); 181 182 foreach ( array_keys( $wp_meta_boxes['nav-menus'] ) as $context ) { 183 foreach ( array_keys( $wp_meta_boxes['nav-menus'][ $context ] ) as $priority ) { 184 foreach ( $wp_meta_boxes['nav-menus'][ $context ][ $priority ] as $box ) { 175 185 if ( in_array( $box['id'], $initial_meta_boxes ) ) { 176 186 unset( $box['id'] ); … … 194 204 $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); 195 205 196 if ( ! $post_types ) 206 if ( ! $post_types ) { 197 207 return; 208 } 198 209 199 210 foreach ( $post_types as $post_type ) { … … 228 239 $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' ); 229 240 230 if ( ! $taxonomies )241 if ( ! $taxonomies ) { 231 242 return; 243 } 232 244 233 245 foreach ( $taxonomies as $tax ) { … … 254 266 global $one_theme_location_no_menus; 255 267 256 if ( $one_theme_location_no_menus ) 268 if ( $one_theme_location_no_menus ) { 257 269 return false; 270 } 258 271 259 272 return disabled( $nav_menu_selected_id, 0 ); … … 288 301 <p class="button-controls wp-clearfix"> 289 302 <span class="add-to-menu"> 290 <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" />303 <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" /> 291 304 <span class="spinner"></span> 292 305 </span> … … 322 335 // Paginate browsing for large numbers of post objects. 323 336 $per_page = 50; 324 $pagenum = isset( $_REQUEST[$post_type_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;325 $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;337 $pagenum = isset( $_REQUEST[ $post_type_name . '-tab' ] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; 338 $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; 326 339 327 340 $args = array( 328 'offset' => $offset,329 'order' => 'ASC',330 'orderby' => 'title',331 'posts_per_page' => $per_page,332 'post_type' => $post_type_name,333 'suppress_filters' => true,341 'offset' => $offset, 342 'order' => 'ASC', 343 'orderby' => 'title', 344 'posts_per_page' => $per_page, 345 'post_type' => $post_type_name, 346 'suppress_filters' => true, 334 347 'update_post_term_cache' => false, 335 'update_post_meta_cache' => false 348 'update_post_meta_cache' => false, 336 349 ); 337 350 338 if ( isset( $box['args']->_default_query ) ) 339 $args = array_merge($args, (array) $box['args']->_default_query ); 351 if ( isset( $box['args']->_default_query ) ) { 352 $args = array_merge( $args, (array) $box['args']->_default_query ); 353 } 340 354 341 355 // @todo transient caching of these results with proper invalidation on updating of a post of this type 342 356 $get_posts = new WP_Query; 343 $posts = $get_posts->query( $args );357 $posts = $get_posts->query( $args ); 344 358 if ( ! $get_posts->post_count ) { 345 359 echo '<p>' . __( 'No items.' ) . '</p>'; … … 349 363 $num_pages = $get_posts->max_num_pages; 350 364 351 $page_links = paginate_links( array( 352 'base' => add_query_arg( 353 array( 354 $post_type_name . '-tab' => 'all', 355 'paged' => '%#%', 356 'item-type' => 'post_type', 357 'item-object' => $post_type_name, 358 ) 359 ), 360 'format' => '', 361 'prev_text' => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '«' ) . '</span>', 362 'next_text' => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '»' ) . '</span>', 363 'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ', 364 'total' => $num_pages, 365 'current' => $pagenum 366 )); 365 $page_links = paginate_links( 366 array( 367 'base' => add_query_arg( 368 array( 369 $post_type_name . '-tab' => 'all', 370 'paged' => '%#%', 371 'item-type' => 'post_type', 372 'item-object' => $post_type_name, 373 ) 374 ), 375 'format' => '', 376 'prev_text' => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '«' ) . '</span>', 377 'next_text' => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '»' ) . '</span>', 378 'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ', 379 'total' => $num_pages, 380 'current' => $pagenum, 381 ) 382 ); 367 383 368 384 $db_fields = false; 369 385 if ( is_post_type_hierarchical( $post_type_name ) ) { 370 $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); 386 $db_fields = array( 387 'parent' => 'post_parent', 388 'id' => 'ID', 389 ); 371 390 } 372 391 … … 374 393 375 394 $current_tab = 'most-recent'; 376 if ( isset( $_REQUEST[ $post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) {377 $current_tab = $_REQUEST[ $post_type_name . '-tab'];378 } 379 380 if ( ! empty( $_REQUEST[ 'quick-search-posttype-' . $post_type_name] ) ) {395 if ( isset( $_REQUEST[ $post_type_name . '-tab' ] ) && in_array( $_REQUEST[ $post_type_name . '-tab' ], array( 'all', 'search' ) ) ) { 396 $current_tab = $_REQUEST[ $post_type_name . '-tab' ]; 397 } 398 399 if ( ! empty( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ) ) { 381 400 $current_tab = 'search'; 382 401 } … … 393 412 $most_recent_url = $view_all_url = $search_url = ''; 394 413 if ( $nav_menu_selected_id ) { 395 $most_recent_url = esc_url( add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args)));396 $view_all_url = esc_url( add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args)));397 $search_url = esc_url( add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args)));414 $most_recent_url = esc_url( add_query_arg( $post_type_name . '-tab', 'most-recent', remove_query_arg( $removed_args ) ) ); 415 $view_all_url = esc_url( add_query_arg( $post_type_name . '-tab', 'all', remove_query_arg( $removed_args ) ) ); 416 $search_url = esc_url( add_query_arg( $post_type_name . '-tab', 'search', remove_query_arg( $removed_args ) ) ); 398 417 } 399 418 ?> … … 412 431 <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>> 413 432 <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php echo $search_url; ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> 414 <?php _e( 'Search' ); ?>433 <?php _e( 'Search' ); ?> 415 434 </a> 416 435 </li> 417 436 </ul><!-- .posttype-tabs --> 418 437 419 <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php 420 echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); 421 ?>"> 438 <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel 439 <?php 440 echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); 441 ?> 442 "> 422 443 <ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear"> 423 444 <?php 424 $recent_args = array_merge( $args, array( 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15 ) ); 425 $most_recent = $get_posts->query( $recent_args ); 445 $recent_args = array_merge( 446 $args, array( 447 'orderby' => 'post_date', 448 'order' => 'DESC', 449 'posts_per_page' => 15, 450 ) 451 ); 452 $most_recent = $get_posts->query( $recent_args ); 426 453 $args['walker'] = $walker; 427 454 … … 447 474 </div><!-- /.tabs-panel --> 448 475 449 <div class="tabs-panel <?php 476 <div class="tabs-panel 477 <?php 450 478 echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); 451 ?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> 479 ?> 480 " id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> 452 481 <?php 453 if ( isset( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { 454 $searched = esc_attr( $_REQUEST['quick-search-posttype-' . $post_type_name] ); 455 $search_results = get_posts( array( 's' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC', ) ); 482 if ( isset( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ) ) { 483 $searched = esc_attr( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ); 484 $search_results = get_posts( 485 array( 486 's' => $searched, 487 'post_type' => $post_type_name, 488 'fields' => 'all', 489 'order' => 'DESC', 490 ) 491 ); 456 492 } else { 457 $searched = '';493 $searched = ''; 458 494 $search_results = array(); 459 495 } … … 466 502 </p> 467 503 468 <ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name ?>" class="categorychecklist form-no-clear">504 <ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name; ?>" class="categorychecklist form-no-clear"> 469 505 <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> 470 506 <?php 471 507 $args['walker'] = $walker; 472 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $search_results), 0, (object) $args );508 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $search_results ), 0, (object) $args ); 473 509 ?> 474 510 <?php elseif ( is_wp_error( $search_results ) ) : ?> 475 511 <li><?php echo $search_results->get_error_message(); ?></li> 476 512 <?php elseif ( ! empty( $searched ) ) : ?> 477 <li><?php _e( 'No results found.'); ?></li>513 <li><?php _e( 'No results found.' ); ?></li> 478 514 <?php endif; ?> 479 515 </ul> 480 516 </div><!-- /.tabs-panel --> 481 517 482 <div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php 483 echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); 484 ?>"> 518 <div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all 519 <?php 520 echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); 521 ?> 522 "> 485 523 <?php if ( ! empty( $page_links ) ) : ?> 486 524 <div class="add-menu-item-pagelinks"> … … 488 526 </div> 489 527 <?php endif; ?> 490 <ul id="<?php echo $post_type_name; ?>checklist" data-wp-lists="list:<?php echo $post_type_name ?>" class="categorychecklist form-no-clear">528 <ul id="<?php echo $post_type_name; ?>checklist" data-wp-lists="list:<?php echo $post_type_name; ?>" class="categorychecklist form-no-clear"> 491 529 <?php 492 530 $args['walker'] = $walker; … … 497 535 */ 498 536 if ( 'page' == $post_type_name ) { 499 $front_page = 'page' == get_option( 'show_on_front') ? (int) get_option( 'page_on_front' ) : 0;537 $front_page = 'page' == get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0; 500 538 if ( ! empty( $front_page ) ) { 501 $front_page_obj = get_post( $front_page );539 $front_page_obj = get_post( $front_page ); 502 540 $front_page_obj->front_or_home = true; 503 541 array_unshift( $posts, $front_page_obj ); 504 542 } else { 505 $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; 506 array_unshift( $posts, (object) array( 507 'front_or_home' => true, 508 'ID' => 0, 509 'object_id' => $_nav_menu_placeholder, 543 $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1; 544 array_unshift( 545 $posts, (object) array( 546 'front_or_home' => true, 547 'ID' => 0, 548 'object_id' => $_nav_menu_placeholder, 549 'post_content' => '', 550 'post_excerpt' => '', 551 'post_parent' => '', 552 'post_title' => _x( 'Home', 'nav menu home label' ), 553 'post_type' => 'nav_menu_item', 554 'type' => 'custom', 555 'url' => home_url( '/' ), 556 ) 557 ); 558 } 559 } 560 561 $post_type = get_post_type_object( $post_type_name ); 562 563 if ( $post_type->has_archive ) { 564 $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1; 565 array_unshift( 566 $posts, (object) array( 567 'ID' => 0, 568 'object_id' => $_nav_menu_placeholder, 569 'object' => $post_type_name, 510 570 'post_content' => '', 511 571 'post_excerpt' => '', 512 'post_parent' => '', 513 'post_title' => _x('Home', 'nav menu home label'), 514 'post_type' => 'nav_menu_item', 515 'type' => 'custom', 516 'url' => home_url('/'), 517 ) ); 518 } 519 } 520 521 $post_type = get_post_type_object( $post_type_name ); 522 523 if ( $post_type->has_archive ) { 524 $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; 525 array_unshift( $posts, (object) array( 526 'ID' => 0, 527 'object_id' => $_nav_menu_placeholder, 528 'object' => $post_type_name, 529 'post_content' => '', 530 'post_excerpt' => '', 531 'post_title' => $post_type->labels->archives, 532 'post_type' => 'nav_menu_item', 533 'type' => 'post_type_archive', 534 'url' => get_post_type_archive_link( $post_type_name ), 535 ) ); 572 'post_title' => $post_type->labels->archives, 573 'post_type' => 'nav_menu_item', 574 'type' => 'post_type_archive', 575 'url' => get_post_type_archive_link( $post_type_name ), 576 ) 577 ); 536 578 } 537 579 … … 554 596 $posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type ); 555 597 556 $checkbox_items = walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $posts), 0, (object) $args );598 $checkbox_items = walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $posts ), 0, (object) $args ); 557 599 558 600 if ( 'all' == $current_tab && ! empty( $_REQUEST['selectall'] ) ) { 559 $checkbox_items = preg_replace( '/(type=(.)checkbox(\2))/', '$1 checked=$2checked$2', $checkbox_items);601 $checkbox_items = preg_replace( '/(type=(.)checkbox(\2))/', '$1 checked=$2checked$2', $checkbox_items ); 560 602 561 603 } … … 573 615 <p class="button-controls wp-clearfix"> 574 616 <span class="list-controls"> 575 <a href="<?php 576 echo esc_url( add_query_arg( 577 array( 578 $post_type_name . '-tab' => 'all', 579 'selectall' => 1, 580 ), 581 remove_query_arg( $removed_args ) 582 )); 583 ?>#posttype-<?php echo $post_type_name; ?>" class="select-all aria-button-if-js"><?php _e( 'Select All' ); ?></a> 617 <a href=" 618 <?php 619 echo esc_url( 620 add_query_arg( 621 array( 622 $post_type_name . '-tab' => 'all', 623 'selectall' => 1, 624 ), 625 remove_query_arg( $removed_args ) 626 ) 627 ); 628 ?> 629 #posttype-<?php echo $post_type_name; ?>" class="select-all aria-button-if-js"><?php _e( 'Select All' ); ?></a> 584 630 </span> 585 631 … … 614 660 global $nav_menu_selected_id; 615 661 $taxonomy_name = $box['args']->name; 616 $taxonomy = get_taxonomy( $taxonomy_name );662 $taxonomy = get_taxonomy( $taxonomy_name ); 617 663 618 664 // Paginate browsing for large numbers of objects. 619 665 $per_page = 50; 620 $pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;621 $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;666 $pagenum = isset( $_REQUEST[ $taxonomy_name . '-tab' ] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; 667 $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; 622 668 623 669 $args = array( 624 'child_of' => 0,625 'exclude' => '',626 'hide_empty' => false,670 'child_of' => 0, 671 'exclude' => '', 672 'hide_empty' => false, 627 673 'hierarchical' => 1, 628 'include' => '',629 'number' => $per_page,630 'offset' => $offset,631 'order' => 'ASC',632 'orderby' => 'name',633 'pad_counts' => false,674 'include' => '', 675 'number' => $per_page, 676 'offset' => $offset, 677 'order' => 'ASC', 678 'orderby' => 'name', 679 'pad_counts' => false, 634 680 ); 635 681 636 682 $terms = get_terms( $taxonomy_name, $args ); 637 683 638 if ( ! $terms || is_wp_error( $terms) ) {684 if ( ! $terms || is_wp_error( $terms ) ) { 639 685 echo '<p>' . __( 'No items.' ) . '</p>'; 640 686 return; 641 687 } 642 688 643 $num_pages = ceil( wp_count_terms( $taxonomy_name , array_merge( $args, array('number' => '', 'offset' => '') ) ) / $per_page ); 644 645 $page_links = paginate_links( array( 646 'base' => add_query_arg( 647 array( 648 $taxonomy_name . '-tab' => 'all', 649 'paged' => '%#%', 650 'item-type' => 'taxonomy', 651 'item-object' => $taxonomy_name, 689 $num_pages = ceil( 690 wp_count_terms( 691 $taxonomy_name, array_merge( 692 $args, array( 693 'number' => '', 694 'offset' => '', 695 ) 652 696 ) 653 ), 654 'format' => '', 655 'prev_text' => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '«' ) . '</span>', 656 'next_text' => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '»' ) . '</span>', 657 'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ', 658 'total' => $num_pages, 659 'current' => $pagenum 660 )); 697 ) / $per_page 698 ); 699 700 $page_links = paginate_links( 701 array( 702 'base' => add_query_arg( 703 array( 704 $taxonomy_name . '-tab' => 'all', 705 'paged' => '%#%', 706 'item-type' => 'taxonomy', 707 'item-object' => $taxonomy_name, 708 ) 709 ), 710 'format' => '', 711 'prev_text' => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '«' ) . '</span>', 712 'next_text' => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '»' ) . '</span>', 713 'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ', 714 'total' => $num_pages, 715 'current' => $pagenum, 716 ) 717 ); 661 718 662 719 $db_fields = false; 663 720 if ( is_taxonomy_hierarchical( $taxonomy_name ) ) { 664 $db_fields = array( 'parent' => 'parent', 'id' => 'term_id' ); 721 $db_fields = array( 722 'parent' => 'parent', 723 'id' => 'term_id', 724 ); 665 725 } 666 726 … … 668 728 669 729 $current_tab = 'most-used'; 670 if ( isset( $_REQUEST[ $taxonomy_name . '-tab'] ) && in_array( $_REQUEST[$taxonomy_name . '-tab'], array('all', 'most-used', 'search') ) ) {671 $current_tab = $_REQUEST[ $taxonomy_name . '-tab'];672 } 673 674 if ( ! empty( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name] ) ) {730 if ( isset( $_REQUEST[ $taxonomy_name . '-tab' ] ) && in_array( $_REQUEST[ $taxonomy_name . '-tab' ], array( 'all', 'most-used', 'search' ) ) ) { 731 $current_tab = $_REQUEST[ $taxonomy_name . '-tab' ]; 732 } 733 734 if ( ! empty( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ) ) { 675 735 $current_tab = 'search'; 676 736 } … … 687 747 $most_used_url = $view_all_url = $search_url = ''; 688 748 if ( $nav_menu_selected_id ) { 689 $most_used_url = esc_url( add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args)));690 $view_all_url = esc_url( add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args)));691 $search_url = esc_url( add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args)));749 $most_used_url = esc_url( add_query_arg( $taxonomy_name . '-tab', 'most-used', remove_query_arg( $removed_args ) ) ); 750 $view_all_url = esc_url( add_query_arg( $taxonomy_name . '-tab', 'all', remove_query_arg( $removed_args ) ) ); 751 $search_url = esc_url( add_query_arg( $taxonomy_name . '-tab', 'search', remove_query_arg( $removed_args ) ) ); 692 752 } 693 753 ?> … … 711 771 </ul><!-- .taxonomy-tabs --> 712 772 713 <div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php 714 echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); 715 ?>"> 773 <div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel 774 <?php 775 echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); 776 ?> 777 "> 716 778 <ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" > 717 779 <?php 718 $popular_terms = get_terms( $taxonomy_name, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); 780 $popular_terms = get_terms( 781 $taxonomy_name, array( 782 'orderby' => 'count', 783 'order' => 'DESC', 784 'number' => 10, 785 'hierarchical' => false, 786 ) 787 ); 719 788 $args['walker'] = $walker; 720 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $popular_terms), 0, (object) $args );789 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $popular_terms ), 0, (object) $args ); 721 790 ?> 722 791 </ul> 723 792 </div><!-- /.tabs-panel --> 724 793 725 <div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php 726 echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); 727 ?>"> 794 <div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all 795 <?php 796 echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); 797 ?> 798 "> 728 799 <?php if ( ! empty( $page_links ) ) : ?> 729 800 <div class="add-menu-item-pagelinks"> … … 731 802 </div> 732 803 <?php endif; ?> 733 <ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name ?>" class="categorychecklist form-no-clear">804 <ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name; ?>" class="categorychecklist form-no-clear"> 734 805 <?php 735 806 $args['walker'] = $walker; 736 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $terms), 0, (object) $args );807 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $terms ), 0, (object) $args ); 737 808 ?> 738 809 </ul> … … 744 815 </div><!-- /.tabs-panel --> 745 816 746 <div class="tabs-panel <?php 817 <div class="tabs-panel 818 <?php 747 819 echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); 748 ?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> 820 ?> 821 " id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> 749 822 <?php 750 if ( isset( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) { 751 $searched = esc_attr( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ); 752 $search_results = get_terms( $taxonomy_name, array( 'name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false ) ); 823 if ( isset( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ) ) { 824 $searched = esc_attr( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ); 825 $search_results = get_terms( 826 $taxonomy_name, array( 827 'name__like' => $searched, 828 'fields' => 'all', 829 'orderby' => 'count', 830 'order' => 'DESC', 831 'hierarchical' => false, 832 ) 833 ); 753 834 } else { 754 $searched = '';835 $searched = ''; 755 836 $search_results = array(); 756 837 } … … 763 844 </p> 764 845 765 <ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name ?>" class="categorychecklist form-no-clear">846 <ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name; ?>" class="categorychecklist form-no-clear"> 766 847 <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> 767 848 <?php 768 849 $args['walker'] = $walker; 769 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $search_results), 0, (object) $args );850 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $search_results ), 0, (object) $args ); 770 851 ?> 771 852 <?php elseif ( is_wp_error( $search_results ) ) : ?> 772 853 <li><?php echo $search_results->get_error_message(); ?></li> 773 854 <?php elseif ( ! empty( $searched ) ) : ?> 774 <li><?php _e( 'No results found.'); ?></li>855 <li><?php _e( 'No results found.' ); ?></li> 775 856 <?php endif; ?> 776 857 </ul> … … 779 860 <p class="button-controls wp-clearfix"> 780 861 <span class="list-controls"> 781 <a href="<?php 782 echo esc_url(add_query_arg( 783 array( 784 $taxonomy_name . '-tab' => 'all', 785 'selectall' => 1, 786 ), 787 remove_query_arg($removed_args) 788 )); 789 ?>#taxonomy-<?php echo $taxonomy_name; ?>" class="select-all aria-button-if-js"><?php _e( 'Select All' ); ?></a> 862 <a href=" 863 <?php 864 echo esc_url( 865 add_query_arg( 866 array( 867 $taxonomy_name . '-tab' => 'all', 868 'selectall' => 1, 869 ), 870 remove_query_arg( $removed_args ) 871 ) 872 ); 873 ?> 874 #taxonomy-<?php echo $taxonomy_name; ?>" class="select-all aria-button-if-js"><?php _e( 'Select All' ); ?></a> 790 875 </span> 791 876 … … 810 895 */ 811 896 function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) { 812 $menu_id = (int) $menu_id;897 $menu_id = (int) $menu_id; 813 898 $items_saved = array(); 814 899 … … 846 931 847 932 $args = array( 848 'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ),849 'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ),850 'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ),851 'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ),852 'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ),853 'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ),854 'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ),855 'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ),933 'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ), 934 'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ), 935 'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ), 936 'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ), 937 'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ), 938 'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ), 939 'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ), 940 'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ), 856 941 'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ), 857 'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ),858 'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ),859 'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ),860 'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ),942 'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ), 943 'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ), 944 'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ), 945 'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ), 861 946 ); 862 947 … … 883 968 if ( 'page' == $object->name ) { 884 969 $object->_default_query = array( 885 'orderby' => 'menu_order title',970 'orderby' => 'menu_order title', 886 971 'post_status' => 'publish', 887 972 ); 888 973 889 // Posts should show only published items.974 // Posts should show only published items. 890 975 } elseif ( 'post' == $object->name ) { 891 976 $object->_default_query = array( … … 893 978 ); 894 979 895 // Categories should be in reverse chronological order.980 // Categories should be in reverse chronological order. 896 981 } elseif ( 'category' == $object->name ) { 897 982 $object->_default_query = array( 898 983 'orderby' => 'id', 899 'order' => 'DESC',984 'order' => 'DESC', 900 985 ); 901 986 902 // Custom post types should show only published items.987 // Custom post types should show only published items. 903 988 } else { 904 989 $object->_default_query = array( … … 924 1009 // If the menu exists, get its items. 925 1010 if ( is_nav_menu( $menu ) ) { 926 $menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'post_status' => 'any') );927 $result = '<div id="menu-instructions" class="post-body-plain';928 $result .= ( ! empty($menu_items) ) ? ' menu-instructions-inactive">' : '">';929 $result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>';930 $result .= '</div>';931 932 if ( empty( $menu_items) )1011 $menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'post_status' => 'any' ) ); 1012 $result = '<div id="menu-instructions" class="post-body-plain'; 1013 $result .= ( ! empty( $menu_items ) ) ? ' menu-instructions-inactive">' : '">'; 1014 $result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>'; 1015 $result .= '</div>'; 1016 1017 if ( empty( $menu_items ) ) { 933 1018 return $result . ' <ul class="menu" id="menu-to-edit"> </ul>'; 1019 } 934 1020 935 1021 /** … … 946 1032 $walker = new $walker_class_name; 947 1033 } else { 948 return new WP_Error( 'menu_walker_not_exist', 1034 return new WP_Error( 1035 'menu_walker_not_exist', 949 1036 /* translators: %s: walker class name */ 950 sprintf( __( 'The Walker class named %s does not exist.' ), 1037 sprintf( 1038 __( 'The Walker class named %s does not exist.' ), 951 1039 '<strong>' . $walker_class_name . '</strong>' 952 1040 ) … … 956 1044 $some_pending_menu_items = $some_invalid_menu_items = false; 957 1045 foreach ( (array) $menu_items as $menu_item ) { 958 if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) 1046 if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) { 959 1047 $some_pending_menu_items = true; 960 if ( ! empty( $menu_item->_invalid ) ) 1048 } 1049 if ( ! empty( $menu_item->_invalid ) ) { 961 1050 $some_invalid_menu_items = true; 1051 } 962 1052 } 963 1053 … … 971 1061 972 1062 $result .= '<ul class="menu" id="menu-to-edit"> '; 973 $result .= walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );1063 $result .= walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $menu_items ), 0, (object) array( 'walker' => $walker ) ); 974 1064 $result .= ' </ul> '; 975 1065 return $result; … … 1012 1102 1013 1103 // Delete orphaned draft menu items. 1014 $menu_items_to_delete = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < %d", $delete_timestamp ) );1015 1016 foreach ( (array) $menu_items_to_delete as $menu_item_id ) 1104 $menu_items_to_delete = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < %d", $delete_timestamp ) ); 1105 1106 foreach ( (array) $menu_items_to_delete as $menu_item_id ) { 1017 1107 wp_delete_post( $menu_item_id, true ); 1108 } 1018 1109 } 1019 1110 … … 1027 1118 * @return array $messages The menu updated message 1028 1119 */ 1029 function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) { 1030 $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) ); 1031 $messages = array(); 1032 $menu_items = array(); 1120 function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ) { 1121 $unsorted_menu_items = wp_get_nav_menu_items( 1122 $nav_menu_selected_id, array( 1123 'orderby' => 'ID', 1124 'output' => ARRAY_A, 1125 'output_key' => 'ID', 1126 'post_status' => 'draft,publish', 1127 ) 1128 ); 1129 $messages = array(); 1130 $menu_items = array(); 1033 1131 // Index menu items by db ID 1034 foreach ( $unsorted_menu_items as $_item ) 1035 $menu_items[$_item->db_id] = $_item; 1132 foreach ( $unsorted_menu_items as $_item ) { 1133 $menu_items[ $_item->db_id ] = $_item; 1134 } 1036 1135 1037 1136 $post_fields = array( 1038 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 1039 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', 1040 'menu-item-title', 'menu-item-url', 'menu-item-description', 1041 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' 1137 'menu-item-db-id', 1138 'menu-item-object-id', 1139 'menu-item-object', 1140 'menu-item-parent-id', 1141 'menu-item-position', 1142 'menu-item-type', 1143 'menu-item-title', 1144 'menu-item-url', 1145 'menu-item-description', 1146 'menu-item-attr-title', 1147 'menu-item-target', 1148 'menu-item-classes', 1149 'menu-item-xfn', 1042 1150 ); 1043 1151 … … 1048 1156 1049 1157 // Menu item title can't be blank 1050 if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) 1158 if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) { 1051 1159 continue; 1160 } 1052 1161 1053 1162 $args = array(); 1054 foreach ( $post_fields as $field ) 1055 $args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : ''; 1056 1057 $menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args ); 1163 foreach ( $post_fields as $field ) { 1164 $args[ $field ] = isset( $_POST[ $field ][ $_key ] ) ? $_POST[ $field ][ $_key ] : ''; 1165 } 1166 1167 $menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][ $_key ] != $_key ? 0 : $_key ), $args ); 1058 1168 1059 1169 if ( is_wp_error( $menu_item_db_id ) ) { … … 1075 1185 1076 1186 // Store 'auto-add' pages. 1077 $auto_add = ! empty( $_POST['auto-add-pages'] );1187 $auto_add = ! empty( $_POST['auto-add-pages'] ); 1078 1188 $nav_menu_option = (array) get_option( 'nav_menu_options' ); 1079 if ( ! isset( $nav_menu_option['auto_add'] ) ) 1189 if ( ! isset( $nav_menu_option['auto_add'] ) ) { 1080 1190 $nav_menu_option['auto_add'] = array(); 1191 } 1081 1192 if ( $auto_add ) { 1082 if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) 1193 if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) { 1083 1194 $nav_menu_option['auto_add'][] = $nav_menu_selected_id; 1195 } 1084 1196 } else { 1085 if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) 1086 unset( $nav_menu_option['auto_add'][$key] ); 1197 if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) { 1198 unset( $nav_menu_option['auto_add'][ $key ] ); 1199 } 1087 1200 } 1088 1201 // Remove nonexistent/deleted menus … … 1097 1210 $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . 1098 1211 /* translators: %s: nav menu title */ 1099 sprintf( __( '%s has been updated.' ), 1212 sprintf( 1213 __( '%s has been updated.' ), 1100 1214 '<strong>' . $nav_menu_selected_title . '</strong>' 1101 1215 ) . '</p></div>';
Note: See TracChangeset
for help on using the changeset viewer.