WP_REST_Posts_Controller::check_is_post_type_allowed()protectedWP 4.7.0

Checks if a given post type can be viewed or managed.

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

Хуков нет.

Возвращает

true|false. Whether the post type is allowed in REST.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->check_is_post_type_allowed( $post_type );
$post_type(WP_Post_Type|строка) (обязательный)
Post type name or object.

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

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

Код WP_REST_Posts_Controller::check_is_post_type_allowed() WP 6.4.3

protected function check_is_post_type_allowed( $post_type ) {
	if ( ! is_object( $post_type ) ) {
		$post_type = get_post_type_object( $post_type );
	}

	if ( ! empty( $post_type ) && ! empty( $post_type->show_in_rest ) ) {
		return true;
	}

	return false;
}