Postie - Version 1.6.14

Version Description

(2015-02-26) = * Fully support custom taxonomies

Download this release

Release Info

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

Code changes from version 1.6.13 to 1.6.14

Files changed (5) hide show
  1. docs/Changes.txt +3 -0
  2. docs/Postie.txt +1 -1
  3. postie-functions.php +37 -11
  4. postie.php +3 -3
  5. readme.txt +4 -1
docs/Changes.txt CHANGED
@@ -27,6 +27,9 @@ 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.13 (2015-02-25) =
31
  * Add some additional checks and error messages to postie_media_handle_upload for cases where the TMP directory isn't writable.
32
  * Any user with "Roles that can post" can now be the default poster.
27
  Attachments are now processed in the order they were attached.
28
 
29
  == CHANGELOG ==
30
+ = 1.6.14 (2015-02-26) =
31
+ * Fully support custom taxonomies
32
+
33
  = 1.6.13 (2015-02-25) =
34
  * Add some additional checks and error messages to postie_media_handle_upload for cases where the TMP directory isn't writable.
35
  * Any user with "Roles that can post" can now be the default poster.
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.13
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.14
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 1097447 2015-02-23 18:39:54Z WayneAllen $
4
  */
5
 
6
  //to turn on debug output add the following line to wp-config.php
@@ -279,7 +279,13 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $
279
  DebugEcho("post ubb: $content");
280
  }
281
 
282
- $post_categories = tag_Categories($subject, $config['default_post_category'], $config['category_match']);
 
 
 
 
 
 
283
  if ($fulldebug) {
284
  DebugEcho("post category: $content");
285
  }
@@ -326,11 +332,6 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $
326
  DebugEcho("post custom: $content");
327
  }
328
 
329
- $post_type = tag_PostType($subject, $postmodifiers, $config);
330
- if ($fulldebug) {
331
- DebugEcho("post type: $content");
332
- }
333
-
334
  $id = GetParentPostForReply($subject);
