rollbar / rollbar-php-wordpress

Official WordPress plugin from Rollbar, Inc.
https://rollbar.com/
GNU General Public License v2.0
15 stars 20 forks source link

Also use the WP_ENV constant #108

Closed Brugman closed 2 years ago

Brugman commented 2 years ago

Hiya. I'm a new customer. You've got a few PRs incoming based on my first impressions. If these are welcome I'd love to write more.

Description of the change

In my experience WP_ENV is more often used as a constant than an environment variable. I don't want to get rid of the environment variable, but if it doesn't exist can we check the constant?

Fixes #68

Type of change

Related issues

None.

Checklists

I'm not yet familiar with testing, I did test manually of course, and I'm on Windows. I hope you'll take this without testing, or can run tests on my behalf.

Brugman commented 2 years ago

There's a bunch of duplicate code in this PR. I couldn't find any example of reusable code in the plugin that I could mimic so I did it like this on purpose. Feel free to modify it.

Brugman commented 2 years ago

A public static function it will be.

Renamed the method to getEnvironment() to avoid confusion/conflict with PHP's native getenv().

Manually tested, all 3 locations work well.