Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function instance()

public function environment()
{
return getenv('WP_ENV') ?: null;
return \Rollbar\Wordpress\Plugin::getEnvironment();
}

public function root()
Expand Down
7 changes: 6 additions & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

Expand Down
4 changes: 3 additions & 1 deletion src/UI.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,10 @@ public static function status($settings)

public static function environmentSettingNote()
{
$env = \Rollbar\Wordpress\Plugin::getEnvironment();

$output =
'<p><code>WP_ENV</code> environment variable: <code> ' . getenv('WP_ENV') . ' </code></p>' .
'<p><code>WP_ENV</code> environment variable: <code>' . $env . '</code></p>' .
'<p><small><strong>Rollbar for Wordpress honors the WP_ENV environment variable.</strong> ' .
'If the <code>environment</code> setting is not specified here, it will take ' .
'precendence over the default value.</strong></small></p>';
Expand Down