Make WordPress Core

Changeset 48336


Ignore:
Timestamp:
07/06/2020 12:02:45 PM (5 years ago)
Author:
youknowriad
Message:

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

Props poena.
See #50550.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-patterns-registry.php

    r48334 r48336  
    3434     *
    3535     * @param string $pattern_name       Pattern name including namespace.
    36      * @param array  $pattern_properties Array containing the properties of the pattern: label, content.
     36     * @param array  $pattern_properties Array containing the properties of the pattern: title, content, description, viewportWidth, categories, keywords.
    3737     * @return bool True if the pattern was registered with success and false otherwise.
    3838     */
     
    4040        if ( ! isset( $pattern_name ) || ! is_string( $pattern_name ) ) {
    4141            _doing_it_wrong( __METHOD__, __( 'Pattern name must be a string.' ), '5.5.0' );
     42            return false;
     43        }
     44
     45        if ( ! isset( $pattern_properties['title'] ) || ! is_string( $pattern_properties['title'] ) ) {
     46            _doing_it_wrong( __METHOD__, __( 'Pattern title must be a string.' ), '5.5.0' );
     47            return false;
     48        }
     49
     50        if ( ! isset( $pattern_properties['content'] ) || ! is_string( $pattern_properties['content'] ) ) {
     51            _doing_it_wrong( __METHOD__, __( 'Pattern content must be a string.' ), '5.5.0' );
    4252            return false;
    4353        }
Note: See TracChangeset for help on using the changeset viewer.