apple-news
apple-news copied to clipboard
Feature request: get API credentials from environment
API key, secret, and channel should be able to be defined in environment variables. The settings page should then disable the inputs if the env vars exist and display a message explaining why.
Currently, I'm doing something like this to load my API credentials from the env. There is an undesirable side effect where the credentials are also saved in the database.
function getCredentials()
{
return [
'api_key' => getenv('APPLE_NEWS_API_KEY'),
'api_secret' => getenv('APPLE_NEWS_API_SECRET'),
'api_channel' => getenv('APPLE_NEWS_API_CHANNEL'),
];
}
function mergeCredentials( array $data )
{
return array_merge( $data, getCredentials() );
}
add_filter('default_option_apple_news_settings', 'getCredentials', 10, 0);
add_filter('option_apple_news_settings', 'mergeCredentials', 10, 1);