From 46971a83ec8b7c867bf0a050c8759fb4f816e166 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 6 Jul 2020 12:02:45 +0000 Subject: [PATCH] Block Editor: Requires title and content when registering block patterns. Props poena. See #50550. git-svn-id: https://develop.svn.wordpress.org/trunk@48336 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-block-patterns-registry.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-block-patterns-registry.php b/src/wp-includes/class-wp-block-patterns-registry.php index bfffb860d7..b7512d8121 100644 --- a/src/wp-includes/class-wp-block-patterns-registry.php +++ b/src/wp-includes/class-wp-block-patterns-registry.php @@ -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 )