| @@ -32,13 +32,13 @@ | ||
| 32 | 32 | */ |
| 33 | 33 | function gutenberg_render_block_core_pattern( $attributes ) { |
| 34 | 34 | static $seen_refs = array(); |
| 35 | 35 | |
| 36 | - if ( empty( $attributes['slug'] ) ) { | |
| 36 | + $slug = $attributes['slug'] ?? null; | |
| 37 | + if ( empty( $slug ) || ! is_string( $slug ) ) { | |
| 37 | 38 | return ''; |
| 38 | 39 | } |
| 39 | 40 | |
| 40 | - $slug = $attributes['slug']; | |
| 41 | 41 | $registry = WP_Block_Patterns_Registry::get_instance(); |
| 42 | 42 | |
| 43 | 43 | if ( ! $registry->is_registered( $slug ) ) { |
| 44 | 44 | return ''; |
| @@ -43,9 +43,9 @@ | ||
| 43 | 43 | if ( ! $registry->is_registered( $slug ) ) { |
| 44 | 44 | return ''; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if ( isset( $seen_refs[ $attributes['slug'] ] ) ) { | |
| 47 | + if ( isset( $seen_refs[ $slug ] ) ) { | |
| 48 | 48 | // WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent |
| 49 | 49 | // is set in `wp_debug_mode()`. |
| 50 | 50 | $is_debug = WP_DEBUG && WP_DEBUG_DISPLAY; |
| 51 | 51 | |
| @@ -57,9 +57,9 @@ | ||
| 57 | 57 | |
| 58 | 58 | $pattern = $registry->get_registered( $slug ); |
| 59 | 59 | $content = $pattern['content']; |
| 60 | 60 | |
| 61 | - $seen_refs[ $attributes['slug'] ] = true; | |
| 61 | + $seen_refs[ $slug ] = true; | |
| 62 | 62 | |
| 63 | 63 | $content = do_blocks( $content ); |
| 64 | 64 | |
| 65 | 65 | global $wp_embed; |
| @@ -64,9 +64,9 @@ | ||
| 64 | 64 | |
| 65 | 65 | global $wp_embed; |
| 66 | 66 | $content = $wp_embed->autoembed( $content ); |
| 67 | 67 | |
| 68 | - unset( $seen_refs[ $attributes['slug'] ] ); | |
| 68 | + unset( $seen_refs[ $slug ] ); | |
| 69 | 69 | return $content; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | add_action( 'init', 'gutenberg_register_block_core_pattern', 20 ); |