Postie - Version 1.5.2

Version Description

(2013.04.12) * Fixed bug in post type/format detection when no valid post type/format was found * Workaround for WP bug when POP3 account has no waiting messages * Fixed bug where cron was running postie_check on every page load

Download this release

Release Info

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

Code changes from version 1.5.1 to 1.5.2

deploy/_deploy.txt CHANGED
@@ -2,9 +2,10 @@ see: http://codex.wordpress.org/Writing_a_Plugin#Updating_your_Plugin
2
  update docs\Changes.txt
3
  update date in docs\Changes.txt
4
  update Upgrade Notice in docs\Changes.txt
5
- update version number in postie.php
6
  update version number in docs\Postie.txt
 
7
  run deploy.cmd
8
  commit
9
  branch trunk to new version
10
- add release post on http://postieplugin.com/ & http://wordpress.org/support/plugin/postie
 
2
  update docs\Changes.txt
3
  update date in docs\Changes.txt
4
  update Upgrade Notice in docs\Changes.txt
 
5
  update version number in docs\Postie.txt
6
+ update version number in postie.php
7
  run deploy.cmd
8
  commit
9
  branch trunk to new version
10
+ add release post on http://postieplugin.com/
11
+ add release post on http://wordpress.org/support/plugin/postie
docs/Changes.txt CHANGED
@@ -18,6 +18,11 @@ All script, style and body tags are stripped from html emails.
18
  Attachments are now processed in the order they were attached.
19
 
20
  == CHANGELOG ==
 
 
 
 
 
21
  = 1.5.1 (2013.04.10)
22
  * Turned on POP3 debug logging if POSTIE_DEBUG is TRUE.
23
  * Disable autocomplete on some setup fields
18
  Attachments are now processed in the order they were attached.
19
 
20
  == CHANGELOG ==
21
+ = 1.5.2 (2013.04.12)
22
+ * Fixed bug in post type/format detection when no valid post type/format was found
23
+ * Workaround for WP bug when POP3 account has no waiting messages
24
+ * Fixed bug where cron was running postie_check on every page load
25
+
26
  = 1.5.1 (2013.04.10)
27
  * Turned on POP3 debug logging if POSTIE_DEBUG is TRUE.
28
  * Disable autocomplete on some setup fields
docs/Postie.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5.1
9
- Stable tag: 1.5.1
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5.1
9
+ Stable tag: 1.5.2
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
docs/TODO.txt CHANGED
@@ -1,20 +1,21 @@
1
  provide a location for custom icons. update docs about location.
2
- reply logic not adding to comments
3
  hide/disable config options that don't apply
4
  handle condition where only one of text/plain & text/html is supplied, but Preferred Text Type is set to the opposite.
5
- replace native imap with flourish
6
  replace MIME parser
7
- debug assistance
8
- setting for default post type/post format
9
  automatically create category if it doesn't exist. new option to allow this feature?
10
  WP MU support
11
- rework attachment logic. video files can come through as application/octect-stream. Mail parsing should separate attachments
12
- into buckets? i.e. video, image, other. Each gets processed differently. I.e. when gallery in turned on images don't get embedded
13
- but videos do.
14
  Add setting for category detection. I.e. checkboxes for [], -- and : styles. Default to all on.
 
15
  Make sure all failures are sent to admin (option?) failed attachments, etc.
 
16
  Comment not being created when subject contains category command []. I.e. listserv subject lines
17
  code to set featured image. Global setting (first picture is featured). Featured tag to enable per email. Enhance #img# http://codex.wordpress.org/Function_Reference/set_post_thumbnail
 
 
 
 
 
18
 
19
  standardize tags
20
  fix postie settings http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/
1
  provide a location for custom icons. update docs about location.
 
2
  hide/disable config options that don't apply
3
  handle condition where only one of text/plain & text/html is supplied, but Preferred Text Type is set to the opposite.
4
+ replace native imap with flourish - http://flourishlib.com/docs/fMailbox
5
  replace MIME parser
 
 
6
  automatically create category if it doesn't exist. new option to allow this feature?
7
  WP MU support
 
 
 
