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.

git-svn-id: https://develop.svn.wordpress.org/trunk@55168 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jorge Costa
2023-01-31 16:47:58 +00:00
parent aaf0a3366c
commit 620760e1c1
3 changed files with 22 additions and 9 deletions
+3 -1
View File
@@ -302,6 +302,7 @@ function _register_remote_theme_patterns() {
* - Keywords (comma-separated values)
* - Block Types (comma-separated values)
* - Post Types (comma-separated values)
* - Template Types (comma-separated values)
* - Inserter (yes/no)
*
* @since 6.0.0
@@ -318,6 +319,7 @@ function _register_theme_block_patterns() {
'blockTypes' => 'Block Types',
'postTypes' => 'Post Types',
'inserter' => 'Inserter',
'templateTypes' => 'Template Types',
);
/*
@@ -388,7 +390,7 @@ function _register_theme_block_patterns() {
}
// For properties of type array, parse data as comma-separated.
foreach ( array( 'categories', 'keywords', 'blockTypes', 'postTypes' ) as $property ) {
foreach ( array( 'categories', 'keywords', 'blockTypes', 'postTypes', 'templateTypes' ) as $property ) {
if ( ! empty( $pattern_data[ $property ] ) ) {
$pattern_data[ $property ] = array_filter(
preg_split(