Coder Social home page Coder Social logo

automattic / jetpack-plugin-deactivation Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 81 KB

[READ ONLY] Intercept the plugin deactivation with a dialog. This repository a mirror, for issue tracking and development head to: https://github.com/automattic/jetpack

License: Other

PHP 100.00%

jetpack-plugin-deactivation's Introduction

plugin-deactivation

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 );
} );
Parameter Description
$plugin_slug Slug of the plugin, e.g. jetpack, jetpack-boost.
$dialog_view_file_path The path to a PHP file that contains the markup for your dialog. Copy src/dialog-template.php to your plugin, customize it, and pass its path as the $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 dialog
  • hideDialog() - Close the deactivation dialog
  • deactivate() - 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)

jetpack-plugin-deactivation's People

Contributors

adimoldovan avatar anomiex avatar bindlegirl avatar coder-karen avatar dhasilva avatar dilirity avatar gogdzl avatar haqadn avatar ice9js avatar jeherve avatar kraftbj avatar lhkowalski avatar nateweller avatar nunyvega avatar ouikhuan avatar paulopmt1 avatar psealock avatar samiff avatar sdixon194 avatar simison avatar tbradsha avatar thingalon avatar vedanshujain avatar yansern avatar zinigor avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.