Skip to content

Commit 4e17774

Browse files
update plugins/post-smtp
1 parent 58ce470 commit 4e17774

405 files changed

Lines changed: 33193 additions & 253 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

wp-content/plugins/post-smtp/Postman/Dashboard/NewDashboard.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ public function __construct() {
1111
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
1212
add_filter( 'post_smtp__new_dashboard', '__return_true' );
1313
add_action( 'post_smtp__new_dashboard_content', array( $this, 'dashboard_content' ) );
14-
if ( post_smtp_has_pro() ) {
14+
15+
if (
16+
is_plugin_active( 'report-and-tracking-addon-premium/post-smtp-report-and-tracking.php' )
17+
||
18+
is_plugin_active( 'post-smtp-pro/post-smtp-pro.php' )
19+
) {
1520
add_filter( 'post_smtp_dashboard_opened_emails_count', array( $this, 'opened_email_count' ), 10, 2 );
16-
}
21+
}
22+
1723
}
1824

1925
private function include() {

wp-content/plugins/post-smtp/Postman/Dashboard/assets/css/app.css

Lines changed: 26 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wp-content/plugins/post-smtp/Postman/Dashboard/assets/js/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wp-content/plugins/post-smtp/Postman/Extensions/Core/Notifications/PostmanNotify.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,15 @@ public function sanitize($new_input, $input, $sanitizer) {
8484

8585
//Webhook Alerts
8686
$webhook_urls = array();
87-
foreach ( $_POST['postman_options']['webhook_alerts_urls'] as $key => $url ) {
8887

89-
if( ! empty( $url ) ) {
90-
$webhook_urls[] = esc_url( $url );
88+
if( isset( $_POST['postman_options']['webhook_alerts_urls'] ) ) {
89+
90+
foreach ( $_POST['postman_options']['webhook_alerts_urls'] as $key => $url ) {
91+
92+
if( ! empty( $url ) ) {
93+
$webhook_urls[] = esc_url( $url );
94+
}
95+
9196
}
9297

9398
}

wp-content/plugins/post-smtp/Postman/Postman-Email-Health-Report/PostmanEmailReportSending.php

Lines changed: 75 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -36,53 +36,93 @@ public static function get_instance() {
3636
* @version 1.0.0
3737
*/
3838
public function __construct() {
39-
40-
add_action( 'init', array( $this, 'send_report' ) );
39+
add_action( 'init', array( $this, 'schedule_email_reporting' ) );
40+
add_action( 'postman_rat_email_report', array( $this, 'handle_email_reporting' ) );
41+
add_filter( 'cron_schedules', array( $this, 'add_monthly_schedule' ) );
4142
}
4243

44+
4345
/**
44-
* Send the report
46+
* Schedules the email reporting cron event based on user-defined settings.
4547
*
46-
* @since 2.9.0
47-
* @version 1.0.0
48+
* This function retrieves the reporting interval from plugin options and schedules
49+
* a WordPress cron job accordingly. If a schedule already exists and its interval
50+
* is different from the new one, the existing schedule is unscheduled and a new
51+
* schedule is created.
52+
* @since 3.0.1
53+
* @version 3.0.1
4854
*/
49-
public function send_report() {
50-
55+
public function schedule_email_reporting() {
5156
$options = get_option( 'postman_rat' );
52-
53-
$enabled = ( $options && isset( $options['enable_email_reporting'] ) ) ? $options['enable_email_reporting'] : false;
54-
55-
$interval = ( $options && isset( $options['reporting_interval'] ) ) ? $options['reporting_interval'] : false;
56-
57-
$has_sent = get_transient( 'ps_rat_has_sent' );
58-
59-
// If transient expired, let's send :).
60-
if ( $enabled && $interval && ! $has_sent ) {
61-
62-
$expiry_time = '';
63-
$report_sent = $this->send_mail( $interval );
64-
65-
if ( $report_sent ) {
66-
67-
if ( $interval === 'd' ) {
68-
69-
$expiry_time = DAY_IN_SECONDS;
70-
}
71-
if ( $interval === 'w' ) {
72-
73-
$expiry_time = WEEK_IN_SECONDS;
57+
if ( $options && isset( $options['enable_email_reporting'] ) && $options['enable_email_reporting'] ) {
58+
$interval = isset( $options['reporting_interval'] ) ? $options['reporting_interval'] : false;
59+
60+
if ( $interval ) {
61+
$schedules = array(
62+
'd' => 'daily',
63+
'w' => 'weekly',
64+
'm' => 'monthly',
65+
);
66+
67+
$schedule = isset( $schedules[ $interval ] ) ? $schedules[ $interval ] : false;
68+
if ( $schedule ) {
69+
$timestamp = wp_next_scheduled( 'postman_rat_email_report' );
70+
if ( $timestamp ) {
71+
$current_interval = wp_get_schedule( 'postman_rat_email_report' );
72+
if ( $current_interval !== $schedule ) {
73+
wp_unschedule_event( $timestamp, 'postman_rat_email_report' );
74+
} else {
75+
return;
76+
}
77+
}
78+
$current_time = current_time( 'timestamp' );
79+
$midnight = strtotime( 'tomorrow midnight', $current_time ) - 1;
80+
wp_schedule_event( $current_time, $schedule, 'postman_rat_email_report' );
7481
}
75-
if ( $interval === 'm' ) {
82+
}
83+
}else{
84+
$interval = isset( $options['reporting_interval'] ) ? $options['reporting_interval'] : false;
85+
$timestamp = wp_next_scheduled( 'postman_rat_email_report' );
86+
if ( $timestamp ) {
87+
wp_unschedule_event( $timestamp, 'postman_rat_email_report' );
88+
}
89+
}
90+
}
7691

77-
$expiry_time = MONTH_IN_SECONDS;
78-
}
92+
/**
93+
* Handles the email reporting functionality triggered by the cron job.
94+
*
95+
* This function checks if email reporting is enabled and retrieves the configured
96+
* reporting interval. If both conditions are met, it triggers the email-sending
97+
* functionality.
98+
* @since 3.0.1
99+
* @version 3.0.1
100+
*/
101+
public function handle_email_reporting() {
102+
$options = get_option( 'postman_rat' );
103+
$enabled = isset( $options['enable_email_reporting'] ) ? $options['enable_email_reporting'] : false;
104+
$interval = isset( $options['reporting_interval'] ) ? $options['reporting_interval'] : false;
79105

80-
// Set Future Transient :D.
81-
set_transient( 'ps_rat_has_sent', '1', $expiry_time );
82-
}
106+
if ( $enabled && $interval ) {
107+
$report_sent = $this->send_mail( $interval );
83108
}
84109
}
85110

111+
/**
112+
* Add a custom monthly schedule to WordPress's cron system.
113+
*
114+
* @param array $schedules The existing cron schedules.
115+
* @return array Modified array of cron schedules with 'monthly' added.
116+
* @since 3.0.1
117+
* @version 3.0.1
118+
*/
119+
public function add_monthly_schedule( $schedules ) {
120+
$schedules['monthly'] = array(
121+
'interval' => 30 * DAY_IN_SECONDS,
122+
'display' => __( 'Once Monthly', 'post-smtp' ),
123+
);
124+
return $schedules;
125+
}
86126

87127
/**
88128
* Get total email count

wp-content/plugins/post-smtp/Postman/Postman-Email-Log/PostmanEmailLogService.php

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,29 @@ public function writeFailureLog( PostmanEmailLog $log, PostmanMessage $message =
133133
}
134134
}
135135

136+
/**
137+
* Sanitizes a list of emails, handling both single and multiple email inputs.
138+
*
139+
* @param string|array $emails The email(s) to sanitize.
140+
* @return string Sanitized email(s) as a comma-separated string.
141+
* @since 3.1.2
142+
* @version 1.0.0
143+
*/
144+
public function sanitize_emails( $emails ) {
145+
if ( empty( $emails ) ) {
146+
return '';
147+
}
148+
149+
$email_list = is_array( $emails ) ? $emails : explode( ',', $emails );
150+
151+
$sanitized_emails = array_map( function ( $email ) {
152+
$email = trim( $email );
153+
return filter_var( $email, FILTER_VALIDATE_EMAIL ) ? sanitize_email( $email ) : '';
154+
}, $email_list );
155+
156+
return implode( ', ', array_filter( $sanitized_emails ) );
157+
}
158+
136159
/**
137160
* Writes an email sending attempt to the Email Log
138161
*
@@ -153,23 +176,21 @@ private function writeToEmailLog( PostmanEmailLog $log, PostmanMessage $message
153176
}
154177

155178
$new_status = apply_filters( 'post_smtp_log_status', $new_status, $log, $message );
156-
157179
//If Table exists, Insert Log into Table
158180
if( $this->new_logging ) {
159-
160181
$data = array();
161-
$data['solution'] = apply_filters( 'post_smtp_log_solution', null, $new_status, $log, $message );
162-
$data['success'] = empty( $new_status ) ? 1 : $new_status;
163-
$data['from_header'] = $log->sender;
164-
$data['to_header'] = !empty( $log->toRecipients ) ? $log->toRecipients : '';
165-
$data['cc_header'] = !empty( $log->ccRecipients ) ? $log->ccRecipients : '';
166-
$data['bcc_header'] = !empty( $log->bccRecipients ) ? $log->bccRecipients : '';
167-
$data['reply_to_header'] = !empty( $log->replyTo ) ? $log->replyTo : '';
168-
$data['transport_uri'] = !empty( $log->transportUri ) ? $log->transportUri : '';
169-
$data['original_to'] = is_array( $log->originalTo ) ? implode( ',', $log->originalTo ) : $log->originalTo;
170-
$data['original_subject'] = !empty( $log->originalSubject ) ? $log->originalSubject : '';
182+
$data['solution'] = apply_filters( 'post_smtp_log_solution', null, $new_status, $log, $message );
183+
$data['success'] = empty( $new_status ) ? 1 : $new_status;
184+
$data['from_header'] = $log->sender;
185+
$data['to_header'] = $this->sanitize_emails( $log->toRecipients );
186+
$data['cc_header'] = $this->sanitize_emails( $log->ccRecipients );
187+
$data['bcc_header'] = $this->sanitize_emails( $log->bccRecipients );
188+
$data['reply_to_header'] = $this->sanitize_emails( $log->replyTo );
189+
$data['transport_uri'] = !empty( $log->transportUri ) ? $log->transportUri : '';
190+
$data['original_to'] = $this->sanitize_emails( $log->originalTo );
191+
$data['original_subject'] = !empty( $log->originalSubject ) ? sanitize_text_field( $log->originalSubject ) : '';
171192
$data['original_message'] = $log->originalMessage;
172-
$data['original_headers'] = is_array($log->originalHeaders) ? serialize($log->originalHeaders) : $log->originalHeaders;
193+
$data['original_headers'] = is_array( $log->originalHeaders ) ? serialize( $log->originalHeaders ) : $log->originalHeaders;
173194
$data['session_transcript'] = $log->sessionTranscript;
174195

175196
$email_logs = new PostmanEmailLogs();
@@ -182,9 +203,8 @@ private function writeToEmailLog( PostmanEmailLog $log, PostmanMessage $message
182203
* @version 1.0.0
183204
*/
184205
$log_id = apply_filters( 'post_smtp_update_email_log_id', '' );
185-
186206
$log_id = $email_logs->save( $data, $log_id );
187-
207+
188208
/**
189209
* Fires after the email log is saved
190210
*

0 commit comments

Comments
 (0)