Postie - Version 1.9.33

Version Description

(2019-04-29) = * Assign author to all media items

Download this release

Release Info

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

Code changes from version 1.9.32 to 1.9.33

Files changed (5) hide show
  1. docs/Changes.txt +3 -0
  2. docs/Postie.txt +2 -2
  3. postie.class.php +21 -15
  4. postie.php +3 -3
  5. readme.txt +5 -2
docs/Changes.txt CHANGED
@@ -35,6 +35,9 @@ All script, style and body tags are stripped from html emails.
35
  Attachments are now processed in the order they were attached.
36
 
37
  == CHANGELOG ==
 
 
 
38
  = 1.9.32 (2019-03-02) =
39
  * Move intermediate_image_sizes_advanced filter to only be effective when Postie is running
40
 
35
  Attachments are now processed in the order they were attached.
36
 
37
  == CHANGELOG ==
38
+ = 1.9.33 (2019-04-29) =
39
+ * Assign author to all media items
40
+
41
  = 1.9.32 (2019-03-02) =
42
  * Move intermediate_image_sizes_advanced filter to only be effective when Postie is running
43
 
docs/Postie.txt CHANGED
@@ -6,8 +6,8 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
- Tested up to: 5.1
10
- Stable tag: 1.9.32
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
6
  Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
+ Tested up to: 5.2
10
+ Stable tag: 1.9.33
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
postie.class.php CHANGED
@@ -145,7 +145,7 @@ class Postie {
145
  return false;
146
  }
147
 
