Attachments - Version 1.0.4

Version Description

  • Fixed a potential error resulting in PHP issuing a Warning when trying to attach Attachments
Download this release

Release Info

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

Code changes from version 1.0.3 to 1.0.4

Files changed (2) hide show
  1. attachments.php +35 -32
  2. readme.txt +4 -1
attachments.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Attachments
4
  Plugin URI: http://mondaybynoon.com/wordpress-attachments/
5
  Description: Attachments gives the ability to append any number of Media Library items to Pages and Posts
6
- Version: 1.0.3
7
  Author: Jonathan Christopher
8
  Author URI: http://jchristopher.me
9
  */
@@ -93,39 +93,42 @@ function attachments_add()
93
  usort($existing_attachments, "cmp");
94
  }
95
  $attachment_index = 0;
96
- foreach ($existing_attachments as $attachment) : $attachment_index++; ?>
97
- <li class="attachments-file">
98
- <h2>
99
- <a href="#" class="attachment-handle">
100
- <span class="attachment-handle-icon"><img src="<?=WP_PLUGIN_URL?>/attachments/images/handle.gif" alt="Drag" /></span>
101
- </a>
102
- <span class="attachment-name"><?=$attachment['name']?></span>
103
- <span class="attachment-delete"><a href="#">Delete</a></span>
104
- </h2>
105
- <div class="attachments-fields">
106
- <div class="textfield" id="field_attachment_title_<?=$attachment_index?>">
107
- <label for="attachment_title_<?=$attachment_index?>">Title</label>
108
- <input type="text" id="attachment_title_<?=$attachment_index?>" name="attachment_title_<?=$attachment_index?>" value="<?=$attachment['title']?>" size="20" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  </div>
110
- <div class="textfield" id="field_attachment_caption_<?=$attachment_index?>">
111
- <label for="attachment_caption_<?=$attachment_index?>">Caption</label>
112
- <input type="text" id="attachment_caption_<?=$attachment_index?>" name="attachment_caption_<?=$attachment_index?>" value="<?=$attachment['caption']?>" size="20" />
 
113
  </div>
114
- </div>
115
- <div class="attachments-data">
116
- <input type="hidden" name="attachment_name_<?=$attachment_index?>" id="attachment_name_<?=$attachment_index?>" value="<?=$attachment['name']?>" />
117
- <input type="hidden" name="attachment_location_<?=$attachment_index?>" id="attachment_location_<?=$attachment_index?>" value="<?=$attachment['location']?>" />
118
- <input type="hidden" name="attachment_mime_<?=$attachment_index?>" id="attachment_mime_<?=$attachment_index?>" value="<?=$attachment['mime']?>" />
119
- <input type="hidden" name="attachment_id_<?=$attachment_index?>" id="attachment_id_<?=$attachment_index?>" value="<?=$attachment['id']?>" />
120
- <input type="hidden" class="attachment_order" name="attachment_order_<?=$attachment_index?>" id="attachment_order_<?=$attachment_index?>" value="<?=$attachment['order']?>" />
121
- </div>
122
- <div class="attachment-thumbnail">
123
- <span class="attachments-thumbnail">
124
- <?=wp_get_attachment_image( $attachment['id'], array(80, 60), true );?>
125
- </span>
126
- </div>
127
- </li>
128
- <?php endforeach;
129
  }
130
  }
131
  ?>
3
  Plugin Name: Attachments
4
  Plugin URI: http://mondaybynoon.com/wordpress-attachments/
5
  Description: Attachments gives the ability to append any number of Media Library items to Pages and Posts
6
+ Version: 1.0.4
7
  Author: Jonathan Christopher
8
  Author URI: http://jchristopher.me
9
  */
93
  usort($existing_attachments, "cmp");
94
  }
95
  $attachment_index = 0;
