How to delete the Hello Dolly plugin automatically?

While I appreciate the idea, isn’t this just replacing one plugin with another? Rarst’s link already has the answer — it just needs to be reworked a bit to check for the plugin periodically, like so:

function goodbye_dolly() {
    if (file_exists(WP_PLUGIN_DIR.'/hello.php')) {
        require_once(ABSPATH.'wp-admin/includes/plugin.php');
        require_once(ABSPATH.'wp-admin/includes/file.php');
        delete_plugins(array('hello.php'));
    }
}

add_action('admin_init','goodbye_dolly');

Slap that into your functions.php file (in a child theme if you aren’t already using a custom theme) and you should be good to go.

Leave a Comment