summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664>2017-10-17 12:11:01 +0000
committeryehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664>2017-10-17 12:11:01 +0000
commitb30b38164d5520d690080cad9eea273b24291f17 (patch)
tree8ee9ded48d8abc15fd09655fd7a42097c2adf751
parent9fa7a56708beb12d8022ec5a210fa5f5f55534b2 (diff)
downloadPost-SMTP-b30b38164d5520d690080cad9eea273b24291f17.zip
= 1.7.6 - 2017-10-17
* Missing sendgrid files * Fixed: Localization slug * Minor typo git-svn-id: https://plugins.svn.wordpress.org/post-smtp/trunk@1747925 b8457f37-d9ea-0310-8a92-e5e31aec5664
-rw-r--r--Postman/Postman-Mail/PostmanMyMailConnector.php176
-rw-r--r--Postman/Postman.php312
-rw-r--r--Postman/PostmanAdminController.php273
-rw-r--r--postman-smtp.php8
-rw-r--r--readme.txt8
5 files changed, 387 insertions, 390 deletions
diff --git a/Postman/Postman-Mail/PostmanMyMailConnector.php b/Postman/Postman-Mail/PostmanMyMailConnector.php
index 203fbf5..151deed 100644
--- a/Postman/Postman-Mail/PostmanMyMailConnector.php
+++ b/Postman/Postman-Mail/PostmanMyMailConnector.php
@@ -1,182 +1,181 @@
<?php
-define ( 'MYMAIL_POSTMAN_REQUIRED_VERSION', '2.0' );
-define ( 'MYMAIL_POSTMAN_ID', 'postman' );
+define( 'MYMAIL_POSTMAN_REQUIRED_VERSION', '2.0' );
+define( 'MYMAIL_POSTMAN_ID', 'postman' );
/**
* Enables MyMail to deliver via Postman
*
* @author jasonhendriks
- *
*/
-if (! class_exists ( 'PostmanMyMailConnector' )) {
+if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
class PostmanMyMailConnector {
-
+
// PostmanLogger
private $logger;
-
+
/**
* No-argument constructor
*/
- public function __construct($file) {
- register_activation_hook ( $file, array (
+ public function __construct( $file ) {
+ register_activation_hook( $file, array(
$this,
- 'activate'
+ 'activate',
) );
- register_deactivation_hook ( $file, array (
+ register_deactivation_hook( $file, array(
$this,
- 'deactivate'
+ 'deactivate',
) );
-
- add_action ( 'init', array (
+
+ add_action( 'init', array(
$this,
- 'init'
+ 'init',
), 1 );
}
-
+
/**
* Initialize the Connector
*/
public function init() {
- if (! defined ( 'MYMAIL_VERSION' ) || version_compare ( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '>' )) {
+ if ( ! defined( 'MYMAIL_VERSION' ) || version_compare( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '>' ) ) {
// no-op
} else {
// create an instance of the Logger
- $this->logger = new PostmanLogger ( get_class ( $this ) );
- $this->logger->debug ( 'Starting' );
-
- add_filter ( 'mymail_delivery_methods', array (
+ $this->logger = new PostmanLogger( get_class( $this ) );
+ $this->logger->debug( 'Starting' );
+
+ add_filter( 'mymail_delivery_methods', array(
&$this,
- 'delivery_method'
+ 'delivery_method',
) );
- add_action ( 'mymail_deliverymethod_tab_postman', array (
+ add_action( 'mymail_deliverymethod_tab_postman', array(
&$this,
- 'deliverytab'
+ 'deliverytab',
) );
-
- if (mymail_option ( 'deliverymethod' ) == MYMAIL_POSTMAN_ID) {
- add_action ( 'mymail_initsend', array (
+
+ if ( mymail_option( 'deliverymethod' ) == MYMAIL_POSTMAN_ID ) {
+ add_action( 'mymail_initsend', array(
&$this,
- 'initsend'
+ 'initsend',
) );
- add_action ( 'mymail_presend', array (
+ add_action( 'mymail_presend', array(
&$this,
- 'presend'
+ 'presend',
) );
- add_action ( 'mymail_dosend', array (
+ add_action( 'mymail_dosend', array(
&$this,
- 'dosend'
+ 'dosend',
) );
- add_action ( 'MYMAIL_POSTMAN_cron', array (
+ add_action( 'MYMAIL_POSTMAN_cron', array(
&$this,
- 'reset'
+ 'reset',
) );
}
}
}
-
+
/**
* initsend function.
*
* uses mymail_initsend hook to set initial settings
*
* @access public
- * @param mixed $mailobject
+ * @param mixed $mailobject
* @return void
*/
- public function initsend($mailobject) {
- $this->logger->trace ( 'initsend' );
+ public function initsend( $mailobject ) {
+ $this->logger->trace( 'initsend' );
// disable dkim
$mailobject->dkim = false;
}
-
+
/**
* presend function.
*
* uses the mymail_presend hook to apply setttings before each mail
*
* @access public
- * @param mixed $mailobject
+ * @param mixed $mailobject
* @return void
*/
- public function presend($mailobject) {
-
+ public function presend( $mailobject ) {
+
// embedding images doesn't work
$mailobject->embed_images = false;
-
+
// use pre_send from the main class
// need the raw email body to send so we use the same option
- $mailobject->pre_send ();
+ $mailobject->pre_send();
}
-
+
/**
* dosend function.
*
* uses the mymail_dosend hook and triggers the send
*
* @access public
- * @param mixed $mailobject
+ * @param mixed $mailobject
* @return void
*/
- public function dosend($mailobject) {
- $this->logger->trace ( 'dosend' );
- $this->logger->trace ( $mailobject->mailer );
-
+ public function dosend( $mailobject ) {
+ $this->logger->trace( 'dosend' );
+ $this->logger->trace( $mailobject->mailer );
+
// create a PostmanWpMail instance
- $postmanWpMail = new PostmanWpMail ();
- $postmanWpMail->init ();
-
+ $postmanWpMail = new PostmanWpMail();
+ $postmanWpMail->init();
+
// create a PostmanMessage instance
- $message = $postmanWpMail->createNewMessage ();
- $message->addHeaders ( $mailobject->headers );
- $message->setBodyTextPart ( $mailobject->mailer->AltBody );
- $message->setBodyHtmlPart ( $mailobject->mailer->Body );
- $message->setBody ( $mailobject->mailer->AltBody . $mailobject->mailer->Body );
- $message->setSubject ( $mailobject->subject );
- $message->addTo ( $mailobject->to );
- $message->setReplyTo ( $mailobject->reply_to );
- $message->setAttachments ( $mailobject->attachments );
-
+ $message = $postmanWpMail->createNewMessage();
+ $message->addHeaders( $mailobject->headers );
+ $message->setBodyTextPart( $mailobject->mailer->AltBody );
+ $message->setBodyHtmlPart( $mailobject->mailer->Body );
+ $message->setBody( $mailobject->mailer->AltBody . $mailobject->mailer->Body );
+ $message->setSubject( $mailobject->subject );
+ $message->addTo( $mailobject->to );
+ $message->setReplyTo( $mailobject->reply_to );
+ $message->setAttachments( $mailobject->attachments );
+
// create a PostmanEmailLog instance
- $log = new PostmanEmailLog ();
-
+ $log = new PostmanEmailLog();
+
// send the message and store the result
- $mailobject->sent = $postmanWpMail->sendMessage ( $message, $log );
-
+ $mailobject->sent = $postmanWpMail->sendMessage( $message, $log );
+
// give error message back to MyMail
- $result = apply_filters ( 'postman_wp_mail_result', null );
- if (! $mailobject->sent) {
- $mailobject->set_error ( $result ['exception']->getMessage () );
+ $result = apply_filters( 'postman_wp_mail_result', null );
+ if ( ! $mailobject->sent ) {
+ $mailobject->set_error( $result ['exception']->getMessage() );
}
}
-
+
/**
* reset function.
*
* resets the current time
*
* @access public
- * @param mixed $message
+ * @param mixed $message
* @return array
*/
public function reset() {
- update_option ( '_transient__mymail_send_period_timeout', false );
- update_option ( '_transient__mymail_send_period', 0 );
+ update_option( '_transient__mymail_send_period_timeout', false );
+ update_option( '_transient__mymail_send_period', 0 );
}
-
+
/**
* delivery_method function.
*
* add the delivery method to the options
*
* @access public
- * @param mixed $delivery_methods
+ * @param mixed $delivery_methods
* @return void
*/
- public function delivery_method($delivery_methods) {
- $delivery_methods [MYMAIL_POSTMAN_ID] = __ ( 'Postman SMTP', Postman::TEXT_DOMAIN );
+ public function delivery_method( $delivery_methods ) {
+ $delivery_methods [ MYMAIL_POSTMAN_ID ] = __( 'Postman SMTP', Postman::TEXT_DOMAIN );
return $delivery_methods;
}
-
+
/**
* deliverytab function.
*
@@ -186,9 +185,9 @@ if (! class_exists ( 'PostmanMyMailConnector' )) {
* @return void
*/
public function deliverytab() {
- apply_filters ( 'print_postman_status', null );
+ apply_filters( 'print_postman_status', null );
}
-
+
/**
* activate function.
*
@@ -196,12 +195,12 @@ if (! class_exists ( 'PostmanMyMailConnector' )) {
* @return void
*/
public function activate() {
- if (defined ( 'MYMAIL_VERSION' ) && version_compare ( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '<=' )) {
- mymail_notice ( sprintf ( __ ( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf ( '<a href="options-general.php?page=newsletter-settings&mymail_remove_notice=mymail_delivery_method#delivery">%s</a>', __ ( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' );
- $this->reset ();
+ if ( defined( 'MYMAIL_VERSION' ) && version_compare( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '<=' ) ) {
+ mymail_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf( '<a href="options-general.php?page=newsletter-settings&mymail_remove_notice=mymail_delivery_method#delivery">%s</a>', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' );
+ $this->reset();
}
}
-
+
/**
* deactivate function.
*
@@ -209,12 +208,11 @@ if (! class_exists ( 'PostmanMyMailConnector' )) {
* @return void
*/
public function deactivate() {
- d;
- if (defined ( 'MYMAIL_VERSION' ) && function_exists ( 'mymail_option' ) && version_compare ( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '<=' )) {
- if (mymail_option ( 'deliverymethod' ) == MYMAIL_POSTMAN_ID) {
- mymail_update_option ( 'deliverymethod', 'simple' );
+ if ( defined( 'MYMAIL_VERSION' ) && function_exists( 'mymail_option' ) && version_compare( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '<=' ) ) {
+ if ( mymail_option( 'deliverymethod' ) == MYMAIL_POSTMAN_ID ) {
+ mymail_update_option( 'deliverymethod', 'simple' );
/* Translators where %s is the name of the page */
- mymail_notice ( sprintf ( __ ( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf ( '<a href="options-general.php?page=newsletter-settings&mymail_remove_notice=mymail_delivery_method#delivery">%s</a>', __ ( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' );
+ mymail_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf( '<a href="options-general.php?page=newsletter-settings&mymail_remove_notice=mymail_delivery_method#delivery">%s</a>', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' );
}
}
}
diff --git a/Postman/Postman.php b/Postman/Postman.php
index a706636..46a69f9 100644
--- a/Postman/Postman.php
+++ b/Postman/Postman.php
@@ -15,30 +15,28 @@
* @copyright Jan 16, 2015
*/
class Postman {
-
- //
- const ADMINISTRATOR_ROLE_NAME = 'administrator';
+
+ const ADMINISTRATOR_ROLE_NAME = 'administrator';
const MANAGE_POSTMAN_CAPABILITY_NAME = 'manage_postman_smtp';
- const TEXT_DOMAIN = 'postman-smtp';
-
- //
+ const TEXT_DOMAIN = 'post-smtp';
+
private $logger;
private $messageHandler;
private $wpMailBinder;
private $pluginData;
private $rootPluginFilenameAndPath;
-
+
/**
* The constructor
*
* @param unknown $rootPluginFilenameAndPath
* - the __FILE__ of the caller
*/
- public function __construct($rootPluginFilenameAndPath, $version) {
- assert ( ! empty ( $rootPluginFilenameAndPath ) );
- assert ( ! empty ( $version ) );
+ public function __construct( $rootPluginFilenameAndPath, $version ) {
+ assert( ! empty( $rootPluginFilenameAndPath ) );
+ assert( ! empty( $version ) );
$this->rootPluginFilenameAndPath = $rootPluginFilenameAndPath;
-
+
// load the dependencies
require_once 'PostmanOptions.php';
require_once 'PostmanState.php';
@@ -55,88 +53,88 @@ class Postman {
require_once 'PostmanConfigTextHelper.php';
require_once 'Postman-Email-Log/PostmanEmailLogPostType.php';
require_once 'Postman-Mail/PostmanMyMailConnector.php';
-
+
// get plugin metadata - alternative to get_plugin_data
- $this->pluginData = array (
- 'name' => __ ( 'Postman SMTP', Postman::TEXT_DOMAIN ),
- 'version' => $version
+ $this->pluginData = array(
+ 'name' => __( 'Postman SMTP', Postman::TEXT_DOMAIN ),
+ 'version' => $version,
);
-
+
// register the plugin metadata filter (part of the Postman API)
- add_filter ( 'postman_get_plugin_metadata', array (
+ add_filter( 'postman_get_plugin_metadata', array(
$this,
- 'getPluginMetaData'
+ 'getPluginMetaData',
) );
-
+
// create an instance of the logger
- $this->logger = new PostmanLogger ( get_class ( $this ) );
- if ($this->logger->isDebug ()) {
- $this->logger->debug ( sprintf ( '%1$s v%2$s starting', $this->pluginData ['name'], $this->pluginData ['version'] ) );
+ $this->logger = new PostmanLogger( get_class( $this ) );
+ if ( $this->logger->isDebug() ) {
+ $this->logger->debug( sprintf( '%1$s v%2$s starting', $this->pluginData ['name'], $this->pluginData ['version'] ) );
}
-
- if (isset ( $_REQUEST ['page'] ) && $this->logger->isTrace ()) {
- $this->logger->trace ( 'Current page: ' . $_REQUEST ['page'] );
+
+ if ( isset( $_REQUEST ['page'] ) && $this->logger->isTrace() ) {
+ $this->logger->trace( 'Current page: ' . $_REQUEST ['page'] );
}
-
+
// register the email transports
- $this->registerTransports ( $rootPluginFilenameAndPath );
-
+ $this->registerTransports( $rootPluginFilenameAndPath );
+
// store an instance of the WpMailBinder
- $this->wpMailBinder = PostmanWpMailBinder::getInstance ();
-
+ $this->wpMailBinder = PostmanWpMailBinder::getInstance();
+
// bind to wp_mail - this has to happen before the "init" action
// this design allows other plugins to register a Postman transport and call bind()
// bind may be called more than once
- $this->wpMailBinder->bind ();
-
+ $this->wpMailBinder->bind();
+
// registers the custom post type for all callers
- PostmanEmailLogPostType::automaticallyCreatePostType ();
-
+ PostmanEmailLogPostType::automaticallyCreatePostType();
+
// run the DatastoreUpgrader any time there is a version mismatch
- if (PostmanState::getInstance ()->getVersion () != $this->pluginData ['version']) {
+ if ( PostmanState::getInstance()->getVersion() != $this->pluginData ['version'] ) {
// manually trigger the activation hook
- if ($this->logger->isInfo ()) {
- $this->logger->info ( sprintf ( "Upgrading datastore from version %s to %s", PostmanState::getInstance ()->getVersion (), $this->pluginData ['version'] ) );
+ if ( $this->logger->isInfo() ) {
+ $this->logger->info( sprintf( 'Upgrading datastore from version %s to %s', PostmanState::getInstance()->getVersion(), $this->pluginData ['version'] ) );
}
require_once 'PostmanInstaller.php';
- $upgrader = new PostmanInstaller ();
- $upgrader->activatePostman ();
+ $upgrader = new PostmanInstaller();
+ $upgrader->activatePostman();
}
-
+
// MyMail integration
- new PostmanMyMailConnector ( $rootPluginFilenameAndPath );
-
+ new PostmanMyMailConnector( $rootPluginFilenameAndPath );
+
// register the shortcode handler on the add_shortcode event
- add_shortcode ( 'postman-version', array (
+ add_shortcode( 'postman-version', array(
$this,
- 'version_shortcode'
+ 'version_shortcode',
) );
-
+
// hook on the plugins_loaded event
- add_action ( 'plugins_loaded', array (
+ add_action( 'plugins_loaded', array(
$this,
- 'on_plugins_loaded'
+ 'on_plugins_loaded',
) );
-
+
// hook on the wp_loaded event
- add_action ( 'wp_loaded', array (
+ add_action( 'wp_loaded', array(
$this,
- 'on_wp_loaded'
+ 'on_wp_loaded',
) );
-
+
// hook on the acivation event
- register_activation_hook ( $rootPluginFilenameAndPath, array (
+ register_activation_hook( $rootPluginFilenameAndPath, array(
$this,
- 'on_activation'
+ 'on_activation',
) );
-
+
// hook on the deactivation event
- register_deactivation_hook ( $rootPluginFilenameAndPath, array (
+ register_deactivation_hook( $rootPluginFilenameAndPath, array(
$this,
- 'on_deactivation'
+ 'on_deactivation',
) );
}
-
+
/**
* Functions to execute on the plugins_loaded event
*
@@ -145,15 +143,15 @@ class Postman {
*/
public function on_plugins_loaded() {
// load the text domain
- $this->loadTextDomain ();
-
+ $this->loadTextDomain();
+
// register the setup_admin function on plugins_loaded because we need to call
// current_user_can to verify the capability of the current user
- if (PostmanUtils::isAdmin () && is_admin ()) {
- $this->setup_admin ();
+ if ( PostmanUtils::isAdmin() && is_admin() ) {
+ $this->setup_admin();
}
}
-
+
/**
* Functions to execute on the wp_loaded event
*
@@ -163,45 +161,45 @@ class Postman {
public function on_wp_loaded() {
// register the check for configuration errors on the wp_loaded hook,
// because we want it to run after the OAuth Grant Code check on the init hook
- $this->check_for_configuration_errors ();
+ $this->check_for_configuration_errors();
}
-
+
/**
* Functions to execute on the register_activation_hook
* ref: https://codex.wordpress.org/Function_Reference/register_activation_hook
*/
public function on_activation() {
- if ($this->logger->isInfo ()) {
- $this->logger->info ( 'Activating plugin' );
+ if ( $this->logger->isInfo() ) {
+ $this->logger->info( 'Activating plugin' );
}
require_once 'PostmanInstaller.php';
- $upgrader = new PostmanInstaller ();
- $upgrader->activatePostman ();
+ $upgrader = new PostmanInstaller();
+ $upgrader->activatePostman();
}
-
+
/**
* Functions to execute on the register_deactivation_hook
* ref: https://codex.wordpress.org/Function_Reference/register_deactivation_hook
*/
public function on_deactivation() {
- if ($this->logger->isInfo ()) {
- $this->logger->info ( 'Deactivating plugin' );
+ if ( $this->logger->isInfo() ) {
+ $this->logger->info( 'Deactivating plugin' );
}
require_once 'PostmanInstaller.php';
- $upgrader = new PostmanInstaller ();
- $upgrader->deactivatePostman ();
+ $upgrader = new PostmanInstaller();
+ $upgrader->deactivatePostman();
}
-
+
/**
* If the user is on the WordPress Admin page, creates the Admin screens
*/
public function setup_admin() {
- $this->logger->debug ( 'Admin start-up sequence' );
-
- $options = PostmanOptions::getInstance ();
- $authToken = PostmanOAuthToken::getInstance ();
+ $this->logger->debug( 'Admin start-up sequence' );
+
+ $options = PostmanOptions::getInstance();
+ $authToken = PostmanOAuthToken::getInstance();
$rootPluginFilenameAndPath = $this->rootPluginFilenameAndPath;
-
+
// load the dependencies
require_once 'PostmanMessageHandler.php';
require_once 'PostmanAdminController.php';
@@ -212,85 +210,83 @@ class Postman {
require_once 'Postman-Configuration/PostmanConfigurationController.php';
require_once 'Postman-Send-Test-Email/PostmanSendTestEmailController.php';
require_once 'Postman-Diagnostic-Test/PostmanDiagnosticTestController.php';
-
+
// create and store an instance of the MessageHandler
- $this->messageHandler = new PostmanMessageHandler ();
-
+ $this->messageHandler = new PostmanMessageHandler();
+
// create the Admin Controllers
- new PostmanDashboardWidgetController ( $rootPluginFilenameAndPath, $options, $authToken, $this->wpMailBinder );
- new PostmanAdminController ( $rootPluginFilenameAndPath, $options, $authToken, $this->messageHandler, $this->wpMailBinder );
- new PostmanEmailLogController ( $rootPluginFilenameAndPath );
- new PostmanConnectivityTestController ( $rootPluginFilenameAndPath );
- new PostmanConfigurationController ( $rootPluginFilenameAndPath );
- new PostmanSendTestEmailController ( $rootPluginFilenameAndPath );
- new PostmanDiagnosticTestController ( $rootPluginFilenameAndPath );
-
+ new PostmanDashboardWidgetController( $rootPluginFilenameAndPath, $options, $authToken, $this->wpMailBinder );
+ new PostmanAdminController( $rootPluginFilenameAndPath, $options, $authToken, $this->messageHandler, $this->wpMailBinder );
+ new PostmanEmailLogController( $rootPluginFilenameAndPath );
+ new PostmanConnectivityTestController( $rootPluginFilenameAndPath );
+ new PostmanConfigurationController( $rootPluginFilenameAndPath );
+ new PostmanSendTestEmailController( $rootPluginFilenameAndPath );
+ new PostmanDiagnosticTestController( $rootPluginFilenameAndPath );
+
// register the Postman signature (only if we're on a postman admin screen) on the in_admin_footer event
- if (PostmanUtils::isCurrentPagePostmanAdmin ()) {
- add_action ( 'in_admin_footer', array (
+ if ( PostmanUtils::isCurrentPagePostmanAdmin() ) {
+ add_action( 'in_admin_footer', array(
$this,
- 'print_signature'
+ 'print_signature',
) );
}
}
-
+
/**
* Check for configuration errors and displays messages to the user
*/
public function check_for_configuration_errors() {
- $options = PostmanOptions::getInstance ();
- $authToken = PostmanOAuthToken::getInstance ();
-
+ $options = PostmanOptions::getInstance();
+ $authToken = PostmanOAuthToken::getInstance();
+
// did Postman fail binding to wp_mail()?
- if ($this->wpMailBinder->isUnboundDueToException ()) {
+ if ( $this->wpMailBinder->isUnboundDueToException() ) {
// this message gets printed on ANY WordPress admin page, as it's a fatal error that
// may occur just by activating a new plugin
-
// log the fatal message
- $this->logger->fatal ( 'Postman: wp_mail has been declared by another plugin or theme, so you won\'t be able to use Postman until the conflict is resolved.' );
-
- if (PostmanUtils::isAdmin () && is_admin ()) {
+ $this->logger->fatal( 'Postman: wp_mail has been declared by another plugin or theme, so you won\'t be able to use Postman until the conflict is resolved.' );
+
+ if ( PostmanUtils::isAdmin() && is_admin() ) {
// on any admin pages, show this error message
-
// I noticed the wpMandrill and SendGrid plugins have the exact same error message here
// I've adopted their error message as well, for shits and giggles .... :D
- $message = __ ( 'Postman: wp_mail has been declared by another plugin or theme, so you won\'t be able to use Postman until the conflict is resolved.', Postman::TEXT_DOMAIN );
- $this->messageHandler->addError ( $message );
+ $message = __( 'Postman: wp_mail has been declared by another plugin or theme, so you won\'t be able to use Postman until the conflict is resolved.', Postman::TEXT_DOMAIN );
+ $this->messageHandler->addError( $message );
}
} else {
- $transport = PostmanTransportRegistry::getInstance ()->getCurrentTransport ();
- $scribe = $transport->getScribe ();
-
- $virgin = $options->isNew ();
- if (! $transport->isConfiguredAndReady ()) {
+ $transport = PostmanTransportRegistry::getInstance()->getCurrentTransport();
+ $scribe = $transport->getScribe();
+
+ $virgin = $options->isNew();
+ if ( ! $transport->isConfiguredAndReady() ) {
// if the configuration is broken, and the user has started to configure the plugin
// show this error message
- $messages = $transport->getConfigurationMessages ();
+ $messages = $transport->getConfigurationMessages();
foreach ( $messages as $message ) {
- if ($message) {
+ if ( $message ) {
// log the warning message
- $this->logger->warn ( sprintf ( '%s Transport has a configuration problem: %s', $transport->getName (), $message ) );
-
- if (PostmanUtils::isAdmin () && PostmanUtils::isCurrentPagePostmanAdmin ()) {
+ $this->logger->warn( sprintf( '%s Transport has a configuration problem: %s', $transport->getName(), $message ) );
+
+ if ( PostmanUtils::isAdmin() && PostmanUtils::isCurrentPagePostmanAdmin() ) {
// on pages that are Postman admin pages only, show this error message
- $this->messageHandler->addError ( $message );
+ $this->messageHandler->addError( $message );
}
}
}
}
-
+
// on pages that are NOT Postman admin pages only, show this error message
- if (PostmanUtils::isAdmin () && ! PostmanUtils::isCurrentPagePostmanAdmin () && ! $transport->isConfiguredAndReady ()) {
+ if ( PostmanUtils::isAdmin() && ! PostmanUtils::isCurrentPagePostmanAdmin() && ! $transport->isConfiguredAndReady() ) {
// on pages that are *NOT* Postman admin pages only....
// if the configuration is broken show this error message
- add_action ( 'admin_notices', Array (
+ add_action( 'admin_notices', array(
$this,
- 'display_configuration_required_warning'
+ 'display_configuration_required_warning',
) );
}
}
}
-
+
/**
* Returns the plugin version number and name
* Part of the Postman API
@@ -301,74 +297,74 @@ class Postman {
// get plugin metadata
return $this->pluginData;
}
-
+
/**
* This is the general message that Postman requires configuration, to warn users who think
* the plugin is ready-to-go as soon as it is activated.
* This message only goes away once the plugin is configured.
*/
public function display_configuration_required_warning() {
- if (PostmanUtils::isAdmin ()) {
- if ($this->logger->isDebug ()) {
- $this->logger->debug ( 'Displaying configuration required warning' );
+ if ( PostmanUtils::isAdmin() ) {
+ if ( $this->logger->isDebug() ) {
+ $this->logger->debug( 'Displaying configuration required warning' );
}
- $message = sprintf ( PostmanTransportRegistry::getInstance ()->getReadyMessage () );
- $goToSettings = sprintf ( '<a href="%s">%s</a>', PostmanUtils::getSettingsPageUrl (), __ ( 'Settings', Postman::TEXT_DOMAIN ) );
- $goToEmailLog = sprintf ( '%s', _x ( 'Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN ) );
- if (PostmanOptions::getInstance ()->isMailLoggingEnabled ()) {
- $goToEmailLog = sprintf ( '<a href="%s">%s</a>', PostmanUtils::getEmailLogPageUrl (), $goToEmailLog );
+ $message = sprintf( PostmanTransportRegistry::getInstance()->getReadyMessage() );
+ $goToSettings = sprintf( '<a href="%s">%s</a>', PostmanUtils::getSettingsPageUrl(), __( 'Settings', Postman::TEXT_DOMAIN ) );
+ $goToEmailLog = sprintf( '%s', _x( 'Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN ) );
+ if ( PostmanOptions::getInstance()->isMailLoggingEnabled() ) {
+ $goToEmailLog = sprintf( '<a href="%s">%s</a>', PostmanUtils::getEmailLogPageUrl(), $goToEmailLog );
}
- $message .= (sprintf ( ' %s | %s', $goToEmailLog, $goToSettings ));
+ $message .= (sprintf( ' %s | %s', $goToEmailLog, $goToSettings ));
;
- $this->messageHandler->printMessage ( $message, PostmanMessageHandler::WARNING_CLASS );
+ $this->messageHandler->printMessage( $message, PostmanMessageHandler::WARNING_CLASS );
}
}
-
+
/**
* Register the email transports.
*
* The Gmail API used to be a separate plugin which was registered when that plugin
* was loaded. But now both the SMTP, Gmail API and other transports are registered here.
*
- * @param unknown $pluginData
+ * @param unknown $pluginData
*/
- private function registerTransports($rootPluginFilenameAndPath) {
- PostmanTransportRegistry::getInstance ()->registerTransport ( new PostmanDefaultModuleTransport ( $rootPluginFilenameAndPath ) );
- PostmanTransportRegistry::getInstance ()->registerTransport ( new PostmanSmtpModuleTransport ( $rootPluginFilenameAndPath ) );
- PostmanTransportRegistry::getInstance ()->registerTransport ( new PostmanGmailApiModuleTransport ( $rootPluginFilenameAndPath ) );
- PostmanTransportRegistry::getInstance ()->registerTransport ( new PostmanMandrillTransport ( $rootPluginFilenameAndPath ) );
- PostmanTransportRegistry::getInstance ()->registerTransport ( new PostmanSendGridTransport ( $rootPluginFilenameAndPath ) );
+ private function registerTransports( $rootPluginFilenameAndPath ) {
+ PostmanTransportRegistry::getInstance()->registerTransport( new PostmanDefaultModuleTransport( $rootPluginFilenameAndPath ) );
+ PostmanTransportRegistry::getInstance()->registerTransport( new PostmanSmtpModuleTransport( $rootPluginFilenameAndPath ) );
+ PostmanTransportRegistry::getInstance()->registerTransport( new PostmanGmailApiModuleTransport( $rootPluginFilenameAndPath ) );
+ PostmanTransportRegistry::getInstance()->registerTransport( new PostmanMandrillTransport( $rootPluginFilenameAndPath ) );
+ PostmanTransportRegistry::getInstance()->registerTransport( new PostmanSendGridTransport( $rootPluginFilenameAndPath ) );
}
-
+
/**
* Print the Postman signature on the bottom of the page
*
* http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/
*/
function print_signature() {
- printf ( '<a href="https://wordpress.org/plugins/postman-smtp/">%s</a> %s<br/>', $this->pluginData ['name'], $this->pluginData ['version'] );
+ printf( '<a href="https://wordpress.org/plugins/postman-smtp/">%s</a> %s<br/>', $this->pluginData ['name'], $this->pluginData ['version'] );
}
-
+
/**
* Loads the appropriate language file
*/
private function loadTextDomain() {
// had to hardcode the third parameter, Relative path to WP_PLUGIN_DIR,
// because __FILE__ returns the wrong path if the plugin is installed as a symlink
- $shortLocale = substr ( get_locale (), 0, 2 );
- if ($shortLocale != 'en') {
+ $shortLocale = substr( get_locale(), 0, 2 );
+ if ( $shortLocale != 'en' ) {
$langDir = 'postman-smtp/Postman/languages';
- $success = load_plugin_textdomain ( Postman::TEXT_DOMAIN, false, $langDir );
- if ($this->logger->isDebug ()) {
- if ($success) {
- $this->logger->debug ( sprintf ( 'local translation file loaded for locale=%s', get_locale () ) );
+ $success = load_plugin_textdomain( Postman::TEXT_DOMAIN, false, $langDir );
+ if ( $this->logger->isDebug() ) {
+ if ( $success ) {
+ $this->logger->debug( sprintf( 'local translation file loaded for locale=%s', get_locale() ) );
} else {
- $this->logger->debug ( sprintf ( 'failed to load local translation file: locale=%s file=%s/%s-%s.mo', get_locale (), $langDir, Postman::TEXT_DOMAIN, get_locale () ) );
+ $this->logger->debug( sprintf( 'failed to load local translation file: locale=%s file=%s/%s-%s.mo', get_locale(), $langDir, Postman::TEXT_DOMAIN, get_locale() ) );
}
}
}
}
-
+
/**
* Shortcode to return the current plugin version.
*
@@ -381,19 +377,19 @@ class Postman {
}
}
-if (! function_exists ( 'str_getcsv' )) {
+if ( ! function_exists( 'str_getcsv' ) ) {
/**
* PHP version less than 5.3 don't have str_getcsv natively.
*
- * @param unknown $string
+ * @param unknown $string
* @return multitype:
*/
- function str_getcsv($string) {
- $logger = new PostmanLogger ( 'postman-common-functions' );
- if ($logger->isDebug ()) {
- $logger->debug ( 'Using custom str_getcsv' );
+ function str_getcsv( $string ) {
+ $logger = new PostmanLogger( 'postman-common-functions' );
+ if ( $logger->isDebug() ) {
+ $logger->debug( 'Using custom str_getcsv' );
}
- return PostmanUtils::postman_strgetcsv_impl ( $string );
+ return PostmanUtils::postman_strgetcsv_impl( $string );
}
}
diff --git a/Postman/PostmanAdminController.php b/Postman/PostmanAdminController.php
index 5e62dfe..c9d0c5d 100644
--- a/Postman/PostmanAdminController.php
+++ b/Postman/PostmanAdminController.php
@@ -1,6 +1,6 @@
<?php
-if (! class_exists ( "PostmanAdminController" )) {
-
+if ( ! class_exists( 'PostmanAdminController' ) ) {
+
require_once 'PostmanOptions.php';
require_once 'PostmanState.php';
require_once 'PostmanState.php';
@@ -14,20 +14,19 @@ if (! class_exists ( "PostmanAdminController" )) {
require_once 'PostmanViewController.php';
require_once 'PostmanPreRequisitesCheck.php';
require_once 'Postman-Auth/PostmanAuthenticationManagerFactory.php';
-
- //
+
class PostmanAdminController {
-
+
// this is the slug used in the URL
const MANAGE_OPTIONS_PAGE_SLUG = 'postman/manage-options';
-
+
// NONCE NAMES
const PURGE_DATA_SLUG = 'postman_purge_data';
const IMPORT_SETTINGS_SLUG = 'postman_import_settings';
-
+
// The Postman Group is used for saving data, make sure it is globally unique
const SETTINGS_GROUP_NAME = 'postman_group';
-
+
// a database entry specifically for the form that sends test e-mail
const TEST_OPTIONS = 'postman_test_options';
const SMTP_OPTIONS = 'postman_smtp_options';
@@ -54,92 +53,92 @@ if (! class_exists ( "PostmanAdminController" )) {
const ADVANCED_SECTION = 'postman_advanced_section';
const EMAIL_VALIDATION_SECTION = 'postman_email_validation_section';
const EMAIL_VALIDATION_OPTIONS = 'postman_email_validation_options';
-
+
// slugs
const POSTMAN_TEST_SLUG = 'postman-test';
-
+
// logging
private $logger;
-
+
// Holds the values to be used in the fields callbacks
private $rootPluginFilenameAndPath;
private $options;
private $authorizationToken;
private $importableConfiguration;
-
+
// helpers
private $messageHandler;
private $oauthScribe;
private $wpMailBinder;
-
+
/**
* Constructor
*
- * @param unknown $rootPluginFilenameAndPath
- * @param PostmanOptions $options
- * @param PostmanOAuthToken $authorizationToken
- * @param PostmanMessageHandler $messageHandler
- * @param PostmanWpMailBinder $binder
+ * @param unknown $rootPluginFilenameAndPath
+ * @param PostmanOptions $options
+ * @param PostmanOAuthToken $authorizationToken
+ * @param PostmanMessageHandler $messageHandler
+ * @param PostmanWpMailBinder $binder
*/
- public function __construct($rootPluginFilenameAndPath, PostmanOptions $options, PostmanOAuthToken $authorizationToken, PostmanMessageHandler $messageHandler, PostmanWpMailBinder $binder) {
- assert ( ! empty ( $rootPluginFilenameAndPath ) );
- assert ( ! empty ( $options ) );
- assert ( ! empty ( $authorizationToken ) );
- assert ( ! empty ( $messageHandler ) );
- assert ( ! empty ( $binder ) );
- assert ( PostmanUtils::isAdmin () );
- assert ( is_admin () );
-
- $this->logger = new PostmanLogger ( get_class ( $this ) );
+ public function __construct( $rootPluginFilenameAndPath, PostmanOptions $options, PostmanOAuthToken $authorizationToken, PostmanMessageHandler $messageHandler, PostmanWpMailBinder $binder ) {
+ assert( ! empty( $rootPluginFilenameAndPath ) );
+ assert( ! empty( $options ) );
+ assert( ! empty( $authorizationToken ) );
+ assert( ! empty( $messageHandler ) );
+ assert( ! empty( $binder ) );
+ assert( PostmanUtils::isAdmin() );
+ assert( is_admin() );
+
+ $this->logger = new PostmanLogger( get_class( $this ) );
$this->options = $options;
$this->authorizationToken = $authorizationToken;
$this->messageHandler = $messageHandler;
$this->rootPluginFilenameAndPath = $rootPluginFilenameAndPath;
$this->wpMailBinder = $binder;
-
+
// check if the user saved data, and if validation was successful
- $session = PostmanSession::getInstance ();
- if ($session->isSetAction ()) {
- $this->logger->debug ( sprintf ( 'session action: %s', $session->getAction () ) );
+ $session = PostmanSession::getInstance();
+ if ( $session->isSetAction() ) {
+ $this->logger->debug( sprintf( 'session action: %s', $session->getAction() ) );
}
- if ($session->getAction () == PostmanInputSanitizer::VALIDATION_SUCCESS) {
+ if ( $session->getAction() == PostmanInputSanitizer::VALIDATION_SUCCESS ) {
// unset the action
- $session->unsetAction ();
+ $session->unsetAction();
// do a redirect on the init hook
- $this->registerInitFunction ( 'handleSuccessfulSave' );
+ $this->registerInitFunction( 'handleSuccessfulSave' );
// add a saved message to be shown after the redirect
- $this->messageHandler->addMessage ( _x ( 'Settings saved.', 'The plugin successfully saved new settings.', Postman::TEXT_DOMAIN ) );
+ $this->messageHandler->addMessage( _x( 'Settings saved.', 'The plugin successfully saved new settings.', Postman::TEXT_DOMAIN ) );
return;
} else {
// unset the action in the failed case as well
- $session->unsetAction ();
+ $session->unsetAction();
}
-
+
// test to see if an OAuth authentication is in progress
- if ($session->isSetOauthInProgress ()) {
+ if ( $session->isSetOauthInProgress() ) {
// there is only a three minute window that Postman will expect a Grant Code, once Grant is clicked by the user
- $this->logger->debug ( 'Looking for grant code' );
- if (isset ( $_GET ['code'] )) {
- $this->logger->debug ( 'Found authorization grant code' );
+ $this->logger->debug( 'Looking for grant code' );
+ if ( isset( $_GET ['code'] ) ) {
+ $this->logger->debug( 'Found authorization grant code' );
// queue the function that processes the incoming grant code
- $this->registerInitFunction ( 'handleAuthorizationGrant' );
+ $this->registerInitFunction( 'handleAuthorizationGrant' );
return;
}
}
-
+
// continue to initialize the AdminController
- add_action ( 'init', array (
+ add_action( 'init', array(
$this,
- 'on_init'
+ 'on_init',
) );
-
+
// Adds "Settings" link to the plugin action page
- add_filter ( 'plugin_action_links_' . plugin_basename ( $this->rootPluginFilenameAndPath ), array (
+ add_filter( 'plugin_action_links_' . plugin_basename( $this->rootPluginFilenameAndPath ), array(
$this,
- 'postmanModifyLinksOnPluginsListPage'
+ 'postmanModifyLinksOnPluginsListPage',
) );
}
-
+
/**
* Functions to execute on the init event
*
@@ -148,86 +147,86 @@ if (! class_exists ( "PostmanAdminController" )) {
*/
public function on_init() {
// only administrators should be able to trigger this
- if (PostmanUtils::isAdmin ()) {
- //
- $transport = PostmanTransportRegistry::getInstance ()->getCurrentTransport ();
- $this->oauthScribe = $transport->getScribe ();
-
+ if ( PostmanUtils::isAdmin() ) {
+ $transport = PostmanTransportRegistry::getInstance()->getCurrentTransport();
+ $this->oauthScribe = $transport->getScribe();
+
// register content handlers
- $viewController = new PostmanViewController ( $this->rootPluginFilenameAndPath, $this->options, $this->authorizationToken, $this->oauthScribe, $this );
-
+ $viewController = new PostmanViewController( $this->rootPluginFilenameAndPath, $this->options, $this->authorizationToken, $this->oauthScribe, $this );
+
// register action handlers
- $this->registerAdminPostAction ( self::PURGE_DATA_SLUG, 'handlePurgeDataAction' );
- $this->registerAdminPostAction ( self::IMPORT_SETTINGS_SLUG, 'importSettingsAction' );
- $this->registerAdminPostAction ( PostmanUtils::REQUEST_OAUTH2_GRANT_SLUG, 'handleOAuthPermissionRequestAction' );
-
- if (PostmanUtils::isCurrentPagePostmanAdmin ()) {
- $this->checkPreRequisites ();
+ $this->registerAdminPostAction( self::PURGE_DATA_SLUG, 'handlePurgeDataAction' );
+ $this->registerAdminPostAction( self::IMPORT_SETTINGS_SLUG, 'importSettingsAction' );
+ $this->registerAdminPostAction( PostmanUtils::REQUEST_OAUTH2_GRANT_SLUG, 'handleOAuthPermissionRequestAction' );
+
+ if ( PostmanUtils::isCurrentPagePostmanAdmin() ) {
+ $this->checkPreRequisites();
}
}
}
-
+
/**
- *
+ *
*/
private function checkPreRequisites() {
- $states = PostmanPreRequisitesCheck::getState ();
+ $states = PostmanPreRequisitesCheck::getState();
foreach ( $states as $state ) {
- if (! $state ['ready']) {
+ if ( ! $state ['ready'] ) {
/* Translators: where %1$s is the name of the library */
- $message = sprintf ( __ ( 'This PHP installation requires the <b>%1$s</b> library.', Postman::TEXT_DOMAIN ), $state ['name'] );
- if ($state ['required']) {
- $this->messageHandler->addError ( $message );
+ $message = sprintf( __( 'This PHP installation requires the <b>%1$s</b> library.', Postman::TEXT_DOMAIN ), $state ['name'] );
+ if ( $state ['required'] ) {
+ $this->messageHandler->addError( $message );
} else {
// $this->messageHandler->addWarning ( $message );
}
}
}
}
-
+
/**
*
- * @param unknown $actionName
- * @param unknown $callbackName
+ * @param unknown $actionName
+ * @param unknown $callbackName
*/
- private function registerInitFunction($callbackName) {
- $this->logger->debug ( 'Registering init function ' . $callbackName );
- add_action ( 'init', array (
+ private function registerInitFunction( $callbackName ) {
+ $this->logger->debug( 'Registering init function ' . $callbackName );
+ add_action( 'init', array(
$this,
- $callbackName
+ $callbackName,
) );
}
-
+
/**
* Registers actions posted by am HTML FORM with the WordPress 'action' parameter
*
- * @param unknown $actionName
- * @param unknown $callbankName
+ * @param unknown $actionName
+ * @param unknown $callbankName
*/
- private function registerAdminPostAction($actionName, $callbankName) {
+ private function registerAdminPostAction( $actionName, $callbankName ) {
// $this->logger->debug ( 'Registering ' . $actionName . ' Action Post handler' );
- add_action ( 'admin_post_' . $actionName, array (
+ add_action( 'admin_post_' . $actionName, array(
$this,
- $callbankName
+ $callbankName,
) );
}
-
+
/**
* Add "Settings" link to the plugin action page
*
- * @param unknown $links
+ * @param unknown $links
* @return multitype:
*/
- public function postmanModifyLinksOnPluginsListPage($links) {
+ public function postmanModifyLinksOnPluginsListPage( $links ) {
// only administrators should be able to trigger this
- if (PostmanUtils::isAdmin ()) {
- $mylinks = array (
- sprintf ( '<a href="%s" class="postman_settings">%s</a>', PostmanUtils::getSettingsPageUrl (), __ ( 'Settings', Postman::TEXT_DOMAIN ) )
+ if ( PostmanUtils::isAdmin() ) {
+ $mylinks = array(
+ sprintf( '<a href="%s" class="postman_settings">%s</a>', PostmanUtils::getSettingsPageUrl(), __( 'Settings', Postman::TEXT_DOMAIN ) ),
+ sprintf( '<a href="%s" class="postman_settings">%s</a>', 'https://postmansmtp.com', __( 'Visit us', Postman::TEXT_DOMAIN ) ),
);
- return array_merge ( $mylinks, $links );
+ return array_merge( $mylinks, $links );
}
}
-
+
/**
* This function runs after a successful, error-free save
*/
@@ -235,43 +234,43 @@ if (! class_exists ( "PostmanAdminController" )) {
// WordPress likes to keep GET parameters around for a long time
// (something in the call to settings_fields() does this)
// here we redirect after a successful save to clear those parameters
- PostmanUtils::redirect ( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL );
+ PostmanUtils::redirect( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL );
}
-
+
/**
* This function handle the request to import plugin data
*/
public function importSettingsAction() {
- $this->logger->debug ( 'is wpnonce import-settings?' );
+ $this->logger->debug( 'is wpnonce import-settings?' );
$success = true;
- if (wp_verify_nonce ( $_REQUEST ['_wpnonce'], PostmanAdminController::IMPORT_SETTINGS_SLUG )) {
- $success = PostmanOptions::getInstance ()->import ( $_POST ['settings'] );
+ if ( wp_verify_nonce( $_REQUEST ['_wpnonce'], PostmanAdminController::IMPORT_SETTINGS_SLUG ) ) {
+ $success = PostmanOptions::getInstance()->import( $_POST ['settings'] );
} else {
$success = false;
}
- if (! $success) {
- $this->messageHandler->addError ( __ ( 'There was an error importing the data.', Postman::TEXT_DOMAIN ) );
- $this->logger->error ( 'There was an error importing the data' );
+ if ( ! $success ) {
+ $this->messageHandler->addError( __( 'There was an error importing the data.', Postman::TEXT_DOMAIN ) );
+ $this->logger->error( 'There was an error importing the data' );
}
- PostmanUtils::redirect ( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL );
+ PostmanUtils::redirect( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL );
}
/**
* This function handle the request to purge plugin data
*/
public function handlePurgeDataAction() {
- $this->logger->debug ( 'is wpnonce purge-data?' );
- if (wp_verify_nonce ( $_REQUEST ['_wpnonce'], PostmanAdminController::PURGE_DATA_SLUG )) {
- $this->logger->debug ( 'Purging stored data' );
- delete_option ( PostmanOptions::POSTMAN_OPTIONS );
- delete_option ( PostmanOAuthToken::OPTIONS_NAME );
- delete_option ( PostmanAdminController::TEST_OPTIONS );
- $logPurger = new PostmanEmailLogPurger ();
- $logPurger->removeAll ();
- $this->messageHandler->addMessage ( __ ( 'Plugin data was removed.', Postman::TEXT_DOMAIN ) );
- PostmanUtils::redirect ( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL );
+ $this->logger->debug( 'is wpnonce purge-data?' );
+ if ( wp_verify_nonce( $_REQUEST ['_wpnonce'], PostmanAdminController::PURGE_DATA_SLUG ) ) {
+ $this->logger->debug( 'Purging stored data' );
+ delete_option( PostmanOptions::POSTMAN_OPTIONS );
+ delete_option( PostmanOAuthToken::OPTIONS_NAME );
+ delete_option( PostmanAdminController::TEST_OPTIONS );
+ $logPurger = new PostmanEmailLogPurger();
+ $logPurger->removeAll();
+ $this->messageHandler->addMessage( __( 'Plugin data was removed.', Postman::TEXT_DOMAIN ) );
+ PostmanUtils::redirect( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL );
}
}
-
+
/**
* Handles the authorization grant
*/
@@ -279,49 +278,49 @@ if (! class_exists ( "PostmanAdminController" )) {
$logger = $this->logger;
$options = $this->options;
$authorizationToken = $this->authorizationToken;
- $logger->debug ( 'Authorization in progress' );
- $transactionId = PostmanSession::getInstance ()->getOauthInProgress ();
-
+ $logger->debug( 'Authorization in progress' );
+ $transactionId = PostmanSession::getInstance()->getOauthInProgress();
+
// begin transaction
- PostmanUtils::lock ();
-
- $authenticationManager = PostmanAuthenticationManagerFactory::getInstance ()->createAuthenticationManager ();
+ PostmanUtils::lock();
+
+ $authenticationManager = PostmanAuthenticationManagerFactory::getInstance()->createAuthenticationManager();
try {
- if ($authenticationManager->processAuthorizationGrantCode ( $transactionId )) {
- $logger->debug ( 'Authorization successful' );
+ if ( $authenticationManager->processAuthorizationGrantCode( $transactionId ) ) {
+ $logger->debug( 'Authorization successful' );
// save to database
- $authorizationToken->save ();
- $this->messageHandler->addMessage ( __ ( 'The OAuth 2.0 authorization was successful. Ready to send e-mail.', Postman::TEXT_DOMAIN ) );
+ $authorizationToken->save();
+ $this->messageHandler->addMessage( __( 'The OAuth 2.0 authorization was successful. Ready to send e-mail.', Postman::TEXT_DOMAIN ) );
} else {
- $this->messageHandler->addError ( __ ( 'Your email provider did not grant Postman permission. Try again.', Postman::TEXT_DOMAIN ) );
+ $this->messageHandler->addError( __( 'Your email provider did not grant Postman permission. Try again.', Postman::TEXT_DOMAIN ) );
}
} catch ( PostmanStateIdMissingException $e ) {
- $this->messageHandler->addError ( __ ( 'The grant code from Google had no accompanying state and may be a forgery', Postman::TEXT_DOMAIN ) );
+ $this->messageHandler->addError( __( 'The grant code from Google had no accompanying state and may be a forgery', Postman::TEXT_DOMAIN ) );
} catch ( Exception $e ) {
- $logger->error ( 'Error: ' . get_class ( $e ) . ' code=' . $e->getCode () . ' message=' . $e->getMessage () );
+ $logger->error( 'Error: ' . get_class( $e ) . ' code=' . $e->getCode() . ' message=' . $e->getMessage() );
/* translators: %s is the error message */
- $this->messageHandler->addError ( sprintf ( __ ( 'Error authenticating with this Client ID. [%s]', Postman::TEXT_DOMAIN ), '<em>' . $e->getMessage () . '</em>' ) );
+ $this->messageHandler->addError( sprintf( __( 'Error authenticating with this Client ID. [%s]', Postman::TEXT_DOMAIN ), '<em>' . $e->getMessage() . '</em>' ) );
}
-
+
// clean-up
- PostmanUtils::unlock ();
- PostmanSession::getInstance ()->unsetOauthInProgress ();
-
+ PostmanUtils::unlock();
+ PostmanSession::getInstance()->unsetOauthInProgress();
+
// redirect home
- PostmanUtils::redirect ( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL );
+ PostmanUtils::redirect( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL );
}
-
+
/**
* This method is called when a user clicks on a "Request Permission from Google" link.
* This link will create a remote API call for Google and redirect the user from WordPress to Google.
* Google will redirect back to WordPress after the user responds.
*/
public function handleOAuthPermissionRequestAction() {
- $this->logger->debug ( 'handling OAuth Permission request' );
- $authenticationManager = PostmanAuthenticationManagerFactory::getInstance ()->createAuthenticationManager ();
- $transactionId = $authenticationManager->generateRequestTransactionId ();
- PostmanSession::getInstance ()->setOauthInProgress ( $transactionId );
- $authenticationManager->requestVerificationCode ( $transactionId );
+ $this->logger->debug( 'handling OAuth Permission request' );
+ $authenticationManager = PostmanAuthenticationManagerFactory::getInstance()->createAuthenticationManager();
+ $transactionId = $authenticationManager->generateRequestTransactionId();
+ PostmanSession::getInstance()->setOauthInProgress( $transactionId );
+ $authenticationManager->requestVerificationCode( $transactionId );
}
}
-} \ No newline at end of file
+}
diff --git a/postman-smtp.php b/postman-smtp.php
index 9aa0ed4..d16c5c0 100644
--- a/postman-smtp.php
+++ b/postman-smtp.php
@@ -4,10 +4,10 @@
* 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.5
+ * Version: 1.7.6
* Author: Jason Hendriks, Yehuda Hassine
- * Text Domain: postman-smtp
- * Author URI: https://github.com/yehudah/Postman-SMTP
+ * Text Domain: post-smtp
+ * Author URI: https://postmansmtp.com
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
@@ -70,5 +70,5 @@ function post_start( $startingMemory ) {
*/
function post_setupPostman() {
require_once 'Postman/Postman.php';
- $kevinCostner = new Postman( __FILE__, '1.7.3' );
+ $kevinCostner = new Postman( __FILE__, '1.7.6' );
}
diff --git a/readme.txt b/readme.txt
index c15d8dd..1d87f5d 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, sparkpost api
Requires at least: 3.9
Tested up to: 4.8
-Stable tag: 1.7.5
+Stable tag: 1.7.6
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -271,7 +271,11 @@ To avoid being flagged as spam, you need to prove your email isn't forged. On a
== Changelog ==
-= 1.7.3 - 2017-10-07 =
+= 1.7.6 - 2017-10-17
+* Missing sendgrid files
+* Fixed: Localization slug
+
+= 1.7.5 - 2017-10-07 =
* Fixed: security issue (XSS)
* Fixed: Small bug with Google API