wordpress cli script and plugin functions availibi

2019-06-27 02:13发布

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.

0条回答
登录 后发表回答