Postie - Version 1.8.9

Version Description

= 1.8.0 = The php-imap library has been replaced with logic based on Flourish fMailbox et al, there are some differences in the structure of the mail header array. This affects the postie_filter_email3 and postie_post_before filters. See http://flourishlib.com/docs/fMailbox

= 1.6.0 = Remote cron jobs need to update the URL used to kick off a manual email check. The new URL is http:///?postie=get-mail Accessing http:///wp-content/plugins/postie/get_mail.php will now receive a 403 error and a message stating what the new URL should be. The Postie menu is now at the main level rather than a Settings submenu.

= 1.5.14 = The postie_post filter has be deprecated in favor of postie_post_before.

= 1.5.3 = Postie can now set the first image in an email to be the "Featured" image. There is a new setting "Use First Image as Featured Image" which is off by default. Postie now supports Use Transport Layer Security (TLS)

= 1.5.0 = New filter postie_filter_email. Used to map "from" to any other email. Allows custom user mapping.

= 1.4.41 = Post format is now supported. You can specify any of the WordPress supported post formats using the Post type syntax. Post status can now be specified using the status: tag. Post status setting was renamed to Default Post Status and moved to the Message tab.

= 1.4.10 = All script, style and body tags are stripped from html emails.

= 1.4.6 = Attachments are now processed in the order they were attached.

Download this release

Release Info

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

Code changes from version 1.8.8 to 1.8.9

Files changed (5) hide show
  1. docs/Changes.txt +4 -0
  2. docs/Postie.txt +1 -1
  3. postie-functions.php +64 -51
  4. postie.php +3 -3
  5. readme.txt +5 -2
docs/Changes.txt CHANGED
@@ -32,6 +32,10 @@ All script, style and body tags are stripped from html emails.
32
  Attachments are now processed in the order they were attached.
33
 
34
  == CHANGELOG ==
 
 
 
 
35
  = 1.8.8 (2016-10-21) =
36
  * Fix bug where success/fail email notifications had missing info.
37
  * Fix bug where galley wan't being inserted on some plain text messages
32
  Attachments are now processed in the order they were attached.
33
 
34
  == CHANGELOG ==
35
+ = 1.8.8 (2016-10-23) =
36
+ * Fix bug when calling new postie_email_* filters
37
+ * Fix bug where inline and related attachments were not being considered for #img#
38
+
39
  = 1.8.8 (2016-10-21) =
40
  * Fix bug where success/fail email notifications had missing info.
41
  * Fix bug where galley wan't being inserted on some plain text messages
docs/Postie.txt CHANGED
@@ -6,7 +6,7 @@ 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.6.1
9
- Stable tag: 1.8.8
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.6.1
9
+ Stable tag: 1.8.9
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
postie-functions.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /*
3
- $Id: postie-functions.php 1519547 2016-10-21 21:16:58Z WayneAllen $
4
  */
5
 
