@@ -289,7 +297,7 @@ function wp_nav_menu_item_link_meta_box() {
}
/**
- * Displays a metabox for a post type menu item.
+ * Displays a meta box for a post type menu item.
*
* @since 3.0.0
*
@@ -297,12 +305,19 @@ function wp_nav_menu_item_link_meta_box() {
* @global int|string $nav_menu_selected_id
*
* @param string $object Not used.
- * @param string $post_type The post type object.
+ * @param array $box {
+ * Post type menu item meta box arguments.
+ *
+ * @type string $id Meta box 'id' attribute.
+ * @type string $title Meta box title.
+ * @type string $callback Meta box display callback.
+ * @type WP_Post_Type $args Extra meta box arguments (the post type object for this meta box).
+ * }
*/
-function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
+function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
global $_nav_menu_placeholder, $nav_menu_selected_id;
- $post_type_name = $post_type['args']->name;
+ $post_type_name = $box['args']->name;
// Paginate browsing for large numbers of post objects.
$per_page = 50;
@@ -320,8 +335,8 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
'update_post_meta_cache' => false
);
- if ( isset( $post_type['args']->_default_query ) )
- $args = array_merge($args, (array) $post_type['args']->_default_query );
+ if ( isset( $box['args']->_default_query ) )
+ $args = array_merge($args, (array) $box['args']->_default_query );
// @todo transient caching of these results with proper invalidation on updating of a post of this type
$get_posts = new WP_Query;
@@ -343,9 +358,10 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
)
),
'format' => '',
- 'prev_text' => __('«'),
- 'next_text' => __('»'),
- 'total' => $num_pages,
+ 'prev_text' => '' . __( '«' ) . '',
+ 'next_text' => '' . __( '»' ) . '',
+ 'before_page_number' => '' . __( 'Page' ) . ' ',
+ 'total' => $num_pages,
'current' => $pagenum
));
@@ -404,18 +420,18 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
$args['walker'] = $walker;
/**
- * Filter the posts displayed in the 'Most Recent' tab of the current
+ * Filters the posts displayed in the 'Most Recent' tab of the current
* post type's menu items meta box.
*
* The dynamic portion of the hook name, `$post_type_name`, refers to the post type name.
*
* @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.
+ * @param array $most_recent An array of post objects being listed.
+ * @param array $args An array of WP_Query arguments.
+ * @param array $box Arguments passed to wp_nav_menu_item_post_type_meta_box().
*/
- $most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $post_type );
+ $most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box );
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args );
?>
@@ -435,9 +451,10 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
}
?>
@@ -494,7 +511,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
}
$post_type = get_post_type_object( $post_type_name );
- $archive_link = get_post_type_archive_link( $post_type_name );
+
if ( $post_type->has_archive ) {
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
array_unshift( $posts, (object) array(
@@ -511,21 +528,23 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
}
/**
- * Filter the posts displayed in the 'View All' tab of the current
+ * Filters the posts displayed in the 'View All' tab of the current
* post type's menu items meta box.
*
* The dynamic portion of the hook name, `$post_type_name`, refers
* to the slug of the current post type.
*
* @since 3.2.0
+ * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
*
* @see WP_Query::query()
*
- * @param array $posts The posts for the current post type.
- * @param array $args An array of WP_Query arguments.
- * @param object $post_type The current post type object for this menu item meta box.
+ * @param array $posts The posts for the current post type.
+ * @param array $args An array of WP_Query arguments.
+ * @param WP_Post_Type $post_type The current post type object for this menu item meta box.
*/
$posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type );
+
$checkbox_items = walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args );
if ( 'all' == $current_tab && ! empty( $_REQUEST['selectall'] ) ) {
@@ -543,7 +562,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
';
/**
- * Filter the Walker class used when adding nav menu items.
+ * Filters the Walker class used when adding nav menu items.
*
* @since 3.0.0
*
@@ -918,11 +946,13 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
$some_invalid_menu_items = true;
}
- if ( $some_pending_menu_items )
- $result .= '
' . __('Click Save Menu to make pending menu items public.') . '