Attachments - Version 3.1.4

Version Description

  • Changed 'Delete' to 'Remove' so as to not make it sound like the file itself would be deleted from Media (props Lane Goldberg)
  • Better handling of posts that have no Attachments when saving
Download this release

Release Info

Developer jchristopher
Plugin Icon wp plugin Attachments
Version 3.1.4
Comparing to
See all releases

Code changes from version 3.1.3 to 3.1.4

Files changed (4) hide show
  1. README.md +4 -0
  2. classes/class.attachments.php +16 -6
  3. index.php +1 -1
  4. readme.txt +5 -1
README.md CHANGED
@@ -250,6 +250,10 @@ Attachments uses WordPress' built in Media library for uploads and storage.
250
 
251
  <dl>
252
 
 
 
 
 
253
  <dt>3.1.3</dt>
254
  <dd>Fixed a potential issue with the WYSIWYG field not working on CPT without editor support</dd>
255
  <dd>Field assets are less aggressive and only fire when necessary</dd>
250
 
251
  <dl>
252
 
253
+ <dt>3.1.4</dt>
254
+ <dd>Changed 'Delete' to 'Remove' so as to not make it sound like the file itself would be deleted from Media (props Lane Goldberg)</dd>
255
+ <dd>Better handling of posts that have no Attachments when saving</dd>
256
+
257
  <dt>3.1.3</dt>
258
  <dd>Fixed a potential issue with the WYSIWYG field not working on CPT without editor support</dd>
259
  <dd>Field assets are less aggressive and only fire when necessary</dd>
classes/class.attachments.php CHANGED
@@ -59,7 +59,7 @@ if ( !class_exists( 'Attachments' ) ) :
59
 
60
  // establish our environment variables
61
 
62
- $this->version = '3.1.3';
63
  $this->url = ATTACHMENTS_URL;
64
  $this->dir = ATTACHMENTS_DIR;
65
 
@@ -961,7 +961,7 @@ if ( !class_exists( 'Attachments' ) ) :
961
  <?php if( ( isset( $attachment->id ) && isset( $attachment->width ) ) || !isset( $attachment->id ) ) : ?>
962
  <div class="dimensions"><?php echo isset( $attachment->width ) ? $attachment->width : '{{ attachments.width }}' ; ?> &times; <?php echo isset( $attachment->height ) ? $attachment->height : '{{ attachments.height }}' ; ?></div>
963
  <?php endif; ?>
964
- <div class="delete-attachment"><a href="#"><?php _e( 'Delete', 'attachments' ); ?></a></div>
965
  </div>
966
  </div>
967
 
@@ -1142,11 +1142,21 @@ if ( !class_exists( 'Attachments' ) ) :
1142
  }
1143
  }
1144
 
1145
- // we're going to store JSON (JSON_UNESCAPED_UNICODE is PHP 5.4+)
1146
- $attachments = version_compare( PHP_VERSION, '5.4.0', '>=' ) ? json_encode( $attachments, JSON_UNESCAPED_UNICODE ) : json_encode( $attachments );
 
 
 
 
 
 
 
 
 
 
 
1147
 
1148
- // we're going to wipe out any existing Attachments meta (because we'll put it back)
1149
- update_post_meta( $post_id, $this->meta_key, $attachments );
1150
  }
1151
 
1152
 
59
 
60
  // establish our environment variables
61
 
62
+ $this->version = '3.1.4';
63
  $this->url = ATTACHMENTS_URL;
64
  $this->dir = ATTACHMENTS_DIR;
65
 
961
  <?php if( ( isset( $attachment->id ) && isset( $attachment->width ) ) || !isset( $attachment->id ) ) : ?>
962
  <div class="dimensions"><?php echo isset( $attachment->width ) ? $attachment->width : '{{ attachments.width }}' ; ?> &times; <?php echo isset( $attachment->height ) ? $attachment->height : '{{ attachments.height }}' ; ?></div>
963
  <?php endif; ?>
964
+ <div class="delete-attachment"><a href="#"><?php _e( 'Remove', 'attachments' ); ?></a></div>
965
  </div>
966
  </div>
967
 
1142
  }
1143
  }
1144
 
1145
+ if( !empty( $attachments ) )
1146
+ {
1147
+ // we're going to store JSON (JSON_UNESCAPED_UNICODE is PHP 5.4+)
1148
+ $attachments = version_compare( PHP_VERSION, '5.4.0', '>=' ) ? json_encode( $attachments, JSON_UNESCAPED_UNICODE ) : json_encode( $attachments );
1149
+
1150
+ // we're going to wipe out any existing Attachments meta (because we'll put it back)
1151
+ update_post_meta( $post_id, $this->meta_key, $attachments );
1152
+ }
1153
+ else
1154
+ {
1155
+ // there are no attachments so we'll clean up the record
1156
+ delete_post_meta( $post_id, $this->meta_key );
1157
+ }
1158
 
1159
+ return $post_id;
 
1160
  }
1161
 
1162
 
index.php CHANGED
@@ -6,7 +6,7 @@
6
  * Description: Attachments gives the ability to append any number of Media Library items to Pages, Posts, and Custom Post Types
7
  * Author: Jonathan Christopher
8
  * Author URI: http://mondaybynoon.com/
9
- * Version: 3.1.3
10
  * Text Domain: attachments
11
  * Domain Path: /languages/
12
  * License: GPLv2 or later
6
  * Description: Attachments gives the ability to append any number of Media Library items to Pages, Posts, and Custom Post Types
7
  * Author: Jonathan Christopher
8
  * Author URI: http://mondaybynoon.com/
9
+ * Version: 3.1.4
10
  * Text Domain: attachments
11
  * Domain Path: /languages/
12
  * License: GPLv2 or later
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://mondaybynoon.com/donate/
4
  Tags: post, page, posts, pages, images, PDF, doc, Word, image, jpg, jpeg, picture, pictures, photos, attachment
5
  Requires at least: 3.0
6
  Tested up to: 3.5
7
- Stable tag: 3.1.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -95,6 +95,10 @@ Attachments uses WordPress' built in Media library for uploads and storage.
95
 
96
  == Changelog ==
97
 
 
 
 
 
98
  = 3.1.3 =
99
  * Fixed a potential issue with the WYSIWYG field not working on CPT without editor support
100
  * Field assets are less aggressive and only fire when necessary
4
  Tags: post, page, posts, pages, images, PDF, doc, Word, image, jpg, jpeg, picture, pictures, photos, attachment
5
  Requires at least: 3.0
6
  Tested up to: 3.5
7
+ Stable tag: 3.1.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
95
 
96
  == Changelog ==
97
 
98
+ = 3.1.4 =
99
+ * Changed 'Delete' to 'Remove' so as to not make it sound like the file itself would be deleted from Media (props Lane Goldberg)
100
+ * Better handling of posts that have no Attachments when saving
101
+
102
  = 3.1.3 =
103
  * Fixed a potential issue with the WYSIWYG field not working on CPT without editor support
104
  * Field assets are less aggressive and only fire when necessary