WP_Customize_Nav_Menu_Item_Setting::get_original_title()
Get original title.
Method of the class: WP_Customize_Nav_Menu_Item_Setting{}
Hooks from the method
Return
String
. The original title.
Usage
// protected - for code of main (parent) or child class $result = $this->get_original_title( $item );
- $item(object) (required)
- Nav menu item.
Changelog
Since 4.7.0 | Introduced. |
WP_Customize_Nav_Menu_Item_Setting::get_original_title() WP Customize Nav Menu Item Setting::get original title code WP 6.6.2
protected function get_original_title( $item ) { $original_title = ''; if ( 'post_type' === $item->type && ! empty( $item->object_id ) ) { $original_object = get_post( $item->object_id ); if ( $original_object ) { /** This filter is documented in wp-includes/post-template.php */ $original_title = apply_filters( 'the_title', $original_object->post_title, $original_object->ID ); if ( '' === $original_title ) { /* translators: %d: ID of a post. */ $original_title = sprintf( __( '#%d (no title)' ), $original_object->ID ); } } } elseif ( 'taxonomy' === $item->type && ! empty( $item->object_id ) ) { $original_term_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' ); if ( ! is_wp_error( $original_term_title ) ) { $original_title = $original_term_title; } } elseif ( 'post_type_archive' === $item->type ) { $original_object = get_post_type_object( $item->object ); if ( $original_object ) { $original_title = $original_object->labels->archives; } } $original_title = html_entity_decode( $original_title, ENT_QUOTES, get_bloginfo( 'charset' ) ); return $original_title; }