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

List v2: add __experimentalEnableListBlockV2 flag for mobile #42697

Merged
merged 1 commit into from
Jul 26, 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
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