Attachments - Version 3.4.2

Version Description

= 3.0 = Now piggybacking the awesome Media workflow introduced in WordPress 3.5

Download this release

Release Info

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

Code changes from version 3.4 to 3.4.2

README.md CHANGED
@@ -106,7 +106,7 @@ When Attachments is first activated, a default instance is created titled Attach
106
 
107
  #### Disable the Default Instance
108
 
109
- If you would like to *disable the default instance* (meta box titled 'Attachments' with a 'Title' and 'Caption' field) add the following to your `wp-config.php`:
110
 
111
  ```php
112
  define( 'ATTACHMENTS_DEFAULT_INSTANCE', false );
@@ -375,7 +375,8 @@ $defaults = array(
375
  'post_type' => null, // (string) search 'any' post type
376
  'post_id' => null, // (int) searching all posts
377
  'post_status' => 'publish', // (string) search only published posts
378
- 'fields' => null, // (string|array) search all fields
 
379
  );
380
  ```
381
 
@@ -473,6 +474,15 @@ Attachments uses WordPress' built in Media library for uploads and storage.
473
 
474
  <dl>
475
 
 
 
 
 
 
 
 
 
 
476
  <dt>3.4</dt>
477
  <dd>New filter: <code>attachments_meta_key</code> facilitates using a different meta key for Attachments storage</dd>
478
  <dd>New filter: <code>attachments_get_<strong>{my_instance}</strong></code> (where <code><strong>{my_instance}</strong></code> is your instance name) allows you to filter Attachments per instance once they've been retrieved</dd>
106
 
107
  #### Disable the Default Instance
108
 
109
+ If you would like to *disable the default instance* (meta box titled 'Attachments' with a 'Title' and 'Caption' field) add the following to your `wp-config.php` *before* `require_once(ABSPATH . 'wp-settings.php');`:
110
 
111
  ```php
112
  define( 'ATTACHMENTS_DEFAULT_INSTANCE', false );
375
  'post_type' => null, // (string) search 'any' post type
376
  'post_id' => null, // (int) searching all posts
377
  'post_status' => 'publish', // (string) search only published posts
378
+ 'fields' => null, // (string|array) search all Attachment fields
379
+ 'filetype' => null, // (string|array) search all Attachment filetypes
380
  );
381
  ```
382
 
474
 
475
  <dl>
476
 
477
+ <dt>3.4.2</dt>
478
+ <dd>Fixed an issue where the `languages` directory wouldn't be utilized for l10n</dd>
479
+ <dd>Search now respects custom `meta_key`</dd>
480
+ <dd>You can now pass in a `filetype` parameter when searching to limit results in that way</dd>
481
+
482
+ <dt>3.4.1</dt>
483
+ <dd>Class abstraction and cleanup</dd>
484
+ <dd>Better support for plugin-created custom image sizes</dd>
485
+
486
  <dt>3.4</dt>
487
  <dd>New filter: <code>attachments_meta_key</code> facilitates using a different meta key for Attachments storage</dd>
488
  <dd>New filter: <code>attachments_get_<strong>{my_instance}</strong></code> (where <code><strong>{my_instance}</strong></code> is your instance name) allows you to filter Attachments per instance once they've been retrieved</dd>