8
  Add setting for category detection. I.e. checkboxes for [], -- and : styles. Default to all on.
9
+ setting for default post type/post format
10
  Make sure all failures are sent to admin (option?) failed attachments, etc.
11
+ debug assistance
12
  Comment not being created when subject contains category command []. I.e. listserv subject lines
13
  code to set featured image. Global setting (first picture is featured). Featured tag to enable per email. Enhance #img# http://codex.wordpress.org/Function_Reference/set_post_thumbnail
14
+ reply logic not adding to comments
15
+ rework attachment logic. video files can come through as application/octect-stream. Mail parsing should separate attachments
16
+ into buckets? i.e. video, image, other. Each gets processed differently. I.e. when gallery in turned on images don't get embedded
17
+ but videos do.
18
+ date: tag is being detected in body when not wanted
19
 
20
  standardize tags
21
  fix postie settings http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/
get_mail.php CHANGED
@@ -35,7 +35,7 @@ $message = 'Done.';
35
  EchoInfo(sprintf(__("There are %d messages to process", "postie"), count($emails)));
36
 
37
  if (function_exists('memory_get_usage'))
38
- EchoInfo(__("memory at start of e-mail processing:") . memory_get_usage());
39
 
40
  DebugEcho("Error log: " . ini_get('error_log'));
41
  DebugDump($config);
@@ -69,6 +69,6 @@ foreach ($emails as $email) {
69
  }
70
 
71
  if (function_exists('memory_get_usage'))
72
- EchoInfo("memory at end of e-mail processing:" . memory_get_usage());
73
 
74
  ?>
35
  EchoInfo(sprintf(__("There are %d messages to process", "postie"), count($emails)));
36
 
37
  if (function_exists('memory_get_usage'))
38
+ DebugEcho(__("memory at start of e-mail processing:") . memory_get_usage());
39
 
40
  DebugEcho("Error log: " . ini_get('error_log'));
41
  DebugDump($config);
69
  }
70
 
71
  if (function_exists('memory_get_usage'))
72
+ DebugEcho("memory at end of e-mail processing:" . memory_get_usage());
73
 
74
  ?>
postie-functions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /*
4
- $Id: postie-functions.php 695680 2013-04-11 04:49:31Z WayneAllen $
5
  */
6
 
7
  //to turn on debug output add the following line to wp-config.php
@@ -407,7 +407,6 @@ function tag_PostType(&$subject, $postmodifiers) {
407
  // Captures the custom post type in the subject before $custom_post_type_delim
408
  $separated_subject = explode($custom_post_type_delim, $subject);
409
  $custom_post_type = $separated_subject[0];
410
- $subject = trim($separated_subject[1]);
411
 
412
  $custom_post_type = trim(strtolower($custom_post_type));
413
  DebugEcho("post type: found possible type '$custom_post_type'");
@@ -420,9 +419,11 @@ function tag_PostType(&$subject, $postmodifiers) {
420
  if (in_array($custom_post_type, array_map('strtolower', $known_post_types))) {
421
  DebugEcho("post type: found type '$post_type'");
422
  $post_type = $custom_post_type;
 
423
  } elseif (in_array($custom_post_type, array_keys(get_post_format_slugs()))) {
424
  DebugEcho("post type: found format '$custom_post_type'");
425
  $postmodifiers->PostFormat = $custom_post_type;
 
426
  }
427
  }
428
 
@@ -2551,12 +2552,7 @@ function config_ResetToDefault() {
2551
  function config_Update($data) {
2552
  UpdatePostiePermissions($data["role_access"]);
2553
  // We also update the cron settings
2554
- if ($data['interval'] != '') {
2555
- postie_decron();
2556
- if ($data['interval'] != 'manual') {
2557
- postie_cron($data['interval']);
2558
- }
2559
- }
2560
  }
2561
 
2562
  /**
1
  <?php
2
 
3
  /*
4
+ $Id: postie-functions.php 696836 2013-04-12 23:57:07Z WayneAllen $
5
  */
6
 
7
  //to turn on debug output add the following line to wp-config.php
407
  // Captures the custom post type in the subject before $custom_post_type_delim
408
  $separated_subject = explode($custom_post_type_delim, $subject);
409
  $custom_post_type = $separated_subject[0];
 
410
 
411
  $custom_post_type = trim(strtolower($custom_post_type));
412
  DebugEcho("post type: found possible type '$custom_post_type'");
419
  if (in_array($custom_post_type, array_map('strtolower', $known_post_types))) {
420
  DebugEcho("post type: found type '$post_type'");
421
  $post_type = $custom_post_type;
422
+ $subject = trim($separated_subject[1]);
423
  } elseif (in_array($custom_post_type, array_keys(get_post_format_slugs()))) {
424
  DebugEcho("post type: found format '$custom_post_type'");
425
  $postmodifiers->PostFormat = $custom_post_type;
426
+ $subject = trim($separated_subject[1]);
427
  }
428
  }
429
 
2552
  function config_Update($data) {
2553
  UpdatePostiePermissions($data["role_access"]);
2554
  // We also update the cron settings
2555
+ postie_cron($data['interval']);
 
 
 
 
 
2556
  }
2557
 
2558
  /**
postie.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://wordpress.org/support/plugin/postie'>postie forum</a> for support.
7
- Version: 1.5.1
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
@@ -27,7 +27,7 @@
27
  */
28
 
29
  /*
30
- $Id: postie.php 695686 2013-04-11 05:08:55Z WayneAllen $
31
  */
32
 
33
  define("POSTIE_ROOT", dirname(__FILE__));
@@ -166,10 +166,10 @@ function postie_warnings() {
166
  add_action('admin_notices', 'postie_mbstring_warning');
167
  }
168
 
169
- if (!function_exists('get_user_by')){
170
  include ABSPATH . 'wp-includes/pluggable.php';
171
  }
172
- $adminuser = get_user_by( 'login', $config['admin_username']);
173
  if ($adminuser === false) {
174
 
175
  function postie_adminuser_warning() {
@@ -192,7 +192,9 @@ function postie_whitelist($options) {
192
  return $options;
193
  }
194
 
 
195
  function check_postie() {
 
196
  $host = get_option('siteurl');
197
  preg_match("/https?:\/\/(.[^\/]*)(.*)/i", $host, $matches);
198
  $host = $matches[1];
@@ -214,7 +216,7 @@ function check_postie() {
214
  }
215
  fclose($fp);
216
  } else {
217
- EchoInfo("Cannot connect to server on port $port. Please check to make sure that this port is open on your webhost. Additional information: $errno: $errstr");
218
  }
219
  }
220
 
@@ -222,7 +224,7 @@ function postie_cron($interval = false) {
222
  //Do not echo output in filters, it seems to break some installs
223
  //error_log("postie_cron: setting up cron task: $interval");
224
 
225
- $schedules = wp_get_schedules();
226
  //error_log("postie_cron\n" . print_r($schedules, true));
227
 
228
  if (!$interval) {
@@ -238,10 +240,17 @@ function postie_cron($interval = false) {
238
  postie_decron();
239
  //error_log("postie_cron: clearing cron (manual)");
240
  } else {
241
- if (false === wp_schedule_event(time(), $interval, 'check_postie_hook')) {
242
- //error_log("postie_cron: Failed to set up cron task: $interval");
 
 
 
 
 
 
243
  } else {
244
- //error_log("postie_cron: Set up cron task: $interval");
 
245
  }
246
  }
247
  }
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://wordpress.org/support/plugin/postie'>postie forum</a> for support.
7
+ Version: 1.5.2
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
27
  */
28
 
29
  /*
30
+ $Id: postie.php 696838 2013-04-13 00:01:48Z WayneAllen $
31
  */
32
 
33
  define("POSTIE_ROOT", dirname(__FILE__));
166
  add_action('admin_notices', 'postie_mbstring_warning');
167
  }
168
 
169
+ if (!function_exists('get_user_by')) {
170
  include ABSPATH . 'wp-includes/pluggable.php';
171
  }
172
+ $adminuser = get_user_by('login', $config['admin_username']);
173
  if ($adminuser === false) {
174
 
175
  function postie_adminuser_warning() {
192
  return $options;
193
  }
194
 
195
+ //don't use DebugEcho or EchoInfo here as it is not defined when called as an action
196
  function check_postie() {
197
+ error_log("check_postie");
198
  $host = get_option('siteurl');
199
  preg_match("/https?:\/\/(.[^\/]*)(.*)/i", $host, $matches);
200
  $host = $matches[1];
216
  }
217
  fclose($fp);
218
  } else {
219
+ error_log("Cannot connect to server on port $port. Please check to make sure that this port is open on your webhost. Additional information: $errno: $errstr");
220
  }
221
  }
222
 
224
  //Do not echo output in filters, it seems to break some installs
225
  //error_log("postie_cron: setting up cron task: $interval");
226
 
227
+ //$schedules = wp_get_schedules();
228
  //error_log("postie_cron\n" . print_r($schedules, true));
229
 
230
  if (!$interval) {
240
  postie_decron();
241
  //error_log("postie_cron: clearing cron (manual)");
242
  } else {
243
+ if ($interval != wp_get_schedule('check_postie_hook')) {
244
+ postie_decron(); //remove existing
245
+ //try to create the new schedule with the first run in 5 minutes
246
+ if (false === wp_schedule_event(time() + 5 * 60, $interval, 'check_postie_hook')) {
247
+ //error_log("postie_cron: Failed to set up cron task: $interval");
248
+ } else {
249
+ //error_log("postie_cron: Set up cron task: $interval");
250
+ }
251
  } else {
252
+ //error_log("postie_cron: OK: $interval");
253
+ //don't need to do anything, cron already scheduled
254
  }
255
  }
256
  }
