diff --git a/lib/block-patterns.php b/lib/block-patterns.php index 23575ee84f821..ccc6f8bbf7b68 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 );