5

The block editor has a Fullscreen mode which you can access via the tools options on the top-right:

enter image description here

Is there a PHP approach to enable the Fullscreen mode by default? As in, force this mode for all users. Alternatively, a javascript solution.

1 Answer 1

8

Switching Gutenberg to fullscreen mode requires setting to TRUE fullscreenMode from the core/edit-post package. To enqueue appropriate script, you use enqueue_block_editor_assets action hook.

function se337302_fullscreen_editor()
{
    $js_code = "jQuery(document).ready(function(){" .
            "   var isFullScreenMode = wp.data.select('core/edit-post').isFeatureActive('fullscreenMode');" .
            "   if ( !isFullScreenMode )" .
            "       wp.data.dispatch('core/edit-post').toggleFeature('fullscreenMode');" .
            "});";
    wp_add_inline_script( 'wp-blocks', $js_code );

}
add_action( 'enqueue_block_editor_assets', 'se337302_fullscreen_editor' );
3
  • 1
    Beautiful. I learned a lot with this one, thank you!
    – Christine Cooper
    May 8, 2019 at 9:36
  • So dirty, but still useful. :) Mar 19, 2020 at 13:27
  • Good thread about this on the WP core blog.
    – Christine Cooper
    Mar 18, 2022 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.