plugin updates

This commit is contained in:
Tony Volpe
2024-09-05 11:04:01 -04:00
parent ed6b060261
commit 50cd64dd3d
925 changed files with 16918 additions and 13003 deletions

View File

@@ -178,6 +178,8 @@ class Processor {
$phpmailer->Username = $connection_options->get( $mailer, 'user' );
$phpmailer->Password = $connection_options->get( $mailer, 'pass' );
}
$phpmailer->Timeout = 30;
// phpcs:enable
// Maybe set default reply-to header.

View File

@@ -177,14 +177,35 @@ class Mailer extends MailerAbstract {
}
/**
* Doesn't support this.
* So we do nothing.
* Set the Reply To information for an email.
*
* @since 4.1.0
* @since 4.1.1
*
* @param array $emails Reply To email addresses.
*/
public function set_reply_to( $emails ) {}
public function set_reply_to( $emails ) {
if ( empty( $emails ) ) {
return;
}
$data = [];
foreach ( $emails as $email ) {
if ( ! isset( $email[0] ) || ! filter_var( $email[0], FILTER_VALIDATE_EMAIL ) ) {
continue;
}
$data[] = $this->address_format( $email );
}
if ( ! empty( $data ) ) {
$this->set_body_header(
'Reply-To',
implode( ',', $data )
);
}
}
/**
* Set email subject.
@@ -399,7 +420,9 @@ class Mailer extends MailerAbstract {
*/
public function get_response_error() { // phpcs:ignore Generic.Metrics.NestingLevel.MaxExceeded, Generic.Metrics.CyclomaticComplexity.TooHigh
$error_text[] = $this->error_message;
$error_text = [
$this->error_message,
];
if ( ! empty( $this->response ) ) {
$body = wp_remote_retrieve_body( $this->response );
@@ -482,4 +505,21 @@ class Mailer extends MailerAbstract {
return $result;
}
/**
* Sanitize email header values.
*
* @since 4.1.1
*
* @param string $name Name of the header.
* @param string $value Value of the header.
*/
public function sanitize_header_value( $name, $value ) {
if ( strtolower( $name ) === 'reply-to' ) {
return $value;
}
return parent::sanitize_header_value( $name, $value );
}
}

View File

@@ -51,7 +51,10 @@ class SummaryEmailTask extends Task {
$date = new \DateTime( 'next monday 2pm', WP::wp_timezone() );
// Schedule the task.
$this->recurring( $date->getTimestamp(), WEEK_IN_SECONDS )->register();
$this
->recurring( $date->getTimestamp(), WEEK_IN_SECONDS )
->unique()
->register();
}
/**
@@ -64,14 +67,38 @@ class SummaryEmailTask extends Task {
public function process( $meta_id ) {
// Prevent email sending if summary report email is disabled.
if ( SummaryReportEmail::is_disabled() ) {
if ( SummaryReportEmail::is_disabled() || ! $this->is_allowed() ) {
return;
}
// Update the last sent week at the top to prevent multiple emails in case of task failure and retry.
update_option( 'wp_mail_smtp_summary_report_email_last_sent_week', current_time( 'W' ) );
$reports = wp_mail_smtp()->get_reports();
$email = $reports->get_summary_report_email();
$email->send();
}
/**
* Check if the summary report email is allowed to be sent.
*
* The email is allowed to be sent if it was not sent in the current week.
*
* @since 4.1.1
*
* @return bool
*/
private function is_allowed() {
$last_sent_week = get_option( 'wp_mail_smtp_summary_report_email_last_sent_week' );
$current_week = current_time( 'W' );
if ( $last_sent_week === false || ( (int) $current_week !== (int) $last_sent_week ) ) {
return true;
}
return false;
}
}

View File

@@ -3,6 +3,7 @@
namespace WPMailSMTP;
use WP_Error;
use WP_Filesystem_Direct;
/**
* WPMailSMTP uploads.
@@ -11,6 +12,13 @@ use WP_Error;
*/
class Uploads {
/**
* Uploads dir name.
*
* @since 4.1.1
*/
const ROOT_FOLDER_NAME = 'wp-mail-smtp';
/**
* Get WPMailSMTP upload root path (e.g. /wp-content/uploads/wp-mail-smtp).
*
@@ -26,7 +34,7 @@ class Uploads {
return new WP_Error( 'wp_upload_dir_error', $upload_dir['error'] );
}
$dir = 'wp-mail-smtp';
$dir = self::ROOT_FOLDER_NAME;
$upload_root = trailingslashit( realpath( $upload_dir['basedir'] ) ) . $dir;
@@ -196,4 +204,34 @@ class Uploads {
// Create empty index.html.
return file_put_contents( $index_file, '' ); // phpcs:ignore WordPress.WP.AlternativeFunctions
}
/**
* Delete the WPMailSMTP uploads directory.
*
* @since 4.1.1
*
* @return void
*/
public static function delete_upload_dir() {
// Get the upload dir.
$upload_dir = self::upload_dir();
// If there is an error, return.
if ( is_wp_error( $upload_dir ) ) {
return;
}
$upload_root = $upload_dir['path'];
// Get WP Filesystembase files.
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
// Initialize WP_Filesystem_Direct.
$wp_filesystem = new WP_Filesystem_Direct( false );
// Delete the directory.
$wp_filesystem->delete( $upload_root, true );
}
}

View File

@@ -345,8 +345,8 @@ class WP {
$locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
}
foreach ( $translations->entries as $msgid => $entry ) {
$locale[ $msgid ] = $entry->translations;
foreach ( $translations->entries as $entry ) {
$locale[ $entry->singular ] = $entry->translations;
}
return $locale;