WPSEO_Post_Type::is_rest_enabled()public staticYoast 1.0

Checks if the post type is enabled in the REST API.

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

Хуков нет.

Возвращает

true|false. Whether or not the post type is available in the REST API.

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

$result = WPSEO_Post_Type::is_rest_enabled( $post_type );
$post_type(строка) (обязательный)
The post type to check.

Код WPSEO_Post_Type::is_rest_enabled() Yoast 22.4

public static function is_rest_enabled( $post_type ) {
	$post_type_object = get_post_type_object( $post_type );

	if ( $post_type_object === null ) {
		return false;
	}

	return $post_type_object->show_in_rest === true;
}