diff --git a/src/Defaults.php b/src/Defaults.php index ef05906a..df8a2ede 100644 --- a/src/Defaults.php +++ b/src/Defaults.php @@ -19,7 +19,7 @@ public static function instance() public function environment() { - return getenv('WP_ENV') ?: null; + return \Rollbar\Wordpress\Plugin::getEnvironment(); } public function root() diff --git a/src/Plugin.php b/src/Plugin.php index b26e0559..e4406426 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -52,6 +52,11 @@ public function configure(array $config) { private function initSettings() { Settings::init(); } + + public static function getEnvironment() + { + return ( getenv('WP_ENV') ?: ( defined( 'WP_ENV' ) ? WP_ENV : null ) ); + } /** * Fetch settings provided in Admin -> Tools -> Rollbar @@ -68,7 +73,7 @@ private function fetchSettings() { if (!isset($options['environment']) || empty($options['environment'])) { - if ($wpEnv = getenv('WP_ENV')) { + if ($wpEnv = $this->getEnvironment()) { $options['environment'] = $wpEnv; } diff --git a/src/UI.php b/src/UI.php index 1cc1cae2..e0ba84aa 100644 --- a/src/UI.php +++ b/src/UI.php @@ -220,8 +220,10 @@ public static function status($settings) public static function environmentSettingNote() { + $env = \Rollbar\Wordpress\Plugin::getEnvironment(); + $output = - '
WP_ENV
environment variable: ' . getenv('WP_ENV') . '
WP_ENV
environment variable: ' . $env . '
Rollbar for Wordpress honors the WP_ENV environment variable. ' .
'If the environment
setting is not specified here, it will take ' .
'precendence over the default value.