Skip to content

Commit

Permalink
Use gutenberg_is_experiment_enabled()
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed May 25, 2023
1 parent 4db4b65 commit 514605e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
4 changes: 1 addition & 3 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,8 @@ function gutenberg_register_packages_scripts( $scripts ) {
// Add dependencies that cannot be detected and generated by build tools.
switch ( $handle ) {
case 'wp-block-library':
$gutenberg_experiments = get_option( 'gutenberg-experiments' );
if (
! $gutenberg_experiments ||
! array_key_exists( 'gutenberg-no-tinymce', $gutenberg_experiments ) ||
! gutenberg_is_experiment_enabled( 'gutenberg-no-tinymce' ) ||
isset( $_COOKIE['requiresTinymce'] )
) {
array_push( $dependencies, 'editor' );
Expand Down
6 changes: 0 additions & 6 deletions lib/experimental/disable-tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
* @package gutenberg
*/

// Power on/off button controlled by a Gutenberg experiment checkbox.
$gutenberg_experiments = get_option( 'gutenberg-experiments' );
if ( ! $gutenberg_experiments || ! array_key_exists( 'gutenberg-no-tinymce', $gutenberg_experiments ) ) {
return;
}

// If user has already requested TinyMCE, we're ending the experiment.
if ( isset( $_COOKIE['requiresTinymce'] ) ) {
return;
Expand Down
2 changes: 1 addition & 1 deletion lib/experimental/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function gutenberg_enable_experiments() {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnablePatternEnhancements = true', 'before' );
}

if ( $gutenberg_experiments && array_key_exists( 'gutenberg-no-tinymce', $gutenberg_experiments ) ) {
if ( gutenberg_is_experiment_enabled( 'gutenberg-no-tinymce' ) ) {
wp_add_inline_script( 'wp-block-library', 'window.__experimentalDisableTinymce = true', 'before' );
}
}
Expand Down
4 changes: 3 additions & 1 deletion lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/experimental/kses.php';
require __DIR__ . '/experimental/l10n.php';
require __DIR__ . '/experimental/navigation-fallback.php';
require __DIR__ . '/experimental/disable-tinymce.php';
if ( gutenberg_is_experiment_enabled( 'gutenberg-no-tinymce' ) ) {
require __DIR__ . '/experimental/disable-tinymce.php';
}
if ( gutenberg_is_experiment_enabled( 'gutenberg-interactivity-api-core-blocks' ) ) {
require __DIR__ . '/experimental/interactivity-api/script-loader.php';
require __DIR__ . '/experimental/interactivity-api/blocks.php';
Expand Down

0 comments on commit 514605e

Please sign in to comment.