Uninstall

The uninstall logic is some logic executed when the plugin is executed.

By default, Launchpad doesn't ship with a way to execute logic on uninstall.

However, it is possible to install a module to have uninstall logic.

Install the module

To install the module wp-launchpad/uninstaller-take-offarrow-up-right you need to run the following command: composer require wp-launchpad/uninstaller-take-off.

Once the command finished being executed a new file uninstall.phparrow-up-right should have been added to your project and it is now possible to take advantage of the uninstall module.

Creating an uninstall logic

In Launchpad, to create a logic which will be executed when the plugin is uninstalled, we need to use an Uninstaller.

To create an uninstaller, any class can be used as the only requirement is to use the @uninstall annotationarrow-up-right inside the docblock of at least one of the methods:

class MyUninstaller {
    /**
    * @uninstall
    */
    public function unregister_options() {
        
    }
}

Once the uninstaller class is created, it needs to be registered on a service provider to be loaded.

For that it is important to first add the necessary logic into the providerarrow-up-right using HasUninstallerServiceProviderInterfacearrow-up-right interface and HasUninstallerServiceProviderTraitarrow-up-right trait:

It is then possible to have access to the register_uninstaller method to register our uninstallerarrow-up-right inside the define methodarrow-up-right:

Last updated