6
  class PostiePostModifiers {
@@ -1751,7 +1751,7 @@ function postie_email_notify($email, $recipients, $postid) {
1751
  return;
1752
  }
1753
  $subject = "Successfully posted to $blogname";
1754
- $subject = apply_filter('postie_email_notify_subject', $subject, $email, $postid);
1755
 
1756
  $message = apply_filters('postie_email_notify_body', $message, $email, $postid);
1757
 
@@ -1802,16 +1802,16 @@ function postie_email_reject($email, $recipients, $returnToSender) {
1802
  $message .= "\n\nIf you would like to prevent postie from forwarding mail in the future, please change the FORWARD_REJECTED_MAIL setting in the Postie settings panel";
1803
  $message .= "\n\nThe original content of the email has been attached.\n\n";
1804
 
1805
- $recipients = apply_filter('postie_email_reject_recipients', $recipients, $email);
1806
  if (count($recipients) == 0) {
1807
  DebugEcho("postie_email_reject: no recipients after postie_email_reject_recipients filter");
1808
  return;
1809
  }
1810
 
1811
  $subject = $blogname . ": Unauthorized Post Attempt from $from";
1812
- $subject = apply_filter('postie_email_reject_subject', $subject, $email);
1813
 
1814
- $message = apply_filter('postie_email_reject_body', $message, $email);
1815
 
1816
  $attachTxt = wp_tempnam() . '.txt';
1817
  file_put_contents($attachTxt, $email['text']);
@@ -2079,60 +2079,73 @@ function filter_ReplaceImagePlaceHolders($content, &$email, $config, $post_id, $
2079
  $i = 0;
2080
 
2081
  foreach ($email['attachment'] as &$attachment) {
2082
- DebugEcho("filter_ReplaceImagePlaceHolders: " . $attachment['filename']);
2083
-
2084
- if (empty($attachment['template'])) {
2085
- DebugEcho("filter_ReplaceImagePlaceHolders: no template");
2086
- continue;
2087
- }
2088
- $imageTemplate = $attachment['template'];
 
 
 
 
 
 
 
 
 
 
2089
 
2090
- // looks for ' #img1# ' etc... and replaces with image
2091
- $img_placeholder_temp0 = rtrim(str_replace("%", intval($startIndex + $i), $image_pattern), '#');
2092
 
2093
- DebugEcho("filter_ReplaceImagePlaceHolders: img_placeholder_temp0: $img_placeholder_temp0");
2094
- if (stristr($content, $img_placeholder_temp0)) {
2095
- $attachment['exclude'] = true;
2096
- while (stristr($content, $img_placeholder_temp0)) {
2097
- // look for caption
2098
- DebugEcho("filter_ReplaceImagePlaceHolders: Found $img_placeholder_temp0");
2099
- $caption = '';
2100
- $img_placeholder_temp = $img_placeholder_temp0;
2101
- $matches = array();
2102
- if (preg_match("/$img_placeholder_temp caption=(.*?)#/i", $content, $matches)) {
2103
- //DebugDump($matches);
2104
- $caption = trim($matches[1]);
2105
- if (strlen($caption) > 2 && ($caption[0] == "'" || $caption[0] == '"')) {
2106
- $caption = substr($caption, 1, strlen($caption) - 2);
2107
- }
2108
- DebugEcho("filter_ReplaceImagePlaceHolders: caption: $caption");
2109
-
2110
- if (count($images) > $i) {
2111
- DebugEcho("filter_ReplaceImagePlaceHolders: Adding alt text to image {$images[$i]->ID}");
2112
- update_post_meta($images[$i]->ID, '_wp_attachment_image_alt', $caption);
2113
- }
2114
-
2115
- $img_placeholder_temp = substr($matches[0], 0, -1);
2116
- DebugEcho("filter_ReplaceImagePlaceHolders: $img_placeholder_temp");
2117
- } else {
2118
- DebugEcho("filter_ReplaceImagePlaceHolders: No caption found");
2119
- }
2120
- DebugEcho("filter_ReplaceImagePlaceHolders: parameterize templete: " . $imageTemplate);
2121
- $imageTemplate = mb_str_replace('{CAPTION}', htmlspecialchars($caption, ENT_QUOTES), $imageTemplate);
2122
- DebugEcho("filter_ReplaceImagePlaceHolders: captioned template: " . $imageTemplate);
2123
 
2124
- $img_placeholder_temp .= '#';
 
2125
 
2126
- $content = str_ireplace($img_placeholder_temp, $imageTemplate, $content);
2127
- DebugEcho("filter_ReplaceImagePlaceHolders: post replace: $content");
 
 
 
 
 
 
 
 
 
 
 
 
2128
  }
 
 
 
 
 
 
 
 
 
 
 
2129
  }
2130
- $i++;
 
 
 
 
 
 
 
2131
  }
2132
- } else {
2133
- DebugEcho("filter_ReplaceImagePlaceHolders: Custom image field, not adding images");
2134
  }
2135
- DebugEcho("filter_ReplaceImagePlaceHolders: end");
2136
  return $content;
2137
  }
2138
 
1
  <?php
2
  /*
3
+ $Id: postie-functions.php 1520721 2016-10-24 03:07:59Z WayneAllen $
4
  */
5
 
6
  class PostiePostModifiers {
1751
  return;
1752
  }
1753
  $subject = "Successfully posted to $blogname";
1754
+ $subject = apply_filters('postie_email_notify_subject', $subject, $email, $postid);
1755
 
1756
  $message = apply_filters('postie_email_notify_body', $message, $email, $postid);
1757
 
1802
  $message .= "\n\nIf you would like to prevent postie from forwarding mail in the future, please change the FORWARD_REJECTED_MAIL setting in the Postie settings panel";
1803
  $message .= "\n\nThe original content of the email has been attached.\n\n";
1804
 
1805
+ $recipients = apply_filters('postie_email_reject_recipients', $recipients, $email);
1806
  if (count($recipients) == 0) {
1807
  DebugEcho("postie_email_reject: no recipients after postie_email_reject_recipients filter");
1808
  return;
1809
  }
1810
 
1811
  $subject = $blogname . ": Unauthorized Post Attempt from $from";
1812
+ $subject = apply_filters('postie_email_reject_subject', $subject, $email);
1813
 
1814
+ $message = apply_filters('postie_email_reject_body', $message, $email);
1815
 
1816
  $attachTxt = wp_tempnam() . '.txt';
1817
  file_put_contents($attachTxt, $email['text']);
2079
  $i = 0;
2080
 
2081
  foreach ($email['attachment'] as &$attachment) {
2082
+ $content = filter_ReplaceImagePlaceHolders_worker($content, $attachment, $image_pattern, $startIndex, $i);
2083
+ $i++;
2084
+ }
2085
+ foreach ($email['inline'] as &$attachment) {
2086
+ $content = filter_ReplaceImagePlaceHolders_worker($content, $attachment, $image_pattern, $startIndex, $i);
2087
+ $i++;
2088
+ }
2089
+ foreach ($email['related'] as &$attachment) {
2090
+ $content = filter_ReplaceImagePlaceHolders_worker($content, $attachment, $image_pattern, $startIndex, $i);
2091
+ $i++;
2092
+ }
2093
+ } else {
2094
+ DebugEcho("filter_ReplaceImagePlaceHolders: Custom image field, not adding images");
2095
+ }
2096
+ DebugEcho("filter_ReplaceImagePlaceHolders: end");
2097
+ return $content;
2098
+ }
2099
 
