Skip to content

Commit

Permalink
Adds experimental blocks flag for blocks that may not be ready for ge…
Browse files Browse the repository at this point in the history
…neral use (#64121)
  • Loading branch information
creativecoder committed Aug 1, 2024
1 parent 7206339 commit ff59ffa
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/experimental/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,28 @@ function gutenberg_enable_experiments() {

/**
* Sets a global JS variable used to trigger the availability of form & input blocks.
*
* @deprecated 19.0.0 Use gutenberg_enable_block_experiments().
*/
function gutenberg_enable_form_input_blocks() {
_deprecated_function( __FUNCTION__, 'Gutenberg 19.0.0', 'gutenberg_enable_block_experiments' );
}

/**
* Sets global JS variables used to enable various block experiments.
*/
function gutenberg_enable_block_experiments() {
$gutenberg_experiments = get_option( 'gutenberg-experiments' );

// Experimental form blocks.
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-form-blocks', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableFormBlocks = true', 'before' );
}

// General experimental blocks that are not in the default block library.
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-block-experiments', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableBlockExperiments = true', 'before' );
}
}

add_action( 'admin_init', 'gutenberg_enable_form_input_blocks' );
add_action( 'admin_init', 'gutenberg_enable_block_experiments' );
12 changes: 12 additions & 0 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ function gutenberg_initialize_experiments_settings() {
)
);

add_settings_field(
'gutenberg-block-experiments',
__( 'Experimental blocks', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Enable experimental blocks.<p class="description">(Warning: these blocks may have significant changes during development that cause validation errors and display issues.)</p>', 'gutenberg' ),
'id' => 'gutenberg-block-experiments',
)
);

add_settings_field(
'gutenberg-form-blocks',
__( 'Form and input blocks ', 'gutenberg' ),
Expand Down
1 change: 1 addition & 0 deletions phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function fail_if_died( $message ) {
'gutenberg-widget-experiments' => '1',
'gutenberg-full-site-editing' => 1,
'gutenberg-form-blocks' => 1,
'gutenberg-block-experiments' => 1,
),
);

Expand Down

0 comments on commit ff59ffa

Please sign in to comment.