11

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.

enter image description here

10

enter image description here

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();
    }
});
  • Is this globally for every user? Is there a way to configure this per code as well? So that when I ship a plugin to a client it deactivates the tips when this plugin gets activated? – leymannx Apr 17 at 7:01
  • 1
    If it’s an option able checkbox in the admin area they’ll be away to toggle it for all as the values got to be stored somewhere you should in code be able to set that value for all users on init or something, try to find where it stores that value in the DB – Daniel Vickers Apr 17 at 7:40
  • 1
    @leymannx This would require additional code (js + php) which, after changing areTipsEnabled, writes the state to DB and restores it when the user logs in. – nmr Apr 17 at 7:50
  • 1
    That is awesome, I'll try it out tomorrow and check the answer if it works. Thank you! – user3135691 Apr 17 at 21:21
  • 1
    @user3135691 In plugin file replace get_stylesheet_directory_uri() . '/disable-tips.js' with plugins_url('/disable-tips.js', __FILE__). – nmr Apr 18 at 9:08
2

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:

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

Source: Creating theme editor styles for Gutenberg

  • Yes, this solution also came to my mind but as you have said: it's quick 'n dirty. Thank you for your help. – user3135691 Apr 17 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.