Categories

Deprecated: category_link is deprecated since version 2.5.0! Use term_link instead. in /home/jeanbaptr/www/2019/wp-includes/functions.php on line 5091

Deprecated: category_link is deprecated since version 2.5.0! Use term_link instead. in /home/jeanbaptr/www/2019/wp-includes/functions.php on line 5091
Development WordPress

Disable Block Editor default FullScreen mode in WordPress 5.4

Scheduled for March 31, 2020, WordPress 5.4 will enable FullScreen mode by default in the Block Editor / Gutenberg.

Even if I’m fully involved in WordPress version 5.4 –as a member of the release squad– I have to admit I’m not super comfortable with the editor in fullscreen mode by default. Indeed, I prefer to always keep a direct access to WP-Admin main menu.

To keep fullscreen mode disabled by default, the following snippet can be used in your (child) theme’s functions.php file:

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' );

That’s all! 😎

Worth noting you can add this snippet in your code now. It won’t break your website and it will prevent switching to fullscreen once your website is updated to WP 5.4.

For reference, see this change’s announcement on the related dev note on Make/Core:

Leave a Reply

Your email address will not be published. Required fields are marked *