diff --git a/lib/experimental/editor-settings.php b/lib/experimental/editor-settings.php index 09ac4b6990d919..065264fd124e8c 100644 --- a/lib/experimental/editor-settings.php +++ b/lib/experimental/editor-settings.php @@ -34,6 +34,9 @@ function gutenberg_enable_experiments() { if ( $gutenberg_experiments && array_key_exists( 'gutenberg-quick-edit-dataviews', $gutenberg_experiments ) ) { wp_add_inline_script( 'wp-block-editor', 'window.__experimentalQuickEditDataViews = true', 'before' ); } + if ( $gutenberg_experiments && array_key_exists( 'gutenberg-block-bindings-ui', $gutenberg_experiments ) ) { + wp_add_inline_script( 'wp-block-editor', 'window.__experimentalBlockBindingsUI = true', 'before' ); + } } add_action( 'admin_init', 'gutenberg_enable_experiments' ); diff --git a/lib/experiments-page.php b/lib/experiments-page.php index 7cc4198c14ef91..acb095b47fde30 100644 --- a/lib/experiments-page.php +++ b/lib/experiments-page.php @@ -163,6 +163,18 @@ function gutenberg_initialize_experiments_settings() { ) ); + add_settings_field( + 'gutenberg-block-bindings-ui', + __( 'UI to create block bindings', 'gutenberg' ), + 'gutenberg_display_experiment_field', + 'gutenberg-experiments', + 'gutenberg_experiments_section', + array( + 'label' => __( 'Add UI to create and update block bindings in block inspector controls.', 'gutenberg' ), + 'id' => 'gutenberg-block-bindings-ui', + ) + ); + register_setting( 'gutenberg-experiments', 'gutenberg-experiments' diff --git a/packages/block-editor/src/hooks/block-bindings.js b/packages/block-editor/src/hooks/block-bindings.js index 2f2a36be9f50db..ce3fdd2f327c40 100644 --- a/packages/block-editor/src/hooks/block-bindings.js +++ b/packages/block-editor/src/hooks/block-bindings.js @@ -298,8 +298,10 @@ export const BlockBindingsPanel = ( { name, metadata } ) => { } } ); - // At this moment, the UI can be locked when there are no fields to connect to. - const readOnly = ! Object.keys( fieldsList ).length; + // Lock the UI when the experiment is not enabled or there are no fields to connect to. + const readOnly = + ! window.__experimentalBlockBindingsUI || + ! Object.keys( fieldsList ).length; if ( readOnly && Object.keys( filteredBindings ).length === 0 ) { return null;