Postie - Version 1.7.12

Version Description

(2015-09-25) = * Add new setting to ignore email read/unread state * fix support for tags in html and plain messages

Download this release

Release Info

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

Code changes from version 1.7.11 to 1.7.12

Files changed (7) hide show
  1. config_form.php +1 -0
  2. docs/Changes.txt +4 -0
  3. docs/Postie.txt +1 -1
  4. docs/TODO.txt +1 -0
  5. postie-functions.php +34 -41
  6. postie.php +3 -3
  7. readme.txt +5 -1
config_form.php CHANGED
@@ -275,6 +275,7 @@
275
  </td>
276
  </tr>
277
  <?php echo BuildBooleanSelect(__("Delete email after posting", POSTIE_SLUG), 'postie-settings[delete_mail_after_processing]', $delete_mail_after_processing, __("Only set to no for testing purposes", POSTIE_SLUG)); ?>
 
278
  <?php echo BuildTextArea(__("Allowed SMTP servers", POSTIE_SLUG), "postie-settings[smtp]", $smtp, __("Only allow messages which have been sent throught the following SMTP servers. Put each server on a separate line. Leave blank to allow any SMTP server.", POSTIE_SLUG)); ?>
279
  </table>
280
  </div>
275
  </td>
276
  </tr>
277
  <?php echo BuildBooleanSelect(__("Delete email after posting", POSTIE_SLUG), 'postie-settings[delete_mail_after_processing]', $delete_mail_after_processing, __("Only set to no for testing purposes", POSTIE_SLUG)); ?>
278
+ <?php echo BuildBooleanSelect(__("Ignore mail state", POSTIE_SLUG), 'postie-settings[ignore_mail_state]', $ignore_mail_state, __("Ignore whether the mails is 'read' or 'unread' If 'No' then only unread messages are processed.", POSTIE_SLUG)); ?>
279
  <?php echo BuildTextArea(__("Allowed SMTP servers", POSTIE_SLUG), "postie-settings[smtp]", $smtp, __("Only allow messages which have been sent throught the following SMTP servers. Put each server on a separate line. Leave blank to allow any SMTP server.", POSTIE_SLUG)); ?>
280
  </table>
281
  </div>
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.7.11 (2015-09-18) =
31
  * Add FILEID to image and video templates
32
 
27
  Attachments are now processed in the order they were attached.
28
 
29
  == CHANGELOG ==
30
+ = 1.7.12 (2015-09-25) =
31
+ * Add new setting to ignore email read/unread state
32
+ * fix support for tags in html and plain messages
33
+
34
  = 1.7.11 (2015-09-18) =
35
  * Add FILEID to image and video templates
36
 
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.3.1
9
- Stable tag: 1.7.11
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  Text Domain: postie
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.3.1
9
+ Stable tag: 1.7.12
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  Text Domain: postie
docs/TODO.txt CHANGED
@@ -1,3 +1,4 @@
 
1
  Preferred text type: just html, just plain, html fallback to plain
2
  Check to see if post already exists. Store hash in custom field.
3
  Change successful post message to take post status into account (i.e. draft really isn't posted - possible link to publish draft?)
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?)
postie-functions.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /*
3
- $Id: postie-functions.php 1248885 2015-09-18 23:32:56Z WayneAllen $
4
  */
5
 
6
  //to turn on debug output add the following line to wp-config.php
@@ -284,7 +284,7 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $
284
  DebugEcho("post category: $content");
285
  }
286
 
287
- $post_tags = tag_Tags($content, $config['default_post_tags']);
288
  if ($fulldebug) {
289
  DebugEcho("post tag: $content");
290
  }
