ACF_Rest_Request::build_supported_routes()privateACF 1.0

Build an array of route match patterns that we handle. These are the same as WordPress' core patterns except we are also matching the object type here as well.

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

Хуков нет.

Возвращает

null. Ничего.

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

// private - только в коде основоного (родительского) класса
$result = $this->build_supported_routes();

Код ACF_Rest_Request::build_supported_routes() ACF 6.0.4

private function build_supported_routes() {
	// Add post type routes for all post types configured to show in REST.
	/** @var WP_Post_Type $post_type */
	foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) {
		$rest_base                = acf_get_object_type_rest_base( $post_type );
		$this->supported_routes[] = "/wp/v2/(?P<rest_base>{$rest_base})";
		$this->supported_routes[] = "/wp/v2/(?P<rest_base>{$rest_base})/(?P<id>[\d]+)";

		if ( post_type_supports( $post_type->name, 'revisions' ) ) {
			$this->supported_routes[] = "/wp/v2/(?P<rest_base>{$rest_base})/(?P<id>[\d]+)/(?P<child_rest_base>revisions)";
			$this->supported_routes[] = "/wp/v2/(?P<rest_base>{$rest_base})/(?P<id>[\d]+)/(?P<child_rest_base>revisions)/(?P<child_id>[\d]+)";
		}

		if ( 'attachment' !== $post_type->name ) {
			$this->supported_routes[] = "/wp/v2/(?P<rest_base>{$rest_base})/(?P<id>[\d]+)/(?P<child_rest_base>autosaves)";
			$this->supported_routes[] = "/wp/v2/(?P<rest_base>{$rest_base})/(?P<id>[\d]+)/(?P<child_rest_base>autosaves)/(?P<child_id>[\d]+)";
		}
	}

	// Add taxonomy routes all taxonomies configured to show in REST.
	/** @var WP_Taxonomy $taxonomy */
	foreach ( get_taxonomies( array( 'show_in_rest' => true ), 'object' ) as $taxonomy ) {
		$rest_base                = acf_get_object_type_rest_base( $taxonomy );
		$this->supported_routes[] = "/wp/v2/(?P<rest_base>{$rest_base})";
		$this->supported_routes[] = "/wp/v2/(?P<rest_base>{$rest_base})/(?P<id>[\d]+)";
	}

	// Add user routes.
	$this->supported_routes[] = '/wp/v2/(?P<rest_base>users)';
	$this->supported_routes[] = '/wp/v2/(?P<rest_base>users)/(?P<id>[\d]+)';
	$this->supported_routes[] = '/wp/v2/(?P<rest_base>users)/me';

	// Add comment routes.
	$this->supported_routes[] = '/wp/v2/(?P<rest_base>comments)';
	$this->supported_routes[] = '/wp/v2/(?P<rest_base>comments)/(?P<id>[\d]+)';
}