summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php2
-rw-r--r--Postman/Postman-Connectivity-Test/PostmanConnectivityTestController.php2
-rw-r--r--Postman/Postman-Connectivity-Test/registered-domain-libs-master/generateEffectiveTLDs.php4
-rw-r--r--Postman/Postman-Email-Log/PostmanEmailLogController.php301
-rw-r--r--Postman/Postman-Mail/PostmanMandrillTransport.php2
-rw-r--r--Postman/Postman-Mail/PostmanSendGridTransport.php2
-rw-r--r--Postman/Postman-Mail/PostmanSmtpModuleTransport.php2
-rw-r--r--Postman/PostmanConfigTextHelper.php4
-rw-r--r--Postman/PostmanUtils.php366
-rw-r--r--postman-smtp.php2
-rw-r--r--readme.txt19
11 files changed, 352 insertions, 354 deletions
diff --git a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
index c1a42a2..7a837f3 100644
--- a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
+++ b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
@@ -347,7 +347,7 @@ class PostmanSettingsRegistry {
* 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 <a target="_new" href="%s">WordPress Debug log</a> - view the log with <a target-"_new" href="%s">Debug</a>.', Postman::TEXT_DOMAIN ), 'https://codex.wordpress.org/Debugging_in_WordPress', 'https://wordpress.org/plugins/debug/' );
+ $inputDescription = sprintf ( __ ( 'Log Level specifies the level of detail written to the <a target="_blank" href="%s">WordPress Debug log</a> - view the log with <a target-"_new" href="%s">Debug</a>.', Postman::TEXT_DOMAIN ), 'https://codex.wordpress.org/Debugging_in_WordPress', 'https://wordpress.org/plugins/debug/' );
printf ( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::LOG_LEVEL );
$currentKey = $this->options->getLogLevel ();
$this->printSelectOption ( __ ( 'Off', Postman::TEXT_DOMAIN ), PostmanLogger::OFF_INT, $currentKey );
diff --git a/Postman/Postman-Connectivity-Test/PostmanConnectivityTestController.php b/Postman/Postman-Connectivity-Test/PostmanConnectivityTestController.php
index 069c414..9999b1d 100644
--- a/Postman/Postman-Connectivity-Test/PostmanConnectivityTestController.php
+++ b/Postman/Postman-Connectivity-Test/PostmanConnectivityTestController.php
@@ -154,7 +154,7 @@ class PostmanConnectivityTestController {
}
print '</table>';
/* Translators: Where %s is the name of the service providing Internet connectivity test */
- printf( '<p class="portquiz" style="display:none; font-size:0.8em">* %s</p>', sprintf( __( 'According to %s', Postman::TEXT_DOMAIN ), '<a target="_new" href="http://ww.downor.me/portquiz.net">portquiz.net</a>' ) );
+ printf( '<p class="portquiz" style="display:none; font-size:0.8em">* %s</p>', sprintf( __( 'According to %s', Postman::TEXT_DOMAIN ), '<a target="_blank" href="http://ww.downor.me/portquiz.net">portquiz.net</a>' ) );
printf( '<p class="ajax-loader" style="display:none"><img src="%s"/></p>', plugins_url( 'post-smtp/style/ajax-loader.gif' ) );
print '<section id="conclusion" style="display:none">';
print sprintf( '<h3>%s:</h3>', __( 'Summary', Postman::TEXT_DOMAIN ) );
diff --git a/Postman/Postman-Connectivity-Test/registered-domain-libs-master/generateEffectiveTLDs.php b/Postman/Postman-Connectivity-Test/registered-domain-libs-master/generateEffectiveTLDs.php
index f8c18a4..63acb79 100644
--- a/Postman/Postman-Connectivity-Test/registered-domain-libs-master/generateEffectiveTLDs.php
+++ b/Postman/Postman-Connectivity-Test/registered-domain-libs-master/generateEffectiveTLDs.php
@@ -150,7 +150,7 @@ error_reporting(E_ERROR);
$tldTree = array();
$list = file_get_contents(URL);
// $list = "bg\na.bg\n0.bg\n!c.bg\n";
-$lines = split("\n", $list);
+$lines = explode("\n", $list);
$licence = TRUE;
if ($format == "php") echo "<?php\n";
@@ -176,7 +176,7 @@ foreach ($lines as $line) {
}
// this must be a TLD
- $tldParts = split('\.', $line);
+ $tldParts = preg_split('\.', $line);
buildSubdomain($tldTree, $tldParts);
}
diff --git a/Postman/Postman-Email-Log/PostmanEmailLogController.php b/Postman/Postman-Email-Log/PostmanEmailLogController.php
index 2aacba6..5df618f 100644
--- a/Postman/Postman-Email-Log/PostmanEmailLogController.php
+++ b/Postman/Postman-Email-Log/PostmanEmailLogController.php
@@ -5,194 +5,193 @@ require_once 'PostmanEmailLogView.php';
/**
*
* @author jasonhendriks
- *
*/
class PostmanEmailLogController {
const RESEND_MAIL_AJAX_SLUG = 'postman_resend_mail';
private $rootPluginFilenameAndPath;
private $logger;
-
+
/**
*/
- function __construct($rootPluginFilenameAndPath) {
+ function __construct( $rootPluginFilenameAndPath ) {
$this->rootPluginFilenameAndPath = $rootPluginFilenameAndPath;
- $this->logger = new PostmanLogger ( get_class ( $this ) );
- if (PostmanOptions::getInstance ()->isMailLoggingEnabled ()) {
- add_action ( 'admin_menu', array (
+ $this->logger = new PostmanLogger( get_class( $this ) );
+ if ( PostmanOptions::getInstance()->isMailLoggingEnabled() ) {
+ add_action( 'admin_menu', array(
$this,
- 'postmanAddMenuItem'
+ 'postmanAddMenuItem',
) );
} else {
- $this->logger->trace ( 'not creating PostmanEmailLog admin menu item' );
+ $this->logger->trace( 'not creating PostmanEmailLog admin menu item' );
}
- if (PostmanUtils::isCurrentPagePostmanAdmin ( 'postman_email_log' )) {
- $this->logger->trace ( 'on postman email log page' );
+ if ( PostmanUtils::isCurrentPagePostmanAdmin( 'postman_email_log' ) ) {
+ $this->logger->trace( 'on postman email log page' );
// $this->logger->debug ( 'Registering ' . $actionName . ' Action Post handler' );
- add_action ( 'admin_post_delete', array (
+ add_action( 'admin_post_delete', array(
$this,
- 'delete_log_item'
+ 'delete_log_item',
) );
- add_action ( 'admin_post_view', array (
+ add_action( 'admin_post_view', array(
$this,
- 'view_log_item'
+ 'view_log_item',
) );
- add_action ( 'admin_post_transcript', array (
+ add_action( 'admin_post_transcript', array(
$this,
- 'view_transcript_log_item'
+ 'view_transcript_log_item',
) );
- add_action ( 'admin_init', array (
+ add_action( 'admin_init', array(
$this,
- 'on_admin_init'
+ 'on_admin_init',
) );
}
- if (is_admin ()) {
+ if ( is_admin() ) {
$actionName = self::RESEND_MAIL_AJAX_SLUG;
$fullname = 'wp_ajax_' . $actionName;
// $this->logger->debug ( 'Registering ' . 'wp_ajax_' . $fullname . ' Ajax handler' );
- add_action ( $fullname, array (
+ add_action( $fullname, array(
$this,
- 'resendMail'
+ 'resendMail',
) );
}
}
-
+
/**
*/
function on_admin_init() {
- $this->handleBulkAction ();
+ $this->handleBulkAction();
// register the stylesheet and javascript external resources
- $pluginData = apply_filters ( 'postman_get_plugin_metadata', null );
- wp_register_script ( 'postman_resend_email_script', plugins_url ( 'script/postman_resend_email_sript.js', $this->rootPluginFilenameAndPath ), array (
+ $pluginData = apply_filters( 'postman_get_plugin_metadata', null );
+ wp_register_script( 'postman_resend_email_script', plugins_url( 'script/postman_resend_email_sript.js', $this->rootPluginFilenameAndPath ), array(
PostmanViewController::JQUERY_SCRIPT,
- PostmanViewController::POSTMAN_SCRIPT
+ PostmanViewController::POSTMAN_SCRIPT,
), $pluginData ['version'] );
}
-
+
/**
*/
public function resendMail() {
// 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] );
-
+ $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] );
+
// Postman API: retrieve the result of sending this message from Postman
- $result = apply_filters ( 'postman_wp_mail_result', null );
+ $result = apply_filters( 'postman_wp_mail_result', null );
$transcript = $result ['transcript'];
-
+
// post-handling
- if ($success) {
- $this->logger->debug ( 'Email was successfully re-sent' );
+ if ( $success ) {
+ $this->logger->debug( 'Email was successfully re-sent' );
// the message was sent successfully, generate an appropriate message for the user
- $statusMessage = sprintf ( __ ( 'Your message was delivered (%d ms) to the SMTP server! Congratulations :)', Postman::TEXT_DOMAIN ), $result ['time'] );
-
+ $statusMessage = sprintf( __( 'Your message was delivered (%d ms) to the SMTP server! Congratulations :)', Postman::TEXT_DOMAIN ), $result ['time'] );
+
// compose the JSON response for the caller
- $response = array (
+ $response = array(
'message' => $statusMessage,
- 'transcript' => $transcript
+ 'transcript' => $transcript,
);
- $this->logger->trace ( 'AJAX response' );
- $this->logger->trace ( $response );
+ $this->logger->trace( 'AJAX response' );
+ $this->logger->trace( $response );
// send the JSON response
- wp_send_json_success ( $response );
+ wp_send_json_success( $response );
} else {
- $this->logger->error ( 'Email was not successfully re-sent - ' . $result ['exception']->getCode () );
+ $this->logger->error( 'Email was not successfully re-sent - ' . $result ['exception']->getCode() );
// the message was NOT sent successfully, generate an appropriate message for the user
- $statusMessage = $result ['exception']->getMessage ();
-
+ $statusMessage = $result ['exception']->getMessage();
+
// compose the JSON response for the caller
- $response = array (
+ $response = array(
'message' => $statusMessage,
- 'transcript' => $transcript
+ 'transcript' => $transcript,
);
- $this->logger->trace ( 'AJAX response' );
- $this->logger->trace ( $response );
+ $this->logger->trace( 'AJAX response' );
+ $this->logger->trace( $response );
// send the JSON response
- wp_send_json_error ( $response );
+ wp_send_json_error( $response );
}
} else {
// compose the JSON response for the caller
- $response = array ();
+ $response = array();
// send the JSON response
- wp_send_json_error ( $response );
+ wp_send_json_error( $response );
}
}
-
+
/**
* TODO move this somewhere reusable
*
- * @param unknown $parameterName
+ * @param unknown $parameterName
* @return unknown
*/
- private function getRequestParameter($parameterName) {
- if (isset ( $_POST [$parameterName] )) {
- $value = filter_var( $_POST [$parameterName], FILTER_SANITIZE_STRING );
- $this->logger->trace ( sprintf ( 'Found parameter "%s"', $parameterName ) );
- $this->logger->trace ( $value );
+ private function getRequestParameter( $parameterName ) {
+ if ( isset( $_POST [ $parameterName ] ) ) {
+ $value = filter_var( $_POST [ $parameterName ], FILTER_SANITIZE_STRING );
+ $this->logger->trace( sprintf( 'Found parameter "%s"', $parameterName ) );
+ $this->logger->trace( $value );
return $value;
}
}
-
+
/**
* From https://www.skyverge.com/blog/add-custom-bulk-action/
*/
function handleBulkAction() {
// only do this for administrators
- if (PostmanUtils::isAdmin () && isset ( $_REQUEST ['email_log_entry'] )) {
- $this->logger->trace ( 'handling bulk action' );
- if (wp_verify_nonce ( $_REQUEST ['_wpnonce'], 'bulk-email_log_entries' )) {
- $this->logger->trace ( sprintf ( 'nonce "%s" passed validation', $_REQUEST ['_wpnonce'] ) );
- if (isset ( $_REQUEST ['action'] ) && ($_REQUEST ['action'] == 'bulk_delete' || $_REQUEST ['action2'] == 'bulk_delete')) {
- $this->logger->trace ( sprintf ( 'handling bulk delete' ) );
- $purger = new PostmanEmailLogPurger ();
+ if ( PostmanUtils::isAdmin() && isset( $_REQUEST ['email_log_entry'] ) ) {
+ $this->logger->trace( 'handling bulk action' );
+ if ( wp_verify_nonce( $_REQUEST ['_wpnonce'], 'bulk-email_log_entries' ) ) {
+ $this->logger->trace( sprintf( 'nonce "%s" passed validation', $_REQUEST ['_wpnonce'] ) );
+ if ( isset( $_REQUEST ['action'] ) && ($_REQUEST ['action'] == 'bulk_delete' || $_REQUEST ['action2'] == 'bulk_delete') ) {
+ $this->logger->trace( sprintf( 'handling bulk delete' ) );
+ $purger = new PostmanEmailLogPurger();
$postids = $_REQUEST ['email_log_entry'];
foreach ( $postids as $postid ) {
- $purger->verifyLogItemExistsAndRemove ( $postid );
+ $purger->verifyLogItemExistsAndRemove( $postid );
}
- $mh = new PostmanMessageHandler ();
- $mh->addMessage ( __ ( 'Mail Log Entries were deleted.', Postman::TEXT_DOMAIN ) );
+ $mh = new PostmanMessageHandler();
+ $mh->addMessage( __( 'Mail Log Entries were deleted.', Postman::TEXT_DOMAIN ) );
} else {
- $this->logger->warn ( sprintf ( 'action "%s" not recognized', $_REQUEST ['action'] ) );
+ $this->logger->warn( sprintf( 'action "%s" not recognized', $_REQUEST ['action'] ) );
}
} else {
- $this->logger->warn ( sprintf ( 'nonce "%s" failed validation', $_REQUEST ['_wpnonce'] ) );
+ $this->logger->warn( sprintf( 'nonce "%s" failed validation', $_REQUEST ['_wpnonce'] ) );
}
- $this->redirectToLogPage ();
+ $this->redirectToLogPage();
}
}
-
+
/**
*/
function delete_log_item() {
// only do this for administrators
- if (PostmanUtils::isAdmin ()) {
- $this->logger->trace ( 'handling delete item' );
+ if ( PostmanUtils::isAdmin() ) {
+ $this->logger->trace( 'handling delete item' );
$postid = $_REQUEST ['email'];
- if (wp_verify_nonce ( $_REQUEST ['_wpnonce'], 'delete_email_log_item_' . $postid )) {
- $this->logger->trace ( sprintf ( 'nonce "%s" passed validation', $_REQUEST ['_wpnonce'] ) );
- $purger = new PostmanEmailLogPurger ();
- $purger->verifyLogItemExistsAndRemove ( $postid );
- $mh = new PostmanMessageHandler ();
- $mh->addMessage ( __ ( 'Mail Log Entry was deleted.', Postman::TEXT_DOMAIN ) );
+ if ( wp_verify_nonce( $_REQUEST ['_wpnonce'], 'delete_email_log_item_' . $postid ) ) {
+ $this->logger->trace( sprintf( 'nonce "%s" passed validation', $_REQUEST ['_wpnonce'] ) );
+ $purger = new PostmanEmailLogPurger();
+ $purger->verifyLogItemExistsAndRemove( $postid );
+ $mh = new PostmanMessageHandler();
+ $mh->addMessage( __( 'Mail Log Entry was deleted.', Postman::TEXT_DOMAIN ) );
} else {
- $this->logger->warn ( sprintf ( 'nonce "%s" failed validation', $_REQUEST ['_wpnonce'] ) );
+ $this->logger->warn( sprintf( 'nonce "%s" failed validation', $_REQUEST ['_wpnonce'] ) );
}
- $this->redirectToLogPage ();
+ $this->redirectToLogPage();
}
}
-
+
/**
*/
function view_log_item() {
// only do this for administrators
- if (PostmanUtils::isAdmin ()) {
- $this->logger->trace ( 'handling view item' );
+ if ( PostmanUtils::isAdmin() ) {
+ $this->logger->trace( 'handling view item' );
$postid = $_REQUEST ['email'];
- $post = get_post ( $postid );
- $meta_values = get_post_meta ( $postid );
+ $post = get_post( $postid );
+ $meta_values = get_post_meta( $postid );
// https://css-tricks.com/examples/hrs/
print '<html><head><style>body {font-family: monospace;} hr {
border: 0;
@@ -200,110 +199,110 @@ class PostmanEmailLogController {
background: #bbb;
}</style></head><body>';
print '<table>';
- if (! empty ( $meta_values ['from_header'] [0] )) {
- printf ( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x ( 'From', 'Who is this message From?', Postman::TEXT_DOMAIN ), esc_html ( $meta_values ['from_header'] [0] ) );
+ if ( ! empty( $meta_values ['from_header'] [0] ) ) {
+ printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'From', 'Who is this message From?', Postman::TEXT_DOMAIN ), esc_html( $meta_values ['from_header'] [0] ) );
}
// show the To header (it's optional)
- if (! empty ( $meta_values ['to_header'] [0] )) {
- printf ( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x ( 'To', 'Who is this message To?', Postman::TEXT_DOMAIN ), esc_html ( $meta_values ['to_header'] [0] ) );
+ if ( ! empty( $meta_values ['to_header'] [0] ) ) {
+ printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'To', 'Who is this message To?', Postman::TEXT_DOMAIN ), esc_html( $meta_values ['to_header'] [0] ) );
}
// show the Cc header (it's optional)
- if (! empty ( $meta_values ['cc_header'] [0] )) {
- printf ( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x ( 'Cc', 'Who is this message Cc\'d to?', Postman::TEXT_DOMAIN ), esc_html ( $meta_values ['cc_header'] [0] ) );
+ if ( ! empty( $meta_values ['cc_header'] [0] ) ) {
+ printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Cc', 'Who is this message Cc\'d to?', Postman::TEXT_DOMAIN ), esc_html( $meta_values ['cc_header'] [0] ) );
}
// show the Bcc header (it's optional)
- if (! empty ( $meta_values ['bcc_header'] [0] )) {
- printf ( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x ( 'Bcc', 'Who is this message Bcc\'d to?', Postman::TEXT_DOMAIN ), esc_html ( $meta_values ['bcc_header'] [0] ) );
+ if ( ! empty( $meta_values ['bcc_header'] [0] ) ) {
+ printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Bcc', 'Who is this message Bcc\'d to?', Postman::TEXT_DOMAIN ), esc_html( $meta_values ['bcc_header'] [0] ) );
}
// show the Reply-To header (it's optional)
- if (! empty ( $meta_values ['reply_to_header'] [0] )) {
- printf ( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', __ ( 'Reply-To', Postman::TEXT_DOMAIN ), esc_html ( $meta_values ['reply_to_header'] [0] ) );
+ if ( ! empty( $meta_values ['reply_to_header'] [0] ) ) {
+ printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', __( 'Reply-To', Postman::TEXT_DOMAIN ), esc_html( $meta_values ['reply_to_header'] [0] ) );
}
- printf ( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x ( 'Date', 'What is the date today?', Postman::TEXT_DOMAIN ), $post->post_date );
- printf ( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x ( 'Subject', 'What is the subject of this message?', Postman::TEXT_DOMAIN ), esc_html ( $post->post_title ) );
+ printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Date', 'What is the date today?', Postman::TEXT_DOMAIN ), $post->post_date );
+ printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Subject', 'What is the subject of this message?', Postman::TEXT_DOMAIN ), esc_html( $post->post_title ) );
// The Transport UI is always there, in more recent versions that is
- if (! empty ( $meta_values ['transport_uri'] [0] )) {
- printf ( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x ( 'Delivery-URI', 'What is the unique URI of the configuration?', Postman::TEXT_DOMAIN ), esc_html ( $meta_values ['transport_uri'] [0] ) );
+ if ( ! empty( $meta_values ['transport_uri'] [0] ) ) {
+ printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Delivery-URI', 'What is the unique URI of the configuration?', Postman::TEXT_DOMAIN ), esc_html( $meta_values ['transport_uri'] [0] ) );
}
print '</table>';
print '<hr/>';
print '<pre>';
- print esc_html ( $post->post_content );
+ print esc_html( $post->post_content );
print '</pre>';
print '</body></html>';
- die ();
+ die();
}
}
-
+
/**
*/
function view_transcript_log_item() {
// only do this for administrators
- if (PostmanUtils::isAdmin ()) {
- $this->logger->trace ( 'handling view transcript item' );
+ if ( PostmanUtils::isAdmin() ) {
+ $this->logger->trace( 'handling view transcript item' );
$postid = $_REQUEST ['email'];
- $post = get_post ( $postid );
- $meta_values = get_post_meta ( $postid );
+ $post = get_post( $postid );
+ $meta_values = get_post_meta( $postid );
// https://css-tricks.com/examples/hrs/
print '<html><head><style>body {font-family: monospace;} hr {
border: 0;
border-bottom: 1px dashed #ccc;
background: #bbb;
}</style></head><body>';
- printf ( '<p>%s</p>', __ ( 'This is the conversation between Postman and the mail server. It can be useful for diagnosing problems. <b>DO NOT</b> post it on-line, it may contain your account password.', Postman::TEXT_DOMAIN ) );
+ printf( '<p>%s</p>', __( 'This is the conversation between Postman and the mail server. It can be useful for diagnosing problems. <b>DO NOT</b> post it on-line, it may contain your account password.', Postman::TEXT_DOMAIN ) );
print '<hr/>';
print '<pre>';
- if (! empty ( $meta_values ['session_transcript'] [0] )) {
- print esc_html ( $meta_values ['session_transcript'] [0] );
+ if ( ! empty( $meta_values ['session_transcript'] [0] ) ) {
+ print esc_html( $meta_values ['session_transcript'] [0] );
} else {
/* Translators: Meaning "Not Applicable" */
- print __ ( 'n/a', Postman::TEXT_DOMAIN );
+ print __( 'n/a', Postman::TEXT_DOMAIN );
}
print '</pre>';
print '</body></html>';
- die ();
+ die();
}
}
-
+
/**
* For whatever reason, PostmanUtils::get..url doesn't work here? :(
*/
function redirectToLogPage() {
- PostmanUtils::redirect ( PostmanUtils::POSTMAN_EMAIL_LOG_PAGE_RELATIVE_URL );
- die ();
+ PostmanUtils::redirect( PostmanUtils::POSTMAN_EMAIL_LOG_PAGE_RELATIVE_URL );
+ die();
}
-
+
/**
* Register the page
*/
function postmanAddMenuItem() {
// only do this for administrators
- if (PostmanUtils::isAdmin ()) {
- $this->logger->trace ( 'created PostmanEmailLog admin menu item' );
+ if ( PostmanUtils::isAdmin() ) {
+ $this->logger->trace( 'created PostmanEmailLog admin menu item' );
/* Translators where (%s) is the name of the plugin */
- $page = add_management_page ( sprintf ( __ ( '%s Email Log', Postman::TEXT_DOMAIN ), __ ( 'Postman SMTP', Postman::TEXT_DOMAIN ) ), _x ( 'Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN ), 'read_private_posts', 'postman_email_log', array (
+ $page = add_management_page( sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) ), _x( 'Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN ), 'read_private_posts', 'postman_email_log', array(
$this,
- 'postman_render_email_page'
+ 'postman_render_email_page',
) );
// When the plugin options page is loaded, also load the stylesheet
- add_action ( 'admin_print_styles-' . $page, array (
+ add_action( 'admin_print_styles-' . $page, array(
$this,
- 'postman_email_log_enqueue_resources'
+ 'postman_email_log_enqueue_resources',
) );
}
}
function postman_email_log_enqueue_resources() {
- $pluginData = apply_filters ( 'postman_get_plugin_metadata', null );
- wp_register_style ( 'postman_email_log', plugins_url ( 'style/postman-email-log.css', $this->rootPluginFilenameAndPath ), null, $pluginData ['version'] );
- wp_enqueue_style ( 'postman_email_log' );
- wp_enqueue_script ( 'postman_resend_email_script' );
- wp_enqueue_script ( 'sprintf' );
- wp_localize_script ( 'postman_resend_email_script', 'postman_js_email_was_resent', __ ( 'Email was successfully resent (but without attachments)', Postman::TEXT_DOMAIN ) );
+ $pluginData = apply_filters( 'postman_get_plugin_metadata', null );
+ wp_register_style( 'postman_email_log', plugins_url( 'style/postman-email-log.css', $this->rootPluginFilenameAndPath ), null, $pluginData ['version'] );
+ wp_enqueue_style( 'postman_email_log' );
+ wp_enqueue_script( 'postman_resend_email_script' );
+ wp_enqueue_script( 'sprintf' );
+ wp_localize_script( 'postman_resend_email_script', 'postman_js_email_was_resent', __( 'Email was successfully resent (but without attachments)', Postman::TEXT_DOMAIN ) );
/* Translators: Where %s is an error message */
- wp_localize_script ( 'postman_resend_email_script', 'postman_js_email_not_resent', __ ( 'Email could not be resent. Error: %s', Postman::TEXT_DOMAIN ) );
- wp_localize_script ( 'postman_resend_email_script', 'postman_js_resend_label', __ ( 'Resend', Postman::TEXT_DOMAIN ) );
+ wp_localize_script( 'postman_resend_email_script', 'postman_js_email_not_resent', __( 'Email could not be resent. Error: %s', Postman::TEXT_DOMAIN ) );
+ wp_localize_script( 'postman_resend_email_script', 'postman_js_resend_label', __( 'Resend', Postman::TEXT_DOMAIN ) );
}
-
+
/**
* *************************** RENDER TEST PAGE ********************************
* ******************************************************************************
@@ -315,28 +314,28 @@ class PostmanEmailLogController {
* it's the way the list tables are used in the WordPress core.
*/
function postman_render_email_page() {
-
+
// Create an instance of our package class...
- $testListTable = new PostmanEmailLogView ();
- wp_enqueue_script ( 'postman_resend_email_script' );
+ $testListTable = new PostmanEmailLogView();
+ wp_enqueue_script( 'postman_resend_email_script' );
// Fetch, prepare, sort, and filter our data...
- $testListTable->prepare_items ();
-
+ $testListTable->prepare_items();
+
?>
<div class="wrap">
<div id="icon-users" class="icon32">
<br />
</div>
- <h2><?php
-/* Translators where (%s) is the name of the plugin */
- echo sprintf ( __ ( '%s Email Log', Postman::TEXT_DOMAIN ), __ ( 'Postman SMTP', Postman::TEXT_DOMAIN ) )?></h2>
+ <h2><?php
+ /* Translators where (%s) is the name of the plugin */
+ echo sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) )?></h2>
<div
style="background: #ECECEC; border: 1px solid #CCC; padding: 0 10px; margin-top: 5px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;">
<p><?php
-
- echo __ ( 'This is a record of deliveries made to the mail server. It does not neccessarily indicate sucessful delivery to the recipient.', Postman::TEXT_DOMAIN )?></p>
+
+ echo __( 'This is a record of deliveries made to the mail server. It does not neccessarily indicate sucessful delivery to the recipient.', Postman::TEXT_DOMAIN )?></p>
</div>
<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
@@ -345,10 +344,10 @@ class PostmanEmailLogController {
<input type="hidden" name="page"
value="<?php echo filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING ); ?>" />
<!-- Now we can render the completed list table -->
- <?php $testListTable->display()?>
- </form>
-
- <?php add_thickbox(); ?>
+ <?php $testListTable->display()?>
+ </form>
+
+ <?php add_thickbox(); ?>
</div>
<?php
diff --git a/Postman/Postman-Mail/PostmanMandrillTransport.php b/Postman/Postman-Mail/PostmanMandrillTransport.php
index bcc0cc3..795abfd 100644
--- a/Postman/Postman-Mail/PostmanMandrillTransport.php
+++ b/Postman/Postman-Mail/PostmanMandrillTransport.php
@@ -235,7 +235,7 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements
*/
public function printMandrillAuthSectionInfo() {
/* Translators: Where (1) is the service URL and (2) is the service name and (3) is a api key URL */
- printf ( '<p id="wizard_mandrill_auth_help">%s</p>', sprintf ( __ ( 'Create an account at <a href="%1$s" target="_new">%2$s</a> and enter <a href="%3$s" target="_new">an API key</a> below.', Postman::TEXT_DOMAIN ), 'https://mandrillapp.com', 'Mandrillapp.com', 'https://mandrillapp.com/settings' ) );
+ printf ( '<p id="wizard_mandrill_auth_help">%s</p>', sprintf ( __ ( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.', Postman::TEXT_DOMAIN ), 'https://mandrillapp.com', 'Mandrillapp.com', 'https://mandrillapp.com/settings' ) );
}
/**
diff --git a/Postman/Postman-Mail/PostmanSendGridTransport.php b/Postman/Postman-Mail/PostmanSendGridTransport.php
index 125217b..358fcc5 100644
--- a/Postman/Postman-Mail/PostmanSendGridTransport.php
+++ b/Postman/Postman-Mail/PostmanSendGridTransport.php
@@ -186,7 +186,7 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements
}
public function printSendGridAuthSectionInfo() {
/* Translators: Where (1) is the service URL and (2) is the service name and (3) is a api key URL */
- printf ( '<p id="wizard_sendgrid_auth_help">%s</p>', sprintf ( __ ( 'Create an account at <a href="%1$s" target="_new">%2$s</a> and enter <a href="%3$s" target="_new">an API key</a> below.', Postman::TEXT_DOMAIN ), 'https://sendgrid.com', 'SendGrid.com', 'https://app.sendgrid.com/settings/api_keys' ) );
+ printf ( '<p id="wizard_sendgrid_auth_help">%s</p>', sprintf ( __ ( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.', Postman::TEXT_DOMAIN ), 'https://sendgrid.com', 'SendGrid.com', 'https://app.sendgrid.com/settings/api_keys' ) );
}
/**
diff --git a/Postman/Postman-Mail/PostmanSmtpModuleTransport.php b/Postman/Postman-Mail/PostmanSmtpModuleTransport.php
index 2526d92..3bd1ad2 100644
--- a/Postman/Postman-Mail/PostmanSmtpModuleTransport.php
+++ b/Postman/Postman-Mail/PostmanSmtpModuleTransport.php
@@ -528,7 +528,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
$inputValue = (null !== $this->options->getEnvelopeSender() ? esc_attr( $this->options->getEnvelopeSender() ) : '');
$requiredLabel = __( 'Required', Postman::TEXT_DOMAIN );
$envelopeFromMessage = __( 'This address, like the <b>return address</b> printed on an envelope, identifies the account owner to the SMTP server.', Postman::TEXT_DOMAIN );
- $spfMessage = sprintf( __( 'For reliable delivery, this domain must specify an <a target="_new" href="%s">SPF record</a> permitting the use of the SMTP server named above.', Postman::TEXT_DOMAIN ), 'https://www.mail-tester.com/spf/' );
+ $spfMessage = sprintf( __( 'For reliable delivery, this domain must specify an <a target="_blank" href="%s">SPF record</a> permitting the use of the SMTP server named above.', Postman::TEXT_DOMAIN ), 'https://www.mail-tester.com/spf/' );
printf( '<input type="email" id="input_envelope_sender_email" name="postman_options[envelope_sender]" value="%s" size="40" class="required" placeholder="%s"/> <br/><span class="postman_input_description">%s %s</span>', $inputValue, $requiredLabel, $envelopeFromMessage, $spfMessage );
}
diff --git a/Postman/PostmanConfigTextHelper.php b/Postman/PostmanConfigTextHelper.php
index 1a74d9d..66a21c8 100644
--- a/Postman/PostmanConfigTextHelper.php
+++ b/Postman/PostmanConfigTextHelper.php
@@ -30,10 +30,10 @@ if ( ! class_exists( 'PostmanAbstractConfigTextHelper' ) ) {
public function getOAuthHelp() {
$attention = __( 'Attention' );
/* translators: parameters available are 1=portal-url, 2=portal-name, 3=clientId-name, 4=clientSecret-name, 5=callbackUrl, 6=service-name, 7=portal-application (e.g. Open the Google Developer Console, create a Client ID for web application using the URL's displayed below, and copy the Client ID and Client Secret here.) */
- $errorMessage = sprintf( __( 'Open the <a href="%1$s" target="_new">%2$s</a>, create <b>%7$s</b> with the values displayed below, and copy the generated %3$s and %4$s here.', Postman::TEXT_DOMAIN ), $this->getApplicationPortalUrl(), $this->getApplicationPortalName(), $this->getClientIdLabel(), $this->getClientSecretLabel(), $this->getCallbackUrlLabel(), $this->getOwnerName(), $this->getApplicationDescription() );
+ $errorMessage = sprintf( __( 'Open the <a href="%1$s" target="_blank">%2$s</a>, create <b>%7$s</b> with the values displayed below, and copy the generated %3$s and %4$s here.', Postman::TEXT_DOMAIN ), $this->getApplicationPortalUrl(), $this->getApplicationPortalName(), $this->getClientIdLabel(), $this->getClientSecretLabel(), $this->getCallbackUrlLabel(), $this->getOwnerName(), $this->getApplicationDescription() );
$text = sprintf( '<b style="color:red">%s!</b> %s', $attention, $errorMessage );
/* translators: parameters available are 1=clientId-name, 2=service-name, 3=FAQ-URL, 4=Video-URL (e.g. See How do I get a Google Client ID? in the F.A.Q.) */
- $howToTemplate = __( 'See <a href="%3$s" target="_new">How do I get a %1$s %2$s?</a> in the F.A.Q. or <a href="%4$s" target="_new">watch our How-To video 📺</a>.', Postman::TEXT_DOMAIN );
+ $howToTemplate = __( 'See <a href="%3$s" target="_blank">How do I get a %1$s %2$s?</a> in the F.A.Q. or <a href="%4$s" target="_blank">watch our How-To video 📺</a>.', Postman::TEXT_DOMAIN );
$text .= sprintf( ' %s', sprintf( $howToTemplate, $this->getOwnerName(), $this->getClientIdLabel(), 'https://wordpress.org/plugins/post-smtp/faq/', 'https://vimeo.com/128589255' ) );
return $text;
}
diff --git a/Postman/PostmanUtils.php b/Postman/PostmanUtils.php
index 77e681f..70a0ec4 100644
--- a/Postman/PostmanUtils.php
+++ b/Postman/PostmanUtils.php
@@ -5,107 +5,103 @@ require_once 'PostmanState.php';
/**
*
* @author jasonhendriks
- *
*/
class PostmanUtils {
private static $logger;
private static $emailValidator;
-
- //
- const POSTMAN_SETTINGS_PAGE_STUB = 'postman';
+
+ const POSTMAN_SETTINGS_PAGE_STUB = 'postman';
const REQUEST_OAUTH2_GRANT_SLUG = 'postman/requestOauthGrant';
const POSTMAN_EMAIL_LOG_PAGE_STUB = 'postman_email_log';
-
+
// redirections back to THIS SITE should always be relative because of IIS bug
const POSTMAN_EMAIL_LOG_PAGE_RELATIVE_URL = 'tools.php?page=postman_email_log';
const POSTMAN_HOME_PAGE_RELATIVE_URL = 'options-general.php?page=postman';
-
+
// custom admin post page
const ADMIN_POST_OAUTH2_GRANT_URL_PART = 'admin-post.php?action=postman/requestOauthGrant';
-
- //
- const NO_ECHO = false;
-
+
+ const NO_ECHO = false;
+
/**
* Initialize the Logger
*/
public static function staticInit() {
- PostmanUtils::$logger = new PostmanLogger ( 'PostmanUtils' );
+ PostmanUtils::$logger = new PostmanLogger( 'PostmanUtils' );
}
-
+
/**
*
- * @param unknown $slug
+ * @param unknown $slug
* @return string
*/
- public static function getPageUrl($slug) {
- return get_admin_url () . 'options-general.php?page=' . $slug;
+ public static function getPageUrl( $slug ) {
+ return get_admin_url() . 'options-general.php?page=' . $slug;
}
-
+
/**
* Returns an escaped URL
*/
public static function getGrantOAuthPermissionUrl() {
- return get_admin_url () . self::ADMIN_POST_OAUTH2_GRANT_URL_PART;
+ return get_admin_url() . self::ADMIN_POST_OAUTH2_GRANT_URL_PART;
}
-
+
/**
* Returns an escaped URL
*/
public static function getEmailLogPageUrl() {
- return menu_page_url ( self::POSTMAN_EMAIL_LOG_PAGE_STUB, self::NO_ECHO );
+ return menu_page_url( self::POSTMAN_EMAIL_LOG_PAGE_STUB, self::NO_ECHO );
}
-
+
/**
* Returns an escaped URL
*/
public static function getSettingsPageUrl() {
- return menu_page_url ( self::POSTMAN_SETTINGS_PAGE_STUB, self::NO_ECHO );
+ return menu_page_url( self::POSTMAN_SETTINGS_PAGE_STUB, self::NO_ECHO );
}
-
- //
- public static function isCurrentPagePostmanAdmin($page = 'postman') {
- $result = (isset ( $_REQUEST ['page'] ) && substr ( $_REQUEST ['page'], 0, strlen ( $page ) ) == $page);
+
+ public static function isCurrentPagePostmanAdmin( $page = 'postman' ) {
+ $result = (isset( $_REQUEST ['page'] ) && substr( $_REQUEST ['page'], 0, strlen( $page ) ) == $page);
return $result;
}
/**
* from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php
*
- * @param unknown $haystack
- * @param unknown $needle
+ * @param unknown $haystack
+ * @param unknown $needle
* @return boolean
*/
- public static function startsWith($haystack, $needle) {
- $length = strlen ( $needle );
- return (substr ( $haystack, 0, $length ) === $needle);
+ public static function startsWith( $haystack, $needle ) {
+ $length = strlen( $needle );
+ return (substr( $haystack, 0, $length ) === $needle);
}
/**
* from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php
*
- * @param unknown $haystack
- * @param unknown $needle
+ * @param unknown $haystack
+ * @param unknown $needle
* @return boolean
*/
- public static function endsWith($haystack, $needle) {
- $length = strlen ( $needle );
- if ($length == 0) {
+ public static function endsWith( $haystack, $needle ) {
+ $length = strlen( $needle );
+ if ( $length == 0 ) {
return true;
}
- return (substr ( $haystack, - $length ) === $needle);
+ return (substr( $haystack, - $length ) === $needle);
}
- public static function obfuscatePassword($password) {
- return str_repeat ( '*', strlen ( $password ) );
+ public static function obfuscatePassword( $password ) {
+ return str_repeat( '*', strlen( $password ) );
}
/**
* Detect if the host is NOT a domain name
*
- * @param unknown $ipAddress
+ * @param unknown $ipAddress
* @return number
*/
- public static function isHostAddressNotADomainName($host) {
+ public static function isHostAddressNotADomainName( $host ) {
// IPv4 / IPv6 test from http://stackoverflow.com/a/17871737/4368109
- $ipv6Detected = preg_match ( '/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/', $host );
- $ipv4Detected = preg_match ( '/((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])/', $host );
+ $ipv6Detected = preg_match( '/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/', $host );
+ $ipv4Detected = preg_match( '/((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])/', $host );
return $ipv4Detected || $ipv6Detected;
// from http://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
// return preg_match ( '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9‌​]{2}|2[0-4][0-9]|25[0-5])$/', $ipAddress );
@@ -115,44 +111,44 @@ class PostmanUtils {
* Inside WordPress we can use wp_remote_post().
* Outside WordPress, not so much.
*
- * @param unknown $url
- * @param unknown $args
+ * @param unknown $url
+ * @param unknown $args
* @return the HTML body
*/
- static function remotePostGetBodyOnly($url, $parameters, array $headers = array()) {
- $response = PostmanUtils::remotePost ( $url, $parameters, $headers );
- $theBody = wp_remote_retrieve_body ( $response );
+ static function remotePostGetBodyOnly( $url, $parameters, array $headers = array() ) {
+ $response = PostmanUtils::remotePost( $url, $parameters, $headers );
+ $theBody = wp_remote_retrieve_body( $response );
return $theBody;
}
-
+
/**
* Makes the outgoing HTTP requests
* Inside WordPress we can use wp_remote_post().
* Outside WordPress, not so much.
*
- * @param unknown $url
- * @param unknown $args
+ * @param unknown $url
+ * @param unknown $args
* @return the HTTP response
*/
- static function remotePost($url, $parameters = array(), array $headers = array()) {
- $args = array (
- 'timeout' => PostmanOptions::getInstance ()->getConnectionTimeout (),
+ static function remotePost( $url, $parameters = array(), array $headers = array() ) {
+ $args = array(
+ 'timeout' => PostmanOptions::getInstance()->getConnectionTimeout(),
'headers' => $headers,
- 'body' => $parameters
+ 'body' => $parameters,
);
- if (PostmanUtils::$logger->isTrace ()) {
- PostmanUtils::$logger->trace ( sprintf ( 'Posting to %s', $url ) );
- PostmanUtils::$logger->trace ( 'Post header:' );
- PostmanUtils::$logger->trace ( $headers );
- PostmanUtils::$logger->trace ( 'Posting args:' );
- PostmanUtils::$logger->trace ( $parameters );
+ if ( PostmanUtils::$logger->isTrace() ) {
+ PostmanUtils::$logger->trace( sprintf( 'Posting to %s', $url ) );
+ PostmanUtils::$logger->trace( 'Post header:' );
+ PostmanUtils::$logger->trace( $headers );
+ PostmanUtils::$logger->trace( 'Posting args:' );
+ PostmanUtils::$logger->trace( $parameters );
}
- $response = wp_remote_post ( $url, $args );
-
+ $response = wp_remote_post( $url, $args );
+
// pre-process the response
- if (is_wp_error ( $response )) {
- PostmanUtils::$logger->error ( $response->get_error_message () );
- throw new Exception ( 'Error executing wp_remote_post: ' . $response->get_error_message () );
+ if ( is_wp_error( $response ) ) {
+ PostmanUtils::$logger->error( $response->get_error_message() );
+ throw new Exception( 'Error executing wp_remote_post: ' . $response->get_error_message() );
} else {
return $response;
}
@@ -161,51 +157,51 @@ class PostmanUtils {
* A facade function that handles redirects.
* Inside WordPress we can use wp_redirect(). Outside WordPress, not so much. **Load it before postman-core.php**
*
- * @param unknown $url
+ * @param unknown $url
*/
- static function redirect($url) {
+ static function redirect( $url ) {
// redirections back to THIS SITE should always be relative because of IIS bug
- if (PostmanUtils::$logger->isTrace ()) {
- PostmanUtils::$logger->trace ( sprintf ( "Redirecting to '%s'", $url ) );
+ if ( PostmanUtils::$logger->isTrace() ) {
+ PostmanUtils::$logger->trace( sprintf( "Redirecting to '%s'", $url ) );
}
- wp_redirect ( $url );
- exit ();
+ wp_redirect( $url );
+ exit();
}
- static function parseBoolean($var) {
- return filter_var ( $var, FILTER_VALIDATE_BOOLEAN );
+ static function parseBoolean( $var ) {
+ return filter_var( $var, FILTER_VALIDATE_BOOLEAN );
}
- static function logMemoryUse($startingMemory, $description) {
- PostmanUtils::$logger->trace ( sprintf ( $description . ' memory used: %s', PostmanUtils::roundBytes ( memory_get_usage () - $startingMemory ) ) );
+ static function logMemoryUse( $startingMemory, $description ) {
+ PostmanUtils::$logger->trace( sprintf( $description . ' memory used: %s', PostmanUtils::roundBytes( memory_get_usage() - $startingMemory ) ) );
}
-
+
/**
* Rounds the bytes returned from memory_get_usage to smaller amounts used IEC binary prefixes
* See http://en.wikipedia.org/wiki/Binary_prefix
*
- * @param unknown $size
+ * @param unknown $size
* @return string
*/
- static function roundBytes($size) {
- $unit = array (
+ static function roundBytes( $size ) {
+ $unit = array(
'B',
'KiB',
'MiB',
'GiB',
'TiB',
- 'PiB'
+ 'PiB',
);
- return @round ( $size / pow ( 1024, ($i = floor ( log ( $size, 1024 ) )) ), 2 ) . ' ' . $unit [$i];
+ return @round( $size / pow( 1024, ($i = floor( log( $size, 1024 ) )) ), 2 ) . ' ' . $unit [ $i ];
}
-
+
/**
* Unblock threads waiting on lock()
*/
static function unlock() {
- if (PostmanState::getInstance ()->isFileLockingEnabled ()) {
- PostmanUtils::deleteLockFile ();
+ if ( PostmanState::getInstance()->isFileLockingEnabled() ) {
+ PostmanUtils::deleteLockFile();
}
}
-
+
/**
* Processes will block on this method until unlock() is called
* Inspired by http://cubicspot.blogspot.ca/2010/10/forget-flock-and-system-v-semaphores.html
@@ -213,56 +209,56 @@ class PostmanUtils {
* @throws Exception
*/
static function lock() {
- if (PostmanState::getInstance ()->isFileLockingEnabled ()) {
+ if ( PostmanState::getInstance()->isFileLockingEnabled() ) {
$attempts = 0;
while ( true ) {
// create the semaphore
- $lock = PostmanUtils::createLockFile ();
- if ($lock) {
+ $lock = PostmanUtils::createLockFile();
+ if ( $lock ) {
// if we got the lock, return
return;
} else {
$attempts ++;
- if ($attempts >= 10) {
- throw new Exception ( sprintf ( 'Could not create lockfile %s', '/tmp' . '/.postman.lock' ) );
+ if ( $attempts >= 10 ) {
+ throw new Exception( sprintf( 'Could not create lockfile %s', '/tmp' . '/.postman.lock' ) );
}
- sleep ( 1 );
+ sleep( 1 );
}
}
}
}
- static function deleteLockFile($tempDirectory = null) {
- $path = PostmanUtils::calculateTemporaryLockPath ( $tempDirectory );
- $success = @unlink ( $path );
- if (PostmanUtils::$logger->isTrace ()) {
- PostmanUtils::$logger->trace ( sprintf ( 'Deleting file %s : %s', $path, $success ) );
+ static function deleteLockFile( $tempDirectory = null ) {
+ $path = PostmanUtils::calculateTemporaryLockPath( $tempDirectory );
+ $success = @unlink( $path );
+ if ( PostmanUtils::$logger->isTrace() ) {
+ PostmanUtils::$logger->trace( sprintf( 'Deleting file %s : %s', $path, $success ) );
}
return $success;
}
- static function createLockFile($tempDirectory = null) {
- $path = PostmanUtils::calculateTemporaryLockPath ( $tempDirectory );
- $success = @fopen ( $path, 'xb' );
- if (PostmanUtils::$logger->isTrace ()) {
- PostmanUtils::$logger->trace ( sprintf ( 'Creating file %s : %s', $path, $success ) );
+ static function createLockFile( $tempDirectory = null ) {
+ $path = PostmanUtils::calculateTemporaryLockPath( $tempDirectory );
+ $success = @fopen( $path, 'xb' );
+ if ( PostmanUtils::$logger->isTrace() ) {
+ PostmanUtils::$logger->trace( sprintf( 'Creating file %s : %s', $path, $success ) );
}
return $success;
}
-
+
/**
* Creates the pathname of the lockfile
*
- * @param unknown $tempDirectory
+ * @param unknown $tempDirectory
* @return string
*/
- private static function calculateTemporaryLockPath($tempDirectory) {
- if (empty ( $tempDirectory )) {
- $options = PostmanOptions::getInstance ();
- $tempDirectory = $options->getTempDirectory ();
+ private static function calculateTemporaryLockPath( $tempDirectory ) {
+ if ( empty( $tempDirectory ) ) {
+ $options = PostmanOptions::getInstance();
+ $tempDirectory = $options->getTempDirectory();
}
- $fullPath = sprintf ( '%s/.postman_%s.lock', $tempDirectory, self::generateUniqueLockKey () );
+ $fullPath = sprintf( '%s/.postman_%s.lock', $tempDirectory, self::generateUniqueLockKey() );
return $fullPath;
}
-
+
/**
*
* @return string
@@ -270,24 +266,24 @@ class PostmanUtils {
private static function generateUniqueLockKey() {
// for single sites, use the network_site_url to generate the key because
// it is unique for every wordpress site unlike the blog ID which may be the same
- $key = hash ( 'crc32', network_site_url ( '/' ) );
+ $key = hash( 'crc32', network_site_url( '/' ) );
// TODO for multisites
// if the subsite is sharing the config - use the network_site_url of site 0
// if the subsite has its own config - use the network_site_url of the subsite
return $key;
}
-
+
/**
* From http://stackoverflow.com/a/381275/4368109
*
- * @param unknown $text
+ * @param unknown $text
* @return boolean
*/
- public static function isEmpty($text) {
+ public static function isEmpty( $text ) {
// Function for basic field validation (present and neither empty nor only white space
- return (! isset ( $text ) || trim ( $text ) === '');
+ return ( ! isset( $text ) || trim( $text ) === '');
}
-
+
/**
* Warning! This can only be called on hook 'init' or later
*/
@@ -304,21 +300,21 @@ class PostmanUtils {
*
* Good to know.
*/
- $logger = PostmanUtils::$logger = new PostmanLogger ( 'PostmanUtils' );
- if ($logger->isTrace ()) {
- $logger->trace ( 'calling current_user_can' );
+ $logger = PostmanUtils::$logger = new PostmanLogger( 'PostmanUtils' );
+ if ( $logger->isTrace() ) {
+ $logger->trace( 'calling current_user_can' );
}
- return current_user_can ( Postman::MANAGE_POSTMAN_CAPABILITY_NAME ) && is_admin ();
+ return current_user_can( Postman::MANAGE_POSTMAN_CAPABILITY_NAME ) && is_admin();
}
-
+
/**
* Validate an e-mail address
*
- * @param unknown $email
+ * @param unknown $email
* @return number
*/
- static function validateEmail($email) {
- if (PostmanOptions::getInstance ()->isEmailValidationDisabled ()) {
+ static function validateEmail( $email ) {
+ if ( PostmanOptions::getInstance()->isEmailValidationDisabled() ) {
return true;
}
require_once 'Postman-Mail/Zend-1.12.10/Exception.php';
@@ -329,134 +325,130 @@ class PostmanUtils {
require_once 'Postman-Mail/Zend-1.12.10/Validate/Ip.php';
require_once 'Postman-Mail/Zend-1.12.10/Validate/Hostname.php';
require_once 'Postman-Mail/Zend-1.12.10/Validate/EmailAddress.php';
- if (! isset ( PostmanUtils::$emailValidator )) {
- PostmanUtils::$emailValidator = new Postman_Zend_Validate_EmailAddress ();
+ if ( ! isset( PostmanUtils::$emailValidator ) ) {
+ PostmanUtils::$emailValidator = new Postman_Zend_Validate_EmailAddress();
}
- return PostmanUtils::$emailValidator->isValid ( $email );
+ return PostmanUtils::$emailValidator->isValid( $email );
}
-
+
/**
* From http://stackoverflow.com/questions/13430120/str-getcsv-alternative-for-older-php-version-gives-me-an-empty-array-at-the-e
*
- * @param unknown $string
+ * @param unknown $string
* @return multitype:
*/
- static function postman_strgetcsv_impl($string) {
- $fh = fopen ( 'php://temp', 'r+' );
- fwrite ( $fh, $string );
- rewind ( $fh );
-
- $row = fgetcsv ( $fh );
-
- fclose ( $fh );
+ static function postman_strgetcsv_impl( $string ) {
+ $fh = fopen( 'php://temp', 'r+' );
+ fwrite( $fh, $string );
+ rewind( $fh );
+
+ $row = fgetcsv( $fh );
+
+ fclose( $fh );
return $row;
}
-
+
/**
*
* @return Ambigous <string, unknown>
*/
static function postmanGetServerName() {
- if (! empty ( $_SERVER ['SERVER_NAME'] )) {
+ if ( ! empty( $_SERVER ['SERVER_NAME'] ) ) {
$serverName = $_SERVER ['SERVER_NAME'];
- } else if (! empty ( $_SERVER ['HTTP_HOST'] )) {
+ } else if ( ! empty( $_SERVER ['HTTP_HOST'] ) ) {
$serverName = $_SERVER ['HTTP_HOST'];
} else {
$serverName = 'localhost.localdomain';
}
return $serverName;
}
-
+
/**
* Does this hostname belong to Google?
*
- * @param unknown $hostname
+ * @param unknown $hostname
* @return boolean
*/
- static function isGoogle($hostname) {
- return PostmanUtils::endsWith ( $hostname, 'gmail.com' ) || PostmanUtils::endsWith ( $hostname, 'googleapis.com' );
+ static function isGoogle( $hostname ) {
+ return PostmanUtils::endsWith( $hostname, 'gmail.com' ) || PostmanUtils::endsWith( $hostname, 'googleapis.com' );
}
-
+
/**
*
- * @param unknown $actionName
- * @param unknown $callbackName
+ * @param unknown $actionName
+ * @param unknown $callbackName
*/
- public static function registerAdminMenu($viewController, $callbackName) {
+ public static function registerAdminMenu( $viewController, $callbackName ) {
$logger = PostmanUtils::$logger;
- if ($logger->isTrace ()) {
- $logger->trace ( 'Registering admin menu ' . $callbackName );
+ if ( $logger->isTrace() ) {
+ $logger->trace( 'Registering admin menu ' . $callbackName );
}
- add_action ( 'admin_menu', array (
+ add_action( 'admin_menu', array(
$viewController,
- $callbackName
+ $callbackName,
) );
}
-
+
/**
*
- * @param unknown $actionName
- * @param unknown $callbackName
+ * @param unknown $actionName
+ * @param unknown $callbackName
*/
- public static function registerAjaxHandler($actionName, $class, $callbackName) {
- if (is_admin ()) {
+ public static function registerAjaxHandler( $actionName, $class, $callbackName ) {
+ if ( is_admin() ) {
$fullname = 'wp_ajax_' . $actionName;
// $this->logger->debug ( 'Registering ' . 'wp_ajax_' . $fullname . ' Ajax handler' );
- add_action ( $fullname, array (
+ add_action( $fullname, array(
$class,
- $callbackName
+ $callbackName,
) );
}
}
-
+
/**
*
- * @param unknown $parameterName
+ * @param unknown $parameterName
* @return mixed
*/
- public static function getBooleanRequestParameter($parameterName) {
- return filter_var ( $this->getRequestParameter ( $parameterName ), FILTER_VALIDATE_BOOLEAN );
+ public static function getBooleanRequestParameter( $parameterName ) {
+ return filter_var( self::getRequestParameter( $parameterName ), FILTER_VALIDATE_BOOLEAN );
}
-
+
/**
*
- * @param unknown $parameterName
+ * @param unknown $parameterName
* @return unknown
*/
- public static function getRequestParameter($parameterName) {
+ public static function getRequestParameter( $parameterName ) {
$logger = PostmanUtils::$logger;
- if (isset ( $_POST [$parameterName] )) {
- $value = filter_var( $_POST [$parameterName], FILTER_SANITIZE_STRING );
- if ($logger->isTrace ()) {
- $logger->trace ( sprintf ( 'Found parameter "%s"', $parameterName ) );
- $logger->trace ( $value );
+ if ( isset( $_POST [ $parameterName ] ) ) {
+ $value = filter_var( $_POST [ $parameterName ], FILTER_SANITIZE_STRING );
+ if ( $logger->isTrace() ) {
+ $logger->trace( sprintf( 'Found parameter "%s"', $parameterName ) );
+ $logger->trace( $value );
}
return $value;
}
}
public static function getServerIp() {
- $ip = $_SERVER['SERVER_ADDR'];
+ $ip = '';
+
+ if ( strpos( $_SERVER['SERVER_SOFTWARE'], 'iis' ) !== false ) {
+ $ip = $_SERVER['LOCAL_ADDR'];
+ }
+
+ if ( empty( $ip ) ) {
+ $ip = $_SERVER['SERVER_ADDR'];
+ }
+
$serverIp = filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
if ( ! $serverIp ) {
- $serverIp = self::get_external_ip();
+ $serverIp = filter_var( gethostbyname( $_SERVER['SERVER_NAME'] ), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
}
- return $serverIp;
+ return $serverIp ? $serverIp : 'localhost';
}
-
- private static function get_external_ip() {
- $ch = curl_init("https://postmansmtp.com/ip.php");
- curl_setopt($ch, CURLOPT_HEADER, FALSE);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- $result = curl_exec($ch);
- curl_close($ch);
- if ($result === FALSE) {
- return "ERROR";
- } else {
- return trim($result);
- }
- }
}
-PostmanUtils::staticInit ();
+PostmanUtils::staticInit();
diff --git a/postman-smtp.php b/postman-smtp.php
index 88af329..df55233 100644
--- a/postman-smtp.php
+++ b/postman-smtp.php
@@ -70,5 +70,5 @@ function post_start( $startingMemory ) {
*/
function post_setupPostman() {
require_once 'Postman/Postman.php';
- $kevinCostner = new Postman( __FILE__, '1.7.7' );
+ $kevinCostner = new Postman( __FILE__, '1.7.8' );
}
diff --git a/readme.txt b/readme.txt
index 79f53ca..cd71026 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,19 +1,20 @@
=== Post SMTP Mailer/Email Log ===
Contributors: yehudah, jasonhendriks
-Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, sparkpost api
+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.8
-Stable tag: 1.7.7
+Stable tag: 1.7.8
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
-Send, log and troubleshoot your Outgoing Email easily. Supports everything: SMTP, Gmail, Mandril, SendGrid and OAuth 2.0!
+Send, log and troubleshoot your Outgoing Email easily. Supports everything: SMTP, Gmail, Mandril, SendGrid, Elastic Email and OAuth 2.0!
== Description ==
-Post is a next-generation [SMTP Mailer](https://wordpress.org/plugins/search.php?q=smtp), software that assists in the delivery of email generated by your WordPress site. Post is the first and only plugin to support the [latest security standards](http://googleonlinesecurity.blogspot.ca/2014/04/new-security-measures-will-affect-older.html). With OAuth 2.0, there is **no need** to [store your email passsword](http://blog.codinghorror.com/youre-probably-storing-passwords-incorrectly/) in the WordPress database where it might be found.
+== Postman SMTP is back! ==
+Now under new maintenance, no need to search for another SMTP plugin anymore.
-> Post is one year old! SparkPost API Integration is coming soon as Mandrill is no longer offering a free service.
+Post is a next-generation [SMTP Mailer](https://wordpress.org/plugins/search.php?q=smtp), software that assists in the delivery of email generated by your WordPress site. Post is the first and only plugin to support the [latest security standards](http://googleonlinesecurity.blogspot.ca/2014/04/new-security-measures-will-affect-older.html). With OAuth 2.0, there is **no need** to [store your email passsword](http://blog.codinghorror.com/youre-probably-storing-passwords-incorrectly/) in the WordPress database where it might be found.
The **Connectivity Test** and intelligent **Setup Wizard** scan your SMTP server to detect firewall blocks and eliminate configuration mistakes. The built-in **Email Log** is an invaluable resource for [diagnosing problems](https://wordpress.org/support/topic/ugly-e-mails-no-html-and-no-special-characters?replies=15) with emails. Even hosts that block the standard SMTP ports, like GoDaddy or Bluehost, can't stop your email as **Post can deliver via HTTPS** if it can't use SMTP.
@@ -40,7 +41,7 @@ Post is *not* another WP Mail SMTP clone like WP Bank or Easy SMTP. It replaces
* COMING SOON: Sparkpost API for sending any email (requires a [Sparkpost](https://www.sparkpost.com) account)
* SendGrid API for sending any email (requires a [SendGrid](https://sendgrid.com) account and PHP 5.3)
-> Post needs [translators](https://translate.wordpress.org/projects/wp-plugins/Post-smtp/stable)! If you are a non-English speaker, please get involved!
+> Post needs [translators](https://translate.wordpress.org/projects/wp-plugins/post-smtp/stable)! If you are a non-English speaker, please get involved!
= Compatibile With.. =
* [Woocommerce](https://wordpress.org/plugins/woocommerce/)
@@ -50,6 +51,7 @@ Post is *not* another WP Mail SMTP clone like WP Bank or Easy SMTP. It replaces
* [Visual Forms Builder](https://wordpress.org/plugins/visual-form-builder/)
* [Contact Form Builder](https://wordpress.org/plugins/contact-form-builder/)
* [PlanSo Forms](https://wordpress.org/plugins/planso-forms/)
+* [Quform](https://www.quform.com/)
* [MyMail Newsletter](http://revaxarts-themes.com/?t=mymail) by revaxarts
* [SendPress Newsletters](https://wordpress.org/plugins/sendpress/)
* [WP HTML Mail](https://wordpress.org/plugins/wp-html-mail/)
@@ -270,6 +272,11 @@ To avoid being flagged as spam, you need to prove your email isn't forged. On a
== Changelog ==
+= 1.7.8 - 2017-10-28
+* Fixed: IP detection error in some web hosts
+* Fixed: Link open in new page attribute = _blank
+* Fixed: Replace deprecated PHP 7 functions.
+
= 1.7.7 - 2017-10-17
* Fixed: Error sending files with sendgrid
* Fixed: Wrong attachments format in Mandrill