Skip to content

Instantly share code, notes, and snippets.

@pbrocks
Created April 1, 2020 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbrocks/7b954e3f9ce482672e04328d05992908 to your computer and use it in GitHub Desktop.
Save pbrocks/7b954e3f9ce482672e04328d05992908 to your computer and use it in GitHub Desktop.
Jean-Baptiste Audras -- Disable editor in fullscreen mode by default.
<?php
/**
* https://jeanbaptisteaudras.com/en/2020/03/disable-block-editor-default-fullscreen-mode-in-wordpress-5-4/
*/
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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment