Get type label.
Parameters
$item
objectrequired- Nav menu item.
Source
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;
}
Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.