classes/class.attachments.legacy.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // exit if accessed directly
4
+ if( !defined( 'ABSPATH' ) ) exit;
5
+
6
+ // exit if we can't extend Attachments
7
+ if ( !class_exists( 'Attachments' ) ) return;
8
+
9
+
10
+
11
+
12
+ /**
13
+ * Check for and handle legacy data appropriately
14
+ *
15
+ * @since 3.4.1
16
+ */
17
+ class AttachmentsLegacyHandler
18
+ {
19
+
20
+ public $legacy = false; // whether or not there is legacy Attachments data
21
+ public $legacy_pro = false; // whether or not there is legacy Attachment Pro data
22
+
23
+ function __construct()
24
+ {
25
+ // deal with our legacy issues if the user hasn't dismissed or migrated already
26
+ $this->check_for_legacy_data();
27
+
28
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_pointer' ), 999 );
29
+
30
+ // with version 3 we'll be giving at least one admin notice
31
+ add_action( 'admin_notices', array( $this, 'admin_notice' ) );
32
+ }
33
+
34
+
35
+
36
+ /**
37
+ * Stores whether or not this environment has active legacy Attachments/Pro data
38
+ *
39
+ * @since 3.1.3
40
+ */
41
+ function check_for_legacy_data()
42
+ {
43
+ // we'll get a warning issued if fired when Network Activated
44
+ // since it's supremely unlikely we'd have legacy data at this point, we're going to short circuit
45
+ if( is_multisite() )
46
+ {
47
+ $plugins = get_site_option( 'active_sitewide_plugins' );
48
+ if ( isset($plugins['attachments/index.php']) )
49
+ return;
50
+ }
51
+
52
+ // deal with our legacy issues if the user hasn't dismissed or migrated already
53
+ if( false == get_option( 'attachments_migrated' ) && false == get_option( 'attachments_ignore_migration' ) )
54
+ {
55
+ $legacy_attachments_settings = get_option( 'attachments_settings' );
56
+
57
+ if( $legacy_attachments_settings && is_array( $legacy_attachments_settings['post_types'] ) && count( $legacy_attachments_settings['post_types'] ) )
58
+ {
59
+ // we have legacy settings, so we're going to use the post types
60
+ // that Attachments is currently utilizing
61
+
62
+ // the keys are the actual CPT names, so we need those
63
+ foreach( $legacy_attachments_settings['post_types'] as $post_type => $value )
64
+ if( $value )
65
+ $post_types[] = $post_type;
66
+
67
+ // set up our WP_Query args to grab anything with legacy data
68
+ $args = array(
69
+ 'post_type' => isset( $post_types ) ? $post_types : array( 'post', 'page' ),
70
+ 'post_status' => 'any',
71
+ 'posts_per_page' => 1,
72
+ 'meta_key' => '_attachments',
73
+ 'suppress_filters' => true,
74
+ );
75
+
76
+ $legacy = new WP_Query( $args );
77
+ $this->legacy = empty( $legacy->found_posts ) ? false : true;
78
+ }
79
+ }
80
+
81
+ // deal with our legacy Pro issues if the user hasn't dismissed or migrated already
82
+ if( false == get_option( 'attachments_pro_migrated' ) && false == get_option( 'attachments_pro_ignore_migration' ) )
83
+ {
84
+ $post_types = get_post_types();
85
+
86
+ // set up our WP_Query args to grab anything (really anything) with legacy data
87
+ $args = array(
88
+ 'post_type' => !empty( $post_types ) ? $post_types : array( 'post', 'page' ),
89
+ 'post_status' => 'any',
90
+ 'posts_per_page' => 1,
91
+ 'meta_key' => '_attachments_pro',
92
+ 'suppress_filters' => true,
93
+ );
94
+
95
+ $legacy_pro = new WP_Query( $args );
96
+ $this->legacy_pro = empty( $legacy_pro->found_posts ) ? false : true;
97
+ }
98
+ }
99
+
100
+
101
+
102
+ /**
103
+ * Outputs a WordPress message to notify user of legacy data
104
+ *
105
+ * @since 3.0
106
+ */
107
+ function admin_notice()
108
+ {
109
+
110
+ if( $this->has_outstanding_legacy_data() && ( isset( $_GET['page'] ) && $_GET['page'] !== 'attachments' || !isset( $_GET['page'] ) ) ) : ?>
111
+ <div class="message updated" id="message">
112
+ <p><?php _e( '<strong>Attachments has detected legacy Attachments data.</strong> A lot has changed since Attachments 1.x.' ,'attachments' ); ?> <a href="options-general.php?page=attachments&amp;overview=1"><?php _e( 'Find out more', 'attachments' ); ?>.</a></p>
113
+ </div>
114
+ <?php endif;
115
+ }
116
+
117
+
118
+
119
+ /**
120
+ * Determines whether or not there is 'active' legacy data the user may not know about
121
+ *
122
+ * @since 3.0
123
+ */
124
+ function has_outstanding_legacy_data()
125
+ {
126
+ if(
127
+ // migration has not taken place and we have legacy data
128
+ ( false == get_option( 'attachments_migrated' ) && !empty( $this->legacy ) )
129
+
130
+ &&
131
+
132
+ // we're not intentionally ignoring the message
133
+ ( false == get_option( 'attachments_ignore_migration' ) )
134
+ )
135
+ {
136
+ return true;
137
+ }
138
+ else
139
+ {
140
+ return false;
141
+ }
142
+ }
143
+
144
+
145
+
146
+ /**
147
+ * Implements our WordPress pointer if necessary
148
+ *
149
+ * @since 3.0
150
+ */
151
+ function admin_pointer( $hook_suffix )
152
+ {
153
+
154
+ // Assume pointer shouldn't be shown
155
+ $enqueue_pointer_script_style = false;
156
+
157
+ // Get array list of dismissed pointers for current user and convert it to array
158
+ $dismissed_pointers = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
159
+
160
+ // Check if our pointer is not among dismissed ones
161
+ if( $this->legacy && !in_array( 'attachments_legacy', $dismissed_pointers ) ) {
162
+ $enqueue_pointer_script_style = true;
163
+
164
+ // Add footer scripts using callback function
165
+ add_action( 'admin_print_footer_scripts', array( $this, 'pointer_legacy' ) );
166
+ }
167
+
168
+ // Enqueue pointer CSS and JS files, if needed
169
+ if( $enqueue_pointer_script_style ) {
170
+ wp_enqueue_style( 'wp-pointer' );
171
+ wp_enqueue_script( 'wp-pointer' );
172
+ }
173
+ }
174
+
175
+
176
+
177
+ /**
178
+ * Pointer that calls attention to legacy data
179
+ *
180
+ * @since 3.0
181
+ */
182
+ function pointer_legacy()
183
+ {
184
+ $pointer_content = "<h3>". __( esc_html( 'Attachments 3.0 brings big changes!' ), 'attachments' ) ."</h3>";
185
+ $pointer_content .= "<p>". __( esc_html( 'It is very important that you take a few minutes to see what has been updated. The changes will affect your themes/plugins.' ), 'attachments' ) ."</p>";
186
+ ?>
187
+
188
+ <script type="text/javascript">
189
+ jQuery(document).ready( function($) {
190
+ $('#message a').pointer({
191
+ content:'<?php echo $pointer_content; ?>',
192
+ position:{
193
+ edge:'top',
194
+ align:'center'
195
+ },
196
+ pointerWidth:350,
197
+ close:function() {
198
+ $.post( ajaxurl, {
199
+ pointer: 'attachments_legacy',
200
+ action: 'dismiss-wp-pointer'
201
+ });
202
+ }
203
+ }).pointer('open');
204
+ });
205
+ </script>
206
+ <?php
207
+ }
208
+ }
209
+
classes/class.attachments.php CHANGED
@@ -32,13 +32,11 @@ if ( !class_exists( 'Attachments' ) ) :
32
  private $fields; // stores all registered field types
33
  private $attachments; // stores all of the Attachments for the given instance
34
 
