Skip to content

Commit

Permalink
Add schemas for WordPress 6.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbillion committed Jul 12, 2024
1 parent 851ae31 commit 8d7063d
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"ext-pdo_sqlite": "*",
"johnbillion/args": "1.7.0",
"roots/wordpress-core-installer": "^1.0.0",
"roots/wordpress-full": "~6.5.0",
"roots/wordpress-full": "6.6-RC3",
"wp-cli/core-command": "^2",
"wp-cli/db-command": "^2",
"wp-cli/language-command": "^2",
Expand Down
43 changes: 43 additions & 0 deletions packages/wp-types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ export interface WP_Post_Type_Labels {
item_link_description: string;
menu_name: string;
name_admin_bar: string;
template_name?: string;
}
/**
* Post type capabilities.
Expand Down Expand Up @@ -1723,6 +1724,7 @@ export interface WP_Taxonomy_Labels {
item_link_description: string;
menu_name: string;
name_admin_bar: string;
template_name: string;
}
/**
* Taxonomy capabilities.
Expand Down Expand Up @@ -1957,6 +1959,10 @@ export interface WP_REST_API_Post {
* A field used for ordering posts.
*/
menu_order?: number;
/**
* An array of the class names for the post container element.
*/
class_list: string[];
/**
* The title for the post.
*/
Expand Down Expand Up @@ -2202,6 +2208,10 @@ export interface WP_REST_API_Attachment {
* Slug automatically generated from the attachment title. Only present when using the 'edit' context and the post type is public.
*/
generated_slug?: string;
/**
* An array of the class names for the post container element.
*/
class_list: string[];
/**
* The title for the attachment.
*/
Expand Down Expand Up @@ -2339,6 +2349,23 @@ export interface WP_REST_API_Block {
*/
protected: boolean;
};
/**
* The excerpt for the block.
*/
excerpt?: {
/**
* Excerpt for the block, as it exists in the database. Only present when using the 'edit' context.
*/
raw?: string;
/**
* HTML content for the post excerpt, transformed for display.
*/
rendered: string;
/**
* Whether the content is protected with a password.
*/
protected: boolean;
};
wp_pattern_sync_status: "" | "partial" | "unsynced";
/**
* Pattern categories.
Expand Down Expand Up @@ -3279,6 +3306,22 @@ export interface WP_REST_API_Type {
* REST route's namespace for the post type.
*/
rest_namespace: string;
/**
* The block template associated with the post type.
*/
template?: (
| [string]
| [
string,
{
[k: string]: unknown;
},
]
)[];
/**
* The template lock associated with the post type, or false if none.
*/
template_lock?: "all" | "insert" | false;
/**
* The visibility settings for the post type. Only present when using the 'edit' context.
*/
Expand Down
3 changes: 3 additions & 0 deletions schemas/properties/post-type-labels.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@
},
"name_admin_bar": {
"type": "string"
},
"template_name": {
"type": "string"
}
},
"additionalProperties": false
Expand Down
4 changes: 4 additions & 0 deletions schemas/properties/taxonomy-labels.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"back_to_items",
"item_link",
"item_link_description",
"template_name",
"menu_name",
"name_admin_bar"
],
Expand Down Expand Up @@ -162,6 +163,9 @@
},
"name_admin_bar": {
"type": "string"
},
"template_name": {
"type": "string"
}
},
"additionalProperties": false
Expand Down
9 changes: 9 additions & 0 deletions schemas/rest-api/attachment.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"slug",
"status",
"type",
"class_list",
"title",
"author",
"template",
Expand Down Expand Up @@ -222,6 +223,14 @@
"description": "Slug automatically generated from the attachment title. Only present when using the 'edit' context and the post type is public.",
"type": "string"
},
"class_list": {
"readOnly": true,
"description": "An array of the class names for the post container element.",
"type": "array",
"items": {
"type": "string"
}
},
"title": {
"description": "The title for the attachment.",
"type": "object",
Expand Down
27 changes: 27 additions & 0 deletions schemas/rest-api/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,33 @@
},
"additionalProperties": false
},
"excerpt": {
"description": "The excerpt for the block.",
"type": "object",
"required": [
"rendered",
"protected"
],
"properties": {
"raw": {
"description": "Excerpt for the block, as it exists in the database. Only present when using the 'edit' context.",
"contentMediaType": "text/html",
"type": "string"
},
"rendered": {
"readOnly": true,
"description": "HTML content for the post excerpt, transformed for display.",
"contentMediaType": "text/html",
"type": "string"
},
"protected": {
"readOnly": true,
"description": "Whether the content is protected with a password.",
"type": "boolean"
}
},
"additionalProperties": false
},
"wp_pattern_sync_status": {
"type": "string",
"enum": [
Expand Down
9 changes: 9 additions & 0 deletions schemas/rest-api/post.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"slug",
"status",
"type",
"class_list",
"title",
"content",
"author",
Expand Down Expand Up @@ -144,6 +145,14 @@
"description": "A field used for ordering posts.",
"type": "integer"
},
"class_list": {
"readOnly": true,
"description": "An array of the class names for the post container element.",
"type": "array",
"items": {
"type": "string"
}
},
"title": {
"description": "The title for the post.",
"type": "object",
Expand Down
57 changes: 57 additions & 0 deletions schemas/rest-api/type.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,63 @@
"description": "REST route's namespace for the post type.",
"type": "string"
},
"template": {
"description": "The block template associated with the post type.",
"examples": [
[
[
"core/image"
]
],
[
[
"core/image"
],
[
"core/paragraph",
{
"placeholder": "Image Details"
}
]
]
],
"type": "array",
"items": {
"oneOf": [
{
"type": "array",
"items": [
{
"type": "string"
}
],
"minItems": 1,
"maxItems": 1
},
{
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "object"
}
],
"minItems": 2,
"maxItems": 2
}
]
}
},
"template_lock": {
"description": "The template lock associated with the post type, or false if none.",
"enum": [
"all",
"insert",
false
]
},
"visibility": {
"description": "The visibility settings for the post type. Only present when using the 'edit' context.",
"type": "object",
Expand Down
4 changes: 4 additions & 0 deletions tests/data/rest-api/routes/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"/wp/v2/blocks/(?P<parent>[\\d]+)/autosaves/(?P<id>[\\d]+)",
"/wp/v2/blocks/(?P<parent>[\\d]+)/revisions",
"/wp/v2/blocks/(?P<parent>[\\d]+)/revisions/(?P<id>[\\d]+)",
"/wp/v2/book",
"/wp/v2/book/(?P<id>[\\d]+)",
"/wp/v2/book/(?P<id>[\\d]+)/autosaves",
"/wp/v2/book/(?P<parent>[\\d]+)/autosaves/(?P<id>[\\d]+)",
"/wp/v2/categories",
"/wp/v2/categories/(?P<id>[\\d]+)",
"/wp/v2/comments",
Expand Down
3 changes: 3 additions & 0 deletions tests/data/rest-api/routes/wp-v2-book-id-autosaves.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp/v2/book/(?P<id>[\\d]+)/autosaves"
}
3 changes: 3 additions & 0 deletions tests/data/rest-api/routes/wp-v2-book-id.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp/v2/book/(?P<id>[\\d]+)"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp/v2/book/(?P<parent>[\\d]+)/autosaves/(?P<id>[\\d]+)"
}
3 changes: 3 additions & 0 deletions tests/data/rest-api/routes/wp-v2-book.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp/v2/book"
}
17 changes: 17 additions & 0 deletions tests/mu-plugins/mu-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@
// Ensure we're authenticated as an admin during test data generation.
grant_super_admin( 1 );
wp_set_current_user( 1 );

register_post_type( 'book', [
'public' => true,
'label' => 'Books',
'show_in_rest' => true,
'template' => [
[
'core/paragraph',
[
'placeholder' => 'Add a description of the book',
],
],
[
'core/paragraph',
],
],
] );
} );

/**
Expand Down

0 comments on commit 8d7063d

Please sign in to comment.