2100
+ function filter_ReplaceImagePlaceHolders_worker($content, &$attachment, $imagePattern, $startIndex, $currentIndex) {
2101
+ DebugEcho("filter_ReplaceImagePlaceHolders_worker: " . $attachment['filename']);
2102
 
2103
+ if (empty($attachment['template'])) {
2104
+ DebugEcho("filter_ReplaceImagePlaceHolders_worker: no template");
2105
+ return;
2106
+ }
2107
+ $imageTemplate = $attachment['template'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2108
 
2109
+ // looks for ' #img1# ' etc... and replaces with image
2110
+ $img_placeholder_temp0 = rtrim(str_replace("%", intval($startIndex + $currentIndex), $imagePattern), '#');
2111
 
2112
+ DebugEcho("filter_ReplaceImagePlaceHolders_worker: img_placeholder_temp0: $img_placeholder_temp0");
2113
+ if (stristr($content, $img_placeholder_temp0)) {
2114
+ $attachment['exclude'] = true;
2115
+ while (stristr($content, $img_placeholder_temp0)) {
2116
+ // look for caption
2117
+ DebugEcho("filter_ReplaceImagePlaceHolders_worker: Found $img_placeholder_temp0");
2118
+ $caption = '';
2119
+ $img_placeholder_temp = $img_placeholder_temp0;
2120
+ $matches = array();
2121
+ if (preg_match("/$img_placeholder_temp caption=(.*?)#/i", $content, $matches)) {
2122
+ //DebugDump($matches);
2123
+ $caption = trim($matches[1]);
2124
+ if (strlen($caption) > 2 && ($caption[0] == "'" || $caption[0] == '"')) {
2125
+ $caption = substr($caption, 1, strlen($caption) - 2);
2126
  }
2127
+ DebugEcho("filter_ReplaceImagePlaceHolders_worker: caption: $caption");
2128
+
2129
+ // if (count($images) > $i) {
2130
+ // DebugEcho("filter_ReplaceImagePlaceHolders_worker: Adding alt text to image {$images[$i]->ID}");
2131
+ // update_post_meta($images[$i]->ID, '_wp_attachment_image_alt', $caption);
2132
+ // }
2133
+
2134
+ $img_placeholder_temp = substr($matches[0], 0, -1);
2135
+ DebugEcho("filter_ReplaceImagePlaceHolders_worker: $img_placeholder_temp");
2136
+ } else {
2137
+ DebugEcho("filter_ReplaceImagePlaceHolders_worker: No caption found");
2138
  }
2139
+ DebugEcho("filter_ReplaceImagePlaceHolders_worker: parameterize templete: " . $imageTemplate);
2140
+ $imageTemplate = mb_str_replace('{CAPTION}', htmlspecialchars($caption, ENT_QUOTES), $imageTemplate);
2141
+ DebugEcho("filter_ReplaceImagePlaceHolders_worker: captioned template: " . $imageTemplate);
2142
+
2143
+ $img_placeholder_temp .= '#';
2144
+
2145
+ $content = str_ireplace($img_placeholder_temp, $imageTemplate, $content);
2146
+ DebugEcho("filter_ReplaceImagePlaceHolders_worker: post replace: $content");
2147
  }
 
 
2148
  }
 
2149
  return $content;
2150
  }
2151
 
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.8.8
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL2
@@ -28,7 +28,7 @@
28
  */
29
 
30
  /*
31
- $Id: postie.php 1519553 2016-10-21 21:38:29Z WayneAllen $
32
  */
33
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/fException.php");
34
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/fUnexpectedException.php");
@@ -49,7 +49,7 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/pPop3MailServer.php"
49
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib_autolink.php");
50
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
51
 
52
- define('POSTIE_VERSION', '1.8.8');
53
  define("POSTIE_ROOT", dirname(__FILE__));
54
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
55
 
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.8.9
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL2
28
  */
29
 
30
  /*
31
+ $Id: postie.php 1520725 2016-10-24 03:11:10Z WayneAllen $
32
  */
33
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/fException.php");
34
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/fUnexpectedException.php");
49
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib_autolink.php");
50
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
51
 
52
+ define('POSTIE_VERSION', '1.8.9');
53
  define("POSTIE_ROOT", dirname(__FILE__));
54
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
55
 
readme.txt CHANGED
@@ -6,7 +6,7 @@ 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.6.1
9
- Stable tag: 1.8.8
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -240,6 +240,10 @@ All script, style and body tags are stripped from html emails.
240
  Attachments are now processed in the order they were attached.
241
 
242
  == CHANGELOG ==
 
 
 
 
243
  = 1.8.8 (2016-10-21) =
244
  * Fix bug where success/fail email notifications had missing info.
245
  * Fix bug where galley wan't being inserted on some plain text messages
@@ -1383,4 +1387,3 @@ plugin. And the rest is history :)
1383
  *
1384
  = 0.1 - 2004-06 =
1385
  * First release
1386
-
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.6.1
9
+ Stable tag: 1.8.9
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
240
  Attachments are now processed in the order they were attached.
241
 
242
  == CHANGELOG ==
243
+ = 1.8.8 (2016-10-23) =
244
+ * Fix bug when calling new postie_email_* filters
245
+ * Fix bug where inline and related attachments were not being considered for #img#
246
+
247
  = 1.8.8 (2016-10-21) =
248
  * Fix bug where success/fail email notifications had missing info.
249
  * Fix bug where galley wan't being inserted on some plain text messages
1387
  *
1388
  = 0.1 - 2004-06 =
1389
  * First release