Block Editor: Requires title and content when registering block patterns.

Props poena.
See #50550.

Built from https://develop.svn.wordpress.org/trunk@48336


git-svn-id: http://core.svn.wordpress.org/trunk@48105 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
youknowriad 2020-07-06 12:04:02 +00:00
parent 4fa05e90e8
commit f867b02772
2 changed files with 12 additions and 2 deletions

View File

@ -33,7 +33,7 @@ final class WP_Block_Patterns_Registry {
* @since 5.5.0
*
* @param string $pattern_name Pattern name including namespace.
* @param array $pattern_properties Array containing the properties of the pattern: label, content.
* @param array $pattern_properties Array containing the properties of the pattern: title, content, description, viewportWidth, categories, keywords.
* @return bool True if the pattern was registered with success and false otherwise.
*/
public function register( $pattern_name, $pattern_properties ) {
@ -42,6 +42,16 @@ final class WP_Block_Patterns_Registry {
return false;
}
if ( ! isset( $pattern_properties['title'] ) || ! is_string( $pattern_properties['title'] ) ) {
_doing_it_wrong( __METHOD__, __( 'Pattern title must be a string.' ), '5.5.0' );
return false;
}
if ( ! isset( $pattern_properties['content'] ) || ! is_string( $pattern_properties['content'] ) ) {
_doing_it_wrong( __METHOD__, __( 'Pattern content must be a string.' ), '5.5.0' );
return false;
}
$this->registered_patterns[ $pattern_name ] = array_merge(
$pattern_properties,
array( 'name' => $pattern_name )

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-48335';
$wp_version = '5.5-alpha-48336';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.