Skip to content

Commit

Permalink
Updated filters after WordPress#28800, which introduced a remote call…
Browse files Browse the repository at this point in the history
… to patterns directory to fetch and then register patterns.

This commit provides filters to opt out of:
1. removing core patterns, in case Gutenberg users want to use Core patterns
2. adding Gutenberg patterns
3. loading core patterns from remote source
  • Loading branch information
ramonjd committed May 26, 2021
1 parent 87ad8f3 commit 6cf879a
Showing 1 changed file with 15 additions and 2 deletions.
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

0 comments on commit 6cf879a

Please sign in to comment.