Skip to content

Commit

Permalink
WP Mail SMTP 2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
slaFFik committed Jul 9, 2020
1 parent d96101c commit ddf20a5
Show file tree
Hide file tree
Showing 33 changed files with 1,339 additions and 538 deletions.
384 changes: 228 additions & 156 deletions assets/languages/wp-mail-smtp.pot

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,10 @@ gulp.task( 'replace_ver', gulp.series( 'replace_plugin_file_ver', 'replace_since
/**
* Task: build.
*/
gulp.task( 'build:lite', gulp.series( gulp.parallel( 'css', 'js', 'img', 'pot:lite' ), 'replace_ver', 'rename:lite', 'composer:lite', 'zip:lite' ) );
gulp.task( 'build:pro', gulp.series( gulp.parallel( 'css', 'js', 'img', 'pot' ), 'replace_ver', 'rename:pro', 'composer:pro', 'zip:pro' ) );
gulp.task( 'build:lite', gulp.series( gulp.parallel( 'css', 'js', 'img' ), 'replace_ver', 'pot:lite', 'rename:lite', 'composer:lite', 'zip:lite' ) );
gulp.task( 'build:pro', gulp.series( gulp.parallel( 'css', 'js', 'img' ), 'replace_ver', 'pot', 'rename:pro', 'composer:pro', 'zip:pro' ) );
gulp.task( 'build:test', gulp.series( 'rename:lite', 'composer:lite', 'zip:lite', 'rename:pro', 'composer:pro', 'zip:pro' ) );
gulp.task( 'build', gulp.series( gulp.parallel( 'css', 'js', 'img', 'pot' ), 'replace_ver', 'rename:lite', 'composer:lite', 'zip:lite', 'rename:pro', 'composer:pro', 'zip:pro' ) );
gulp.task( 'build', gulp.series( gulp.parallel( 'css', 'js', 'img' ), 'replace_ver', 'pot', 'rename:lite', 'composer:lite', 'zip:lite', 'rename:pro', 'composer:pro', 'zip:pro' ) );

/**
* Look out for relevant sass/js changes.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wp-mail-smtp",
"version": "2.1.1",
"version": "2.2.1",
"description": "Reconfigures the wp_mail() function to improve WordPress emails deliverability.",
"private": true,
"repository": {
Expand Down
10 changes: 9 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: wpforms, jaredatch, smub, slaFFik
Tags: smtp, wp mail smtp, wordpress smtp, gmail smtp, sendgrid smtp, mailgun smtp, mail, mailer, phpmailer, wp_mail, email, mailgun, sengrid, gmail, pepipost, sendinblue, wp smtp
Requires at least: 4.9
Tested up to: 5.4
Stable tag: 2.1.1
Stable tag: 2.2.1
Requires PHP: 5.5.0

The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 1 million sites.
Expand Down Expand Up @@ -229,6 +229,14 @@ By all means please contact us to discuss features or options you'd like to see

== Changelog ==

= 2.2.1 - 2020-07-09 =
* Added: Gmail mailer now supports aliases.
* Added: Support both old PHPMailer v5 (WordPress <=5.4) and PHPMailer v6 (WordPress >=5.5).
* Changed: Pepipost mailer is now using the native API v5 instead of the SendGrid migration API.
* Fixed: Incorrect Mailgun Domain Name option was not showing an email delivery error.
* Fixed: Empty debug errors for the Sendinblue mailer are no more.
* Fixed: Properly compare From Email option value with a correct default email address from WP core.

= 2.1.1 - 2020-06-08 =
* Changed: Remove current automatic default reply-to address and add WP filter `wp_mail_smtp_processor_set_default_reply_to` for setting default reply-to addresses.
* Changed: Improve description for several options with links to an article about how to properly use constants.
Expand Down
18 changes: 8 additions & 10 deletions src/Admin/Area.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public function maybe_redirect_email_log_menu_to_email_log_settings_tab() {
* @since 1.5.0 Added new assets for new pages.
* @since 1.7.0 Added jQuery Confirm library css/js files.
*
* @param string $hook
* @param string $hook Current hook.
*/
public function enqueue_assets( $hook ) {

Expand Down Expand Up @@ -305,9 +305,7 @@ public function enqueue_assets( $hook ) {
'title' => esc_html__( 'Heads up!', 'wp-mail-smtp' ),
'content' => wp_kses(
__( '<p>The Default (PHP) mailer is currently selected, but is not recommended because in most cases it does not resolve email delivery issues.</p><p>Please consider selecting and configuring one of the other mailers.</p>', 'wp-mail-smtp' ),
array(
'p' => true,
)
[ 'p' => [] ]
),
'save_button' => esc_html__( 'Save Settings', 'wp-mail-smtp' ),
'cancel_button' => esc_html__( 'Cancel', 'wp-mail-smtp' ),
Expand All @@ -322,11 +320,11 @@ public function enqueue_assets( $hook ) {
'upgrade_bonus' => '<p>' .
wp_kses(
__( '<strong>Bonus:</strong> WP Mail SMTP users get <span>$50 off</span> regular price,<br>applied at checkout.', 'wp-mail-smtp' ),
array(
'strong' => true,
'span' => true,
'br' => true,
)
[
'strong' => [],
'span' => [],
'br' => [],
]
)
. '</p>',
'upgrade_doc' => '<a href="https://wpmailsmtp.com/docs/how-to-upgrade-wp-mail-smtp-to-pro-version/?utm_source=WordPress&amp;utm_medium=link&amp;utm_campaign=liteplugin" target="_blank" rel="noopener noreferrer" class="already-purchased">
Expand Down Expand Up @@ -893,7 +891,7 @@ public function get_admin_page_url( $page = '' ) {
return add_query_arg(
'page',
$page,
admin_url( 'admin.php' )
WP::admin_url( 'admin.php' )
);
}

Expand Down
4 changes: 3 additions & 1 deletion src/Admin/PageAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace WPMailSMTP\Admin;

use WPMailSMTP\WP;

/**
* Class PageAbstract.
*
Expand All @@ -23,7 +25,7 @@ public function get_link() {
add_query_arg(
'tab',
$this->slug,
admin_url( 'admin.php?page=' . Area::SLUG )
WP::admin_url( 'admin.php?page=' . Area::SLUG )
)
);
}
Expand Down
30 changes: 27 additions & 3 deletions src/Admin/Pages/About.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use WPMailSMTP\Admin\PageAbstract;
use WPMailSMTP\Admin\PluginsInstallSkin;
use WPMailSMTP\Admin\PluginsInstallUpgrader;
use WPMailSMTP\WP;

/**
* Class About to display a page with About Us and Versus content.
Expand Down Expand Up @@ -42,7 +43,7 @@ public function get_link( $tab = '' ) {
return add_query_arg(
'tab',
$this->get_defined_tab( $tab ),
admin_url( 'admin.php?page=' . Area::SLUG . '-' . $this->slug )
WP::admin_url( 'admin.php?page=' . Area::SLUG . '-' . $this->slug )
);
}

Expand Down Expand Up @@ -214,6 +215,24 @@ protected function display_about() {

</div>

<?php

// Do not display the plugin section if the user can't install or activate them.
if ( ! current_user_can( 'install_plugins' ) && ! current_user_can( 'activate_plugins' ) ) {
return;
}

$this->display_plugins();
}

/**
* Display the plugins section.
*
* @since 2.2.0
*/
protected function display_plugins() {
?>

<div class="wp-mail-smtp-admin-about-plugins">
<div class="plugins-container">
<?php
Expand All @@ -229,11 +248,16 @@ protected function display_about() {
$data = array_merge( $data, $this->get_about_plugins_data( $plugin, true ) );
}

// Do not display a plugin which has to be installed and the user can't install it.
if ( ! current_user_can( 'install_plugins' ) && $data['status_class'] === 'status-download' ) {
continue;
}

?>
<div class="plugin-container">
<div class="plugin-item">
<div class="details wp-mail-smtp-clear">
<img src="<?php echo \esc_url( $plugin['icon'] ); ?>">
<img src="<?php echo \esc_url( $plugin['icon'] ); ?>" alt="<?php esc_attr_e( 'Plugin icon', 'wp-mail-smtp' ); ?>">
<h5 class="plugin-name">
<?php echo $plugin['name']; ?>
</h5>
Expand Down Expand Up @@ -430,7 +454,7 @@ public static function ajax_plugin_install() {
$error = \esc_html__( 'Could not install the plugin.', 'wp-mail-smtp' );

// Check for permissions.
if ( ! \current_user_can( 'activate_plugins' ) ) {
if ( ! \current_user_can( 'install_plugins' ) ) {
\wp_send_json_error( $error );
}

Expand Down
5 changes: 2 additions & 3 deletions src/Admin/Pages/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

use WPMailSMTP\Admin\Area;
use WPMailSMTP\Admin\PageAbstract;
use WPMailSMTP\WP;

/**
* Class Logs
*
* @since 1.5.0
*/
class Logs extends PageAbstract {

Expand All @@ -34,7 +33,7 @@ public function get_link() {
return add_query_arg(
'tab',
$this->slug,
admin_url( 'admin.php?page=' . Area::SLUG )
WP::admin_url( 'admin.php?page=' . Area::SLUG )
);
}

Expand Down
15 changes: 13 additions & 2 deletions src/Admin/Pages/MiscTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,12 @@ class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-checkbox wp-mail-smtp-c
}

/**
* @inheritdoc
* Process tab form submission ($_POST).
*
* @since 1.0.0
* @since 2.2.0 Fixed checkbox saving and use the correct merge to prevent breaking other 'general' checkboxes.
*
* @param array $data Tab data specific for the plugin ($_POST).
*/
public function process_post( $data ) {

Expand All @@ -207,14 +212,20 @@ public function process_post( $data ) {
$options = new Options();

// Unchecked checkboxes doesn't exist in $_POST, so we need to ensure we actually have them in data to save.
if ( empty( $data['general']['do_not_send'] ) ) {
$data['general']['do_not_send'] = false;
}
if ( empty( $data['general']['am_notifications_hidden'] ) ) {
$data['general']['am_notifications_hidden'] = false;
}
if ( empty( $data['general']['email_delivery_errors_hidden'] ) ) {
$data['general']['email_delivery_errors_hidden'] = false;
}
if ( empty( $data['general']['uninstall'] ) ) {
$data['general']['uninstall'] = false;
}

$to_save = array_merge( $options->get_all(), $data );
$to_save = Options::array_merge_recursive( $options->get_all(), $data );

// All the sanitization is done there.
$options->set( $to_save );
Expand Down
65 changes: 54 additions & 11 deletions src/Admin/Pages/SettingsTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use WPMailSMTP\Admin\PageAbstract;
use WPMailSMTP\Debug;
use WPMailSMTP\Options;
use WPMailSMTP\Providers\Gmail\Auth;
use WPMailSMTP\WP;

/**
Expand Down Expand Up @@ -58,6 +59,8 @@ public function display() {
<form method="POST" action="" autocomplete="off">
<?php $this->wp_nonce_field(); ?>

<?php ob_start(); ?>

<!-- License Section Title -->
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content wp-mail-smtp-clear section-heading" id="wp-mail-smtp-setting-row-license-heading">
<div class="wp-mail-smtp-setting-field">
Expand Down Expand Up @@ -92,16 +95,37 @@ public function display() {
<label for="wp-mail-smtp-setting-from_email"><?php esc_html_e( 'From Email', 'wp-mail-smtp' ); ?></label>
</div>
<div class="wp-mail-smtp-setting-field">
<input name="wp-mail-smtp[mail][from_email]" type="email"
value="<?php echo esc_attr( $options->get( 'mail', 'from_email' ) ); ?>"
<?php echo $options->is_const_defined( 'mail', 'from_email' ) || ! empty( $disabled_email ) ? 'disabled' : ''; ?>
id="wp-mail-smtp-setting-from_email" spellcheck="false"
placeholder="<?php echo esc_attr( wp_mail_smtp()->get_processor()->get_default_email() ); ?>">
<?php if ( 'gmail' !== $mailer ) : ?>
<input name="wp-mail-smtp[mail][from_email]" type="email"
value="<?php echo esc_attr( $options->get( 'mail', 'from_email' ) ); ?>"
<?php echo $options->is_const_defined( 'mail', 'from_email' ) || ! empty( $disabled_email ) ? 'disabled' : ''; ?>
id="wp-mail-smtp-setting-from_email" spellcheck="false"
placeholder="<?php echo esc_attr( wp_mail_smtp()->get_processor()->get_default_email() ); ?>">
<?php else : ?>
<?php
// Gmail mailer From Email selector.
$gmail_auth = new Auth();
$gmail_aliases = $gmail_auth->is_clients_saved() ? $gmail_auth->get_user_possible_send_from_addresses() : [];
?>

<?php if ( empty( $gmail_aliases ) ) : ?>
<select name="wp-mail-smtp[mail][from_email]" id="wp-mail-smtp-setting-from_email" disabled>
<option value=""><?php esc_html_e( 'Please first authorize the Gmail mailer below', 'wp-mail-smtp' ); ?></option>
</select>
<?php else : ?>
<select name="wp-mail-smtp[mail][from_email]" id="wp-mail-smtp-setting-from_email">
<?php foreach ( $gmail_aliases as $gmail_email_address ) : ?>
<option value="<?php echo esc_attr( $gmail_email_address ); ?>" <?php selected( $options->get( 'mail', 'from_email' ), $gmail_email_address ); ?>><?php echo esc_html( $gmail_email_address ); ?></option>
<?php endforeach; ?>
</select>
<?php endif; ?>

<?php endif; ?>

<?php if ( empty( $disabled_email ) ) : ?>
<p class="desc">
<?php esc_html_e( 'The email address which emails are sent from.', 'wp-mail-smtp' ); ?><br/>
<?php esc_html_e( 'If you using an email provider (Gmail, Yahoo, Outlook.com, etc) this should be your email address for that account.', 'wp-mail-smtp' ); ?>
<?php esc_html_e( 'If you\'re using an email provider (Yahoo, Outlook.com, etc) this should be your email address for that account.', 'wp-mail-smtp' ); ?>
</p>
<p class="desc">
<?php esc_html_e( 'Please note that other plugins can change this, to prevent this use the setting below.', 'wp-mail-smtp' ); ?>
Expand All @@ -110,18 +134,30 @@ public function display() {

<hr class="wp-mail-smtp-setting-mid-row-sep">

<input name="wp-mail-smtp[mail][from_email_force]" type="checkbox"
value="true" <?php checked( true, (bool) $options->get( 'mail', 'from_email_force' ) ); ?>
<?php echo $options->is_const_defined( 'mail', 'from_email_force' ) || ! empty( $disabled_email ) ? 'disabled' : ''; ?>
id="wp-mail-smtp-setting-from_email_force">
<?php if ( 'gmail' !== $mailer ) : ?>
<input name="wp-mail-smtp[mail][from_email_force]" type="checkbox"
value="true" <?php checked( true, (bool) $options->get( 'mail', 'from_email_force' ) ); ?>
<?php echo $options->is_const_defined( 'mail', 'from_email_force' ) || ! empty( $disabled_email ) ? 'disabled' : ''; ?>
id="wp-mail-smtp-setting-from_email_force">
<?php else : ?>
<input name="wp-mail-smtp[mail][from_email_force]" type="checkbox"
value="true" checked="checked" disabled
id="wp-mail-smtp-setting-from_email_force">
<?php endif; ?>

<label for="wp-mail-smtp-setting-from_email_force">
<?php esc_html_e( 'Force From Email', 'wp-mail-smtp' ); ?>
</label>

<?php if ( ! empty( $disabled_email ) ) : ?>
<p class="desc">
<?php esc_html_e( 'Current provider will automatically force From Email to be the email address that you use to set up the connection below.', 'wp-mail-smtp' ); ?>
<?php
if ( 'gmail' !== $mailer ) :
esc_html_e( 'Current provider will automatically force From Email to be the email address that you use to set up the connection below.', 'wp-mail-smtp' );
else :
esc_html_e( 'Gmail mailer will automatically force From Email to be the email address that you selected above.', 'wp-mail-smtp' );
endif;
?>
</p>
<?php else : ?>
<p class="desc">
Expand Down Expand Up @@ -292,6 +328,11 @@ class="wp-mail-smtp-mailer-notice-dismiss js-wp-mail-smtp-mailer-notice-dismiss"

</div>

<?php
$settings_content = apply_filters( 'wp_mail_smtp_admin_settings_tab_display', ob_get_clean() );
echo $settings_content; // phpcs:ignore
?>

<?php $this->display_save_btn(); ?>

</form>
Expand Down Expand Up @@ -525,6 +566,8 @@ public function process_post( $data ) {
}
}

$data = apply_filters( 'wp_mail_smtp_settings_tab_process_post', $data );

// New gmail clients data will be added from new $data.
$to_save = Options::array_merge_recursive( $old_opt, $data );

Expand Down
6 changes: 3 additions & 3 deletions src/Admin/Pages/TestTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use WPMailSMTP\Conflicts;
use WPMailSMTP\Debug;
use WPMailSMTP\MailCatcher;
use WPMailSMTP\MailCatcherInterface;
use WPMailSMTP\Options;
use WPMailSMTP\WP;
use WPMailSMTP\Admin\PageAbstract;
Expand Down Expand Up @@ -393,8 +393,8 @@ public static function set_test_html_content_type() {
*
* @since 1.0.0
*
* @param MailCatcher $phpmailer
* @param string $smtp_debug
* @param MailCatcherInterface $phpmailer The MailCatcher object.
* @param string $smtp_debug The SMTP debug message.
*
* @return string
*/
Expand Down
Loading

0 comments on commit ddf20a5

Please sign in to comment.