Skip to content

Commit

Permalink
Add __experimentalEnableQuoteBlockV2 flag (#40089)
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal authored Apr 7, 2022
1 parent 48566af commit 36fcdb2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
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

0 comments on commit 36fcdb2

Please sign in to comment.