From 847480686054765e6167e97650a18b5d9727328a Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Thu, 20 May 2021 14:07:35 +1000 Subject: [PATCH] Fix unregister_block_pattern notices --- lib/block-patterns.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/block-patterns.php b/lib/block-patterns.php index 23575ee84f8216..ccc6f8bbf7b68e 100644 --- a/lib/block-patterns.php +++ b/lib/block-patterns.php @@ -202,7 +202,10 @@ function remove_core_patterns() { ); foreach ( $core_block_patterns as $core_block_pattern ) { - unregister_block_pattern( 'core/' . $core_block_pattern ); + $name = 'core/' . $core_block_pattern; + if ( WP_Block_Patterns_Registry::get_instance()->is_registered( $name ) ) { + unregister_block_pattern( $name ); + } } } @@ -212,7 +215,7 @@ function remove_core_patterns() { function load_remote_patterns() { $patterns = get_transient( 'gutenberg_remote_block_patterns' ); if ( ! $patterns ) { - $request = new WP_REST_Request( 'GET', '/__experimental/pattern-directory/patterns' ); + $request = new WP_REST_Request( 'GET', '/__experimental/pattern-directory/patterns' ); $core_keyword_id = 11; // 11 is the ID for "core". $request->set_param( 'keyword', $core_keyword_id ); $response = rest_do_request( $request );