Skip to content

Commit

Permalink
List v2: add __experimentalEnableListBlockV2 flag for mobile (#42697)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored Jul 26, 2022
1 parent c5a8482 commit bb9d9ce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/experimental/block-editor-settings-mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ function gutenberg_get_block_editor_settings_mobile( $settings ) {
// To tell mobile that the site uses quote v2 (inner blocks).
// See https://github.com/WordPress/gutenberg/pull/25892.
$settings['__experimentalEnableQuoteBlockV2'] = true;
// To be set to true when the web makes quote v2 (inner blocks) the default.
$settings['__experimentalEnableListBlockV2'] = gutenberg_is_list_v2_enabled();
}

return $settings;
Expand Down
12 changes: 11 additions & 1 deletion lib/experimental/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@
* @package gutenberg
*/

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

/**
* Sets a global JS variable used to trigger the availability of the experimental blocks.
*/
function gutenberg_enable_experimental_blocks() {
if ( get_option( 'gutenberg-experiments' ) && array_key_exists( 'gutenberg-list-v2', get_option( 'gutenberg-experiments' ) ) ) {
if ( gutenberg_is_list_v2_enabled() ) {
wp_add_inline_script( 'wp-block-library', 'window.__experimentalEnableListBlockV2 = true', 'before' );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ public function get_item_schema() {
'context' => array( 'mobile' ),
),

'__experimentalEnableListBlockV2' => array(
'description' => __( 'Whether the V2 of the list 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 bb9d9ce

Please sign in to comment.