Closed pgraham3 closed 3 years ago
Hi @pgraham3,
I've been wanting something similar. With today's announcement of Sandbox mode it becomes even more useful. I'd be happy to work on a PR for this. I was thinking of an approach like this:
https://wpmailsmtp.com/docs/how-to-secure-smtp-settings-by-using-constants/
Basically check for the existence of constants in wp-config.php
and do an array_merge()
on them inside of load_settings
with the constants overriding anything coming from get_option()
. If the setting is detected in a constant, make the field in the dash board read-only. Keep the original value in options
to fall back to if the constants are removed from wp-config.php
. This would allow you to place Sandbox keys in wp-config.php
for local/staging environments.
A downside to this approach is It wouldn't use the WordPress environment setting. If that was to be used then you would need to store two sets of settings, one for Sandbox and one for Production. I'd be happy to look at a PR taking that route too.
Both of those things could be implemented as well... Check for sandbox and production constants in wp-config.php
and override anything coming from your stored settings.
@tflight I like this idea/approach as well! Thanks for the offer to work on a PR for it. Happy to review it when it is ready.
Great, I'll get a PR soon. It looks like this repo is a version behind what is in the Plugins directory, so maybe you can get this repo up to date first?
All set! Should have parity with the WordPress repo's trunk now.
Been looking for a solution like this for a LONG time. We are a web hosting agency and having this functionality would allow us to ditch SendGrid and move to Postmark for our outbound transactional notifications from WordPress. It would be great if there was a way to have an environmental var that could completely hide the plugin. Customers do dumb things. :)
Glad to help test this out!
Potentially related to https://github.com/wildbit/postmark-wordpress/issues/69