Skip to content

Instantly share code, notes, and snippets.

@kebbet
Created March 16, 2021 10:45
Show Gist options
  • Save kebbet/3a076930706ee482314c0b3669a18787 to your computer and use it in GitHub Desktop.
Save kebbet/3a076930706ee482314c0b3669a18787 to your computer and use it in GitHub Desktop.
WordPress - Disable fullscreen editor
<?php
/**
* Disable full screen Gutenberg by default.
*
* @source https://jeanbaptisteaudras.com/en/2020/03/disable-block-editor-default-fullscreen-mode-in-wordpress-5-4/
*/
function kebbet_disable_editor_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', 'kebbet_disable_editor_fullscreen_by_default' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment