diff --git a/lib/experimental/editor-settings.php b/lib/experimental/editor-settings.php index 065264fd124e8..c34984baa0a61 100644 --- a/lib/experimental/editor-settings.php +++ b/lib/experimental/editor-settings.php @@ -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' ); diff --git a/lib/experiments-page.php b/lib/experiments-page.php index acb095b47fde3..b27f6fc2726a2 100644 --- a/lib/experiments-page.php +++ b/lib/experiments-page.php @@ -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.
(Warning: these blocks may have significant changes during development that cause validation errors and display issues.)
', 'gutenberg' ), + 'id' => 'gutenberg-block-experiments', + ) + ); + add_settings_field( 'gutenberg-form-blocks', __( 'Form and input blocks ', 'gutenberg' ), diff --git a/phpunit/bootstrap.php b/phpunit/bootstrap.php index 295d02978f120..55319a752b61e 100644 --- a/phpunit/bootstrap.php +++ b/phpunit/bootstrap.php @@ -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, ), );