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

Add __experimentalEnableQuoteBlockV2 flag #40089

Merged
merged 4 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
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
11 changes: 8 additions & 3 deletions lib/experimental/block-editor-settings-mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ function gutenberg_get_block_editor_settings_mobile( $settings ) {
defined( 'REST_REQUEST' ) &&
REST_REQUEST &&
isset( $_GET['context'] ) &&
'mobile' === $_GET['context'] &&
WP_Theme_JSON_Resolver_Gutenberg::theme_has_support()
'mobile' === $_GET['context']
) {
$settings['__experimentalStyles'] = gutenberg_get_global_styles();
if ( WP_Theme_JSON_Resolver_Gutenberg::theme_has_support() ) {
$settings['__experimentalStyles'] = gutenberg_get_global_styles();
}

// To be set to true when the web makes quote v2 (inner blocks) the default.
// See https://github.com/WordPress/gutenberg/pull/25892.
$settings['__experimentalEnableQuoteBlockV2'] = gutenberg_is_quote_v2_enabled();
}

return $settings;
Expand Down
11 changes: 10 additions & 1 deletion lib/experimental/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ function ( $response ) {
}
add_action( 'rest_api_init', 'gutenberg_rest_comment_set_children_as_embeddable' );

/**
* Returns whether the quote v2 is enabled by the user.
*
* @return boolean
*/
function gutenberg_is_quote_v2_enabled() {
return get_option( 'gutenberg-experiments' ) && array_key_exists( 'gutenberg-quote-v2', get_option( 'gutenberg-experiments' ) );
}

/**
* Sets a global JS variable used to trigger the availability of the experimental blocks.
*/
Expand All @@ -160,7 +169,7 @@ function gutenberg_enable_experimental_blocks() {
wp_add_inline_script( 'wp-block-library', 'window.__experimentalEnableListBlockV2 = true', 'before' );
}

if ( get_option( 'gutenberg-experiments' ) && array_key_exists( 'gutenberg-quote-v2', get_option( 'gutenberg-experiments' ) ) ) {
if ( gutenberg_is_quote_v2_enabled() ) {
wp_add_inline_script( 'wp-block-library', 'window.__experimentalEnableQuoteBlockV2 = true', 'before' );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ public function get_item_schema() {
'context' => array( 'mobile' ),
),

'__experimentalEnableQuoteBlockV2' => array(
'description' => __( 'Whether the V2 of the quote block that uses inner blocks should be enabled.', 'gutenberg' ),
'type' => 'boolean',
'context' => array( 'mobile' ),
),

'alignWide' => array(
'description' => __( 'Enable/Disable Wide/Full Alignments.', 'gutenberg' ),
'type' => 'boolean',
Expand Down