96
+ if( is_array($existing_attachments) && !empty($existing_attachments) )
97
+ {
98
+ foreach ($existing_attachments as $attachment) : $attachment_index++; ?>
99
+ <li class="attachments-file">
100
+ <h2>
101
+ <a href="#" class="attachment-handle">
102
+ <span class="attachment-handle-icon"><img src="<?=WP_PLUGIN_URL?>/attachments/images/handle.gif" alt="Drag" /></span>
103
+ </a>
104
+ <span class="attachment-name"><?=$attachment['name']?></span>
105
+ <span class="attachment-delete"><a href="#">Delete</a></span>
106
+ </h2>
107
+ <div class="attachments-fields">
108
+ <div class="textfield" id="field_attachment_title_<?=$attachment_index?>">
109
+ <label for="attachment_title_<?=$attachment_index?>">Title</label>
110
+ <input type="text" id="attachment_title_<?=$attachment_index?>" name="attachment_title_<?=$attachment_index?>" value="<?=$attachment['title']?>" size="20" />
111
+ </div>
112
+ <div class="textfield" id="field_attachment_caption_<?=$attachment_index?>">
113
+ <label for="attachment_caption_<?=$attachment_index?>">Caption</label>
114
+ <input type="text" id="attachment_caption_<?=$attachment_index?>" name="attachment_caption_<?=$attachment_index?>" value="<?=$attachment['caption']?>" size="20" />
115
+ </div>
116
+ </div>
117
+ <div class="attachments-data">
118
+ <input type="hidden" name="attachment_name_<?=$attachment_index?>" id="attachment_name_<?=$attachment_index?>" value="<?=$attachment['name']?>" />
119
+ <input type="hidden" name="attachment_location_<?=$attachment_index?>" id="attachment_location_<?=$attachment_index?>" value="<?=$attachment['location']?>" />
120
+ <input type="hidden" name="attachment_mime_<?=$attachment_index?>" id="attachment_mime_<?=$attachment_index?>" value="<?=$attachment['mime']?>" />
121
+ <input type="hidden" name="attachment_id_<?=$attachment_index?>" id="attachment_id_<?=$attachment_index?>" value="<?=$attachment['id']?>" />
122
+ <input type="hidden" class="attachment_order" name="attachment_order_<?=$attachment_index?>" id="attachment_order_<?=$attachment_index?>" value="<?=$attachment['order']?>" />
123
  </div>
124
+ <div class="attachment-thumbnail">
125
+ <span class="attachments-thumbnail">
126
+ <?=wp_get_attachment_image( $attachment['id'], array(80, 60), true );?>
127
+ </span>
128
  </div>
129
+ </li>
130
+ <?php endforeach;
131
+ }
 
 
 
 
 
 
 
 
 
 
 
 
132
  }
133
  }
134
  ?>
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: 2.8
6
  Tested up to: 2.9
7
- Stable tag: 1.0.3
8
 
9
  Attachments allows you to append any number of items from your WordPress Media Library to Posts and Pages
10
 
@@ -33,6 +33,9 @@ Attachments uses WordPress' built in Media library for uploads and storage.
33
 
34
  == Changelog ==
35
 
 
 
 
36
  = 1.0.3 =
37
  * Fixed an issue when `attachments_get_attachments()` returning no Attachments generating a warning
38
 
4
  Tags: post, page, posts, pages, images, PDF, doc, Word, image, jpg, jpeg, picture, pictures, photos, attachment
5
  Requires at least: 2.8
6
  Tested up to: 2.9
7
+ Stable tag: 1.0.4
8
 
9
  Attachments allows you to append any number of items from your WordPress Media Library to Posts and Pages
10
 
33
 
34
  == Changelog ==
35
 
36
+ = 1.0.4 =
37
+ * Fixed a potential error resulting in PHP issuing a Warning when trying to attach Attachments
38
+
39
  = 1.0.3 =
40
  * Fixed an issue when `attachments_get_attachments()` returning no Attachments generating a warning
41