Quick Tip: Disable WordPress Block Editor Fullscreen Mode

I don’t know why, but any time I edit posts on this site, the block editor always goes into fullscreen mode. Even if I disable it, the next time I edit a post or refresh, it goes right back. My preferences aren’t being saved.

Oh well, we can fix that with some PHP!

if ( is_admin() ) {
     function jba_disable_editor_fullscreen_by_default() {
         $script = "jQuery( window ).load(function() { const 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', $script );
     }
     add_action( 'enqueue_block_editor_assets', 'jba_disable_editor_fullscreen_by_default' );
 }Code language: PHP (php)

Many thanks to Jean-Baptiste Audras for this snippet he shared on his site last year 🥳

Other Posts Not Worth Reading

Hey, You!

Like this kind of garbage? Subscribe for more! I post like once a month or so, unless I found something interesting to write about.


Comments

Leave a Reply