好的,我一直在寻找解决方案。出于某些不明智的原因,我无法找到正确的解决办法,我真的不明白出了什么问题。
我正在尝试使用register_activation_hook和register_deactivation_hook。这是我的代码。
register_activation_hook(__FILE__, 'plugin_on' );
register_deactivation_hook(__FILE__, 'plugin_off' );
function plugin_on() {
$file = 'people.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current .= "1\n";
// Write the contents back to the file
file_put_contents($file, $current);
wp_schedule_event( time(), 'minutely', 'my_daily_event' );
}
add_action( 'my_daily_event', 'mail_test' );
function plugin_off() {
wp_clear_scheduled_hook('my_daily_event');
}
永远不会调用plugin_on。
以下是我已经尝试的一些事情,或者我知道的事情不是问题。
__FILE__
路径是正确的。它指向此文件,这是主插件文件。非常感谢任何帮助。