' . __( 'No items.' ) . '
';
return;
}
} elseif ( ! empty( $important_pages ) ) {
$posts = array_merge( $important_pages, $posts );
}
$num_pages = $get_posts->max_num_pages;
$page_links = paginate_links(
array(
'base' => add_query_arg(
array(
$tab_name => 'all',
'paged' => '%#%',
'item-type' => 'post_type',
'item-object' => $post_type_name,
)
),
'format' => '',
'prev_text' => '
'post_date',
'order' => 'DESC',
'posts_per_page' => 15,
)
);
$most_recent = $get_posts->query( $recent_args );
$args['walker'] = $walker;
/**
* 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.
*
* Possible hook names include:
*
* - `nav_menu_items_post_recent`
* - `nav_menu_items_page_recent`
*
* @since 4.3.0
* @since 4.9.0 Added the `$recent_args` parameter.
*
* @param WP_Post[] $most_recent An array of post objects being listed.
* @param array $args An array of `WP_Query` arguments for the meta box.
* @param array $box Arguments passed to `wp_nav_menu_item_post_type_meta_box()`.
* @param array $recent_args An array of `WP_Query` arguments for 'Most Recent' tab.
*/
$most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box, $recent_args );
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $most_recent ), 0, (object) $args );
?>
has_archive ) {
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1;
array_unshift(
$posts,
(object) array(
'ID' => 0,
'object_id' => $_nav_menu_placeholder,
'object' => $post_type_name,
'post_content' => '',
'post_excerpt' => '',
'post_title' => $post_type->labels->archives,
'post_type' => 'nav_menu_item',
'type' => 'post_type_archive',
'url' => get_post_type_archive_link( $post_type_name ),
)
);
}
/**
* 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.
*
* Possible hook names include:
*
* - `nav_menu_items_post`
* - `nav_menu_items_page`
*
* @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 object[] $posts The posts for the current post type. Mostly `WP_Post` objects, but
* can also contain "fake" post objects to represent other menu items.
* @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 );
echo $checkbox_items;
?>
id="" class="select-all" />
name;
$taxonomy = get_taxonomy( $taxonomy_name );
$tab_name = $taxonomy_name . '-tab';
// Paginate browsing for large numbers of objects.
$per_page = 50;
$pagenum = isset( $_REQUEST[ $tab_name ] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
$args = array(
'taxonomy' => $taxonomy_name,
'child_of' => 0,
'exclude' => '',
'hide_empty' => false,
'hierarchical' => 1,
'include' => '',
'number' => $per_page,
'offset' => $offset,
'order' => 'ASC',
'orderby' => 'name',
'pad_counts' => false,
);
$terms = get_terms( $args );
if ( ! $terms || is_wp_error( $terms ) ) {
echo '' . __( 'No items.' ) . '
';
return;
}
$num_pages = ceil(
wp_count_terms(
array_merge(
$args,
array(
'number' => '',
'offset' => '',
)
)
) / $per_page
);
$page_links = paginate_links(
array(
'base' => add_query_arg(
array(
$tab_name => 'all',
'paged' => '%#%',
'item-type' => 'taxonomy',
'item-object' => $taxonomy_name,
)
),
'format' => '',
'prev_text' => '
$_item_object_data ) {
if (
// Checkbox is not checked.
empty( $_item_object_data['menu-item-object-id'] ) &&
(
// And item type either isn't set.
! isset( $_item_object_data['menu-item-type'] ) ||
// Or URL is the default.
in_array( $_item_object_data['menu-item-url'], array( 'https://', 'http://', '' ), true ) ||
// Or it's not a custom menu item (but not the custom home page).
! ( 'custom' === $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) ||
// Or it *is* a custom menu item that already exists.
! empty( $_item_object_data['menu-item-db-id'] )
)
) {
// Then this potential menu item is not getting added to this menu.
continue;
}
// If this possible menu item doesn't actually have a menu database ID yet.
if (
empty( $_item_object_data['menu-item-db-id'] ) ||
( 0 > $_possible_db_id ) ||
$_possible_db_id != $_item_object_data['menu-item-db-id']
) {
$_actual_db_id = 0;
} else {
$_actual_db_id = (int) $_item_object_data['menu-item-db-id'];
}
$args = array(
'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ),
'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ),
'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ),
'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ),
'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ),
'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ),
'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ),
'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ),
'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ),
'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ),
'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ),
'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ),
'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ),
);
$items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args );
}
}
return $items_saved;
}
/**
* Adds custom arguments to some of the meta box object types.
*
* @since 3.0.0
*
* @access private
*
* @param object $object The post type or taxonomy meta-object.
* @return object The post type or taxonomy object.
*/
function _wp_nav_menu_meta_box_object( $object = null ) {
if ( isset( $object->name ) ) {
if ( 'page' === $object->name ) {
$object->_default_query = array(
'orderby' => 'menu_order title',
'post_status' => 'publish',
);
// Posts should show only published items.
} elseif ( 'post' === $object->name ) {
$object->_default_query = array(
'post_status' => 'publish',
);
// Categories should be in reverse chronological order.
} elseif ( 'category' === $object->name ) {
$object->_default_query = array(
'orderby' => 'id',
'order' => 'DESC',
);
// Custom post types should show only published items.
} else {
$object->_default_query = array(
'post_status' => 'publish',
);
}
}
return $object;
}
/**
* Returns the menu formatted to edit.
*
* @since 3.0.0
*
* @param int $menu_id Optional. The ID of the menu to format. Default 0.
* @return string|WP_Error The menu formatted to edit or error object on failure.
*/
function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
$menu = wp_get_nav_menu_object( $menu_id );
// If the menu exists, get its items.
if ( is_nav_menu( $menu ) ) {
$menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'post_status' => 'any' ) );
$result = '' : '">';
$result .= '
' . __( 'Add menu items from the column on the left.' ) . '
';
$result .= '
';
if ( empty( $menu_items ) ) {
return $result . ' ';
}
/**
* Filters the Walker class used when adding nav menu items.
*
* @since 3.0.0
*
* @param string $class The walker class to use. Default 'Walker_Nav_Menu_Edit'.
* @param int $menu_id ID of the menu being rendered.
*/
$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
if ( class_exists( $walker_class_name ) ) {
$walker = new $walker_class_name;
} else {
return new WP_Error(
'menu_walker_not_exist',
sprintf(
/* translators: %s: Walker class name. */
__( 'The Walker class named %s does not exist.' ),
'