Returns an array of all the available item types.
Source
public function available_item_types() {
$item_types = array();
$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' );
if ( $post_types ) {
foreach ( $post_types as $slug => $post_type ) {
$item_types[] = array(
'title' => $post_type->labels->name,
'type_label' => $post_type->labels->singular_name,
'type' => 'post_type',
'object' => $post_type->name,
);
}
}
$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'objects' );
if ( $taxonomies ) {
foreach ( $taxonomies as $slug => $taxonomy ) {
if ( 'post_format' === $taxonomy && ! current_theme_supports( 'post-formats' ) ) {
continue;
}
$item_types[] = array(
'title' => $taxonomy->labels->name,
'type_label' => $taxonomy->labels->singular_name,
'type' => 'taxonomy',
'object' => $taxonomy->name,
);
}
}
/**
* Filters the available menu item types.
*
* @since 4.3.0
* @since 4.7.0 Each array item now includes a `$type_label` in addition to `$title`, `$type`, and `$object`.
*
* @param array $item_types Navigation menu item types.
*/
$item_types = apply_filters( 'customize_nav_menu_available_item_types', $item_types );
return $item_types;
}
Hooks
- apply_filters( ‘customize_nav_menu_available_item_types’,
array $item_types ) Filters the available menu item types.
User Contributed Notes
You must log in before being able to contribute a note or feedback.