Attachments - Version 3.5.3

Version Description

  • Cleaned up PHP Warning/Notice (props Mike C.)
  • Fixed a potential fatal error triggered by deleting something from the Media library that was an Attachment
  • Tested with WordPress 3.7
Download this release

Release Info

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

Code changes from version 3.5.2 to 3.5.3

classes/class.attachments.php CHANGED
@@ -55,7 +55,7 @@ if( !class_exists( 'Attachments' ) ) :
55
  global $_wp_additional_image_sizes;
56
 
57
  // establish our environment variables
58
- $this->version = '3.5.2';
59
  $this->url = ATTACHMENTS_URL;
60
  $this->dir = ATTACHMENTS_DIR;
61
  $plugin = 'attachments/index.php';
@@ -1543,7 +1543,18 @@ if( !class_exists( 'Attachments' ) ) :
1543
  // loop through each Attachment of this instance
1544
  foreach( $instance_attachments as $key => $attachment )
1545
  {
1546
- $attachment_exists = isset( $attachment['id'] ) ? get_post( $attachment['id'] ) : false;
 
 
 
 
 
 
 
 
 
 
 
1547
  // make sure the attachment exists
1548
  if( $attachment_exists )
1549
  {
55
  global $_wp_additional_image_sizes;
56
 
57
  // establish our environment variables
58
+ $this->version = '3.5.3';
59
  $this->url = ATTACHMENTS_URL;
60
  $this->dir = ATTACHMENTS_DIR;
61
  $plugin = 'attachments/index.php';
1543
  // loop through each Attachment of this instance
1544
  foreach( $instance_attachments as $key => $attachment )
1545
  {
1546
+ // see if it was pulled as JSON from a delete cleanup
1547
+ if( is_object( $attachment ) )
1548
+ {
1549
+ $attachment = get_object_vars( $attachment );
1550
+ if( is_array( $attachment ) && !empty( $attachment ) )
1551
+ {
1552
+ if( isset( $attachment['fields'] ) && is_object( $attachment['fields'] ) )
1553
+ $attachment['fields'] = get_object_vars( $attachment['fields'] );
1554
+ }
1555
+ }
1556
+
1557
+ $attachment_exists = isset( $attachment['id'] ) ? get_post( absint( $attachment['id'] ) ) : false;
1558
  // make sure the attachment exists
1559
  if( $attachment_exists )
1560
  {
classes/class.attachments.search.php CHANGED
@@ -132,10 +132,11 @@ class AttachmentsSearch extends Attachments
132
  else
133
  {
134
  // we want to check all fields
135
- foreach( $potential_attachments[$i]->fields as $field_name => $field_value )
136
- if( empty( $query ) || strpos( strtolower( $field_value) , strtolower( $query ) ) !== false )
137
- if( is_null( $params['filetype'] ) || ( !is_null( $params['filetype'] ) && in_array( parent::get_mime_type( $potential_attachments[$i]->id ), $params['filetype'] ) ) )
138
- $valid = true;
 
139
  }
140
 
141
  if( !$valid )
@@ -147,10 +148,9 @@ class AttachmentsSearch extends Attachments
147
  // limit to attachment ID if applicable
148
  if( $params['attachment_id'] )
149
  {
150
- $total_potentials = count( $potential_attachments );
151
- for( $i = 0; $i < $total_potentials; $i++ )
152
- if( $potential_attachments[$i]->id != $params['attachment_id'] )
153
- unset( $potential_attachments[$i] );
154
  }
155
 
156
  $this->results = array_values( $potential_attachments );
132
  else
133
  {
134
  // we want to check all fields
135
+ if( isset( $potential_attachments[$i]->fields ) )
136
+ foreach( $potential_attachments[$i]->fields as $field_name => $field_value )
137
+ if( empty( $query ) || strpos( strtolower( $field_value) , strtolower( $query ) ) !== false )
138
+ if( is_null( $params['filetype'] ) || ( !is_null( $params['filetype'] ) && in_array( parent::get_mime_type( $potential_attachments[$i]->id ), $params['filetype'] ) ) )
139
+ $valid = true;
140
  }
141
 
142
  if( !$valid )
148
  // limit to attachment ID if applicable
149
  if( $params['attachment_id'] )
150
  {
151
+ foreach( $potential_attachments as $key => $value )
152
+ if( $potential_attachments[$key]->id != $params['attachment_id'] )
153
+ unset( $potential_attachments[$key] );
 
154
  }
155
 
156
  $this->results = array_values( $potential_attachments );
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.5.2
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.5.3
10
  * Text Domain: attachments
11
  * Domain Path: /languages/
12
  * License: GPLv2 or later
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: jchristopher
3
  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.6.1
7
- Stable tag: 3.5.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -91,6 +91,11 @@ Please see [Issues on GitHub](https://github.com/jchristopher/attachments/issues
91
 
92
  Please see [Attachments' changelog on GitHub](https://github.com/jchristopher/attachments/docs/changelog.md)
93
 
 
 
 
 
 
94
  = 3.5.2 =
95
  * Fixed an issue where newline characters may not be properly retrieved
96
  * Fixed an issue with localization not initializing properly
3
  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.7
7
+ Stable tag: 3.5.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
91
 
92
  Please see [Attachments' changelog on GitHub](https://github.com/jchristopher/attachments/docs/changelog.md)
93
 
94
+ = 3.5.3 =
95
+ * Cleaned up PHP Warning/Notice (props Mike C.)
96
+ * Fixed a potential fatal error triggered by deleting something from the Media library that was an Attachment
97
+ * Tested with WordPress 3.7
98
+
99
  = 3.5.2 =
100
  * Fixed an issue where newline characters may not be properly retrieved
101
  * Fixed an issue with localization not initializing properly