Skip to content

Commit 1d592cc

Browse files
authored
Merge pull request #108 from Brugman/feature/also-use-constant
Also use the WP_ENV constant
2 parents 4837aa9 + 7f23189 commit 1d592cc

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/Defaults.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static function instance()
1919

2020
public function environment()
2121
{
22-
return getenv('WP_ENV') ?: null;
22+
return \Rollbar\Wordpress\Plugin::getEnvironment();
2323
}
2424

2525
public function root()

src/Plugin.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public function configure(array $config) {
5252
private function initSettings() {
5353
Settings::init();
5454
}
55+
56+
public static function getEnvironment()
57+
{
58+
return ( getenv('WP_ENV') ?: ( defined( 'WP_ENV' ) ? WP_ENV : null ) );
59+
}
5560

5661
/**
5762
* Fetch settings provided in Admin -> Tools -> Rollbar
@@ -68,7 +73,7 @@ private function fetchSettings() {
6873

6974
if (!isset($options['environment']) || empty($options['environment'])) {
7075

71-
if ($wpEnv = getenv('WP_ENV')) {
76+
if ($wpEnv = $this->getEnvironment()) {
7277
$options['environment'] = $wpEnv;
7378
}
7479

src/UI.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,10 @@ public static function status($settings)
220220

221221
public static function environmentSettingNote()
222222
{
223+
$env = \Rollbar\Wordpress\Plugin::getEnvironment();
224+
223225
$output =
224-
'<p><code>WP_ENV</code> environment variable: <code> ' . getenv('WP_ENV') . ' </code></p>' .
226+
'<p><code>WP_ENV</code> environment variable: <code>' . $env . '</code></p>' .
225227
'<p><small><strong>Rollbar for Wordpress honors the WP_ENV environment variable.</strong> ' .
226228
'If the <code>environment</code> setting is not specified here, it will take ' .
227229
'precendence over the default value.</strong></small></p>';

0 commit comments

Comments
 (0)