30 if ( ! $response_format || ! in_array( $response_format, array( 'json', 'markup' ), true ) ) { |
30 if ( ! $response_format || ! in_array( $response_format, array( 'json', 'markup' ), true ) ) { |
31 $response_format = 'json'; |
31 $response_format = 'json'; |
32 } |
32 } |
33 |
33 |
34 if ( 'markup' === $response_format ) { |
34 if ( 'markup' === $response_format ) { |
35 $args['walker'] = new Walker_Nav_Menu_Checklist; |
35 $args['walker'] = new Walker_Nav_Menu_Checklist(); |
36 } |
36 } |
37 |
37 |
38 if ( 'get-post-item' === $type ) { |
38 if ( 'get-post-item' === $type ) { |
39 if ( post_type_exists( $object_type ) ) { |
39 if ( post_type_exists( $object_type ) ) { |
40 if ( isset( $request['ID'] ) ) { |
40 if ( isset( $request['ID'] ) ) { |
41 $object_id = (int) $request['ID']; |
41 $object_id = (int) $request['ID']; |
|
42 |
42 if ( 'markup' === $response_format ) { |
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 } elseif ( 'json' === $response_format ) { |
49 } elseif ( 'json' === $response_format ) { |
45 echo wp_json_encode( |
50 echo wp_json_encode( |
46 array( |
51 array( |
47 'ID' => $object_id, |
52 'ID' => $object_id, |
48 'post_title' => get_the_title( $object_id ), |
53 'post_title' => get_the_title( $object_id ), |
82 'posts_per_page' => 10, |
92 'posts_per_page' => 10, |
83 'post_type' => $matches[2], |
93 'post_type' => $matches[2], |
84 's' => $query, |
94 's' => $query, |
85 ) |
95 ) |
86 ); |
96 ); |
|
97 |
87 if ( isset( $post_type_obj->_default_query ) ) { |
98 if ( isset( $post_type_obj->_default_query ) ) { |
88 $args = array_merge( $args, (array) $post_type_obj->_default_query ); |
99 $args = array_merge( $args, (array) $post_type_obj->_default_query ); |
89 } |
100 } |
|
101 |
90 $search_results_query = new WP_Query( $args ); |
102 $search_results_query = new WP_Query( $args ); |
91 if ( ! $search_results_query->have_posts() ) { |
103 if ( ! $search_results_query->have_posts() ) { |
92 return; |
104 return; |
93 } |
105 } |
|
106 |
94 while ( $search_results_query->have_posts() ) { |
107 while ( $search_results_query->have_posts() ) { |
95 $post = $search_results_query->next_post(); |
108 $post = $search_results_query->next_post(); |
|
109 |
96 if ( 'markup' === $response_format ) { |
110 if ( 'markup' === $response_format ) { |
97 $var_by_ref = $post->ID; |
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 } elseif ( 'json' === $response_format ) { |
117 } elseif ( 'json' === $response_format ) { |
100 echo wp_json_encode( |
118 echo wp_json_encode( |
101 array( |
119 array( |
102 'ID' => $post->ID, |
120 'ID' => $post->ID, |
103 'post_title' => get_the_title( $post->ID ), |
121 'post_title' => get_the_title( $post->ID ), |
296 ?> |
345 ?> |
297 <div class="customlinkdiv" id="customlinkdiv"> |
346 <div class="customlinkdiv" id="customlinkdiv"> |
298 <input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" /> |
347 <input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" /> |
299 <p id="menu-item-url-wrap" class="wp-clearfix"> |
348 <p id="menu-item-url-wrap" class="wp-clearfix"> |
300 <label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label> |
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 </p> |
354 </p> |
303 |
355 |
304 <p id="menu-item-name-wrap" class="wp-clearfix"> |
356 <p id="menu-item-name-wrap" class="wp-clearfix"> |
305 <label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label> |
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 </p> |
362 </p> |
308 |
363 |
309 <p class="button-controls wp-clearfix"> |
364 <p class="button-controls wp-clearfix"> |
310 <span class="add-to-menu"> |
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 <span class="spinner"></span> |
370 <span class="spinner"></span> |
313 </span> |
371 </span> |
314 </p> |
372 </p> |
315 |
373 |
316 </div><!-- /.customlinkdiv --> |
374 </div><!-- /.customlinkdiv --> |
400 |
462 |
401 // Insert Posts Page. |
463 // Insert Posts Page. |
402 $posts_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0; |
464 $posts_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0; |
403 |
465 |
404 if ( ! empty( $posts_page ) ) { |
466 if ( ! empty( $posts_page ) ) { |
405 $posts_page_obj = get_post( $posts_page ); |
467 $posts_page_obj = get_post( $posts_page ); |
406 $posts_page_obj->posts_page = true; |
468 |
407 |
469 if ( $posts_page_obj ) { |
408 $important_pages[] = $posts_page_obj; |
470 $front_page_obj->posts_page = true; |
409 $suppress_page_ids[] = $posts_page_obj->ID; |
471 |
|
472 $important_pages[] = $posts_page_obj; |
|
473 $suppress_page_ids[] = $posts_page_obj->ID; |
|
474 } |
410 } |
475 } |
411 |
476 |
412 // Insert Privacy Policy Page. |
477 // Insert Privacy Policy Page. |
413 $privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); |
478 $privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); |
414 |
479 |
415 if ( ! empty( $privacy_policy_page_id ) ) { |
480 if ( ! empty( $privacy_policy_page_id ) ) { |
416 $privacy_policy_page = get_post( $privacy_policy_page_id ); |
481 $privacy_policy_page = get_post( $privacy_policy_page_id ); |
|
482 |
417 if ( $privacy_policy_page instanceof WP_Post && 'publish' === $privacy_policy_page->post_status ) { |
483 if ( $privacy_policy_page instanceof WP_Post && 'publish' === $privacy_policy_page->post_status ) { |
418 $privacy_policy_page->privacy_policy_page = true; |
484 $privacy_policy_page->privacy_policy_page = true; |
419 |
485 |
420 $important_pages[] = $privacy_policy_page; |
486 $important_pages[] = $privacy_policy_page; |
421 $suppress_page_ids[] = $privacy_policy_page->ID; |
487 $suppress_page_ids[] = $privacy_policy_page->ID; |
497 ); |
564 ); |
498 |
565 |
499 $most_recent_url = ''; |
566 $most_recent_url = ''; |
500 $view_all_url = ''; |
567 $view_all_url = ''; |
501 $search_url = ''; |
568 $search_url = ''; |
|
569 |
502 if ( $nav_menu_selected_id ) { |
570 if ( $nav_menu_selected_id ) { |
503 $most_recent_url = esc_url( add_query_arg( $tab_name, 'most-recent', remove_query_arg( $removed_args ) ) ); |
571 $most_recent_url = add_query_arg( $tab_name, 'most-recent', remove_query_arg( $removed_args ) ); |
504 $view_all_url = esc_url( add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ) ); |
572 $view_all_url = add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ); |
505 $search_url = esc_url( add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ) ); |
573 $search_url = add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ); |
506 } |
574 } |
507 ?> |
575 ?> |
508 <div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv"> |
576 <div id="<?php echo esc_attr( "posttype-{$post_type_name}" ); ?>" class="posttypediv"> |
509 <ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs"> |
577 <ul id="<?php echo esc_attr( "posttype-{$post_type_name}-tabs" ); ?>" class="posttype-tabs add-menu-item-tabs"> |
510 <li <?php echo ( 'most-recent' === $current_tab ? ' class="tabs"' : '' ); ?>> |
578 <li <?php echo ( 'most-recent' === $current_tab ? ' class="tabs"' : '' ); ?>> |
511 <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"> |
579 <a class="nav-tab-link" |
|
580 data-type="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>" |
|
581 href="<?php echo esc_url( $most_recent_url . "#tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>" |
|
582 > |
512 <?php _e( 'Most Recent' ); ?> |
583 <?php _e( 'Most Recent' ); ?> |
513 </a> |
584 </a> |
514 </li> |
585 </li> |
515 <li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>> |
586 <li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>> |
516 <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"> |
587 <a class="nav-tab-link" |
|
588 data-type="<?php echo esc_attr( "{$post_type_name}-all" ); ?>" |
|
589 href="<?php echo esc_url( $view_all_url . "#{$post_type_name}-all" ); ?>" |
|
590 > |
517 <?php _e( 'View All' ); ?> |
591 <?php _e( 'View All' ); ?> |
518 </a> |
592 </a> |
519 </li> |
593 </li> |
520 <li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>> |
594 <li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>> |
521 <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"> |
595 <a class="nav-tab-link" |
|
596 data-type="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-search" ); ?>" |
|
597 href="<?php echo esc_url( $search_url . "#tabs-panel-posttype-{$post_type_name}-search" ); ?>" |
|
598 > |
522 <?php _e( 'Search' ); ?> |
599 <?php _e( 'Search' ); ?> |
523 </a> |
600 </a> |
524 </li> |
601 </li> |
525 </ul><!-- .posttype-tabs --> |
602 </ul><!-- .posttype-tabs --> |
526 |
603 |
527 <div id="tabs-panel-posttype-<?php echo $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 _e( 'Most Recent' ); ?>" tabindex="0"> |
604 <div id="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>" |
528 <ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear"> |
605 class="tabs-panel <?php echo ( 'most-recent' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" |
|
606 role="region" aria-label="<?php esc_attr_e( 'Most Recent' ); ?>" tabindex="0" |
|
607 > |
|
608 <ul id="<?php echo esc_attr( "{$post_type_name}checklist-most-recent" ); ?>" |
|
609 class="categorychecklist form-no-clear" |
|
610 > |
529 <?php |
611 <?php |
530 $recent_args = array_merge( |
612 $recent_args = array_merge( |
531 $args, |
613 $args, |
532 array( |
614 array( |
533 'orderby' => 'post_date', |
615 'orderby' => 'post_date', |
534 'order' => 'DESC', |
616 'order' => 'DESC', |
535 'posts_per_page' => 15, |
617 'posts_per_page' => 15, |
536 ) |
618 ) |
537 ); |
619 ); |
538 $most_recent = $get_posts->query( $recent_args ); |
620 $most_recent = $get_posts->query( $recent_args ); |
|
621 |
539 $args['walker'] = $walker; |
622 $args['walker'] = $walker; |
540 |
623 |
541 /** |
624 /** |
542 * Filters the posts displayed in the 'Most Recent' tab of the current |
625 * Filters the posts displayed in the 'Most Recent' tab of the current |
543 * post type's menu items meta box. |
626 * post type's menu items meta box. |
555 * @param WP_Post[] $most_recent An array of post objects being listed. |
638 * @param WP_Post[] $most_recent An array of post objects being listed. |
556 * @param array $args An array of `WP_Query` arguments for the meta box. |
639 * @param array $args An array of `WP_Query` arguments for the meta box. |
557 * @param array $box Arguments passed to `wp_nav_menu_item_post_type_meta_box()`. |
640 * @param array $box Arguments passed to `wp_nav_menu_item_post_type_meta_box()`. |
558 * @param array $recent_args An array of `WP_Query` arguments for 'Most Recent' tab. |
641 * @param array $recent_args An array of `WP_Query` arguments for 'Most Recent' tab. |
559 */ |
642 */ |
560 $most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box, $recent_args ); |
643 $most_recent = apply_filters( |
561 |
644 "nav_menu_items_{$post_type_name}_recent", |
562 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $most_recent ), 0, (object) $args ); |
645 $most_recent, |
|
646 $args, |
|
647 $box, |
|
648 $recent_args |
|
649 ); |
|
650 |
|
651 echo walk_nav_menu_tree( |
|
652 array_map( 'wp_setup_nav_menu_item', $most_recent ), |
|
653 0, |
|
654 (object) $args |
|
655 ); |
563 ?> |
656 ?> |
564 </ul> |
657 </ul> |
565 </div><!-- /.tabs-panel --> |
658 </div><!-- /.tabs-panel --> |
566 |
659 |
567 <div class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search" role="region" aria-label="<?php echo $post_type->labels->search_items; ?>" tabindex="0"> |
660 <div id="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-search" ); ?>" |
|
661 class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" |
|
662 role="region" aria-label="<?php echo esc_attr( $post_type->labels->search_items ); ?>" tabindex="0" |
|
663 > |
568 <?php |
664 <?php |
569 if ( isset( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ) ) { |
665 if ( isset( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] ) ) { |
570 $searched = esc_attr( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ); |
666 $searched = esc_attr( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] ); |
571 $search_results = get_posts( |
667 $search_results = get_posts( |
572 array( |
668 array( |
573 's' => $searched, |
669 's' => $searched, |
574 'post_type' => $post_type_name, |
670 'post_type' => $post_type_name, |
575 'fields' => 'all', |
671 'fields' => 'all', |
580 $searched = ''; |
676 $searched = ''; |
581 $search_results = array(); |
677 $search_results = array(); |
582 } |
678 } |
583 ?> |
679 ?> |
584 <p class="quick-search-wrap"> |
680 <p class="quick-search-wrap"> |
585 <label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label> |
681 <label for="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>" class="screen-reader-text"> |
586 <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 $post_type_name; ?>" id="quick-search-posttype-<?php echo $post_type_name; ?>" /> |
682 <?php |
|
683 /* translators: Hidden accessibility text. */ |
|
684 _e( 'Search' ); |
|
685 ?> |
|
686 </label> |
|
687 <input type="search"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> |
|
688 class="quick-search" value="<?php echo $searched; ?>" |
|
689 name="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>" |
|
690 id="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>" |
|
691 /> |
587 <span class="spinner"></span> |
692 <span class="spinner"></span> |
588 <?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?> |
693 <?php |
|
694 submit_button( |
|
695 __( 'Search' ), |
|
696 'small quick-search-submit hide-if-js', |
|
697 'submit', |
|
698 false, |
|
699 array( 'id' => "submit-quick-search-posttype-{$post_type_name}" ) |
|
700 ); |
|
701 ?> |
589 </p> |
702 </p> |
590 |
703 |
591 <ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name; ?>" class="categorychecklist form-no-clear"> |
704 <ul id="<?php echo esc_attr( "{$post_type_name}-search-checklist" ); ?>" |
|
705 data-wp-lists="<?php echo esc_attr( "list:{$post_type_name}" ); ?>" |
|
706 class="categorychecklist form-no-clear" |
|
707 > |
592 <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
708 <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
593 <?php |
709 <?php |
594 $args['walker'] = $walker; |
710 $args['walker'] = $walker; |
595 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $search_results ), 0, (object) $args ); |
711 echo walk_nav_menu_tree( |
|
712 array_map( 'wp_setup_nav_menu_item', $search_results ), |
|
713 0, |
|
714 (object) $args |
|
715 ); |
596 ?> |
716 ?> |
597 <?php elseif ( is_wp_error( $search_results ) ) : ?> |
717 <?php elseif ( is_wp_error( $search_results ) ) : ?> |
598 <li><?php echo $search_results->get_error_message(); ?></li> |
718 <li><?php echo $search_results->get_error_message(); ?></li> |
599 <?php elseif ( ! empty( $searched ) ) : ?> |
719 <?php elseif ( ! empty( $searched ) ) : ?> |
600 <li><?php _e( 'No results found.' ); ?></li> |
720 <li><?php _e( 'No results found.' ); ?></li> |
601 <?php endif; ?> |
721 <?php endif; ?> |
602 </ul> |
722 </ul> |
603 </div><!-- /.tabs-panel --> |
723 </div><!-- /.tabs-panel --> |
604 |
724 |
605 <div id="<?php echo $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 $post_type->labels->all_items; ?>" tabindex="0"> |
725 <div id="<?php echo esc_attr( "{$post_type_name}-all" ); ?>" |
|
726 class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" |
|
727 role="region" aria-label="<?php echo esc_attr( $post_type->labels->all_items ); ?>" tabindex="0" |
|
728 > |
606 <?php if ( ! empty( $page_links ) ) : ?> |
729 <?php if ( ! empty( $page_links ) ) : ?> |
607 <div class="add-menu-item-pagelinks"> |
730 <div class="add-menu-item-pagelinks"> |
608 <?php echo $page_links; ?> |
731 <?php echo $page_links; ?> |
609 </div> |
732 </div> |
610 <?php endif; ?> |
733 <?php endif; ?> |
611 <ul id="<?php echo $post_type_name; ?>checklist" data-wp-lists="list:<?php echo $post_type_name; ?>" class="categorychecklist form-no-clear"> |
734 |
|
735 <ul id="<?php echo esc_attr( "{$post_type_name}checklist" ); ?>" |
|
736 data-wp-lists="<?php echo esc_attr( "list:{$post_type_name}" ); ?>" |
|
737 class="categorychecklist form-no-clear" |
|
738 > |
612 <?php |
739 <?php |
613 $args['walker'] = $walker; |
740 $args['walker'] = $walker; |
614 |
741 |
615 if ( $post_type->has_archive ) { |
742 if ( $post_type->has_archive ) { |
616 $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1; |
743 $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1; |
650 * @param object[] $posts The posts for the current post type. Mostly `WP_Post` objects, but |
777 * @param object[] $posts The posts for the current post type. Mostly `WP_Post` objects, but |
651 * can also contain "fake" post objects to represent other menu items. |
778 * can also contain "fake" post objects to represent other menu items. |
652 * @param array $args An array of `WP_Query` arguments. |
779 * @param array $args An array of `WP_Query` arguments. |
653 * @param WP_Post_Type $post_type The current post type object for this menu item meta box. |
780 * @param WP_Post_Type $post_type The current post type object for this menu item meta box. |
654 */ |
781 */ |
655 $posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type ); |
782 $posts = apply_filters( |
656 |
783 "nav_menu_items_{$post_type_name}", |
657 $checkbox_items = walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $posts ), 0, (object) $args ); |
784 $posts, |
|
785 $args, |
|
786 $post_type |
|
787 ); |
|
788 |
|
789 $checkbox_items = walk_nav_menu_tree( |
|
790 array_map( 'wp_setup_nav_menu_item', $posts ), |
|
791 0, |
|
792 (object) $args |
|
793 ); |
658 |
794 |
659 echo $checkbox_items; |
795 echo $checkbox_items; |
660 ?> |
796 ?> |
661 </ul> |
797 </ul> |
|
798 |
662 <?php if ( ! empty( $page_links ) ) : ?> |
799 <?php if ( ! empty( $page_links ) ) : ?> |
663 <div class="add-menu-item-pagelinks"> |
800 <div class="add-menu-item-pagelinks"> |
664 <?php echo $page_links; ?> |
801 <?php echo $page_links; ?> |
665 </div> |
802 </div> |
666 <?php endif; ?> |
803 <?php endif; ?> |
667 </div><!-- /.tabs-panel --> |
804 </div><!-- /.tabs-panel --> |
668 |
805 |
669 <p class="button-controls wp-clearfix" data-items-type="posttype-<?php echo esc_attr( $post_type_name ); ?>"> |
806 <p class="button-controls wp-clearfix" data-items-type="<?php echo esc_attr( "posttype-{$post_type_name}" ); ?>"> |
670 <span class="list-controls hide-if-no-js"> |
807 <span class="list-controls hide-if-no-js"> |
671 <input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" /> |
808 <input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> |
|
809 id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" |
|
810 /> |
672 <label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label> |
811 <label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label> |
673 </span> |
812 </span> |
674 |
813 |
675 <span class="add-to-menu"> |
814 <span class="add-to-menu"> |
676 <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 ); ?>" /> |
815 <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> |
|
816 class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" |
|
817 name="add-post-type-menu-item" id="<?php echo esc_attr( "submit-posttype-{$post_type_name}" ); ?>" |
|
818 /> |
677 <span class="spinner"></span> |
819 <span class="spinner"></span> |
678 </span> |
820 </span> |
679 </p> |
821 </p> |
680 |
822 |
681 </div><!-- /.posttypediv --> |
823 </div><!-- /.posttypediv --> |
793 ); |
936 ); |
794 |
937 |
795 $most_used_url = ''; |
938 $most_used_url = ''; |
796 $view_all_url = ''; |
939 $view_all_url = ''; |
797 $search_url = ''; |
940 $search_url = ''; |
|
941 |
798 if ( $nav_menu_selected_id ) { |
942 if ( $nav_menu_selected_id ) { |
799 $most_used_url = esc_url( add_query_arg( $tab_name, 'most-used', remove_query_arg( $removed_args ) ) ); |
943 $most_used_url = add_query_arg( $tab_name, 'most-used', remove_query_arg( $removed_args ) ); |
800 $view_all_url = esc_url( add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ) ); |
944 $view_all_url = add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ); |
801 $search_url = esc_url( add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ) ); |
945 $search_url = add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ); |
802 } |
946 } |
803 ?> |
947 ?> |
804 <div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv"> |
948 <div id="<?php echo esc_attr( "taxonomy-{$taxonomy_name}" ); ?>" class="taxonomydiv"> |
805 <ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs"> |
949 <ul id="<?php echo esc_attr( "taxonomy-{$taxonomy_name}-tabs" ); ?>" class="taxonomy-tabs add-menu-item-tabs"> |
806 <li <?php echo ( 'most-used' === $current_tab ? ' class="tabs"' : '' ); ?>> |
950 <li <?php echo ( 'most-used' === $current_tab ? ' class="tabs"' : '' ); ?>> |
807 <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 $taxonomy_name; ?>-pop"> |
951 <a class="nav-tab-link" |
|
952 data-type="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-pop" ); ?>" |
|
953 href="<?php echo esc_url( $most_used_url . "#tabs-panel-{$taxonomy_name}-pop" ); ?>" |
|
954 > |
808 <?php echo esc_html( $taxonomy->labels->most_used ); ?> |
955 <?php echo esc_html( $taxonomy->labels->most_used ); ?> |
809 </a> |
956 </a> |
810 </li> |
957 </li> |
811 <li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>> |
958 <li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>> |
812 <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 $taxonomy_name; ?>-all"> |
959 <a class="nav-tab-link" |
|
960 data-type="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-all" ); ?>" |
|
961 href="<?php echo esc_url( $view_all_url . "#tabs-panel-{$taxonomy_name}-all" ); ?>" |
|
962 > |
813 <?php _e( 'View All' ); ?> |
963 <?php _e( 'View All' ); ?> |
814 </a> |
964 </a> |
815 </li> |
965 </li> |
816 <li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>> |
966 <li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>> |
817 <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 $taxonomy_name; ?>"> |
967 <a class="nav-tab-link" |
|
968 data-type="<?php echo esc_attr( "tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>" |
|
969 href="<?php echo esc_url( $search_url . "#tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>" |
|
970 > |
818 <?php _e( 'Search' ); ?> |
971 <?php _e( 'Search' ); ?> |
819 </a> |
972 </a> |
820 </li> |
973 </li> |
821 </ul><!-- .taxonomy-tabs --> |
974 </ul><!-- .taxonomy-tabs --> |
822 |
975 |
823 <div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php echo ( 'most-used' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $taxonomy->labels->most_used; ?>" tabindex="0"> |
976 <div id="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-pop" ); ?>" |
824 <ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" > |
977 class="tabs-panel <?php echo ( 'most-used' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" |
|
978 role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->most_used ); ?>" tabindex="0" |
|
979 > |
|
980 <ul id="<?php echo esc_attr( "{$taxonomy_name}checklist-pop" ); ?>" |
|
981 class="categorychecklist form-no-clear" |
|
982 > |
825 <?php |
983 <?php |
826 $popular_terms = get_terms( |
984 $popular_terms = get_terms( |
827 array( |
985 array( |
828 'taxonomy' => $taxonomy_name, |
986 'taxonomy' => $taxonomy_name, |
829 'orderby' => 'count', |
987 'orderby' => 'count', |
830 'order' => 'DESC', |
988 'order' => 'DESC', |
831 'number' => 10, |
989 'number' => 10, |
832 'hierarchical' => false, |
990 'hierarchical' => false, |
833 ) |
991 ) |
834 ); |
992 ); |
|
993 |
835 $args['walker'] = $walker; |
994 $args['walker'] = $walker; |
836 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $popular_terms ), 0, (object) $args ); |
995 echo walk_nav_menu_tree( |
|
996 array_map( 'wp_setup_nav_menu_item', $popular_terms ), |
|
997 0, |
|
998 (object) $args |
|
999 ); |
837 ?> |
1000 ?> |
838 </ul> |
1001 </ul> |
839 </div><!-- /.tabs-panel --> |
1002 </div><!-- /.tabs-panel --> |
840 |
1003 |
841 <div id="tabs-panel-<?php echo $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 $taxonomy->labels->all_items; ?>" tabindex="0"> |
1004 <div id="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-all" ); ?>" |
|
1005 class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" |
|
1006 role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->all_items ); ?>" tabindex="0" |
|
1007 > |
842 <?php if ( ! empty( $page_links ) ) : ?> |
1008 <?php if ( ! empty( $page_links ) ) : ?> |
843 <div class="add-menu-item-pagelinks"> |
1009 <div class="add-menu-item-pagelinks"> |
844 <?php echo $page_links; ?> |
1010 <?php echo $page_links; ?> |
845 </div> |
1011 </div> |
846 <?php endif; ?> |
1012 <?php endif; ?> |
847 <ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name; ?>" class="categorychecklist form-no-clear"> |
1013 |
|
1014 <ul id="<?php echo esc_attr( "{$taxonomy_name}checklist" ); ?>" |
|
1015 data-wp-lists="<?php echo esc_attr( "list:{$taxonomy_name}" ); ?>" |
|
1016 class="categorychecklist form-no-clear" |
|
1017 > |
848 <?php |
1018 <?php |
849 $args['walker'] = $walker; |
1019 $args['walker'] = $walker; |
850 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $terms ), 0, (object) $args ); |
1020 echo walk_nav_menu_tree( |
|
1021 array_map( 'wp_setup_nav_menu_item', $terms ), |
|
1022 0, |
|
1023 (object) $args |
|
1024 ); |
851 ?> |
1025 ?> |
852 </ul> |
1026 </ul> |
|
1027 |
853 <?php if ( ! empty( $page_links ) ) : ?> |
1028 <?php if ( ! empty( $page_links ) ) : ?> |
854 <div class="add-menu-item-pagelinks"> |
1029 <div class="add-menu-item-pagelinks"> |
855 <?php echo $page_links; ?> |
1030 <?php echo $page_links; ?> |
856 </div> |
1031 </div> |
857 <?php endif; ?> |
1032 <?php endif; ?> |
858 </div><!-- /.tabs-panel --> |
1033 </div><!-- /.tabs-panel --> |
859 |
1034 |
860 <div class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>" role="region" aria-label="<?php echo $taxonomy->labels->search_items; ?>" tabindex="0"> |
1035 <div id="<?php echo esc_attr( "tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>" |
|
1036 class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" |
|
1037 role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->search_items ); ?>" tabindex="0"> |
861 <?php |
1038 <?php |
862 if ( isset( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ) ) { |
1039 if ( isset( $_REQUEST[ "quick-search-taxonomy-{$taxonomy_name}" ] ) ) { |
863 $searched = esc_attr( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ); |
1040 $searched = esc_attr( $_REQUEST[ "quick-search-taxonomy-{$taxonomy_name}" ] ); |
864 $search_results = get_terms( |
1041 $search_results = get_terms( |
865 array( |
1042 array( |
866 'taxonomy' => $taxonomy_name, |
1043 'taxonomy' => $taxonomy_name, |
867 'name__like' => $searched, |
1044 'name__like' => $searched, |
868 'fields' => 'all', |
1045 'fields' => 'all', |
875 $searched = ''; |
1052 $searched = ''; |
876 $search_results = array(); |
1053 $search_results = array(); |
877 } |
1054 } |
878 ?> |
1055 ?> |
879 <p class="quick-search-wrap"> |
1056 <p class="quick-search-wrap"> |
880 <label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label> |
1057 <label for="<?php echo esc_attr( "quick-search-taxonomy-{$taxonomy_name}" ); ?>" class="screen-reader-text"> |
881 <input type="search" class="quick-search" value="<?php echo $searched; ?>" name="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" id="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" /> |
1058 <?php |
|
1059 /* translators: Hidden accessibility text. */ |
|
1060 _e( 'Search' ); |
|
1061 ?> |
|
1062 </label> |
|
1063 <input type="search" |
|
1064 class="quick-search" value="<?php echo $searched; ?>" |
|
1065 name="<?php echo esc_attr( "quick-search-taxonomy-{$taxonomy_name}" ); ?>" |
|
1066 id="<?php echo esc_attr( "quick-search-taxonomy-{$taxonomy_name}" ); ?>" |
|
1067 /> |
882 <span class="spinner"></span> |
1068 <span class="spinner"></span> |
883 <?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?> |
1069 <?php |
|
1070 submit_button( |
|
1071 __( 'Search' ), |
|
1072 'small quick-search-submit hide-if-js', |
|
1073 'submit', |
|
1074 false, |
|
1075 array( 'id' => "submit-quick-search-taxonomy-{$taxonomy_name}" ) |
|
1076 ); |
|
1077 ?> |
884 </p> |
1078 </p> |
885 |
1079 |
886 <ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name; ?>" class="categorychecklist form-no-clear"> |
1080 <ul id="<?php echo esc_attr( "{$taxonomy_name}-search-checklist" ); ?>" |
|
1081 data-wp-lists="<?php echo esc_attr( "list:{$taxonomy_name}" ); ?>" |
|
1082 class="categorychecklist form-no-clear" |
|
1083 > |
887 <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
1084 <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
888 <?php |
1085 <?php |
889 $args['walker'] = $walker; |
1086 $args['walker'] = $walker; |
890 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $search_results ), 0, (object) $args ); |
1087 echo walk_nav_menu_tree( |
|
1088 array_map( 'wp_setup_nav_menu_item', $search_results ), |
|
1089 0, |
|
1090 (object) $args |
|
1091 ); |
891 ?> |
1092 ?> |
892 <?php elseif ( is_wp_error( $search_results ) ) : ?> |
1093 <?php elseif ( is_wp_error( $search_results ) ) : ?> |
893 <li><?php echo $search_results->get_error_message(); ?></li> |
1094 <li><?php echo $search_results->get_error_message(); ?></li> |
894 <?php elseif ( ! empty( $searched ) ) : ?> |
1095 <?php elseif ( ! empty( $searched ) ) : ?> |
895 <li><?php _e( 'No results found.' ); ?></li> |
1096 <li><?php _e( 'No results found.' ); ?></li> |
896 <?php endif; ?> |
1097 <?php endif; ?> |
897 </ul> |
1098 </ul> |
898 </div><!-- /.tabs-panel --> |
1099 </div><!-- /.tabs-panel --> |
899 |
1100 |
900 <p class="button-controls wp-clearfix" data-items-type="taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>"> |
1101 <p class="button-controls wp-clearfix" data-items-type="<?php echo esc_attr( "taxonomy-{$taxonomy_name}" ); ?>"> |
901 <span class="list-controls hide-if-no-js"> |
1102 <span class="list-controls hide-if-no-js"> |
902 <input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" /> |
1103 <input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> |
|
1104 id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" |
|
1105 /> |
903 <label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label> |
1106 <label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label> |
904 </span> |
1107 </span> |
905 |
1108 |
906 <span class="add-to-menu"> |
1109 <span class="add-to-menu"> |
907 <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 ); ?>" /> |
1110 <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> |
|
1111 class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" |
|
1112 name="add-taxonomy-menu-item" id="<?php echo esc_attr( "submit-taxonomy-{$taxonomy_name}" ); ?>" |
|
1113 /> |
908 <span class="spinner"></span> |
1114 <span class="spinner"></span> |
909 </span> |
1115 </span> |
910 </p> |
1116 </p> |
911 |
1117 |
912 </div><!-- /.taxonomydiv --> |
1118 </div><!-- /.taxonomydiv --> |
1071 ); |
1278 ); |
1072 } |
1279 } |
1073 |
1280 |
1074 $some_pending_menu_items = false; |
1281 $some_pending_menu_items = false; |
1075 $some_invalid_menu_items = false; |
1282 $some_invalid_menu_items = false; |
|
1283 |
1076 foreach ( (array) $menu_items as $menu_item ) { |
1284 foreach ( (array) $menu_items as $menu_item ) { |
1077 if ( isset( $menu_item->post_status ) && 'draft' === $menu_item->post_status ) { |
1285 if ( isset( $menu_item->post_status ) && 'draft' === $menu_item->post_status ) { |
1078 $some_pending_menu_items = true; |
1286 $some_pending_menu_items = true; |
1079 } |
1287 } |
1080 if ( ! empty( $menu_item->_invalid ) ) { |
1288 if ( ! empty( $menu_item->_invalid ) ) { |
1081 $some_invalid_menu_items = true; |
1289 $some_invalid_menu_items = true; |
1082 } |
1290 } |
1083 } |
1291 } |
1084 |
1292 |
1085 if ( $some_pending_menu_items ) { |
1293 if ( $some_pending_menu_items ) { |
1086 $result .= '<div class="notice notice-info notice-alt inline"><p>' . __( 'Click Save Menu to make pending menu items public.' ) . '</p></div>'; |
1294 $message = __( 'Click Save Menu to make pending menu items public.' ); |
|
1295 $notice_args = array( |
|
1296 'type' => 'info', |
|
1297 'additional_classes' => array( 'notice-alt', 'inline' ), |
|
1298 ); |
|
1299 $result .= wp_get_admin_notice( $message, $notice_args ); |
1087 } |
1300 } |
1088 |
1301 |
1089 if ( $some_invalid_menu_items ) { |
1302 if ( $some_invalid_menu_items ) { |
1090 $result .= '<div class="notice notice-error notice-alt inline"><p>' . __( 'There are some invalid menu items. Please check or delete them.' ) . '</p></div>'; |
1303 $message = __( 'There are some invalid menu items. Please check or delete them.' ); |
|
1304 $notice_args = array( |
|
1305 'type' => 'error', |
|
1306 'additional_classes' => array( 'notice-alt', 'inline' ), |
|
1307 ); |
|
1308 $result .= wp_get_admin_notice( $message, $notice_args ); |
1091 } |
1309 } |
1092 |
1310 |
1093 $result .= '<ul class="menu" id="menu-to-edit"> '; |
1311 $result .= '<ul class="menu" id="menu-to-edit"> '; |
1094 $result .= walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $menu_items ), 0, (object) array( 'walker' => $walker ) ); |
1312 $result .= walk_nav_menu_tree( |
|
1313 array_map( 'wp_setup_nav_menu_item', $menu_items ), |
|
1314 0, |
|
1315 (object) array( 'walker' => $walker ) |
|
1316 ); |
1095 $result .= ' </ul> '; |
1317 $result .= ' </ul> '; |
|
1318 |
1096 return $result; |
1319 return $result; |
1097 } elseif ( is_wp_error( $menu ) ) { |
1320 } elseif ( is_wp_error( $menu ) ) { |
1098 return $menu; |
1321 return $menu; |
1099 } |
1322 } |
1100 |
|
1101 } |
1323 } |
1102 |
1324 |
1103 /** |
1325 /** |
1104 * Returns the columns for the nav menus page. |
1326 * Returns the columns for the nav menus page. |
1105 * |
1327 * |
1127 * |
1349 * |
1128 * @global wpdb $wpdb WordPress database abstraction object. |
1350 * @global wpdb $wpdb WordPress database abstraction object. |
1129 */ |
1351 */ |
1130 function _wp_delete_orphaned_draft_menu_items() { |
1352 function _wp_delete_orphaned_draft_menu_items() { |
1131 global $wpdb; |
1353 global $wpdb; |
|
1354 |
1132 $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
1355 $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
1133 |
1356 |
1134 // Delete orphaned draft menu items. |
1357 // Delete orphaned draft menu items. |
1135 $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 ) ); |
1358 $menu_items_to_delete = $wpdb->get_col( |
|
1359 $wpdb->prepare( |
|
1360 "SELECT ID FROM $wpdb->posts AS p |
|
1361 LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id |
|
1362 WHERE post_type = 'nav_menu_item' AND post_status = 'draft' |
|
1363 AND meta_key = '_menu_item_orphaned' AND meta_value < %d", |
|
1364 $delete_timestamp |
|
1365 ) |
|
1366 ); |
1136 |
1367 |
1137 foreach ( (array) $menu_items_to_delete as $menu_item_id ) { |
1368 foreach ( (array) $menu_items_to_delete as $menu_item_id ) { |
1138 wp_delete_post( $menu_item_id, true ); |
1369 wp_delete_post( $menu_item_id, true ); |
1139 } |
1370 } |
1140 } |
1371 } |
1141 |
1372 |
1142 /** |
1373 /** |
1143 * Saves nav menu items |
1374 * Saves nav menu items. |
1144 * |
1375 * |
1145 * @since 3.6.0 |
1376 * @since 3.6.0 |
1146 * |
1377 * |
1147 * @param int|string $nav_menu_selected_id ID, slug, or name of the currently-selected menu. |
1378 * @param int|string $nav_menu_selected_id ID, slug, or name of the currently-selected menu. |
1148 * @param string $nav_menu_selected_title Title of the currently-selected menu. |
1379 * @param string $nav_menu_selected_title Title of the currently-selected menu. |
1149 * @return array The menu updated message |
1380 * @return string[] The menu updated messages. |
1150 */ |
1381 */ |
1151 function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ) { |
1382 function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ) { |
1152 $unsorted_menu_items = wp_get_nav_menu_items( |
1383 $unsorted_menu_items = wp_get_nav_menu_items( |
1153 $nav_menu_selected_id, |
1384 $nav_menu_selected_id, |
1154 array( |
1385 array( |
1236 unset( $nav_menu_option['auto_add'][ $key ] ); |
1477 unset( $nav_menu_option['auto_add'][ $key ] ); |
1237 } |
1478 } |
1238 } |
1479 } |
1239 |
1480 |
1240 // Remove non-existent/deleted menus. |
1481 // Remove non-existent/deleted menus. |
1241 $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) ); |
1482 $nav_menu_option['auto_add'] = array_intersect( |
|
1483 $nav_menu_option['auto_add'], |
|
1484 wp_get_nav_menus( array( 'fields' => 'ids' ) ) |
|
1485 ); |
|
1486 |
1242 update_option( 'nav_menu_options', $nav_menu_option ); |
1487 update_option( 'nav_menu_options', $nav_menu_option ); |
1243 |
1488 |
1244 wp_defer_term_counting( false ); |
1489 wp_defer_term_counting( false ); |
1245 |
1490 |
1246 /** This action is documented in wp-includes/nav-menu.php */ |
1491 /** This action is documented in wp-includes/nav-menu.php */ |
1247 do_action( 'wp_update_nav_menu', $nav_menu_selected_id ); |
1492 do_action( 'wp_update_nav_menu', $nav_menu_selected_id ); |
1248 |
1493 |
1249 $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . |
1494 /* translators: %s: Nav menu title. */ |
1250 sprintf( |
1495 $message = sprintf( __( '%s has been updated.' ), '<strong>' . $nav_menu_selected_title . '</strong>' ); |
1251 /* translators: %s: Nav menu title. */ |
1496 $notice_args = array( |
1252 __( '%s has been updated.' ), |
1497 'id' => 'message', |
1253 '<strong>' . $nav_menu_selected_title . '</strong>' |
1498 'dismissible' => true, |
1254 ) . '</p></div>'; |
1499 'additional_classes' => array( 'updated' ), |
|
1500 ); |
|
1501 |
|
1502 $messages[] = wp_get_admin_notice( $message, $notice_args ); |
1255 |
1503 |
1256 unset( $menu_items, $unsorted_menu_items ); |
1504 unset( $menu_items, $unsorted_menu_items ); |
1257 |
1505 |
1258 return $messages; |
1506 return $messages; |
1259 } |
1507 } |