automattic / jetpack-plugin-deactivation
Ask for feedback while deactivating a plugin
Installs: 2 590
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Type:jetpack-library
Requires
- php: >=7.0
- automattic/jetpack-assets: ^2.3.5
Requires (Dev)
- automattic/jetpack-changelogger: ^4.2.6
- yoast/phpunit-polyfills: ^1.1.1
Suggests
- automattic/jetpack-autoloader: Allow for better interoperability with other plugins that use this package.
README
Intercept the plugin deactivation with a dialog
How to install plugin-deactivation
Instantiate the Deactivation_Handler
by providing the $plugin_slug
, and $dialog_view_file_path
as parameters.
add_action( 'init', function() { Automattic\Jetpack\Plugin_Deactivation\Deactivation_Handler::init( $plugin_slug, $dialog_view_file_path ); } );
Controlling the dialog
Using attribute
You can use data-jp-plugin-deactivation-action
attribute with the values close
|deactivate
on any element. Adding this attribute will observe the element and
close or deactivate the plugin based on the attribute value.
Example of a button that closes the dialog:
<button type="button" class="jp-plugin-deactivation__button" data-jp-plugin-deactivation-action="close" >Cancel</button>
Using the instance
You can access the deactivation dialog instance in window.JetpackPluginDeactivationData[<plugin slug>]
. It has access to the following methods:
showDialog()
- Open the deactivation dialoghideDialog()
- Close the deactivation dialogdeactivate()
- Deactivate the plugin and close the dialog
Using this package in your WordPress plugin
If you plan on using this package in your WordPress plugin, we would recommend that you use Jetpack Autoloader as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well.
Security
Need to report a security vulnerability? Go to https://automattic.com/security/ or directly to our security bug bounty site https://hackerone.com/automattic.
License
plugin-deactivation is licensed under GNU General Public License v2 (or later)