wordpress cli script and plugin functions availibility

∥☆過路亽.° 提交于 2019-12-14 00:55:04

问题


I have a maintenance script for a Wordpress install that I run through the command line, after initializing my wp enviroment thus:

 define( 'WP_USE_THEMES', FALSE );
$_SERVER = [
"HTTP_HOST"      => "example.com",
"SERVER_NAME"    => "example.com",
"REQUEST_URI"    => "/",
"REQUEST_METHOD" => "GET"
];

require( 'wordpress/wp-load.php' );

Later down the road I'll send e-mail notifications using wp_mail. The thing is, I'm using a plugin that would normally override the default wp_mail for its own, since it's using an external service to handle emails.

The plugin works perfectly when used in regular WP, but when using it through my cli script, the default wp_mail defined in wp-includes/pluggable will be run, instead of the plugin defined one.

Are plugins not loaded when loading the wp environment this way? Is there a way to load them?

I also tried using wp-cli eval-file method, but I've got the same result.

来源:https://stackoverflow.com/questions/28817192/wordpress-cli-script-and-plugin-functions-availibility

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!