Editor: Add post types property to wp-rest-block-patterns-controller.php.
Backports PHP changes in WordPress/gutenberg#41791 to the core. Adds the post types property to the rest API patterns endpoint. Props mcsf, ntsekouras, matveb. See #56467. Built from https://develop.svn.wordpress.org/trunk@54263 git-svn-id: http://core.svn.wordpress.org/trunk@53822 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7049f79f97
commit
d3b0d0f1df
|
@ -189,6 +189,7 @@ function _register_remote_theme_patterns() {
|
||||||
* - Categories (comma-separated values)
|
* - Categories (comma-separated values)
|
||||||
* - Keywords (comma-separated values)
|
* - Keywords (comma-separated values)
|
||||||
* - Block Types (comma-separated values)
|
* - Block Types (comma-separated values)
|
||||||
|
* - Post Types (comma-separated values)
|
||||||
* - Inserter (yes/no)
|
* - Inserter (yes/no)
|
||||||
*
|
*
|
||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
|
@ -203,6 +204,7 @@ function _register_theme_block_patterns() {
|
||||||
'categories' => 'Categories',
|
'categories' => 'Categories',
|
||||||
'keywords' => 'Keywords',
|
'keywords' => 'Keywords',
|
||||||
'blockTypes' => 'Block Types',
|
'blockTypes' => 'Block Types',
|
||||||
|
'postTypes' => 'Post Types',
|
||||||
'inserter' => 'Inserter',
|
'inserter' => 'Inserter',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -274,7 +276,7 @@ function _register_theme_block_patterns() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// For properties of type array, parse data as comma-separated.
|
// For properties of type array, parse data as comma-separated.
|
||||||
foreach ( array( 'categories', 'keywords', 'blockTypes' ) as $property ) {
|
foreach ( array( 'categories', 'keywords', 'blockTypes', 'postTypes' ) as $property ) {
|
||||||
if ( ! empty( $pattern_data[ $property ] ) ) {
|
if ( ! empty( $pattern_data[ $property ] ) ) {
|
||||||
$pattern_data[ $property ] = array_filter(
|
$pattern_data[ $property ] = array_filter(
|
||||||
preg_split(
|
preg_split(
|
||||||
|
|
|
@ -124,6 +124,7 @@ class WP_REST_Block_Patterns_Controller extends WP_REST_Controller {
|
||||||
'description' => 'description',
|
'description' => 'description',
|
||||||
'viewportWidth' => 'viewport_width',
|
'viewportWidth' => 'viewport_width',
|
||||||
'blockTypes' => 'block_types',
|
'blockTypes' => 'block_types',
|
||||||
|
'postTypes' => 'post_types',
|
||||||
'categories' => 'categories',
|
'categories' => 'categories',
|
||||||
'keywords' => 'keywords',
|
'keywords' => 'keywords',
|
||||||
'content' => 'content',
|
'content' => 'content',
|
||||||
|
@ -185,6 +186,12 @@ class WP_REST_Block_Patterns_Controller extends WP_REST_Controller {
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'context' => array( 'view', 'edit', 'embed' ),
|
'context' => array( 'view', 'edit', 'embed' ),
|
||||||
),
|
),
|
||||||
|
'post_types' => array(
|
||||||
|
'description' => __( ' An array of post types that the pattern is restricted to be used with.' ),
|
||||||
|
'type' => 'array',
|
||||||
|
'readonly' => true,
|
||||||
|
'context' => array( 'view', 'edit', 'embed' ),
|
||||||
|
),
|
||||||
'categories' => array(
|
'categories' => array(
|
||||||
'description' => __( 'The pattern category slugs.' ),
|
'description' => __( 'The pattern category slugs.' ),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.1-alpha-54262';
|
$wp_version = '6.1-alpha-54263';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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