Skip to content

Commit

Permalink
WP Mail SMTP 3.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
capuderg committed Oct 7, 2022
1 parent 1c3d208 commit d1cefbc
Show file tree
Hide file tree
Showing 34 changed files with 2,122 additions and 879 deletions.
Binary file modified assets/images/about/team.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
612 changes: 375 additions & 237 deletions assets/languages/wp-mail-smtp-vue.php

Large diffs are not rendered by default.

1,452 changes: 867 additions & 585 deletions assets/languages/wp-mail-smtp.pot

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/vue/css/wizard.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/vue/css/wizard.rtl.min.css

Large diffs are not rendered by default.

35 changes: 15 additions & 20 deletions assets/vue/js/chunk-vendors.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/vue/js/wizard.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"symfony/polyfill-mbstring": "1.19.0",
"symfony/polyfill-php72": "1.19.0",
"wikimedia/composer-merge-plugin": "1.4.1",
"woocommerce/action-scheduler": "3.4.0"
"woocommerce/action-scheduler": "3.4.2"
},
"autoload": {
"psr-4": {
Expand All @@ -58,7 +58,7 @@
]
},
"require-dev": {
"awesomemotive/wpforms-phpcs": "^1.0",
"awesomemotive/wpforms-phpcs": "^1.0.5",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"phpcompatibility/php-compatibility": "^9.3",
"roave/security-advisories": "dev-master",
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": "3.5.2",
"version": "3.6.1",
"description": "Make email delivery easy for WordPress. Connect with SMTP, Gmail, Outlook, SendGrid, Mailgun, Zoho, SES, and more.",
"private": true,
"repository": {
Expand Down
13 changes: 12 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, sendinblue, wp smtp
Requires at least: 5.2
Tested up to: 6.0
Stable tag: 3.5.2
Stable tag: 3.6.1
Requires PHP: 5.6.20

Make email delivery easy for WordPress. Connect with SMTP, Gmail, Outlook, SendGrid, Mailgun, Zoho, SES, and more. Rated #1 WordPress SMTP Email plugin.
Expand Down Expand Up @@ -333,6 +333,17 @@ By all means please contact us to discuss features or options you'd like to see

== Changelog ==

= 3.6.1 - 2022-10-06 =
- Added: The `wp_mail` function call backtrace to the Debug Events if the "Debug Email Sending" option is enabled.
- Added: Plugin's DB tables re-creation process in WP Site Health.
- Added: Debug Events retention period setting.
- Changed: Updated the list of conflicting plugins (added Zoho Mail).
- Changed: Improved conflicting plugins' admin notices (display multiple at once)
- Changed: Switched to the WP Core function `is_email` for verifying email addresses.
- Changed: Improved the detection if `wp_mail` function is overwritten.
- Fixed: Gmail mailer not using the correct From Email Address in Domain Checker.
- Fixed: Setup Wizard steps navigation, when going backwards.

= 3.5.2 - 2022-08-17 =
- Fixed: The check if `wp_mail` function is overwritten on Windows servers.

Expand Down
47 changes: 47 additions & 0 deletions src/Admin/DebugEvents/DebugEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use WPMailSMTP\Admin\Area;
use WPMailSMTP\Options;
use WPMailSMTP\Tasks\DebugEventsCleanupTask;
use WPMailSMTP\WP;

/**
* Debug Events class.
Expand All @@ -27,6 +29,51 @@ public function hooks() {
add_action( 'load-wp-mail-smtp_page_wp-mail-smtp-tools', [ $this, 'screen_options' ] );
add_filter( 'set-screen-option', [ $this, 'set_screen_options' ], 10, 3 );
add_filter( 'set_screen_option_wp_mail_smtp_debug_events_per_page', [ $this, 'set_screen_options' ], 10, 3 );

// Cancel previous debug events cleanup task if retention period option was changed.
add_filter( 'wp_mail_smtp_options_set', [ $this, 'maybe_cancel_debug_events_cleanup_task' ] );

// Detect debug events log retention period constant change.
if ( Options::init()->is_const_defined( 'debug_events', 'retention_period' ) ) {
add_action( 'admin_init', [ $this, 'detect_debug_events_retention_period_constant_change' ] );
}
}

/**
* Detect debug events retention period constant change.
*
* @since 3.6.0
*/
public function detect_debug_events_retention_period_constant_change() {

if ( ! WP::in_wp_admin() ) {
return;
}

if ( Options::init()->is_const_changed( 'debug_events', 'retention_period' ) ) {
( new DebugEventsCleanupTask() )->cancel();
}
}

/**
* Cancel previous debug events cleanup task if retention period option was changed.
*
* @since 3.6.0
*
* @param array $options Currently processed options passed to a filter hook.
*
* @return array
*/
public function maybe_cancel_debug_events_cleanup_task( $options ) {

if ( isset( $options['debug_events']['retention_period'] ) ) {
// If this option has changed, cancel the recurring cleanup task and init again.
if ( Options::init()->is_option_changed( $options['debug_events']['retention_period'], 'debug_events', 'retention_period' ) ) {
( new DebugEventsCleanupTask() )->cancel();
}
}

return $options;
}

/**
Expand Down
46 changes: 44 additions & 2 deletions src/Admin/DebugEvents/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,24 @@ public function get_initiator_file_line() {
return $initiator['line'];
}

/**
* Get the event's initiator backtrace.
*
* @since 3.6.0
*
* @return array
*/
private function get_initiator_backtrace() {

$initiator = (array) $this->get_initiator_raw();

if ( empty( $initiator['backtrace'] ) ) {
return [];
}

return $initiator['backtrace'];
}

/**
* Get the event preview HTML.
*
Expand All @@ -329,7 +347,8 @@ public function get_initiator_file_line() {
*/
public function get_details_html() {

$initiator = $this->get_initiator();
$initiator = $this->get_initiator();
$initiator_backtrace = $this->get_initiator_backtrace();

ob_start();
?>
Expand Down Expand Up @@ -364,6 +383,25 @@ public function get_details_html() {
esc_html( $this->get_initiator_file_line() )
);
?>

<?php if ( ! empty( $initiator_backtrace ) ) : ?>
<br><br>
<b><?php esc_html_e( 'Backtrace:', 'wp-mail-smtp' ); ?></b>
<br>
<?php
foreach ( $initiator_backtrace as $i => $item ) {
printf(
/* translators: %1$d - index number; %2$s - function name; %3$s - file path; %4$s - line number. */
esc_html__( '[%1$d] %2$s called at [%3$s:%4$s]', 'wp-mail-smtp' ),
$i,
isset( $item['class'] ) ? esc_html( $item['class'] . $item['type'] . $item['function'] ) : esc_html( $item['function'] ),
isset( $item['file'] ) ? esc_html( $item['file'] ) : '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
isset( $item['line'] ) ? esc_html( $item['line'] ) : '' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
echo '<br>';
}
?>
<?php endif; ?>
</p>
</div>
</div>
Expand Down Expand Up @@ -557,12 +595,16 @@ private function get_wpmail_backtrace() {

$backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace

foreach ( $backtrace as $item ) {
foreach ( $backtrace as $i => $item ) {
if ( $item['function'] === 'wp_mail' ) {
if ( isset( $item['function'] ) ) {
unset( $item['function'] );
}

if ( DebugEvents::is_debug_enabled() ) {
$item['backtrace'] = array_slice( $backtrace, $i );
}

return $item;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Admin/Pages/AboutTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public function display() {
'https://www.wpbeginner.com/?utm_source=wpmailsmtpplugin&utm_medium=pluginaboutpage&utm_campaign=aboutwpmailsmtp',
'https://optinmonster.com/?utm_source=wpmailsmtpplugin&utm_medium=pluginaboutpage&utm_campaign=aboutwpmailsmtp',
'https://www.monsterinsights.com/?utm_source=wpmailsmtpplugin&utm_medium=pluginaboutpage&utm_campaign=aboutwpmailsmtp',
'https://awesomemotive.com/'
// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
esc_url( wp_mail_smtp()->get_utm_url( 'https://awesomemotive.com/', [ 'medium' => 'pluginaboutpage', 'content' => 'aboutwpmailsmtp' ] ) )
);
?>
</p>
Expand Down
78 changes: 78 additions & 0 deletions src/Admin/Pages/DebugEventsTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,35 @@ public function display() {
</div>
</div>

<div id="wp-mail-smtp-setting-row-debug_events_retention_period" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-select wp-mail-smtp-clear">
<div class="wp-mail-smtp-setting-label">
<label for="wp-mail-smtp-setting-debug_events_retention_period">
<?php esc_html_e( 'Events Retention Period', 'wp-mail-smtp' ); ?>
</label>
</div>
<div class="wp-mail-smtp-setting-field">
<select name="wp-mail-smtp[debug_events][retention_period]" id="wp-mail-smtp-setting-debug_events_retention_period"
<?php disabled( $this->options->is_const_defined( 'debug_events', 'retention_period' ) ); ?>>
<option value=""><?php esc_html_e( 'Forever', 'wp-mail-smtp' ); ?></option>
<?php foreach ( $this->get_debug_events_retention_period_options() as $value => $label ) : ?>
<option value="<?php echo esc_attr( $value ); ?>" <?php selected( $this->options->get( 'debug_events', 'retention_period' ), $value ); ?>>
<?php echo esc_html( $label ); ?>
</option>
<?php endforeach; ?>
</select>
<p class="desc">
<?php
esc_html_e( 'Debug events older than the selected period will be permanently deleted from the database.', 'wp-mail-smtp' );

if ( $this->options->is_const_defined( 'debug_events', 'retention_period' ) ) {
//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<br>' . $this->options->get_const_set_message( 'WPMS_DEBUG_EVENTS_RETENTION_PERIOD' );
}
?>
</p>
</div>
</div>

<?php $this->display_save_btn(); ?>
</form>
<?php endif; ?>
Expand Down Expand Up @@ -470,4 +499,53 @@ protected function remove_get_parameters() {
);
}
}

/**
* Get debug events retention period options.
*
* @since 3.6.0
*
* @return array
*/
protected function get_debug_events_retention_period_options() {

$options = [
604800 => esc_html__( '1 Week', 'wp-mail-smtp' ),
2628000 => esc_html__( '1 Month', 'wp-mail-smtp' ),
7885000 => esc_html__( '3 Months', 'wp-mail-smtp' ),
15770000 => esc_html__( '6 Months', 'wp-mail-smtp' ),
31540000 => esc_html__( '1 Year', 'wp-mail-smtp' ),
];

$debug_event_retention_period = $this->options->get( 'debug_events', 'retention_period' );

// Check if defined value already in list and add it if not.
if (
! empty( $debug_event_retention_period ) &&
! isset( $options[ $debug_event_retention_period ] )
) {
$debug_event_retention_period_days = floor( $debug_event_retention_period / DAY_IN_SECONDS );

$options[ $debug_event_retention_period ] = sprintf(
/* translators: %d - days count. */
_n( '%d Day', '%d Days', $debug_event_retention_period_days, 'wp-mail-smtp' ),
$debug_event_retention_period_days
);

ksort( $options );
}

/**
* Filter debug events retention period options.
*
* @since 3.6.0
*
* @param array $options Debug Events retention period options.
* Option key in seconds.
*/
return apply_filters(
'wp_mail_smtp_admin_pages_debug_events_tab_get_debug_events_retention_period_options',
$options
);
}
}
1 change: 1 addition & 0 deletions src/Admin/Pages/ExportTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public function display() {
<label><input type="checkbox"><?php esc_html_e( 'Mailer', 'wp-mail-smtp' ); ?></label>
<label><input type="checkbox"><?php esc_html_e( 'Error Details', 'wp-mail-smtp' ); ?></label>
<label><input type="checkbox"><?php esc_html_e( 'Email log ID', 'wp-mail-smtp' ); ?></label>
<label><input type="checkbox"><?php esc_html_e( 'Source', 'wp-mail-smtp' ); ?></label>
</section>

<section class="wp-clearfix">
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/Pages/LogsTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function display() {
wp_mail_smtp()->get_upgrade_link(
[
'medium' => 'logs',
'content' => '',
'content' => 'Upgrade to Pro Button',
]
)
);
Expand Down
28 changes: 28 additions & 0 deletions src/Admin/Pages/SettingsTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,34 @@ public function process_post( $data ) { // phpcs:ignore Generic.Metrics.Cyclomat
// All the sanitization is done in Options class.
$options->set( $data, false, false );

/*
* If the mailer was switched to Gmail. Then we need to set the `from_email` address,
* to avoid the SPF and DKIM issue.
*/
if (
! empty( $old_opt['mail']['mailer'] ) &&
! empty( $data['mail']['mailer'] ) &&
$old_opt['mail']['mailer'] !== $data['mail']['mailer'] &&
is_array( $data ) && in_array( $data['mail']['mailer'], [ 'gmail' ], true ) &&
! empty( $data['gmail']['client_id'] ) &&
! empty( $data['gmail']['client_secret'] )
) {

$gmail_auth = new Auth();
$gmail_aliases = $gmail_auth->is_clients_saved() ? $gmail_auth->get_user_possible_send_from_addresses() : [];

if (
! empty( $gmail_aliases ) &&
isset( $gmail_aliases[0] ) &&
$data['mail']['from_email'] !== $gmail_aliases[0] &&
is_email( $gmail_aliases[0] ) !== false
) {
$data['mail']['from_email'] = $gmail_aliases[0];

$options->set( $data, false, false );
}
}

if ( $to_redirect ) {

// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Missing
Expand Down
5 changes: 4 additions & 1 deletion src/Admin/Pages/TestTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,11 @@ protected function get_debug_messages( $phpmailer, $smtp_debug ) {

$mailer_text .= '<strong>Mailer:</strong> ' . $this->debug['mailer'] . '<br>';
$mailer_text .= '<strong>Constants:</strong> ' . ( $options->is_const_enabled() ? 'Yes' : 'No' ) . '<br>';

if ( $conflicts->is_detected() ) {
$mailer_text .= '<strong>Conflicts:</strong> ' . esc_html( $conflicts->get_conflict_name() ) . '<br>';
$conflict_plugin_names = implode( ', ', $conflicts->get_all_conflict_names() );

$mailer_text .= '<strong>Conflicts:</strong> ' . esc_html( $conflict_plugin_names ) . '<br>';
}

// Display different debug info based on the mailer.
Expand Down
20 changes: 17 additions & 3 deletions src/Admin/SetupWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ public function enqueue_scripts() {
'upgrade_link' => wp_mail_smtp()->get_upgrade_link( 'setup-wizard' ),
'versions' => $this->prepare_versions_data(),
'public_url' => wp_mail_smtp()->assets_url . '/vue/',
'current_user_email' => wp_get_current_user()->user_email,
'completed_time' => self::get_stats()['completed_time'],
'education' => [
'upgrade_text' => esc_html__( 'We\'re sorry, the %mailer% mailer is not available on your plan. Please upgrade to the PRO plan to unlock all these awesome features.', 'wp-mail-smtp' ),
'upgrade_button' => esc_html__( 'Upgrade to Pro', 'wp-mail-smtp' ),
Expand Down Expand Up @@ -1084,12 +1086,24 @@ public function subscribe_to_newsletter() {
wp_send_json_error();
}

if ( function_exists( 'wpforms' ) && ( wpforms()->pro ) ) {
$wpforms_version_type = 'pro';
} elseif ( function_exists( 'wpforms' ) && ( ! wpforms()->pro ) ) {
$wpforms_version_type = 'lite';
}

$body = [
'email' => base64_encode( $email ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
];

if ( isset( $wpforms_version_type ) ) {
$body['wpforms_version_type'] = $wpforms_version_type;
}

wp_remote_post(
'https://connect.wpmailsmtp.com/subscribe/drip/',
[
'body' => [
'email' => base64_encode( $email ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
],
'body' => $body,
]
);

Expand Down
Loading

0 comments on commit d1cefbc

Please sign in to comment.