35
- private $legacy = false; // whether or not there is legacy Attachments data
36
- private $legacy_pro = false; // whether or not there is legacy Attachment Pro data
37
- private $image_sizes = array( 'full' ); // store all registered image sizes
38
- private $default_instance = true; // use the default instance?
39
- private $attachments_ref = -1; // flags where a get() loop last did it's thing
40
- private $meta_key = 'attachments'; // our meta key
41
- private $valid_filetypes = array( // what WordPress considers to be valid file types
42
  'image',
43
  'video',
44
  'text',
@@ -59,26 +57,27 @@ if ( !class_exists( 'Attachments' ) ) :
59
 
60
  // establish our environment variables
61
 
62
- $this->version = '3.4';
63
  $this->url = ATTACHMENTS_URL;
64
  $this->dir = ATTACHMENTS_DIR;
65
 
66
  // includes
67
  include_once( ATTACHMENTS_DIR . 'upgrade.php' );
 
 
68
  include_once( ATTACHMENTS_DIR . '/classes/class.field.php' );
69
 
70
  // include our fields
71
  $this->fields = $this->get_field_types();
72
 
73
- // deal with our legacy issues if the user hasn't dismissed or migrated already
74
- $this->check_for_legacy_data();
75
-
76
  // set our image sizes
77
  $this->image_sizes = array_merge( $this->image_sizes, get_intermediate_image_sizes() );
78
 
 
 
 
79
  // hook into WP
80
  add_action( 'admin_enqueue_scripts', array( $this, 'assets' ), 999, 1 );
81
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_pointer' ), 999 );
82
 
83
  // register our user-defined instances
84
  add_action( 'init', array( $this, 'setup_instances' ) );
@@ -94,9 +93,6 @@ if ( !class_exists( 'Attachments' ) ) :
94
  if( !( defined( 'ATTACHMENTS_SETTINGS_SCREEN' ) && ATTACHMENTS_SETTINGS_SCREEN === false ) )
95
  add_action( 'admin_menu', array( $this, 'admin_page' ) );
96
 
97
- // with version 3 we'll be giving at least one admin notice
98
- add_action( 'admin_notices', array( $this, 'admin_notice' ) );
99
-
100
  add_action( 'admin_head', array( $this, 'field_inits' ) );
101
  add_action( 'admin_print_footer_scripts', array( $this, 'field_assets' ) );
102
 
@@ -117,80 +113,38 @@ if ( !class_exists( 'Attachments' ) ) :
117
 
118
 
119
  /**
120
- * Various initialization filter triggers
121
  *
122
- * @since 3.4
123
  */
124
- function apply_init_filters()
125
  {
126
- // allows a different meta_key to be used
127
- $this->meta_key = apply_filters( 'attachments_meta_key', $this->meta_key );
128
  }
129
 
130
 
131
 
132
  /**
133
- * Stores whether or not this environment has active legacy Attachments/Pro data
134
  *
135
- * @since 3.1.3
136
  */
137
- function check_for_legacy_data()
138
  {
139
- // we'll get a warning issued if fired when Network Activated
140
- // since it's supremely unlikely we'd have legacy data at this point, we're going to short circuit
141
- if( is_multisite() )
142
- {
143
- $plugins = get_site_option( 'active_sitewide_plugins' );
144
- if ( isset($plugins['attachments/index.php']) )
145
- return;
146
- }
147
 
148
- // deal with our legacy issues if the user hasn't dismissed or migrated already
149
- if( false == get_option( 'attachments_migrated' ) && false == get_option( 'attachments_ignore_migration' ) )
150
- {
151
- $legacy_attachments_settings = get_option( 'attachments_settings' );
152
 
153
- if( $legacy_attachments_settings && is_array( $legacy_attachments_settings['post_types'] ) && count( $legacy_attachments_settings['post_types'] ) )
154
- {
155
- // we have legacy settings, so we're going to use the post types
156
- // that Attachments is currently utilizing
157
-
158
- // the keys are the actual CPT names, so we need those
159
- foreach( $legacy_attachments_settings['post_types'] as $post_type => $value )
160
- if( $value )
161
- $post_types[] = $post_type;
162
-
163
- // set up our WP_Query args to grab anything with legacy data
164
- $args = array(
165
- 'post_type' => isset( $post_types ) ? $post_types : array( 'post', 'page' ),
166
- 'post_status' => 'any',
167
- 'posts_per_page' => 1,
168
- 'meta_key' => '_attachments',
169
- 'suppress_filters' => true,
170
- );
171
 
172
- $legacy = new WP_Query( $args );
173
- $this->legacy = empty( $legacy->found_posts ) ? false : true;
174
- }
175
- }
176
-
177
- // deal with our legacy Pro issues if the user hasn't dismissed or migrated already
178
- if( false == get_option( 'attachments_pro_migrated' ) && false == get_option( 'attachments_pro_ignore_migration' ) )
179
- {
180
- $post_types = get_post_types();
181
-
182
- // set up our WP_Query args to grab anything (really anything) with legacy data
183
- $args = array(
184
- 'post_type' => !empty( $post_types ) ? $post_types : array( 'post', 'page' ),
185
- 'post_status' => 'any',
186
- 'posts_per_page' => 1,
187
- 'meta_key' => '_attachments_pro',
188
- 'suppress_filters' => true,
189
- );
190
-
191
- $legacy_pro = new WP_Query( $args );
192
- $this->legacy_pro = empty( $legacy_pro->found_posts ) ? false : true;
193
- }
194
  }
195
 
196
 
@@ -202,125 +156,8 @@ if ( !class_exists( 'Attachments' ) ) :
202
  */
203
  function search( $query = null, $params = array() )
204
  {
205
- $defaults = array(
206
- 'attachment_id' => null, // not searching for a single attachment ID
207
- 'instance' => 'attachments', // default instance
208
- 'post_type' => null, // search 'any' post type
209
- 'post_id' => null, // searching all posts
210
- 'post_status' => 'publish', // search only published posts
211
- 'fields' => null, // search all fields
212
- );
213
-
214
- $query = is_null( $query ) ? null : sanitize_text_field( $query );
215
- $params = array_merge( $defaults, $params );
216
-
217
- // sanitize parameters
218
- $params['attachment_id'] = is_null( $params['attachment_id'] ) ? null : intval( $params['attachment_id'] );
219
- $params['instance'] = !is_string( $params['instance'] ) ? 'attachments' : sanitize_text_field( $params['instance'] );
220
- $params['post_type'] = is_null( $params['post_type'] ) ? 'any' : sanitize_text_field( $params['post_type'] );
221
- $params['post_id'] = is_null( $params['post_id'] ) ? null : intval( $params['post_id'] );
222
-
223
- $params['post_status'] = sanitize_text_field( $params['post_status'] );
224
-
225
- if( is_string( $params['fields'] ) )
226
- $params['fields'] = array( $params['fields'] ); // we always want an array
227
-
228
- // since we have an array for our fields, we need to loop through and sanitize
229
- for( $i = 0; $i < count( $params['fields'] ); $i++ )
230
- $params['fields'][$i] = sanitize_text_field( $params['fields'][$i] );
231
-
232
- // prepare our search args
233
- $args = array(
234
- 'nopaging' => true,
235
- 'post_status' => $params['post_status'],
236
- 'meta_query' => array(
237
- array(
238
- 'key' => 'attachments',
239
- 'value' => $query,
240
- 'compare' => 'LIKE'
241
- )
242
- ),
243
- );
244
-
245
- // append any applicable parameters that got passed to the original method call
246
- if( $params['post_type'] )
247
- $args['post_type'] = $params['post_type'];
248
-
249
- if( $params['post_id'] )
250
- $args['post__in'] = array( $params['post_id'] ); // avoid using 'p' or 'page_id'
251
-
252
- // we haven't utilized all parameters yet because they're meta-value based so we need to
253
- // do some parsing on our end to validate the returned results
254
-
255
- $possible_posts = new WP_Query( $args );
256
- $potential_attachments = false; // stores valid attachments as restrictions are added
257
-
258
- if( $possible_posts->found_posts )
259
- {
260
- // we have results from the reliminary search, we need to quantify them
261
- while( $possible_posts->have_posts() )
262
- {
263
- $possible_posts->next_post();
264
- $possible_post_ids[] = $possible_posts->post->ID;
265
- }
266
-
267
- // now that we have our possible post IDs we can grab all Attachments for all of those posts
268
- foreach( $possible_post_ids as $possible_post_id )
269
- {
270
- $possible_attachments = $this->get_attachments( $params['instance'], $possible_post_id );
271
-
272
- foreach( $possible_attachments as $possible_attachment )
273
- $potential_attachments[] = $possible_attachment;
274
- }
275
-
276
- }
277
-
278
- // if there aren't even any potential attachments, we'll just short circuit
279
- if( !$potential_attachments )
280
- return;
281
-
282
- // first we need to make sure that our query matches each attachment
283
- // we need to do this because the LIKE query returned the entire meta record,
284
- // not necessarily tied to any specific Attachment
285
- $total_potentials = count( $potential_attachments );
286
- for( $i = 0; $i < $total_potentials; $i++ )
287
- {
288
- $valid = false;
289
-
290
- // if we need to limit our search to specific fields, we'll do that here
291
- if( $params['fields'] )
292
- {
293
- // we only want to check certain fields
294
- foreach( $params['fields'] as $field )
295
- if( isset( $potential_attachments[$i]->fields->$field ) ) // does the field exist?
296
- if( strpos( strtolower( $potential_attachments[$i]->fields->$field ),
297
- strtolower( $query ) ) !== false ) // does the value match?
298
- $valid = true;
299
- }
300
- else
301
- {
302
- // we want to check all fields
303
- foreach( $potential_attachments[$i]->fields as $field_name => $field_value )
304
- if( strpos( strtolower( $field_value) , strtolower( $query ) ) !== false )
305
- $valid = true;
306
- }
307
-
308
- if( !$valid )
309
- unset( $potential_attachments[$i] );
310
-
311
- // now our potentials have been limited to each match the query based on any field
312
- }
313
-
314
- // limit to attachment ID if applicable
315
- if( $params['attachment_id'] )
316
- {
317
- $total_potentials = count( $potential_attachments );
318
- for( $i = 0; $i < $total_potentials; $i++ )
319
- if( $potential_attachments[$i]->id != $params['attachment_id'] )
320
- unset( $potential_attachments[$i] );
321
- }
322
-
323
- $this->attachments = array_values( $potential_attachments );
324
  }
325
 
326
 
@@ -392,9 +229,7 @@ if ( !class_exists( 'Attachments' ) ) :
392
  $this->attachments[$index]->meta = wp_get_attachment_metadata( $this->attachments[$index]->id );
393
 
394
  // is it an image?
395
- if(
396
- isset( $this->attachments[$index]->meta['sizes'] ) && // is it an image?
397
- in_array( $size, $this->image_sizes ) ) // do we have the right size?
398
  {
399
  $asset = wp_get_attachment_image_src( $this->attachments[$index]->id, $size );
400
  }
@@ -418,11 +253,28 @@ if ( !class_exists( 'Attachments' ) ) :
418
  {
419
  $index = is_null( $index ) ? $this->attachments_ref : intval( $index );
420
  $asset = wp_get_attachment_image_src( $this->attachments[$index]->id, null, true );
 
421
  return $asset;
422
  }
423
 
424
 
425
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426
  /**
427
  * Returns an appropriate <img /> for the current Attachment if it's an image
428
  *
@@ -496,7 +348,23 @@ if ( !class_exists( 'Attachments' ) ) :
496
  if( !isset( $this->attachments[$index]->id ) )
497
  return false;
498
 
499
- $attachment_mime = explode( '/', get_post_mime_type( $this->attachments[$index]->id ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
500
  return isset( $attachment_mime[0] ) ? $attachment_mime[0] : false;
501
  }
502
 
@@ -1649,115 +1517,6 @@ if ( !class_exists( 'Attachments' ) ) :
1649
 
1650
 
1651
 
1652
- /**
1653
- * Determines whether or not there is 'active' legacy data the user may not know about
1654
- *
1655
- * @since 3.0
1656
- */
1657
- function has_outstanding_legacy_data()
1658
- {
1659
- if(
1660
- // migration has not taken place and we have legacy data
1661
- ( false == get_option( 'attachments_migrated' ) && !empty( $this->legacy ) )
1662
-
1663
- &&
1664
-
1665
- // we're not intentionally ignoring the message
1666
- ( false == get_option( 'attachments_ignore_migration' ) )
1667
- )
1668
- {
1669
- return true;
1670
- }
1671
- else
1672
- {
1673
- return false;
1674
- }
1675
- }
1676
-
1677
-
1678
-
1679
- /**
1680
- * Outputs a WordPress message to notify user of legacy data
1681
- *
1682
- * @since 3.0
1683
- */
1684
- function admin_notice()
1685
- {
1686
-
1687
- if( $this->has_outstanding_legacy_data() && ( isset( $_GET['page'] ) && $_GET['page'] !== 'attachments' || !isset( $_GET['page'] ) ) ) : ?>
1688
- <div class="message updated" id="message">
1689
- <p><?php _e( '<strong>Attachments has detected legacy Attachments data.</strong> A lot has changed since Attachments 1.x.' ,'attachments' ); ?> <a href="options-general.php?page=attachments&amp;overview=1"><?php _e( 'Find out more', 'attachments' ); ?>.</a></p>
1690
- </div>
1691
- <?php endif;
1692
- }
1693
-
1694
-
1695
-
1696
- /**
1697
- * Implements our WordPress pointer if necessary
1698
- *
1699
- * @since 3.0
1700
- */
1701
- function admin_pointer( $hook_suffix )
1702
- {
1703
-
1704
- // Assume pointer shouldn't be shown
1705
- $enqueue_pointer_script_style = false;
1706
-
1707
- // Get array list of dismissed pointers for current user and convert it to array
1708
- $dismissed_pointers = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
1709
-
1710
- // Check if our pointer is not among dismissed ones
1711
- if( $this->legacy && !in_array( 'attachments_legacy', $dismissed_pointers ) ) {
1712
- $enqueue_pointer_script_style = true;
1713
-
1714
- // Add footer scripts using callback function
1715
- add_action( 'admin_print_footer_scripts', array( $this, 'pointer_legacy' ) );
1716
- }
1717
-
1718
- // Enqueue pointer CSS and JS files, if needed
1719
- if( $enqueue_pointer_script_style ) {
1720
- wp_enqueue_style( 'wp-pointer' );
1721
- wp_enqueue_script( 'wp-pointer' );
1722
- }
1723
- }
1724
-
1725
-
1726
-
1727
- /**
1728
- * Pointer that calls attention to legacy data
1729
- *
1730
- * @since 3.0
1731
- */
1732
- function pointer_legacy()
1733
- {
1734
- $pointer_content = "<h3>". __( esc_html( 'Attachments 3.0 brings big changes!' ), 'attachments' ) ."</h3>";
1735
- $pointer_content .= "<p>". __( esc_html( 'It is very important that you take a few minutes to see what has been updated. The changes will affect your themes/plugins.' ), 'attachments' ) ."</p>";
1736
- ?>
1737
-
1738
- <script type="text/javascript">
1739
- jQuery(document).ready( function($) {
1740
- $('#message a').pointer({
1741
- content:'<?php echo $pointer_content; ?>',
1742
- position:{
1743
- edge:'top',
1744
- align:'center'
1745
- },
1746
- pointerWidth:350,
1747
- close:function() {
1748
- $.post( ajaxurl, {
1749
- pointer: 'attachments_legacy',
1750
- action: 'dismiss-wp-pointer'
1751
- });
1752
- }
1753
- }).pointer('open');
1754
- });
1755
- </script>
1756
- <?php
1757
- }
1758
-
1759
-
1760
-
1761
  /**
1762
  * Callback to implement our Settings page
1763
  *
32
  private $fields; // stores all registered field types
33
  private $attachments; // stores all of the Attachments for the given instance
34
 
35
+ private $image_sizes = array( 'full' ); // store all registered image sizes
36
+ private $default_instance = true; // use the default instance?
37
+ private $attachments_ref = -1; // flags where a get() loop last did it's thing
38
+ private $meta_key = 'attachments'; // our meta key
39
+ private $valid_filetypes = array( // what WordPress considers to be valid file types
 
 
40
  'image',
41
  'video',
42
  'text',
57
 
58
  // establish our environment variables
59
 
60
+ $this->version = '3.4.1';
61
  $this->url = ATTACHMENTS_URL;
62
  $this->dir = ATTACHMENTS_DIR;
63
 
64
  // includes
65
  include_once( ATTACHMENTS_DIR . 'upgrade.php' );
66
+ include_once( ATTACHMENTS_DIR . '/classes/class.attachments.legacy.php' );
67
+ include_once( ATTACHMENTS_DIR . '/classes/class.attachments.search.php' );
68
  include_once( ATTACHMENTS_DIR . '/classes/class.field.php' );
69
 
70
  // include our fields
71
  $this->fields = $this->get_field_types();
72
 
 
 
 
73
  // set our image sizes
74
  $this->image_sizes = array_merge( $this->image_sizes, get_intermediate_image_sizes() );
75
 
76
+ // set up l10n
77
+ add_action( 'plugins_loaded', array( $this, 'l10n' ) );
78
+
79
  // hook into WP
80
  add_action( 'admin_enqueue_scripts', array( $this, 'assets' ), 999, 1 );
 
81
 
82
  // register our user-defined instances
83
  add_action( 'init', array( $this, 'setup_instances' ) );
93
  if( !( defined( 'ATTACHMENTS_SETTINGS_SCREEN' ) && ATTACHMENTS_SETTINGS_SCREEN === false ) )
94
  add_action( 'admin_menu', array( $this, 'admin_page' ) );
95
 
 
 
 
96
  add_action( 'admin_head', array( $this, 'field_inits' ) );
97
  add_action( 'admin_print_footer_scripts', array( $this, 'field_assets' ) );
98
 
113
 
114
 
115
  /**
116
+ * Getter for the current meta_key
117
  *
118
+ * @since 3.4.2
119
  */
120
+ function get_meta_key()
121
  {
122
+ return $this->meta_key;
 
123
  }
124
 
125
 
126
 
127
  /**
128
+ * Register our textdomain for l10n
129
  *
130
+ * @since 3.4.2
131
  */
132
+ function l10n()
133
  {
134
+ load_plugin_textdomain( 'attachments', false, trailingslashit( ATTACHMENTS_DIR ) . 'languages/' );
135
+ }
 
 
 
 
 
 
136
 
 
 
 
 
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
+ /**
140
+ * Various initialization filter triggers
141
+ *
142
+ * @since 3.4
143
+ */
144
+ function apply_init_filters()
145
+ {
146
+ // allows a different meta_key to be used
147
+ $this->meta_key = apply_filters( 'attachments_meta_key', $this->meta_key );
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  }
149
 
150
 
156
  */
157
  function search( $query = null, $params = array() )
158
  {
159
+ $results = new AttachmentsSearch( $query, $params );
160
+ $this->attachments = $results->results;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  }
162
 
163
 
229
  $this->attachments[$index]->meta = wp_get_attachment_metadata( $this->attachments[$index]->id );
230
 
231
  // is it an image?
232
+ if( isset( $this->attachments[$index]->meta['sizes'] ) )
 
 
233
  {
234
  $asset = wp_get_attachment_image_src( $this->attachments[$index]->id, $size );
235
  }
253
  {
254
  $index = is_null( $index ) ? $this->attachments_ref : intval( $index );
255
  $asset = wp_get_attachment_image_src( $this->attachments[$index]->id, null, true );
256
+
257
  return $asset;
258
  }
259
 
260
 
261
 
262
+ /**
263
+ * Returns the date for the current Attachment
264
+ * @author Hasin Hayder
265
+ *
266
+ * @since 3.4.1
267
+ */
268
+ function date( $d = "d/m/Y", $index = null )
269
+ {
270
+ $index = is_null( $index ) ? $this->attachments_ref : intval( $index );
271
+ $date = get_the_time( $d, $this->attachments[$index]->id );
272
+
273
+ return $date;
274
+ }
275
+
276
+
277
+
278
  /**
279
  * Returns an appropriate <img /> for the current Attachment if it's an image
280
  *
348
  if( !isset( $this->attachments[$index]->id ) )
349
  return false;
350
 
351
+ $attachment_mime = $this->get_mime_type( $this->attachments[$index]->id );
352
+ return isset( $attachment_mime[0] ) ? $attachment_mime[0] : false;
353
+ }
354
+
355
+
356
+
357
+ /**
358
+ * Retrieves the mime type for a WordPress $post ID
359
+ *
360
+ * @since 3.4.2
361
+ */
362
+ function get_mime_type( $id = null )
363
+ {
364
+ if( !is_int( $id ) )
365
+ return false;
366
+
367
+ $attachment_mime = explode( '/', get_post_mime_type( $id ) );
368
  return isset( $attachment_mime[0] ) ? $attachment_mime[0] : false;
369
  }
370
 
1517
 
1518
 
1519
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1520
  /**
1521
  * Callback to implement our Settings page
1522
  *
classes/class.attachments.search.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // exit if accessed directly
4
+ if( !defined( 'ABSPATH' ) ) exit;
5
+
6
+ // exit if we can't extend Attachments
7
+ if ( !class_exists( 'Attachments' ) ) return;
8
+
9
+
10
+
11
+
12
+ /**
13
+ * Search Attachments metadata based on a number of parameters
14
+ *
15
+ * @since 3.4.1
16
+ */
17
+ class AttachmentsSearch extends Attachments
18
+ {
19
+
20
+ public $results;
21
+
22
+ /**
23
+ * Facilitates searching for Attachments
24
+ *
25
+ * @since 3.3
26
+ */
27
+ function __construct( $query = null, $params = array() )
28
+ {
29
+ parent::__construct();
30
+ $this->apply_init_filters();
31
+
32
+ $defaults = array(
33
+ 'attachment_id' => null, // not searching for a single attachment ID
34
+ 'instance' => 'attachments', // default instance
35
+ 'post_type' => null, // search 'any' post type
36
+ 'post_id' => null, // searching all posts
37
+ 'post_status' => 'publish', // search only published posts
38
+ 'fields' => null, // search all fields
39
+ 'filetype' => null, // search all filetypes
40
+ );
41
+
42
+ $query = is_null( $query ) ? null : sanitize_text_field( $query );
43
+ $params = array_merge( $defaults, $params );
44
+
45
+ // sanitize parameters
46
+ $params['attachment_id'] = is_null( $params['attachment_id'] ) ? null : intval( $params['attachment_id'] );
47
+ $params['instance'] = !is_string( $params['instance'] ) ? 'attachments' : sanitize_text_field( $params['instance'] );
48
+ $params['post_type'] = is_null( $params['post_type'] ) ? 'any' : sanitize_text_field( $params['post_type'] );
49
+ $params['post_id'] = is_null( $params['post_id'] ) ? null : intval( $params['post_id'] );
50
+
51
+ $params['post_status'] = sanitize_text_field( $params['post_status'] );
52
+
53
+ if( is_string( $params['fields'] ) )
54
+ $params['fields'] = array( $params['fields'] ); // we always want an array
55
+
56
+ if( is_string( $params['filetype'] ) )
57
+ $params['filetype'] = array( $params['filetype'] ); // we always want an array
58
+
59
+ // since we have an array for our fields, we need to loop through and sanitize
60
+ for( $i = 0; $i < count( $params['fields'] ); $i++ )
61
+ $params['fields'][$i] = sanitize_text_field( $params['fields'][$i] );
62
+
63
+ // prepare our search args
64
+ $args = array(
65
+ 'nopaging' => true,
66
+ 'post_status' => $params['post_status'],
67
+ 'meta_query' => array(
68
+ array(
69
+ 'key' => parent::get_meta_key(),
70
+ 'value' => $query,
71
+ 'compare' => 'LIKE'
72
+ )
73
+ ),
74
+ );
75
+
76
+ // append any applicable parameters that got passed to the original method call
77
+ if( $params['post_type'] )
78
+ $args['post_type'] = $params['post_type'];
79
+
80
+ if( $params['post_id'] )
81
+ $args['post__in'] = array( $params['post_id'] ); // avoid using 'p' or 'page_id'
82
+
83
+ // we haven't utilized all parameters yet because they're meta-value based so we need to
84
+ // do some parsing on our end to validate the returned results
85
+
86
+ $possible_posts = new WP_Query( $args );
87
+ $potential_attachments = false; // stores valid attachments as restrictions are added
88
+
89
+ if( $possible_posts->found_posts )
90
+ {
91
+ // we have results from the reliminary search, we need to quantify them
92
+ while( $possible_posts->have_posts() )
93
+ {
94
+ $possible_posts->next_post();
95
+ $possible_post_ids[] = $possible_posts->post->ID;
96
+ }
97
+
98
+ // now that we have our possible post IDs we can grab all Attachments for all of those posts
99
+ foreach( $possible_post_ids as $possible_post_id )
100
+ {
101
+ $possible_attachments = parent::get_attachments( $params['instance'], $possible_post_id );
102
+
103
+ foreach( $possible_attachments as $possible_attachment )
104
+ $potential_attachments[] = $possible_attachment;
105
+ }
106
+
107
+ }
108
+
109
+ // if there aren't even any potential attachments, we'll just short circuit
110
+ if( !$potential_attachments )
111
+ return;
112
+
113
+ // first we need to make sure that our query matches each attachment
114
+ // we need to do this because the LIKE query returned the entire meta record,
115
+ // not necessarily tied to any specific Attachment
116
+ $total_potentials = count( $potential_attachments );
117
+ for( $i = 0; $i < $total_potentials; $i++ )
118
+ {
119
+ $valid = false;
120
+
121
+ // if we need to limit our search to specific fields, we'll do that here
122
+ if( $params['fields'] )
123
+ {
124
+ // we only want to check certain fields
125
+ foreach( $params['fields'] as $field )
126
+ if( isset( $potential_attachments[$i]->fields->$field ) ) // does the field exist?
127
+ if( !$query || strpos( strtolower( $potential_attachments[$i]->fields->$field ),
128
+ strtolower( $query ) ) !== false ) // does the value match?
129
+ if( !is_null( $params['filetype'] ) && in_array( parent::get_mime_type( $potential_attachments[$i]->id ), $params['filetype'] ) )
130
+ $valid = true;
131
+ }
132
+ else
133
+ {
134
+ // we want to check all fields
135
+ foreach( $potential_attachments[$i]->fields as $field_name => $field_value )
136
+ if( !$query || strpos( strtolower( $field_value) , strtolower( $query ) ) !== false )
137
+ if( !is_null( $params['filetype'] ) && in_array( parent::get_mime_type( $potential_attachments[$i]->id ), $params['filetype'] ) )
138
+ $valid = true;
139
+ }
140
+
141
+ if( !$valid )
142
+ unset( $potential_attachments[$i] );
143
+
144
+ // now our potentials have been limited to each match the query based on any field
145
+ }
146
+
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 );
157
+ }
158
+ }
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.4
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.4.2
10
  * Text Domain: attachments
