REST API: Add inserter field to the schema of Patterns endpoint

Backports changes from https://github.com/WordPress/gutenberg/pull/40416. Adds the missing `inserter` field to the Patterns item schema. This field was omitted from the response, and patterns that should be hidden in the inserter were visible.

Props mamaduka, ndiego.
See #55567.
Follow-up [53152].




git-svn-id: https://develop.svn.wordpress.org/trunk@53210 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Greg Ziółkowski 2022-04-19 09:39:42 +00:00
parent 699853bbc4
commit e8df37e341

View File

@ -127,6 +127,7 @@ class WP_REST_Block_Patterns_Controller extends WP_REST_Controller {
'categories' => 'categories',
'keywords' => 'keywords',
'content' => 'content',
'inserter' => 'inserter',
);
$data = array();
foreach ( $keys as $item_key => $rest_key ) {
@ -202,6 +203,12 @@ class WP_REST_Block_Patterns_Controller extends WP_REST_Controller {
'readonly' => true,
'context' => array( 'view', 'edit', 'embed' ),
),
'inserter' => array(
'description' => __( 'Determines whether the pattern is visible in inserter.' ),
'type' => 'boolean',
'readonly' => true,
'context' => array( 'view', 'edit', 'embed' ),
),
),
);