postie_test.php CHANGED
@@ -21,11 +21,7 @@ DebugEcho("Error log: " . ini_get('error_log'));
21
  <h1>Postie Configuration Test</h1>
22
  <?php
23
  if (isMarkdownInstalled()) {
24
- ?>
25
- <h1>Warning!</h1>
26
- <p>You currently have the Markdown plugin installed. It will cause problems if you send in HTML
27
- email. Please turn it off if you intend to send email using HTML</p>");
28
- <?php
29
  }
30
 
31
  if (!isPostieInCorrectDirectory()) {
@@ -33,6 +29,13 @@ DebugEcho("Error log: " . ini_get('error_log'));
33
  } else {
34
  EchoInfo("Postie is in " . dirname(__FILE__));
35
  }
 
 
 
 
 
 
 
36
  ?>
37
 
38
  <br/>
@@ -97,15 +100,23 @@ DebugEcho("Error log: " . ini_get('error_log'));
97
  default:
98
  require_once(ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'class-pop3.php');
99
  $pop3 = new POP3();
 
 
 
100
  if (!$pop3->connect($config["mail_server"], $config["mail_server_port"])) {
101
- EchoInfo("Unable to connect. The server said:");
102
- EchoInfo($pop3->ERROR);
103
  } else {
104
  EchoInfo("Sucessful " . strtoupper($config['input_protocol']) . " connection on port {$config["mail_server_port"]}");
105
  $msgs = $pop3->login($config["mail_userid"], $config["mail_password"]);
106
  if ($msgs === false) {
107
- EchoInfo("Unable to authenticate. The server said:");
108
- EchoInfo($pop3->ERROR);
 
 
 
 
 
 
109
  } else {
110
  EchoInfo("# of waiting messages: $msgs");
111
  }
21
  <h1>Postie Configuration Test</h1>
22
  <?php
23
  if (isMarkdownInstalled()) {
24
+ EchoInfo("You currently have the Markdown plugin installed. It will cause problems if you send in HTML email. Please turn it off if you intend to send email using HTML.");
 
 
 
 
25
  }
26
 
27
  if (!isPostieInCorrectDirectory()) {
29
  } else {
30
  EchoInfo("Postie is in " . dirname(__FILE__));
31
  }
32
+ if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
33
+ EchoInfo("Alternate cron is enabled");
34
+ }
35
+
36
+ if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {
37
+ EchoInfo("WordPress cron is disabled. Postie will not run unless you have an external cron set up.");
38
+ }
39
  ?>
40
 
41
  <br/>
100
  default:
