Last active
November 24, 2020 18:10
-
-
Save timotheemoulin/697f0b188168534ba000fcfbc981f127 to your computer and use it in GitHub Desktop.
Gutenberg disable fullscreen as the default editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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