WP_Taxonomy::get_rest_controller()publicWP 5.5.0

Gets the REST API controller for this taxonomy.

Will only instantiate the controller class once per request.

Метод класса: WP_Taxonomy{}

Хуков нет.

Возвращает

WP_REST_Controller|null. The controller instance, or null if the taxonomy is set not to show in rest.

Использование

$WP_Taxonomy = new WP_Taxonomy();
$WP_Taxonomy->get_rest_controller();

Список изменений

С версии 5.5.0 Введена.

Код WP_Taxonomy::get_rest_controller() WP 6.4.3

public function get_rest_controller() {
	if ( ! $this->show_in_rest ) {
		return null;
	}

	$class = $this->rest_controller_class ? $this->rest_controller_class : WP_REST_Terms_Controller::class;

	if ( ! class_exists( $class ) ) {
		return null;
	}

	if ( ! is_subclass_of( $class, WP_REST_Controller::class ) ) {
		return null;
	}

	if ( ! $this->rest_controller ) {
		$this->rest_controller = new $class( $this->name );
	}

	if ( ! ( $this->rest_controller instanceof $class ) ) {
		return null;
	}

	return $this->rest_controller;
}