diff options
Diffstat (limited to 'Postman')
-rw-r--r-- | Postman/Postman-Configuration/PostmanConfigurationController.php | 20 | ||||
-rw-r--r-- | Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php | 15 | ||||
-rw-r--r-- | Postman/Postman-Configuration/postman_manual_config.js | 3 | ||||
-rw-r--r-- | Postman/Postman-Configuration/postman_wizard.js | 2 | ||||
-rw-r--r-- | Postman/Postman-Email-Log/PostmanEmailLogService.php | 2 | ||||
-rw-r--r-- | Postman/PostmanAdminController.php | 2 | ||||
-rw-r--r-- | Postman/PostmanLogFields.php | 18 | ||||
-rw-r--r-- | Postman/PostmanViewController.php | 4 |
8 files changed, 47 insertions, 19 deletions
diff --git a/Postman/Postman-Configuration/PostmanConfigurationController.php b/Postman/Postman-Configuration/PostmanConfigurationController.php index ee14ad8..59fbdb8 100644 --- a/Postman/Postman-Configuration/PostmanConfigurationController.php +++ b/Postman/Postman-Configuration/PostmanConfigurationController.php @@ -390,17 +390,19 @@ class PostmanConfigurationController { print '<section id="notifications">'; do_settings_sections( PostmanAdminController::NOTIFICATIONS_OPTIONS ); - $currentKey = $this->options->getNotificationService(); - $pushover = $currentKey == 'pushover' ? 'block' : 'none'; - $slack = $currentKey == 'slack' ? 'block' : 'none'; + $currentKey = $this->options->getNotificationService(); + $pushover = $currentKey == 'pushover' ? 'block' : 'none'; + $slack = $currentKey == 'slack' ? 'block' : 'none'; - echo '<div id="pushover_cred" style="display: ' . $pushover . ';">'; - do_settings_sections( PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED ); - echo '</div>'; + echo '<div id="pushover_cred" style="display: ' . $pushover . ';">'; + do_settings_sections( PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED ); + echo '</div>'; - echo '<div id="slack_cred" style="display: ' . $slack . ';">'; - do_settings_sections( PostmanAdminController::NOTIFICATIONS_SLACK_CRED ); - echo '</div>'; + echo '<div id="slack_cred" style="display: ' . $slack . ';">'; + do_settings_sections( PostmanAdminController::NOTIFICATIONS_SLACK_CRED ); + echo '</div>'; + + do_action( 'post_smtp_notification_settings' ); print '</section>'; diff --git a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php index 6ddebd7..705ef23 100644 --- a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php +++ b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php @@ -234,6 +234,7 @@ class PostmanSettingsRegistry { 'notification_chrome_uid_callback', ), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION ); + do_action( 'post_smtp_settings' ); } } @@ -443,12 +444,20 @@ class PostmanSettingsRegistry { public function notification_service_callback() { $inputDescription = __( 'Select the notification service you want to recieve alerts about failed emails.' ); + + $options = apply_filters('post_smtp_notification_service', array( + 'default' => __( 'WP Admin Email', 'post-smtp' ), + 'pushover' => __( 'Pushover', 'post-smtp' ), + 'slack' => __( 'Slack', 'post-smtp' ), + )); + printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_SERVICE ); $currentKey = $this->options->getNotificationService(); - $this->printSelectOption( __( 'Email', 'post-smtp' ), 'default', $currentKey ); - $this->printSelectOption( __( 'Pushover', 'post-smtp' ), 'pushover', $currentKey ); - $this->printSelectOption( __( 'Slack', 'post-smtp' ), 'slack', $currentKey ); + foreach ( $options as $key => $label ) { + $this->printSelectOption( $label, $key, $currentKey ); + } + printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription ); } diff --git a/Postman/Postman-Configuration/postman_manual_config.js b/Postman/Postman-Configuration/postman_manual_config.js index a47df1a..49438fc 100644 --- a/Postman/Postman-Configuration/postman_manual_config.js +++ b/Postman/Postman-Configuration/postman_manual_config.js @@ -40,6 +40,9 @@ jQuery(document).ready( $('#pushover_cred').fadeOut('fast'); $('#slack_cred').fadeIn(); } + + Hook.call( 'post_smtp_notification_change', selected ); + }); diff --git a/Postman/Postman-Configuration/postman_wizard.js b/Postman/Postman-Configuration/postman_wizard.js index d844322..cbd2031 100644 --- a/Postman/Postman-Configuration/postman_wizard.js +++ b/Postman/Postman-Configuration/postman_wizard.js @@ -517,6 +517,8 @@ function handleConfigurationResponse(response) { jQuery('#pushover_cred').fadeOut('fast'); jQuery('#slack_cred').fadeIn(); } + + Hook.call( 'post_smtp_notification_change', selected ); }); // add an event on the user port override field diff --git a/Postman/Postman-Email-Log/PostmanEmailLogService.php b/Postman/Postman-Email-Log/PostmanEmailLogService.php index 1afb4fc..2538700 100644 --- a/Postman/Postman-Email-Log/PostmanEmailLogService.php +++ b/Postman/Postman-Email-Log/PostmanEmailLogService.php @@ -212,6 +212,8 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) { $notifyer = new PostmanMailNotify; } + $notifyer = apply_filters( 'post_smtp_notifier', $notifyer, $notification_service ); + // Notifications $notify = new PostmanNotify( $notifyer ); $notify->send($message, $log); diff --git a/Postman/PostmanAdminController.php b/Postman/PostmanAdminController.php index 3d0486f..1e43c6d 100644 --- a/Postman/PostmanAdminController.php +++ b/Postman/PostmanAdminController.php @@ -128,11 +128,13 @@ if ( ! class_exists( 'PostmanAdminController' ) ) { $this->logger->debug( 'Looking for grant code' ); if ( isset( $_GET ['code'] ) ) { $this->logger->debug( 'Found authorization grant code' ); + // queue the function that processes the incoming grant code $this->registerInitFunction( 'handleAuthorizationGrant' ); return; } } + do_action('post_smtp_handle_oauth', $this->messageHandler ); // continue to initialize the AdminController add_action( 'init', array( diff --git a/Postman/PostmanLogFields.php b/Postman/PostmanLogFields.php index 84a3121..6e04b8d 100644 --- a/Postman/PostmanLogFields.php +++ b/Postman/PostmanLogFields.php @@ -3,11 +3,11 @@ class PostmanLogFields { private $fields = array( 'success' => 'sanitize_text_field', - 'from_header' => 'sanitize_text_field', - 'to_header' => 'sanitize_text_field', - 'cc_header' => 'sanitize_text_field', - 'bcc_header' => 'sanitize_text_field', - 'reply_to_header' => 'sanitize_text_field', + 'from_header' => '', + 'to_header' => '', + 'cc_header' => '', + 'bcc_header' => '', + 'reply_to_header' => '', 'transport_uri' => 'sanitize_text_field', 'original_to' => 'sanitize_text_field', 'original_subject' => 'sanitize_text_field', @@ -75,7 +75,11 @@ class PostmanLogFields { private function sanitize( $key, $value ) { $callback = is_array( $value ) ? 'array_map' : 'call_user_func'; - return $callback( $this->fields[$key], $value ); + if ( ! empty( $this->fields[$key] ) ) { + return $callback( $this->fields[$key], $value ); + } + + return filter_var( $value, FILTER_SANITIZE_STRING | FILTER_SANITIZE_SPECIAL_CHARS ); } private function sanitize_message( $message ) { @@ -92,4 +96,4 @@ class PostmanLogFields { return $value; } -} +}
\ No newline at end of file diff --git a/Postman/PostmanViewController.php b/Postman/PostmanViewController.php index 726880b..050033f 100644 --- a/Postman/PostmanViewController.php +++ b/Postman/PostmanViewController.php @@ -347,7 +347,11 @@ if ( ! class_exists( 'PostmanViewController' ) ) { print '<ul>'; // Grant permission with Google + ob_start(); PostmanTransportRegistry::getInstance()->getSelectedTransport()->printActionMenuItem(); + $oauth_link = ob_get_clean(); + + echo apply_filters( 'post_smtp_oauth_actions', $oauth_link ); if ( PostmanWpMailBinder::getInstance()->isBound() ) { printf( '<li><a href="%s" class="welcome-icon send_test_email">%s</a></li>', $this->getPageUrl( PostmanSendTestEmailController::EMAIL_TEST_SLUG ), __( 'Send a Test Email', 'post-smtp' ) ); |