From 86ae306841efdb92000cfed72736b947448b3413 Mon Sep 17 00:00:00 2001 From: yehudah Date: Mon, 20 Nov 2017 22:02:17 +0000 Subject: * Fixed: misspled false * Fixed: feedback form * Fixed: Some localization strings * Removed: deprecated function * New: Option to input emails when resend email * Added: explain message on email log filter git-svn-id: https://plugins.svn.wordpress.org/post-smtp/trunk@1771856 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- .../PostmanRegisterConfigurationSettings.php | 364 ++++++++++----------- .../PostmanEmailLogController.php | 18 +- Postman/Postman-Email-Log/PostmanEmailLogView.php | 10 +- Postman/PostmanInputSanitizer.php | 192 +++++------ Postman/PostmanPluginFeedback.php | 62 ++-- Postman/PostmanViewController.php | 15 +- postman-smtp.php | 4 +- readme.txt | 11 +- script/feedback/feedback.js | 58 ++-- script/postman_resend_email_sript.js | 58 +++- 10 files changed, 442 insertions(+), 350 deletions(-) diff --git a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php index 7a837f3..9915850 100644 --- a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php +++ b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php @@ -2,212 +2,210 @@ class PostmanSettingsRegistry { private $options; - + public function __construct() { $this->options = PostmanOptions::getInstance(); } - + /** * Fires on the admin_init method */ public function on_admin_init() { - // - $this->registerSettings (); + $this->registerSettings(); } - + /** * Register and add settings */ private function registerSettings() { - + // only administrators should be able to trigger this - if (PostmanUtils::isAdmin ()) { - // - $sanitizer = new PostmanInputSanitizer (); - register_setting ( PostmanAdminController::SETTINGS_GROUP_NAME, PostmanOptions::POSTMAN_OPTIONS, array ( + if ( PostmanUtils::isAdmin() ) { + $sanitizer = new PostmanInputSanitizer(); + register_setting( PostmanAdminController::SETTINGS_GROUP_NAME, PostmanOptions::POSTMAN_OPTIONS, array( $sanitizer, - 'sanitize' + 'sanitize', ) ); - + // Sanitize - add_settings_section ( 'transport_section', __ ( 'Transport', Postman::TEXT_DOMAIN ), array ( + add_settings_section( 'transport_section', __( 'Transport', Postman::TEXT_DOMAIN ), array( $this, - 'printTransportSectionInfo' + 'printTransportSectionInfo', ), 'transport_options' ); - - add_settings_field ( PostmanOptions::TRANSPORT_TYPE, _x ( 'Type', '(i.e.) What kind is it?', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::TRANSPORT_TYPE, _x( 'Type', '(i.e.) What kind is it?', Postman::TEXT_DOMAIN ), array( $this, - 'transport_type_callback' + 'transport_type_callback', ), 'transport_options', 'transport_section' ); - + // the Message From section - add_settings_section ( PostmanAdminController::MESSAGE_FROM_SECTION, _x ( 'From Address', 'The Message Sender Email Address', Postman::TEXT_DOMAIN ), array ( + add_settings_section( PostmanAdminController::MESSAGE_FROM_SECTION, _x( 'From Address', 'The Message Sender Email Address', Postman::TEXT_DOMAIN ), array( $this, - 'printMessageFromSectionInfo' + 'printMessageFromSectionInfo', ), PostmanAdminController::MESSAGE_FROM_OPTIONS ); - - add_settings_field ( PostmanOptions::MESSAGE_SENDER_EMAIL, __ ( 'Email Address', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::MESSAGE_SENDER_EMAIL, __( 'Email Address', Postman::TEXT_DOMAIN ), array( $this, - 'from_email_callback' + 'from_email_callback', ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION ); - - add_settings_field ( PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE, '', array ( + + add_settings_field( PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE, '', array( $this, - 'prevent_from_email_override_callback' + 'prevent_from_email_override_callback', ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION ); - - add_settings_field ( PostmanOptions::MESSAGE_SENDER_NAME, __ ( 'Name', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::MESSAGE_SENDER_NAME, __( 'Name', Postman::TEXT_DOMAIN ), array( $this, - 'sender_name_callback' + 'sender_name_callback', ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION ); - - add_settings_field ( PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE, '', array ( + + add_settings_field( PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE, '', array( $this, - 'prevent_from_name_override_callback' + 'prevent_from_name_override_callback', ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION ); - + // the Additional Addresses section - add_settings_section ( PostmanAdminController::MESSAGE_SECTION, __ ( 'Additional Email Addresses', Postman::TEXT_DOMAIN ), array ( + add_settings_section( PostmanAdminController::MESSAGE_SECTION, __( 'Additional Email Addresses', Postman::TEXT_DOMAIN ), array( $this, - 'printMessageSectionInfo' + 'printMessageSectionInfo', ), PostmanAdminController::MESSAGE_OPTIONS ); - - add_settings_field ( PostmanOptions::REPLY_TO, __ ( 'Reply-To', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::REPLY_TO, __( 'Reply-To', Postman::TEXT_DOMAIN ), array( $this, - 'reply_to_callback' + 'reply_to_callback', ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION ); - - add_settings_field ( PostmanOptions::FORCED_TO_RECIPIENTS, __ ( 'To Recipient(s)', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::FORCED_TO_RECIPIENTS, __( 'To Recipient(s)', Postman::TEXT_DOMAIN ), array( $this, - 'to_callback' + 'to_callback', ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION ); - - add_settings_field ( PostmanOptions::FORCED_CC_RECIPIENTS, __ ( 'Carbon Copy Recipient(s)', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::FORCED_CC_RECIPIENTS, __( 'Carbon Copy Recipient(s)', Postman::TEXT_DOMAIN ), array( $this, - 'cc_callback' + 'cc_callback', ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION ); - - add_settings_field ( PostmanOptions::FORCED_BCC_RECIPIENTS, __ ( 'Blind Carbon Copy Recipient(s)', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::FORCED_BCC_RECIPIENTS, __( 'Blind Carbon Copy Recipient(s)', Postman::TEXT_DOMAIN ), array( $this, - 'bcc_callback' + 'bcc_callback', ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION ); - + // the Additional Headers section - add_settings_section ( PostmanAdminController::MESSAGE_HEADERS_SECTION, __ ( 'Additional Headers', Postman::TEXT_DOMAIN ), array ( + add_settings_section( PostmanAdminController::MESSAGE_HEADERS_SECTION, __( 'Additional Headers', Postman::TEXT_DOMAIN ), array( $this, - 'printAdditionalHeadersSectionInfo' + 'printAdditionalHeadersSectionInfo', ), PostmanAdminController::MESSAGE_HEADERS_OPTIONS ); - - add_settings_field ( PostmanOptions::ADDITIONAL_HEADERS, __ ( 'Custom Headers', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::ADDITIONAL_HEADERS, __( 'Custom Headers', Postman::TEXT_DOMAIN ), array( $this, - 'headers_callback' + 'headers_callback', ), PostmanAdminController::MESSAGE_HEADERS_OPTIONS, PostmanAdminController::MESSAGE_HEADERS_SECTION ); - + // the Email Validation section - add_settings_section ( PostmanAdminController::EMAIL_VALIDATION_SECTION, __ ( 'Validation', Postman::TEXT_DOMAIN ), array ( + add_settings_section( PostmanAdminController::EMAIL_VALIDATION_SECTION, __( 'Validation', Postman::TEXT_DOMAIN ), array( $this, - 'printEmailValidationSectionInfo' + 'printEmailValidationSectionInfo', ), PostmanAdminController::EMAIL_VALIDATION_OPTIONS ); - - add_settings_field ( PostmanOptions::ENVELOPE_SENDER, __ ( 'Email Address', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::ENVELOPE_SENDER, __( 'Email Address', Postman::TEXT_DOMAIN ), array( $this, - 'disable_email_validation_callback' + 'disable_email_validation_callback', ), PostmanAdminController::EMAIL_VALIDATION_OPTIONS, PostmanAdminController::EMAIL_VALIDATION_SECTION ); - + // the Logging section - add_settings_section ( PostmanAdminController::LOGGING_SECTION, __ ( 'Email Log Settings', Postman::TEXT_DOMAIN ), array ( + add_settings_section( PostmanAdminController::LOGGING_SECTION, __( 'Email Log Settings', Postman::TEXT_DOMAIN ), array( $this, - 'printLoggingSectionInfo' + 'printLoggingSectionInfo', ), PostmanAdminController::LOGGING_OPTIONS ); - - add_settings_field ( 'logging_status', __ ( 'Enable Logging', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( 'logging_status', __( 'Enable Logging', Postman::TEXT_DOMAIN ), array( $this, - 'loggingStatusInputField' + 'loggingStatusInputField', ), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION ); - - add_settings_field ( 'logging_max_entries', __ ( 'Maximum Log Entries', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( 'logging_max_entries', __( 'Maximum Log Entries', Postman::TEXT_DOMAIN ), array( $this, - 'loggingMaxEntriesInputField' + 'loggingMaxEntriesInputField', ), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION ); - - add_settings_field ( PostmanOptions::TRANSCRIPT_SIZE, __ ( 'Maximum Transcript Size', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::TRANSCRIPT_SIZE, __( 'Maximum Transcript Size', Postman::TEXT_DOMAIN ), array( $this, - 'transcriptSizeInputField' + 'transcriptSizeInputField', ), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION ); - + // the Network section - add_settings_section ( PostmanAdminController::NETWORK_SECTION, __ ( 'Network Settings', Postman::TEXT_DOMAIN ), array ( + add_settings_section( PostmanAdminController::NETWORK_SECTION, __( 'Network Settings', Postman::TEXT_DOMAIN ), array( $this, - 'printNetworkSectionInfo' + 'printNetworkSectionInfo', ), PostmanAdminController::NETWORK_OPTIONS ); - - add_settings_field ( 'connection_timeout', _x ( 'TCP Connection Timeout (sec)', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( 'connection_timeout', _x( 'TCP Connection Timeout (sec)', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( $this, - 'connection_timeout_callback' + 'connection_timeout_callback', ), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION ); - - add_settings_field ( 'read_timeout', _x ( 'TCP Read Timeout (sec)', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( 'read_timeout', _x( 'TCP Read Timeout (sec)', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( $this, - 'read_timeout_callback' + 'read_timeout_callback', ), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION ); - + // the Advanced section - add_settings_section ( PostmanAdminController::ADVANCED_SECTION, _x ( 'Miscellaneous Settings', 'Configuration Section Title', Postman::TEXT_DOMAIN ), array ( + add_settings_section( PostmanAdminController::ADVANCED_SECTION, _x( 'Miscellaneous Settings', 'Configuration Section Title', Postman::TEXT_DOMAIN ), array( $this, - 'printAdvancedSectionInfo' + 'printAdvancedSectionInfo', ), PostmanAdminController::ADVANCED_OPTIONS ); - - add_settings_field ( PostmanOptions::LOG_LEVEL, _x ( 'PHP Log Level', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::LOG_LEVEL, _x( 'PHP Log Level', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( $this, - 'log_level_callback' + 'log_level_callback', ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION ); - - add_settings_field ( PostmanOptions::RUN_MODE, _x ( 'Delivery Mode', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::RUN_MODE, _x( 'Delivery Mode', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( $this, - 'runModeCallback' + 'runModeCallback', ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION ); - - add_settings_field ( PostmanOptions::STEALTH_MODE, _x ( 'Stealth Mode', 'This mode removes the Postman X-Mailer signature from emails', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::STEALTH_MODE, _x( 'Stealth Mode', 'This mode removes the Postman X-Mailer signature from emails', Postman::TEXT_DOMAIN ), array( $this, - 'stealthModeCallback' + 'stealthModeCallback', ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION ); - - add_settings_field ( PostmanOptions::TEMPORARY_DIRECTORY, __ ( 'Temporary Directory', Postman::TEXT_DOMAIN ), array ( + + add_settings_field( PostmanOptions::TEMPORARY_DIRECTORY, __( 'Temporary Directory', Postman::TEXT_DOMAIN ), array( $this, - 'temporaryDirectoryCallback' + 'temporaryDirectoryCallback', ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION ); } } - + /** * Print the Transport section info */ public function printTransportSectionInfo() { - print __ ( 'Choose SMTP or a vendor-specific API:', Postman::TEXT_DOMAIN ); + print __( 'Choose SMTP or a vendor-specific API:', Postman::TEXT_DOMAIN ); } public function printLoggingSectionInfo() { - print __ ( 'Configure the delivery audit log:', Postman::TEXT_DOMAIN ); + print __( 'Configure the delivery audit log:', Postman::TEXT_DOMAIN ); } - + /** * Print the Section text */ public function printMessageFromSectionInfo() { - print sprintf ( __ ( 'This address, like the letterhead printed on a letter, identifies the sender to the recipient. Change this when you are sending on behalf of someone else, for example to use Google\'s Send Mail As feature. Other plugins, especially Contact Forms, may override this field to be your visitor\'s address.', Postman::TEXT_DOMAIN ), 'https://support.google.com/mail/answer/22370?hl=en' ); + print sprintf( __( 'This address, like the letterhead printed on a letter, identifies the sender to the recipient. Change this when you are sending on behalf of someone else, for example to use Google\'s Send Mail As feature. Other plugins, especially Contact Forms, may override this field to be your visitor\'s address.', Postman::TEXT_DOMAIN ), 'https://support.google.com/mail/answer/22370?hl=en' ); } - + /** * Print the Section text */ public function printMessageSectionInfo() { - print __ ( 'Separate multiple to/cc/bcc recipients with commas.', Postman::TEXT_DOMAIN ); + print __( 'Separate multiple to/cc/bcc recipients with commas.', Postman::TEXT_DOMAIN ); } - + /** * Print the Section text */ public function printNetworkSectionInfo() { - print __ ( 'Increase the timeouts if your host is intermittenly failing to send mail. Be careful, this also correlates to how long your user must wait if the mail server is unreachable.', Postman::TEXT_DOMAIN ); + print __( 'Increase the timeouts if your host is intermittenly failing to send mail. Be careful, this also correlates to how long your user must wait if the mail server is unreachable.', Postman::TEXT_DOMAIN ); } /** * Print the Section text @@ -218,190 +216,190 @@ class PostmanSettingsRegistry { * Print the Section text */ public function printAdditionalHeadersSectionInfo() { - print __ ( 'Specify custom headers (e.g. X-MC-Tags: wordpress-site-A), one per line. Use custom headers with caution as they can negatively affect your Spam score.', Postman::TEXT_DOMAIN ); + print __( 'Specify custom headers (e.g. X-MC-Tags: wordpress-site-A), one per line. Use custom headers with caution as they can negatively affect your Spam score.', Postman::TEXT_DOMAIN ); } - + /** * Print the Email Validation Description */ public function printEmailValidationSectionInfo() { - print __ ( 'E-mail addresses can be validated before sending e-mail, however this may fail with some newer domains.', Postman::TEXT_DOMAIN ); + print __( 'E-mail addresses can be validated before sending e-mail, however this may fail with some newer domains.', Postman::TEXT_DOMAIN ); } - + /** * Get the settings option array and print one of its values */ public function transport_type_callback() { - $transportType = $this->options->getTransportType (); - printf ( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TRANSPORT_TYPE ); + foreach ( PostmanTransportRegistry::getInstance()->getTransports() as $transport ) { + printf( '', $transport->getSlug(), $transport->getName(), $transportType == $transport->getSlug() ? 'selected="selected"' : '' ); } print ''; } - + /** * Get the settings option array and print one of its values */ public function sender_name_callback() { - printf ( '', null !== $this->options->getMessageSenderName () ? esc_attr ( $this->options->getMessageSenderName () ) : '' ); + printf( '', null !== $this->options->getMessageSenderName() ? esc_attr( $this->options->getMessageSenderName() ) : '' ); } - + /** */ public function prevent_from_name_override_callback() { - $enforced = $this->options->isPluginSenderNameEnforced (); - printf ( ' %s', $enforced ? 'checked="checked"' : '', __ ( 'Prevent plugins and themes from changing this', Postman::TEXT_DOMAIN ) ); + $enforced = $this->options->isPluginSenderNameEnforced(); + printf( ' %s', $enforced ? 'checked="checked"' : '', __( 'Prevent plugins and themes from changing this', Postman::TEXT_DOMAIN ) ); } - + /** * Get the settings option array and print one of its values */ public function from_email_callback() { - printf ( '', null !== $this->options->getMessageSenderEmail () ? esc_attr ( $this->options->getMessageSenderEmail () ) : '', __ ( 'Required', Postman::TEXT_DOMAIN ) ); + printf( '', null !== $this->options->getMessageSenderEmail() ? esc_attr( $this->options->getMessageSenderEmail() ) : '', __( 'Required', Postman::TEXT_DOMAIN ) ); } - + /** * Print the Section text */ public function printMessageSenderSectionInfo() { - print sprintf ( __ ( 'This address, like the return address printed on an envelope, identifies the account owner to the SMTP server.', Postman::TEXT_DOMAIN ), 'https://support.google.com/mail/answer/22370?hl=en' ); + print sprintf( __( 'This address, like the return address printed on an envelope, identifies the account owner to the SMTP server.', Postman::TEXT_DOMAIN ), 'https://support.google.com/mail/answer/22370?hl=en' ); } - + /** * Get the settings option array and print one of its values */ public function prevent_from_email_override_callback() { - $enforced = $this->options->isPluginSenderEmailEnforced (); - printf ( ' %s', $enforced ? 'checked="checked"' : '', __ ( 'Prevent plugins and themes from changing this', Postman::TEXT_DOMAIN ) ); + $enforced = $this->options->isPluginSenderEmailEnforced(); + printf( ' %s', $enforced ? 'checked="checked"' : '', __( 'Prevent plugins and themes from changing this', Postman::TEXT_DOMAIN ) ); } - + /** * Shows the Mail Logging enable/disabled option */ public function loggingStatusInputField() { // isMailLoggingAllowed - $disabled = ""; - if (! $this->options->isMailLoggingAllowed ()) { + $disabled = ''; + if ( ! $this->options->isMailLoggingAllowed() ) { $disabled = 'disabled="disabled" '; } - printf ( '' ); + printf( '' ); } public function loggingMaxEntriesInputField() { - printf ( '', PostmanOptions::MAIL_LOG_MAX_ENTRIES, $this->options->getMailLoggingMaxEntries () ); + printf( '', PostmanOptions::MAIL_LOG_MAX_ENTRIES, $this->options->getMailLoggingMaxEntries() ); } public function transcriptSizeInputField() { $inputOptionsSlug = PostmanOptions::POSTMAN_OPTIONS; $inputTranscriptSlug = PostmanOptions::TRANSCRIPT_SIZE; - $inputValue = $this->options->getTranscriptSize (); - $inputDescription = __ ( 'Change this value if you can\'t see the beginning of the transcript because your messages are too big.', Postman::TEXT_DOMAIN ); - printf ( '
%4$s', $inputOptionsSlug, $inputTranscriptSlug, $inputValue, $inputDescription ); + $inputValue = $this->options->getTranscriptSize(); + $inputDescription = __( 'Change this value if you can\'t see the beginning of the transcript because your messages are too big.', Postman::TEXT_DOMAIN ); + printf( '
%4$s', $inputOptionsSlug, $inputTranscriptSlug, $inputValue, $inputDescription ); } - + /** * Get the settings option array and print one of its values */ public function reply_to_callback() { - printf ( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::REPLY_TO, null !== $this->options->getReplyTo () ? esc_attr ( $this->options->getReplyTo () ) : '' ); + printf( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::REPLY_TO, null !== $this->options->getReplyTo() ? esc_attr( $this->options->getReplyTo() ) : '' ); } - + /** * Get the settings option array and print one of its values */ public function to_callback() { - printf ( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_TO_RECIPIENTS, null !== $this->options->getForcedToRecipients () ? esc_attr ( $this->options->getForcedToRecipients () ) : '' ); + printf( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_TO_RECIPIENTS, null !== $this->options->getForcedToRecipients() ? esc_attr( $this->options->getForcedToRecipients() ) : '' ); } - + /** * Get the settings option array and print one of its values */ public function cc_callback() { - printf ( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_CC_RECIPIENTS, null !== $this->options->getForcedCcRecipients () ? esc_attr ( $this->options->getForcedCcRecipients () ) : '' ); + printf( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_CC_RECIPIENTS, null !== $this->options->getForcedCcRecipients() ? esc_attr( $this->options->getForcedCcRecipients() ) : '' ); } - + /** * Get the settings option array and print one of its values */ public function bcc_callback() { - printf ( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_BCC_RECIPIENTS, null !== $this->options->getForcedBccRecipients () ? esc_attr ( $this->options->getForcedBccRecipients () ) : '' ); + printf( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_BCC_RECIPIENTS, null !== $this->options->getForcedBccRecipients() ? esc_attr( $this->options->getForcedBccRecipients() ) : '' ); } - + /** * Get the settings option array and print one of its values */ public function headers_callback() { - printf ( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::ADDITIONAL_HEADERS, null !== $this->options->getAdditionalHeaders () ? esc_attr ( $this->options->getAdditionalHeaders () ) : '' ); + printf( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::ADDITIONAL_HEADERS, null !== $this->options->getAdditionalHeaders() ? esc_attr( $this->options->getAdditionalHeaders() ) : '' ); } - + /** */ public function disable_email_validation_callback() { - $disabled = $this->options->isEmailValidationDisabled (); - printf ( ' %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::DISABLE_EMAIL_VALIDAITON, $disabled ? 'checked="checked"' : '', __ ( 'Disable e-mail validation', Postman::TEXT_DOMAIN ) ); + $disabled = $this->options->isEmailValidationDisabled(); + printf( ' %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::DISABLE_EMAIL_VALIDAITON, $disabled ? 'checked="checked"' : '', __( 'Disable e-mail validation', Postman::TEXT_DOMAIN ) ); } - + /** * Get the settings option array and print one of its values */ public function log_level_callback() { - $inputDescription = sprintf ( __ ( 'Log Level specifies the level of detail written to the WordPress Debug log - view the log with Debug.', Postman::TEXT_DOMAIN ), 'https://codex.wordpress.org/Debugging_in_WordPress', 'https://wordpress.org/plugins/debug/' ); - printf ( '
%s', $inputDescription ); - } - private function printSelectOption($label, $optionKey, $currentKey) { + $inputDescription = sprintf( __( 'Log Level specifies the level of detail written to the WordPress Debug log - view the log with Debug.', Postman::TEXT_DOMAIN ), 'https://codex.wordpress.org/Debugging_in_WordPress', 'https://wordpress.org/plugins/debug/' ); + printf( '
%s', $inputDescription ); + } + private function printSelectOption( $label, $optionKey, $currentKey ) { $optionPattern = ''; - printf ( $optionPattern, $optionKey, $optionKey == $currentKey ? 'selected="selected"' : '', $label ); + printf( $optionPattern, $optionKey, $optionKey == $currentKey ? 'selected="selected"' : '', $label ); } public function runModeCallback() { - $inputDescription = __ ( 'Delivery mode offers options useful for developing or testing.', Postman::TEXT_DOMAIN ); - printf ( '
%s', $inputDescription ); + $inputDescription = __( 'Delivery mode offers options useful for developing or testing.', Postman::TEXT_DOMAIN ); + printf( '
%s', $inputDescription ); } public function stealthModeCallback() { - printf ( ' %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::STEALTH_MODE, $this->options->isStealthModeEnabled () ? 'checked="checked"' : '', __ ( 'Remove the Postman X-Header signature from messages', Postman::TEXT_DOMAIN ) ); + printf( ' %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::STEALTH_MODE, $this->options->isStealthModeEnabled() ? 'checked="checked"' : '', __( 'Remove the Postman X-Header signature from messages', Postman::TEXT_DOMAIN ) ); } public function temporaryDirectoryCallback() { - $inputDescription = __ ( 'Lockfiles are written here to prevent users from triggering an OAuth 2.0 token refresh at the same time.' ); - printf ( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TEMPORARY_DIRECTORY, $this->options->getTempDirectory () ); - if (PostmanState::getInstance ()->isFileLockingEnabled ()) { - printf ( ' %s
%s', __ ( 'Valid', Postman::TEXT_DOMAIN ), $inputDescription ); + $inputDescription = __( 'Lockfiles are written here to prevent users from triggering an OAuth 2.0 token refresh at the same time.' ); + printf( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TEMPORARY_DIRECTORY, $this->options->getTempDirectory() ); + if ( PostmanState::getInstance()->isFileLockingEnabled() ) { + printf( ' %s
%s', __( 'Valid', Postman::TEXT_DOMAIN ), $inputDescription ); } else { - printf ( ' %s
%s', __ ( 'Invalid', Postman::TEXT_DOMAIN ), $inputDescription ); + printf( ' %s
%s', __( 'Invalid', Postman::TEXT_DOMAIN ), $inputDescription ); } } - + /** * Get the settings option array and print one of its values */ public function connection_timeout_callback() { - printf ( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::CONNECTION_TIMEOUT, $this->options->getConnectionTimeout () ); + printf( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::CONNECTION_TIMEOUT, $this->options->getConnectionTimeout() ); } - + /** * Get the settings option array and print one of its values */ public function read_timeout_callback() { - printf ( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::READ_TIMEOUT, $this->options->getReadTimeout () ); + printf( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::READ_TIMEOUT, $this->options->getReadTimeout() ); } - + /** * Get the settings option array and print one of its values */ - public function port_callback($args) { - printf ( '', null !== $this->options->getPort () ? esc_attr ( $this->options->getPort () ) : '', isset ( $args ['style'] ) ? $args ['style'] : '', __ ( 'Required', Postman::TEXT_DOMAIN ) ); + public function port_callback( $args ) { + printf( '', null !== $this->options->getPort() ? esc_attr( $this->options->getPort() ) : '', isset( $args ['style'] ) ? $args ['style'] : '', __( 'Required', Postman::TEXT_DOMAIN ) ); } -} \ No newline at end of file +} diff --git a/Postman/Postman-Email-Log/PostmanEmailLogController.php b/Postman/Postman-Email-Log/PostmanEmailLogController.php index a7bd78a..efb19ae 100644 --- a/Postman/Postman-Email-Log/PostmanEmailLogController.php +++ b/Postman/Postman-Email-Log/PostmanEmailLogController.php @@ -70,13 +70,22 @@ class PostmanEmailLogController { /** */ public function resendMail() { + check_ajax_referer( 'resend', 'security' ); + // get the email address of the recipient from the HTTP Request $postid = $this->getRequestParameter( 'email' ); if ( ! empty( $postid ) ) { $post = get_post( $postid ); $meta_values = get_post_meta( $postid ); - $success = wp_mail( $meta_values ['original_to'] [0], $meta_values ['original_subject'] [0], $meta_values ['original_message'] [0], $meta_values ['original_headers'] [0] ); + if ( isset( $_POST['mail_to'] ) && ! empty( $_POST['mail_to'] ) ) { + $emails = explode( ',', $_POST['mail_to'] ); + $to = array_map( 'sanitize_email', $emails ); + } else { + $to = $meta_values ['original_to'] [0]; + } + + $success = wp_mail( $to, $meta_values ['original_subject'] [0], $meta_values ['original_message'] [0], $meta_values ['original_headers'] [0] ); // Postman API: retrieve the result of sending this message from Postman $result = apply_filters( 'postman_wp_mail_result', null ); @@ -288,7 +297,7 @@ class PostmanEmailLogController { $this->logger->trace( 'created PostmanEmailLog admin menu item' ); /* Translators where (%s) is the name of the plugin */ - $pageTitle = sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) ); + $pageTitle = sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) ); $pluginName = _x( 'Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN ); $page = add_submenu_page( PostmanViewController::POSTMAN_MENU_SLUG, $pageTitle, $pluginName, 'read_private_posts', 'postman_email_log', array( $this, 'postman_render_email_page' ) ); @@ -338,7 +347,7 @@ class PostmanEmailLogController {

+ echo sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) )?>
@@ -374,7 +383,8 @@ class PostmanEmailLogController {
-
+ +
Please notice: when you select a date for example 11/20/2017, behind the scene the query select 11/20/2017 00:00:00.
So if you searching for an email arrived that day at any hour you need to select 11/20/2017 as the From Date and 11/21/2017 as the To Date.
diff --git a/Postman/Postman-Email-Log/PostmanEmailLogView.php b/Postman/Postman-Email-Log/PostmanEmailLogView.php index f8f4fac..fe0fdfe 100644 --- a/Postman/Postman-Email-Log/PostmanEmailLogView.php +++ b/Postman/Postman-Email-Log/PostmanEmailLogView.php @@ -105,7 +105,9 @@ class PostmanEmailLogView extends WP_List_Table { } if ( ! (empty( $meta_values ['original_to'] [0] ) && empty( $meta_values ['originalHeaders'] [0] )) ) { // $actions ['resend'] = sprintf ( '%s', $resendUrl, __ ( 'Resend', Postman::TEXT_DOMAIN ) ); - $actions ['resend'] = sprintf( '%2$s', $item ['ID'], __( 'Resend', Postman::TEXT_DOMAIN ), 'resend-' . $item ['ID'] ); + $emails = maybe_unserialize( $meta_values ['original_to'] [0] ); + $to = is_array( $emails ) ? implode( ',', $emails ) : $emails; + $actions ['resend'] = sprintf( '%2$s
%5$s
', $item ['ID'], __( 'Resend', Postman::TEXT_DOMAIN ), 'resend-' . $item ['ID'], esc_attr( $to ), __( 'comma-separated for multiple emails', Postman::TEXT_DOMAIN ), wp_create_nonce( 'resend' ) ); } else { $actions ['resend'] = sprintf( '%2$s', $resendUrl, __( 'Resend', Postman::TEXT_DOMAIN ) ); } @@ -317,6 +319,7 @@ class PostmanEmailLogView extends WP_List_Table { $from_date = sanitize_text_field( $_POST['from_date'] ); $args['date_query']['after'] = $from_date; + $args['date_query']['column'] = 'post_date'; $args['date_query']['inclusive'] = false; } @@ -324,6 +327,7 @@ class PostmanEmailLogView extends WP_List_Table { $to_date = sanitize_text_field( $_POST['to_date'] ); $args['date_query']['before'] = $to_date; + $args['date_query']['column'] = 'post_date'; $args['date_query']['inclusive'] = true; } @@ -336,6 +340,8 @@ class PostmanEmailLogView extends WP_List_Table { } $posts = new WP_query( $args ); + $date_format = get_option( 'date_format' ); + $time_format = get_option( 'time_format' ); foreach ( $posts->posts as $post ) { $date = $post->post_date; @@ -351,7 +357,7 @@ class PostmanEmailLogView extends WP_List_Table { 'title' => esc_html( $post->post_title ), // the post status must be escaped as they are displayed in the HTML output 'status' => ($post->post_excerpt != null ? esc_html( $post->post_excerpt ) : __( 'Sent', Postman::TEXT_DOMAIN )), - 'date' => $date, + 'date' => date( "$date_format $time_format", strtotime( $post->post_date ) ), 'ID' => $post->ID, ); array_push( $data, $flattenedPost ); diff --git a/Postman/PostmanInputSanitizer.php b/Postman/PostmanInputSanitizer.php index 008b3c9..d8b6e49 100644 --- a/Postman/PostmanInputSanitizer.php +++ b/Postman/PostmanInputSanitizer.php @@ -1,154 +1,154 @@ logger = new PostmanLogger ( get_class ( $this ) ); + $this->logger = new PostmanLogger( get_class( $this ) ); $this->options = PostmanOptions::getInstance(); } - + /** * Sanitize each setting field as needed * * @param array $input * Contains all settings fields as array keys */ - public function sanitize($input) { - $this->logger->debug ( "Sanitizing data before storage" ); - - $new_input = array (); + public function sanitize( $input ) { + $this->logger->debug( 'Sanitizing data before storage' ); + + $new_input = array(); $success = true; - - $this->sanitizeString ( 'Encryption Type', PostmanOptions::SECURITY_TYPE, $input, $new_input ); - $this->sanitizeString ( 'Hostname', PostmanOptions::HOSTNAME, $input, $new_input ); - if (! empty ( $input [PostmanOptions::PORT] )) { - $port = absint ( $input [PostmanOptions::PORT] ); - if ($port > 0) { - $this->sanitizeInt ( 'Port', PostmanOptions::PORT, $input, $new_input ); + + $this->sanitizeString( 'Encryption Type', PostmanOptions::SECURITY_TYPE, $input, $new_input ); + $this->sanitizeString( 'Hostname', PostmanOptions::HOSTNAME, $input, $new_input ); + if ( ! empty( $input [ PostmanOptions::PORT ] ) ) { + $port = absint( $input [ PostmanOptions::PORT ] ); + if ( $port > 0 ) { + $this->sanitizeInt( 'Port', PostmanOptions::PORT, $input, $new_input ); } else { - $new_input [PostmanOptions::PORT] = $this->options->getPort (); - add_settings_error ( PostmanOptions::PORT, PostmanOptions::PORT, 'Invalid TCP Port', 'error' ); + $new_input [ PostmanOptions::PORT ] = $this->options->getPort(); + add_settings_error( PostmanOptions::PORT, PostmanOptions::PORT, 'Invalid TCP Port', 'error' ); $success = false; } } // check the auth type AFTER the hostname because we reset the hostname if auth is bad - $this->sanitizeString ( 'From Email', PostmanOptions::MESSAGE_SENDER_EMAIL, $input, $new_input ); + $this->sanitizeString( 'From Email', PostmanOptions::MESSAGE_SENDER_EMAIL, $input, $new_input ); // the wizard doesn't set an envelope sender, so we'll default it to From Email - $new_input [PostmanOptions::ENVELOPE_SENDER] = $new_input [PostmanOptions::MESSAGE_SENDER_EMAIL]; - $this->sanitizeString ( 'Sender Email', PostmanOptions::ENVELOPE_SENDER, $input, $new_input ); - $this->sanitizeString ( 'Transport Type', PostmanOptions::TRANSPORT_TYPE, $input, $new_input ); - $this->sanitizeString ( 'Authorization Type', PostmanOptions::AUTHENTICATION_TYPE, $input, $new_input ); - $this->sanitizeString ( 'From Name', PostmanOptions::MESSAGE_SENDER_NAME, $input, $new_input ); - $this->sanitizeString ( 'Client ID', PostmanOptions::CLIENT_ID, $input, $new_input ); - $this->sanitizeString ( 'Client Secret', PostmanOptions::CLIENT_SECRET, $input, $new_input ); - $this->sanitizeString ( 'Username', PostmanOptions::BASIC_AUTH_USERNAME, $input, $new_input ); - $this->sanitizePassword ( 'Password', PostmanOptions::BASIC_AUTH_PASSWORD, $input, $new_input, $this->options->getPassword () ); - $this->sanitizePassword ( 'Mandrill API Key', PostmanOptions::MANDRILL_API_KEY, $input, $new_input, $this->options->getMandrillApiKey () ); - $this->sanitizePassword ( 'SendGrid API Key', PostmanOptions::SENDGRID_API_KEY, $input, $new_input, $this->options->getSendGridApiKey () ); - $this->sanitizeString ( 'Reply-To', PostmanOptions::REPLY_TO, $input, $new_input ); - $this->sanitizeString ( 'From Name Override', PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE, $input, $new_input ); - $this->sanitizeString ( 'From Email Override', PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE, $input, $new_input ); - $this->sanitizeString ( 'Disable Email Validation', PostmanOptions::DISABLE_EMAIL_VALIDAITON, $input, $new_input ); - $this->sanitizeString ( 'Forced To Recipients', PostmanOptions::FORCED_TO_RECIPIENTS, $input, $new_input ); - $this->sanitizeString ( 'Forced CC Recipients', PostmanOptions::FORCED_CC_RECIPIENTS, $input, $new_input ); - $this->sanitizeString ( 'Forced BCC Recipients', PostmanOptions::FORCED_BCC_RECIPIENTS, $input, $new_input ); - $this->sanitizeString ( 'Additional Headers', PostmanOptions::ADDITIONAL_HEADERS, $input, $new_input ); - $this->sanitizeInt ( 'Read Timeout', PostmanOptions::READ_TIMEOUT, $input, $new_input ); - $this->sanitizeInt ( 'Conenction Timeout', PostmanOptions::CONNECTION_TIMEOUT, $input, $new_input ); - $this->sanitizeInt ( 'Log Level', PostmanOptions::LOG_LEVEL, $input, $new_input ); - $this->sanitizeString ( 'Email Log Enabled', PostmanOptions::MAIL_LOG_ENABLED_OPTION, $input, $new_input ); - $this->sanitizeLogMax ( 'Email Log Max Entries', PostmanOptions::MAIL_LOG_MAX_ENTRIES, $input, $new_input ); - $this->sanitizeString ( 'Run Mode', PostmanOptions::RUN_MODE, $input, $new_input ); - $this->sanitizeString ( 'Stealth Mode', PostmanOptions::STEALTH_MODE, $input, $new_input ); - $this->sanitizeInt ( 'Transcript Size', PostmanOptions::TRANSCRIPT_SIZE, $input, $new_input ); - $this->sanitizeString ( 'Temporary Directory', PostmanOptions::TEMPORARY_DIRECTORY, $input, $new_input ); - - if ($new_input [PostmanOptions::CLIENT_ID] != $this->options->getClientId () || $new_input [PostmanOptions::CLIENT_SECRET] != $this->options->getClientSecret () || $new_input [PostmanOptions::HOSTNAME] != $this->options->getHostname ()) { - $this->logger->debug ( "Recognized new Client ID" ); + $new_input [ PostmanOptions::ENVELOPE_SENDER ] = $new_input [ PostmanOptions::MESSAGE_SENDER_EMAIL ]; + $this->sanitizeString( 'Sender Email', PostmanOptions::ENVELOPE_SENDER, $input, $new_input ); + $this->sanitizeString( 'Transport Type', PostmanOptions::TRANSPORT_TYPE, $input, $new_input ); + $this->sanitizeString( 'Authorization Type', PostmanOptions::AUTHENTICATION_TYPE, $input, $new_input ); + $this->sanitizeString( 'From Name', PostmanOptions::MESSAGE_SENDER_NAME, $input, $new_input ); + $this->sanitizeString( 'Client ID', PostmanOptions::CLIENT_ID, $input, $new_input ); + $this->sanitizeString( 'Client Secret', PostmanOptions::CLIENT_SECRET, $input, $new_input ); + $this->sanitizeString( 'Username', PostmanOptions::BASIC_AUTH_USERNAME, $input, $new_input ); + $this->sanitizePassword( 'Password', PostmanOptions::BASIC_AUTH_PASSWORD, $input, $new_input, $this->options->getPassword() ); + $this->sanitizePassword( 'Mandrill API Key', PostmanOptions::MANDRILL_API_KEY, $input, $new_input, $this->options->getMandrillApiKey() ); + $this->sanitizePassword( 'SendGrid API Key', PostmanOptions::SENDGRID_API_KEY, $input, $new_input, $this->options->getSendGridApiKey() ); + $this->sanitizeString( 'Reply-To', PostmanOptions::REPLY_TO, $input, $new_input ); + $this->sanitizeString( 'From Name Override', PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE, $input, $new_input ); + $this->sanitizeString( 'From Email Override', PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE, $input, $new_input ); + $this->sanitizeString( 'Disable Email Validation', PostmanOptions::DISABLE_EMAIL_VALIDAITON, $input, $new_input ); + $this->sanitizeString( 'Forced To Recipients', PostmanOptions::FORCED_TO_RECIPIENTS, $input, $new_input ); + $this->sanitizeString( 'Forced CC Recipients', PostmanOptions::FORCED_CC_RECIPIENTS, $input, $new_input ); + $this->sanitizeString( 'Forced BCC Recipients', PostmanOptions::FORCED_BCC_RECIPIENTS, $input, $new_input ); + $this->sanitizeString( 'Additional Headers', PostmanOptions::ADDITIONAL_HEADERS, $input, $new_input ); + $this->sanitizeInt( 'Read Timeout', PostmanOptions::READ_TIMEOUT, $input, $new_input ); + $this->sanitizeInt( 'Conenction Timeout', PostmanOptions::CONNECTION_TIMEOUT, $input, $new_input ); + $this->sanitizeInt( 'Log Level', PostmanOptions::LOG_LEVEL, $input, $new_input ); + $this->sanitizeString( 'Email Log Enabled', PostmanOptions::MAIL_LOG_ENABLED_OPTION, $input, $new_input ); + $this->sanitizeLogMax( 'Email Log Max Entries', PostmanOptions::MAIL_LOG_MAX_ENTRIES, $input, $new_input ); + $this->sanitizeString( 'Run Mode', PostmanOptions::RUN_MODE, $input, $new_input ); + $this->sanitizeString( 'Stealth Mode', PostmanOptions::STEALTH_MODE, $input, $new_input ); + $this->sanitizeInt( 'Transcript Size', PostmanOptions::TRANSCRIPT_SIZE, $input, $new_input ); + $this->sanitizeString( 'Temporary Directory', PostmanOptions::TEMPORARY_DIRECTORY, $input, $new_input ); + + if ( $new_input [ PostmanOptions::CLIENT_ID ] != $this->options->getClientId() || $new_input [ PostmanOptions::CLIENT_SECRET ] != $this->options->getClientSecret() || $new_input [ PostmanOptions::HOSTNAME ] != $this->options->getHostname() ) { + $this->logger->debug( 'Recognized new Client ID' ); // the user entered a new client id and we should destroy the stored auth token - delete_option ( PostmanOAuthToken::OPTIONS_NAME ); + delete_option( PostmanOAuthToken::OPTIONS_NAME ); } - + // can we create a tmp file? - this code is duplicated in ActivationHandler - PostmanUtils::deleteLockFile ( $new_input [PostmanOptions::TEMPORARY_DIRECTORY] ); - $lockSuccess = PostmanUtils::createLockFile ( $new_input [PostmanOptions::TEMPORARY_DIRECTORY] ); + PostmanUtils::deleteLockFile( $new_input [ PostmanOptions::TEMPORARY_DIRECTORY ] ); + $lockSuccess = PostmanUtils::createLockFile( $new_input [ PostmanOptions::TEMPORARY_DIRECTORY ] ); // &= does not work as expected in my PHP - $lockSuccess = $lockSuccess && PostmanUtils::deleteLockFile ( $new_input [PostmanOptions::TEMPORARY_DIRECTORY] ); - $this->logger->debug ( 'FileLocking=' . $lockSuccess ); - PostmanState::getInstance ()->setFileLockingEnabled ( $lockSuccess ); - - if ($success) { - PostmanSession::getInstance ()->setAction ( self::VALIDATION_SUCCESS ); + $lockSuccess = $lockSuccess && PostmanUtils::deleteLockFile( $new_input [ PostmanOptions::TEMPORARY_DIRECTORY ] ); + $this->logger->debug( 'FileLocking=' . $lockSuccess ); + PostmanState::getInstance()->setFileLockingEnabled( $lockSuccess ); + + if ( $success ) { + PostmanSession::getInstance()->setAction( self::VALIDATION_SUCCESS ); } else { - PostmanSession::getInstance ()->setAction ( self::VALIDATION_FAILED ); + PostmanSession::getInstance()->setAction( self::VALIDATION_FAILED ); } - + return $new_input; } - private function sanitizeString($desc, $key, $input, &$new_input) { - if (isset ( $input [$key] )) { - $this->logSanitize ( $desc, $input [$key] ); - $new_input [$key] = trim ( $input [$key] ); + private function sanitizeString( $desc, $key, $input, &$new_input ) { + if ( isset( $input [ $key ] ) ) { + $this->logSanitize( $desc, $input [ $key ] ); + $new_input [ $key ] = trim( $input [ $key ] ); } } - + /** * Sanitize a Basic Auth password, and base64-encode it * - * @param unknown $desc - * @param unknown $key - * @param unknown $input - * @param unknown $new_input + * @param unknown $desc + * @param unknown $key + * @param unknown $input + * @param unknown $new_input */ - private function sanitizePassword($desc, $key, $input, &$new_input, $existingPassword) { + private function sanitizePassword( $desc, $key, $input, &$new_input, $existingPassword ) { // WordPress calling Sanitize twice is a known issue // https://core.trac.wordpress.org/ticket/21989 - $action = PostmanSession::getInstance ()->getAction (); + $action = PostmanSession::getInstance()->getAction(); // if $action is not empty, then sanitize has already run - if (! empty ( $action )) { + if ( ! empty( $action ) ) { // use the already encoded password in the $input - $new_input [$key] = $input [$key]; + $new_input [ $key ] = $input [ $key ]; // log it - $this->logger->debug ( 'Warning, second sanitizePassword attempt detected' ); - } else if (isset ( $input [$key] )) { - if (strlen ( $input [$key] ) > 0 && preg_match ( '/^\**$/', $input [$key] )) { + $this->logger->debug( 'Warning, second sanitizePassword attempt detected' ); + } else if ( isset( $input [ $key ] ) ) { + if ( strlen( $input [ $key ] ) > 0 && preg_match( '/^\**$/', $input [ $key ] ) ) { // if the password is all stars, then keep the existing password - $new_input [$key] = $existingPassword; + $new_input [ $key ] = $existingPassword; } else { // otherwise the password is new, so trim it - $new_input [$key] = trim ( $input [$key] ); + $new_input [ $key ] = trim( $input [ $key ] ); } // log it - $this->logSanitize ( $desc, $new_input [$key] ); + $this->logSanitize( $desc, $new_input [ $key ] ); // base-64 scramble password - $new_input [$key] = base64_encode ( $new_input [$key] ); + $new_input [ $key ] = base64_encode( $new_input [ $key ] ); } - $this->logger->debug ( sprintf ( 'Encoding %s as %s', $desc, $new_input [$key] ) ); + $this->logger->debug( sprintf( 'Encoding %s as %s', $desc, $new_input [ $key ] ) ); } - private function sanitizeLogMax($desc, $key, $input, &$new_input) { - if (isset ( $input [$key] )) { - $value = absint ( $input [$key] ); - if ($value <= 0) { - $new_input [$key] = PostmanOptions::getInstance ()->getMailLoggingMaxEntries (); - $h = new PostmanMessageHandler (); - $h->addError ( sprintf ( '%s %s', __ ( 'Maximum Log Entries', 'Configuration Input Field', Postman::TEXT_DOMAIN ), __ ( 'must be greater than 0', Postman::TEXT_DOMAIN ) ) ); + private function sanitizeLogMax( $desc, $key, $input, &$new_input ) { + if ( isset( $input [ $key ] ) ) { + $value = absint( $input [ $key ] ); + if ( $value <= 0 ) { + $new_input [ $key ] = PostmanOptions::getInstance()->getMailLoggingMaxEntries(); + $h = new PostmanMessageHandler(); + $h->addError( sprintf( '%s %s', __( 'Maximum Log Entries', Postman::TEXT_DOMAIN ), __( 'must be greater than 0', Postman::TEXT_DOMAIN ) ) ); } else { - $this->logSanitize ( $desc, $input [$key] ); - $new_input [$key] = $value; + $this->logSanitize( $desc, $input [ $key ] ); + $new_input [ $key ] = $value; } } } - private function sanitizeInt($desc, $key, $input, &$new_input) { - if (isset ( $input [$key] )) { - $this->logSanitize ( $desc, $input [$key] ); - $new_input [$key] = absint ( $input [$key] ); + private function sanitizeInt( $desc, $key, $input, &$new_input ) { + if ( isset( $input [ $key ] ) ) { + $this->logSanitize( $desc, $input [ $key ] ); + $new_input [ $key ] = absint( $input [ $key ] ); } } - private function logSanitize($desc, $value) { - $this->logger->trace ( 'Sanitize ' . $desc . ' ' . $value ); + private function logSanitize( $desc, $value ) { + $this->logger->trace( 'Sanitize ' . $desc . ' ' . $value ); } } } diff --git a/Postman/PostmanPluginFeedback.php b/Postman/PostmanPluginFeedback.php index de7d73f..3ac985d 100644 --- a/Postman/PostmanPluginFeedback.php +++ b/Postman/PostmanPluginFeedback.php @@ -4,7 +4,6 @@ class PostmanPluginFeedback { function __construct() { add_filter( 'plugin_action_links_' . plugin_basename( POST_BASE ), array( $this, 'insert_deactivate_link_id' ) ); add_action( 'wp_ajax_post_user_feedback', array( $this, 'post_user_feedback' ) ); - global $pagenow; if ( 'plugins.php' === $pagenow ) { add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) ); @@ -15,7 +14,7 @@ class PostmanPluginFeedback { function load_scripts() { wp_enqueue_style( 'wp-jquery-ui-dialog' ); - wp_register_script( 'post-feedback', plugins_url( 'script/feedback/feedback.js', POST_BASE ), array( 'jquery', 'jquery-ui-core', 'jquery-ui-dialog' ), fasle, true ); + wp_register_script( 'post-feedback', plugins_url( 'script/feedback/feedback.js', POST_BASE ), array( 'jquery', 'jquery-ui-core', 'jquery-ui-dialog' ), false, true ); wp_localize_script( 'post-feedback', 'post_feedback', array( 'admin_ajax' => admin_url( 'admin-ajax.php' ) ) ); wp_enqueue_script( 'post-feedback' ); } @@ -27,7 +26,7 @@ class PostmanPluginFeedback { $payload = array( 'reason' => sanitize_text_field( $_POST['reason'] ), - 'other_input' => isset( $_POST['other_input'] ) ? sanitize_textarea_field( $_POST['other_input'] ) : '', + 'other_input' => isset( $_POST['other_input'] ) ? sanitize_text_field( $_POST['other_input'] ) : '', ); if ( isset( $_POST['support'] ) ) { @@ -38,6 +37,7 @@ class PostmanPluginFeedback { $args = array( 'body' => $payload, + 'timeout' => 20, ); $result = wp_remote_post( 'https://postmansmtp.com/feedback', $args ); die( 'success' ); @@ -50,11 +50,11 @@ class PostmanPluginFeedback { float: none !important; } - #postman-feedback-dialog-skip { + #postman-feedback-dialog-go { float: left; } - #postman-feedback-dialog-go, #postman-feedback-dialog-cancel { + #postman-feedback-dialog-skip, #postman-feedback-dialog-cancel { float: right; } @@ -62,11 +62,31 @@ class PostmanPluginFeedback { font-size: 1.1em; } - #postman-deactivate-reasons textarea { + .postman-reason-input textarea { margin-top: 10px; width: 100%; height: 150px; } + + .postman-feedback-dialog-form .ui-icon { + display: none; + } + + #postman-feedback-dialog-go.postman-ajax-progress .ui-icon { + text-indent: inherit; + display: inline-block !important; + vertical-align: middle; + animation: rotate 2s infinite linear; + } + + #postman-feedback-dialog-go.postman-ajax-progress .ui-button-text { + vertical-align: middle; + } + + @keyframes rotate { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } + } + %s', sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) ) ); + printf( '

%s

', sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) ) ); printf( '
', $slug ); print '
'; print '
'; @@ -253,15 +253,14 @@ if ( ! class_exists( 'PostmanViewController' ) ) { /** */ private function displayTopNavigation() { - screen_icon(); - printf( '

%s

', sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) ) ); + printf( '

%s

', sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) ) ); print '
'; print '
'; print '
'; print '
'; printf( '

%s

', __( 'Configuration', Postman::TEXT_DOMAIN ) ); printf( '%s', $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG ), __( 'Start the Wizard', Postman::TEXT_DOMAIN ) ); - printf( '

or %s

', $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_SLUG ), __( 'Show All Settings', Postman::TEXT_DOMAIN ) ); + printf( '

%s %s

', __( 'or', Postman::TEXT_DOMAIN ), $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_SLUG ), __( 'Show All Settings', Postman::TEXT_DOMAIN ) ); print '
'; print '
'; printf( '

%s

', _x( 'Actions', 'Main Menu', Postman::TEXT_DOMAIN ) ); @@ -295,7 +294,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) { printf( '
  • %s
  • ', $this->getPageUrl( PostmanConnectivityTestController::PORT_TEST_SLUG ), __( 'Connectivity Test', Postman::TEXT_DOMAIN ) ); printf( '
  • %s
  • ', $this->getPageUrl( PostmanDiagnosticTestController::DIAGNOSTICS_SLUG ), __( 'Diagnostic Test', Postman::TEXT_DOMAIN ) ); printf( '
  • %s
  • ', __( 'Online Support', Postman::TEXT_DOMAIN ) ); - printf( '
  • %s
  • ', __( 'Guides', Postman::TEXT_DOMAIN ) ); + printf( '
  • %s
  • ', __( 'Guides', Postman::TEXT_DOMAIN ) ); print '
    '; } } diff --git a/postman-smtp.php b/postman-smtp.php index 04b8e16..b394b23 100644 --- a/postman-smtp.php +++ b/postman-smtp.php @@ -4,7 +4,7 @@ * Plugin Name: Post SMTP * Plugin URI: https://wordpress.org/plugins/post-smtp/ * Description: Email not reliable? Post SMTP is the first and only WordPress SMTP plugin to implement OAuth 2.0 for Gmail, Hotmail and Yahoo Mail. Setup is a breeze with the Configuration Wizard and integrated Port Tester. Enjoy worry-free delivery even if your password changes! - * Version: 1.7.8 + * Version: 1.7.9 * Author: Jason Hendriks, Yehuda Hassine * Text Domain: post-smtp * Author URI: https://postmansmtp.com @@ -71,5 +71,5 @@ function post_start( $startingMemory ) { */ function post_setupPostman() { require_once 'Postman/Postman.php'; - $kevinCostner = new Postman( __FILE__, '1.7.8' ); + $kevinCostner = new Postman( __FILE__, '1.7.9' ); } diff --git a/readme.txt b/readme.txt index cea73c2..6250eee 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: yehudah, jasonhendriks Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email Requires at least: 3.9 Tested up to: 4.9 -Stable tag: 1.7.8 +Stable tag: 1.7.9 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -277,10 +277,19 @@ To avoid being flagged as spam, you need to prove your email isn't forged. On a 1. Emai Log screen 1. Connectivity Test utility screen 1. Diagnostic Information screen +1. Email Log Filter == Changelog == + += 1.7.9 - 2017-11-20 +* Fixed: misspled false +* Fixed: feedback form +* Fixed: Some localization strings +* Added: explain message on email log filter +* Removed: deprecated function + = 1.7.8 - 2017-11-17 * = Menu Items grouping = * Fixed: IP detection error in some web hosts diff --git a/script/feedback/feedback.js b/script/feedback/feedback.js index 97940cf..a151f3b 100644 --- a/script/feedback/feedback.js +++ b/script/feedback/feedback.js @@ -13,24 +13,17 @@ jQuery(document).ready(function($) { minWidth: 400, minHeight: 300, modal: true, - buttons: { - 'skip' : { - text: 'Skip', - id: 'postman-feedback-dialog-skip', - click: function() { - $( this ).dialog( "close" ); - - location.href = deactivateLink; - } - }, + buttons: { 'go' : { text: 'Continue', + icons: { primary: "dashicons dashicons-update" }, id: 'postman-feedback-dialog-go', class: 'button', click: function() { - $( this ).dialog( "close" ); - var form = $( this ).find( 'form' ).serializeArray(), + var dialog = $(this), + go = $('#postman-feedback-dialog-go'), + form = dialog.find( 'form' ).serializeArray(), result = {}; $.each( form, function() { @@ -41,13 +34,26 @@ jQuery(document).ready(function($) { if ( ! jQuery.isEmptyObject( result ) ) { result.action = 'post_user_feedback'; - $.post( post_feedback.admin_ajax, result, function(result) { - - }); + $.ajax({ + url: post_feedback.admin_ajax, + type: 'POST', + data: result, + error: function(){}, + success: function(msg){}, + beforeSend: function() { + go.addClass('postman-ajax-progress'); + }, + complete: function() { + go.removeClass('postman-ajax-progress'); + + dialog.dialog( "close" ); + location.href = deactivateLink; + } + }); + } - // Remove this comment to deactivate plugin - location.href = deactivateLink; + }, }, 'cancel' : { @@ -57,7 +63,16 @@ jQuery(document).ready(function($) { click: function() { $( this ).dialog( "close" ); } - } + }, + 'skip' : { + text: 'Skip', + id: 'postman-feedback-dialog-skip', + click: function() { + $( this ).dialog( "close" ); + + location.href = deactivateLink; + } + }, } }); @@ -65,8 +80,13 @@ jQuery(document).ready(function($) { $( '.postman-reason-input' ).hide(); if ( $( this ).hasClass( 'postman-custom-input' ) ) { - $( this ).find( '.postman-reason-input' ).show(); + $( '#postman-deactivate-reasons' ).next( '.postman-reason-input' ).show(); } + + if ( $( this ).hasClass( 'postman-support-input' ) ) { + console.log($(this)); + $( this ).find( '.postman-reason-input' ).show(); + } }); }); diff --git a/script/postman_resend_email_sript.js b/script/postman_resend_email_sript.js index 1905bc5..c6d218a 100644 --- a/script/postman_resend_email_sript.js +++ b/script/postman_resend_email_sript.js @@ -1,17 +1,43 @@ -function postman_resend_email(emailId) { - var data = { - 'action' : 'postman_resend_mail', - 'email' : emailId - }; - - jQuery.post(ajaxurl, data, function(response) { - if (response.success) { - alert(response.data.message); -// jQuery('span#resend-' + emailId).text(postman_js_resend_label); - } else { - alert(sprintf(postman_js_email_not_resent, response.data.message)); - } - }).fail(function(response) { - ajaxFailed(response); +jQuery(document).ready(function($) { + $('.postman-open-resend').on('click', function(e) { + e.preventDefault(); + + $(this).parent().next('div').fadeToggle(); }); -} + + $('.postman-resend').on('click', function(e) { + e.preventDefault(); + + var parent = $(this).closest('div'), + mailField = $(this).prev('input'), + emailId = mailField.data('id'), + mail_to = mailField.val(), + security = parent.find('input[name="security"]').val(); + + + postman_resend_email(emailId, mail_to, security); + + }); + + function postman_resend_email(emailId, mail_to, security ) { + var data = { + 'action' : 'postman_resend_mail', + 'email' : emailId, + 'mail_to' : mail_to, + 'security' : security + }; + + jQuery.post(ajaxurl, data, function(response) { + if (response.success) { + alert(response.data.message); + // jQuery('span#resend-' + emailId).text(postman_js_resend_label); + } else { + alert(sprintf(postman_js_email_not_resent, response.data.message)); + } + }).fail(function(response) { + ajaxFailed(response); + }); + } + +}) + -- cgit v1.2.3