You can use this code fragment in the plugin init action
if ( defined(‘WP_CLI’) ) {
return;
}
and we can define WP_CLI in config file and resolve notice
Or like this code, you can find a better way. Thank you!
Please replace $_SERVER[‘HTTP_HOST’] with
global $wp;
$http_host = home_url( $wp->request );
I will replace in the next update
Also, I am not sure why it was causing a crashing error. It should have caused a warning
Thank you very much,
You are completely right, it generates warning message, but we are monitoring our logs, so, it’s annoying to see them every time.
I agree that using $wp->request will stop generating warning, however, I assume that it will be better to not run part of codes in WP CLI, if they are address to end user (i.e. cart, product single page etc).
Anyway, you know better than me, so, just to have that warning fixed will be huge improvment for us.
I have removed all references to $_SERVER[‘HTTP_HOST’].