mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-29 23:57:41 +02:00
REST API: Use snake case convention for field names in Block Patterns
Backports the same changes applied in Gutenberg: https://github.com/WordPress/gutenberg/pull/40254. Follow-up for [53152]. Props jsnajdr, timothyblynjacobs. See #55505. Built from https://develop.svn.wordpress.org/trunk@53154 git-svn-id: http://core.svn.wordpress.org/trunk@52743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e1414c93ca
commit
34e9aca0ca
@ -107,19 +107,19 @@ class WP_REST_Block_Patterns_Controller extends WP_REST_Controller {
|
|||||||
public function prepare_item_for_response( $item, $request ) {
|
public function prepare_item_for_response( $item, $request ) {
|
||||||
$fields = $this->get_fields_for_response( $request );
|
$fields = $this->get_fields_for_response( $request );
|
||||||
$keys = array(
|
$keys = array(
|
||||||
'name',
|
'name' => 'name',
|
||||||
'title',
|
'title' => 'title',
|
||||||
'description',
|
'description' => 'description',
|
||||||
'viewportWidth',
|
'viewportWidth' => 'viewport_width',
|
||||||
'blockTypes',
|
'blockTypes' => 'block_types',
|
||||||
'categories',
|
'categories' => 'categories',
|
||||||
'keywords',
|
'keywords' => 'keywords',
|
||||||
'content',
|
'content' => 'content',
|
||||||
);
|
);
|
||||||
$data = array();
|
$data = array();
|
||||||
foreach ( $keys as $key ) {
|
foreach ( $keys as $item_key => $rest_key ) {
|
||||||
if ( isset( $item[ $key ] ) && rest_is_field_included( $key, $fields ) ) {
|
if ( isset( $item[ $item_key ] ) && rest_is_field_included( $rest_key, $fields ) ) {
|
||||||
$data[ $key ] = $item[ $key ];
|
$data[ $rest_key ] = $item[ $item_key ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,49 +142,49 @@ class WP_REST_Block_Patterns_Controller extends WP_REST_Controller {
|
|||||||
'title' => 'block-pattern',
|
'title' => 'block-pattern',
|
||||||
'type' => 'object',
|
'type' => 'object',
|
||||||
'properties' => array(
|
'properties' => array(
|
||||||
'name' => array(
|
'name' => array(
|
||||||
'description' => __( 'The pattern name.' ),
|
'description' => __( 'The pattern name.' ),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'context' => array( 'view', 'edit', 'embed' ),
|
'context' => array( 'view', 'edit', 'embed' ),
|
||||||
),
|
),
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'description' => __( 'The pattern title, in human readable format.' ),
|
'description' => __( 'The pattern title, in human readable format.' ),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'context' => array( 'view', 'edit', 'embed' ),
|
'context' => array( 'view', 'edit', 'embed' ),
|
||||||
),
|
),
|
||||||
'description' => array(
|
'description' => array(
|
||||||
'description' => __( 'The pattern detailed description.' ),
|
'description' => __( 'The pattern detailed description.' ),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'context' => array( 'view', 'edit', 'embed' ),
|
'context' => array( 'view', 'edit', 'embed' ),
|
||||||
),
|
),
|
||||||
'viewportWidth' => array(
|
'viewport_Width' => array(
|
||||||
'description' => __( 'The pattern viewport width for inserter preview.' ),
|
'description' => __( 'The pattern viewport width for inserter preview.' ),
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'context' => array( 'view', 'edit', 'embed' ),
|
'context' => array( 'view', 'edit', 'embed' ),
|
||||||
),
|
),
|
||||||
'blockTypes' => array(
|
'block_Types' => array(
|
||||||
'description' => __( 'Block types that the pattern is intended to be used with.' ),
|
'description' => __( 'Block types that the pattern is intended to be used with.' ),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'context' => array( 'view', 'edit', 'embed' ),
|
'context' => array( 'view', 'edit', 'embed' ),
|
||||||
),
|
),
|
||||||
'categories' => array(
|
'categories' => array(
|
||||||
'description' => __( 'The pattern category slugs.' ),
|
'description' => __( 'The pattern category slugs.' ),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'context' => array( 'view', 'edit', 'embed' ),
|
'context' => array( 'view', 'edit', 'embed' ),
|
||||||
),
|
),
|
||||||
'keywords' => array(
|
'keywords' => array(
|
||||||
'description' => __( 'The pattern keywords.' ),
|
'description' => __( 'The pattern keywords.' ),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'context' => array( 'view', 'edit', 'embed' ),
|
'context' => array( 'view', 'edit', 'embed' ),
|
||||||
),
|
),
|
||||||
'content' => array(
|
'content' => array(
|
||||||
'description' => __( 'The pattern content.' ),
|
'description' => __( 'The pattern content.' ),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.0-alpha-53153';
|
$wp_version = '6.0-alpha-53154';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user