admin管理员组文章数量:1023230
I'm trying to build a child plugin which needs another parent plugin to work correctly. I've managed it so far, that the child plugin can't be activated when the parent plugin isn't installed or activated.
Now I'm working on the point that the child plugin is deactivated on the moment when the parent plugin is deactivated. I'm trying to hook in on the
add_action('deactivated_plugin', 'functionxxx')
But it look's like, when doing some dump and die in the core WordPress files, that at first it deactivated my child plugin and then tries to deactivate the parent plugin. But when it deactivates the parent plugin, I can see my child-plugin in the list with activated plugins.
My code so far:
Plugin base file:
<?php
/*
Plugin Name: xxx
Plugin URI:
Description:
Version:
Author:
Author URI:
*/
require_once __DIR__ . '/vendor/autoload.php';
new Test();
Test Class
<?php
class Test
{
public function __construct()
{
add_action('deactivated_plugin', [$this, 'detectPluginDeactivation'])
}
public function detectPluginDeactivation($plugin): void
{
if ($plugin === 'xxx') {
deactivate_plugins(plugin_basename(plugin_base_file));
}
}
}
I'm trying to build a child plugin which needs another parent plugin to work correctly. I've managed it so far, that the child plugin can't be activated when the parent plugin isn't installed or activated.
Now I'm working on the point that the child plugin is deactivated on the moment when the parent plugin is deactivated. I'm trying to hook in on the
add_action('deactivated_plugin', 'functionxxx')
But it look's like, when doing some dump and die in the core WordPress files, that at first it deactivated my child plugin and then tries to deactivate the parent plugin. But when it deactivates the parent plugin, I can see my child-plugin in the list with activated plugins.
My code so far:
Plugin base file:
<?php
/*
Plugin Name: xxx
Plugin URI:
Description:
Version:
Author:
Author URI:
*/
require_once __DIR__ . '/vendor/autoload.php';
new Test();
Test Class
<?php
class Test
{
public function __construct()
{
add_action('deactivated_plugin', [$this, 'detectPluginDeactivation'])
}
public function detectPluginDeactivation($plugin): void
{
if ($plugin === 'xxx') {
deactivate_plugins(plugin_basename(plugin_base_file));
}
}
}
本文标签: Deactivate subplugin when parentplugin is deactivated
版权声明:本文标题:Deactivate sub-plugin when parent-plugin is deactivated 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745597079a2158236.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论