Postie - Version 1.6.12

Version Description

(2015-02-09) = * Fix confirmation emails that were always sending to administrator. * Fix regression in 1.6.11 which prevented attachments from being displayed in some cases.

Download this release

Release Info

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

Code changes from version 1.6.11 to 1.6.12

Files changed (6) hide show
  1. docs/Changes.txt +4 -0
  2. docs/Postie.txt +1 -1
  3. docs/TODO.txt +3 -1
  4. postie-functions.php +50 -35
  5. postie.php +3 -3
  6. readme.txt +5 -1
docs/Changes.txt CHANGED
@@ -27,6 +27,10 @@ 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.6.11 (2015-01-30) =
31
  * Call wp_set_current_user() so that other WP functions that depend on the current user work correctly. (custom taxonomy)
32
  * Only do image template processing if the preferred text type is plain
27
  Attachments are now processed in the order they were attached.
28
 
29
  == CHANGELOG ==
30
+ = 1.6.12 (2015-02-09) =
31
+ * Fix confirmation emails that were always sending to administrator.
32
+ * Fix regression in 1.6.11 which prevented attachments from being displayed in some cases.
33
+
34
  = 1.6.11 (2015-01-30) =
35
  * Call wp_set_current_user() so that other WP functions that depend on the current user work correctly. (custom taxonomy)
36
  * Only do image template processing if the preferred text type is plain
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.0
8
  Tested up to: 4.1
9
- Stable tag: 1.6.11
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.0
8
  Tested up to: 4.1
9
+ Stable tag: 1.6.12
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
docs/TODO.txt CHANGED
@@ -2,7 +2,9 @@ Separate out video linkifying from normal url linkifying - separate settings
2
  Add Message-ID header value to custom field (postie_message_id?) to both posts and comments.
3
  Use In-Reply-To header value as a better way to detect replies
4
  Verify that {TITLE} is doing the right thing.
5
- Automatic updates for AddOns: https://github.com/seedprod/sellwp-updater
 
 
6
  automatically create category if it doesn't exist. new option to allow this feature?
7
  Add setting for category detection. I.e. checkboxes for [], -- and : styles. Default to all on.
8
  Add setting to not remove category text from subject/title
2
  Add Message-ID header value to custom field (postie_message_id?) to both posts and comments.
3
  Use In-Reply-To header value as a better way to detect replies
4
  Verify that {TITLE} is doing the right thing.
5
+ Automatic updates for AddOns:
6
+ https://github.com/seedprod/sellwp-updater
7
+ http://code.tutsplus.com/series/create-a-license-controlled-theme-and-plugin-update-system--cms-760
8
  automatically create category if it doesn't exist. new option to allow this feature?
9
  Add setting for category detection. I.e. checkboxes for [], -- and : styles. Default to all on.
10
  Add setting to not remove category text from subject/title
postie-functions.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /*
3
- $Id: postie-functions.php 1068958 2015-01-16 00:34:02Z WayneAllen $
4
  */
5
 
6
  //to turn on debug output add the following line to wp-config.php
@@ -230,7 +230,8 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $
230
 
231
  $content = GetContent($mimeDecodedEmail, $attachments, $post_id, $poster, $config);
232
  if ($fulldebug) {
233
- DebugEcho("the content is $content");
 
234
  }
235
 
236
  $subject = GetSubject($mimeDecodedEmail, $content, $config);
@@ -385,20 +386,20 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $
385
  DebugEcho("post end: $content");
386
  }
387
 
388
- if ($config['prefer_text_type'] == 'plain') {
389
- filter_ReplaceImagePlaceHolders($content, $attachments["html"], $config, $id, $config['image_placeholder'], true);
390
- if ($fulldebug) {
391
- DebugEcho("post body ReplaceImagePlaceHolders: $content");
392
- }
393
 
394
- if ($post_excerpt) {
395
- filter_ReplaceImagePlaceHolders($post_excerpt, $attachments["html"], $config, $id, "#eimg%#", false);
396
- DebugEcho("excerpt: $post_excerpt");
397
- if ($fulldebug) {
398
- DebugEcho("post excerpt ReplaceImagePlaceHolders: $content");
399
- }
400
  }
401
  }
 
402
 
