diff --git a/README.md b/README.md index 01b0867..1680a9a 100755 --- a/README.md +++ b/README.md @@ -92,6 +92,9 @@ The plugin supports using the `wp_mail_from_name` filter for manually setting a [Can I use the Postmark for WordPress plugin with Divi contact forms?](https://postmarkapp.com/support/article/1128-can-i-use-the-postmark-for-wordpress-plugin-with-divi-contact-forms) ## Changelog +### v1.14.0 +* Adds ability to override settings for environment specific Postmark plugin settings. + ### v1.13.7 * Fix limit of 500 sending logs deleted per day. diff --git a/page-settings.php b/page-settings.php index 57e1127..6c3b3bd 100644 --- a/page-settings.php +++ b/page-settings.php @@ -42,6 +42,18 @@ + overridden_settings['api_key'] ) ) : ?> +
POSTMARK_API_KEY is defined in your wp-config.php and overrides the API Key set here.
+ + + overridden_settings['stream_name'] ) ) : ?> +
POSTMARK_STREAM_NAME is defined in your wp-config.php and overrides the Message Stream set here.
+ + + overridden_settings['sender_address'] ) ) : ?> +
POSTMARK_SENDER_ADDRESS is defined in your wp-config.php and overrides the Sender Email set here.
+ +
diff --git a/postmark-settings.php b/postmark-settings.php new file mode 100644 index 0000000..20512a4 --- /dev/null +++ b/postmark-settings.php @@ -0,0 +1,19 @@ + defined( 'POSTMARK_API_KEY' ) ? POSTMARK_API_KEY : null, + 'stream_name' => defined( 'POSTMARK_STREAM_NAME' ) ? POSTMARK_STREAM_NAME : null, + 'sender_address' => defined( 'POSTMARK_SENDER_ADDRESS' ) ? POSTMARK_SENDER_ADDRESS : null, +); +$settings_from_constants = array_filter( $settings_from_constants ); +$settings = array_merge( $settings, $settings_from_constants ); +return array( + 'settings' => $settings, + 'settings_from_constants' => $settings_from_constants, +); diff --git a/postmark.php b/postmark.php index 1a39e77..2762988 100644 --- a/postmark.php +++ b/postmark.php @@ -3,7 +3,7 @@ * Plugin Name: Postmark (Official) * Plugin URI: https://postmarkapp.com/ * Description: Overrides wp_mail to send emails through Postmark - * Version: 1.13.7 + * Version: 1.14.0 * Author: Andrew Yates & Matt Gibbs */ @@ -19,6 +19,13 @@ class Postmark_Mail { */ public $settings; + /** + * Overridden Settings. + * + * @var array + */ + public $overridden_settings; + /** * Last Error. * @@ -31,7 +38,7 @@ class Postmark_Mail { */ public function __construct() { if ( ! defined( 'POSTMARK_VERSION' ) ) { - define( 'POSTMARK_VERSION', '1.13.7' ); + define( 'POSTMARK_VERSION', '1.14.0' ); } if ( ! defined( 'POSTMARK_DIR' ) ) { @@ -45,6 +52,8 @@ public function __construct() { add_filter( 'init', array( $this, 'init' ) ); $this->settings = $this->load_settings(); + $this->overridden_settings = include POSTMARK_DIR . '/postmark-settings.php'; + $this->overridden_settings = $this->overridden_settings['settings_from_constants']; } /** diff --git a/readme.txt b/readme.txt index bb87bad..99f18ca 100644 --- a/readme.txt +++ b/readme.txt @@ -59,11 +59,22 @@ Because we've been in this business for many years. We’ve been running an emai Most importantly, a great product requires great support and even better education. Our team is spread out across six time zones to offer fast support on everything from using Postmark to best practices on content and user engagement. A solid infrastructure only goes so far, that’s why improving our customer’s sending practices helps achieve incredible results - = Why aren't my HTML emails being sent? = This plugin detects HTML by checking the headers sent by other WordPress plugins. If a "text/html" content type isn't set then this plugin won't send the HTML to Postmark to be sent out only the plain text version of the email. += How do I set environment specific Postmark plugin settings? + +You can optionally set the Postmark API Token, message stream, and default sending address by adding the following to your `wp-config.php` file: + +``` +define( 'POSTMARK_API_KEY', '' ); +define( 'POSTMARK_STREAM_NAME', 'stream-name' ); +define( 'POSTMARK_SENDER_ADDRESS', 'from@example.com' ); +``` + +Setting any of these here will override what is set via the plugin's UI. + = Why are password reset links not showing in emails sent with this plugin? = There are a couple ways to resolve this issue. @@ -103,6 +114,9 @@ The plugin supports using the `wp_mail_from_name` filter for manually setting a 1. Postmark WP Plugin Settings screen. == Changelog == += v1.14.0 = +* Adds ability to override settings for environment specific Postmark plugin settings. + = v1.13.7 = * Fix limit of 500 sending logs deleted per day. diff --git a/wp-mail.php b/wp-mail.php index b4fb885..5fdbb9c 100644 --- a/wp-mail.php +++ b/wp-mail.php @@ -52,7 +52,8 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() // Compact the input, apply the filters, and extract them back out. extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) ); - $settings = json_decode( get_option( 'postmark_settings' ), true ); + $settings = include POSTMARK_DIR . '/postmark-settings.php'; + $settings = $settings['settings']; if ( ! is_array( $attachments ) ) { $attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) );