定制 automattic/jetpack-plugin-deactivation 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

automattic/jetpack-plugin-deactivation

最新稳定版本:v0.3.26

Composer 安装命令:

composer require automattic/jetpack-plugin-deactivation

包简介

Ask for feedback while deactivating a plugin

README 文档

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 );
} );
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)

统计信息

  • 总下载量: 4.27k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2022-11-21