403
  if (trim($subject) == "") {
404
  $subject = $config['default_title'];
@@ -2115,6 +2116,8 @@ function MailToRecipients(&$mail_content, $testEmail = false, $recipients = arra
2115
  return false;
2116
  }
2117
 
 
 
2118
  $from = trim($mail_content->headers["from"]);
2119
  $subject = $mail_content->headers['subject'];
2120
  if ($returnToSender) {
@@ -2129,7 +2132,10 @@ function MailToRecipients(&$mail_content, $testEmail = false, $recipients = arra
2129
  $headers .= "Cc: " . $recipient . "\r\n";
2130
  }
2131
  }
 
 
2132
  DebugEcho($headers);
 
2133
  // Set email subject
2134
  if ($reject) {
2135
  DebugEcho("MailToRecipients: sending reject mail");
@@ -2180,7 +2186,7 @@ function MailToRecipients(&$mail_content, $testEmail = false, $recipients = arra
2180
  DebugEcho("MailToRecipients: $alert_subject\n$mailtext");
2181
  }
2182
 
2183
- wp_mail($myemailadd, $alert_subject, $mailtext, $headers);
2184
 
2185
  return true;
2186
  }
@@ -2403,39 +2409,47 @@ function parseTemplate($id, $type, $template, $orig_filename, $icon = "") {
2403
  * @param array - array of HTML for images for post
2404
  */
2405
  function filter_ReplaceImageCIDs(&$content, &$attachments, $config) {
2406
- if ($config['prefer_text_type'] == "html" && count($attachments["cids"])) {
2407
  DebugEcho("ReplaceImageCIDs");
2408
  $used = array();
2409
  foreach ($attachments["cids"] as $key => $info) {
2410
- $key = str_replace('/', '\/', $key);
2411
- $pattern = "/cid:$key/";
 
2412
  if (preg_match($pattern, $content)) {
2413
  $content = preg_replace($pattern, $info[0], $content);
2414
  $used[] = $info[1]; //Index of html to ignore
2415
  }
2416
  }
2417
- DebugEcho("# cid attachments: " . count($used));
2418
-
2419
- $html = array();
2420
- $att = array_values($attachments["html"]); //make sure there are numeric indexes
2421
- DebugEcho('$attachments');
2422
- //DebugDump($attachments);
2423
- DebugEcho('$used');
2424
- //DebugDump($used);
2425
- for ($i = 0; $i < count($attachments["html"]); $i++) {
2426
- if (!in_array($i, $used)) {
2427
- $html[] = $att[$i];
 
 
 
 
2428
  }
2429
- }
2430
 
2431
- foreach ($attachments['html'] as $key => $value) {
2432
- if (!in_array($value, $used)) {
2433
- $html[$key] = $value;
 
 
 
2434
  }
 
 
 
 
2435
  }
2436
-
2437
- $attachments["html"] = $html;
2438
- //DebugDump($attachments);
2439
  }
2440
  }
2441
 
@@ -2508,6 +2522,7 @@ function filter_ReplaceImagePlaceHolders(&$content, $attachments, $config, $post
2508
  $imageTemplate = str_replace('{CAPTION}', '', $imageTemplate);
2509
  /* if using the gallery shortcode, don't add pictures at all */
2510
  if (!preg_match("/\[gallery[^\[]*\]/", $content, $matches)) {
 
2511
  $pics .= $imageTemplate;
2512
  } else {
2513
  DebugEcho("gallery detected, not inserting images");
1
  <?php
2
  /*
3
+ $Id: postie-functions.php 1085948 2015-02-09 23:43:57Z WayneAllen $
4
  */
5
 
6
  //to turn on debug output add the following line to wp-config.php
230
 
231
  $content = GetContent($mimeDecodedEmail, $attachments, $post_id, $poster, $config);
232
  if ($fulldebug) {
233
+ DebugEcho("CreatePost: '$content'");
234
+ DebugDump($attachments);
235
  }
236
 
237
  $subject = GetSubject($mimeDecodedEmail, $content, $config);
386
  DebugEcho("post end: $content");
387
  }
388
 
389
+ //if ($config['prefer_text_type'] == 'plain') {
390
+ filter_ReplaceImagePlaceHolders($content, $attachments["html"], $config, $id, $config['image_placeholder'], true);
391
+ if ($fulldebug) {
392
+ DebugEcho("post body ReplaceImagePlaceHolders: $content");
393
+ }
394
 
395
+ if ($post_excerpt) {
396
+ filter_ReplaceImagePlaceHolders($post_excerpt, $attachments["html"], $config, $id, "#eimg%#", false);
397
+ DebugEcho("excerpt: $post_excerpt");
398
+ if ($fulldebug) {
399
+ DebugEcho("post excerpt ReplaceImagePlaceHolders: $content");
 
400
  }
401
  }
402
+ //}
403
 
404
  if (trim($subject) == "") {
405
  $subject = $config['default_title'];
2116
  return false;
2117
  }
2118
 
2119
+ $to = array_pop($recipients);
2120
+
2121
  $from = trim($mail_content->headers["from"]);
2122
  $subject = $mail_content->headers['subject'];
2123
  if ($returnToSender) {
2132
  $headers .= "Cc: " . $recipient . "\r\n";
2133
  }
2134
  }
2135
+
2136
+ DebugEcho("To: $to");
2137
  DebugEcho($headers);
2138
+
2139
  // Set email subject
2140
  if ($reject) {
2141
  DebugEcho("MailToRecipients: sending reject mail");
2186
  DebugEcho("MailToRecipients: $alert_subject\n$mailtext");
2187
  }
2188
 
2189
+ wp_mail($to, $alert_subject, $mailtext, $headers);
2190
 
2191
  return true;
2192
  }
2409
  * @param array - array of HTML for images for post
2410
  */
2411
  function filter_ReplaceImageCIDs(&$content, &$attachments, $config) {
2412
+ if (count($attachments["cids"])) {
2413
  DebugEcho("ReplaceImageCIDs");
2414
  $used = array();
2415
  foreach ($attachments["cids"] as $key => $info) {
2416
+ DebugEcho("looking for $key in content");
2417
+ $ckey = str_replace('/', '\/', $key);
2418
+ $pattern = "/cid:$ckey/";
2419
  if (preg_match($pattern, $content)) {
2420
  $content = preg_replace($pattern, $info[0], $content);
2421
  $used[] = $info[1]; //Index of html to ignore
2422
  }
2423
  }
2424
+ if (count($used) > 0) {
2425
+ DebugEcho("# cid attachments: " . count($used));
2426
+
2427
+ $html = array();
2428
+ $att = array_values($attachments["html"]); //make sure there are numeric indexes
2429
+ DebugEcho('$attachments["html"]');
2430
+ DebugDump($attachments["html"]);
2431
+ DebugEcho('$used');
2432
+ DebugDump($used);
2433
+ for ($i = 0; $i < count($attachments["html"]); $i++) {
2434
+ DebugEcho("looking for $i in used");
2435
+ if (!in_array($i, $used)) {
2436
+ DebugEcho("not found, adding {$att[$i]}");
2437
+ $html[] = $att[$i];
2438
+ }
2439
  }
 
2440
 
2441
+ foreach ($attachments['html'] as $key => $value) {
2442
+ DebugEcho("Looking for '$value' in attachments");
2443
+ if (!in_array($value, $used)) {
2444
+ DebugEcho("not found, adding as $key");
2445
+ $html[$key] = $value;
2446
+ }
2447
  }
2448
+ DebugEcho('$html');
2449
+ DebugDump($html);
2450
+ $attachments["html"] = $html;
2451
+ //DebugDump($attachments);
2452
  }
 
 
 
2453
  }
2454
  }
2455
 
2522
  $imageTemplate = str_replace('{CAPTION}', '', $imageTemplate);
2523
  /* if using the gallery shortcode, don't add pictures at all */
2524
  if (!preg_match("/\[gallery[^\[]*\]/", $content, $matches)) {
2525
+ DebugEcho("imageTemplate: $imageTemplate");
2526
  $pics .= $imageTemplate;
2527
  } else {
2528
  DebugEcho("gallery detected, not inserting images");
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.6.11
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
@@ -27,11 +27,11 @@
27
  */
28
 
29
  /*
30
- $Id: postie.php 1079101 2015-01-30 16:45:46Z WayneAllen $
31
  */
32
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
33
 
34
- define('POSTIE_VERSION', '1.6.11');
35
  define("POSTIE_ROOT", dirname(__FILE__));
36
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
37
 
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.6.12
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
27
  */
28
 
29
  /*
30
+ $Id: postie.php 1085949 2015-02-09 23:45:02Z WayneAllen $
31
  */
32
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
33
 
34
+ define('POSTIE_VERSION', '1.6.12');
35
  define("POSTIE_ROOT", dirname(__FILE__));
36
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
37
 
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.0
8
  Tested up to: 4.1
9
- Stable tag: 1.6.11
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -238,6 +238,10 @@ All script, style and body tags are stripped from html emails.
238
  Attachments are now processed in the order they were attached.
239
 
240
  == CHANGELOG ==
 
 
 
 
241
  = 1.6.11 (2015-01-30) =
242
  * Call wp_set_current_user() so that other WP functions that depend on the current user work correctly. (custom taxonomy)
243
  * Only do image template processing if the preferred text type is plain
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.0
8
  Tested up to: 4.1
9
+ Stable tag: 1.6.12
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
238
  Attachments are now processed in the order they were attached.
239
 
240
  == CHANGELOG ==
241
+ = 1.6.12 (2015-02-09) =
242
+ * Fix confirmation emails that were always sending to administrator.
243
+ * Fix regression in 1.6.11 which prevented attachments from being displayed in some cases.
244
+
245
  = 1.6.11 (2015-01-30) =
246
  * Call wp_set_current_user() so that other WP functions that depend on the current user work correctly. (custom taxonomy)
247
  * Only do image template processing if the preferred text type is plain