Add: Template types to the patterns API.
Backports https://github.com/WordPress/gutenberg/pull/45814 into the core. This commit adds a new templateType property to the patterns registration API. This property allows a pattern to specify which template it makes sense on, e.g.: 404, single-post, single-product, category. Props youknowriad, ntsekouras, spacedmonkey. Built from https://develop.svn.wordpress.org/trunk@55168 git-svn-id: http://core.svn.wordpress.org/trunk@54701 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -173,6 +173,7 @@ class WP_REST_Block_Patterns_Controller extends WP_REST_Controller {
|
||||
'keywords' => 'keywords',
|
||||
'content' => 'content',
|
||||
'inserter' => 'inserter',
|
||||
'templateTypes' => 'template_types',
|
||||
);
|
||||
$data = array();
|
||||
foreach ( $keys as $item_key => $rest_key ) {
|
||||
@@ -248,6 +249,12 @@ class WP_REST_Block_Patterns_Controller extends WP_REST_Controller {
|
||||
'readonly' => true,
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
),
|
||||
'template_types' => array(
|
||||
'description' => __( 'An array of template types where the pattern fits.' ),
|
||||
'type' => 'array',
|
||||
'readonly' => true,
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
),
|
||||
'content' => array(
|
||||
'description' => __( 'The pattern content.' ),
|
||||
'type' => 'string',
|
||||
|
||||
Reference in New Issue
Block a user