Attachments - Version 3.0.7

Version Description

  • Proper sanitization of Custom Post Type names (as WordPress does it)
Download this release

Release Info

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

Code changes from version 3.0.6 to 3.0.7

Files changed (4) hide show
  1. README.md +3 -0
  2. classes/class.attachments.php +7 -1
  3. index.php +1 -1
  4. readme.txt +4 -0
README.md CHANGED
@@ -246,6 +246,9 @@ Attachments uses WordPress' built in Media library for uploads and storage.
246
 
247
  <dl>
248
 
 
 
 
249
  <dt>3.0.6</dt>
250
  <dd>Fixed a possible JavaScript error if an Attachment that's an image doesn't have a proper thumbnail URL</dd>
251
  <dd>Added a total() method that will return the number of Attachments for the current instance</dd>
246
 
247
  <dl>
248
 
249
+ <dt>3.0.7</dt>
250
+ <dd>Proper sanitization of Custom Post Type names (as WordPress does it)</dd>
251
+
252
  <dt>3.0.6</dt>
253
  <dd>Fixed a possible JavaScript error if an Attachment that's an image doesn't have a proper thumbnail URL</dd>
254
  <dd>Added a total() method that will return the number of Attachments for the current instance</dd>
classes/class.attachments.php CHANGED
@@ -56,7 +56,7 @@ if ( !class_exists( 'Attachments' ) ) :
56
  global $_wp_additional_image_sizes;
57
 
58
  // establish our environment variables
59
- $this->version = '3.0.6';
60
  $this->url = ATTACHMENTS_URL;
61
  $this->dir = ATTACHMENTS_DIR;
62
 
@@ -685,6 +685,12 @@ if ( !class_exists( 'Attachments' ) ) :
685
  }
686
  }
687
 
 
 
 
 
 
 
688
  // make sure the instance name is proper
689
  $instance = str_replace( '-', '_', sanitize_title( $name ) );
690
 
56
  global $_wp_additional_image_sizes;
57
 
58
  // establish our environment variables
59
+ $this->version = '3.0.7';
60
  $this->url = ATTACHMENTS_URL;
61
  $this->dir = ATTACHMENTS_DIR;
62
 
685
  }
686
  }
687
 
688
+ // WordPress sanitizes post type names when registering, so we will too
689
+ foreach( $params['post_type'] as $key => $post_type )
690
+ $params['post_type'][$key] = sanitize_key( $post_type );
691
+
692
+ // print_r($params['post_type']);
693
+
694
  // make sure the instance name is proper
695
  $instance = str_replace( '-', '_', sanitize_title( $name ) );
696
 
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.0.6
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.0.7
10
  * Text Domain: attachments
11
  * Domain Path: /languages/
12
  * License: GPLv2 or later
readme.txt CHANGED
@@ -29,6 +29,7 @@ The idea behind Attachments is to give developers the ability to directly associ
29
  `<?php $attachments = new Attachments( 'attachments' ); /* pass the instance name */ ?>
30
  <?php if( $attachments->exist() ) : ?>
31
  <h3>Attachments</h3>
 
32
  <ul>
33
  <?php while( $attachments->get() ) : ?>
34
  <li>
@@ -94,6 +95,9 @@ Attachments uses WordPress' built in Media library for uploads and storage.
94
 
95
  == Changelog ==
96
 
 
 
 
97
  = 3.0.6 =
98
  * Fixed a possible JavaScript error if an Attachment that's an image doesn't have a proper thumbnail URL
99
  * Added a total() method that will return the number of Attachments for the current instance
29
  `<?php $attachments = new Attachments( 'attachments' ); /* pass the instance name */ ?>
30
  <?php if( $attachments->exist() ) : ?>
31
  <h3>Attachments</h3>
32
+ <p>Total Attachments: <?php echo $attachments->total(); ?></p>
33
  <ul>
34
  <?php while( $attachments->get() ) : ?>
35
  <li>
95
 
96
  == Changelog ==
97
 
98
+ = 3.0.7 =
99
+ * Proper sanitization of Custom Post Type names (as WordPress does it)
100
+
101
  = 3.0.6 =
102
  * Fixed a possible JavaScript error if an Attachment that's an image doesn't have a proper thumbnail URL
103
  * Added a total() method that will return the number of Attachments for the current instance