Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Settings to be Overridden by Constants #79

Merged
merged 12 commits into from
Jul 20, 2021

Conversation

tflight
Copy link
Contributor

@tflight tflight commented Jul 13, 2021

This needs review and documentation before merging.

This PR allows you to set constants in your wp-config.php file which will override, but not overwrite, any settings stored in the database (WP options). API Key, Stream Name/ID, and Sender Address are supported. Example config:

// setup Postmark constants
define('POSTMARK_API_KEY', 'xyz-123-abc');
define('POSTMARK_STREAM_NAME', null);
define('POSTMARK_SENDER_ADDRESS', '[email protected]');

An example usage would be for a developer to use settings from a Postmark Sandbox stream in their development environment that would survive database merges. See #71. This also helps address #72.

tflight added 4 commits July 13, 2021 11:38
Since both page-settings.php and wp-mail.php (class Postmark_Mail) need these settings a new file is created that will return an array of settings. The array of settings coming from the database is merged with the settings defined as constants, with constants taking priority.
In the WP Dashboard, show the user if settings have been overridden by constants, but don’t show them the actual constant values. This will somehwat obfuscate the API key from the user. (Think agencies that define constants for a client using the agencies sandboxed api key.)
@pgraham3
Copy link
Contributor

@tflight Thanks for putting this PR together! I will review it this week.

postmark-settings.php Show resolved Hide resolved
Copy link
Contributor

@pgraham3 pgraham3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @tflight! Merging this in and releasing as v1.14.0.

@pgraham3 pgraham3 merged commit 5e987dd into ActiveCampaign:master Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants