Ticket #37586: 37586.2.diff
File 37586.2.diff, 2.3 KB (added by , 4 years ago) |
---|
-
src/wp-includes/class-wp-customize-nav-menus.php
305 305 public function search_available_items_query( $args = array() ) { 306 306 $items = array(); 307 307 308 $post_type_objects = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' );308 $post_type_objects = $this->get_available_item_types( 'post_type' ); 309 309 $query = array( 310 310 'post_type' => array_keys( $post_type_objects ), 311 311 'suppress_filters' => true, … … 363 363 } 364 364 365 365 // Query taxonomy terms. 366 $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'names' ); 367 $terms = get_terms( 368 array( 369 'taxonomies' => $taxonomies, 370 'name__like' => $args['s'], 371 'number' => 20, 372 'offset' => 20 * ( $args['pagenum'] - 1 ), 373 ) 374 ); 366 $taxonomies = $this->get_available_item_types( 'taxonomy', 'object' ); 375 367 368 if( empty( $taxonomies ) ) { 369 $terms = array(); 370 } else { 371 $terms = get_terms( 372 array( 373 'taxonomy' => $taxonomies, 374 'name__like' => $args['s'], 375 'number' => 20, 376 'offset' => 20 * ( $args['pagenum'] - 1 ), 377 ) 378 ); 379 } 380 376 381 // Check if any taxonomies were found. 377 382 if ( ! empty( $terms ) ) { 378 383 foreach ( $terms as $term ) { … … 864 869 } 865 870 866 871 /** 872 * Get specific type from available item types. 873 * 874 * @since 5.4.0 875 * 876 * @param string $item_type Item type. Can be `post_type` or `taxonomy`. 877 * @param mixed $return_key Return specific key of the item type array. 878 * Default set to false which returns whole object. 879 * 880 * @return array 881 */ 882 public function get_available_item_types( $item_type, $return_key = false ) { 883 $item_types = array_filter( 884 $this->available_item_types(), 885 function( $item ) use ( $item_type ) { 886 return $item_type === $item['type']; 887 } 888 ); 889 890 if( ! $return_key ) { 891 return $item_types; 892 } 893 894 return array_map( 895 function( $item ) use ( $return_key ) { 896 return $item[ $return_key ]; 897 }, 898 $item_types 899 ); 900 } 901 902 903 /** 867 904 * Add a new `auto-draft` post. 868 905 * 869 906 * @since 4.7.0