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

block editor - Deactivate Gutenberg tips forever - not Gutenberg

programmeradmin2浏览0评论

I like Gutenberg a lot, however, the tips at the beginning of each page load drives me mad. I would like to disable the nagging tips forever and ever via code.

Please don't post "Disable Gutenberg" plugin, I've already seen that. I want to do it via a couple of lines of code in my theme.

There must be a hook, but I couldn't find it. Thanks for a hint.

I like Gutenberg a lot, however, the tips at the beginning of each page load drives me mad. I would like to disable the nagging tips forever and ever via code.

Please don't post "Disable Gutenberg" plugin, I've already seen that. I want to do it via a couple of lines of code in my theme.

There must be a hook, but I couldn't find it. Thanks for a hint.

Share Improve this question edited Apr 17, 2019 at 9:58 Glorfindel 6093 gold badges10 silver badges18 bronze badges asked Apr 17, 2019 at 6:34 user3135691user3135691 1,0359 silver badges15 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 13

Update #1:

After asking from @leymannx I checked how these settings are stored. It turned out that settings are not permanent, they are saved in the browser as localStorage.

key: WP_DATA_USER_{id}:
value: {
    "core/nux":{
        "preferences":{
            "areTipsEnabled":false,
            "dismissedTips":{}
        }
    },
    //"core/edit-post"
    //...

Update #2:

Gutenberg tips can be disabled by using dispatch('core/nux').disableTips() (NUX package) and action hook enqueue_block_editor_assets.

file functions.php:

function se334561_editor_tips() {

    wp_enqueue_script(
        'se334561-js',
        // --- to use in plugin ---
        // plugins_url('/disable-tips.js', __FILE__),
        get_stylesheet_directory_uri() . '/disable-tips.js',
        array('wp-blocks')
    );
}
add_action('enqueue_block_editor_assets', 'se334561_editor_tips');

file disable-tips.js:

jQuery(document).ready(function(){
    var isVisible = wp.data.select('core/nux').areTipsEnabled()
    if (isVisible) {
        wp.data.dispatch('core/nux').disableTips();
    }
});

As @nmr found out this seems to be stored browser-wise only. Though I found a workaround to simply hide it via CSS. Quick and dirty.

functions.php:

// Add backend styles for Gutenberg.
add_action('enqueue_block_editor_assets', 'gutenberg_editor_assets');

function gutenberg_editor_assets() {
  // Load the theme styles within Gutenberg.
  wp_enqueue_style('my-gutenberg-editor-styles', get_theme_file_uri('/assets/gutenberg-editor-styles.css'), FALSE);
}

assets/gutenberg-editor-styles.css:

ponents-popover.nux-dot-tip {
  display: none !important;
}

Source: Creating theme editor styles for Gutenberg

Small plugin that should fix it: https://wordpress/plugins/disable-welcome-messages-and-tips/

The relevant part of the code is:

<style>
    /* disable tips */
    .wp-admin ponents-popover.nux-dot-tip {
        display: none !important;
    }
</style>

<script>
    /* disable welcome message */
    window.onload = function(){
        wp.data && wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) && wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' );
    };
</script>
发布评论

评论列表(0)

  1. 暂无评论