• Resolved Joe Siegler

    (@joe-siegler)


    It’s a simple question. When I’m in the dashboard (or any part of my WP site back end), there’s an option to “delete cache” in the top most menu – it’s persistent across all pages. Today I accidentally clicked that and nuked my cache.

    I really didn’t want to do that, as I had over 1,000 pages cached in there.

    It got me to look around and I couldn’t find a way to disable that in the menu. So basically, how can I get that out of there? I’ve never once intentionally used that button, and I’d really like to remove it to prevent that from happening.

    How can that be done? Tkx.

    • This topic was modified 1 year, 8 months ago by Joe Siegler.
Viewing 7 replies - 1 through 7 (of 7 total)
  • It’s not possible to remove that button, but you can hide it with this small amount of CSS:

    #wp-admin-bar-delete-cache {
    	display: none;
    }
    Thread Starter Joe Siegler

    (@joe-siegler)

    At the risk of sounding stupid, is there anything special I need to do? I added that into the css file for my active theme, but the button persists.

    Also, any chance that can be added to the plugin with an off switch?

    Ah, did you clear the cache, or disable caching for logged in users after adding that CSS? I added it to the stylesheet of my own blog and it disappeared.

    Ah, I just realised there’s another way. Define the constant “WPSCDISABLEDELETEBUTTON” and the button won’t be shown at all.

    You could create an mu-plugin and add this code which will work:

    <?php
    if ( ! defined( 'WPSCDISABLEDELETEBUTTON' ) ) {
        define( 'WPSCDISABLEDELETEBUTTON', 1 );
    }

    That shortcircuits the code and stops the button loading.

    Thread Starter Joe Siegler

    (@joe-siegler)

    Caching is disabled for logged in users all the time anyway, so that’s not an issue.

    And this bit I don’t understand what you told me..

    “Define the constant “WPSCDISABLEDELETEBUTTON””

    Seems easier to have a built in off button. ??

    Thread Starter Joe Siegler

    (@joe-siegler)

    Additional. Your CSS from the first reply seems to work when I’m on the front end, but when I’m in WordPress’ back end the button is still there. Any ideas there?

    The “WPSCDISABLEDELETEBUTTON” constant will remove it from the backend too. Give it a go.

    Create a file called wp-content/mu-content/delete-button.php and put the code I suggested above into it. Save it and if you did it correctly, the delete button will be gone everywhere.

    <?php
    if ( ! defined( 'WPSCDISABLEDELETEBUTTON' ) ) {
        define( 'WPSCDISABLEDELETEBUTTON', 1 );
    }

    Thread Starter Joe Siegler

    (@joe-siegler)

    Put that quoted code in here:

    /redacted/public_html/wp-content/mu-content/delete-button.php
    permissions: -rw-r–r–

    (I do not have my wordpress install in /wordpress, it’s in root)

    Delete Cache button remains on the top in the WordPress backend.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Can the “Delete Cache” button in header be removed?’ is closed to new replies.