Skip to content

Commit

Permalink
Fix WP_CLI error
Browse files Browse the repository at this point in the history
  • Loading branch information
Jazz-Man committed May 18, 2020
1 parent 0bbd67d commit a3c432e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion config/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/
Config::define('WP_HOME', env('WP_HOME'));
Config::define('WP_SITEURL', env('WP_SITEURL'));

$current_server = parse_url(env('WP_HOME'));
/**
* Custom Content Directory
*/
Expand Down Expand Up @@ -84,6 +84,17 @@
Config::define('LOGGED_IN_SALT', env('LOGGED_IN_SALT'));
Config::define('NONCE_SALT', env('NONCE_SALT'));

// Fix WP_CLI error
if (defined('WP_CLI') && WP_CLI) {
$server_port = !empty($current_server['port']) ? $current_server['port'] : false;
$is_https = !empty($current_server['scheme']) && 'https' === $current_server['scheme'] ? 'on' : false;

$_SERVER['HTTP_HOST'] = $current_server['host'];
$_SERVER['SERVER_NAME'] = $current_server['host'];
$_SERVER['HTTPS'] = $is_https;
$_SERVER['SERVER_PORT'] = $server_port;
}

/**
* Custom Settings
*/
Expand All @@ -109,6 +120,8 @@
$_SERVER['HTTPS'] = 'on';
}



$env_config = __DIR__ . '/environments/' . WP_ENV . '.php';

if (file_exists($env_config)) {
Expand Down

0 comments on commit a3c432e

Please sign in to comment.