Post SMTP Mailer/Email Log - Version 1.7.9

Version Description

  • 2017-11-20
  • Fixed: misspled false
  • Fixed: feedback form
  • Fixed: Some localization strings
  • Removed: deprecated function
  • New: Option to input emails when resend email
  • Added: explain message on email log filter
Download this release

Release Info

Developer yehudah
Plugin Icon 128x128 Post SMTP Mailer/Email Log
Version 1.7.9
Comparing to
See all releases

Code changes from version 1.7.8 to 1.7.9

Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php CHANGED
@@ -2,212 +2,210 @@
2
  class PostmanSettingsRegistry {
3
 
4
  private $options;
5
-
6
  public function __construct() {
7
  $this->options = PostmanOptions::getInstance();
8
  }
9
-
10
  /**
11
  * Fires on the admin_init method
12
  */
13
  public function on_admin_init() {
14
- //
15
- $this->registerSettings ();
16
  }
17
-
18
  /**
19
  * Register and add settings
20
  */
21
  private function registerSettings() {
22
-
23
  // only administrators should be able to trigger this
24
- if (PostmanUtils::isAdmin ()) {
25
- //
26
- $sanitizer = new PostmanInputSanitizer ();
27
- register_setting ( PostmanAdminController::SETTINGS_GROUP_NAME, PostmanOptions::POSTMAN_OPTIONS, array (
28
  $sanitizer,
29
- 'sanitize'
30
  ) );
31
-
32
  // Sanitize
33
- add_settings_section ( 'transport_section', __ ( 'Transport', Postman::TEXT_DOMAIN ), array (
34
  $this,
35
- 'printTransportSectionInfo'
36
  ), 'transport_options' );
37
-
38
- add_settings_field ( PostmanOptions::TRANSPORT_TYPE, _x ( 'Type', '(i.e.) What kind is it?', Postman::TEXT_DOMAIN ), array (
39
  $this,
40
- 'transport_type_callback'
41
  ), 'transport_options', 'transport_section' );
42
-
43
  // the Message From section
44
- add_settings_section ( PostmanAdminController::MESSAGE_FROM_SECTION, _x ( 'From Address', 'The Message Sender Email Address', Postman::TEXT_DOMAIN ), array (
45
  $this,
46
- 'printMessageFromSectionInfo'
47
  ), PostmanAdminController::MESSAGE_FROM_OPTIONS );
48
-
49
- add_settings_field ( PostmanOptions::MESSAGE_SENDER_EMAIL, __ ( 'Email Address', Postman::TEXT_DOMAIN ), array (
50
  $this,
51
- 'from_email_callback'
52
  ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
53
-
54
- add_settings_field ( PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE, '', array (
55
  $this,
56
- 'prevent_from_email_override_callback'
57
  ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
58
-
59
- add_settings_field ( PostmanOptions::MESSAGE_SENDER_NAME, __ ( 'Name', Postman::TEXT_DOMAIN ), array (
60
  $this,
61
- 'sender_name_callback'
62
  ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
63
-
64
- add_settings_field ( PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE, '', array (
65
  $this,
66
- 'prevent_from_name_override_callback'
67
  ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
68
-
69
  // the Additional Addresses section
70
- add_settings_section ( PostmanAdminController::MESSAGE_SECTION, __ ( 'Additional Email Addresses', Postman::TEXT_DOMAIN ), array (
71
  $this,
72
- 'printMessageSectionInfo'
73
  ), PostmanAdminController::MESSAGE_OPTIONS );
74
-
75
- add_settings_field ( PostmanOptions::REPLY_TO, __ ( 'Reply-To', Postman::TEXT_DOMAIN ), array (
76
  $this,
77
- 'reply_to_callback'
78
  ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
79
-
80
- add_settings_field ( PostmanOptions::FORCED_TO_RECIPIENTS, __ ( 'To Recipient(s)', Postman::TEXT_DOMAIN ), array (
81
  $this,
82
- 'to_callback'
83
  ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
84
-
85
- add_settings_field ( PostmanOptions::FORCED_CC_RECIPIENTS, __ ( 'Carbon Copy Recipient(s)', Postman::TEXT_DOMAIN ), array (
86
  $this,
87
- 'cc_callback'
88
  ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
89
-
90
- add_settings_field ( PostmanOptions::FORCED_BCC_RECIPIENTS, __ ( 'Blind Carbon Copy Recipient(s)', Postman::TEXT_DOMAIN ), array (
91
  $this,
92
- 'bcc_callback'
93
  ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
94
-
95
  // the Additional Headers section
96
- add_settings_section ( PostmanAdminController::MESSAGE_HEADERS_SECTION, __ ( 'Additional Headers', Postman::TEXT_DOMAIN ), array (
97
  $this,
98
- 'printAdditionalHeadersSectionInfo'
99
  ), PostmanAdminController::MESSAGE_HEADERS_OPTIONS );
100
-
101
- add_settings_field ( PostmanOptions::ADDITIONAL_HEADERS, __ ( 'Custom Headers', Postman::TEXT_DOMAIN ), array (
102
  $this,
103
- 'headers_callback'
104
  ), PostmanAdminController::MESSAGE_HEADERS_OPTIONS, PostmanAdminController::MESSAGE_HEADERS_SECTION );
105
-
106
  // the Email Validation section
107
- add_settings_section ( PostmanAdminController::EMAIL_VALIDATION_SECTION, __ ( 'Validation', Postman::TEXT_DOMAIN ), array (
108
  $this,
109
- 'printEmailValidationSectionInfo'
110
  ), PostmanAdminController::EMAIL_VALIDATION_OPTIONS );
111
-
112
- add_settings_field ( PostmanOptions::ENVELOPE_SENDER, __ ( 'Email Address', Postman::TEXT_DOMAIN ), array (
113
  $this,
114
- 'disable_email_validation_callback'
115
  ), PostmanAdminController::EMAIL_VALIDATION_OPTIONS, PostmanAdminController::EMAIL_VALIDATION_SECTION );
116
-
117
  // the Logging section
118
- add_settings_section ( PostmanAdminController::LOGGING_SECTION, __ ( 'Email Log Settings', Postman::TEXT_DOMAIN ), array (
119
  $this,
120
- 'printLoggingSectionInfo'
121
  ), PostmanAdminController::LOGGING_OPTIONS );
122
-
123
- add_settings_field ( 'logging_status', __ ( 'Enable Logging', Postman::TEXT_DOMAIN ), array (
124
  $this,
125
- 'loggingStatusInputField'
126
  ), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION );
127
-
128
- add_settings_field ( 'logging_max_entries', __ ( 'Maximum Log Entries', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array (
129
  $this,
130
- 'loggingMaxEntriesInputField'
131
  ), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION );
132
-
133
- add_settings_field ( PostmanOptions::TRANSCRIPT_SIZE, __ ( 'Maximum Transcript Size', Postman::TEXT_DOMAIN ), array (
134
  $this,
135
- 'transcriptSizeInputField'
136
  ), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION );
137
-
138
  // the Network section
139
- add_settings_section ( PostmanAdminController::NETWORK_SECTION, __ ( 'Network Settings', Postman::TEXT_DOMAIN ), array (
140
  $this,
141
- 'printNetworkSectionInfo'
142
  ), PostmanAdminController::NETWORK_OPTIONS );
143
-
144
- add_settings_field ( 'connection_timeout', _x ( 'TCP Connection Timeout (sec)', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array (
145
  $this,
146
- 'connection_timeout_callback'
147
  ), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION );
148
-
149
- add_settings_field ( 'read_timeout', _x ( 'TCP Read Timeout (sec)', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array (
150
  $this,
151
- 'read_timeout_callback'
152
  ), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION );
153
-
154
  // the Advanced section
155
- add_settings_section ( PostmanAdminController::ADVANCED_SECTION, _x ( 'Miscellaneous Settings', 'Configuration Section Title', Postman::TEXT_DOMAIN ), array (
156
  $this,
157
- 'printAdvancedSectionInfo'
158
  ), PostmanAdminController::ADVANCED_OPTIONS );
159
-
160
- add_settings_field ( PostmanOptions::LOG_LEVEL, _x ( 'PHP Log Level', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array (
161
  $this,
162
- 'log_level_callback'
163
  ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
164
-
165
- add_settings_field ( PostmanOptions::RUN_MODE, _x ( 'Delivery Mode', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array (
166
  $this,
167
- 'runModeCallback'
168
  ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
169
-
170
- add_settings_field ( PostmanOptions::STEALTH_MODE, _x ( 'Stealth Mode', 'This mode removes the Postman X-Mailer signature from emails', Postman::TEXT_DOMAIN ), array (
171
  $this,
172
- 'stealthModeCallback'
173
  ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
174
-
175
- add_settings_field ( PostmanOptions::TEMPORARY_DIRECTORY, __ ( 'Temporary Directory', Postman::TEXT_DOMAIN ), array (
176
  $this,
177
- 'temporaryDirectoryCallback'
178
  ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
179
  }
180
  }
181
-
182
  /**
183
  * Print the Transport section info
184
  */
185
  public function printTransportSectionInfo() {
186
- print __ ( 'Choose SMTP or a vendor-specific API:', Postman::TEXT_DOMAIN );
187
  }
188
  public function printLoggingSectionInfo() {
189
- print __ ( 'Configure the delivery audit log:', Postman::TEXT_DOMAIN );
190
  }
191
-
192
  /**
193
  * Print the Section text
194
  */
195
  public function printMessageFromSectionInfo() {
196
- print sprintf ( __ ( 'This address, like the <b>letterhead</b> printed on a letter, identifies the sender to the recipient. Change this when you are sending on behalf of someone else, for example to use Google\'s <a href="%s">Send Mail As</a> feature. Other plugins, especially Contact Forms, may override this field to be your visitor\'s address.', Postman::TEXT_DOMAIN ), 'https://support.google.com/mail/answer/22370?hl=en' );
197
  }
198
-
199
  /**
200
  * Print the Section text
201
  */
202
  public function printMessageSectionInfo() {
203
- print __ ( 'Separate multiple <b>to</b>/<b>cc</b>/<b>bcc</b> recipients with commas.', Postman::TEXT_DOMAIN );
204
  }
205
-
206
  /**
207
  * Print the Section text
208
  */
209
  public function printNetworkSectionInfo() {
210
- print __ ( 'Increase the timeouts if your host is intermittenly failing to send mail. Be careful, this also correlates to how long your user must wait if the mail server is unreachable.', Postman::TEXT_DOMAIN );
211
  }
212
  /**
213
  * Print the Section text
@@ -218,190 +216,190 @@ class PostmanSettingsRegistry {
218
  * Print the Section text
219
  */
220
  public function printAdditionalHeadersSectionInfo() {
221
- print __ ( 'Specify custom headers (e.g. <code>X-MC-Tags: wordpress-site-A</code>), one per line. Use custom headers with caution as they can negatively affect your Spam score.', Postman::TEXT_DOMAIN );
222
  }
223
-
224
  /**
225
  * Print the Email Validation Description
226
  */
227
  public function printEmailValidationSectionInfo() {
228
- print __ ( 'E-mail addresses can be validated before sending e-mail, however this may fail with some newer domains.', Postman::TEXT_DOMAIN );
229
  }
230
-
231
  /**
232
  * Get the settings option array and print one of its values
233
  */
234
  public function transport_type_callback() {
235
- $transportType = $this->options->getTransportType ();
236
- printf ( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TRANSPORT_TYPE );
237
- foreach ( PostmanTransportRegistry::getInstance ()->getTransports () as $transport ) {
238
- printf ( '<option class="input_tx_type_%1$s" value="%1$s" %3$s>%2$s</option>', $transport->getSlug (), $transport->getName (), $transportType == $transport->getSlug () ? 'selected="selected"' : '' );
239
  }
240
  print '</select>';
241
  }
242
-
243
  /**
244
  * Get the settings option array and print one of its values
245
  */
246
  public function sender_name_callback() {
247
- printf ( '<input type="text" id="input_sender_name" name="postman_options[sender_name]" value="%s" size="40" />', null !== $this->options->getMessageSenderName () ? esc_attr ( $this->options->getMessageSenderName () ) : '' );
248
  }
249
-
250
  /**
251
  */
252
  public function prevent_from_name_override_callback() {
253
- $enforced = $this->options->isPluginSenderNameEnforced ();
254
- printf ( '<input type="checkbox" id="input_prevent_sender_name_override" name="postman_options[prevent_sender_name_override]" %s /> %s', $enforced ? 'checked="checked"' : '', __ ( 'Prevent <b>plugins</b> and <b>themes</b> from changing this', Postman::TEXT_DOMAIN ) );
255
  }
256
-
257
  /**
258
  * Get the settings option array and print one of its values
259
  */
260
  public function from_email_callback() {
261
- printf ( '<input type="email" id="input_sender_email" name="postman_options[sender_email]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getMessageSenderEmail () ? esc_attr ( $this->options->getMessageSenderEmail () ) : '', __ ( 'Required', Postman::TEXT_DOMAIN ) );
262
  }
263
-
264
  /**
265
  * Print the Section text
266
  */
267
  public function printMessageSenderSectionInfo() {
268
- print sprintf ( __ ( 'This address, like the <b>return address</b> printed on an envelope, identifies the account owner to the SMTP server.', Postman::TEXT_DOMAIN ), 'https://support.google.com/mail/answer/22370?hl=en' );
269
  }
270
-
271
  /**
272
  * Get the settings option array and print one of its values
273
  */
274
  public function prevent_from_email_override_callback() {
275
- $enforced = $this->options->isPluginSenderEmailEnforced ();
276
- printf ( '<input type="checkbox" id="input_prevent_sender_email_override" name="postman_options[prevent_sender_email_override]" %s /> %s', $enforced ? 'checked="checked"' : '', __ ( 'Prevent <b>plugins</b> and <b>themes</b> from changing this', Postman::TEXT_DOMAIN ) );
277
  }
278
-
279
  /**
280
  * Shows the Mail Logging enable/disabled option
281
  */
282
  public function loggingStatusInputField() {
283
  // isMailLoggingAllowed
284
- $disabled = "";
285
- if (! $this->options->isMailLoggingAllowed ()) {
286
  $disabled = 'disabled="disabled" ';
287
  }
288
- printf ( '<select ' . $disabled . 'id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::MAIL_LOG_ENABLED_OPTION );
289
- printf ( '<option value="%s" %s>%s</option>', PostmanOptions::MAIL_LOG_ENABLED_OPTION_YES, $this->options->isMailLoggingEnabled () ? 'selected="selected"' : '', __ ( 'Yes', Postman::TEXT_DOMAIN ) );
290
- printf ( '<option value="%s" %s>%s</option>', PostmanOptions::MAIL_LOG_ENABLED_OPTION_NO, ! $this->options->isMailLoggingEnabled () ? 'selected="selected"' : '', __ ( 'No', Postman::TEXT_DOMAIN ) );
291
- printf ( '</select>' );
292
  }
293
  public function loggingMaxEntriesInputField() {
294
- printf ( '<input type="text" id="input_logging_max_entries" name="postman_options[%s]" value="%s"/>', PostmanOptions::MAIL_LOG_MAX_ENTRIES, $this->options->getMailLoggingMaxEntries () );
295
  }
296
  public function transcriptSizeInputField() {
297
  $inputOptionsSlug = PostmanOptions::POSTMAN_OPTIONS;
298
  $inputTranscriptSlug = PostmanOptions::TRANSCRIPT_SIZE;
299
- $inputValue = $this->options->getTranscriptSize ();
300
- $inputDescription = __ ( 'Change this value if you can\'t see the beginning of the transcript because your messages are too big.', Postman::TEXT_DOMAIN );
301
- printf ( '<input type="text" id="input%2$s" name="%1$s[%2$s]" value="%3$s"/><br/><span class="postman_input_description">%4$s</span>', $inputOptionsSlug, $inputTranscriptSlug, $inputValue, $inputDescription );
302
  }
303
-
304
  /**
305
  * Get the settings option array and print one of its values
306
  */
307
  public function reply_to_callback() {
308
- printf ( '<input type="text" id="input_reply_to" name="%s[%s]" value="%s" size="40" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::REPLY_TO, null !== $this->options->getReplyTo () ? esc_attr ( $this->options->getReplyTo () ) : '' );
309
  }
310
-
311
  /**
312
  * Get the settings option array and print one of its values
313
  */
314
  public function to_callback() {
315
- printf ( '<input type="text" id="input_to" name="%s[%s]" value="%s" size="60" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_TO_RECIPIENTS, null !== $this->options->getForcedToRecipients () ? esc_attr ( $this->options->getForcedToRecipients () ) : '' );
316
  }
317
-
318
  /**
319
  * Get the settings option array and print one of its values
320
  */
321
  public function cc_callback() {
322
- printf ( '<input type="text" id="input_cc" name="%s[%s]" value="%s" size="60" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_CC_RECIPIENTS, null !== $this->options->getForcedCcRecipients () ? esc_attr ( $this->options->getForcedCcRecipients () ) : '' );
323
  }
324
-
325
  /**
326
  * Get the settings option array and print one of its values
327
  */
328
  public function bcc_callback() {
329
- printf ( '<input type="text" id="input_bcc" name="%s[%s]" value="%s" size="60" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_BCC_RECIPIENTS, null !== $this->options->getForcedBccRecipients () ? esc_attr ( $this->options->getForcedBccRecipients () ) : '' );
330
  }
331
-
332
  /**
333
  * Get the settings option array and print one of its values
334
  */
335
  public function headers_callback() {
336
- printf ( '<textarea id="input_headers" name="%s[%s]" cols="60" rows="5" >%s</textarea>', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::ADDITIONAL_HEADERS, null !== $this->options->getAdditionalHeaders () ? esc_attr ( $this->options->getAdditionalHeaders () ) : '' );
337
  }
338
-
339
  /**
340
  */
341
  public function disable_email_validation_callback() {
342
- $disabled = $this->options->isEmailValidationDisabled ();
343
- printf ( '<input type="checkbox" id="%2$s" name="%1$s[%2$s]" %3$s /> %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::DISABLE_EMAIL_VALIDAITON, $disabled ? 'checked="checked"' : '', __ ( 'Disable e-mail validation', Postman::TEXT_DOMAIN ) );
344
  }
345
-
346
  /**
347
  * Get the settings option array and print one of its values
348
  */
349
  public function log_level_callback() {
350
- $inputDescription = sprintf ( __ ( 'Log Level specifies the level of detail written to the <a target="_blank" href="%s">WordPress Debug log</a> - view the log with <a target-"_new" href="%s">Debug</a>.', Postman::TEXT_DOMAIN ), 'https://codex.wordpress.org/Debugging_in_WordPress', 'https://wordpress.org/plugins/debug/' );
351
- printf ( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::LOG_LEVEL );
352
- $currentKey = $this->options->getLogLevel ();
353
- $this->printSelectOption ( __ ( 'Off', Postman::TEXT_DOMAIN ), PostmanLogger::OFF_INT, $currentKey );
354
- $this->printSelectOption ( __ ( 'Trace', Postman::TEXT_DOMAIN ), PostmanLogger::TRACE_INT, $currentKey );
355
- $this->printSelectOption ( __ ( 'Debug', Postman::TEXT_DOMAIN ), PostmanLogger::DEBUG_INT, $currentKey );
356
- $this->printSelectOption ( __ ( 'Info', Postman::TEXT_DOMAIN ), PostmanLogger::INFO_INT, $currentKey );
357
- $this->printSelectOption ( __ ( 'Warning', Postman::TEXT_DOMAIN ), PostmanLogger::WARN_INT, $currentKey );
358
- $this->printSelectOption ( __ ( 'Error', Postman::TEXT_DOMAIN ), PostmanLogger::ERROR_INT, $currentKey );
359
- printf ( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
360
- }
361
- private function printSelectOption($label, $optionKey, $currentKey) {
362
  $optionPattern = '<option value="%1$s" %2$s>%3$s</option>';
363
- printf ( $optionPattern, $optionKey, $optionKey == $currentKey ? 'selected="selected"' : '', $label );
364
  }
365
  public function runModeCallback() {
366
- $inputDescription = __ ( 'Delivery mode offers options useful for developing or testing.', Postman::TEXT_DOMAIN );
367
- printf ( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::RUN_MODE );
368
- $currentKey = $this->options->getRunMode ();
369
- $this->printSelectOption ( _x ( 'Log Email and Send', 'When the server is online to the public, this is "Production" mode', Postman::TEXT_DOMAIN ), PostmanOptions::RUN_MODE_PRODUCTION, $currentKey );
370
- $this->printSelectOption ( __ ( 'Log Email and Delete', Postman::TEXT_DOMAIN ), PostmanOptions::RUN_MODE_LOG_ONLY, $currentKey );
371
- $this->printSelectOption ( __ ( 'Delete All Emails', Postman::TEXT_DOMAIN ), PostmanOptions::RUN_MODE_IGNORE, $currentKey );
372
- printf ( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
373
  }
374
  public function stealthModeCallback() {
375
- printf ( '<input type="checkbox" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" %3$s /> %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::STEALTH_MODE, $this->options->isStealthModeEnabled () ? 'checked="checked"' : '', __ ( 'Remove the Postman X-Header signature from messages', Postman::TEXT_DOMAIN ) );
376
  }
377
  public function temporaryDirectoryCallback() {
378
- $inputDescription = __ ( 'Lockfiles are written here to prevent users from triggering an OAuth 2.0 token refresh at the same time.' );
379
- printf ( '<input type="text" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TEMPORARY_DIRECTORY, $this->options->getTempDirectory () );
380
- if (PostmanState::getInstance ()->isFileLockingEnabled ()) {
381
- printf ( ' <span style="color:green">%s</span></br><span class="postman_input_description">%s</span>', __ ( 'Valid', Postman::TEXT_DOMAIN ), $inputDescription );
382
  } else {
383
- printf ( ' <span style="color:red">%s</span></br><span class="postman_input_description">%s</span>', __ ( 'Invalid', Postman::TEXT_DOMAIN ), $inputDescription );
384
  }
385
  }
386
-
387
  /**
388
  * Get the settings option array and print one of its values
389
  */
390
  public function connection_timeout_callback() {
391
- printf ( '<input type="text" id="input_connection_timeout" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::CONNECTION_TIMEOUT, $this->options->getConnectionTimeout () );
392
  }
393
-
394
  /**
395
  * Get the settings option array and print one of its values
396
  */
397
  public function read_timeout_callback() {
398
- printf ( '<input type="text" id="input_read_timeout" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::READ_TIMEOUT, $this->options->getReadTimeout () );
399
  }
400
-
401
  /**
402
  * Get the settings option array and print one of its values
403
  */
404
- public function port_callback($args) {
405
- printf ( '<input type="text" id="input_port" name="postman_options[port]" value="%s" %s placeholder="%s"/>', null !== $this->options->getPort () ? esc_attr ( $this->options->getPort () ) : '', isset ( $args ['style'] ) ? $args ['style'] : '', __ ( 'Required', Postman::TEXT_DOMAIN ) );
406
  }
407
- }
2
  class PostmanSettingsRegistry {
3
 
4
  private $options;
5
+
6
  public function __construct() {
7
  $this->options = PostmanOptions::getInstance();
8
  }
9
+
10
  /**
11
  * Fires on the admin_init method
12
  */
13
  public function on_admin_init() {
14
+ $this->registerSettings();
 
15
  }
16
+
17
  /**
18
  * Register and add settings
19
  */
20
  private function registerSettings() {
21
+
22
  // only administrators should be able to trigger this
23
+ if ( PostmanUtils::isAdmin() ) {
24
+ $sanitizer = new PostmanInputSanitizer();
25
+ register_setting( PostmanAdminController::SETTINGS_GROUP_NAME, PostmanOptions::POSTMAN_OPTIONS, array(
 
26
  $sanitizer,
27
+ 'sanitize',
28
  ) );
29
+
30
  // Sanitize
31
+ add_settings_section( 'transport_section', __( 'Transport', Postman::TEXT_DOMAIN ), array(
32
  $this,
33
+ 'printTransportSectionInfo',
34
  ), 'transport_options' );
35
+
36
+ add_settings_field( PostmanOptions::TRANSPORT_TYPE, _x( 'Type', '(i.e.) What kind is it?', Postman::TEXT_DOMAIN ), array(
37
  $this,
38
+ 'transport_type_callback',
39
  ), 'transport_options', 'transport_section' );
40
+
41
  // the Message From section
42
+ add_settings_section( PostmanAdminController::MESSAGE_FROM_SECTION, _x( 'From Address', 'The Message Sender Email Address', Postman::TEXT_DOMAIN ), array(
43
  $this,
44
+ 'printMessageFromSectionInfo',
45
  ), PostmanAdminController::MESSAGE_FROM_OPTIONS );
46
+
47
+ add_settings_field( PostmanOptions::MESSAGE_SENDER_EMAIL, __( 'Email Address', Postman::TEXT_DOMAIN ), array(
48
  $this,
49
+ 'from_email_callback',
50
  ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
51
+
52
+ add_settings_field( PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE, '', array(
53
  $this,
54
+ 'prevent_from_email_override_callback',
55
  ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
56
+
57
+ add_settings_field( PostmanOptions::MESSAGE_SENDER_NAME, __( 'Name', Postman::TEXT_DOMAIN ), array(
58
  $this,
59
+ 'sender_name_callback',
60
  ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
61
+
62
+ add_settings_field( PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE, '', array(
63
  $this,
64
+ 'prevent_from_name_override_callback',
65
  ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
66
+
67
  // the Additional Addresses section
68
+ add_settings_section( PostmanAdminController::MESSAGE_SECTION, __( 'Additional Email Addresses', Postman::TEXT_DOMAIN ), array(
69
  $this,
70
+ 'printMessageSectionInfo',
71
  ), PostmanAdminController::MESSAGE_OPTIONS );
72
+
73
+ add_settings_field( PostmanOptions::REPLY_TO, __( 'Reply-To', Postman::TEXT_DOMAIN ), array(
74
  $this,
75
+ 'reply_to_callback',
76
  ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
77
+
78
+ add_settings_field( PostmanOptions::FORCED_TO_RECIPIENTS, __( 'To Recipient(s)', Postman::TEXT_DOMAIN ), array(
79
  $this,
80
+ 'to_callback',
81
  ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
82
+
83
+ add_settings_field( PostmanOptions::FORCED_CC_RECIPIENTS, __( 'Carbon Copy Recipient(s)', Postman::TEXT_DOMAIN ), array(
84
  $this,
85
+ 'cc_callback',
86
  ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
87
+
88
+ add_settings_field( PostmanOptions::FORCED_BCC_RECIPIENTS, __( 'Blind Carbon Copy Recipient(s)', Postman::TEXT_DOMAIN ), array(
89
  $this,
90
+ 'bcc_callback',
91
  ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
92
+
93
  // the Additional Headers section
94
+ add_settings_section( PostmanAdminController::MESSAGE_HEADERS_SECTION, __( 'Additional Headers', Postman::TEXT_DOMAIN ), array(
95
  $this,
96
+ 'printAdditionalHeadersSectionInfo',
97
  ), PostmanAdminController::MESSAGE_HEADERS_OPTIONS );
98
+
99
+ add_settings_field( PostmanOptions::ADDITIONAL_HEADERS, __( 'Custom Headers', Postman::TEXT_DOMAIN ), array(
100
  $this,
101
+ 'headers_callback',
102
  ), PostmanAdminController::MESSAGE_HEADERS_OPTIONS, PostmanAdminController::MESSAGE_HEADERS_SECTION );
103
+
104
  // the Email Validation section
105
+ add_settings_section( PostmanAdminController::EMAIL_VALIDATION_SECTION, __( 'Validation', Postman::TEXT_DOMAIN ), array(
106
  $this,
107
+ 'printEmailValidationSectionInfo',
108
  ), PostmanAdminController::EMAIL_VALIDATION_OPTIONS );
109
+
110
+ add_settings_field( PostmanOptions::ENVELOPE_SENDER, __( 'Email Address', Postman::TEXT_DOMAIN ), array(
111
  $this,
112
+ 'disable_email_validation_callback',
113
  ), PostmanAdminController::EMAIL_VALIDATION_OPTIONS, PostmanAdminController::EMAIL_VALIDATION_SECTION );
114
+
115
  // the Logging section
116
+ add_settings_section( PostmanAdminController::LOGGING_SECTION, __( 'Email Log Settings', Postman::TEXT_DOMAIN ), array(
117
  $this,
118
+ 'printLoggingSectionInfo',
119
  ), PostmanAdminController::LOGGING_OPTIONS );
120
+
121
+ add_settings_field( 'logging_status', __( 'Enable Logging', Postman::TEXT_DOMAIN ), array(
122
  $this,
123
+ 'loggingStatusInputField',
124
  ), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION );
125
+
126
+ add_settings_field( 'logging_max_entries', __( 'Maximum Log Entries', Postman::TEXT_DOMAIN ), array(
127
  $this,
128
+ 'loggingMaxEntriesInputField',
129
  ), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION );
130
+
131
+ add_settings_field( PostmanOptions::TRANSCRIPT_SIZE, __( 'Maximum Transcript Size', Postman::TEXT_DOMAIN ), array(
132
  $this,
133
+ 'transcriptSizeInputField',
134
  ), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION );
135
+
136
  // the Network section
137
+ add_settings_section( PostmanAdminController::NETWORK_SECTION, __( 'Network Settings', Postman::TEXT_DOMAIN ), array(
138
  $this,
139
+ 'printNetworkSectionInfo',
140
  ), PostmanAdminController::NETWORK_OPTIONS );
141
+
142
+ add_settings_field( 'connection_timeout', _x( 'TCP Connection Timeout (sec)', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array(
143
  $this,
144
+ 'connection_timeout_callback',
145
  ), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION );
146
+
147
+ add_settings_field( 'read_timeout', _x( 'TCP Read Timeout (sec)', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array(
148
  $this,
149
+ 'read_timeout_callback',
150
  ), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION );
151
+
152
  // the Advanced section
153
+ add_settings_section( PostmanAdminController::ADVANCED_SECTION, _x( 'Miscellaneous Settings', 'Configuration Section Title', Postman::TEXT_DOMAIN ), array(
154
  $this,
155
+ 'printAdvancedSectionInfo',
156
  ), PostmanAdminController::ADVANCED_OPTIONS );
157
+
158
+ add_settings_field( PostmanOptions::LOG_LEVEL, _x( 'PHP Log Level', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array(
159
  $this,
160
+ 'log_level_callback',
161
  ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
162
+
163
+ add_settings_field( PostmanOptions::RUN_MODE, _x( 'Delivery Mode', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array(
164
  $this,
165
+ 'runModeCallback',
166
  ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
167
+
168
+ add_settings_field( PostmanOptions::STEALTH_MODE, _x( 'Stealth Mode', 'This mode removes the Postman X-Mailer signature from emails', Postman::TEXT_DOMAIN ), array(
169
  $this,
170
+ 'stealthModeCallback',
171
  ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
172
+
173
+ add_settings_field( PostmanOptions::TEMPORARY_DIRECTORY, __( 'Temporary Directory', Postman::TEXT_DOMAIN ), array(
174
  $this,
175
+ 'temporaryDirectoryCallback',
176
  ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
177
  }
178
  }
179
+
180
  /**
181
  * Print the Transport section info
182
  */
183
  public function printTransportSectionInfo() {
184
+ print __( 'Choose SMTP or a vendor-specific API:', Postman::TEXT_DOMAIN );
185
  }
186
  public function printLoggingSectionInfo() {
187
+ print __( 'Configure the delivery audit log:', Postman::TEXT_DOMAIN );
188
  }
189
+
190
  /**
191
  * Print the Section text
192
  */
193
  public function printMessageFromSectionInfo() {
194
+ print sprintf( __( 'This address, like the <b>letterhead</b> printed on a letter, identifies the sender to the recipient. Change this when you are sending on behalf of someone else, for example to use Google\'s <a href="%s">Send Mail As</a> feature. Other plugins, especially Contact Forms, may override this field to be your visitor\'s address.', Postman::TEXT_DOMAIN ), 'https://support.google.com/mail/answer/22370?hl=en' );
195
  }
196
+
197
  /**
198
  * Print the Section text
199
  */
200
  public function printMessageSectionInfo() {
201
+ print __( 'Separate multiple <b>to</b>/<b>cc</b>/<b>bcc</b> recipients with commas.', Postman::TEXT_DOMAIN );
202
  }
203
+
204
  /**
205
  * Print the Section text
206
  */
207
  public function printNetworkSectionInfo() {
208
+ print __( 'Increase the timeouts if your host is intermittenly failing to send mail. Be careful, this also correlates to how long your user must wait if the mail server is unreachable.', Postman::TEXT_DOMAIN );
209
  }
210
  /**
211
  * Print the Section text
216
  * Print the Section text
217
  */
218
  public function printAdditionalHeadersSectionInfo() {
219
+ print __( 'Specify custom headers (e.g. <code>X-MC-Tags: wordpress-site-A</code>), one per line. Use custom headers with caution as they can negatively affect your Spam score.', Postman::TEXT_DOMAIN );
220
  }
221
+
222
  /**
223
  * Print the Email Validation Description
224
  */
225
  public function printEmailValidationSectionInfo() {
226
+ print __( 'E-mail addresses can be validated before sending e-mail, however this may fail with some newer domains.', Postman::TEXT_DOMAIN );
227
  }
228
+
229
  /**
230
  * Get the settings option array and print one of its values
231
  */
232
  public function transport_type_callback() {
233
+ $transportType = $this->options->getTransportType();
234
+ printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TRANSPORT_TYPE );
235
+ foreach ( PostmanTransportRegistry::getInstance()->getTransports() as $transport ) {
236
+ printf( '<option class="input_tx_type_%1$s" value="%1$s" %3$s>%2$s</option>', $transport->getSlug(), $transport->getName(), $transportType == $transport->getSlug() ? 'selected="selected"' : '' );
237
  }
238
  print '</select>';
239
  }
240
+
241
  /**
242
  * Get the settings option array and print one of its values
243
  */
244
  public function sender_name_callback() {
245
+ printf( '<input type="text" id="input_sender_name" name="postman_options[sender_name]" value="%s" size="40" />', null !== $this->options->getMessageSenderName() ? esc_attr( $this->options->getMessageSenderName() ) : '' );
246
  }
247
+
248
  /**
249
  */
250
  public function prevent_from_name_override_callback() {
251
+ $enforced = $this->options->isPluginSenderNameEnforced();
252
+ printf( '<input type="checkbox" id="input_prevent_sender_name_override" name="postman_options[prevent_sender_name_override]" %s /> %s', $enforced ? 'checked="checked"' : '', __( 'Prevent <b>plugins</b> and <b>themes</b> from changing this', Postman::TEXT_DOMAIN ) );
253
  }
254
+
255
  /**
256
  * Get the settings option array and print one of its values
257
  */
258
  public function from_email_callback() {
259
+ printf( '<input type="email" id="input_sender_email" name="postman_options[sender_email]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getMessageSenderEmail() ? esc_attr( $this->options->getMessageSenderEmail() ) : '', __( 'Required', Postman::TEXT_DOMAIN ) );
260
  }
261
+
262
  /**
263
  * Print the Section text
264
  */
265
  public function printMessageSenderSectionInfo() {
266
+ print sprintf( __( 'This address, like the <b>return address</b> printed on an envelope, identifies the account owner to the SMTP server.', Postman::TEXT_DOMAIN ), 'https://support.google.com/mail/answer/22370?hl=en' );
267
  }
268
+
269
  /**
270
  * Get the settings option array and print one of its values
271
  */
272
  public function prevent_from_email_override_callback() {
273
+ $enforced = $this->options->isPluginSenderEmailEnforced();
274
+ printf( '<input type="checkbox" id="input_prevent_sender_email_override" name="postman_options[prevent_sender_email_override]" %s /> %s', $enforced ? 'checked="checked"' : '', __( 'Prevent <b>plugins</b> and <b>themes</b> from changing this', Postman::TEXT_DOMAIN ) );
275
  }
276
+
277
  /**
278
  * Shows the Mail Logging enable/disabled option
279
  */
280
  public function loggingStatusInputField() {
281
  // isMailLoggingAllowed
282
+ $disabled = '';
283
+ if ( ! $this->options->isMailLoggingAllowed() ) {
284
  $disabled = 'disabled="disabled" ';
285
  }
286
+ printf( '<select ' . $disabled . 'id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::MAIL_LOG_ENABLED_OPTION );
287
+ printf( '<option value="%s" %s>%s</option>', PostmanOptions::MAIL_LOG_ENABLED_OPTION_YES, $this->options->isMailLoggingEnabled() ? 'selected="selected"' : '', __( 'Yes', Postman::TEXT_DOMAIN ) );
288
+ printf( '<option value="%s" %s>%s</option>', PostmanOptions::MAIL_LOG_ENABLED_OPTION_NO, ! $this->options->isMailLoggingEnabled() ? 'selected="selected"' : '', __( 'No', Postman::TEXT_DOMAIN ) );
289
+ printf( '</select>' );
290
  }
291
  public function loggingMaxEntriesInputField() {
292
+ printf( '<input type="text" id="input_logging_max_entries" name="postman_options[%s]" value="%s"/>', PostmanOptions::MAIL_LOG_MAX_ENTRIES, $this->options->getMailLoggingMaxEntries() );
293
  }
294
  public function transcriptSizeInputField() {
295
  $inputOptionsSlug = PostmanOptions::POSTMAN_OPTIONS;
296
  $inputTranscriptSlug = PostmanOptions::TRANSCRIPT_SIZE;
297
+ $inputValue = $this->options->getTranscriptSize();
298
+ $inputDescription = __( 'Change this value if you can\'t see the beginning of the transcript because your messages are too big.', Postman::TEXT_DOMAIN );
299
+ printf( '<input type="text" id="input%2$s" name="%1$s[%2$s]" value="%3$s"/><br/><span class="postman_input_description">%4$s</span>', $inputOptionsSlug, $inputTranscriptSlug, $inputValue, $inputDescription );
300
  }
301
+
302
  /**
303
  * Get the settings option array and print one of its values
304
  */
305
  public function reply_to_callback() {
306
+ printf( '<input type="text" id="input_reply_to" name="%s[%s]" value="%s" size="40" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::REPLY_TO, null !== $this->options->getReplyTo() ? esc_attr( $this->options->getReplyTo() ) : '' );
307
  }
308
+
309
  /**
310
  * Get the settings option array and print one of its values
311
  */
312
  public function to_callback() {
313
+ printf( '<input type="text" id="input_to" name="%s[%s]" value="%s" size="60" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_TO_RECIPIENTS, null !== $this->options->getForcedToRecipients() ? esc_attr( $this->options->getForcedToRecipients() ) : '' );
314
  }
315
+
316
  /**
317
  * Get the settings option array and print one of its values
318
  */
319
  public function cc_callback() {
320
+ printf( '<input type="text" id="input_cc" name="%s[%s]" value="%s" size="60" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_CC_RECIPIENTS, null !== $this->options->getForcedCcRecipients() ? esc_attr( $this->options->getForcedCcRecipients() ) : '' );
321
  }
322
+
323
  /**
324
  * Get the settings option array and print one of its values
325
  */
326
  public function bcc_callback() {
327
+ printf( '<input type="text" id="input_bcc" name="%s[%s]" value="%s" size="60" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_BCC_RECIPIENTS, null !== $this->options->getForcedBccRecipients() ? esc_attr( $this->options->getForcedBccRecipients() ) : '' );
328
  }
329
+
330
  /**
331
  * Get the settings option array and print one of its values
332
  */
333
  public function headers_callback() {
334
+ printf( '<textarea id="input_headers" name="%s[%s]" cols="60" rows="5" >%s</textarea>', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::ADDITIONAL_HEADERS, null !== $this->options->getAdditionalHeaders() ? esc_attr( $this->options->getAdditionalHeaders() ) : '' );
335
  }
336
+
337
  /**
338
  */
339
  public function disable_email_validation_callback() {
340
+ $disabled = $this->options->isEmailValidationDisabled();
341
+ printf( '<input type="checkbox" id="%2$s" name="%1$s[%2$s]" %3$s /> %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::DISABLE_EMAIL_VALIDAITON, $disabled ? 'checked="checked"' : '', __( 'Disable e-mail validation', Postman::TEXT_DOMAIN ) );
342
  }
343
+
344
  /**
345
  * Get the settings option array and print one of its values
346
  */
347
  public function log_level_callback() {
348
+ $inputDescription = sprintf( __( 'Log Level specifies the level of detail written to the <a target="_blank" href="%s">WordPress Debug log</a> - view the log with <a target-"_new" href="%s">Debug</a>.', Postman::TEXT_DOMAIN ), 'https://codex.wordpress.org/Debugging_in_WordPress', 'https://wordpress.org/plugins/debug/' );
349
+ printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::LOG_LEVEL );
350
+ $currentKey = $this->options->getLogLevel();
351
+ $this->printSelectOption( __( 'Off', Postman::TEXT_DOMAIN ), PostmanLogger::OFF_INT, $currentKey );
352
+ $this->printSelectOption( __( 'Trace', Postman::TEXT_DOMAIN ), PostmanLogger::TRACE_INT, $currentKey );
353
+ $this->printSelectOption( __( 'Debug', Postman::TEXT_DOMAIN ), PostmanLogger::DEBUG_INT, $currentKey );
354
+ $this->printSelectOption( __( 'Info', Postman::TEXT_DOMAIN ), PostmanLogger::INFO_INT, $currentKey );
355
+ $this->printSelectOption( __( 'Warning', Postman::TEXT_DOMAIN ), PostmanLogger::WARN_INT, $currentKey );
356
+ $this->printSelectOption( __( 'Error', Postman::TEXT_DOMAIN ), PostmanLogger::ERROR_INT, $currentKey );
357
+ printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
358
+ }
359
+ private function printSelectOption( $label, $optionKey, $currentKey ) {
360
  $optionPattern = '<option value="%1$s" %2$s>%3$s</option>';
361
+ printf( $optionPattern, $optionKey, $optionKey == $currentKey ? 'selected="selected"' : '', $label );
362
  }
363
  public function runModeCallback() {
364
+ $inputDescription = __( 'Delivery mode offers options useful for developing or testing.', Postman::TEXT_DOMAIN );
365
+ printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::RUN_MODE );
366
+ $currentKey = $this->options->getRunMode();
367
+ $this->printSelectOption( _x( 'Log Email and Send', 'When the server is online to the public, this is "Production" mode', Postman::TEXT_DOMAIN ), PostmanOptions::RUN_MODE_PRODUCTION, $currentKey );
368
+ $this->printSelectOption( __( 'Log Email and Delete', Postman::TEXT_DOMAIN ), PostmanOptions::RUN_MODE_LOG_ONLY, $currentKey );
369
+ $this->printSelectOption( __( 'Delete All Emails', Postman::TEXT_DOMAIN ), PostmanOptions::RUN_MODE_IGNORE, $currentKey );
370
+ printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
371
  }
372
  public function stealthModeCallback() {
373
+ printf( '<input type="checkbox" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" %3$s /> %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::STEALTH_MODE, $this->options->isStealthModeEnabled() ? 'checked="checked"' : '', __( 'Remove the Postman X-Header signature from messages', Postman::TEXT_DOMAIN ) );
374
  }
375
  public function temporaryDirectoryCallback() {
376
+ $inputDescription = __( 'Lockfiles are written here to prevent users from triggering an OAuth 2.0 token refresh at the same time.' );
377
+ printf( '<input type="text" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TEMPORARY_DIRECTORY, $this->options->getTempDirectory() );
378
+ if ( PostmanState::getInstance()->isFileLockingEnabled() ) {
379
+ printf( ' <span style="color:green">%s</span></br><span class="postman_input_description">%s</span>', __( 'Valid', Postman::TEXT_DOMAIN ), $inputDescription );
380
  } else {
381
+ printf( ' <span style="color:red">%s</span></br><span class="postman_input_description">%s</span>', __( 'Invalid', Postman::TEXT_DOMAIN ), $inputDescription );
382
  }
383
  }
384
+
385
  /**
386
  * Get the settings option array and print one of its values
387
  */
388
  public function connection_timeout_callback() {
389
+ printf( '<input type="text" id="input_connection_timeout" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::CONNECTION_TIMEOUT, $this->options->getConnectionTimeout() );
390
  }
391
+
392
  /**
393
  * Get the settings option array and print one of its values
394
  */
395
  public function read_timeout_callback() {
396
+ printf( '<input type="text" id="input_read_timeout" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::READ_TIMEOUT, $this->options->getReadTimeout() );
397
  }
398
+
399
  /**
400
  * Get the settings option array and print one of its values
401
  */
402
+ public function port_callback( $args ) {
403
+ printf( '<input type="text" id="input_port" name="postman_options[port]" value="%s" %s placeholder="%s"/>', null !== $this->options->getPort() ? esc_attr( $this->options->getPort() ) : '', isset( $args ['style'] ) ? $args ['style'] : '', __( 'Required', Postman::TEXT_DOMAIN ) );
404
  }
405
+ }
Postman/Postman-Email-Log/PostmanEmailLogController.php CHANGED
@@ -70,13 +70,22 @@ class PostmanEmailLogController {
70
  /**
71
  */
72
  public function resendMail() {
 
 
73
  // get the email address of the recipient from the HTTP Request
74
  $postid = $this->getRequestParameter( 'email' );
75
  if ( ! empty( $postid ) ) {
76
  $post = get_post( $postid );
77
  $meta_values = get_post_meta( $postid );
78
 
79
- $success = wp_mail( $meta_values ['original_to'] [0], $meta_values ['original_subject'] [0], $meta_values ['original_message'] [0], $meta_values ['original_headers'] [0] );
 
 
 
 
 
 
 
80
 
81
  // Postman API: retrieve the result of sending this message from Postman
82
  $result = apply_filters( 'postman_wp_mail_result', null );
@@ -288,7 +297,7 @@ class PostmanEmailLogController {
288
  $this->logger->trace( 'created PostmanEmailLog admin menu item' );
289
  /*
290
  Translators where (%s) is the name of the plugin */
291
- $pageTitle = sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) );
292
  $pluginName = _x( 'Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN );
293
 
294
  $page = add_submenu_page( PostmanViewController::POSTMAN_MENU_SLUG, $pageTitle, $pluginName, 'read_private_posts', 'postman_email_log', array( $this, 'postman_render_email_page' ) );
@@ -338,7 +347,7 @@ class PostmanEmailLogController {
338
  </div>
339
  <h2><?php
340
  /* Translators where (%s) is the name of the plugin */
341
- echo sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) )?></h2>
342
 
343
  <div
344
  style="background: #ECECEC; border: 1px solid #CCC; padding: 0 10px; margin-top: 5px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;">
@@ -374,7 +383,8 @@ class PostmanEmailLogController {
374
  <div class="form-control">
375
  <!-- <button type="submit" name="export_email_logs" class="button button-primary">Export To CSV</button> -->
376
  </div>
377
- </div>
 
378
  </form>
379
 
380
  <!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
70
  /**
71
  */
72
  public function resendMail() {
73
+ check_ajax_referer( 'resend', 'security' );
74
+
75
  // get the email address of the recipient from the HTTP Request
76
  $postid = $this->getRequestParameter( 'email' );
77
  if ( ! empty( $postid ) ) {
78
  $post = get_post( $postid );
79
  $meta_values = get_post_meta( $postid );
80
 
81
+ if ( isset( $_POST['mail_to'] ) && ! empty( $_POST['mail_to'] ) ) {
82
+ $emails = explode( ',', $_POST['mail_to'] );
83
+ $to = array_map( 'sanitize_email', $emails );
84
+ } else {
85
+ $to = $meta_values ['original_to'] [0];
86
+ }
87
+
88
+ $success = wp_mail( $to, $meta_values ['original_subject'] [0], $meta_values ['original_message'] [0], $meta_values ['original_headers'] [0] );
89
 
90
  // Postman API: retrieve the result of sending this message from Postman
91
  $result = apply_filters( 'postman_wp_mail_result', null );
297
  $this->logger->trace( 'created PostmanEmailLog admin menu item' );
298
  /*
299
  Translators where (%s) is the name of the plugin */
300
+ $pageTitle = sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) );
301
  $pluginName = _x( 'Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN );
302
 
303
  $page = add_submenu_page( PostmanViewController::POSTMAN_MENU_SLUG, $pageTitle, $pluginName, 'read_private_posts', 'postman_email_log', array( $this, 'postman_render_email_page' ) );
347
  </div>
348
  <h2><?php
349
  /* Translators where (%s) is the name of the plugin */
350
+ echo sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) )?></h2>
351
 
352
  <div
353
  style="background: #ECECEC; border: 1px solid #CCC; padding: 0 10px; margin-top: 5px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;">
383
  <div class="form-control">
384
  <!-- <button type="submit" name="export_email_logs" class="button button-primary">Export To CSV</button> -->
385
  </div>
386
+ </div>
387
+ <div class="error">Please notice: when you select a date for example 11/20/2017, behind the scene the query select <b>11/20/2017 00:00:00</b>.<br>So if you searching for an email arrived that day at any hour you need to select 11/20/2017 as the <b>From Date</b> and 11/21/2017 as the <b>To Date</b>.</div>
388
  </form>
389
 
390
  <!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
Postman/Postman-Email-Log/PostmanEmailLogView.php CHANGED
@@ -105,7 +105,9 @@ class PostmanEmailLogView extends WP_List_Table {
105
  }
106
  if ( ! (empty( $meta_values ['original_to'] [0] ) && empty( $meta_values ['originalHeaders'] [0] )) ) {
107
  // $actions ['resend'] = sprintf ( '<a href="%s">%s</a>', $resendUrl, __ ( 'Resend', Postman::TEXT_DOMAIN ) );
108
- $actions ['resend'] = sprintf( '<span id="%3$s"><a href="javascript:postman_resend_email(%1$s);">%2$s</a></span>', $item ['ID'], __( 'Resend', Postman::TEXT_DOMAIN ), 'resend-' . $item ['ID'] );
 
 
109
  } else {
110
  $actions ['resend'] = sprintf( '%2$s', $resendUrl, __( 'Resend', Postman::TEXT_DOMAIN ) );
111
  }
@@ -317,6 +319,7 @@ class PostmanEmailLogView extends WP_List_Table {
317
  $from_date = sanitize_text_field( $_POST['from_date'] );
318
 
319
  $args['date_query']['after'] = $from_date;
 
320
  $args['date_query']['inclusive'] = false;
321
  }
322
 
@@ -324,6 +327,7 @@ class PostmanEmailLogView extends WP_List_Table {
324
  $to_date = sanitize_text_field( $_POST['to_date'] );
325
 
326
  $args['date_query']['before'] = $to_date;
 
327
  $args['date_query']['inclusive'] = true;
328
  }
329
 
@@ -336,6 +340,8 @@ class PostmanEmailLogView extends WP_List_Table {
336
  }
337
 
338
  $posts = new WP_query( $args );
 
 
339
 
340
  foreach ( $posts->posts as $post ) {
341
  $date = $post->post_date;
@@ -351,7 +357,7 @@ class PostmanEmailLogView extends WP_List_Table {
351
  'title' => esc_html( $post->post_title ),
352
  // the post status must be escaped as they are displayed in the HTML output
353
  'status' => ($post->post_excerpt != null ? esc_html( $post->post_excerpt ) : __( 'Sent', Postman::TEXT_DOMAIN )),
354
- 'date' => $date,
355
  'ID' => $post->ID,
356
  );
357
  array_push( $data, $flattenedPost );
105
  }
106
  if ( ! (empty( $meta_values ['original_to'] [0] ) && empty( $meta_values ['originalHeaders'] [0] )) ) {
107
  // $actions ['resend'] = sprintf ( '<a href="%s">%s</a>', $resendUrl, __ ( 'Resend', Postman::TEXT_DOMAIN ) );
108
+ $emails = maybe_unserialize( $meta_values ['original_to'] [0] );
109
+ $to = is_array( $emails ) ? implode( ',', $emails ) : $emails;
110
+ $actions ['resend'] = sprintf( '<span id="%3$s"><a class="postman-open-resend" href="#">%2$s</a></span><div style="display:none;"><input type="hidden" name="security" value="%6$s"><input type="text" name="mail_to" class="regular-text ltr" data-id="%1$s" value="%4$s"><button class="postman-resend button button-primary">%2$s</button><i style="color: black;">%5$s</i></div>', $item ['ID'], __( 'Resend', Postman::TEXT_DOMAIN ), 'resend-' . $item ['ID'], esc_attr( $to ), __( 'comma-separated for multiple emails', Postman::TEXT_DOMAIN ), wp_create_nonce( 'resend' ) );
111
  } else {
112
  $actions ['resend'] = sprintf( '%2$s', $resendUrl, __( 'Resend', Postman::TEXT_DOMAIN ) );
113
  }
319
  $from_date = sanitize_text_field( $_POST['from_date'] );
320
 
321
  $args['date_query']['after'] = $from_date;
322
+ $args['date_query']['column'] = 'post_date';
323
  $args['date_query']['inclusive'] = false;
324
  }
325
 
327
  $to_date = sanitize_text_field( $_POST['to_date'] );
328
 
329
  $args['date_query']['before'] = $to_date;
330
+ $args['date_query']['column'] = 'post_date';
331
  $args['date_query']['inclusive'] = true;
332
  }
333
 
340
  }
341
 
342
  $posts = new WP_query( $args );
343
+ $date_format = get_option( 'date_format' );
344
+ $time_format = get_option( 'time_format' );
345
 
346
  foreach ( $posts->posts as $post ) {
347
  $date = $post->post_date;
357
  'title' => esc_html( $post->post_title ),
358
  // the post status must be escaped as they are displayed in the HTML output
359
  'status' => ($post->post_excerpt != null ? esc_html( $post->post_excerpt ) : __( 'Sent', Postman::TEXT_DOMAIN )),
360
+ 'date' => date( "$date_format $time_format", strtotime( $post->post_date ) ),
361
  'ID' => $post->ID,
362
  );
363
  array_push( $data, $flattenedPost );
Postman/PostmanInputSanitizer.php CHANGED
@@ -1,154 +1,154 @@
1
  <?php
2
- if (! class_exists ( 'PostmanInputSanitizer' )) {
3
  class PostmanInputSanitizer {
4
  private $logger;
5
  private $options;
6
  const VALIDATION_SUCCESS = 'validation_success';
7
  const VALIDATION_FAILED = 'validation_failed';
8
  public function __construct() {
9
- $this->logger = new PostmanLogger ( get_class ( $this ) );
10
  $this->options = PostmanOptions::getInstance();
11
  }
12
-
13
  /**
14
  * Sanitize each setting field as needed
15
  *
16
  * @param array $input
17
  * Contains all settings fields as array keys
18
  */
19
- public function sanitize($input) {
20
- $this->logger->debug ( "Sanitizing data before storage" );
21
-
22
- $new_input = array ();
23
  $success = true;
24
-
25
- $this->sanitizeString ( 'Encryption Type', PostmanOptions::SECURITY_TYPE, $input, $new_input );
26
- $this->sanitizeString ( 'Hostname', PostmanOptions::HOSTNAME, $input, $new_input );
27
- if (! empty ( $input [PostmanOptions::PORT] )) {
28
- $port = absint ( $input [PostmanOptions::PORT] );
29
- if ($port > 0) {
30
- $this->sanitizeInt ( 'Port', PostmanOptions::PORT, $input, $new_input );
31
  } else {
32
- $new_input [PostmanOptions::PORT] = $this->options->getPort ();
33
- add_settings_error ( PostmanOptions::PORT, PostmanOptions::PORT, 'Invalid TCP Port', 'error' );
34
  $success = false;
35
  }
36
  }
37
  // check the auth type AFTER the hostname because we reset the hostname if auth is bad
38
- $this->sanitizeString ( 'From Email', PostmanOptions::MESSAGE_SENDER_EMAIL, $input, $new_input );
39
  // the wizard doesn't set an envelope sender, so we'll default it to From Email
40
- $new_input [PostmanOptions::ENVELOPE_SENDER] = $new_input [PostmanOptions::MESSAGE_SENDER_EMAIL];
41
- $this->sanitizeString ( 'Sender Email', PostmanOptions::ENVELOPE_SENDER, $input, $new_input );
42
- $this->sanitizeString ( 'Transport Type', PostmanOptions::TRANSPORT_TYPE, $input, $new_input );
43
- $this->sanitizeString ( 'Authorization Type', PostmanOptions::AUTHENTICATION_TYPE, $input, $new_input );
44
- $this->sanitizeString ( 'From Name', PostmanOptions::MESSAGE_SENDER_NAME, $input, $new_input );
45
- $this->sanitizeString ( 'Client ID', PostmanOptions::CLIENT_ID, $input, $new_input );
46
- $this->sanitizeString ( 'Client Secret', PostmanOptions::CLIENT_SECRET, $input, $new_input );
47
- $this->sanitizeString ( 'Username', PostmanOptions::BASIC_AUTH_USERNAME, $input, $new_input );
48
- $this->sanitizePassword ( 'Password', PostmanOptions::BASIC_AUTH_PASSWORD, $input, $new_input, $this->options->getPassword () );
49
- $this->sanitizePassword ( 'Mandrill API Key', PostmanOptions::MANDRILL_API_KEY, $input, $new_input, $this->options->getMandrillApiKey () );
50
- $this->sanitizePassword ( 'SendGrid API Key', PostmanOptions::SENDGRID_API_KEY, $input, $new_input, $this->options->getSendGridApiKey () );
51
- $this->sanitizeString ( 'Reply-To', PostmanOptions::REPLY_TO, $input, $new_input );
52
- $this->sanitizeString ( 'From Name Override', PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE, $input, $new_input );
53
- $this->sanitizeString ( 'From Email Override', PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE, $input, $new_input );
54
- $this->sanitizeString ( 'Disable Email Validation', PostmanOptions::DISABLE_EMAIL_VALIDAITON, $input, $new_input );
55
- $this->sanitizeString ( 'Forced To Recipients', PostmanOptions::FORCED_TO_RECIPIENTS, $input, $new_input );
56
- $this->sanitizeString ( 'Forced CC Recipients', PostmanOptions::FORCED_CC_RECIPIENTS, $input, $new_input );
57
- $this->sanitizeString ( 'Forced BCC Recipients', PostmanOptions::FORCED_BCC_RECIPIENTS, $input, $new_input );
58
- $this->sanitizeString ( 'Additional Headers', PostmanOptions::ADDITIONAL_HEADERS, $input, $new_input );
59
- $this->sanitizeInt ( 'Read Timeout', PostmanOptions::READ_TIMEOUT, $input, $new_input );
60
- $this->sanitizeInt ( 'Conenction Timeout', PostmanOptions::CONNECTION_TIMEOUT, $input, $new_input );
61
- $this->sanitizeInt ( 'Log Level', PostmanOptions::LOG_LEVEL, $input, $new_input );
62
- $this->sanitizeString ( 'Email Log Enabled', PostmanOptions::MAIL_LOG_ENABLED_OPTION, $input, $new_input );
63
- $this->sanitizeLogMax ( 'Email Log Max Entries', PostmanOptions::MAIL_LOG_MAX_ENTRIES, $input, $new_input );
64
- $this->sanitizeString ( 'Run Mode', PostmanOptions::RUN_MODE, $input, $new_input );
65
- $this->sanitizeString ( 'Stealth Mode', PostmanOptions::STEALTH_MODE, $input, $new_input );
66
- $this->sanitizeInt ( 'Transcript Size', PostmanOptions::TRANSCRIPT_SIZE, $input, $new_input );
67
- $this->sanitizeString ( 'Temporary Directory', PostmanOptions::TEMPORARY_DIRECTORY, $input, $new_input );
68
-
69
- if ($new_input [PostmanOptions::CLIENT_ID] != $this->options->getClientId () || $new_input [PostmanOptions::CLIENT_SECRET] != $this->options->getClientSecret () || $new_input [PostmanOptions::HOSTNAME] != $this->options->getHostname ()) {
70
- $this->logger->debug ( "Recognized new Client ID" );
71
  // the user entered a new client id and we should destroy the stored auth token
72
- delete_option ( PostmanOAuthToken::OPTIONS_NAME );
73
  }
74
-
75
  // can we create a tmp file? - this code is duplicated in ActivationHandler
76
- PostmanUtils::deleteLockFile ( $new_input [PostmanOptions::TEMPORARY_DIRECTORY] );
77
- $lockSuccess = PostmanUtils::createLockFile ( $new_input [PostmanOptions::TEMPORARY_DIRECTORY] );
78
  // &= does not work as expected in my PHP
79
- $lockSuccess = $lockSuccess && PostmanUtils::deleteLockFile ( $new_input [PostmanOptions::TEMPORARY_DIRECTORY] );
80
- $this->logger->debug ( 'FileLocking=' . $lockSuccess );
81
- PostmanState::getInstance ()->setFileLockingEnabled ( $lockSuccess );
82
-
83
- if ($success) {
84
- PostmanSession::getInstance ()->setAction ( self::VALIDATION_SUCCESS );
85
  } else {
86
- PostmanSession::getInstance ()->setAction ( self::VALIDATION_FAILED );
87
  }
88
-
89
  return $new_input;
90
  }
91
- private function sanitizeString($desc, $key, $input, &$new_input) {
92
- if (isset ( $input [$key] )) {
93
- $this->logSanitize ( $desc, $input [$key] );
94
- $new_input [$key] = trim ( $input [$key] );
95
  }
96
  }
97
-
98
  /**
99
  * Sanitize a Basic Auth password, and base64-encode it
100
  *
101
- * @param unknown $desc
102
- * @param unknown $key
103
- * @param unknown $input
104
- * @param unknown $new_input
105
  */
106
- private function sanitizePassword($desc, $key, $input, &$new_input, $existingPassword) {
107
  // WordPress calling Sanitize twice is a known issue
108
  // https://core.trac.wordpress.org/ticket/21989
109
- $action = PostmanSession::getInstance ()->getAction ();
110
  // if $action is not empty, then sanitize has already run
111
- if (! empty ( $action )) {
112
  // use the already encoded password in the $input
113
- $new_input [$key] = $input [$key];
114
  // log it
115
- $this->logger->debug ( 'Warning, second sanitizePassword attempt detected' );
116
- } else if (isset ( $input [$key] )) {
117
- if (strlen ( $input [$key] ) > 0 && preg_match ( '/^\**$/', $input [$key] )) {
118
  // if the password is all stars, then keep the existing password
119
- $new_input [$key] = $existingPassword;
120
  } else {
121
  // otherwise the password is new, so trim it
122
- $new_input [$key] = trim ( $input [$key] );
123
  }
124
  // log it
125
- $this->logSanitize ( $desc, $new_input [$key] );
126
  // base-64 scramble password
127
- $new_input [$key] = base64_encode ( $new_input [$key] );
128
  }
129
- $this->logger->debug ( sprintf ( 'Encoding %s as %s', $desc, $new_input [$key] ) );
130
  }
131
- private function sanitizeLogMax($desc, $key, $input, &$new_input) {
132
- if (isset ( $input [$key] )) {
133
- $value = absint ( $input [$key] );
134
- if ($value <= 0) {
135
- $new_input [$key] = PostmanOptions::getInstance ()->getMailLoggingMaxEntries ();
136
- $h = new PostmanMessageHandler ();
137
- $h->addError ( sprintf ( '%s %s', __ ( 'Maximum Log Entries', 'Configuration Input Field', Postman::TEXT_DOMAIN ), __ ( 'must be greater than 0', Postman::TEXT_DOMAIN ) ) );
138
  } else {
139
- $this->logSanitize ( $desc, $input [$key] );
140
- $new_input [$key] = $value;
141
  }
142
  }
143
  }
144
- private function sanitizeInt($desc, $key, $input, &$new_input) {
145
- if (isset ( $input [$key] )) {
146
- $this->logSanitize ( $desc, $input [$key] );
147
- $new_input [$key] = absint ( $input [$key] );
148
  }
149
  }
150
- private function logSanitize($desc, $value) {
151
- $this->logger->trace ( 'Sanitize ' . $desc . ' ' . $value );
152
  }
153
  }
154
  }
1
  <?php
2
+ if ( ! class_exists( 'PostmanInputSanitizer' ) ) {
3
  class PostmanInputSanitizer {
4
  private $logger;
5
  private $options;
6
  const VALIDATION_SUCCESS = 'validation_success';
7
  const VALIDATION_FAILED = 'validation_failed';
8
  public function __construct() {
9
+ $this->logger = new PostmanLogger( get_class( $this ) );
10
  $this->options = PostmanOptions::getInstance();
11
  }
12
+
13
  /**
14
  * Sanitize each setting field as needed
15
  *
16
  * @param array $input
17
  * Contains all settings fields as array keys
18
  */
19
+ public function sanitize( $input ) {
20
+ $this->logger->debug( 'Sanitizing data before storage' );
21
+
22
+ $new_input = array();
23
  $success = true;
24
+
25
+ $this->sanitizeString( 'Encryption Type', PostmanOptions::SECURITY_TYPE, $input, $new_input );
26
+ $this->sanitizeString( 'Hostname', PostmanOptions::HOSTNAME, $input, $new_input );
27
+ if ( ! empty( $input [ PostmanOptions::PORT ] ) ) {
28
+ $port = absint( $input [ PostmanOptions::PORT ] );
29
+ if ( $port > 0 ) {
30
+ $this->sanitizeInt( 'Port', PostmanOptions::PORT, $input, $new_input );
31
  } else {
32
+ $new_input [ PostmanOptions::PORT ] = $this->options->getPort();
33
+ add_settings_error( PostmanOptions::PORT, PostmanOptions::PORT, 'Invalid TCP Port', 'error' );
34
  $success = false;
35
  }
36
  }
37
  // check the auth type AFTER the hostname because we reset the hostname if auth is bad
38
+ $this->sanitizeString( 'From Email', PostmanOptions::MESSAGE_SENDER_EMAIL, $input, $new_input );
39
  // the wizard doesn't set an envelope sender, so we'll default it to From Email
40
+ $new_input [ PostmanOptions::ENVELOPE_SENDER ] = $new_input [ PostmanOptions::MESSAGE_SENDER_EMAIL ];
41
+ $this->sanitizeString( 'Sender Email', PostmanOptions::ENVELOPE_SENDER, $input, $new_input );
42
+ $this->sanitizeString( 'Transport Type', PostmanOptions::TRANSPORT_TYPE, $input, $new_input );
43
+ $this->sanitizeString( 'Authorization Type', PostmanOptions::AUTHENTICATION_TYPE, $input, $new_input );
44
+ $this->sanitizeString( 'From Name', PostmanOptions::MESSAGE_SENDER_NAME, $input, $new_input );
45
+ $this->sanitizeString( 'Client ID', PostmanOptions::CLIENT_ID, $input, $new_input );
46
+ $this->sanitizeString( 'Client Secret', PostmanOptions::CLIENT_SECRET, $input, $new_input );
47
+ $this->sanitizeString( 'Username', PostmanOptions::BASIC_AUTH_USERNAME, $input, $new_input );
48
+ $this->sanitizePassword( 'Password', PostmanOptions::BASIC_AUTH_PASSWORD, $input, $new_input, $this->options->getPassword() );
49
+ $this->sanitizePassword( 'Mandrill API Key', PostmanOptions::MANDRILL_API_KEY, $input, $new_input, $this->options->getMandrillApiKey() );
50
+ $this->sanitizePassword( 'SendGrid API Key', PostmanOptions::SENDGRID_API_KEY, $input, $new_input, $this->options->getSendGridApiKey() );
51
+ $this->sanitizeString( 'Reply-To', PostmanOptions::REPLY_TO, $input, $new_input );
52
+ $this->sanitizeString( 'From Name Override', PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE, $input, $new_input );
53
+ $this->sanitizeString( 'From Email Override', PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE, $input, $new_input );
54
+ $this->sanitizeString( 'Disable Email Validation', PostmanOptions::DISABLE_EMAIL_VALIDAITON, $input, $new_input );
55
+ $this->sanitizeString( 'Forced To Recipients', PostmanOptions::FORCED_TO_RECIPIENTS, $input, $new_input );
56
+ $this->sanitizeString( 'Forced CC Recipients', PostmanOptions::FORCED_CC_RECIPIENTS, $input, $new_input );
57
+ $this->sanitizeString( 'Forced BCC Recipients', PostmanOptions::FORCED_BCC_RECIPIENTS, $input, $new_input );
58
+ $this->sanitizeString( 'Additional Headers', PostmanOptions::ADDITIONAL_HEADERS, $input, $new_input );
59
+ $this->sanitizeInt( 'Read Timeout', PostmanOptions::READ_TIMEOUT, $input, $new_input );
60
+ $this->sanitizeInt( 'Conenction Timeout', PostmanOptions::CONNECTION_TIMEOUT, $input, $new_input );
61
+ $this->sanitizeInt( 'Log Level', PostmanOptions::LOG_LEVEL, $input, $new_input );
62
+ $this->sanitizeString( 'Email Log Enabled', PostmanOptions::MAIL_LOG_ENABLED_OPTION, $input, $new_input );
63
+ $this->sanitizeLogMax( 'Email Log Max Entries', PostmanOptions::MAIL_LOG_MAX_ENTRIES, $input, $new_input );
64
+ $this->sanitizeString( 'Run Mode', PostmanOptions::RUN_MODE, $input, $new_input );
65
+ $this->sanitizeString( 'Stealth Mode', PostmanOptions::STEALTH_MODE, $input, $new_input );
66
+ $this->sanitizeInt( 'Transcript Size', PostmanOptions::TRANSCRIPT_SIZE, $input, $new_input );
67
+ $this->sanitizeString( 'Temporary Directory', PostmanOptions::TEMPORARY_DIRECTORY, $input, $new_input );
68
+
69
+ if ( $new_input [ PostmanOptions::CLIENT_ID ] != $this->options->getClientId() || $new_input [ PostmanOptions::CLIENT_SECRET ] != $this->options->getClientSecret() || $new_input [ PostmanOptions::HOSTNAME ] != $this->options->getHostname() ) {
70
+ $this->logger->debug( 'Recognized new Client ID' );
71
  // the user entered a new client id and we should destroy the stored auth token
72
+ delete_option( PostmanOAuthToken::OPTIONS_NAME );
73
  }
74
+
75
  // can we create a tmp file? - this code is duplicated in ActivationHandler
76
+ PostmanUtils::deleteLockFile( $new_input [ PostmanOptions::TEMPORARY_DIRECTORY ] );
77
+ $lockSuccess = PostmanUtils::createLockFile( $new_input [ PostmanOptions::TEMPORARY_DIRECTORY ] );
78
  // &= does not work as expected in my PHP
79
+ $lockSuccess = $lockSuccess && PostmanUtils::deleteLockFile( $new_input [ PostmanOptions::TEMPORARY_DIRECTORY ] );
80
+ $this->logger->debug( 'FileLocking=' . $lockSuccess );
81
+ PostmanState::getInstance()->setFileLockingEnabled( $lockSuccess );
82
+
83
+ if ( $success ) {
84
+ PostmanSession::getInstance()->setAction( self::VALIDATION_SUCCESS );
85
  } else {
86
+ PostmanSession::getInstance()->setAction( self::VALIDATION_FAILED );
87
  }
88
+
89
  return $new_input;
90
  }
91
+ private function sanitizeString( $desc, $key, $input, &$new_input ) {
92
+ if ( isset( $input [ $key ] ) ) {
93
+ $this->logSanitize( $desc, $input [ $key ] );
94
+ $new_input [ $key ] = trim( $input [ $key ] );
95
  }
96
  }
97
+
98
  /**
99
  * Sanitize a Basic Auth password, and base64-encode it
100
  *
101
+ * @param unknown $desc
102
+ * @param unknown $key
103
+ * @param unknown $input
104
+ * @param unknown $new_input
105
  */
106
+ private function sanitizePassword( $desc, $key, $input, &$new_input, $existingPassword ) {
107
  // WordPress calling Sanitize twice is a known issue
108
  // https://core.trac.wordpress.org/ticket/21989
109
+ $action = PostmanSession::getInstance()->getAction();
110
  // if $action is not empty, then sanitize has already run
111
+ if ( ! empty( $action ) ) {
112
  // use the already encoded password in the $input
113
+ $new_input [ $key ] = $input [ $key ];
114
  // log it
115
+ $this->logger->debug( 'Warning, second sanitizePassword attempt detected' );
116
+ } else if ( isset( $input [ $key ] ) ) {
117
+ if ( strlen( $input [ $key ] ) > 0 && preg_match( '/^\**$/', $input [ $key ] ) ) {
118
  // if the password is all stars, then keep the existing password
119
+ $new_input [ $key ] = $existingPassword;
120
  } else {
121
  // otherwise the password is new, so trim it
122
+ $new_input [ $key ] = trim( $input [ $key ] );
123
  }
124
  // log it
125
+ $this->logSanitize( $desc, $new_input [ $key ] );
126
  // base-64 scramble password
127
+ $new_input [ $key ] = base64_encode( $new_input [ $key ] );
128
  }
129
+ $this->logger->debug( sprintf( 'Encoding %s as %s', $desc, $new_input [ $key ] ) );
130
  }
131
+ private function sanitizeLogMax( $desc, $key, $input, &$new_input ) {
132
+ if ( isset( $input [ $key ] ) ) {
133
+ $value = absint( $input [ $key ] );
134
+ if ( $value <= 0 ) {
135
+ $new_input [ $key ] = PostmanOptions::getInstance()->getMailLoggingMaxEntries();
136
+ $h = new PostmanMessageHandler();
137
+ $h->addError( sprintf( '%s %s', __( 'Maximum Log Entries', Postman::TEXT_DOMAIN ), __( 'must be greater than 0', Postman::TEXT_DOMAIN ) ) );
138
  } else {
139
+ $this->logSanitize( $desc, $input [ $key ] );
140
+ $new_input [ $key ] = $value;
141
  }
142
  }
143
  }
144
+ private function sanitizeInt( $desc, $key, $input, &$new_input ) {
145
+ if ( isset( $input [ $key ] ) ) {
146
+ $this->logSanitize( $desc, $input [ $key ] );
147
+ $new_input [ $key ] = absint( $input [ $key ] );
148
  }
149
  }
150
+ private function logSanitize( $desc, $value ) {
151
+ $this->logger->trace( 'Sanitize ' . $desc . ' ' . $value );
152
  }
153
  }
154
  }
Postman/PostmanPluginFeedback.php CHANGED
@@ -4,7 +4,6 @@ class PostmanPluginFeedback {
4
  function __construct() {
5
  add_filter( 'plugin_action_links_' . plugin_basename( POST_BASE ), array( $this, 'insert_deactivate_link_id' ) );
6
  add_action( 'wp_ajax_post_user_feedback', array( $this, 'post_user_feedback' ) );
7
-
8
  global $pagenow;
9
  if ( 'plugins.php' === $pagenow ) {
10
  add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
@@ -15,7 +14,7 @@ class PostmanPluginFeedback {
15
 
16
  function load_scripts() {
17
  wp_enqueue_style( 'wp-jquery-ui-dialog' );
18
- wp_register_script( 'post-feedback', plugins_url( 'script/feedback/feedback.js', POST_BASE ), array( 'jquery', 'jquery-ui-core', 'jquery-ui-dialog' ), fasle, true );
19
  wp_localize_script( 'post-feedback', 'post_feedback', array( 'admin_ajax' => admin_url( 'admin-ajax.php' ) ) );
20
  wp_enqueue_script( 'post-feedback' );
21
  }
@@ -27,7 +26,7 @@ class PostmanPluginFeedback {
27
 
28
  $payload = array(
29
  'reason' => sanitize_text_field( $_POST['reason'] ),
30
- 'other_input' => isset( $_POST['other_input'] ) ? sanitize_textarea_field( $_POST['other_input'] ) : '',
31
  );
32
 
33
  if ( isset( $_POST['support'] ) ) {
@@ -38,6 +37,7 @@ class PostmanPluginFeedback {
38
 
39
  $args = array(
40
  'body' => $payload,
 
41
  );
42
  $result = wp_remote_post( 'https://postmansmtp.com/feedback', $args );
43
  die( 'success' );
@@ -50,11 +50,11 @@ class PostmanPluginFeedback {
50
  float: none !important;
51
  }
52
 
53
- #postman-feedback-dialog-skip {
54
  float: left;
55
  }
56
 
57
- #postman-feedback-dialog-go, #postman-feedback-dialog-cancel {
58
  float: right;
59
  }
60
 
@@ -62,11 +62,31 @@ class PostmanPluginFeedback {
62
  font-size: 1.1em;
63
  }
64
 
65
- #postman-deactivate-reasons textarea {
66
  margin-top: 10px;
67
  width: 100%;
68
  height: 150px;
69
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  </style>
71
  <?php
72
  }
@@ -87,31 +107,32 @@ class PostmanPluginFeedback {
87
  <form>
88
  <?php wp_nonce_field(); ?>
89
  <ul id="postman-deactivate-reasons">
 
 
 
 
 
 
 
90
  <li class="postman-reason postman-custom-input">
91
  <label>
92
  <span><input value="Found a better plugin" type="radio" name="reason" /></span>
93
  <span><?php _e( 'Found a better plugin', 'postman' ); ?></span>
94
- </label>
95
- <div class="postman-reason-input" style="display: none;">
96
- <textarea name="other_input"></textarea>
97
- </div>
98
  </li>
99
- <li class="postman-reason">
100
  <label>
101
- <span><input value="The plugin didn't work" type="radio" name="reason" /></span>
102
  <span><?php _e( 'The plugin didn\'t work', 'postman' ); ?></span>
103
- </label>
104
- </li>
105
  <li class="postman-reason postman-custom-input">
106
  <label>
107
  <span><input value="Other Reason" type="radio" name="reason" /></span>
108
  <span><?php _e( 'Other Reason', 'postman' ); ?></span>
109
  </label>
110
- <div class="postman-reason-input" style="display: none;">
111
- <textarea name="other_input"></textarea>
112
- </div>
113
  </li>
114
- <li class="postman-reason postman-custom-input">
115
  <label>
116
  <span><input value="Support Ticket" type="radio" name="reason" /></span>
117
  <span><?php _e( 'Open A support ticket for me', 'postman' ); ?></span>
@@ -121,8 +142,11 @@ class PostmanPluginFeedback {
121
  <input type="text" name="support[title]" placeholder="The Title" required>
122
  <textarea name="support[text]" placeholder="Describe the issue" required></textarea>
123
  </div>
124
- </li>
125
  </ul>
 
 
 
126
  </form>
127
  </div>
128
  <?php
4
  function __construct() {
5
  add_filter( 'plugin_action_links_' . plugin_basename( POST_BASE ), array( $this, 'insert_deactivate_link_id' ) );
6
  add_action( 'wp_ajax_post_user_feedback', array( $this, 'post_user_feedback' ) );
 
7
  global $pagenow;
8
  if ( 'plugins.php' === $pagenow ) {
9
  add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
14
 
15
  function load_scripts() {
16
  wp_enqueue_style( 'wp-jquery-ui-dialog' );
17
+ wp_register_script( 'post-feedback', plugins_url( 'script/feedback/feedback.js', POST_BASE ), array( 'jquery', 'jquery-ui-core', 'jquery-ui-dialog' ), false, true );
18
  wp_localize_script( 'post-feedback', 'post_feedback', array( 'admin_ajax' => admin_url( 'admin-ajax.php' ) ) );
19
  wp_enqueue_script( 'post-feedback' );
20
  }
26
 
27
  $payload = array(
28
  'reason' => sanitize_text_field( $_POST['reason'] ),
29
+ 'other_input' => isset( $_POST['other_input'] ) ? sanitize_text_field( $_POST['other_input'] ) : '',
30
  );
31
 
32
  if ( isset( $_POST['support'] ) ) {
37
 
38
  $args = array(
39
  'body' => $payload,
40
+ 'timeout' => 20,
41
  );
42
  $result = wp_remote_post( 'https://postmansmtp.com/feedback', $args );
43
  die( 'success' );
50
  float: none !important;
51
  }
52
 
53
+ #postman-feedback-dialog-go {
54
  float: left;
55
  }
56
 
57
+ #postman-feedback-dialog-skip, #postman-feedback-dialog-cancel {
58
  float: right;
59
  }
60
 
62
  font-size: 1.1em;
63
  }
64
 
65
+ .postman-reason-input textarea {
66
  margin-top: 10px;
67
  width: 100%;
68
  height: 150px;
69
  }
70
+
71
+ .postman-feedback-dialog-form .ui-icon {
72
+ display: none;
73
+ }
74
+
75
+ #postman-feedback-dialog-go.postman-ajax-progress .ui-icon {
76
+ text-indent: inherit;
77
+ display: inline-block !important;
78
+ vertical-align: middle;
79
+ animation: rotate 2s infinite linear;
80
+ }
81
+
82
+ #postman-feedback-dialog-go.postman-ajax-progress .ui-button-text {
83
+ vertical-align: middle;
84
+ }
85
+
86
+ @keyframes rotate {
87
+ 0% { transform: rotate(0deg); }
88
+ 100% { transform: rotate(360deg); }
89
+ }
90
  </style>
91
  <?php
92
  }
107
  <form>
108
  <?php wp_nonce_field(); ?>
109
  <ul id="postman-deactivate-reasons">
110
+
111
+ <li class="postman-reason">
112
+ <label>
113
+ <span><input value="bad support" type="radio" name="reason" checked/></span>
114
+ <span><?php _e( 'Bad Support', 'postman' ); ?></span>
115
+ </label>
116
+ </li>
117
  <li class="postman-reason postman-custom-input">
118
  <label>
119
  <span><input value="Found a better plugin" type="radio" name="reason" /></span>
120
  <span><?php _e( 'Found a better plugin', 'postman' ); ?></span>
121
+ </label>
 
 
 
122
  </li>
123
+ <li class="postman-reason postman-custom-input">
124
  <label>
125
+ <span><input value="<?php echo esc_attr( "The plugin didn't work" ); ?>" type="radio" name="reason" /></span>
126
  <span><?php _e( 'The plugin didn\'t work', 'postman' ); ?></span>
127
+ </label>
128
+ </li>
129
  <li class="postman-reason postman-custom-input">
130
  <label>
131
  <span><input value="Other Reason" type="radio" name="reason" /></span>
132
  <span><?php _e( 'Other Reason', 'postman' ); ?></span>
133
  </label>
 
 
 
134
  </li>
135
+ <li class="postman-reason postman-support-input">
136
  <label>
137
  <span><input value="Support Ticket" type="radio" name="reason" /></span>
138
  <span><?php _e( 'Open A support ticket for me', 'postman' ); ?></span>
142
  <input type="text" name="support[title]" placeholder="The Title" required>
143
  <textarea name="support[text]" placeholder="Describe the issue" required></textarea>
144
  </div>
145
+ </li>
146
  </ul>
147
+ <div class="postman-reason-input" style="display: none;">
148
+ <input type="text" class="regular-text" name="other_input" placeholder="Do you mind help and give more detailes?">
149
+ </div>
150
  </form>
151
  </div>
152
  <?php
Postman/PostmanViewController.php CHANGED
@@ -49,8 +49,8 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
49
  */
50
  public function generateDefaultContent() {
51
  // This page will be under "Settings"
52
- $pageTitle = sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) );
53
- $pluginName = __( 'Postman SMTP', Postman::TEXT_DOMAIN );
54
  $uniqueId = self::POSTMAN_MENU_SLUG;
55
  $pageOptions = array(
56
  $this,
@@ -72,7 +72,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
72
  * Register the Email Test screen
73
  */
74
  public function addPurgeDataSubmenu() {
75
- $page = add_submenu_page( null, sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanAdminController::MANAGE_OPTIONS_PAGE_SLUG, array(
76
  $this,
77
  'outputPurgeDataContent',
78
  ) );
@@ -182,7 +182,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
182
  * @param string $slug
183
  */
184
  public static function outputChildPageHeader( $title, $slug = '' ) {
185
- printf( '<h2>%s</h2>', sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) ) );
186
  printf( '<div id="postman-main-menu" class="welcome-panel %s">', $slug );
187
  print '<div class="welcome-panel-content">';
188
  print '<div class="welcome-panel-column-container">';
@@ -253,15 +253,14 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
253
  /**
254
  */
255
  private function displayTopNavigation() {
256
- screen_icon();
257
- printf( '<h2>%s</h2>', sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) ) );
258
  print '<div id="postman-main-menu" class="welcome-panel">';
259
  print '<div class="welcome-panel-content">';
260
  print '<div class="welcome-panel-column-container">';
261
  print '<div class="welcome-panel-column">';
262
  printf( '<h4>%s</h4>', __( 'Configuration', Postman::TEXT_DOMAIN ) );
263
  printf( '<a class="button button-primary button-hero" href="%s">%s</a>', $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG ), __( 'Start the Wizard', Postman::TEXT_DOMAIN ) );
264
- printf( '<p class="">or <a href="%s" class="configure_manually">%s</a></p>', $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_SLUG ), __( 'Show All Settings', Postman::TEXT_DOMAIN ) );
265
  print '</div>';
266
  print '<div class="welcome-panel-column">';
267
  printf( '<h4>%s</h4>', _x( 'Actions', 'Main Menu', Postman::TEXT_DOMAIN ) );
@@ -295,7 +294,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
295
  printf( '<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl( PostmanConnectivityTestController::PORT_TEST_SLUG ), __( 'Connectivity Test', Postman::TEXT_DOMAIN ) );
296
  printf( '<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl( PostmanDiagnosticTestController::DIAGNOSTICS_SLUG ), __( 'Diagnostic Test', Postman::TEXT_DOMAIN ) );
297
  printf( '<li><a href="https://postmansmtp.com/forums/" class="welcome-icon postman_support">%s</a></li>', __( 'Online Support', Postman::TEXT_DOMAIN ) );
298
- printf( '<li><img class="align-middle" src="' . plugins_url( 'style/images/new.gif', dirname( __DIR__ ) . '/postman-smtp.php' ) . '"><a class="align-middle" href="https://postmansmtp.com/category/guides/" class="welcome-icon postman_guides">%s</a></li>', __( 'Guides', Postman::TEXT_DOMAIN ) );
299
  print '</ul></div></div></div></div>';
300
  }
301
  }
49
  */
50
  public function generateDefaultContent() {
51
  // This page will be under "Settings"
52
+ $pageTitle = sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) );
53
+ $pluginName = __( 'Post SMTP', Postman::TEXT_DOMAIN );
54
  $uniqueId = self::POSTMAN_MENU_SLUG;
55
  $pageOptions = array(
56
  $this,
72
  * Register the Email Test screen
73
  */
74
  public function addPurgeDataSubmenu() {
75
+ $page = add_submenu_page( null, sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) ), __( 'Post SMTP', Postman::TEXT_DOMAIN ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanAdminController::MANAGE_OPTIONS_PAGE_SLUG, array(
76
  $this,
77
  'outputPurgeDataContent',
78
  ) );
182
  * @param string $slug
183
  */
184
  public static function outputChildPageHeader( $title, $slug = '' ) {
185
+ printf( '<h2>%s</h2>', sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) ) );
186
  printf( '<div id="postman-main-menu" class="welcome-panel %s">', $slug );
187
  print '<div class="welcome-panel-content">';
188
  print '<div class="welcome-panel-column-container">';
253
  /**
254
  */
255
  private function displayTopNavigation() {
256
+ printf( '<h2>%s</h2>', sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) ) );
 
257
  print '<div id="postman-main-menu" class="welcome-panel">';
258
  print '<div class="welcome-panel-content">';
259
  print '<div class="welcome-panel-column-container">';
260
  print '<div class="welcome-panel-column">';
261
  printf( '<h4>%s</h4>', __( 'Configuration', Postman::TEXT_DOMAIN ) );
262
  printf( '<a class="button button-primary button-hero" href="%s">%s</a>', $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG ), __( 'Start the Wizard', Postman::TEXT_DOMAIN ) );
263
+ printf( '<p class="">%s <a href="%s" class="configure_manually">%s</a></p>', __( 'or', Postman::TEXT_DOMAIN ), $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_SLUG ), __( 'Show All Settings', Postman::TEXT_DOMAIN ) );
264
  print '</div>';
265
  print '<div class="welcome-panel-column">';
266
  printf( '<h4>%s</h4>', _x( 'Actions', 'Main Menu', Postman::TEXT_DOMAIN ) );
294
  printf( '<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl( PostmanConnectivityTestController::PORT_TEST_SLUG ), __( 'Connectivity Test', Postman::TEXT_DOMAIN ) );
295
  printf( '<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl( PostmanDiagnosticTestController::DIAGNOSTICS_SLUG ), __( 'Diagnostic Test', Postman::TEXT_DOMAIN ) );
296
  printf( '<li><a href="https://postmansmtp.com/forums/" class="welcome-icon postman_support">%s</a></li>', __( 'Online Support', Postman::TEXT_DOMAIN ) );
297
+ printf( '<li><img class="align-middle" src="' . plugins_url( 'style/images/new.gif', dirname( __DIR__ ) . '/postman-smtp.php' ) . '"><a target="blank" class="align-middle" href="https://postmansmtp.com/category/guides/" class="welcome-icon postman_guides">%s</a></li>', __( 'Guides', Postman::TEXT_DOMAIN ) );
298
  print '</ul></div></div></div></div>';
299
  }
300
  }
postman-smtp.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Post SMTP
5
  * Plugin URI: https://wordpress.org/plugins/post-smtp/
6
  * 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!
7
- * Version: 1.7.8
8
  * Author: Jason Hendriks, Yehuda Hassine
9
  * Text Domain: post-smtp
10
  * Author URI: https://postmansmtp.com
@@ -71,5 +71,5 @@ function post_start( $startingMemory ) {
71
  */
72
  function post_setupPostman() {
73
  require_once 'Postman/Postman.php';
74
- $kevinCostner = new Postman( __FILE__, '1.7.8' );
75
  }
4
  * Plugin Name: Post SMTP
5
  * Plugin URI: https://wordpress.org/plugins/post-smtp/
6
  * 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!
7
+ * Version: 1.7.9
8
  * Author: Jason Hendriks, Yehuda Hassine
9
  * Text Domain: post-smtp
10
  * Author URI: https://postmansmtp.com
71
  */
72
  function post_setupPostman() {
73
  require_once 'Postman/Postman.php';
74
+ $kevinCostner = new Postman( __FILE__, '1.7.9' );
75
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: yehudah, jasonhendriks
3
  Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email
4
  Requires at least: 3.9
5
  Tested up to: 4.9
6
- Stable tag: 1.7.8
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -277,10 +277,20 @@ To avoid being flagged as spam, you need to prove your email isn't forged. On a
277
  1. Emai Log screen
278
  1. Connectivity Test utility screen
279
  1. Diagnostic Information screen
 
280
 
281
 
282
 
283
  == Changelog ==
 
 
 
 
 
 
 
 
 
284
  = 1.7.8 - 2017-11-17
285
  * = Menu Items grouping =
286
  * Fixed: IP detection error in some web hosts
3
  Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email
4
  Requires at least: 3.9
5
  Tested up to: 4.9
6
+ Stable tag: 1.7.9
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
277
  1. Emai Log screen
278
  1. Connectivity Test utility screen
279
  1. Diagnostic Information screen
280
+ 1. Email Log Filter
281
 
282
 
283
 
284
  == Changelog ==
285
+
286
+ = 1.7.9 - 2017-11-20
287
+ * Fixed: misspled false
288
+ * Fixed: feedback form
289
+ * Fixed: Some localization strings
290
+ * Removed: deprecated function
291
+ * New: Option to input emails when resend email
292
+ * Added: explain message on email log filter
293
+
294
  = 1.7.8 - 2017-11-17
295
  * = Menu Items grouping =
296
  * Fixed: IP detection error in some web hosts
script/feedback/feedback.js CHANGED
@@ -13,24 +13,17 @@ jQuery(document).ready(function($) {
13
  minWidth: 400,
14
  minHeight: 300,
15
  modal: true,
16
- buttons: {
17
- 'skip' : {
18
- text: 'Skip',
19
- id: 'postman-feedback-dialog-skip',
20
- click: function() {
21
- $( this ).dialog( "close" );
22
-
23
- location.href = deactivateLink;
24
- }
25
- },
26
  'go' : {
27
  text: 'Continue',
 
28
  id: 'postman-feedback-dialog-go',
29
  class: 'button',
30
  click: function() {
31
- $( this ).dialog( "close" );
32
 
33
- var form = $( this ).find( 'form' ).serializeArray(),
 
 
34
  result = {};
35
 
36
  $.each( form, function() {
@@ -41,13 +34,26 @@ jQuery(document).ready(function($) {
41
  if ( ! jQuery.isEmptyObject( result ) ) {
42
  result.action = 'post_user_feedback';
43
 
44
- $.post( post_feedback.admin_ajax, result, function(result) {
45
-
46
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  }
48
 
49
- // Remove this comment to deactivate plugin
50
- location.href = deactivateLink;
51
  },
52
  },
53
  'cancel' : {
@@ -57,7 +63,16 @@ jQuery(document).ready(function($) {
57
  click: function() {
58
  $( this ).dialog( "close" );
59
  }
60
- }
 
 
 
 
 
 
 
 
 
61
  }
62
  });
63
 
@@ -65,8 +80,13 @@ jQuery(document).ready(function($) {
65
  $( '.postman-reason-input' ).hide();
66
 
67
  if ( $( this ).hasClass( 'postman-custom-input' ) ) {
68
- $( this ).find( '.postman-reason-input' ).show();
69
  }
 
 
 
 
 
70
  });
71
 
72
  });
13
  minWidth: 400,
14
  minHeight: 300,
15
  modal: true,
16
+ buttons: {
 
 
 
 
 
 
 
 
 
17
  'go' : {
18
  text: 'Continue',
19
+ icons: { primary: "dashicons dashicons-update" },
20
  id: 'postman-feedback-dialog-go',
21
  class: 'button',
22
  click: function() {
 
23
 
24
+ var dialog = $(this),
25
+ go = $('#postman-feedback-dialog-go'),
26
+ form = dialog.find( 'form' ).serializeArray(),
27
  result = {};
28
 
29
  $.each( form, function() {
34
  if ( ! jQuery.isEmptyObject( result ) ) {
35
  result.action = 'post_user_feedback';
36
 
37
+ $.ajax({
38
+ url: post_feedback.admin_ajax,
39
+ type: 'POST',
40
+ data: result,
41
+ error: function(){},
42
+ success: function(msg){},
43
+ beforeSend: function() {
44
+ go.addClass('postman-ajax-progress');
45
+ },
46
+ complete: function() {
47
+ go.removeClass('postman-ajax-progress');
48
+
49
+ dialog.dialog( "close" );
50
+ location.href = deactivateLink;
51
+ }
52
+ });
53
+
54
  }
55
 
56
+
 
57
  },
58
  },
59
  'cancel' : {
63
  click: function() {
64
  $( this ).dialog( "close" );
65
  }
66
+ },
67
+ 'skip' : {
68
+ text: 'Skip',
69
+ id: 'postman-feedback-dialog-skip',
70
+ click: function() {
71
+ $( this ).dialog( "close" );
72
+
73
+ location.href = deactivateLink;
74
+ }
75
+ },
76
  }
77
  });
78
 
80
  $( '.postman-reason-input' ).hide();
81
 
82
  if ( $( this ).hasClass( 'postman-custom-input' ) ) {
83
+ $( '#postman-deactivate-reasons' ).next( '.postman-reason-input' ).show();
84
  }
85
+
86
+ if ( $( this ).hasClass( 'postman-support-input' ) ) {
87
+ console.log($(this));
88
+ $( this ).find( '.postman-reason-input' ).show();
89
+ }
90
  });
91
 
92
  });
script/postman_resend_email_sript.js CHANGED
@@ -1,17 +1,43 @@
1
- function postman_resend_email(emailId) {
2
- var data = {
3
- 'action' : 'postman_resend_mail',
4
- 'email' : emailId
5
- };
6
-
7
- jQuery.post(ajaxurl, data, function(response) {
8
- if (response.success) {
9
- alert(response.data.message);
10
- // jQuery('span#resend-' + emailId).text(postman_js_resend_label);
11
- } else {
12
- alert(sprintf(postman_js_email_not_resent, response.data.message));
13
- }
14
- }).fail(function(response) {
15
- ajaxFailed(response);
16
  });
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+ $('.postman-open-resend').on('click', function(e) {
3
+ e.preventDefault();
4
+
5
+ $(this).parent().next('div').fadeToggle();
 
 
 
 
 
 
 
 
 
 
6
  });
7
+
8
+ $('.postman-resend').on('click', function(e) {
9
+ e.preventDefault();
10
+
11
+ var parent = $(this).closest('div'),
12
+ mailField = $(this).prev('input'),
13
+ emailId = mailField.data('id'),
14
+ mail_to = mailField.val(),
15
+ security = parent.find('input[name="security"]').val();
16
+
17
+
18
+ postman_resend_email(emailId, mail_to, security);
19
+
20
+ });
21
+
22
+ function postman_resend_email(emailId, mail_to, security ) {
23
+ var data = {
24
+ 'action' : 'postman_resend_mail',
25
+ 'email' : emailId,
26
+ 'mail_to' : mail_to,
27
+ 'security' : security
28
+ };
29
+
30
+ jQuery.post(ajaxurl, data, function(response) {
31
+ if (response.success) {
32
+ alert(response.data.message);
33
+ // jQuery('span#resend-' + emailId).text(postman_js_resend_label);
34
+ } else {
35
+ alert(sprintf(postman_js_email_not_resent, response.data.message));
36
+ }
37
+ }).fail(function(response) {
38
+ ajaxFailed(response);
39
+ });
40
+ }
41
+
42
+ })
43
+