Changeset 55616 for trunk/src/wp-admin/includes/nav-menu.php
- Timestamp:
- 04/01/2023 08:35:16 AM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/nav-menu.php
r55615 r55616 40 40 if ( isset( $request['ID'] ) ) { 41 41 $object_id = (int) $request['ID']; 42 42 43 if ( 'markup' === $response_format ) { 43 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args ); 44 echo walk_nav_menu_tree( 45 array_map( 'wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 46 0, 47 (object) $args 48 ); 44 49 } elseif ( 'json' === $response_format ) { 45 50 echo wp_json_encode( … … 56 61 if ( isset( $request['ID'] ) ) { 57 62 $object_id = (int) $request['ID']; 63 58 64 if ( 'markup' === $response_format ) { 59 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args ); 65 echo walk_nav_menu_tree( 66 array_map( 'wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 67 0, 68 (object) $args 69 ); 60 70 } elseif ( 'json' === $response_format ) { 61 71 $post_obj = get_term( $object_id, $object_type ); … … 85 95 ) 86 96 ); 97 87 98 if ( isset( $post_type_obj->_default_query ) ) { 88 99 $args = array_merge( $args, (array) $post_type_obj->_default_query ); 89 100 } 101 90 102 $search_results_query = new WP_Query( $args ); 91 103 if ( ! $search_results_query->have_posts() ) { 92 104 return; 93 105 } 106 94 107 while ( $search_results_query->have_posts() ) { 95 108 $post = $search_results_query->next_post(); 109 96 110 if ( 'markup' === $response_format ) { 97 111 $var_by_ref = $post->ID; 98 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args ); 112 echo walk_nav_menu_tree( 113 array_map( 'wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 114 0, 115 (object) $args 116 ); 99 117 } elseif ( 'json' === $response_format ) { 100 118 echo wp_json_encode( … … 117 135 ) 118 136 ); 137 119 138 if ( empty( $terms ) || is_wp_error( $terms ) ) { 120 139 return; 121 140 } 141 122 142 foreach ( (array) $terms as $term ) { 123 143 if ( 'markup' === $response_format ) { 124 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args ); 144 echo walk_nav_menu_tree( 145 array_map( 'wp_setup_nav_menu_item', array( $term ) ), 146 0, 147 (object) $args 148 ); 125 149 } elseif ( 'json' === $response_format ) { 126 150 echo wp_json_encode( … … 146 170 // Register meta boxes. 147 171 wp_nav_menu_post_type_meta_boxes(); 148 add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' ); 172 add_meta_box( 173 'add-custom-links', 174 __( 'Custom Links' ), 175 'wp_nav_menu_item_link_meta_box', 176 'nav-menus', 177 'side', 178 'default' 179 ); 149 180 wp_nav_menu_taxonomy_meta_boxes(); 150 181 … … 228 259 */ 229 260 $post_type = apply_filters( 'nav_menu_meta_box_object', $post_type ); 261 230 262 if ( $post_type ) { 231 263 $id = $post_type->name; 232 264 // Give pages a higher priority. 233 265 $priority = ( 'page' === $post_type->name ? 'core' : 'default' ); 234 add_meta_box( "add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type ); 266 add_meta_box( 267 "add-post-type-{$id}", 268 $post_type->labels->name, 269 'wp_nav_menu_item_post_type_meta_box', 270 'nav-menus', 271 'side', 272 $priority, 273 $post_type 274 ); 235 275 } 236 276 } … … 252 292 /** This filter is documented in wp-admin/includes/nav-menu.php */ 253 293 $tax = apply_filters( 'nav_menu_meta_box_object', $tax ); 294 254 295 if ( $tax ) { 255 296 $id = $tax->name; 256 add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax ); 297 add_meta_box( 298 "add-{$id}", 299 $tax->labels->name, 300 'wp_nav_menu_item_taxonomy_meta_box', 301 'nav-menus', 302 'side', 303 'default', 304 $tax 305 ); 257 306 } 258 307 } … … 299 348 <p id="menu-item-url-wrap" class="wp-clearfix"> 300 349 <label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label> 301 <input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="code menu-item-textbox form-required" placeholder="https://" /> 350 <input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" 351 type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> 352 class="code menu-item-textbox form-required" placeholder="https://" 353 /> 302 354 </p> 303 355 304 356 <p id="menu-item-name-wrap" class="wp-clearfix"> 305 357 <label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label> 306 <input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="regular-text menu-item-textbox" /> 358 <input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" 359 type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> 360 class="regular-text menu-item-textbox" 361 /> 307 362 </p> 308 363 309 364 <p class="button-controls wp-clearfix"> 310 365 <span class="add-to-menu"> 311 <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" /> 366 <input id="submit-customlinkdiv" name="add-custom-menu-item" 367 type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> 368 class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" 369 /> 312 370 <span class="spinner"></span> 313 371 </span> … … 415 473 if ( ! empty( $privacy_policy_page_id ) ) { 416 474 $privacy_policy_page = get_post( $privacy_policy_page_id ); 475 417 476 if ( $privacy_policy_page instanceof WP_Post && 'publish' === $privacy_policy_page->post_status ) { 418 477 $privacy_policy_page->privacy_policy_page = true; … … 485 544 } 486 545 487 if ( ! empty( $_REQUEST[ 'quick-search-posttype-' . $post_type_name] ) ) {546 if ( ! empty( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] ) ) { 488 547 $current_tab = 'search'; 489 548 } … … 501 560 $view_all_url = ''; 502 561 $search_url = ''; 562 503 563 if ( $nav_menu_selected_id ) { 504 $most_recent_url = esc_url( add_query_arg( $tab_name, 'most-recent', remove_query_arg( $removed_args )) );505 $view_all_url = esc_url( add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args )) );506 $search_url = esc_url( add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args )) );564 $most_recent_url = add_query_arg( $tab_name, 'most-recent', remove_query_arg( $removed_args ) ); 565 $view_all_url = add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ); 566 $search_url = add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ); 507 567 } 508 568 ?> 509 <div id=" posttype-<?php echo esc_attr( $post_type_name); ?>" class="posttypediv">510 <ul id=" posttype-<?php echo esc_attr( $post_type_name ); ?>-tabs" class="posttype-tabs add-menu-item-tabs">569 <div id="<?php echo esc_attr( "posttype-{$post_type_name}" ); ?>" class="posttypediv"> 570 <ul id="<?php echo esc_attr( "posttype-{$post_type_name}-tabs" ); ?>" class="posttype-tabs add-menu-item-tabs"> 511 571 <li <?php echo ( 'most-recent' === $current_tab ? ' class="tabs"' : '' ); ?>> 512 <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php echo $most_recent_url; ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> 572 <a class="nav-tab-link" 573 data-type="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>" 574 href="<?php echo esc_url( $most_recent_url . "#tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>" 575 > 513 576 <?php _e( 'Most Recent' ); ?> 514 577 </a> 515 578 </li> 516 579 <li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>> 517 <a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php echo $view_all_url; ?>#<?php echo $post_type_name; ?>-all"> 580 <a class="nav-tab-link" 581 data-type="<?php echo esc_attr( "{$post_type_name}-all" ); ?>" 582 href="<?php echo esc_url( $view_all_url . "#{$post_type_name}-all" ); ?>" 583 > 518 584 <?php _e( 'View All' ); ?> 519 585 </a> 520 586 </li> 521 587 <li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>> 522 <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"> 588 <a class="nav-tab-link" 589 data-type="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-search" ); ?>" 590 href="<?php echo esc_url( $search_url . "#tabs-panel-posttype-{$post_type_name}-search" ); ?>" 591 > 523 592 <?php _e( 'Search' ); ?> 524 593 </a> … … 526 595 </ul><!-- .posttype-tabs --> 527 596 528 <div id="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" class="tabs-panel <?php echo ( 'most-recent' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php esc_attr_e( 'Most Recent' ); ?>" tabindex="0"> 529 <ul id="<?php echo esc_attr( $post_type_name ); ?>checklist-most-recent" class="categorychecklist form-no-clear"> 597 <div id="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>" 598 class="tabs-panel <?php echo ( 'most-recent' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" 599 role="region" aria-label="<?php esc_attr_e( 'Most Recent' ); ?>" tabindex="0" 600 > 601 <ul id="<?php echo esc_attr( "{$post_type_name}checklist-most-recent" ); ?>" 602 class="categorychecklist form-no-clear" 603 > 530 604 <?php 531 $recent_args 605 $recent_args = array_merge( 532 606 $args, 533 607 array( … … 537 611 ) 538 612 ); 539 $most_recent = $get_posts->query( $recent_args ); 613 $most_recent = $get_posts->query( $recent_args ); 614 540 615 $args['walker'] = $walker; 541 616 … … 559 634 * @param array $recent_args An array of `WP_Query` arguments for 'Most Recent' tab. 560 635 */ 561 $most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box, $recent_args ); 562 563 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $most_recent ), 0, (object) $args ); 636 $most_recent = apply_filters( 637 "nav_menu_items_{$post_type_name}_recent", 638 $most_recent, 639 $args, 640 $box, 641 $recent_args 642 ); 643 644 echo walk_nav_menu_tree( 645 array_map( 'wp_setup_nav_menu_item', $most_recent ), 646 0, 647 (object) $args 648 ); 564 649 ?> 565 650 </ul> 566 651 </div><!-- /.tabs-panel --> 567 652 568 <div class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" role="region" aria-label="<?php echo esc_attr( $post_type->labels->search_items ); ?>" tabindex="0"> 653 <div id="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-search" ); ?>" 654 class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" 655 role="region" aria-label="<?php echo esc_attr( $post_type->labels->search_items ); ?>" tabindex="0" 656 > 569 657 <?php 570 if ( isset( $_REQUEST[ 'quick-search-posttype-' . $post_type_name] ) ) {571 $searched = esc_attr( $_REQUEST[ 'quick-search-posttype-' . $post_type_name] );658 if ( isset( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] ) ) { 659 $searched = esc_attr( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] ); 572 660 $search_results = get_posts( 573 661 array( … … 584 672 ?> 585 673 <p class="quick-search-wrap"> 586 <label for=" quick-search-posttype-<?php echo esc_attr( $post_type_name); ?>" class="screen-reader-text">674 <label for="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>" class="screen-reader-text"> 587 675 <?php 588 676 /* translators: Hidden accessibility text. */ … … 590 678 ?> 591 679 </label> 592 <input type="search"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="quick-search" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo esc_attr( $post_type_name ); ?>" id="quick-search-posttype-<?php echo esc_attr( $post_type_name ); ?>" /> 680 <input type="search"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> 681 class="quick-search" value="<?php echo $searched; ?>" 682 name="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>" 683 id="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>" 684 /> 593 685 <span class="spinner"></span> 594 <?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?> 686 <?php 687 submit_button( 688 __( 'Search' ), 689 'small quick-search-submit hide-if-js', 690 'submit', 691 false, 692 array( 'id' => "submit-quick-search-posttype-{$post_type_name}" ) 693 ); 694 ?> 595 695 </p> 596 696 597 <ul id="<?php echo esc_attr( $post_type_name ); ?>-search-checklist" data-wp-lists="list:<?php echo esc_attr( $post_type_name ); ?>" class="categorychecklist form-no-clear"> 697 <ul id="<?php echo esc_attr( "{$post_type_name}-search-checklist" ); ?>" 698 data-wp-lists="<?php echo esc_attr( "list:{$post_type_name}" ); ?>" 699 class="categorychecklist form-no-clear" 700 > 598 701 <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> 599 702 <?php 600 703 $args['walker'] = $walker; 601 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $search_results ), 0, (object) $args ); 704 echo walk_nav_menu_tree( 705 array_map( 'wp_setup_nav_menu_item', $search_results ), 706 0, 707 (object) $args 708 ); 602 709 ?> 603 710 <?php elseif ( is_wp_error( $search_results ) ) : ?> … … 609 716 </div><!-- /.tabs-panel --> 610 717 611 <div id="<?php echo esc_attr( $post_type_name ); ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo esc_attr( $post_type->labels->all_items ); ?>" tabindex="0"> 718 <div id="<?php echo esc_attr( "{$post_type_name}-all" ); ?>" 719 class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" 720 role="region" aria-label="<?php echo esc_attr( $post_type->labels->all_items ); ?>" tabindex="0" 721 > 612 722 <?php if ( ! empty( $page_links ) ) : ?> 613 723 <div class="add-menu-item-pagelinks"> … … 615 725 </div> 616 726 <?php endif; ?> 617 <ul id="<?php echo esc_attr( $post_type_name ); ?>checklist" data-wp-lists="list:<?php echo esc_attr( $post_type_name ); ?>" class="categorychecklist form-no-clear"> 727 728 <ul id="<?php echo esc_attr( "{$post_type_name}checklist" ); ?>" 729 data-wp-lists="<?php echo esc_attr( "list:{$post_type_name}" ); ?>" 730 class="categorychecklist form-no-clear" 731 > 618 732 <?php 619 733 $args['walker'] = $walker; … … 659 773 * @param WP_Post_Type $post_type The current post type object for this menu item meta box. 660 774 */ 661 $posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type ); 662 663 $checkbox_items = walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $posts ), 0, (object) $args ); 775 $posts = apply_filters( 776 "nav_menu_items_{$post_type_name}", 777 $posts, 778 $args, 779 $post_type 780 ); 781 782 $checkbox_items = walk_nav_menu_tree( 783 array_map( 'wp_setup_nav_menu_item', $posts ), 784 0, 785 (object) $args 786 ); 664 787 665 788 echo $checkbox_items; 666 789 ?> 667 790 </ul> 791 668 792 <?php if ( ! empty( $page_links ) ) : ?> 669 793 <div class="add-menu-item-pagelinks"> … … 673 797 </div><!-- /.tabs-panel --> 674 798 675 <p class="button-controls wp-clearfix" data-items-type=" posttype-<?php echo esc_attr( $post_type_name); ?>">799 <p class="button-controls wp-clearfix" data-items-type="<?php echo esc_attr( "posttype-{$post_type_name}" ); ?>"> 676 800 <span class="list-controls hide-if-no-js"> 677 <input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" /> 801 <input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> 802 id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" 803 /> 678 804 <label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label> 679 805 </span> 680 806 681 807 <span class="add-to-menu"> 682 <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-post-type-menu-item" id="<?php echo esc_attr( 'submit-posttype-' . $post_type_name ); ?>" /> 808 <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> 809 class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" 810 name="add-post-type-menu-item" id="<?php echo esc_attr( "submit-posttype-{$post_type_name}" ); ?>" 811 /> 683 812 <span class="spinner"></span> 684 813 </span> … … 787 916 } 788 917 789 if ( ! empty( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name] ) ) {918 if ( ! empty( $_REQUEST[ "quick-search-taxonomy-{$taxonomy_name}" ] ) ) { 790 919 $current_tab = 'search'; 791 920 } … … 803 932 $view_all_url = ''; 804 933 $search_url = ''; 934 805 935 if ( $nav_menu_selected_id ) { 806 $most_used_url = esc_url( add_query_arg( $tab_name, 'most-used', remove_query_arg( $removed_args )) );807 $view_all_url = esc_url( add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args )) );808 $search_url = esc_url( add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args )) );936 $most_used_url = add_query_arg( $tab_name, 'most-used', remove_query_arg( $removed_args ) ); 937 $view_all_url = add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ); 938 $search_url = add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ); 809 939 } 810 940 ?> 811 <div id=" taxonomy-<?php echo esc_attr( $taxonomy_name); ?>" class="taxonomydiv">812 <ul id=" taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">941 <div id="<?php echo esc_attr( "taxonomy-{$taxonomy_name}" ); ?>" class="taxonomydiv"> 942 <ul id="<?php echo esc_attr( "taxonomy-{$taxonomy_name}-tabs" ); ?>" class="taxonomy-tabs add-menu-item-tabs"> 813 943 <li <?php echo ( 'most-used' === $current_tab ? ' class="tabs"' : '' ); ?>> 814 <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php echo $most_used_url; ?>#tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop"> 944 <a class="nav-tab-link" 945 data-type="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-pop" ); ?>" 946 href="<?php echo esc_url( $most_used_url . "#tabs-panel-{$taxonomy_name}-pop" ); ?>" 947 > 815 948 <?php echo esc_html( $taxonomy->labels->most_used ); ?> 816 949 </a> 817 950 </li> 818 951 <li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>> 819 <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php echo $view_all_url; ?>#tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all"> 952 <a class="nav-tab-link" 953 data-type="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-all" ); ?>" 954 href="<?php echo esc_url( $view_all_url . "#tabs-panel-{$taxonomy_name}-all" ); ?>" 955 > 820 956 <?php _e( 'View All' ); ?> 821 957 </a> 822 958 </li> 823 959 <li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>> 824 <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php echo $search_url; ?>#tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>"> 960 <a class="nav-tab-link" 961 data-type="<?php echo esc_attr( "tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>" 962 href="<?php echo esc_url( $search_url . "#tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>" 963 > 825 964 <?php _e( 'Search' ); ?> 826 965 </a> … … 828 967 </ul><!-- .taxonomy-tabs --> 829 968 830 <div id="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" class="tabs-panel <?php echo ( 'most-used' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->most_used ); ?>" tabindex="0"> 831 <ul id="<?php echo esc_attr( $taxonomy_name ); ?>checklist-pop" class="categorychecklist form-no-clear" > 969 <div id="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-pop" ); ?>" 970 class="tabs-panel <?php echo ( 'most-used' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" 971 role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->most_used ); ?>" tabindex="0" 972 > 973 <ul id="<?php echo esc_attr( "{$taxonomy_name}checklist-pop" ); ?>" 974 class="categorychecklist form-no-clear" 975 > 832 976 <?php 833 $popular_terms 977 $popular_terms = get_terms( 834 978 array( 835 979 'taxonomy' => $taxonomy_name, … … 840 984 ) 841 985 ); 986 842 987 $args['walker'] = $walker; 843 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $popular_terms ), 0, (object) $args ); 988 echo walk_nav_menu_tree( 989 array_map( 'wp_setup_nav_menu_item', $popular_terms ), 990 0, 991 (object) $args 992 ); 844 993 ?> 845 994 </ul> 846 995 </div><!-- /.tabs-panel --> 847 996 848 <div id="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->all_items ); ?>" tabindex="0"> 997 <div id="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-all" ); ?>" 998 class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" 999 role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->all_items ); ?>" tabindex="0" 1000 > 849 1001 <?php if ( ! empty( $page_links ) ) : ?> 850 1002 <div class="add-menu-item-pagelinks"> … … 852 1004 </div> 853 1005 <?php endif; ?> 854 <ul id="<?php echo esc_attr( $taxonomy_name ); ?>checklist" data-wp-lists="list:<?php echo esc_attr( $taxonomy_name ); ?>" class="categorychecklist form-no-clear"> 1006 1007 <ul id="<?php echo esc_attr( "{$taxonomy_name}checklist" ); ?>" 1008 data-wp-lists="<?php echo esc_attr( "list:{$taxonomy_name}" ); ?>" 1009 class="categorychecklist form-no-clear" 1010 > 855 1011 <?php 856 1012 $args['walker'] = $walker; 857 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $terms ), 0, (object) $args ); 1013 echo walk_nav_menu_tree( 1014 array_map( 'wp_setup_nav_menu_item', $terms ), 1015 0, 1016 (object) $args 1017 ); 858 1018 ?> 859 1019 </ul> 1020 860 1021 <?php if ( ! empty( $page_links ) ) : ?> 861 1022 <div class="add-menu-item-pagelinks"> … … 865 1026 </div><!-- /.tabs-panel --> 866 1027 867 <div class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->search_items ); ?>" tabindex="0"> 1028 <div id="<?php echo esc_attr( "tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>" 1029 class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" 1030 role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->search_items ); ?>" tabindex="0"> 868 1031 <?php 869 if ( isset( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name] ) ) {870 $searched = esc_attr( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name] );1032 if ( isset( $_REQUEST[ "quick-search-taxonomy-{$taxonomy_name}" ] ) ) { 1033 $searched = esc_attr( $_REQUEST[ "quick-search-taxonomy-{$taxonomy_name}" ] ); 871 1034 $search_results = get_terms( 872 1035 array( … … 885 1048 ?> 886 1049 <p class="quick-search-wrap"> 887 <label for=" quick-search-taxonomy-<?php echo esc_attr( $taxonomy_name); ?>" class="screen-reader-text">1050 <label for="<?php echo esc_attr( "quick-search-taxonomy-{$taxonomy_name}" ); ?>" class="screen-reader-text"> 888 1051 <?php 889 1052 /* translators: Hidden accessibility text. */ … … 891 1054 ?> 892 1055 </label> 893 <input type="search" class="quick-search" value="<?php echo $searched; ?>" name="quick-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" id="quick-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" /> 1056 <input type="search" 1057 class="quick-search" value="<?php echo $searched; ?>" 1058 name="<?php echo esc_attr( "quick-search-taxonomy-{$taxonomy_name}" ); ?>" 1059 id="<?php echo esc_attr( "quick-search-taxonomy-{$taxonomy_name}" ); ?>" 1060 /> 894 1061 <span class="spinner"></span> 895 <?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?> 1062 <?php 1063 submit_button( 1064 __( 'Search' ), 1065 'small quick-search-submit hide-if-js', 1066 'submit', 1067 false, 1068 array( 'id' => "submit-quick-search-taxonomy-{$taxonomy_name}" ) 1069 ); 1070 ?> 896 1071 </p> 897 1072 898 <ul id="<?php echo esc_attr( $taxonomy_name ); ?>-search-checklist" data-wp-lists="list:<?php echo esc_attr( $taxonomy_name ); ?>" class="categorychecklist form-no-clear"> 1073 <ul id="<?php echo esc_attr( "{$taxonomy_name}-search-checklist" ); ?>" 1074 data-wp-lists="<?php echo esc_attr( "list:{$taxonomy_name}" ); ?>" 1075 class="categorychecklist form-no-clear" 1076 > 899 1077 <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> 900 1078 <?php 901 1079 $args['walker'] = $walker; 902 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $search_results ), 0, (object) $args ); 1080 echo walk_nav_menu_tree( 1081 array_map( 'wp_setup_nav_menu_item', $search_results ), 1082 0, 1083 (object) $args 1084 ); 903 1085 ?> 904 1086 <?php elseif ( is_wp_error( $search_results ) ) : ?> … … 910 1092 </div><!-- /.tabs-panel --> 911 1093 912 <p class="button-controls wp-clearfix" data-items-type=" taxonomy-<?php echo esc_attr( $taxonomy_name); ?>">1094 <p class="button-controls wp-clearfix" data-items-type="<?php echo esc_attr( "taxonomy-{$taxonomy_name}" ); ?>"> 913 1095 <span class="list-controls hide-if-no-js"> 914 <input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" /> 1096 <input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> 1097 id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" 1098 /> 915 1099 <label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label> 916 1100 </span> 917 1101 918 1102 <span class="add-to-menu"> 919 <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-taxonomy-menu-item" id="<?php echo esc_attr( 'submit-taxonomy-' . $taxonomy_name ); ?>" /> 1103 <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> 1104 class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" 1105 name="add-taxonomy-menu-item" id="<?php echo esc_attr( "submit-taxonomy-{$taxonomy_name}" ); ?>" 1106 /> 920 1107 <span class="spinner"></span> 921 1108 </span> … … 992 1179 } 993 1180 } 1181 994 1182 return $items_saved; 995 1183 } … … 1086 1274 $some_pending_menu_items = false; 1087 1275 $some_invalid_menu_items = false; 1276 1088 1277 foreach ( (array) $menu_items as $menu_item ) { 1089 1278 if ( isset( $menu_item->post_status ) && 'draft' === $menu_item->post_status ) { … … 1096 1285 1097 1286 if ( $some_pending_menu_items ) { 1098 $result .= '<div class="notice notice-info notice-alt inline"><p>' . __( 'Click Save Menu to make pending menu items public.' ) . '</p></div>'; 1287 $result .= '<div class="notice notice-info notice-alt inline"><p>' 1288 . __( 'Click Save Menu to make pending menu items public.' ) 1289 . '</p></div>'; 1099 1290 } 1100 1291 1101 1292 if ( $some_invalid_menu_items ) { 1102 $result .= '<div class="notice notice-error notice-alt inline"><p>' . __( 'There are some invalid menu items. Please check or delete them.' ) . '</p></div>'; 1293 $result .= '<div class="notice notice-error notice-alt inline"><p>' 1294 . __( 'There are some invalid menu items. Please check or delete them.' ) 1295 . '</p></div>'; 1103 1296 } 1104 1297 1105 1298 $result .= '<ul class="menu" id="menu-to-edit"> '; 1106 $result .= walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $menu_items ), 0, (object) array( 'walker' => $walker ) ); 1299 $result .= walk_nav_menu_tree( 1300 array_map( 'wp_setup_nav_menu_item', $menu_items ), 1301 0, 1302 (object) array( 'walker' => $walker ) 1303 ); 1107 1304 $result .= ' </ul> '; 1305 1108 1306 return $result; 1109 1307 } elseif ( is_wp_error( $menu ) ) { … … 1142 1340 function _wp_delete_orphaned_draft_menu_items() { 1143 1341 global $wpdb; 1342 1144 1343 $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); 1145 1344 1146 1345 // Delete orphaned draft menu items. 1147 $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 ) ); 1346 $menu_items_to_delete = $wpdb->get_col( 1347 $wpdb->prepare( 1348 "SELECT ID FROM $wpdb->posts AS p 1349 LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id 1350 WHERE post_type = 'nav_menu_item' AND post_status = 'draft' 1351 AND meta_key = '_menu_item_orphaned' AND meta_value < %d", 1352 $delete_timestamp 1353 ) 1354 ); 1148 1355 1149 1356 foreach ( (array) $menu_items_to_delete as $menu_item_id ) { … … 1255 1462 1256 1463 // Remove non-existent/deleted menus. 1257 $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) ); 1464 $nav_menu_option['auto_add'] = array_intersect( 1465 $nav_menu_option['auto_add'], 1466 wp_get_nav_menus( array( 'fields' => 'ids' ) ) 1467 ); 1468 1258 1469 update_option( 'nav_menu_options', $nav_menu_option ); 1259 1470
Note: See TracChangeset
for help on using the changeset viewer.