diff --git a/lib/block-patterns.php b/lib/block-patterns.php index ccc6f8bbf7b68..04dc127da1ddf 100644 --- a/lib/block-patterns.php +++ b/lib/block-patterns.php @@ -239,8 +239,16 @@ function() { if ( ! get_theme_support( 'core-block-patterns' ) || ! function_exists( 'unregister_block_pattern' ) ) { return; } - remove_core_patterns(); - register_gutenberg_patterns(); + + // Provides a way to opt-out of removing core patterns. + if ( apply_filters( 'remove_core_patterns', true ) ) { + remove_core_patterns(); + } + + // Provides a way to opt-out of pattern registration. + if ( apply_filters( 'register_gutenberg_patterns', true ) ) { + register_gutenberg_patterns(); + } } ); @@ -251,6 +259,11 @@ function( $current_screen ) { return; } + // Provides a way to opt-out of remotely loading core patterns. + if ( ! apply_filters( 'load_remote_patterns', true ) ) { + return; + } + $is_site_editor = ( function_exists( 'gutenberg_is_edit_site_page' ) && gutenberg_is_edit_site_page( $current_screen->id ) ); if ( $current_screen->is_block_editor || $is_site_editor ) { load_remote_patterns();