101
  require_once(ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'class-pop3.php');
102
  $pop3 = new POP3();
103
+ if (defined('POSTIE_DEBUG')) {
104
+ $pop3->DEBUG = POSTIE_DEBUG;
105
+ }
106
  if (!$pop3->connect($config["mail_server"], $config["mail_server_port"])) {
107
+ EchoInfo("Unable to connect. The server said:" . $pop3->ERROR);
 
108
  } else {
109
  EchoInfo("Sucessful " . strtoupper($config['input_protocol']) . " connection on port {$config["mail_server_port"]}");
110
  $msgs = $pop3->login($config["mail_userid"], $config["mail_password"]);
111
  if ($msgs === false) {
112
+ //workaround for bug reported here Apr 12, 2013
113
+ //https://sourceforge.net/tracker/?func=detail&atid=100311&aid=3610701&group_id=311
114
+ //originally repoted here:
115
+ //https://core.trac.wordpress.org/ticket/10587
116
+ if (empty($pop3->ERROR))
117
+ EchoInfo("No waiting messages");
118
+ else
119
+ EchoInfo("Unable to login. The server said:" . $pop3->ERROR);
120
  } else {
121
  EchoInfo("# of waiting messages: $msgs");
122
  }
readme.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5.1
9
- Stable tag: 1.5.1
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -439,6 +439,11 @@ All script, style and body tags are stripped from html emails.
439
  Attachments are now processed in the order they were attached.
440
 
441
  == CHANGELOG ==
 
 
 
 
 
442
  = 1.5.1 (2013.04.10)
443
  * Turned on POP3 debug logging if POSTIE_DEBUG is TRUE.
444
  * Disable autocomplete on some setup fields
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5.1
9
+ Stable tag: 1.5.2
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
439
  Attachments are now processed in the order they were attached.
440
 
441
  == CHANGELOG ==
442
+ = 1.5.2 (2013.04.12)
443
+ * Fixed bug in post type/format detection when no valid post type/format was found
444
+ * Workaround for WP bug when POP3 account has no waiting messages
445
+ * Fixed bug where cron was running postie_check on every page load
446
+
447
  = 1.5.1 (2013.04.10)
448
  * Turned on POP3 debug logging if POSTIE_DEBUG is TRUE.
449
  * Disable autocomplete on some setup fields
test/postie-functionsTest.php CHANGED
@@ -269,11 +269,11 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
269
 
270
  $subject = "//test";
271
  $this->assertEquals("post", tag_PostType($subject, $pm));
272
- $this->assertEquals("test", $subject);
273
 
274
  $subject = "//";
275
  $this->assertEquals("post", tag_PostType($subject, $pm));
276
- $this->assertEquals("", $subject);
277
 
278
  $subject = "custom2//test";
279
  $this->assertEquals("custom2", tag_PostType($subject, $pm));
@@ -287,6 +287,11 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
287
  $this->assertEquals("post", tag_PostType($subject, $pm));
288
  $this->assertEquals("test", $subject);
289
  $this->assertEquals('video', $pm->PostFormat);
 
 
 
 
 
290
  }
291
 
292
  public function testGetPostExcerpt() {
269
 
270
  $subject = "//test";
271
  $this->assertEquals("post", tag_PostType($subject, $pm));
272
+ $this->assertEquals("//test", $subject);
273
 
274
  $subject = "//";
275
  $this->assertEquals("post", tag_PostType($subject, $pm));
276
+ $this->assertEquals("//", $subject);
277
 
278
  $subject = "custom2//test";
279
  $this->assertEquals("custom2", tag_PostType($subject, $pm));
287
  $this->assertEquals("post", tag_PostType($subject, $pm));
288
  $this->assertEquals("test", $subject);
289
  $this->assertEquals('video', $pm->PostFormat);
290
+
291
+ $subject = "//WL2K /Test Message";
292
+ $this->assertEquals("post", tag_PostType($subject, $pm));
293
+ $this->assertEquals("//WL2K /Test Message", $subject);
294
+ $this->assertEquals('video', $pm->PostFormat);
295
  }
296
 
297
  public function testGetPostExcerpt() {