335
  if (empty($id)) {
336
  DebugEcho("Not a reply");
@@ -2679,8 +2680,9 @@ function tag_Excerpt(&$content, $config) {
2679
  * This function determines the categories ids for the post
2680
  * @return array
2681
  */
2682
- function tag_Categories(&$subject, $defaultCategory, $category_match) {
2683
  $original_subject = $subject;
 
2684
  $post_categories = array();
2685
  $matchtypes = array();
2686
  $matches = array();
@@ -2698,9 +2700,17 @@ function tag_Categories(&$subject, $defaultCategory, $category_match) {
2698
  if (preg_match('/(.+): (.*)/', $subject, $matches)) { // <category>:<Subject>
2699
  $category = lookup_category($matches[1], $category_match);
2700
  if (!empty($category)) {
 
2701
  DebugEcho("colon category: $category");
2702
  $subject = trim($matches[2]);
2703
- $post_categories[] = $category;
 
 
 
 
 
 
 
2704
  }
2705
  }
2706
 
@@ -2712,14 +2722,22 @@ function tag_Categories(&$subject, $defaultCategory, $category_match) {
2712
  foreach ($matches[1] as $match) {
2713
  $category = lookup_category($match, $category_match);
2714
  if (!empty($category)) {
 
2715
  $subject = str_replace($matches[0][$i], '', $subject);
2716
- $post_categories[] = $category;
 
 
 
 
 
 
 
2717
  }
2718
  $i++;
2719
  }
2720
  }
2721
  }
2722
- if (!count($post_categories)) {
2723
  $post_categories[] = $defaultCategory;
2724
  $subject = $original_subject;
2725
  }
@@ -2727,6 +2745,14 @@ function tag_Categories(&$subject, $defaultCategory, $category_match) {
2727
  return $post_categories;
2728
  }
2729
 
 
 
 
 
 
 
 
 
2730
  function lookup_category($trial_category, $category_match) {
2731
  global $wpdb;
2732
  $trial_category = trim($trial_category);
1
  <?php
2
  /*
3
+ $Id: postie-functions.php 1100752 2015-02-26 22:24:55Z WayneAllen $
4
  */
5
 
6
  //to turn on debug output add the following line to wp-config.php
279
  DebugEcho("post ubb: $content");
280
  }
281
 
282
+ //do post type before category to keep the subject line correct
283
+ $post_type = tag_PostType($subject, $postmodifiers, $config);
284
+ if ($fulldebug) {
285
+ DebugEcho("post type: $content");
286
+ }
287
+
288
+ $post_categories = tag_Categories($subject, $config['default_post_category'], $config['category_match'], $post_id);
289
  if ($fulldebug) {
290
  DebugEcho("post category: $content");
291
  }
332
  DebugEcho("post custom: $content");
333
  }
334
 
 
 
 
 
 
335
  $id = GetParentPostForReply($subject);
336
  if (empty($id)) {
337
  DebugEcho("Not a reply");
2680
  * This function determines the categories ids for the post
2681
  * @return array
2682
  */
2683
+ function tag_Categories(&$subject, $defaultCategory, $category_match, $post_id) {
2684
  $original_subject = $subject;
2685
+ $found = false;
2686
  $post_categories = array();
2687
  $matchtypes = array();
2688
  $matches = array();
2700
  if (preg_match('/(.+): (.*)/', $subject, $matches)) { // <category>:<Subject>
2701
  $category = lookup_category($matches[1], $category_match);
2702
  if (!empty($category)) {
2703
+ $found = true;
2704
  DebugEcho("colon category: $category");
2705
  $subject = trim($matches[2]);
2706
+ DebugEcho("colon category: subject: $subject");
2707
+ $tax = lookup_taxonomy($category);
2708
+ if ('category' == $tax) {
2709
+ $post_categories[] = $category;
2710
+ } else {
2711
+ DebugEcho("colon category: custom taxonomy $tax");
2712
+ wp_set_object_terms($post_id, $category, $tax);
2713
+ }
2714
  }
2715
  }
2716
 
2722
  foreach ($matches[1] as $match) {
2723
  $category = lookup_category($match, $category_match);
2724
  if (!empty($category)) {
2725
+ $found = true;
2726
  $subject = str_replace($matches[0][$i], '', $subject);
2727
+ DebugEcho("tag_Categories: subject: $subject");
2728
+ $tax = lookup_taxonomy($category);
2729
+ if ('category' == $tax) {
2730
+ $post_categories[] = $category;
2731
+ } else {
2732
+ DebugEcho("tag_Categories: custom taxonomy $tax");
2733
+ wp_set_object_terms($post_id, $category, $tax);
2734
+ }
2735
  }
2736
  $i++;
2737
  }
2738
  }
2739
  }
2740
+ if (!$found) {
2741
  $post_categories[] = $defaultCategory;
2742
  $subject = $original_subject;
2743
  }
2745
  return $post_categories;
2746
  }
2747
 
2748
+ function lookup_taxonomy($termid) {
2749
+ global $wpdb;
2750
+ $tax_sql = 'SELECT taxonomy FROM ' . $wpdb->term_taxonomy . ' WHERE term_id = ' . $termid;
2751
+ $tax = $wpdb->get_var($tax_sql);
2752
+ DebugEcho("lookup_taxonomy: $termid is in taxonomy $tax");
2753
+ return $tax;
2754
+ }
2755
+
2756
  function lookup_category($trial_category, $category_match) {
2757
  global $wpdb;
2758
  $trial_category = trim($trial_category);
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.13
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 1099450 2015-02-25 18:12:14Z WayneAllen $
31
  */
32
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
33
 
34
- define('POSTIE_VERSION', '1.6.13');
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.14
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
27
  */
28
 
29
  /*
30
+ $Id: postie.php 1100814 2015-02-26 23:13:36Z WayneAllen $
31
  */
32
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
33
 
34
+ define('POSTIE_VERSION', '1.6.14');
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.13
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -238,6 +238,9 @@ 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.13 (2015-02-25) =
242
  * Add some additional checks and error messages to postie_media_handle_upload for cases where the TMP directory isn't writable.
243
  * Any user with "Roles that can post" can now be the default poster.
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.14
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.14 (2015-02-26) =
242
+ * Fully support custom taxonomies
243
+
244
  = 1.6.13 (2015-02-25) =
245
  * Add some additional checks and error messages to postie_media_handle_upload for cases where the TMP directory isn't writable.
246
  * Any user with "Roles that can post" can now be the default poster.