Postie - Version 1.9.39

Version Description

(2019-11-12) = * Add Site Health checks * PHP 7.3 compatibility * Fix bug where if Remove matched categories is No then the default category is always set. * Address deprecated file class-oembed.php

Download this release

Release Info

Developer WayneAllen
Plugin Icon 128x128 Postie
Version 1.9.39
Comparing to
See all releases

Code changes from version 1.9.38 to 1.9.39

docs/Changes.txt CHANGED
@@ -35,6 +35,12 @@ All script, style and body tags are stripped from html emails.
35
  Attachments are now processed in the order they were attached.
36
 
37
  == CHANGELOG ==
 
 
 
 
 
 
38
  = 1.9.38 (2019-07-27) =
39
  * Fix bug where filtering out an attachment prevented other attachments from being processed
40
 
35
  Attachments are now processed in the order they were attached.
36
 
37
  == CHANGELOG ==
38
+ = 1.9.39 (2019-11-12) =
39
+ * Add Site Health checks
40
+ * PHP 7.3 compatibility
41
+ * Fix bug where if Remove matched categories is No then the default category is always set.
42
+ * Address deprecated file class-oembed.php
43
+
44
  = 1.9.38 (2019-07-27) =
45
  * Fix bug where filtering out an attachment prevented other attachments from being processed
46
 
docs/Postie.txt CHANGED
@@ -6,8 +6,8 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
- Tested up to: 5.2
10
- Stable tag: 1.9.38
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
6
  Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
+ Tested up to: 5.3
10
+ Stable tag: 1.9.39
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
lib/fException.php CHANGED
@@ -308,7 +308,7 @@ abstract class fException extends Exception {
308
  $text_matches[$i] .= $html_matches[$i][0];
309
  }
310
 
311
- $content_with_newlines = implode($text_matches);
312
 
313
  $output = ($no_block_html) ? '<p>' : '';
314
  $output .= $content_with_newlines;
@@ -367,7 +367,7 @@ abstract class fException extends Exception {
367
 
368
  foreach ($list_items as $list_item) {
369
  foreach ($matching_array as $num => $match_string) {
370
- if (strpos($list_item[1], $match_string) !== FALSE) {
371
  $ordered_items[$num][] = $list_item[0];
372
  continue 2;
373
  }
@@ -501,7 +501,7 @@ abstract class fException extends Exception {
501
 
502
  foreach ($list_items as $list_item) {
503
  foreach ($matching_array as $match_num => $matching_string) {
504
- if (strpos($list_item[1], $matching_string) !== FALSE) {
505
  $matched_list_items[$match_num][] = $list_item[0];
506
  $found = TRUE;
507
  continue 2;
308
  $text_matches[$i] .= $html_matches[$i][0];
309
  }
310
 
311
+ $content_with_newlines = implode('', $text_matches);
312
 
313
  $output = ($no_block_html) ? '<p>' : '';
314
  $output .= $content_with_newlines;
367
 
368
  foreach ($list_items as $list_item) {
369
  foreach ($matching_array as $num => $match_string) {
370
+ if (strpos($list_item[1], strval($match_string)) !== FALSE) {
371
  $ordered_items[$num][] = $list_item[0];
372
  continue 2;
373
  }
501
 
502
  foreach ($list_items as $list_item) {
503
  foreach ($matching_array as $match_num => $matching_string) {
504
+ if (strpos($list_item[1], strval($matching_string)) !== FALSE) {
505
  $matched_list_items[$match_num][] = $list_item[0];
506
  $found = TRUE;
507
  continue 2;
lib/fMailbox.php CHANGED
@@ -560,7 +560,7 @@ class fMailbox {
560
  * @param string $filter Remove any headers that match this
561
  * @return array The parsed headers
562
  */
563
- static public function parseHeaders($headers, $filter = NULL) {
564
  $headers = trim($headers);
565
  if (!strlen($headers)) {
566
  return array();
@@ -580,10 +580,6 @@ class fMailbox {
580
  list ($header, $value) = preg_split('#:\s*#', $header_line, 2);
581
  $header = strtolower($header);
582
 
583
- if (strpos($header, $filter) !== FALSE) {
584
- continue;
585
- }
586
-
587
  $is_single_email = in_array($header, $single_email_fields);
588
  $is_multi_email = in_array($header, $multi_email_fields);
589
  $is_additional_info_field = in_array($header, $additional_info_fields);
560
  * @param string $filter Remove any headers that match this
561
  * @return array The parsed headers
562
  */
563
+ static public function parseHeaders($headers) {
564
  $headers = trim($headers);
565
  if (!strlen($headers)) {
566
  return array();
580
  list ($header, $value) = preg_split('#:\s*#', $header_line, 2);
581
  $header = strtolower($header);
582
 
 
 
 
 
583
  $is_single_email = in_array($header, $single_email_fields);
584
  $is_multi_email = in_array($header, $multi_email_fields);
585
  $is_additional_info_field = in_array($header, $additional_info_fields);
lib/simple_html_dom.php CHANGED
@@ -1698,7 +1698,7 @@ class simple_html_dom
1698
 
1699
  foreach($this->noise as $noiseElement)
1700
  {
1701
- if (strpos($noiseElement, $text)!==false)
1702
  {
1703
  return $noiseElement;
1704
  }
1698
 
1699
  foreach($this->noise as $noiseElement)
1700
  {
1701
+ if (strpos($noiseElement, strval($text))!==false)
1702
  {
1703
  return $noiseElement;
1704
  }
postie-api.php CHANGED
@@ -29,10 +29,11 @@ function EchoError($v) {
29
 
30
  function DebugDump($v) {
31
  global $g_postie;
 
32
  if (defined('POSTIE_DEBUG') && true == POSTIE_DEBUG && !empty($g_postie)) {
33
- $g_postie->log_onscreen(print_r($v, true));
34
  }
35
- do_action('postie_log_debug', print_r($v, true));
36
  }
37
 
38
  function DebugEcho($v, $force = false) {
29
 
30
  function DebugDump($v) {
31
  global $g_postie;
32
+ $d = print_r($v, true);
33
  if (defined('POSTIE_DEBUG') && true == POSTIE_DEBUG && !empty($g_postie)) {
34
+ $g_postie->log_onscreen($d);
35
  }
36
+ do_action('postie_log_debug', $d);
37
  }
38
 
39
  function DebugEcho($v, $force = false) {
postie-filters.php CHANGED
@@ -30,6 +30,7 @@ function filter_AttachmentTemplates($content, $mimeDecodedEmail, $post_id, $conf
30
  foreach ($mimeDecodedEmail['attachment'] as $attachment) {
31
  if (isset($attachment['wp_filename'])) {
32
  DebugEcho("filter_AttachmentTemplates: image: " . $attachment['wp_filename']);
 
33
  $skip = ($featuredimageid == $attachment['wp_id'] && !$config['include_featured_image']) || $attachment['exclude'];
34
  if (!$skip) {
35
  if (!$addimages && $attachment['primary'] == 'image') {
@@ -504,6 +505,9 @@ function filter_ReplaceImagePlaceHolders_worker($content, &$attachment, $imagePa
504
  //DebugEcho($content);
505
  DebugDump($matches);
506
  foreach ($matches as $match) {
 
 
 
507
  $attachment['exclude'] = true;
508
  $imageTemplate = $attachment['template'];
509
 
30
  foreach ($mimeDecodedEmail['attachment'] as $attachment) {
31
  if (isset($attachment['wp_filename'])) {
32
  DebugEcho("filter_AttachmentTemplates: image: " . $attachment['wp_filename']);
33
+ DebugEcho("filter_AttachmentTemplates: skip: $featuredimageid, " . $attachment['wp_id'] . ', ' . $config['include_featured_image'] . ', ' . $attachment['exclude']);
34
  $skip = ($featuredimageid == $attachment['wp_id'] && !$config['include_featured_image']) || $attachment['exclude'];
35
  if (!$skip) {
36
  if (!$addimages && $attachment['primary'] == 'image') {
505
  //DebugEcho($content);
506
  DebugDump($matches);
507
  foreach ($matches as $match) {
508
+ DebugEcho('filter_ReplaceImagePlaceHolders_worker: processing:');
509
+ DebugDump($match);
510
+
511
  $attachment['exclude'] = true;
512
  $imageTemplate = $attachment['template'];
513
 
postie-tags.php CHANGED
@@ -353,8 +353,10 @@ function tag_Categories(&$subject, $defaultCategoryId, $config, $post_id) {
353
  if ($config[PostieConfigOptions::PostType] == 'page') {
354
  DebugEcho("tag_Categories: no default, page post type, not adding default category");
355
  } else {
356
- DebugEcho("tag_Categories: using default: $defaultCategoryId for post type {$config[PostieConfigOptions::PostType]}");
357
- $post_categories[] = $defaultCategoryId;
 
 
358
  }
359
  $subject = $original_subject;
360
  }
@@ -391,7 +393,7 @@ function tag_PostType(&$subject, &$config) {
391
 
392
  $custom_post_type_delim = '//';
393
  $trial = '';
394
- if (strpos($subject, $custom_post_type_delim) !== FALSE) {
395
  // Captures the custom post type in the subject before $custom_post_type_delim
396
  $separated_subject = explode($custom_post_type_delim, $subject);
397
  $trial = trim(strtolower($separated_subject[0]));
@@ -414,10 +416,10 @@ function tag_PostType(&$subject, &$config) {
414
  }
415
 
416
  function tag_Date(&$content, $message_date) {
417
- DebugEcho("tag_Date: starting");
 
418
 
419
  foreach (postie_content_lines($content) as $e) {
420
- //DebugEcho("tag_Date: " . $e);
421
  $matches = array();
422
  if (1 === preg_match("/^\s*date:(.*)$/imu", $e, $matches)) {
423
  $possibledate = trim($matches[1]);
@@ -441,6 +443,8 @@ function tag_Date(&$content, $message_date) {
441
  //DebugEcho("tag_Date: nothing found");
442
  }
443
  }
 
 
444
 
445
  return $message_date;
446
  }
353
  if ($config[PostieConfigOptions::PostType] == 'page') {
354
  DebugEcho("tag_Categories: no default, page post type, not adding default category");
355
  } else {
356
+ if (!$found) {
357
+ DebugEcho("tag_Categories: using default: $defaultCategoryId for post type {$config[PostieConfigOptions::PostType]}");
358
+ $post_categories[] = $defaultCategoryId;
359
+ }
360
  }
361
  $subject = $original_subject;
362
  }
393
 
394
  $custom_post_type_delim = '//';
395
  $trial = '';
396
+ if (strpos($subject, strval($custom_post_type_delim)) !== FALSE) {
397
  // Captures the custom post type in the subject before $custom_post_type_delim
398
  $separated_subject = explode($custom_post_type_delim, $subject);
399
  $trial = trim(strtolower($separated_subject[0]));
416
  }
417
 
418
  function tag_Date(&$content, $message_date) {
419
+
420
+ DebugEcho("tag_Date: start");
421
 
422
  foreach (postie_content_lines($content) as $e) {
 
423
  $matches = array();
424
  if (1 === preg_match("/^\s*date:(.*)$/imu", $e, $matches)) {
425
  $possibledate = trim($matches[1]);
443
  //DebugEcho("tag_Date: nothing found");
444
  }
445
  }
446
+
447
+ DebugEcho("tag_Date: end: $message_date");
448
 
449
  return $message_date;
450
  }
postie.class.php CHANGED
@@ -21,10 +21,13 @@ require_once(ABSPATH . 'wp-admin/includes/image.php');
21
  require_once(ABSPATH . 'wp-admin/includes/media.php');
22
  require_once(ABSPATH . 'wp-admin/includes/file.php'); //wp_tempnam()
23
 
24
- require_once( ABSPATH . WPINC . '/class-oembed.php' );
25
 
26
  if (!function_exists('file_get_html')) {
 
27
  require_once (plugin_dir_path(__FILE__) . 'lib/simple_html_dom.php');
 
 
28
  }
29
 
30
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-filters.php");
21
  require_once(ABSPATH . 'wp-admin/includes/media.php');
22
  require_once(ABSPATH . 'wp-admin/includes/file.php'); //wp_tempnam()
23
 
24
+ require_once( ABSPATH . WPINC . '/class-wp-oembed.php' );
25
 
26
  if (!function_exists('file_get_html')) {
27
+ DebugEcho('Including Postie simple_html_dom');
28
  require_once (plugin_dir_path(__FILE__) . 'lib/simple_html_dom.php');
29
+ } else {
30
+ DebugEcho('non-Postie simple_html_dom already loaded');
31
  }
32
 
33
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-filters.php");
postie.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Create posts via email. Significantly upgrades the Post by Email features of WordPress.
7
- Version: 1.9.38
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL3
@@ -28,14 +28,14 @@
28
  */
29
 
30
  /*
31
- $Id: postie.php 2129475 2019-07-27 15:09:15Z WayneAllen $
32
  */
33
 
34
  if (!defined('WPINC')) {
35
  die; // Exit if accessed directly
36
  }
37
 
38
- define('POSTIE_VERSION', '1.9.38');
39
  define('POSTIE_ROOT', dirname(__FILE__));
40
  define('POSTIE_URL', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
41
 
@@ -62,6 +62,7 @@ if (!class_exists('PostieInit')) {
62
  add_filter("plugin_action_links_" . plugin_basename(__FILE__), array($this, 'plugin_action_links_filter'));
63
  add_filter('plugin_row_meta', array($this, 'plugin_row_meta_filter'), 10, 2);
64
  add_filter('enable_post_by_email_configuration', array($this, 'enable_post_by_email_configuration'));
 
65
 
66
  //WordPress Hooks
67
  register_activation_hook(__FILE__, array('PostieInit', 'postie_activate_hook'));
@@ -120,6 +121,57 @@ if (!class_exists('PostieInit')) {
120
  wp_clear_scheduled_hook('check_postie_hook');
121
  }
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  function plugins_loaded_action() {
124
  load_plugin_textdomain('postie', false, dirname(plugin_basename(__FILE__)) . '/languages/');
125
  }
@@ -133,7 +185,7 @@ if (!class_exists('PostieInit')) {
133
  }
134
 
135
  function plugin_row_meta_filter($links, $file) {
136
- if (strpos($file, plugin_basename(__FILE__)) !== false) {
137
  $new_links = array(
138
  '<a href="http://postieplugin.com/" target="_blank">Support</a>',
139
  '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HPK99BJ88V4C2" target="_blank">Donate</a>'
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Create posts via email. Significantly upgrades the Post by Email features of WordPress.
7
+ Version: 1.9.39
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL3
28
  */
29
 
30
  /*
31
+ $Id: postie.php 2191194 2019-11-13 05:05:01Z WayneAllen $
32
  */
33
 
34
  if (!defined('WPINC')) {
35
  die; // Exit if accessed directly
36
  }
37
 
38
+ define('POSTIE_VERSION', '1.9.39');
39
  define('POSTIE_ROOT', dirname(__FILE__));
40
  define('POSTIE_URL', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
41
 
62
  add_filter("plugin_action_links_" . plugin_basename(__FILE__), array($this, 'plugin_action_links_filter'));
63
  add_filter('plugin_row_meta', array($this, 'plugin_row_meta_filter'), 10, 2);
64
  add_filter('enable_post_by_email_configuration', array($this, 'enable_post_by_email_configuration'));
65
+ add_filter('site_status_tests', array($this, 'site_status_tests_filter'));
66
 
67
  //WordPress Hooks
68
  register_activation_hook(__FILE__, array('PostieInit', 'postie_activate_hook'));
121
  wp_clear_scheduled_hook('check_postie_hook');
122
  }
123
 
124
+ function site_status_tests_filter($tests) {
125
+ $tests['direct']['postie1'] = array(
126
+ 'label' => __('Postie Test'),
127
+ 'test' => array($this, 'test_delete_mail_after_processing'),
128
+ );
129
+ $tests['direct']['postie2'] = array(
130
+ 'label' => __('Postie Test'),
131
+ 'test' => array($this, 'test_turn_authorization_off'),
132
+ );
133
+ return $tests;
134
+ }
135
+
136
+ //https://make.wordpress.org/core/2019/04/25/site-health-check-in-5-2/
137
+ function test_delete_mail_after_processing() {
138
+ $config = postie_config_read();
139
+ $enabled = $config['delete_mail_after_processing'];
140
+ $result = array(
141
+ 'label' => __('Postie should delete emails after processing'),
142
+ 'status' => $enabled ? 'good' : 'recommended',
143
+ 'badge' => array(
144
+ 'label' => __('Performance'),
145
+ 'color' => 'blue',
146
+ ),
147
+ 'description' => sprintf('<p>%s</p>', __('If emails are not deleted they will be imported every time Postie runs.')
148
+ ),
149
+ 'actions' => '',
150
+ 'test' => 'postie_delete_mail_after_processing',
151
+ );
152
+
153
+ return $result;
154
+ }
155
+
156
+ function test_turn_authorization_off() {
157
+ $config = postie_config_read();
158
+ $enabled = !$config['turn_authorization_off'];
159
+ $result = array(
160
+ 'label' => __('Postie should only allow authorized users to post'),
161
+ 'status' => $enabled ? 'good' : 'critical',
162
+ 'badge' => array(
163
+ 'label' => __('Security'),
164
+ 'color' => 'blue',
165
+ ),
166
+ 'description' => sprintf('<p>%s</p>', __('Allowing anyone who knows your Postie email address to post can result in unwanted posts.')
167
+ ),
168
+ 'actions' => '',
169
+ 'test' => 'postie_turn_authorization_off',
170
+ );
171
+
172
+ return $result;
173
+ }
174
+
175
  function plugins_loaded_action() {
176
  load_plugin_textdomain('postie', false, dirname(plugin_basename(__FILE__)) . '/languages/');
177
  }
185
  }
186
 
187
  function plugin_row_meta_filter($links, $file) {
188
+ if (strpos($file, strval(plugin_basename(__FILE__))) !== false) {
189
  $new_links = array(
190
  '<a href="http://postieplugin.com/" target="_blank">Support</a>',
191
  '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HPK99BJ88V4C2" target="_blank">Donate</a>'
readme.txt CHANGED
@@ -6,8 +6,8 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
- Tested up to: 5.2
10
- Stable tag: 1.9.38
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -107,6 +107,12 @@ All script, style and body tags are stripped from html emails.
107
  Attachments are now processed in the order they were attached.
108
 
109
  == CHANGELOG ==
 
 
 
 
 
 
110
  = 1.9.38 (2019-07-27) =
111
  * Fix bug where filtering out an attachment prevented other attachments from being processed
112
 
6
  Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
+ Tested up to: 5.3
10
+ Stable tag: 1.9.39
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
107
  Attachments are now processed in the order they were attached.
108
 
109
  == CHANGELOG ==
110
+ = 1.9.39 (2019-11-12) =
111
+ * Add Site Health checks
112
+ * PHP 7.3 compatibility
113
+ * Fix bug where if Remove matched categories is No then the default category is always set.
114
+ * Address deprecated file class-oembed.php
115
+
116
  = 1.9.38 (2019-07-27) =
117
  * Fix bug where filtering out an attachment prevented other attachments from being processed
118