11
  * Domain Path: /languages/
12
  * License: GPLv2 or later
languages/attachments-es_ES.po ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Attachments v3.4\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2013-03-21 11:42+0100\n"
6
+ "PO-Revision-Date: 2013-03-21 17:14+0100\n"
7
+ "Last-Translator: Joan Botella Vinaches <joanbotella@joanbotella.com>\n"
8
+ "Language-Team: Joan Botella Vinaches <joanbotella@joanbotella.com>\n"
9
+ "Language: \n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e;_ngettext:1,2\n"
14
+ "X-Poedit-Basepath: /media/Datos/Joan/Desarrollo/web/elrodat/web/wp-content/plugins/attachments\n"
15
+ "X-Poedit-Language: Spanish\n"
16
+ "X-Poedit-Country: SPAIN\n"
17
+ "X-Poedit-SourceCharset: utf-8\n"
18
+ "Plural-Forms: nplurals=2; plural=(n != 1)\n"
19
+ "X-Poedit-SearchPath-0: .\n"
20
+
21
+ #: index.php:30
22
+ msgid "Attachments requires PHP 5.2+. Attachments has been automatically deactivated."
23
+ msgstr "Attachments requiere PHP 5.2+. Attachments ha sido desactivado automáticamente."
24
+
25
+ #: classes/class.attachments.migrate.php:162
26
+ #: classes/class.attachments.migrate.php:218
27
+ msgid "Invalid request"
28
+ msgstr "Petición inválida"
29
+
30
+ #: classes/class.attachments.migrate.php:164
31
+ msgid "Migration Step 1"
32
+ msgstr "Paso 1 de la Migración"
33
+
34
+ #: classes/class.attachments.migrate.php:165
35
+ msgid "In order to migrate Attachments 1.x data, you need to set which instance and fields in version 3.0+ you'd like to use:"
36
+ msgstr "Para migrar los datos de Attachments 1.x necesitas especificar qué instancia y campos de la versión 3.0+ te gustaría usar:"
37
+
38
+ #: classes/class.attachments.migrate.php:174
39
+ msgid "Attachments 3.x Instance"
40
+ msgstr "Instancia de Attachments 3.x"
41
+
42
+ #: classes/class.attachments.migrate.php:178
43
+ msgid "The instance name you would like to use in the migration. Required."
44
+ msgstr "El nombre de la instancia que te gustaría usar en la migración. Requerido."
45
+
46
+ #: classes/class.attachments.migrate.php:183
47
+ msgid "Attachments 3.x Title"
48
+ msgstr "Título de Attachments 3.x"
49
+
50
+ #: classes/class.attachments.migrate.php:187
51
+ msgid "The <code>Title</code> field data will be migrated to this field name in Attachments 3.x. Leave empty to disregard."
52
+ msgstr "Los datos del campo <code>Title</code> se migrarán al campo con este nombre en Attachments 3.x. Dejar vacío para ignorar."
53
+
54
+ #: classes/class.attachments.migrate.php:192
55
+ msgid "Attachments 3.x Caption"
56
+ msgstr "Leyenda de Attachments 3.x"
57
+
58
+ #: classes/class.attachments.migrate.php:196
59
+ msgid "The <code>Caption</code> field data will be migrated to this field name in Attachments 3.x. Leave empty to disregard."
60
+ msgstr "Los datos del campo <code>Leyenda</code> se migrarán al campo con este nombre en Attachments 3.x. Dejar vacío para ignorar."
61
+
62
+ #: classes/class.attachments.migrate.php:224
63
+ msgid "Migration Complete!"
64
+ msgstr "¡Migración Completa!"
65
+
66
+ #: classes/class.attachments.migrate.php:225
67
+ msgid "The migration has completed."
68
+ msgstr "La migración se ha completado."
69
+
70
+ #: classes/class.attachments.migrate.php:225
71
+ msgid "Migrated"
72
+ msgstr "Migrado"
73
+
74
+ #: classes/class.attachments.migrate.php:227
75
+ msgid "Migration has already Run!"
76
+ msgstr "¡La migración ya se ha ejecutado!"
77
+
78
+ #: classes/class.attachments.migrate.php:228
79
+ msgid "The migration has already been run. The migration process has not been repeated."
80
+ msgstr "La migración ya se había ejecutado. El proceso de migración no se ha repetido."
81
+
82
+ #: classes/class.attachments.php:904
83
+ #: classes/class.attachments.php:978
84
+ #: deprecated/attachments.php:365
85
+ msgid "Title"
86
+ msgstr "Título"
87
+
88
+ # I kept "Attachments" untranslated instead of using the "Adjuntos" spanish version, because is the name of the plugin, and even the spanish users have to search it by its english name.
89
+ #: classes/class.attachments.php:940
90
+ #: classes/class.attachments.php:1768
91
+ #: deprecated/attachments.php:417
92
+ msgid "Attachments"
93
+ msgstr "Attachments"
94
+
95
+ #: classes/class.attachments.php:965
96
+ #: classes/class.attachments.php:968
97
+ #: deprecated/attachments.php:312
98
+ msgid "Attach"
99
+ msgstr "Adjuntar"
100
+
101
+ #: classes/class.attachments.php:984
102
+ #: deprecated/attachments.php:369
103
+ msgid "Caption"
104
+ msgstr "Leyenda"
105
+
106
+ #: classes/class.attachments.php:1235
107
+ msgid "Remove"
108
+ msgstr "Eliminar"
109
+
110
+ # "Campos de Alternancia" is a bit ugly...
111
+ #: classes/class.attachments.php:1236
112
+ msgid "Toggle Fields"
113
+ msgstr "Campos de Alternancia"
114
+
115
+ #: classes/class.attachments.php:1689
116
+ msgid "<strong>Attachments has detected legacy Attachments data.</strong> A lot has changed since Attachments 1.x."
117
+ msgstr "<strong>Attachments ha detectado datos de una versión antigua.</strong> Mucho ha cambiado desde Attachments 1.x."
118
+
119
+ #: classes/class.attachments.php:1689
120
+ msgid "Find out more"
121
+ msgstr "Saber más"
122
+
123
+ #: deprecated/attachments.php:51
124
+ msgid "Attachments requires PHP 5.2 or higher, as does WordPress 3.2+. Attachments has been automatically deactivated."
125
+ msgstr "Attachments requiere PHP 5.2 o superior, al igual que WordPress 3.2+. Attachments ha sido desactivado automáticamente."
126
+
127
+ #: deprecated/attachments.php:361
128
+ msgid "Delete"
129
+ msgstr "Borrar"
130
+
131
+ #: views/options.php:26
132
+ msgid "<strong>Attachments has changed significantly since it's last update.</strong> These changes <em>will affect your themes and plugins</em>."
133
+ msgstr "<strong>Attachments ha cambiado significativamente desde su última actualización.</strong> Estos cambios <em>afectarán a tus temas y plugins</em>."
134
+
135
+ #: views/options.php:29
136
+ msgid "Immediate Reversal to Attachments 1.x"
137
+ msgstr "Revertir Inmediatamente a Attachments 1.x"
138
+
139
+ # Keep the "wp-config.php" part of the sentence inside the translatable string, or it will become difficult to read for the translator.
140
+ #: views/options.php:31
141
+ msgid "If you would like to immediately <em>revert to the old version of Attachments</em> you may do so by downgrading the plugin install itself, or adding the following to your"
142
+ msgstr "Si quisieras <em>revertir a la versión antigua de Attachments</em> inmediatamente puedes hacerlo degradando la instalación misma del plugin, o añadiendo lo siguiente a tu"
143
+
144
+ #: views/options.php:35
145
+ msgid "Overview of changes from Attachments 1.x"
146
+ msgstr "Resumen de cambios desde Attachments 1.x"
147
+
148
+ # "coming down the line" == "new" ?
149
+ # I'm keeping untrasnlated the "meta box" concept. As a plugin writter, I often read the english name instead of "cajas meta" even on spanish articles.
150
+ #: views/options.php:37
151
+ msgid "A lot has changed since Attachments 1.x. The entire codebase was rewritten to not only make better use of the stellar Media updates in WordPress 3.5, but to also facilitate some exciting features coming down the line. With this rewrite came significant changes to the way you will work with Attachments. One of the biggest changes in Attachments 3.0 is the ability to create multiple meta boxes of Attachments, each with any number of custom fields you define. By default, Attachments will re-implement the meta box you've been using until now, but <strong>you will need to trigger a migration to the new format</strong>."
152
+ msgstr "Mucho ha cambiado desde Attachments 1.x. Todo el código de base ha sido reescrito no sólo para hacer mejor uso de las actualizaciones estelares de Media en WordPress 3.5, sino también para facilitar algunas nuevas funcionalidades excitantes. Con esta reescritura llegan cambios significativos en la forma con la que trabajas con Attachments. Uno de los mayores cambios en Attachments 3.0 es la capacidad para crear múltiples meta boxes de Attachments, cada una con el número de campos personalizados que definas. Por defecto, Attachments reimplementa la meta box que has estado usando hasta ahora, pero <strong>necesitarás realizar una migración al nuevo formato</strong>."
153
+
154
+ #: views/options.php:39
155
+ msgid "Migrating Attachments 1.x data to Attachments 3.x"
156
+ msgstr "Migrando los datos de Attachments 1.x a Attachments 3.x"
157
+
158
+ #: views/options.php:41
159
+ msgid "If you have existing Attachments 1.x data and are using it, a migration script has been bundled here and you can use it below. If you would like to directly migrate from Attachments 1.x to Attachments 3.x you can use the defaults put in place and your data will be migrated to the new format quickly and easily. Alternatively, if you'd like to customize the fields you're using a bit, you can do that first and then adjust the migration parameters to map the old fields to your new ones."
160
+ msgstr "Si tienes datos de Attachments 1.x que estés usando, un script de migración ha sido incluído y puedes usarlo más abajo. Si quieres migrar directamente de Attachments 1.x a Attachments 3.x puedes usar los valores por defecto especificados y tus datos se migrarán al nuevo formato rápida y fácilmente. Por el contrario, si prefieres personalizar un poco los campos que estás usando, puedes hacerlo y después ajustar los parámetros de migración para adaptar los campos viejos a los nuevos."
161
+
162
+ #: views/options.php:43
163
+ msgid "Setting up Instances"
164
+ msgstr "Preparando Instancias"
165
+
166
+ # I suppose the README file won't be translated, so the file name won't be LEEME.
167
+ #: views/options.php:45
168
+ msgid "Attachments 3.0 ships with what are called <em>instances</em>. An instance is equivalent to a meta box on an edit screen and it has a number of properties you can customize. Please read the README for more information."
169
+ msgstr "Attachments 3.0 se distribuye con lo que se han llamado <em>instancias</em>. Una instancia es equivalente a una meta box en la pantalla de edición y tiene diversas propiedades que puedes personalizar. Por favor lee el README para más información."
170
+
171
+ # A typo on AdditiNOal !
172
+ #: views/options.php:45
173
+ #: views/options.php:49
174
+ msgid "Additinoal instructions"
175
+ msgstr "Instrucciones adicionales"
176
+
177
+ #: views/options.php:47
178
+ msgid "Retrieving Attachments in your theme"
179
+ msgstr "Mostrando Attachments en tu tema"
180
+
181
+ # Incompleted sentence again. Some languages may need to add some text after whatever it has to be readed, or to know exactly what has to be readed in order to use male or female articles!
182
+ #: views/options.php:49
183
+ msgid "As always has been the case with Attachments, editing your theme files is required. The syntax to do so has changed in Attachments 3.0. Please read the"
184
+ msgstr "Como siempre ha ocurrido con Attachments, es necesario que edites los archivos de tu tema. La sintaxis para hacerlo ha cambiado en Attachments 3.0. Por favor lee las"
185
+
186
+ #: views/options.php:82
187
+ msgid "Migrate legacy Attachments data"
188
+ msgstr "Migrar datos de versiones antiguas de Attachments"
189
+
190
+ #: views/options.php:83
191
+ msgid "Attachments has found records from version 1.x. Would you like to migrate them to version 3?"
192
+ msgstr "Attachments ha encontrado registros de la versión 1.x. ¿Quieres migrarlos a la versión 3?"
193
+
194
+ #: views/options.php:84
195
+ msgid "Migrate legacy data"
196
+ msgstr "Migrar datos de una versión antigua"
197
+
198
+ #: views/options.php:86
199
+ msgid "You have already migrated your legacy Attachments data."
200
+ msgstr "Ya has migrado los datos de la versión antigua de Attachments."
201
+
202
+ #: views/options.php:89
203
+ msgid "Revert to version 1.x"
204
+ msgstr "Revertir a la versión 1.x"
205
+
206
+ # Incompleted again.
207
+ #: views/options.php:90
208
+ msgid "If you would like to forcefully revert to the 1.x version branch of Attachments, add the following to your"
209
+ msgstr "Si quieres revertir a la fuerza a la rama de la versión 1.x de Attachments, añade lo siguiente a tu"
210
+
211
+ #: views/options.php:92
212
+ msgid "Meta box customization"
213
+ msgstr "Personalización de las meta box"
214
+
215
+ # Incompleted.
216
+ #: views/options.php:93
217
+ msgid "By default, Attachments implements a single meta box on Posts and Pages with two fields. You can disable this default instance by adding the following to your"
218
+ msgstr "Por defecto, Attachments implementa una única meta box en Entradas y Páginas con dos campos. Puedes deshabilitar esta instancia por defecto añadiendo lo siguiente a tu"
219
+
220
+ # Incompleted. The right translation would be "añadiendo lo siguiente en el fichero functions.php de tu tema", but I can't change the "functions.php" position because is outside the translatable string.
221
+ #: views/options.php:95
222
+ msgid "Your Attachments meta box(es) can be customized by adding the following to your theme's"
223
+ msgstr "Tu(s) meta box(es) de Attachments pueden ser personalizadas añadiendo lo siguiente en tu tema, en el fichero"
224
+
225
+ #: views/options.php:97
226
+ msgid "Using Attachments data in your theme"
227
+ msgstr "Usando datos de Attachments en tu tema"
228
+
229
+ # The Loop is kept untranslated because all the doc out there uses that words instead of "El Bucle" spanish version.
230
+ #: views/options.php:98
231
+ msgid "Attachments does not directly integrate with your theme out of the box, you will need to edit your theme's template files where appropriate. You can add the following within The Loop to retrieve all Attachments data for the current post:"
232
+ msgstr "Attachments no se integra directamente en tu tema tras instalarlo, necesitarás editar los archivos de plantillas de tu tema donde sea apropiado. Puedes añadir lo siguiente dentro de The Loop para obtener los datos de Attachments para la entrada actual:"
233
+
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.1
7
- Stable tag: 3.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
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.1
7
+ Stable tag: 3.4.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
views/options.php CHANGED
@@ -4,6 +4,9 @@
4
  include_once( ATTACHMENTS_DIR . '/classes/class.attachments.migrate.php' );
