WP_Customize_Nav_Menu_Item_Setting::get_type_label() WordPress Method

The WP_Customize_Nav_Menu_Item_Setting::get_type_label() Wordpress method is used to get a human-readable label for a menu item's type.

WP_Customize_Nav_Menu_Item_Setting::get_type_label( object $item ) #

Get type label.


Parameters

$item

(object)(Required)Nav menu item.


Top ↑

Return

(string) The type label.


Top ↑

Source

File: wp-includes/customize/class-wp-customize-nav-menu-item-setting.php

	protected function get_type_label( $item ) {
		if ( 'post_type' === $item->type ) {
			$object = get_post_type_object( $item->object );
			if ( $object ) {
				$type_label = $object->labels->singular_name;
			} else {
				$type_label = $item->object;
			}
		} elseif ( 'taxonomy' === $item->type ) {
			$object = get_taxonomy( $item->object );
			if ( $object ) {
				$type_label = $object->labels->singular_name;
			} else {
				$type_label = $item->object;
			}
		} elseif ( 'post_type_archive' === $item->type ) {
			$type_label = __( 'Post Type Archive' );
		} else {
			$type_label = __( 'Custom Link' );
		}
		return $type_label;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.