How to delete the Hello Dolly plugin automatically?

I’m planing to create a plugin called Goodbye Dolly. Once installed, it will take care for the installation to remove the auto-installing Hello Dolly (WordPress Plugin) shipping with wordpress.

This is due to popular request. Some folks have asked for it.

I like the idea. I never cared so far because I removed it manually. But I like the idea to save the hassles and have this removal automated for the future.

I wanted to just delete the file when it exists basically. But I’m unsure a bit about file system abstraction. And I would like to do this on install / update already, so this does not needs to be checked for all the time.

So which hooks are to be considered? Any best practice ideas?

Update:

  • Homepage: http://hakre.wordpress.com/plugins/goodbye-dolly/
  • Repository: http://wordpress.org/extend/plugins/goodbye-dolly/

3 s
3

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