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:
Robert Anderson
2021-11-08 23:09:53 +00:00
parent 81b29a2865
commit 39e33bed83
18 changed files with 1828 additions and 44 deletions

View File

@@ -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
}
]
}
}
};