Skip to content

Instantly share code, notes, and snippets.

@timotheemoulin
Last active November 24, 2020 18:10
Show Gist options
  • Save timotheemoulin/697f0b188168534ba000fcfbc981f127 to your computer and use it in GitHub Desktop.
Save timotheemoulin/697f0b188168534ba000fcfbc981f127 to your computer and use it in GitHub Desktop.
Gutenberg disable fullscreen as the default editor
/**
* This checks if the fullscreen mode is "on" on page load and toggle it off.
*/
(function (wp) {
const isFullscreenMode = wp.data.select('core/edit-post').isFeatureActive('fullscreenMode');
if (isFullscreenMode) {
wp.data.dispatch('core/edit-post').toggleFeature('fullscreenMode');
}
})(window.wp);
<?php
/**
* Toggle off the fullscreen when editing a post. This can be toggled on later.
*/
public function tim_disable_default_fullscreen_editor()
{
// enqueue script with 'wp-blocks' will ensure that the blocks are loaded before calling the script
wp_enqueue_script('tim-disable-fullscreen', stylesheet_directory_uri().'js/disable-fullscreen.js', ['wp-blocks']);
}
// this hook is callon only when you are using Gutenberg editor (no other admin page)
add_action('enqueue_block_editor_assets', 'tim_disable_default_fullscreen_editor');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment