Postie - Version 1.7.28

Version Description

(2016-02-09) = * better tag detection with html * Don't skip image processing when Include Featured Image in Post is set to "No" and the Preferred Text Type is HTML. * Use the blog name as the "from" text in any emails. * New filter: postie_filter_email3 * Email headers now available in postie_post_before filter * When looking for a parent post to add comments ensure the comments are open

Download this release

Release Info

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

Code changes from version 1.7.27 to 1.7.28

Files changed (7) hide show
  1. docs/Changes.txt +10 -1
  2. docs/Postie.txt +2 -2
  3. docs/TODO.txt +9 -5
  4. lib_autolink.php +19 -17
  5. postie-functions.php +17 -7
  6. postie.php +3 -3
  7. readme.txt +13 -3
docs/Changes.txt CHANGED
@@ -27,11 +27,20 @@ All script, style and body tags are stripped from html emails.
27
  Attachments are now processed in the order they were attached.
28
 
29
  == CHANGELOG ==
 
 
 
 
 
 
 
 
30
  = 1.7.27 (2015-12-28) =
31
  * Fix category match settings not saving
32
 
33
  = 1.7.26 (2015-12-28) =
34
  * Detect oEmbedable links and don't linkify
 
35
 
36
  = 1.7.25 (2015-12-15) =
37
  * Fix settings page for new category matching flavors
@@ -1093,4 +1102,4 @@ plugin. And the rest is history :)
1093
  * Cleaned up some pear stuff in install
1094
  *
1095
  = 0.1 - 2004-06 =
1096
- * First release
27
  Attachments are now processed in the order they were attached.
28
 
29
  == CHANGELOG ==
30
+ = 1.7.28 (2016-02-09) =
31
+ * better tag detection with html
32
+ * Don't skip image processing when Include Featured Image in Post is set to "No" and the Preferred Text Type is HTML.
33
+ * Use the blog name as the "from" text in any emails.
34
+ * New filter: postie_filter_email3
35
+ * Email headers now available in postie_post_before filter
36
+ * When looking for a parent post to add comments ensure the comments are open
37
+
38
  = 1.7.27 (2015-12-28) =
39
  * Fix category match settings not saving
40
 
41
  = 1.7.26 (2015-12-28) =
42
  * Detect oEmbedable links and don't linkify
43
+ * New filter postie_preconnect. http://postieplugin.com/filter-postie_preconnect/
44
 
45
  = 1.7.25 (2015-12-15) =
46
  * Fix settings page for new category matching flavors
1102
  * Cleaned up some pear stuff in install
1103
  *
1104
  = 0.1 - 2004-06 =
1105
+ * First release
docs/Postie.txt CHANGED
@@ -1,12 +1,12 @@
1
  === Postie ===
2
- Contributors: WayneAllen
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HPK99BJ88V4C2
4
  Author URI: http://allens-home.com/
5
  Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.4.1
9
- Stable tag: 1.7.27
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
1
  === Postie ===
2
+ Contributors: WayneAllen, wooranker
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HPK99BJ88V4C2
4
  Author URI: http://allens-home.com/
5
  Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.4.1
9
+ Stable tag: 1.7.28
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
docs/TODO.txt CHANGED
@@ -1,9 +1,17 @@
 
 
 
 
 
 
 
 
 
1
  For IMAP mailboxes allow the user to choose the folder.
2
  Preferred text type: just html, just plain, html fallback to plain
3
  Check to see if post already exists. Store hash in custom field.
