Created
October 13, 2015 14:28
-
-
Save dwickstrom/93b3fb94c78e5c682b42 to your computer and use it in GitHub Desktop.
WordPress getenv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get option value, unless we are in debug mode && that key is set in the environment | |
*/ | |
function get_environment_variable($varname) { | |
if (!is_string($varname)) throw new Exception('Strings only.'); | |
if (getenv('WP_DEBUG')) { | |
return (getenv(strtoupper($varname))) ? : get_option($varname); | |
} | |
return get_option($varname); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment