WP_Customize_Nav_Menus::available_item_types()
Returns an array of all the available item types.
Метод класса: WP_Customize_Nav_Menus{}
Хуки из метода
Возвращает
Массив
. The available menu item types.
Использование
$WP_Customize_Nav_Menus = new WP_Customize_Nav_Menus(); $WP_Customize_Nav_Menus->available_item_types();
Список изменений
С версии 4.3.0 | Введена. |
С версии 4.7.0 | Each array item now includes a $type_label in addition to $title, $type, and $object. |
Код WP_Customize_Nav_Menus::available_item_types() WP Customize Nav Menus::available item types WP 6.6.2
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; }