Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patterns: provide a way to opt-out of Gutenberg patterns and core patterns updates #31924

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/block-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
);

Expand All @@ -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();
Expand Down