5
  $migrator = new AttachmentsMigrate();
6
 
 
 
 
7
  if( isset( $_GET['dismiss'] ) )
8
  {
9
  if( !wp_verify_nonce( $_GET['nonce'], 'attachments-dismiss') )
@@ -78,7 +81,7 @@
78
  else
79
  { ?>
80
 
81
- <?php if( false == get_option( 'attachments_migrated' ) && $migrator->legacy ) : ?>
82
  <h2><?php _e( 'Migrate legacy Attachments data', 'attachments' ); ?></h2>
83
  <p><?php _e( 'Attachments has found records from version 1.x. Would you like to migrate them to version 3?', 'attachments' ); ?></p>
84
  <p><a href="?page=attachments&amp;migrate=1&amp;nonce=<?php echo wp_create_nonce( 'attachments-migrate-1' ); ?>" class="button-primary button"><?php _e( 'Migrate legacy data', 'attachments' ); ?></a></p>
4
  include_once( ATTACHMENTS_DIR . '/classes/class.attachments.migrate.php' );
5
  $migrator = new AttachmentsMigrate();
6
 
7
+ include_once( ATTACHMENTS_DIR . '/classes/class.attachments.legacy.php' );
8
+ $legacy = new AttachmentsLegacyHandler();
9
+
10
  if( isset( $_GET['dismiss'] ) )
11
  {
12
  if( !wp_verify_nonce( $_GET['nonce'], 'attachments-dismiss') )
81
  else
82
  { ?>
83
 
84
+ <?php if( false == get_option( 'attachments_migrated' ) && $legacy->legacy ) : ?>
85
  <h2><?php _e( 'Migrate legacy Attachments data', 'attachments' ); ?></h2>
86
  <p><?php _e( 'Attachments has found records from version 1.x. Would you like to migrate them to version 3?', 'attachments' ); ?></p>
87
  <p><a href="?page=attachments&amp;migrate=1&amp;nonce=<?php echo wp_create_nonce( 'attachments-migrate-1' ); ?>" class="button-primary button"><?php _e( 'Migrate legacy data', 'attachments' ); ?></a></p>