I have a unique plugin whose purpose is to set up a new WordPress site with a theme, default widgets, default plugins, custom menus, pages, posts, etc.
The plugin does everything it needs to do when activated and never runs again.
I’m looking for suggestions on how I might, as the last step in the activation routine, deactivate and delete the plugin.
Any help, suggestions, or example references appreciated.
You can deactivate it with:
I don’t think you can delete it. It would be a big security risk, IMO. But if the folder has the correct (but insecure) permissions, you could use the PHP function rmdir
You can use WordPress’s “filesystem api” for deleting files, same as wp core can. It’s a neat little system that asks politely for ftp user credentials if it doesn’t have permission to do it itself transparently. (I don’t think it’s really a security issue, since wordpress has install, auto update, and removal of plugins capabilities out of the box.)