From 77d2e23a69eebd8a1afa4b37aa7cfdffefefdf81 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Thu, 18 Jun 2015 11:34:33 +0000 Subject: [PATCH] Make posts in the 'Most recent' tab of post type meta boxes filterable. Provides parity with the 'View All' tab of post type meta boxes in Appearance > Menus. Props jpyper, chriscct7. Fixes #19365. git-svn-id: https://develop.svn.wordpress.org/trunk@32833 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/nav-menu.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/wp-admin/includes/nav-menu.php b/src/wp-admin/includes/nav-menu.php index 38dd9092a5..a614650852 100644 --- a/src/wp-admin/includes/nav-menu.php +++ b/src/wp-admin/includes/nav-menu.php @@ -728,6 +728,19 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) { $recent_args = array_merge( $args, array( 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15 ) ); $most_recent = $get_posts->query( $recent_args ); $args['walker'] = $walker; + + /** + * Filter the posts displayed in the 'Most Recent' tab of the current + * post type's menu items meta box. + * + * @since 4.3.0 + * + * @param array $most_recent An array of post objects being listed. + * @param array $args An array of WP_Query arguments. + * @param object $post_type The current post type object for this menu item meta box. + */ + $most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $post_type ); + echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args ); ?>