是的,虽然有点complicated by this bug, 我在上面讨论过this post (原件:http://stephenharris.info/deactivate-other-plug-ins-on-deactivation/) 它们实际上处理停用,而不是激活,但原理是一样的。
在撰写本文时trac ticket 已提交3.7的修补程序
当激活“A”时,应激活“B”:
//This all goes inside Plugin A.
//When A is activated. Activate B.
register_activation_hook(__FILE__,\'my_plugin_A_activate\');
function my_plugin_A_activate(){
$dependent = \'B/B.php\';
if( !is_plugin_active( $dependent ) ){
add_action(\'update_option_active_plugins\', \'my_activate_dependent_B\');
}
}
function my_activate_dependent_B(){
$dependent = \'B/B.php\';
activate_plugins( $dependent );
}