Skip to content

Instantly share code, notes, and snippets.

@dwickstrom
Created October 13, 2015 14:28
Show Gist options
  • Save dwickstrom/93b3fb94c78e5c682b42 to your computer and use it in GitHub Desktop.
Save dwickstrom/93b3fb94c78e5c682b42 to your computer and use it in GitHub Desktop.
WordPress getenv
<?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