为什么activate_plugin在register_activation_hook中不起作用
我正在尝试在激活第一个插件时自动激活第二个插件。 register_activation_hook(__FILE__, 'example_activation' ); function example_activation() { include_once(ABSPATH .'/wp-admin/includes/plugin.php'); activate_plugin('hello.php'); } 它不能在register_activation_hook内部工作。如果我直接使用它,则它的工作方式如下: include_once(ABSPATH .'/wp-admin/includes/plugin.php'); activate_plugin('hello.php'); 我该如何解决?感谢帮助 解: 我现在为自己使用它: // When this plugin activate, activate another plugin too. register_activation_hook(__FILE__, function(){ $dependent = 'hello.php'; if( is_plugin_inactive($dependent) ){ add_action('update_option_active_plugins', function($dependent){ /* for some reason, activate_plugin($dependent); is not working */ activate_plugin('hello.php'); }); } }); …