-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Implement partially synced patterns behind an experimental flag #56235
Changes from all commits
dc91763
d6ba27c
6a6d651
66ed476
fd0d8e3
f5f6282
a1ecae4
728f592
cc1d5bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* Pattern block support flag. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
$gutenberg_experiments = get_option( 'gutenberg-experiments' ); | ||
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-pattern-partial-syncing', $gutenberg_experiments ) ) { | ||
/** | ||
* Registers the overrides context for block types that support it. | ||
* | ||
* @param WP_Block_Type $block_type Block Type. | ||
*/ | ||
function gutenberg_register_pattern_support( $block_type ) { | ||
$pattern_support = property_exists( $block_type, 'supports' ) ? _wp_array_get( $block_type->supports, array( '__experimentalConnections' ), false ) : false; | ||
|
||
if ( $pattern_support ) { | ||
if ( ! $block_type->uses_context ) { | ||
$block_type->uses_context = array(); | ||
} | ||
|
||
if ( ! in_array( 'pattern/overrides', $block_type->uses_context, true ) ) { | ||
$block_type->uses_context[] = 'pattern/overrides'; | ||
} | ||
} | ||
} | ||
|
||
// Register the block support. | ||
WP_Block_Supports::get_instance()->register( | ||
'pattern', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this might be a bit confusing as we don't add Similar to the other comment, the name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks more specific to block bindings (previously connections), but it is indeed necessary for the Pattern block. |
||
array( | ||
'register_attribute' => 'gutenberg_register_pattern_support', | ||
) | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,18 @@ function gutenberg_initialize_experiments_settings() { | |
) | ||
); | ||
|
||
add_settings_field( | ||
'gutenberg-pattern-partial-syncing', | ||
__( 'Synced patterns partial syncing', 'gutenberg' ), | ||
'gutenberg_display_experiment_field', | ||
'gutenberg-experiments', | ||
'gutenberg_experiments_section', | ||
array( | ||
'label' => __( 'Test partial syncing of patterns', 'gutenberg' ), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could add a better description to this, but maybe I can do a follow-up PR that adds some more detail. |
||
'id' => 'gutenberg-pattern-partial-syncing', | ||
) | ||
); | ||
|
||
register_setting( | ||
'gutenberg-experiments', | ||
'gutenberg-experiments' | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this could be called
pattern-partial-syncing.php
or similar. While it does a slightly different thing to the js file of the same name, it is a little more descriptive.