Attachments - Version 1.5.4

Version Description

  • Updated the way Thickbox is hijacked in an effort to be more stable among tab switching. As an unfortunate result, bulk attaching is no longer possible.
  • Added environment check in preparation for future feature updates
  • Updated Polish translation, courtesy of Wiktor Maj
Download this release

Release Info

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

Code changes from version 1.5.3.2 to 1.5.4

attachments-pl_PL.mo DELETED
Binary file
attachments.php CHANGED
@@ -3,12 +3,12 @@
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, Posts, and Custom Post Types
6
- Version: 1.5.3.2
7
  Author: Jonathan Christopher
8
  Author URI: http://mondaybynoon.com/
9
  */
10
 
11
- /* Copyright 2009 Jonathan Christopher (email : jonathandchr@gmail.com)
12
 
13
  This program is free software; you can redistribute it and/or modify
14
  it under the terms of the GNU General Public License as published by
@@ -26,6 +26,11 @@
26
  */
27
 
28
 
 
 
 
 
 
29
  // ===========
30
  // = GLOBALS =
31
  // ===========
@@ -33,17 +38,35 @@
33
  global $wpdb;
34
 
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  // =========
38
  // = HOOKS =
39
  // =========
40
- if( is_admin() )
41
  {
42
  add_action( 'admin_menu', 'attachments_init' );
43
  add_action( 'admin_head', 'attachments_init_js' );
44
  add_action( 'save_post', 'attachments_save' );
45
  add_action( 'admin_menu', 'attachments_menu' );
46
- add_action( 'admin_init', 'fix_async_upload_image' );
 
47
  }
48
 
49
 
@@ -200,7 +223,7 @@ function attachments_meta_box()
200
  $args = array(
201
  'public' => true,
202
  'show_ui' => true
203
- );
204
  $output = 'objects';
205
  $operator = 'and';
206
  $post_types = get_post_types( $args, $output, $operator );
@@ -230,22 +253,6 @@ function attachments_init_js()
230
  echo '<script type="text/javascript" charset="utf-8">';
231
  echo ' var attachments_base = "' . WP_PLUGIN_URL . '/attachments"; ';
232
  echo ' var attachments_media = ""; ';
233
- if ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow )
234
- {
235
- echo ' var attachments_upload = true; ';
236
- }
237
- else
238
- {
239
- echo ' var attachments_upload = false; ';
240
- }
241
- if( ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow ) && is_attachments_context() )
242
- {
243
- echo ' var attachments_is_attachments_context = true; ';
244
- }
245
- else
246
- {
247
- echo ' var attachments_is_attachments_context = false; ';
248
- }
249
  echo '</script>';
250
  }
251
 
@@ -344,7 +351,7 @@ function attachments_save($post_id)
344
  if( get_option( 'attachments_store_native' ) == 'true' )
345
  {
346
  // need to first check to make sure we're not overwriting a native Attach
347
- $attach_post_ref = get_post( $attachment_id );
348
 
349
  if( $attach_post_ref->post_parent == 0 )
350
  {
@@ -419,7 +426,7 @@ function attachments_get_attachments( $post_id=null )
419
  // We can now proceed as normal, all legacy data should now be upgraded
420
 
421
  $post_attachments = array();
422
-
423
  if( is_array( $existing_attachments ) && count( $existing_attachments ) > 0 )
424
  {
425
 
@@ -450,38 +457,6 @@ function attachments_get_attachments( $post_id=null )
450
  }
451
 
452
 
453
- if( !function_exists( 'fix_async_upload_image' ) )
454
- {
455
- function fix_async_upload_image() {
456
- if( isset( $_REQUEST['attachment_id'] ) )
457
- {
458
- $GLOBALS['post'] = get_post( $_REQUEST['attachment_id'] );
459
- }
460
- }
461
- }
462
-
463
- function is_attachments_context()
464
- {
465
- global $pagenow;
466
-
467
- // if post_id is set, it's the editor upload...
468
- if ( !isset( $_REQUEST['post_id'] ) || ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow ) && ( empty( $_REQUEST['post_id'] ) && $_REQUEST['post_id'] != '0' ) )
469
- {
470
- return true;
471
- }
472
- return false;
473
- }
474
-
475
- function hijack_thickbox_text($translated_text, $source_text, $domain)
476
- {
477
- if ( is_attachments_context() )
478
- {
479
- if ('Insert into Post' == $source_text) {
480
- return __('Attach', 'attachments' );
481
- }
482
- }
483
- return $translated_text;
484
- }
485
 
486
 
487
 
@@ -501,11 +476,6 @@ function attachments_init()
501
  wp_enqueue_script( 'jquery-ui-core' );
502
  wp_enqueue_style( 'thickbox' );
503
 
504
- if ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow )
505
- {
506
- add_filter( 'gettext', 'hijack_thickbox_text', 1, 3 );
507
- }
508
-
509
  wp_enqueue_style( 'attachments', WP_PLUGIN_URL . '/attachments/css/attachments.css' );