4
  Change successful post message to take post status into account (i.e. draft really isn't posted - possible link to publish draft?)
5
  Verify that WP is honoring the wp_set_current_user() call. I.e. if the user is not an "author" role can they publish?
6
- Test server port combination by opening a socket connection to see if any service responds. (via ajax call)
7
  Option to not process forwarded emails (getPostAuthorDetails)
8
  Add Message-ID header value to custom field (postie_message_id?) to both posts and comments.
9
  Use In-Reply-To header value as a better way to detect replies
@@ -12,14 +20,11 @@ Automatic updates for AddOns:
12
  https://github.com/seedprod/sellwp-updater
13
  http://code.tutsplus.com/series/create-a-license-controlled-theme-and-plugin-update-system--cms-760
14
  automatically create category if it doesn't exist. new option to allow this feature?
15
- Add setting to not remove category text from subject/title
16
  Comment not being created when subject contains category command []. I.e. listserv subject lines
17
  date: tag is being detected in body when not wanted
18
  Update tag_* and filter_* to handle HTML (per tag_Tags)
19
  dynamically determine video size (height/width) - https://code.google.com/p/phpvideotoolkit/
20
- gallery logic does not handle both images and non-images
21
  plugin conflict - Image Rotation Fixer/Image Rotation Repair
22
- send email notice when attachments are rejected.
23
  readme tips http://wp.smashingmagazine.com/2011/11/23/improve-wordpress-plugins-readme-txt/
24
  review http://codex.wordpress.org/Settings_API
25
  use wordpress plugin template
@@ -27,7 +32,6 @@ use wordpress plugin template
27
  starter-plugin https://github.com/mattyza/starter-plugin
28
  WordPress-Plugin-Template https://github.com/hlashbrooke/WordPress-Plugin-Template
29
  configurable message for "post confirmation" - variable substitution
30
- allow other roles access to manual check like "Roles That Can Post"
31
 
32
  Hooks
33
  add hooks for post meta data change
1
+ AddOn Ideas
2
+ CSS Inliner - use one of the online services to convert class styled html to inline styles. https://www.google.com/search?q=css+inline+tool&oq=css+inline+tool
3
+
4
+ Other
5
+ allow other roles access to manual check like "Roles That Can Post"
6
+ Add setting to not remove category text from subject/title
7
+ Test server port combination by opening a socket connection to see if any service responds. (via ajax call)
8
+ gallery logic does not handle both images and non-images
9
+ send email notice when attachments are rejected.
10
  For IMAP mailboxes allow the user to choose the folder.
11
  Preferred text type: just html, just plain, html fallback to plain
12
  Check to see if post already exists. Store hash in custom field.
13
  Change successful post message to take post status into account (i.e. draft really isn't posted - possible link to publish draft?)
14
  Verify that WP is honoring the wp_set_current_user() call. I.e. if the user is not an "author" role can they publish?
 
15
  Option to not process forwarded emails (getPostAuthorDetails)
16
  Add Message-ID header value to custom field (postie_message_id?) to both posts and comments.
17
  Use In-Reply-To header value as a better way to detect replies
20
  https://github.com/seedprod/sellwp-updater
21
  http://code.tutsplus.com/series/create-a-license-controlled-theme-and-plugin-update-system--cms-760
22
  automatically create category if it doesn't exist. new option to allow this feature?
 
23
  Comment not being created when subject contains category command []. I.e. listserv subject lines
24
  date: tag is being detected in body when not wanted
25
  Update tag_* and filter_* to handle HTML (per tag_Tags)
26
  dynamically determine video size (height/width) - https://code.google.com/p/phpvideotoolkit/
 
27
  plugin conflict - Image Rotation Fixer/Image Rotation Repair
 
28
  readme tips http://wp.smashingmagazine.com/2011/11/23/improve-wordpress-plugins-readme-txt/
29
  review http://codex.wordpress.org/Settings_API
30
  use wordpress plugin template
32
  starter-plugin https://github.com/mattyza/starter-plugin
33
  WordPress-Plugin-Template https://github.com/hlashbrooke/WordPress-Plugin-Template
34
  configurable message for "post confirmation" - variable substitution
 
35
 
36
  Hooks
37
  add hooks for post meta data change
lib_autolink.php CHANGED
@@ -245,40 +245,42 @@ class PostieAutolink {
245
  $fail_text = $pre . $hit;
246
  $fail_len = strlen($fail_text);
247
 
248
- DebugEcho("autolink_email: Pre: $pre");
249
- DebugEcho("autolink_email: Hit: $hit");
250
- DebugEcho("autolink_email: Post: $post");
251
- DebugEcho("autolink_email: Fail: $fail_text");
252
  #
253
  # substring found - first check to see if we're inside a link tag already...
254
  #
255
 
256
  $bits = preg_split("!</a>!i", $pre);
257
  $last_bit = array_pop($bits);
258
- DebugEcho("autolink_email: link? $last_bit");
259
 
260
  if (preg_match("!<a\s!i", $last_bit)) {
261
 
262
- DebugEcho("autolink_email: link fail 1 at $cursor");
263
 
264
  $ok = 0;
265
  $cursor += $fail_len;
266
  $buffer .= $fail_text;
267
  }
268
 
269
- #
270
- # check to see if we're inside a shortcode
271
- #
272
- $bits = preg_split("!\]!i", $pre);
273
- $last_bit = array_pop($bits);
274
- DebugEcho("autolink_email: shortcode? $last_bit");
275
- if (preg_match("!\[!i", $last_bit)) {
 
276
 
277
- DebugEcho("autolink_email: shortcode fail 1 at $cursor");
278
 
279
- $ok = 0;
280
- $cursor += $fail_len;
281
- $buffer .= $fail_text;
 
282
  }
283
  }
284
 
245
  $fail_text = $pre . $hit;
246
  $fail_len = strlen($fail_text);
247
 
248
+ DebugEcho("autolink_email: \$pre: $pre");
249
+ DebugEcho("autolink_email: \$hit: $hit");
250
+ DebugEcho("autolink_email: \$post: $post");
251
+ DebugEcho("autolink_email: \$fail_text: $fail_text");
252
  #
253
  # substring found - first check to see if we're inside a link tag already...
254
  #
255
 
256
  $bits = preg_split("!</a>!i", $pre);
257
  $last_bit = array_pop($bits);
258
+ DebugEcho("autolink_email: check this for '<a' $last_bit");
259
 
260
  if (preg_match("!<a\s!i", $last_bit)) {
261
 
262
+ DebugEcho("autolink_email: found '<a' so not linkifying (already a link)");
263
 
264
  $ok = 0;
265
  $cursor += $fail_len;
266
  $buffer .= $fail_text;
267
  }
268
 
269
+ if ($ok) {
270
+ #
271
+ # check to see if we're inside a shortcode
272
+ #
273
+ $bits = preg_split("!\]!i", $pre);
274
+ $last_bit = array_pop($bits);
275
+ DebugEcho("autolink_email: check this for '[' $last_bit");
276
+ if (preg_match("!\[!i", $last_bit)) {
277
 
278
+ DebugEcho("autolink_email: found '[' so not linkifying (in a shortcode)");
279
 
280
+ $ok = 0;
281
+ $cursor += $fail_len;
282
+ $buffer .= $fail_text;
283
+ }
284
  }
285
  }
286
 
postie-functions.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /*
3
- $Id: postie-functions.php 1317583 2015-12-28 22:03:06Z WayneAllen $
4
  */
5
 
6
  class PostiePostModifiers {
@@ -438,7 +438,7 @@ function PostEmail($poster, $mimeDecodedEmail, $config) {
438
  $details = CreatePost($poster, $mimeDecodedEmail, $post_id, $is_reply, $config, $postmodifiers);
439
 
440
  $details = apply_filters('postie_post', $details);
441
- $details = apply_filters('postie_post_before', $details);
442
 
443
  DebugEcho(("Post postie_post filter"));
444
  DebugDump($details);
@@ -634,7 +634,7 @@ function GetParentPostForReply(&$subject) {
634
  $tmpSubject = trim($tmpSubject_matches[1]);
635
  }
636
  DebugEcho("GetParentPostForReply: tmpSubject: $tmpSubject");
637
- $checkExistingPostQuery = "SELECT ID FROM $wpdb->posts WHERE post_title LIKE %s AND post_status = 'publish'";
638
  if ($id = $wpdb->get_var($wpdb->prepare($checkExistingPostQuery, $tmpSubject))) {
639
  if (!empty($id)) {
640
  DebugEcho("GetParentPostForReply: id: $id");
@@ -935,6 +935,8 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
935
  } elseif (property_exists($part, 'd_parameters') && is_array($part->d_parameters) && array_key_exists('filename', $part->d_parameters)) {
936
  $filename = $part->d_parameters['filename'];
937
  }
 
 
938
  $filename = sanitize_file_name($filename);
939
  $fileext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
940
 
@@ -1076,7 +1078,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
1076
  set_post_thumbnail($post_id, $file_id);
1077
 
1078
  //optionally skip adding the featured imagea to the post
1079
- $addimage = $config['include_featured_image'];
1080
  }
1081
 
1082
  if ($addimage) {
@@ -1093,6 +1095,8 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
1093
  $attachments["cids"][$cid] = array($file, count($attachments["html"]) - 1);
1094
  DebugEcho("GetContent: CID Attachement: $cid");
1095
  }
 
 
1096
  }
1097
  } else {
1098
  EchoError("image error: " . $file_id->get_error_message());
@@ -1318,6 +1322,11 @@ function ValidatePoster(&$mimeDecodedEmail, $config) {
1318
  DebugDump($mimeDecodedEmail->headers);
1319
  }
1320
 
 
 
 
 
 
1321
  $resentFrom = "";
1322
  if (property_exists($mimeDecodedEmail, "headers") && array_key_exists('resent-from', $mimeDecodedEmail->headers)) {
1323
  $resentFrom = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["resent-from"]));
@@ -2035,6 +2044,7 @@ function MailToRecipients(&$mail_content, $recipients = array(), $returnToSender
2035
 
2036
  $myemailadd = get_option("admin_email");
2037
  $blogname = get_option("blogname");
 
2038
  $posturl = '';
2039
  if ($postid != null) {
2040
  $posturl = get_permalink($postid);
@@ -2054,7 +2064,7 @@ function MailToRecipients(&$mail_content, $recipients = array(), $returnToSender
2054
  array_push($recipients, $from);
2055
  }
2056
 
2057
- $headers = "From: Wordpress <" . $myemailadd . ">\r\n";
2058
  foreach ($recipients as $recipient) {
2059
  $recipient = trim($recipient);
2060
  if (!empty($recipient)) {
@@ -2540,9 +2550,9 @@ function tag_Tags(&$content, $defaultTags, $isHtml) {
2540
  $post_tags = array();
2541
 
2542
  $matches = array();
2543
- $rx = '/[>|\a]?tags:\s?(.*?)[<|\z]/im';
2544
  if (!$isHtml) {
2545
- $rx = '/tags:\s?(.*)/im';
2546
  }
2547
  if (preg_match($rx, $content, $matches)) {
2548
  if (!empty($matches[1])) {
1
  <?php
2
  /*
3
+ $Id: postie-functions.php 1346872 2016-02-09 17:05:09Z WayneAllen $
4
  */
5
 
6
  class PostiePostModifiers {
438
  $details = CreatePost($poster, $mimeDecodedEmail, $post_id, $is_reply, $config, $postmodifiers);
439
 
440
  $details = apply_filters('postie_post', $details);
441
+ $details = apply_filters('postie_post_before', $details, $mimeDecodedEmail->headers);
442
 
443
  DebugEcho(("Post postie_post filter"));
444
  DebugDump($details);
634
  $tmpSubject = trim($tmpSubject_matches[1]);
635
  }
636
  DebugEcho("GetParentPostForReply: tmpSubject: $tmpSubject");
637
+ $checkExistingPostQuery = "SELECT ID FROM $wpdb->posts WHERE post_title LIKE %s AND post_status = 'publish' AND comment_status = 'open'";
638
  if ($id = $wpdb->get_var($wpdb->prepare($checkExistingPostQuery, $tmpSubject))) {
639
  if (!empty($id)) {
640
  DebugEcho("GetParentPostForReply: id: $id");
935
  } elseif (property_exists($part, 'd_parameters') && is_array($part->d_parameters) && array_key_exists('filename', $part->d_parameters)) {
936
  $filename = $part->d_parameters['filename'];
937
  }
938
+ DebugEcho("GetContent: pre sanitize file name '$filename'");
939
+ //DebugDump($part);
940
  $filename = sanitize_file_name($filename);
941
  $fileext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
942
 
1078
  set_post_thumbnail($post_id, $file_id);
1079
 
1080
  //optionally skip adding the featured imagea to the post
1081
+ $addimage = $config['include_featured_image'] || $config['prefer_text_type'] == 'html';
1082
  }
1083
 
1084
  if ($addimage) {
1095
  $attachments["cids"][$cid] = array($file, count($attachments["html"]) - 1);
1096
  DebugEcho("GetContent: CID Attachement: $cid");
1097
  }
1098
+ } else {
1099
+ DebugEcho("Skipping image $filename as it is the featured image");
1100
  }
1101
  } else {
1102
  EchoError("image error: " . $file_id->get_error_message());
1322
  DebugDump($mimeDecodedEmail->headers);
1323
  }
1324
 
1325
+ if (property_exists($mimeDecodedEmail, "headers")) {
1326
+ $from = apply_filters("postie_filter_email3", $from, $mimeDecodedEmail->headers);
1327
+ DebugEcho("ValidatePoster: post postie_filter_email3 $from");
1328
+ }
1329
+
1330
  $resentFrom = "";
1331
  if (property_exists($mimeDecodedEmail, "headers") && array_key_exists('resent-from', $mimeDecodedEmail->headers)) {
1332
  $resentFrom = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["resent-from"]));
2044
 
2045
  $myemailadd = get_option("admin_email");
2046
  $blogname = get_option("blogname");
2047
+ $eblogname = "=?utf-8?b?" . base64_encode($blogname) . "?= ";
2048
  $posturl = '';
2049
  if ($postid != null) {
2050
  $posturl = get_permalink($postid);
2064
  array_push($recipients, $from);
2065
  }
2066
 
2067
+ $headers = "From: $eblogname <$myemailadd>\r\n";
2068
  foreach ($recipients as $recipient) {
2069
  $recipient = trim($recipient);
2070
  if (!empty($recipient)) {
2550
  $post_tags = array();
2551
 
2552
  $matches = array();
2553
+ $rx = '/>\s*tags:\s?(.*?)</is';
2554
  if (!$isHtml) {
2555
+ $rx = '/tags:\s?(.*)/i';
2556
  }
2557
  if (preg_match($rx, $content, $matches)) {
2558
  if (!empty($matches[1])) {
postie.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Create posts via email. Signifigantly upgrades the Post by Email features of Word Press.
7
- Version: 1.7.27
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL2
@@ -28,12 +28,12 @@
28
  */
29
 
30
  /*
31
- $Id: postie.php 1323574 2016-01-07 22:46:17Z WayneAllen $
32
  */
33
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib_autolink.php");
34
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
35
 
36
- define('POSTIE_VERSION', '1.7.27');
37
  define("POSTIE_ROOT", dirname(__FILE__));
38
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
39
 
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Create posts via email. Signifigantly upgrades the Post by Email features of Word Press.
7
+ Version: 1.7.28
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL2
28
  */
29
 
30
  /*
31
+ $Id: postie.php 1346907 2016-02-09 18:02:38Z WayneAllen $
32
  */
33
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib_autolink.php");
34
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
35
 
36
+ define('POSTIE_VERSION', '1.7.28');
37
  define("POSTIE_ROOT", dirname(__FILE__));
38
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
39
 
readme.txt CHANGED
@@ -1,12 +1,12 @@
1
  === Postie ===
2
- Contributors: WayneAllen
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HPK99BJ88V4C2
4
  Author URI: http://allens-home.com/
5
  Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.4.1
9
- Stable tag: 1.7.27
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -235,11 +235,20 @@ All script, style and body tags are stripped from html emails.
235
  Attachments are now processed in the order they were attached.
236
 
237
  == CHANGELOG ==
 
 
 
 
 
 
 
 
238
  = 1.7.27 (2015-12-28) =
239
  * Fix category match settings not saving
240
 
241
  = 1.7.26 (2015-12-28) =
242
  * Detect oEmbedable links and don't linkify
 
243
 
244
  = 1.7.25 (2015-12-15) =
245
  * Fix settings page for new category matching flavors
@@ -1301,4 +1310,5 @@ plugin. And the rest is history :)
1301
  * Cleaned up some pear stuff in install
1302
  *
1303
  = 0.1 - 2004-06 =
1304
- * First release
 
1
  === Postie ===
2
+ Contributors: WayneAllen, wooranker
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HPK99BJ88V4C2
4
  Author URI: http://allens-home.com/
5
  Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.4.1
9
+ Stable tag: 1.7.28
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
235
  Attachments are now processed in the order they were attached.
236
 
237
  == CHANGELOG ==
238
+ = 1.7.28 (2016-02-09) =
239
+ * better tag detection with html
240
+ * Don't skip image processing when Include Featured Image in Post is set to "No" and the Preferred Text Type is HTML.
241
+ * Use the blog name as the "from" text in any emails.
242
+ * New filter: postie_filter_email3
243
+ * Email headers now available in postie_post_before filter
244
+ * When looking for a parent post to add comments ensure the comments are open
245
+
246
  = 1.7.27 (2015-12-28) =
247
  * Fix category match settings not saving
248
 
249
  = 1.7.26 (2015-12-28) =
250
  * Detect oEmbedable links and don't linkify
251
+ * New filter postie_preconnect. http://postieplugin.com/filter-postie_preconnect/
252
 
253
  = 1.7.25 (2015-12-15) =
254
  * Fix settings page for new category matching flavors
1310
  * Cleaned up some pear stuff in install
1311
  *
1312
  = 0.1 - 2004-06 =
1313
+ * First release
1314
+