@@ -1724,7 +1724,7 @@ function filter_Delay(&$content, $message_date = NULL, $offset = 0) {
1724
  $delay = 0;
1725
  $matches = array();
1726
  if (preg_match("/delay:(-?[0-9dhm]+)/i", $content, $matches) && trim($matches[1])) {
1727
- DebugEcho("found delay: " . $matches[1]);
1728
  $days = 0;
1729
  $hours = 0;
1730
  $minutes = 0;
@@ -1741,7 +1741,7 @@ function filter_Delay(&$content, $message_date = NULL, $offset = 0) {
1741
  $minutes = $minuteMatches[1];
1742
  }
1743
  $delay = (($days * 24 + $hours) * 60 + $minutes) * 60;
1744
- DebugEcho("calculated delay: $delay");
1745
  $content = preg_replace("/delay:$matches[1]/i", "", $content);
1746
  }
1747
  if (empty($message_date)) {
@@ -1753,7 +1753,7 @@ function filter_Delay(&$content, $message_date = NULL, $offset = 0) {
1753
 
1754
  $post_date = gmdate('Y-m-d H:i:s', $dateInSeconds + ($offset * 3600));
1755
  $post_date_gmt = gmdate('Y-m-d H:i:s', $dateInSeconds);
1756
- DebugEcho("post date: $post_date / $post_date_gmt");
1757
 
1758
  return array($post_date, $post_date_gmt, $delay);
1759
  }
@@ -2626,21 +2626,10 @@ function GetSubject(&$mimeDecodedEmail, &$content, $config) {
2626
  * this function determines tags for the post
2627
  *
2628
  */
2629
- function tag_Tags(&$content, $defaultTags) {
2630
  $post_tags = array();
2631
 
2632
- // $html = LoadDOM($content);
2633
- // if ($html !== false) {
2634
- // DebugEcho("tag_Tags: html detected");
2635
- // foreach ($html->find('text') as $element) {
2636
- // $e = $element->innertext;
2637
- // $post_tags = array_merge($post_tags, tag_TagsWorker($e));
2638
- // $element->innertext = $e;
2639
- // }
2640
- // $content = $html->save();
2641
- // } else {
2642
- $post_tags = tag_TagsWorker($content);
2643
- // }
2644
 
2645
  if (count($post_tags) == 0 && is_array($defaultTags)) {
2646
  $post_tags = $defaultTags;
@@ -2648,34 +2637,24 @@ function tag_Tags(&$content, $defaultTags) {
2648
  return $post_tags;
2649
  }
2650
 
2651
- function tag_TagsWorker(&$content) {
2652
  $post_tags = array();
2653
  $matches = array();
2654
- if (preg_match('/tags: ?(.*)$/im', $content, $matches)) {
2655
- if (!empty($matches[1])) {
2656
- DebugEcho("Found tags: $matches[1]");
2657
- $content = str_replace($matches[0], "", $content);
2658
- $post_tags = preg_split("/,\s*/", trim($matches[1]));
2659
- }
2660
  }
2661
- return $post_tags;
2662
- }
2663
-
2664
- function tag_Tags2(&$content, $defaultTags) {
2665
- $post_tags = array();
2666
- //try and determine tags
2667
- $matches = array();
2668
- if (preg_match('/tags: ?(.*)$/im', $content, $matches)) {
2669
  if (!empty($matches[1])) {
2670
  DebugEcho("Found tags: $matches[1]");
2671
- $content = str_replace($matches[0], "", $content);
 
 
 
 
2672
  $post_tags = preg_split("/,\s*/", trim($matches[1]));
2673
- //DebugDump($post_tags);
2674
  }
2675
  }
2676
- if (count($post_tags) == 0 && is_array($defaultTags)) {
2677
- $post_tags = $defaultTags;
2678
- }
2679
  return $post_tags;
2680
  }
2681
 
@@ -3021,7 +3000,8 @@ function config_GetDefaults() {
3021
  'generate_thumbnails' => true,
3022
  'reply_as_comment' => true,
3023
  'force_user_login' => false,
3024
- 'auto_gallery_link' => 'default'
 
3025
  );
3026
  }
3027
 
@@ -3530,7 +3510,20 @@ function postie_test_config() {
3530
  $data = filter_Delay($content, null, $config['time_offset']);
3531
  EchoInfo("Post time: $data[0]");
3532
  ?>
3533
-
 
 
 
 
 
 
 
 
 
 
 
 
 
3534
  <h2>Connect to Mail Host</h2>
3535
 
3536
  <?php
@@ -3643,7 +3636,7 @@ function postie_get_mail() {
3643
  $message = __('Dang, message is empty!', POSTIE_SLUG);
3644
  EchoInfo("$message_number: $message");
3645
  continue;
3646
- } else if ($email == 'already read') {
3647
  $message = __("Message is already marked 'read'.", POSTIE_SLUG);
3648
  EchoInfo("$message_number: $message");
3649
  continue;
1
  <?php
2
  /*
3
+ $Id: postie-functions.php 1253587 2015-09-25 18:51:46Z WayneAllen $
4
  */
5
 
6
  //to turn on debug output add the following line to wp-config.php
284
  DebugEcho("post category: $content");
285
  }
286
 
287
+ $post_tags = tag_Tags($content, $config['default_post_tags'], 'html' == $config['prefer_text_type']);
288
  if ($fulldebug) {
289
  DebugEcho("post tag: $content");
290
  }
1724
  $delay = 0;
1725
  $matches = array();
1726
  if (preg_match("/delay:(-?[0-9dhm]+)/i", $content, $matches) && trim($matches[1])) {
1727
+ DebugEcho("filter_Delay: found delay: " . $matches[1]);
1728
  $days = 0;
1729
  $hours = 0;
1730
  $minutes = 0;
1741
  $minutes = $minuteMatches[1];
1742
  }
1743
  $delay = (($days * 24 + $hours) * 60 + $minutes) * 60;
1744
+ DebugEcho("filter_Delay: calculated delay: $delay");
1745
  $content = preg_replace("/delay:$matches[1]/i", "", $content);
1746
  }
1747
  if (empty($message_date)) {
1753
 
1754
  $post_date = gmdate('Y-m-d H:i:s', $dateInSeconds + ($offset * 3600));
1755
  $post_date_gmt = gmdate('Y-m-d H:i:s', $dateInSeconds);
1756
+ DebugEcho("filter_Delay: post date: $post_date / $post_date_gmt (gmt)");
1757
 
1758
  return array($post_date, $post_date_gmt, $delay);
1759
  }
2626
  * this function determines tags for the post
2627
  *
2628
  */
2629
+ function tag_Tags(&$content, $defaultTags, $isHtml) {
2630
  $post_tags = array();
2631
 
2632
+ $post_tags = tag_TagsWorker($content, $isHtml);
 
 
 
 
 
 
 
 
 
 
 
2633
 
2634
  if (count($post_tags) == 0 && is_array($defaultTags)) {
2635
  $post_tags = $defaultTags;
2637
  return $post_tags;
2638
  }
2639
 
2640
+ function tag_TagsWorker(&$content, $isHtml) {
2641
  $post_tags = array();
2642
  $matches = array();
2643
+ $rx = '/[>|\a]?tags:\s?(.*?)[<|\z]/im';
2644
+ if (!$isHtml) {
2645
+ $rx = '/tags:\s?(.*)/im';
 
 
 
2646
  }
2647
+ if (preg_match($rx, $content, $matches)) {
 
 
 
 
 
 
 
2648
  if (!empty($matches[1])) {
2649
  DebugEcho("Found tags: $matches[1]");
2650
+ if ($isHtml) {
2651
+ $content = str_replace($matches[0], "><", $content);
2652
+ } else {
2653
+ $content = str_replace($matches[0], "", $content);
2654
+ }
2655
  $post_tags = preg_split("/,\s*/", trim($matches[1]));
 
2656
  }
2657
  }
 
 
 
2658
  return $post_tags;
2659
  }
2660
 
3000
  'generate_thumbnails' => true,
3001
  'reply_as_comment' => true,
3002
  'force_user_login' => false,
3003
+ 'auto_gallery_link' => 'default',
3004
+ 'ignore_mail_state' => false
3005
  );
3006
  }
3007
 
3510
  $data = filter_Delay($content, null, $config['time_offset']);
3511
  EchoInfo("Post time: $data[0]");
3512
  ?>
3513
+ <h2>Encoding</h2>
3514
+ <?php
3515
+ EchoInfo("default_charset: " . ini_get('default_charset'));
3516
+ if (defined('DB_CHARSET')) {
3517
+ EchoInfo("DB_CHARSET: " . DB_CHARSET);
3518
+ } else {
3519
+ EchoInfo("DB_CHARSET: undefined (utf8)");
3520
+ }
3521
+ if (defined('DB_COLLATE')) {
3522
+ EchoInfo("DB_COLLATE: " . DB_COLLATE);
3523
+ }
3524
+ EchoInfo("WordPress encoding: " . esc_attr(get_option('blog_charset')));
3525
+ EchoInfo("Postie encoding: " . $config['message_encoding']);
3526
+ ?>
3527
  <h2>Connect to Mail Host</h2>
3528
 
3529
  <?php
3636
  $message = __('Dang, message is empty!', POSTIE_SLUG);
3637
  EchoInfo("$message_number: $message");
3638
  continue;
3639
+ } else if (($config['ignore_mail_state'] == false) && ( $email == 'already read')) {
3640
  $message = __("Message is already marked 'read'.", POSTIE_SLUG);
3641
  EchoInfo("$message_number: $message");
3642
  continue;
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.11
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL2
@@ -27,11 +27,11 @@
27
  */
28
 
29
  /*
30
- $Id: postie.php 1248887 2015-09-18 23:33:58Z WayneAllen $
31
  */
32
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
33
 
34
- define('POSTIE_VERSION', '1.7.11');
35
  define("POSTIE_ROOT", dirname(__FILE__));
36
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
37
  define('POSTIE_SLUG', 'postie');
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.12
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL2
27
  */
28
 
29
  /*
30
+ $Id: postie.php 1253587 2015-09-25 18:51:46Z WayneAllen $
31
  */
32
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
33
 
34
+ define('POSTIE_VERSION', '1.7.12');
35
  define("POSTIE_ROOT", dirname(__FILE__));
36
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
37
  define('POSTIE_SLUG', 'postie');
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.3.1
9
- Stable tag: 1.7.11
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  Text Domain: postie
@@ -236,6 +236,10 @@ All script, style and body tags are stripped from html emails.
236
  Attachments are now processed in the order they were attached.
237
 
238
  == CHANGELOG ==
 
 
 
 
239
  = 1.7.11 (2015-09-18) =
240
  * Add FILEID to image and video templates
241
 
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.3.1
9
+ Stable tag: 1.7.12
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  Text Domain: postie
236
  Attachments are now processed in the order they were attached.
237
 
238
  == CHANGELOG ==
239
+ = 1.7.12 (2015-09-25) =
240
+ * Add new setting to ignore email read/unread state
241
+ * fix support for tags in html and plain messages
242
+
243
  = 1.7.11 (2015-09-18) =
244
  * Add FILEID to image and video templates
245