510
  wp_enqueue_script( 'attachments', WP_PLUGIN_URL . '/attachments/js/attachments.js', array( 'jquery', 'thickbox' ), false, false );
511
 
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, Posts, and Custom Post Types
6
+ Version: 1.5.4
7
  Author: Jonathan Christopher
8
  Author URI: http://mondaybynoon.com/
9
  */
10
 
11
+ /* Copyright 2009-2011 Jonathan Christopher (email : jonathan@irontoiron.com)
12
 
13
  This program is free software; you can redistribute it and/or modify
14
  it under the terms of the GNU General Public License as published by
26
  */
27
 
28
 
29
+ // constant definition
30
+ if( !defined( 'IS_ADMIN' ) )
31
+ define( 'IS_ADMIN', is_admin() );
32
+
33
+
34
  // ===========
35
  // = GLOBALS =
36
  // ===========
38
  global $wpdb;
39
 
40
 
41
+ // environment check
42
+ $wp_version = get_bloginfo( 'version' );
43
+ if( !version_compare( PHP_VERSION, '5.2', '>=' ) || !version_compare( $wp_version, '3.0', '>=' ) )
44
+ {
45
+ if( IS_ADMIN && ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) )
46
+ {
47
+ require_once ABSPATH.'/wp-admin/includes/plugin.php';
48
+ deactivate_plugins( __FILE__ );
49
+ wp_die( __('Attachments requires PHP 5.2 or higher, as will WordPress 3.2 and higher. It has been automatically deactivated.') );
50
+ }
51
+ else
52
+ {
53
+ return;
54
+ }
55
+ }
56
+
57
+
58
 
59
  // =========
60
  // = HOOKS =
61
  // =========
62
+ if( IS_ADMIN )
63
  {
64
  add_action( 'admin_menu', 'attachments_init' );
65
  add_action( 'admin_head', 'attachments_init_js' );
66
  add_action( 'save_post', 'attachments_save' );
67
  add_action( 'admin_menu', 'attachments_menu' );
68
+
69
+ load_plugin_textdomain( 'attachments', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
70
  }
71
 
72
 
223
  $args = array(
224
  'public' => true,
225
  'show_ui' => true
226
+ );
227
  $output = 'objects';
228
  $operator = 'and';
229
  $post_types = get_post_types( $args, $output, $operator );
253
  echo '<script type="text/javascript" charset="utf-8">';
254
  echo ' var attachments_base = "' . WP_PLUGIN_URL . '/attachments"; ';
255
  echo ' var attachments_media = ""; ';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  echo '</script>';
257
  }
258
 
351
  if( get_option( 'attachments_store_native' ) == 'true' )
