mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-05 05:04:31 +00:00
Editor: Add block theme infrastructure
Adds the required infrastructure to render block-based themes. This is sourced from the Gutenberg plugin. Fixes #54335. Props bernhard-reiter, youknowriad, ntsekouras, hellofromtonya. git-svn-id: https://develop.svn.wordpress.org/trunk@52062 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
3
tests/phpunit/data/templates/template.html
Normal file
3
tests/phpunit/data/templates/template.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<!-- wp:paragraph -->
|
||||
<p>Just a paragraph</p>
|
||||
<!-- /wp:paragraph -->
|
||||
@@ -337,5 +337,6 @@ function _unhook_block_registration() {
|
||||
remove_action( 'init', 'register_block_core_tag_cloud' );
|
||||
remove_action( 'init', 'register_core_block_types_from_metadata' );
|
||||
remove_action( 'init', 'register_block_core_legacy_widget' );
|
||||
remove_action( 'init', 'register_block_core_template_part' );
|
||||
}
|
||||
tests_add_filter( 'init', '_unhook_block_registration', 1000 );
|
||||
|
||||
@@ -6,12 +6,34 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the Block Template Loader abstraction layer.
|
||||
* Tests for the Block Templates abstraction layer.
|
||||
*/
|
||||
class Block_Template_Utils_Test extends WP_UnitTestCase {
|
||||
private static $post;
|
||||
private static $template_part_post;
|
||||
|
||||
public static function wpSetUpBeforeClass() {
|
||||
// We may need a block theme.
|
||||
// switch_theme( 'tt1-blocks' );
|
||||
|
||||
// Set up a template post corresponding to a different theme.
|
||||
// We do this to ensure resolution and slug creation works as expected,
|
||||
// even with another post of that same name present for another theme.
|
||||
$args = array(
|
||||
'post_type' => 'wp_template',
|
||||
'post_name' => 'my_template',
|
||||
'post_title' => 'My Template',
|
||||
'post_content' => 'Content',
|
||||
'post_excerpt' => 'Description of my template',
|
||||
'tax_input' => array(
|
||||
'wp_theme' => array(
|
||||
'this-theme-should-not-resolve',
|
||||
),
|
||||
),
|
||||
);
|
||||
self::$post = self::factory()->post->create_and_get( $args );
|
||||
wp_set_post_terms( self::$post->ID, 'this-theme-should-not-resolve', 'wp_theme' );
|
||||
|
||||
// Set up template post.
|
||||
$args = array(
|
||||
'post_type' => 'wp_template',
|
||||
@@ -27,6 +49,26 @@ class Block_Template_Utils_Test extends WP_UnitTestCase {
|
||||
);
|
||||
self::$post = self::factory()->post->create_and_get( $args );
|
||||
wp_set_post_terms( self::$post->ID, get_stylesheet(), 'wp_theme' );
|
||||
|
||||
// Set up template part post.
|
||||
$template_part_args = array(
|
||||
'post_type' => 'wp_template_part',
|
||||
'post_name' => 'my_template_part',
|
||||
'post_title' => 'My Template Part',
|
||||
'post_content' => 'Content',
|
||||
'post_excerpt' => 'Description of my template part',
|
||||
'tax_input' => array(
|
||||
'wp_theme' => array(
|
||||
get_stylesheet(),
|
||||
),
|
||||
'wp_template_part_area' => array(
|
||||
WP_TEMPLATE_PART_AREA_HEADER,
|
||||
),
|
||||
),
|
||||
);
|
||||
self::$template_part_post = self::factory()->post->create_and_get( $template_part_args );
|
||||
wp_set_post_terms( self::$template_part_post->ID, WP_TEMPLATE_PART_AREA_HEADER, 'wp_template_part_area' );
|
||||
wp_set_post_terms( self::$template_part_post->ID, get_stylesheet(), 'wp_theme' );
|
||||
}
|
||||
|
||||
public static function wpTearDownAfterClass() {
|
||||
@@ -34,20 +76,143 @@ class Block_Template_Utils_Test extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_build_template_result_from_post() {
|
||||
$template = _build_template_result_from_post(
|
||||
$template = _build_block_template_result_from_post(
|
||||
self::$post,
|
||||
'wp_template'
|
||||
);
|
||||
|
||||
$this->assertNotWPError( $template );
|
||||
$this->assertSame( get_stylesheet() . '//my_template', $template->id );
|
||||
$this->assertSame( get_stylesheet(), $template->theme );
|
||||
$this->assertSame( 'my_template', $template->slug );
|
||||
$this->assertSame( 'publish', $template->status );
|
||||
$this->assertSame( 'custom', $template->source );
|
||||
$this->assertSame( 'My Template', $template->title );
|
||||
$this->assertSame( 'Description of my template', $template->description );
|
||||
$this->assertSame( 'wp_template', $template->type );
|
||||
$this->assertEquals( get_stylesheet() . '//my_template', $template->id );
|
||||
$this->assertEquals( get_stylesheet(), $template->theme );
|
||||
$this->assertEquals( 'my_template', $template->slug );
|
||||
$this->assertEquals( 'publish', $template->status );
|
||||
$this->assertEquals( 'custom', $template->source );
|
||||
$this->assertEquals( 'My Template', $template->title );
|
||||
$this->assertEquals( 'Description of my template', $template->description );
|
||||
$this->assertEquals( 'wp_template', $template->type );
|
||||
|
||||
// Test template parts.
|
||||
$template_part = _build_block_template_result_from_post(
|
||||
self::$template_part_post,
|
||||
'wp_template_part'
|
||||
);
|
||||
$this->assertNotWPError( $template_part );
|
||||
$this->assertEquals( get_stylesheet() . '//my_template_part', $template_part->id );
|
||||
$this->assertEquals( get_stylesheet(), $template_part->theme );
|
||||
$this->assertEquals( 'my_template_part', $template_part->slug );
|
||||
$this->assertEquals( 'publish', $template_part->status );
|
||||
$this->assertEquals( 'custom', $template_part->source );
|
||||
$this->assertEquals( 'My Template Part', $template_part->title );
|
||||
$this->assertEquals( 'Description of my template part', $template_part->description );
|
||||
$this->assertEquals( 'wp_template_part', $template_part->type );
|
||||
$this->assertEquals( WP_TEMPLATE_PART_AREA_HEADER, $template_part->area );
|
||||
}
|
||||
|
||||
function test_build_block_template_result_from_file() {
|
||||
$template = _build_block_template_result_from_file(
|
||||
array(
|
||||
'slug' => 'single',
|
||||
'path' => __DIR__ . '/../data/templates/template.html',
|
||||
),
|
||||
'wp_template'
|
||||
);
|
||||
|
||||
$this->assertEquals( get_stylesheet() . '//single', $template->id );
|
||||
$this->assertEquals( get_stylesheet(), $template->theme );
|
||||
$this->assertEquals( 'single', $template->slug );
|
||||
$this->assertEquals( 'publish', $template->status );
|
||||
$this->assertEquals( 'theme', $template->source );
|
||||
$this->assertEquals( 'Single Post', $template->title );
|
||||
$this->assertEquals( 'Template used to display a single blog post.', $template->description );
|
||||
$this->assertEquals( 'wp_template', $template->type );
|
||||
|
||||
// Test template parts.
|
||||
$template_part = _build_block_template_result_from_file(
|
||||
array(
|
||||
'slug' => 'header',
|
||||
'path' => __DIR__ . '/../data/templates/template.html',
|
||||
'area' => WP_TEMPLATE_PART_AREA_HEADER,
|
||||
),
|
||||
'wp_template_part'
|
||||
);
|
||||
$this->assertEquals( get_stylesheet() . '//header', $template_part->id );
|
||||
$this->assertEquals( get_stylesheet(), $template_part->theme );
|
||||
$this->assertEquals( 'header', $template_part->slug );
|
||||
$this->assertEquals( 'publish', $template_part->status );
|
||||
$this->assertEquals( 'theme', $template_part->source );
|
||||
$this->assertEquals( 'header', $template_part->title );
|
||||
$this->assertEquals( '', $template_part->description );
|
||||
$this->assertEquals( 'wp_template_part', $template_part->type );
|
||||
$this->assertEquals( WP_TEMPLATE_PART_AREA_HEADER, $template_part->area );
|
||||
}
|
||||
|
||||
function test_inject_theme_attribute_in_block_template_content() {
|
||||
$theme = get_stylesheet();
|
||||
$content_without_theme_attribute = '<!-- wp:template-part {"slug":"header","align":"full", "tagName":"header","className":"site-header"} /-->';
|
||||
$template_content = _inject_theme_attribute_in_block_template_content(
|
||||
$content_without_theme_attribute,
|
||||
$theme
|
||||
);
|
||||
$expected = sprintf(
|
||||
'<!-- wp:template-part {"slug":"header","align":"full","tagName":"header","className":"site-header","theme":"%s"} /-->',
|
||||
get_stylesheet()
|
||||
);
|
||||
$this->assertEquals( $expected, $template_content );
|
||||
|
||||
$content_without_theme_attribute_nested = '<!-- wp:group --><!-- wp:template-part {"slug":"header","align":"full", "tagName":"header","className":"site-header"} /--><!-- /wp:group -->';
|
||||
$template_content = _inject_theme_attribute_in_block_template_content(
|
||||
$content_without_theme_attribute_nested,
|
||||
$theme
|
||||
);
|
||||
$expected = sprintf(
|
||||
'<!-- wp:group --><!-- wp:template-part {"slug":"header","align":"full","tagName":"header","className":"site-header","theme":"%s"} /--><!-- /wp:group -->',
|
||||
get_stylesheet()
|
||||
);
|
||||
$this->assertEquals( $expected, $template_content );
|
||||
|
||||
// Does not inject theme when there is an existing theme attribute.
|
||||
$content_with_existing_theme_attribute = '<!-- wp:template-part {"slug":"header","theme":"fake-theme","align":"full", "tagName":"header","className":"site-header"} /-->';
|
||||
$template_content = _inject_theme_attribute_in_block_template_content(
|
||||
$content_with_existing_theme_attribute,
|
||||
$theme
|
||||
);
|
||||
$this->assertEquals( $content_with_existing_theme_attribute, $template_content );
|
||||
|
||||
// Does not inject theme when there is no template part.
|
||||
$content_with_no_template_part = '<!-- wp:post-content /-->';
|
||||
$template_content = _inject_theme_attribute_in_block_template_content(
|
||||
$content_with_no_template_part,
|
||||
$theme
|
||||
);
|
||||
$this->assertEquals( $content_with_no_template_part, $template_content );
|
||||
}
|
||||
|
||||
/**
|
||||
* Should retrieve the template from the theme files.
|
||||
*/
|
||||
function test_get_block_template_from_file() {
|
||||
$this->markTestIncomplete();
|
||||
// Requires switching to a block theme.
|
||||
/* $id = get_stylesheet() . '//' . 'index';
|
||||
$template = get_block_template( $id, 'wp_template' );
|
||||
$this->assertEquals( $id, $template->id );
|
||||
$this->assertEquals( get_stylesheet(), $template->theme );
|
||||
$this->assertEquals( 'index', $template->slug );
|
||||
$this->assertEquals( 'publish', $template->status );
|
||||
$this->assertEquals( 'theme', $template->source );
|
||||
$this->assertEquals( 'wp_template', $template->type );
|
||||
|
||||
// Test template parts.
|
||||
$id = get_stylesheet() . '//' . 'header';
|
||||
$template = get_block_template( $id, 'wp_template_part' );
|
||||
$this->assertEquals( $id, $template->id );
|
||||
$this->assertEquals( get_stylesheet(), $template->theme );
|
||||
$this->assertEquals( 'header', $template->slug );
|
||||
$this->assertEquals( 'publish', $template->status );
|
||||
$this->assertEquals( 'theme', $template->source );
|
||||
$this->assertEquals( 'wp_template_part', $template->type );
|
||||
$this->assertEquals( WP_TEMPLATE_PART_AREA_HEADER, $template->area );
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,16 +221,27 @@ class Block_Template_Utils_Test extends WP_UnitTestCase {
|
||||
public function test_get_block_template_from_post() {
|
||||
$id = get_stylesheet() . '//' . 'my_template';
|
||||
$template = get_block_template( $id, 'wp_template' );
|
||||
$this->assertSame( $id, $template->id );
|
||||
$this->assertSame( get_stylesheet(), $template->theme );
|
||||
$this->assertSame( 'my_template', $template->slug );
|
||||
$this->assertSame( 'publish', $template->status );
|
||||
$this->assertSame( 'custom', $template->source );
|
||||
$this->assertSame( 'wp_template', $template->type );
|
||||
$this->assertEquals( $id, $template->id );
|
||||
$this->assertEquals( get_stylesheet(), $template->theme );
|
||||
$this->assertEquals( 'my_template', $template->slug );
|
||||
$this->assertEquals( 'publish', $template->status );
|
||||
$this->assertEquals( 'custom', $template->source );
|
||||
$this->assertEquals( 'wp_template', $template->type );
|
||||
|
||||
// Test template parts.
|
||||
$id = get_stylesheet() . '//' . 'my_template_part';
|
||||
$template = get_block_template( $id, 'wp_template_part' );
|
||||
$this->assertEquals( $id, $template->id );
|
||||
$this->assertEquals( get_stylesheet(), $template->theme );
|
||||
$this->assertEquals( 'my_template_part', $template->slug );
|
||||
$this->assertEquals( 'publish', $template->status );
|
||||
$this->assertEquals( 'custom', $template->source );
|
||||
$this->assertEquals( 'wp_template_part', $template->type );
|
||||
$this->assertEquals( WP_TEMPLATE_PART_AREA_HEADER, $template->area );
|
||||
}
|
||||
|
||||
/**
|
||||
* Should retrieve block templates.
|
||||
* Should retrieve block templates (file and CPT)
|
||||
*/
|
||||
public function test_get_block_templates() {
|
||||
function get_template_ids( $templates ) {
|
||||
@@ -84,14 +260,53 @@ class Block_Template_Utils_Test extends WP_UnitTestCase {
|
||||
// Avoid testing the entire array because the theme might add/remove templates.
|
||||
$this->assertContains( get_stylesheet() . '//' . 'my_template', $template_ids );
|
||||
|
||||
// The result might change in a block theme.
|
||||
// $this->assertContains( get_stylesheet() . '//' . 'index', $template_ids );
|
||||
|
||||
// Filter by slug.
|
||||
$templates = get_block_templates( array( 'slug__in' => array( 'my_template' ) ), 'wp_template' );
|
||||
$template_ids = get_template_ids( $templates );
|
||||
$this->assertSame( array( get_stylesheet() . '//' . 'my_template' ), $template_ids );
|
||||
$this->assertEquals( array( get_stylesheet() . '//' . 'my_template' ), $template_ids );
|
||||
|
||||
// Filter by CPT ID.
|
||||
$templates = get_block_templates( array( 'wp_id' => self::$post->ID ), 'wp_template' );
|
||||
$template_ids = get_template_ids( $templates );
|
||||
$this->assertSame( array( get_stylesheet() . '//' . 'my_template' ), $template_ids );
|
||||
$this->assertEquals( array( get_stylesheet() . '//' . 'my_template' ), $template_ids );
|
||||
|
||||
// Filter template part by area.
|
||||
// Requires a block theme.
|
||||
/*$templates = get_block_templates( array( 'area' => WP_TEMPLATE_PART_AREA_HEADER ), 'wp_template_part' );
|
||||
$template_ids = get_template_ids( $templates );
|
||||
$this->assertEquals(
|
||||
array(
|
||||
get_stylesheet() . '//' . 'my_template_part',
|
||||
get_stylesheet() . '//' . 'header',
|
||||
),
|
||||
$template_ids
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Should flatten nested blocks
|
||||
*/
|
||||
function test_flatten_blocks() {
|
||||
$content_template_part_inside_group = '<!-- wp:group --><!-- wp:template-part {"slug":"header"} /--><!-- /wp:group -->';
|
||||
$blocks = parse_blocks( $content_template_part_inside_group );
|
||||
$actual = _flatten_blocks( $blocks );
|
||||
$expected = array( $blocks[0], $blocks[0]['innerBlocks'][0] );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
|
||||
$content_template_part_inside_group_inside_group = '<!-- wp:group --><!-- wp:group --><!-- wp:template-part {"slug":"header"} /--><!-- /wp:group --><!-- /wp:group -->';
|
||||
$blocks = parse_blocks( $content_template_part_inside_group_inside_group );
|
||||
$actual = _flatten_blocks( $blocks );
|
||||
$expected = array( $blocks[0], $blocks[0]['innerBlocks'][0], $blocks[0]['innerBlocks'][0]['innerBlocks'][0] );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
|
||||
$content_without_inner_blocks = '<!-- wp:group /-->';
|
||||
$blocks = parse_blocks( $content_without_inner_blocks );
|
||||
$actual = _flatten_blocks( $blocks );
|
||||
$expected = array( $blocks[0] );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +132,12 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
'/wp/v2/block-types/(?P<namespace>[a-zA-Z0-9_-]+)',
|
||||
'/wp/v2/block-types/(?P<namespace>[a-zA-Z0-9_-]+)/(?P<name>[a-zA-Z0-9_-]+)',
|
||||
'/wp/v2/settings',
|
||||
'/wp/v2/template-parts',
|
||||
'/wp/v2/template-parts/(?P<id>[\/\w-]+)',
|
||||
'/wp/v2/template-parts/(?P<id>[\d]+)/autosaves',
|
||||
'/wp/v2/template-parts/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+)',
|
||||
'/wp/v2/template-parts/(?P<parent>[\d]+)/revisions',
|
||||
'/wp/v2/template-parts/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+)',
|
||||
'/wp/v2/templates',
|
||||
'/wp/v2/templates/(?P<id>[\/\w-]+)',
|
||||
'/wp/v2/templates/(?P<id>[\d]+)/autosaves',
|
||||
|
||||
@@ -4164,6 +4164,16 @@ mockedApiResponse.Schema = {
|
||||
"description": "Limit to the specified post id.",
|
||||
"type": "integer",
|
||||
"required": false
|
||||
},
|
||||
"area": {
|
||||
"description": "Limit to the specified template part area.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"post_type": {
|
||||
"description": "Post type to get the templates for.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -4585,6 +4595,478 @@ mockedApiResponse.Schema = {
|
||||
}
|
||||
]
|
||||
},
|
||||
"/wp/v2/template-parts": {
|
||||
"namespace": "wp/v2",
|
||||
"methods": [
|
||||
"GET",
|
||||
"POST"
|
||||
],
|
||||
"endpoints": [
|
||||
{
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"args": {
|
||||
"context": {
|
||||
"description": "Scope under which the request is made; determines fields present in response.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"view",
|
||||
"embed",
|
||||
"edit"
|
||||
],
|
||||
"required": false
|
||||
},
|
||||
"wp_id": {
|
||||
"description": "Limit to the specified post id.",
|
||||
"type": "integer",
|
||||
"required": false
|
||||
},
|
||||
"area": {
|
||||
"description": "Limit to the specified template part area.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"post_type": {
|
||||
"description": "Post type to get the templates for.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"methods": [
|
||||
"POST"
|
||||
],
|
||||
"args": {
|
||||
"slug": {
|
||||
"description": "Unique slug identifying the template.",
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"pattern": "[a-zA-Z_\\-]+",
|
||||
"required": true
|
||||
},
|
||||
"theme": {
|
||||
"description": "Theme identifier for the template.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"content": {
|
||||
"default": "",
|
||||
"description": "Content of template.",
|
||||
"type": [
|
||||
"object",
|
||||
"string"
|
||||
],
|
||||
"required": false
|
||||
},
|
||||
"title": {
|
||||
"default": "",
|
||||
"description": "Title of template.",
|
||||
"type": [
|
||||
"object",
|
||||
"string"
|
||||
],
|
||||
"required": false
|
||||
},
|
||||
"description": {
|
||||
"default": "",
|
||||
"description": "Description of template.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"status": {
|
||||
"default": "publish",
|
||||
"description": "Status of template.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"area": {
|
||||
"description": "Where the template part is intended for use (header, footer, etc.)",
|
||||
"type": "string",
|
||||
"required": false
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"_links": {
|
||||
"self": [
|
||||
{
|
||||
"href": "http://example.org/index.php?rest_route=/wp/v2/template-parts"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/wp/v2/template-parts/(?P<id>[\\/\\w-]+)": {
|
||||
"namespace": "wp/v2",
|
||||
"methods": [
|
||||
"GET",
|
||||
"POST",
|
||||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE"
|
||||
],
|
||||
"endpoints": [
|
||||
{
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"args": {
|
||||
"id": {
|
||||
"description": "The id of a template",
|
||||
"type": "string",
|
||||
"required": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"methods": [
|
||||
"POST",
|
||||
"PUT",
|
||||
"PATCH"
|
||||
],
|
||||
"args": {
|
||||
"slug": {
|
||||
"description": "Unique slug identifying the template.",
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"pattern": "[a-zA-Z_\\-]+",
|
||||
"required": false
|
||||
},
|
||||
"theme": {
|
||||
"description": "Theme identifier for the template.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"content": {
|
||||
"description": "Content of template.",
|
||||
"type": [
|
||||
"object",
|
||||
"string"
|
||||
],
|
||||
"required": false
|
||||
},
|
||||
"title": {
|
||||
"description": "Title of template.",
|
||||
"type": [
|
||||
"object",
|
||||
"string"
|
||||
],
|
||||
"required": false
|
||||
},
|
||||
"description": {
|
||||
"description": "Description of template.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"status": {
|
||||
"description": "Status of template.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"area": {
|
||||
"description": "Where the template part is intended for use (header, footer, etc.)",
|
||||
"type": "string",
|
||||
"required": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"methods": [
|
||||
"DELETE"
|
||||
],
|
||||
"args": {
|
||||
"force": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Whether to bypass Trash and force deletion.",
|
||||
"required": false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"/wp/v2/template-parts/(?P<parent>[\\d]+)/revisions": {
|
||||
"namespace": "wp/v2",
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"endpoints": [
|
||||
{
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"args": {
|
||||
"parent": {
|
||||
"description": "The ID for the parent of the revision.",
|
||||
"type": "integer",
|
||||
"required": false
|
||||
},
|
||||
"context": {
|
||||
"description": "Scope under which the request is made; determines fields present in response.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"view",
|
||||
"embed",
|
||||
"edit"
|
||||
],
|
||||
"default": "view",
|
||||
"required": false
|
||||
},
|
||||
"page": {
|
||||
"description": "Current page of the collection.",
|
||||
"type": "integer",
|
||||
"default": 1,
|
||||
"minimum": 1,
|
||||
"required": false
|
||||
},
|
||||
"per_page": {
|
||||
"description": "Maximum number of items to be returned in result set.",
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 100,
|
||||
"required": false
|
||||
},
|
||||
"search": {
|
||||
"description": "Limit results to those matching a string.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"exclude": {
|
||||
"description": "Ensure result set excludes specific IDs.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
},
|
||||
"default": [],
|
||||
"required": false
|
||||
},
|
||||
"include": {
|
||||
"description": "Limit result set to specific IDs.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
},
|
||||
"default": [],
|
||||
"required": false
|
||||
},
|
||||
"offset": {
|
||||
"description": "Offset the result set by a specific number of items.",
|
||||
"type": "integer",
|
||||
"required": false
|
||||
},
|
||||
"order": {
|
||||
"description": "Order sort attribute ascending or descending.",
|
||||
"type": "string",
|
||||
"default": "desc",
|
||||
"enum": [
|
||||
"asc",
|
||||
"desc"
|
||||
],
|
||||
"required": false
|
||||
},
|
||||
"orderby": {
|
||||
"description": "Sort collection by object attribute.",
|
||||
"type": "string",
|
||||
"default": "date",
|
||||
"enum": [
|
||||
"date",
|
||||
"id",
|
||||
"include",
|
||||
"relevance",
|
||||
"slug",
|
||||
"include_slugs",
|
||||
"title"
|
||||
],
|
||||
"required": false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"/wp/v2/template-parts/(?P<parent>[\\d]+)/revisions/(?P<id>[\\d]+)": {
|
||||
"namespace": "wp/v2",
|
||||
"methods": [
|
||||
"GET",
|
||||
"DELETE"
|
||||
],
|
||||
"endpoints": [
|
||||
{
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"args": {
|
||||
"parent": {
|
||||
"description": "The ID for the parent of the revision.",
|
||||
"type": "integer",
|
||||
"required": false
|
||||
},
|
||||
"id": {
|
||||
"description": "Unique identifier for the revision.",
|
||||
"type": "integer",
|
||||
"required": false
|
||||
},
|
||||
"context": {
|
||||
"description": "Scope under which the request is made; determines fields present in response.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"view",
|
||||
"embed",
|
||||
"edit"
|
||||
],
|
||||
"default": "view",
|
||||
"required": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"methods": [
|
||||
"DELETE"
|
||||
],
|
||||
"args": {
|
||||
"parent": {
|
||||
"description": "The ID for the parent of the revision.",
|
||||
"type": "integer",
|
||||
"required": false
|
||||
},
|
||||
"id": {
|
||||
"description": "Unique identifier for the revision.",
|
||||
"type": "integer",
|
||||
"required": false
|
||||
},
|
||||
"force": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Required to be true, as revisions do not support trashing.",
|
||||
"required": false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"/wp/v2/template-parts/(?P<id>[\\d]+)/autosaves": {
|
||||
"namespace": "wp/v2",
|
||||
"methods": [
|
||||
"GET",
|
||||
"POST"
|
||||
],
|
||||
"endpoints": [
|
||||
{
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"args": {
|
||||
"parent": {
|
||||
"description": "The ID for the parent of the autosave.",
|
||||
"type": "integer",
|
||||
"required": false
|
||||
},
|
||||
"context": {
|
||||
"description": "Scope under which the request is made; determines fields present in response.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"view",
|
||||
"embed",
|
||||
"edit"
|
||||
],
|
||||
"default": "view",
|
||||
"required": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"methods": [
|
||||
"POST"
|
||||
],
|
||||
"args": {
|
||||
"parent": {
|
||||
"description": "The ID for the parent of the autosave.",
|
||||
"type": "integer",
|
||||
"required": false
|
||||
},
|
||||
"slug": {
|
||||
"description": "Unique slug identifying the template.",
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"pattern": "[a-zA-Z_\\-]+",
|
||||
"required": false
|
||||
},
|
||||
"theme": {
|
||||
"description": "Theme identifier for the template.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"content": {
|
||||
"description": "Content of template.",
|
||||
"type": [
|
||||
"object",
|
||||
"string"
|
||||
],
|
||||
"required": false
|
||||
},
|
||||
"title": {
|
||||
"description": "Title of template.",
|
||||
"type": [
|
||||
"object",
|
||||
"string"
|
||||
],
|
||||
"required": false
|
||||
},
|
||||
"description": {
|
||||
"description": "Description of template.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"status": {
|
||||
"description": "Status of template.",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"area": {
|
||||
"description": "Where the template part is intended for use (header, footer, etc.)",
|
||||
"type": "string",
|
||||
"required": false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"/wp/v2/template-parts/(?P<parent>[\\d]+)/autosaves/(?P<id>[\\d]+)": {
|
||||
"namespace": "wp/v2",
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"endpoints": [
|
||||
{
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"args": {
|
||||
"parent": {
|
||||
"description": "The ID for the parent of the autosave.",
|
||||
"type": "integer",
|
||||
"required": false
|
||||
},
|
||||
"id": {
|
||||
"description": "The ID for the autosave.",
|
||||
"type": "integer",
|
||||
"required": false
|
||||
},
|
||||
"context": {
|
||||
"description": "Scope under which the request is made; determines fields present in response.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"view",
|
||||
"embed",
|
||||
"edit"
|
||||
],
|
||||
"default": "view",
|
||||
"required": false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"/wp/v2/types": {
|
||||
"namespace": "wp/v2",
|
||||
"methods": [
|
||||
@@ -8610,6 +9092,34 @@ mockedApiResponse.TypesCollection = {
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"wp_template_part": {
|
||||
"description": "Template parts to include in your templates.",
|
||||
"hierarchical": false,
|
||||
"name": "Template Parts",
|
||||
"slug": "wp_template_part",
|
||||
"taxonomies": [],
|
||||
"rest_base": "template-parts",
|
||||
"rest_namespace": "wp/v2",
|
||||
"_links": {
|
||||
"collection": [
|
||||
{
|
||||
"href": "http://example.org/index.php?rest_route=/wp/v2/types"
|
||||
}
|
||||
],
|
||||
"wp:items": [
|
||||
{
|
||||
"href": "http://example.org/index.php?rest_route=/wp/v2/template-parts"
|
||||
}
|
||||
],
|
||||
"curies": [
|
||||
{
|
||||
"name": "wp",
|
||||
"href": "https://api.w.org/{rel}",
|
||||
"templated": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user