WP_REST_Menus_Controller::get_term()protectedWP 5.9.0

Gets the term, if the ID is valid.

{} It's a method of the class: WP_REST_Menus_Controller{}

No Hooks.

Return

WP_Term|WP_Error. Term object if ID is valid, WP_Error otherwise.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_term( $id );
$id(int) (required)
Supplied ID.

Changelog

Since 5.9.0 Introduced.

Code of WP_REST_Menus_Controller::get_term() WP 6.0

protected function get_term( $id ) {
	$term = parent::get_term( $id );

	if ( is_wp_error( $term ) ) {
		return $term;
	}

	$nav_term           = wp_get_nav_menu_object( $term );
	$nav_term->auto_add = $this->get_menu_auto_add( $nav_term->term_id );

	return $nav_term;
}