How to keep the menu visible in the WordPress editor

For some reason, the default WordPress editing experience hides the dashboard menu. This can be confusing for beginners (“How do I exit the editor?”) and annoying for power users (“Why so many clicks to get to where I want to go?”).

Yes, there is a user-configurable option for whether or not to show the dashboard menu in the editor. However, I don’t expect a beginner to know about that setting (and even if they did, could they find it?). I want the menu to be displayed for all users at all times. Here’s the code to make that happen:

/**
 * Disable Fullscreen Gutenberg.
 */
function prefix_disable_fullscreen_by_default() {
	$script = "window.onload = 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', 'prefix_disable_fullscreen_by_default' );
Posted in ,

Leave a Comment

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