Skip to content

Commit

Permalink
Adds the gutenberg-off-canvas-navigation-editor experiment (#45515)
Browse files Browse the repository at this point in the history
  • Loading branch information
draganescu committed Nov 7, 2022
1 parent 25aa4b4 commit 1386ec3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/experimental/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,15 @@ function gutenberg_enable_zoomed_out_view() {
}

add_action( 'admin_init', 'gutenberg_enable_zoomed_out_view' );

/**
* Sets a global JS variable used to trigger the availability of the Navigation List View experiment.
*/
function gutenberg_enable_off_canvas_navigation_editor() {
$gutenberg_experiments = get_option( 'gutenberg-experiments' );
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-off-canvas-navigation-editor', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableOffCanvasNavigationEditor = true', 'before' );
}
}

add_action( 'admin_init', 'gutenberg_enable_off_canvas_navigation_editor' );
11 changes: 11 additions & 0 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ function gutenberg_initialize_experiments_settings() {
'id' => 'gutenberg-zoomed-out-view',
)
);
add_settings_field(
'gutenberg-off-canvas-navigation-editor',
__( 'Off canvas navigation editor ', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Test a new "off canvas" editor for navigation block using the block inspector and a tree view of the current menu', 'gutenberg' ),
'id' => 'gutenberg-off-canvas-navigation-editor',
)
);
register_setting(
'gutenberg-experiments',
'gutenberg-experiments'
Expand Down

0 comments on commit 1386ec3

Please sign in to comment.