最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

block editor - Set fullscreen mode by default

programmeradmin5浏览0评论

The block editor has a Fullscreen mode which you can access via the tools options on the top-right:

Is there a PHP approach to enable the Fullscreen mode by default? As in, force this mode for all users. Alternatively, a javascript solution.

The block editor has a Fullscreen mode which you can access via the tools options on the top-right:

Is there a PHP approach to enable the Fullscreen mode by default? As in, force this mode for all users. Alternatively, a javascript solution.

Share Improve this question asked May 7, 2019 at 13:14 Christine CooperChristine Cooper 8,8877 gold badges60 silver badges93 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 8

Switching Gutenberg to fullscreen mode requires setting to TRUE fullscreenMode from the core/edit-post package. To enqueue appropriate script, you use enqueue_block_editor_assets action hook.

function se337302_fullscreen_editor()
{
    $js_code = "jQuery(document).ready(function(){" .
            "   var 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', $js_code );

}
add_action( 'enqueue_block_editor_assets', 'se337302_fullscreen_editor' );
发布评论

评论列表(0)

  1. 暂无评论