148
- function save_attachments(&$email, $post_id, $config) {
149
  DebugEcho('save_attachments: ---- start');
150
 
151
  if (!isset($email['attachment'])) {
@@ -159,11 +159,11 @@ class Postie {
159
  }
160
 
161
  DebugEcho("save_attachments: [attachment]");
162
- $this->save_attachments_worker($email['attachment'], $post_id, $config);
163
  DebugEcho("save_attachments: [inline]");
164
- $this->save_attachments_worker($email['inline'], $post_id, $config);
165
  DebugEcho("save_attachments: [related]");
166
- $this->save_attachments_worker($email['related'], $post_id, $config);
167
 
168
 
169
  DebugEcho("save_attachments: ==== end");
@@ -192,7 +192,7 @@ class Postie {
192
  return false;
193
  }
194
 
195
- function save_attachments_worker(&$attachments, $post_id, $config) {
196
  DebugEcho("save_attachments_worker: start");
197
  foreach ($attachments as &$attachment) {
198
  foreach ($attachment as $key => $value) {
@@ -216,7 +216,7 @@ class Postie {
216
  DebugEcho('save_attachments_worker: un-named attachment');
217
  }
218
 
219
- $this->save_attachment($attachment, $post_id, $config);
220
 
221
  $filename = $attachment['wp_filename'];
222
  $fileext = $attachment['ext'];
@@ -366,7 +366,7 @@ class Postie {
366
  //DebugDump($wp_filter[$hook]->callbacks);
367
  }
368
 
369
- function save_attachment(&$attachment, $post_id, $config) {
370
 
371
  if (isset($attachment['filename']) && !empty($attachment['filename'])) {
372
  $filename = $attachment['filename'];
@@ -430,7 +430,7 @@ class Postie {
430
  //DebugDump($part);
431
 
432
  DebugEcho("save_attachment: text Attachement: $filename");
433
- $file_id = $this->media_handle_upload($attachment, $post_id);
434
  if (!is_wp_error($file_id)) {
435
  $attachment['wp_id'] = $file_id;
436
  DebugEcho("save_attachment: text attachment: adding '$filename'");
@@ -443,7 +443,7 @@ class Postie {
443
 
444
  case 'image':
445
  DebugEcho("save_attachment: image Attachement: $filename");
446
- $file_id = $this->media_handle_upload($attachment, $post_id);
447
  if (!is_wp_error($file_id)) {
448
  $attachment['wp_id'] = $file_id;
449
  //set the first image we come across as the featured image
@@ -459,7 +459,7 @@ class Postie {
459
 
460
  case 'audio':
461
  DebugEcho("save_attachment: audio Attachement: $filename");
462
- $file_id = $this->media_handle_upload($attachment, $post_id);
463
  if (!is_wp_error($file_id)) {
464
  $attachment['wp_id'] = $file_id;
465
  } else {
@@ -470,7 +470,7 @@ class Postie {
470
 
471
  case 'video':
472
  DebugEcho("save_attachment: video Attachement: $filename");
473
- $file_id = $this->media_handle_upload($attachment, $post_id);
474
  if (!is_wp_error($file_id)) {
475
  $attachment['wp_id'] = $file_id;
476
  } else {
@@ -487,7 +487,7 @@ class Postie {
487
  DebugEcho("save_attachment: found pgp-signature - done");
488
  break;
489
  }
490
- $file_id = $this->media_handle_upload($attachment, $post_id);
491
  if (!is_wp_error($file_id)) {
492
  $attachment['wp_id'] = $file_id;
493
  $file = wp_get_attachment_url($file_id);
@@ -531,7 +531,7 @@ class Postie {
531
  wp_mail($recipients, $subject, $message);
532
  }
533
 
534
- function media_handle_upload($attachment, $post_id) {
535
 
536
  $tmpFile = tempnam(get_temp_dir(), 'postie');
537
  if ($tmpFile !== false) {
@@ -566,9 +566,15 @@ class Postie {
566
  $id = media_handle_sideload($file_array, $post_id);
567
 
568
  if (!is_wp_error($id)) {
 
 
 
 
 
 
569
  $mediapath = get_attached_file($id);
570
  $file_array['tmp_name'] = $mediapath;
571
- DebugEcho("doing postie_file_added");
572
  do_action('postie_file_added', $post_id, $id, $file_array);
573
  } else {
574
  EchoError("There was an error adding the attachment: " . $id->get_error_message());
@@ -652,7 +658,7 @@ class Postie {
652
  DebugDump($mimeDecodedEmail);
653
  }
654
 
655
- $this->save_attachments($mimeDecodedEmail, $post_id, $config);
656
 
657
  $content = $this->get_content($mimeDecodedEmail, $config);
658
 
145
  return false;
146
  }
147
 
148
+ function save_attachments(&$email, $post_id, $config, $poster) {
149
  DebugEcho('save_attachments: ---- start');
150
 
151
  if (!isset($email['attachment'])) {
159
  }
160
 
161
  DebugEcho("save_attachments: [attachment]");
162
+ $this->save_attachments_worker($email['attachment'], $post_id, $config, $poster);
163
  DebugEcho("save_attachments: [inline]");
164
+ $this->save_attachments_worker($email['inline'], $post_id, $config, $poster);
165
  DebugEcho("save_attachments: [related]");
166
+ $this->save_attachments_worker($email['related'], $post_id, $config, $poster);
167
 
168
 
169
  DebugEcho("save_attachments: ==== end");
192
  return false;
193
  }
194
 
195
+ function save_attachments_worker(&$attachments, $post_id, $config, $poster) {
196
  DebugEcho("save_attachments_worker: start");
197
  foreach ($attachments as &$attachment) {
198
  foreach ($attachment as $key => $value) {
216
  DebugEcho('save_attachments_worker: un-named attachment');
217
  }
218
 
219
+ $this->save_attachment($attachment, $post_id, $config, $poster);
220
 
221
  $filename = $attachment['wp_filename'];
222
  $fileext = $attachment['ext'];
366
  //DebugDump($wp_filter[$hook]->callbacks);
367
  }
368
 
369
+ function save_attachment(&$attachment, $post_id, $config, $poster) {
370
 
371
  if (isset($attachment['filename']) && !empty($attachment['filename'])) {
372
  $filename = $attachment['filename'];
430
  //DebugDump($part);
431
 
432
  DebugEcho("save_attachment: text Attachement: $filename");
433
+ $file_id = $this->media_handle_upload($attachment, $post_id, $poster);
434
  if (!is_wp_error($file_id)) {
435
  $attachment['wp_id'] = $file_id;
436
  DebugEcho("save_attachment: text attachment: adding '$filename'");
443
 
444
  case 'image':
445
  DebugEcho("save_attachment: image Attachement: $filename");
446
+ $file_id = $this->media_handle_upload($attachment, $post_id, $poster);
447
  if (!is_wp_error($file_id)) {
448
  $attachment['wp_id'] = $file_id;
449
  //set the first image we come across as the featured image
459
 
460
  case 'audio':
461
  DebugEcho("save_attachment: audio Attachement: $filename");
462
+ $file_id = $this->media_handle_upload($attachment, $post_id, $poster);
463
  if (!is_wp_error($file_id)) {
464
  $attachment['wp_id'] = $file_id;
465
  } else {
470
 
471
  case 'video':
472
  DebugEcho("save_attachment: video Attachement: $filename");
473
+ $file_id = $this->media_handle_upload($attachment, $post_id, $poster);
474
  if (!is_wp_error($file_id)) {
475
  $attachment['wp_id'] = $file_id;
476
  } else {
487
  DebugEcho("save_attachment: found pgp-signature - done");
488
  break;
489
  }
490
+ $file_id = $this->media_handle_upload($attachment, $post_id, $poster);
491
  if (!is_wp_error($file_id)) {
492
  $attachment['wp_id'] = $file_id;
493
  $file = wp_get_attachment_url($file_id);
531
  wp_mail($recipients, $subject, $message);
532
  }
533
 
534
+ function media_handle_upload($attachment, $post_id, $poster) {
535
 
536
  $tmpFile = tempnam(get_temp_dir(), 'postie');
537
  if ($tmpFile !== false) {
566
  $id = media_handle_sideload($file_array, $post_id);
567
 
568
  if (!is_wp_error($id)) {
569
+ DebugEcho("media_handle_upload: changing owner to $poster");
570
+ wp_update_post(array(
571
+ 'ID' => $id,
572
+ 'post_author' => $poster,
573
+ ));
574
+
575
  $mediapath = get_attached_file($id);
576
  $file_array['tmp_name'] = $mediapath;
577
+ DebugEcho("media_handle_upload: doing postie_file_added");
578
  do_action('postie_file_added', $post_id, $id, $file_array);
579
  } else {
580
  EchoError("There was an error adding the attachment: " . $id->get_error_message());
658
  DebugDump($mimeDecodedEmail);
659
  }
660
 
661
+ $this->save_attachments($mimeDecodedEmail, $post_id, $config, $poster);
662
 
663
  $content = $this->get_content($mimeDecodedEmail, $config);
664
 
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.9.32
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL3
@@ -28,14 +28,14 @@
28
  */
29
 
30
  /*
31
- $Id: postie.php 2042984 2019-03-02 22:59:05Z WayneAllen $
32
  */
33
 
34
  if (!defined('WPINC')) {
35
  die; // Exit if accessed directly
36
  }
37
 
38
- define('POSTIE_VERSION', '1.9.32');
39
  define('POSTIE_ROOT', dirname(__FILE__));
40
  define('POSTIE_URL', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
41
 
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.9.33
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL3
28
  */
29
 
30
  /*
31
+ $Id: postie.php 2077502 2019-04-30 04:08:22Z WayneAllen $
32
  */
33
 
34
  if (!defined('WPINC')) {
35
  die; // Exit if accessed directly
36
  }
37
 
38
+ define('POSTIE_VERSION', '1.9.33');
39
  define('POSTIE_ROOT', dirname(__FILE__));
40
  define('POSTIE_URL', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
41
 
readme.txt CHANGED
@@ -6,8 +6,8 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
- Tested up to: 5.1
10
- Stable tag: 1.9.32
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -107,6 +107,9 @@ All script, style and body tags are stripped from html emails.
107
  Attachments are now processed in the order they were attached.
108
 
109
  == CHANGELOG ==
 
 
 
110
  = 1.9.32 (2019-03-02) =
111
  * Move intermediate_image_sizes_advanced filter to only be effective when Postie is running
112
 
6
  Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
+ Tested up to: 5.2
10
+ Stable tag: 1.9.33
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
107
  Attachments are now processed in the order they were attached.
108
 
109
  == CHANGELOG ==
110
+ = 1.9.33 (2019-04-29) =
111
+ * Assign author to all media items
112
+
113
  = 1.9.32 (2019-03-02) =
114
  * Move intermediate_image_sizes_advanced filter to only be effective when Postie is running
115