352
  {
353
  // need to first check to make sure we're not overwriting a native Attach
354
+ $attach_post_ref = get_post( $attachment_id );
355
 
356
  if( $attach_post_ref->post_parent == 0 )
357
  {
426
  // We can now proceed as normal, all legacy data should now be upgraded
427
 
428
  $post_attachments = array();
429
+
430
  if( is_array( $existing_attachments ) && count( $existing_attachments ) > 0 )
431
  {
432
 
457
  }
458
 
459
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
460
 
461
 
462
 
476
  wp_enqueue_script( 'jquery-ui-core' );
477
  wp_enqueue_style( 'thickbox' );
478
 
 
 
 
 
 
479
  wp_enqueue_style( 'attachments', WP_PLUGIN_URL . '/attachments/css/attachments.css' );
480
  wp_enqueue_script( 'attachments', WP_PLUGIN_URL . '/attachments/js/attachments.js', array( 'jquery', 'thickbox' ), false, false );
481
 
js/attachments.js CHANGED
@@ -1,168 +1,154 @@
1
- function str_replace (search, replace, subject, count) {
2
- // http://kevin.vanzonneveld.net
3
- // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
4
- // + improved by: Gabriel Paderni
5
- // + improved by: Philip Peterson
6
- // + improved by: Simon Willison (http://simonwillison.net)
7
- // + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
8
- // + bugfixed by: Anton Ongson
9
- // + input by: Onno Marsman
10
- // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
11
- // + tweaked by: Onno Marsman
12
- // + input by: Brett Zamir (http://brett-zamir.me)
13
- // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
14
- // + input by: Oleg Eremeev
15
- // + improved by: Brett Zamir (http://brett-zamir.me)
16
- // + bugfixed by: Oleg Eremeev
17
- // % note 1: The count parameter must be passed as a string in order
18
- // % note 1: to find a global variable in which the result will be given
19
- // * example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
20
- // * returns 1: 'Kevin.van.Zonneveld'
21
- // * example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
22
- // * returns 2: 'hemmo, mars'
23
-
24
- var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
25
- f = [].concat(search),
26
- r = [].concat(replace),
27
- s = subject,
28
- ra = r instanceof Array, sa = s instanceof Array;
29
- s = [].concat(s);
30
- if (count) {
31
- this.window[count] = 0;
32
- }
33
-
34
- for (i=0, sl=s.length; i < sl; i++) {
35
- if (s[i] === '') {
36
- continue;
37
- }
38
- for (j=0, fl=f.length; j < fl; j++) {
39
- temp = s[i]+'';
40
- repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
41
- s[i] = (temp).split(f[j]).join(repl);
42
- if (count && s[i] !== temp) {
43
- this.window[count] += (temp.length-s[i].length)/f[j].length;}
44
  }
45
- }
46
- return sa ? s : s[0];
47
- }
48
-
49
-
50
-
51
-
52
- function init_attachments_sortable() {
53
- if(jQuery('div#attachments-list ul:data(sortable)').length==0&&jQuery('div#attachments-list ul li').length>0){
54
- jQuery('div#attachments-list ul').sortable({
55
- containment: 'parent',
56
- stop: function(e, ui) {
57
- jQuery('#attachments-list ul li').each(function(i, id) {
58
- jQuery(this).find('input.attachment_order').val(i+1);
59
- });
60
- }
61
- });
62
- }
63
  }
 
64
 
65
 
66
 
67
 
68
- function attachments_handle_attach(title,caption,id,thumb){
69
 
70
- attachment_index = jQuery('li.attachments-file', top.document).length;
71
- new_attachments = '';
72
 
73
- attachment_name = title;
74
- attachment_caption = caption;
75
- attachment_id = id;
76
- attachment_thumb = thumb;
77
 
78
- attachment_index++;
79
- new_attachments += '<li class="attachments-file">';
80
- new_attachments += '<h2><a href="#" class="attachment-handle"><span class="attachment-handle-icon"><img src="' + attachments_base + '/images/handle.gif" alt="Drag" /></span></a><span class="attachment-name">' + attachment_name + '</span><span class="attachment-delete"><a href="#">Delete</a></span></h2>';
81
- new_attachments += '<div class="attachments-fields">';
82
- new_attachments += '<div class="textfield" id="field_attachment_title_' + attachment_index + '"><label for="attachment_title_' + attachment_index + '">Title</label><input type="text" id="attachment_title_' + attachment_index + '" name="attachment_title_' + attachment_index + '" value="' + attachment_name + '" size="20" /></div>';
83
- new_attachments += '<div class="textfield" id="field_attachment_caption_' + attachment_index + '"><label for="attachment_caption_' + attachment_index + '">Caption</label><input type="text" id="attachment_caption_' + attachment_index + '" name="attachment_caption_' + attachment_index + '" value="' + attachment_caption + '" size="20" /></div>';
84
- new_attachments += '</div>';
85
- new_attachments += '<div class="attachments-data">';
86
- new_attachments += '<input type="hidden" name="attachment_id_' + attachment_index + '" id="attachment_id_' + attachment_index + '" value="' + attachment_id + '" />';
87
- new_attachments += '<input type="hidden" class="attachment_order" name="attachment_order_' + attachment_index + '" id="attachment_order_' + attachment_index + '" value="' + attachment_index + '" />';
88
- new_attachments += '</div>';
89
- new_attachments += '<div class="attachment-thumbnail"><span class="attachments-thumbnail">';
90
 
91
 
92
- new_attachments += '<img src="' + attachment_thumb + '" alt="Thumbnail" />';
93
- new_attachments += '</span></div>';
94
- new_attachments += '</li>';
95
 
96
- jQuery('div#attachments-list ul', top.document).append(new_attachments);
97
 
98
- if(jQuery('#attachments-list li', top.document).length > 0) {
99
 
100
- // We've got some attachments
101
- jQuery('#attachments-list', top.document).show();
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  }
104
  }
105
 
106
-
107
- jQuery(document).ready(function() {
108
-
109
- if(attachments_is_attachments_context)
110
- {
111
- jQuery('body').addClass('attachments-media-upload');
112
-
113
- // we need to hijack the Attach button
114
- jQuery('td.savesend input').live('click',function(e){
115
  theparent = jQuery(this).parent().parent().parent();
116
  thetitle = theparent.find('tr.post_title td.field input').val();
117
  thecaption = theparent.find('tr.post_excerpt td.field input').val();
118
- theid = str_replace( 'imgedit-response-', '', theparent.find('td.imgedit-response').attr('id') );
119
  thethumb = theparent.parent().parent().find('img.pinkynail').attr('src');
120
  attachments_handle_attach(thetitle,thecaption,theid,thethumb);
121
- jQuery(this).after('<span class="attachments-attached-note"> Attached</span>').parent().find('span.attachments-attached-note').delay(1000).fadeOut();
122
- return false;
123
  });
124
- }
125
-
126
- // we're going to handle the Thickbox
127
- jQuery("body").click(function(event) {
128
- if (jQuery(event.target).is('a#attachments-thickbox')) {
129
- tb_show("Attach a file", event.target.href, false);
130
- return false;
131
  }
132
- });
133
-
134
- // Modify thickbox link to fit window. Adapted from wp-admin\js\media-upload.dev.js.
135
- jQuery('a#attachments-thickbox').each( function() {
136
- var href = jQuery(this).attr('href'), width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
137
- if ( ! href ) return;
138
- href = href.replace(/&width=[0-9]+/g, '');
139
- href = href.replace(/&height=[0-9]+/g, '');
140
- jQuery(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
141
- });
142
-
143
- // If there are no attachments, let's hide this thing...
144
- if(jQuery('div#attachments-list li').length == 0) {
145
- jQuery('#attachments-list').hide();
146
  }
 
147
 
148
- // Hook our delete links
149
- jQuery('span.attachment-delete a').live('click', function() {
150
- attachment_parent = jQuery(this).parent().parent().parent();
151
- attachment_parent.slideUp(function() {
152
- attachment_parent.remove();
153
- jQuery('#attachments-list ul li').each(function(i, id) {
154
- jQuery(this).find('input.attachment_order').val(i+1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  });
156
- if(jQuery('div#attachments-list li').length == 0) {
157
- jQuery('#attachments-list').slideUp(function() {
158
- jQuery('#attachments-list').hide();
159
- });
160
- }
161
- });
162
- return false;
163
  });
 
 
164
 
165
- // we also need to get a bit hacky with sortable...
166
- setInterval('init_attachments_sortable()',500);
167
 
168
- });
1
+ var attachments_button_label_updater = null;
2
+ var attachments_button_label = 'Attach File';
3
+ var attachments_asset = null;
4
+ var attachments_hijacked_thickbox = false;
5
+
6
+ function init_attachments_sortable() {
7
+ if(jQuery('div#attachments-list ul:data(sortable)').length==0&&jQuery('div#attachments-list ul li').length>0){
8
+ jQuery('div#attachments-list ul').sortable({
9
+ containment: 'parent',
10
+ stop: function(e, ui) {
11
+ jQuery('#attachments-list ul li').each(function(i, id) {
12
+ jQuery(this).find('input.attachment_order').val(i+1);
13
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  }
15
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  }
17
+ }
18
 
19
 
20
 
21
 
22
+ function attachments_handle_attach(title,caption,id,thumb){
23
 
24
+ attachment_index = jQuery('li.attachments-file', top.document).length;
25
+ new_attachments = '';
26
 
27
+ attachment_name = title;
28
+ attachment_caption = caption;
29
+ attachment_id = id;
30
+ attachment_thumb = thumb;
31
 
32
+ attachment_index++;
33
+ new_attachments += '<li class="attachments-file">';
34
+ new_attachments += '<h2><a href="#" class="attachment-handle"><span class="attachment-handle-icon"><img src="' + attachments_base + '/images/handle.gif" alt="Drag" /></span></a><span class="attachment-name">' + attachment_name + '</span><span class="attachment-delete"><a href="#">Delete</a></span></h2>';
35
+ new_attachments += '<div class="attachments-fields">';
36
+ new_attachments += '<div class="textfield" id="field_attachment_title_' + attachment_index + '"><label for="attachment_title_' + attachment_index + '">Title</label><input type="text" id="attachment_title_' + attachment_index + '" name="attachment_title_' + attachment_index + '" value="' + attachment_name + '" size="20" /></div>';
37
+ new_attachments += '<div class="textfield" id="field_attachment_caption_' + attachment_index + '"><label for="attachment_caption_' + attachment_index + '">Caption</label><input type="text" id="attachment_caption_' + attachment_index + '" name="attachment_caption_' + attachment_index + '" value="' + attachment_caption + '" size="20" /></div>';
38
+ new_attachments += '</div>';
39
+ new_attachments += '<div class="attachments-data">';
40
+ new_attachments += '<input type="hidden" name="attachment_id_' + attachment_index + '" id="attachment_id_' + attachment_index + '" value="' + attachment_id + '" />';
41
+ new_attachments += '<input type="hidden" class="attachment_order" name="attachment_order_' + attachment_index + '" id="attachment_order_' + attachment_index + '" value="' + attachment_index + '" />';
42
+ new_attachments += '</div>';
43
+ new_attachments += '<div class="attachment-thumbnail"><span class="attachments-thumbnail">';
44
 
45
 
46
+ new_attachments += '<img src="' + attachment_thumb + '" alt="Thumbnail" />';
47
+ new_attachments += '</span></div>';
48
+ new_attachments += '</li>';
49
 
50
+ jQuery('div#attachments-list ul', top.document).append(new_attachments);
51
 
52
+ if(jQuery('#attachments-list li', top.document).length > 0) {
53
 
54
+ // We've got some attachments
55
+ jQuery('#attachments-list', top.document).show();
56
 
57
+ }
58
+ }
59
+
60
+
61
+ jQuery(document).ready(function() {
62
+
63
+ if (typeof send_to_editor === 'function')
64
+ {
65
+ var attachments_send_to_editor_default = send_to_editor;
66
+ send_to_editor = function(markup){
67
+ clearInterval(attachments_button_label_updater);
68
+ if(attachments_hijacked_thickbox){
69
+ // determine what got retuned
70
+ var src = markup.match(/src="(.*)" alt=/i);
71
+ src = (src && src[1]) ? src[1] : '' ;
72
+ var href = markup.match(/href='(.*)'/i);
73
+ href = (href && href[1]) ? href[1] : '' ;
74
+ var attachments_asset = href ? href : src ;
75
+ attachments_hijacked_thickbox = false; // reset our flag
76
+ tb_remove();
77
+ }else{
78
+ attachments_send_to_editor_default(markup);
79
+ }
80
  }
81
  }
82
 
83
+ function attachments_update_button_label(){
84
+ if(attachments_hijacked_thickbox){
85
+ // our new click handler for the attach button
86
+ jQuery('#TB_iframeContent').contents().find('td.savesend input').unbind('click').click(function(e){
 
 
 
 
 
87
  theparent = jQuery(this).parent().parent().parent();
88
  thetitle = theparent.find('tr.post_title td.field input').val();
89
  thecaption = theparent.find('tr.post_excerpt td.field input').val();
90
+ theid = theparent.find('td.imgedit-response').attr('id').replace('imgedit-response-','');
91
  thethumb = theparent.parent().parent().find('img.pinkynail').attr('src');
92
  attachments_handle_attach(thetitle,thecaption,theid,thethumb);
 
 
93
  });
94
+ // update button
95
+ if(jQuery('#TB_iframeContent').contents().find('.media-item .savesend input[type=submit], #insertonlybutton').length){
96
+ jQuery('#TB_iframeContent').contents().find('.media-item .savesend input[type=submit], #insertonlybutton').val(attachments_button_label);
 
 
 
 
97
  }
98
+ if(jQuery('#TB_iframeContent').contents().find('#tab-type_url').length){
99
+ jQuery('#TB_iframeContent').contents().find('#tab-type_url').hide();
100
+ }
101
+ if(jQuery('#TB_iframeContent').contents().find('tr.post_title').length){
102
+ // we need to ALWAYS get the fullsize since we're retrieving the guid
103
+ // if the user inserts an image somewhere else and chooses another size, everything breaks
104
+ jQuery('#TB_iframeContent').contents().find('tr.image-size input[value="full"]').prop('checked', true);
105
+ jQuery('#TB_iframeContent').contents().find('tr.post_title,tr.image_alt,tr.post_excerpt,tr.image-size,tr.post_content,tr.url,tr.align,tr.submit>td>a.del-link').hide();
106
+ }
107
+ }
108
+ if(jQuery('#TB_iframeContent').contents().length==0&&attachments_hijacked_thickbox){
109
+ // the thickbox was closed
110
+ clearInterval(attachments_button_label_updater);
111
+ attachments_hijacked_thickbox = false;
112
  }
113
+ }
114
 
115
+ // thickbox handler
116
+ jQuery('a#attachments-thickbox').live('click',function(event){
117
+ var href = jQuery(this).attr('href'), width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
118
+ if ( ! href ) return;
119
+ href = href.replace(/&width=[0-9]+/g, '');
120
+ href = href.replace(/&height=[0-9]+/g, '');
121
+ jQuery(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
122
+ attachments_hijacked_thickbox = true;
123
+ attachments_button_label_updater = setInterval(attachments_update_button_label, 500);
124
+ // jQuery(this).parent().parent().find('ul.attachments-pro-list').addClass('attachments-pro-context');
125
+ tb_show('Attach a file', event.target.href, false);
126
+ return false;
127
+ });
128
+
129
+ // If there are no attachments, let's hide this thing...
130
+ if(jQuery('div#attachments-list li').length == 0) {
131
+ jQuery('#attachments-list').hide();
132
+ }
133
+
134
+ // Hook our delete links
135
+ jQuery('span.attachment-delete a').live('click', function() {
136
+ attachment_parent = jQuery(this).parent().parent().parent();
137
+ attachment_parent.slideUp(function() {
138
+ attachment_parent.remove();
139
+ jQuery('#attachments-list ul li').each(function(i, id) {
140
+ jQuery(this).find('input.attachment_order').val(i+1);
141
+ });
142
+ if(jQuery('div#attachments-list li').length == 0) {
143
+ jQuery('#attachments-list').slideUp(function() {
144
+ jQuery('#attachments-list').hide();
145
  });
146
+ }
 
 
 
 
 
 
147
  });
148
+ return false;
149
+ });
150
 
151
+ // we also need to get a bit hacky with sortable...
152
+ setInterval('init_attachments_sortable()',500);
153
 
154
+ });
attachments-fr_FR.mo → languages/attachments-fr_FR.mo RENAMED
File without changes
attachments-fr_FR.po → languages/attachments-fr_FR.po RENAMED
File without changes
attachments-it_IT.mo → languages/attachments-it_IT.mo RENAMED
File without changes
attachments-it_IT.po → languages/attachments-it_IT.po RENAMED
File without changes
languages/attachments-pl_PL.mo ADDED
Binary file
attachments-pl_PL.po → languages/attachments-pl_PL.po RENAMED
@@ -1,9 +1,9 @@
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: Attachments pl_PL version\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2011-06-03 15:16-0500\n"
6
- "PO-Revision-Date: 2011-06-03 15:18-0500\n"
7
  "Last-Translator: Wiktor Maj <w.maj@majpage.com>\n"
8
  "Language-Team: Wiktor Maj <w.maj@majpage.com>\n"
9
  "MIME-Version: 1.0\n"
@@ -16,55 +16,44 @@ msgstr ""
16
  "X-Poedit-SourceCharset: utf-8\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
- # @ attachments
20
- #: attachments.options.php:28
21
- #, fuzzy
22
  msgid "Post Type Settings"
23
  msgstr "Ustawienia Custom Post Types"
24
 
25
- # @ attachments
26
- #: attachments.options.php:29
27
- #, fuzzy
28
  msgid "Include Attachments in the following Post Types:"
29
  msgstr "Dodaj załączniki do następujących Custom Post Types:"
30
 
31
- # @ attachments
32
- #: attachments.options.php:41
33
  msgid "Attachments can be integrated with your Custom Post Types. Unfortunately, there are none to work with at this time."
34
  msgstr "Załączniki mogą być zintegrowane z Custom Post Types. Niestety w tej chwili nie ma żadnych zarejestrowanych Custom Post Types."
35
 
36
- #: attachments.options.php:47
37
  msgid "Miscellaneous"
38
- msgstr ""
39
 
40
- # @ attachments
41
- #: attachments.options.php:57
42
  msgid "Save"
43
  msgstr "Zapisz"
44
 
45
- # @ attachments
46
  #: attachments.php:132
47
- #: attachments.php:482
48
  msgid "Attach"
49
  msgstr "Załącz"
50
 
51
- # @ attachments
52
  #: attachments.php:156
53
  msgid "Delete"
54
  msgstr "Usuń"
55
 
56
- # @ attachments
57
  #: attachments.php:160
58
  msgid "Title"
59
  msgstr "Tytuł"
60
 
61
- # @ attachments
62
  #: attachments.php:164
63
  msgid "Caption"
64
  msgstr "Opis"
65
 
66
- # @ attachments
67
- #: attachments.php:214
68
  msgid "Attachments"
69
  msgstr "Załączniki"
70
 
1
  msgid ""
2
  msgstr ""
3
+ "Project-Id-Version: Attachments pl_PL 1.5.3.2\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-06-06 18:29+0100\n"
6
+ "PO-Revision-Date: 2011-06-06 18:33+0100\n"
7
  "Last-Translator: Wiktor Maj <w.maj@majpage.com>\n"
8
  "Language-Team: Wiktor Maj <w.maj@majpage.com>\n"
9
  "MIME-Version: 1.0\n"
16
  "X-Poedit-SourceCharset: utf-8\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
+ #: attachments.options.php:29
 
 
20
  msgid "Post Type Settings"
21
  msgstr "Ustawienia Custom Post Types"
22
 
23
+ #: attachments.options.php:30
 
 
24
  msgid "Include Attachments in the following Post Types:"
25
  msgstr "Dodaj załączniki do następujących Custom Post Types:"
26
 
27
+ #: attachments.options.php:42
 
28
  msgid "Attachments can be integrated with your Custom Post Types. Unfortunately, there are none to work with at this time."
29
  msgstr "Załączniki mogą być zintegrowane z Custom Post Types. Niestety w tej chwili nie ma żadnych zarejestrowanych Custom Post Types."
30
 
31
+ #: attachments.options.php:48
32
  msgid "Miscellaneous"
33
+ msgstr "Różne"
34
 
35
+ #: attachments.options.php:58
 
36
  msgid "Save"
37
  msgstr "Zapisz"
38
 
 
39
  #: attachments.php:132
40
+ #: attachments.php:480
41
  msgid "Attach"
42
  msgstr "Załącz"
43
 
 
44
  #: attachments.php:156
45
  msgid "Delete"
46
  msgstr "Usuń"
47
 
 
48
  #: attachments.php:160
49
  msgid "Title"
50
  msgstr "Tytuł"
51
 
 
52
  #: attachments.php:164
53
  msgid "Caption"
54
  msgstr "Opis"
55
 
56
+ #: attachments.php:212
 
57
  msgid "Attachments"
58
  msgstr "Załączniki"
59
 
attachments-pt_BR.mo → languages/attachments-pt_BR.mo RENAMED
File without changes
attachments-pt_BR.po → languages/attachments-pt_BR.po RENAMED
File without changes
attachments-sv_SE.mo → languages/attachments-sv_SE.mo RENAMED
File without changes
attachments-sv_SE.po → languages/attachments-sv_SE.po RENAMED
File without changes
readme.txt CHANGED
@@ -3,29 +3,53 @@ 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.2
7
- Stable tag: 1.5.3.2
8
 
9
  Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types
10
 
11
  == Description ==
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types. This plugin *does not* directly interact with your theme, you will need to edit your template files.
14
 
15
- There is an [outdated] **screencast available** on the [plugin home page](http://mondaybynoon.com/wordpress-attachments/) that will be upgraded soon.
 
 
 
 
 
 
16
 
17
  == Installation ==
18
 
19
  1. Download the plugin and extract the files
20
  1. Upload `attachments` to your `~/wp-content/plugins/` directory
21
  1. Activate the plugin through the 'Plugins' menu in WordPress
 
22
  1. Update your templates where applicable (see **Usage**)
23
 
24
  == Frequently Asked Questions ==
25
 
 
 
 
 
26
  = Attachments are not showing up in my theme =
27
 
28
- You will need to edit your theme files where applicable. Please reference the **Usage** instructions
29
 
30
  = Where are uploads saved? =
31
 
@@ -39,11 +63,15 @@ Attachments uses WordPress' built in Media library for uploads and storage.
39
 
40
  1. Attachments meta box as it appears on Posts, Pages, or Custom Post Types
41
  2. Native WordPress browse modal dialog, slightly customized for Attachments. Upload straight from your computer.
42
- 3. You can also browse the existing media in your Media Library. The dialog remains open, allowing you to attach multiple assets.
43
  4. Once assets have been attached, you can customize the title, caption, and order
44
 
45
  == Changelog ==
46
 
 
 
 
 
 
47
  = 1.5.3.1 =
48
  * Hotfix for an oversight where Attachments no longer display with Custom Post Types
49
 
@@ -142,8 +170,7 @@ Attachments are now stored in such a way that removes an in-place limitation on
142
 
143
  Planned feature additions include:
144
 
145
- * Physically attaching Attachments to Posts/Pages/Custom Post Types on a WordPress level
146
- * Modifying UI to provide ability to better bulk-add Attachments
147
 
148
  == Usage ==
149
 
@@ -161,7 +188,7 @@ Firing `attachments_get_attachments()` returns an array consisting of all availa
161
 
162
  Here is a basic implementation:
163
 
164
- `<?php
165
  if( function_exists( 'attachments_get_attachments' ) )
166
  {
167
  $attachments = attachments_get_attachments();
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.2.1
7
+ Stable tag: 1.5.4
8
 
9
  Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types
10
 
11
  == Description ==
12
 
13
+ = Attachments Pro Now Availble! =
14
+
15
+ Attachments Pro brings a number of frequently requested features:
16
+
17
+ * Multiple Attachments instances on edit screens
18
+ * Customizable field labels
19
+ * Unlimited number of fields per Attachment
20
+ * Ability to define rules limiting the availablility of Attachments on edit screens
21
+
22
+ **Much more information** available about [Attachments Pro](http://mondaybynoon.com/store/attachments-pro/)
23
+
24
+ = About Attachments =
25
+
26
  Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types. This plugin *does not* directly interact with your theme, you will need to edit your template files.
27
 
28
+ There is an [outdated] **screencast available** on the [plugin home page](http://mondaybynoon.com/wordpress-attachments/) that will be updated soon.
29
+
30
+ ![Attachments meta box](http://mondaybynoon.com/images/attachments/screenshot-1.jpg)
31
+
32
+ ![Attachments browse](http://mondaybynoon.com/images/attachments/screenshot-2.jpg)
33
+
34
+ ![Attachments after they've been added](http://mondaybynoon.com/images/attachments/screenshot-3.jpg)
35
 
36
  == Installation ==
37
 
38
  1. Download the plugin and extract the files
39
  1. Upload `attachments` to your `~/wp-content/plugins/` directory
40
  1. Activate the plugin through the 'Plugins' menu in WordPress
41
+ 1. View the Attachments settings (located under the main Settings menu in the WordPress admin) and turn on Attachments for your desired post types
42
  1. Update your templates where applicable (see **Usage**)
43
 
44
  == Frequently Asked Questions ==
45
 
46
+ = Attachments isn't showing up on my edit screens =
47
+
48
+ You need to turn on Attachments for your post types. View the Attachments settings under the main Settings menu in the WordPress admin.
49
+
50
  = Attachments are not showing up in my theme =
51
 
52
+ You will need to edit your theme files where applicable. Please reference the **Usage** instructions.
53
 
54
  = Where are uploads saved? =
55
 
63
 
64
  1. Attachments meta box as it appears on Posts, Pages, or Custom Post Types
65
  2. Native WordPress browse modal dialog, slightly customized for Attachments. Upload straight from your computer.
 
66
  4. Once assets have been attached, you can customize the title, caption, and order
67
 
68
  == Changelog ==
69
 
70
+ = 1.5.4 =
71
+ * Updated the way Thickbox is hijacked in an effort to be more stable among tab switching. As an unfortunate result, bulk attaching is no longer possible.
72
+ * Added environment check in preparation for future feature updates
73
+ * Updated Polish translation, courtesy of Wiktor Maj
74
+
75
  = 1.5.3.1 =
76
  * Hotfix for an oversight where Attachments no longer display with Custom Post Types
77
 
170
 
171
  Planned feature additions include:
172
 
173
+ * Code refactoring in preparation for future features
 
174
 
175
  == Usage ==
176
 
188
 
189
  Here is a basic implementation:
190
 
191
+ `<?php
192
  if( function_exists( 'attachments_get_attachments' ) )
193
  {
194
  $attachments = attachments_get_attachments();
screenshot-3.jpg CHANGED
Binary file
screenshot-4.jpg DELETED
Binary file