我很难弄清楚如何在我的插件类中使用wp_mail()。我一直在读几篇文章,但仍然无法弄清楚我做错了什么。
add_action( 'plugins_loaded', array ( 'MY_class', 'init' ), 99 );
require_once dirname( __FILE__ ) . '/class.extended.php';
class MY_class extends Extended{
public function init(){
$class = __CLASS__;
new $class;
}
public function__construct(){
//my codes what are firing the plugin
}
}
主要课程
class Extended{
public function init(){
$class = __CLASS__;
new $class;
}
public function __construct(){
//my codes
}
public function send_email($to, $message){
var_dump($message);
$subject = 'test';
$message = 'this is a test from send invitation';
$to = 'test@gmail.com';
wp_mail( $to, $subject, $message, $headers, $attachments );
}
}
所以实际上可以加载插件,但是当我发送电子邮件时,我得到Fatal error: Call to undefined function wp_mail()