Media Library Assistant - Version 1.70

Version Description

  • New: Internationalization (i18n) and Localization (l10n) support! All of the internationalization work in the plugin source code has been completed and there is a Portable Object Template (.POT) available in the "/languages" directory. I don't have working knowledge of anything but English, but if you'd like to volunteer to produce a translation, I would be delighted to work with you to make it happen. Have a look at the "MLA Internationalization Guide.php" file in the languages directory and get in touch.
  • New: For Custom Field and IPTC/EXIF mapping, twelve new apply_filters/do_action hooks give you complete control over rule execution and value creation from PHP code in your theme or in another plugin. More information in the "Other Notes" section here. A complete, working example is provided in the Settings/Media Library Assistant Documentation tab.
  • New: For Settings/Media Library Assistant Custom Fields and IPTC/EXIF tabs "Enable ... Mapping when updating media metadata" options allow you to apply mapping rules whenever the media metadata is updated, not just on new uploads.
  • Fix: On the Settings/Media Library Assistant IPTC/EXIF tab, Taxonomy Parent dropdown now reflects term hierarchy.
  • Fix: MLAMime::mla_upload_mimes_filter() returns the MLA updated list of allowed types, not the WordPress default list.
  • Fix: MLAMime::mla_upload_mimes_filter() now respects the WordPress per-user 'unfiltered_html' capability.
  • Fix: When uploading new attachments, attachment metadata (_wp_attachment_metadata) is now updated from custom field and IPTC/EXIF mapping rules that contain the "meta:" prefix.
  • Fix: For WordPress 3.5 and later, a more efficient query is used to compose the "Attachments" column in the Media/taxonomy submenu tables.
  • Fix: Documentation for custom field and IPTC/EXIF mapping has been restructured and expanded to better explain these features.
Download this release

Release Info

Developer dglingren
Plugin Icon 128x128 Media Library Assistant
Version 1.70
Comparing to
See all releases

Code changes from version 1.61 to 1.70

Files changed (39) hide show
  1. css/mla-style.css +1 -1
  2. includes/class-mla-data.php +1132 -902
  3. includes/class-mla-edit-media.php +129 -101
  4. includes/class-mla-list-table.php +429 -359
  5. includes/class-mla-main.php +491 -355
  6. includes/class-mla-media-modal.php +98 -88
  7. includes/class-mla-mime-types.php +473 -306
  8. includes/class-mla-objects.php +69 -80
  9. includes/class-mla-options.php +1810 -1294
  10. includes/class-mla-settings.php +945 -651
  11. includes/class-mla-shortcodes.php +773 -599
  12. includes/class-mla-upload-list-table.php +111 -103
  13. includes/class-mla-upload-optional-list-table.php +71 -66
  14. includes/class-mla-view-list-table.php +99 -90
  15. includes/mla-plugin-loader.php +19 -18
  16. index.php +4 -2
  17. phpDocs/classes/MLA.html +16 -14
  18. phpDocs/classes/MLAData.html +63 -62
  19. phpDocs/classes/MLAEdit.html +1 -1
  20. phpDocs/classes/MLAMime.html +7 -3
  21. phpDocs/classes/MLAModal.html +1 -1
  22. phpDocs/classes/MLAObjects.html +1 -1
  23. phpDocs/classes/MLAOptions.html +152 -17
  24. phpDocs/classes/MLASettings.html +19 -2
  25. phpDocs/classes/MLAShortcodes.html +1 -1
  26. phpDocs/classes/MLATest.html +1 -1
  27. phpDocs/classes/MLATextWidget.html +1 -25
  28. phpDocs/classes/MLA_List_Table.html +6 -7
  29. phpDocs/classes/MLA_Upload_List_Table.html +4 -2
  30. phpDocs/classes/MLA_Upload_Optional_List_Table.html +4 -2
  31. phpDocs/classes/MLA_View_List_Table.html +4 -2
  32. phpDocs/deprecated.html +1 -1
  33. phpDocs/errors.html +1 -1
  34. phpDocs/graph_class.html +1 -1
  35. phpDocs/index.html +1 -1
  36. phpDocs/markers.html +2 -2
  37. phpDocs/namespaces/global.html +1 -1
  38. phpDocs/packages/Media Library Assistant.html +1 -1
  39. phpDocs/structure.xml +462 -462
css/mla-style.css CHANGED
@@ -175,7 +175,7 @@ textarea[readonly] {
175
  .quick-edit-row-upload fieldset.inline-edit-col label,
176
  .quick-edit-row-view fieldset.inline-edit-col label {
177
  float:left;
178
- width: 23em
179
  }
180
 
181
  .quick-edit-row-upload fieldset.inline-edit-col input.inline-edit-menu-order,
175
  .quick-edit-row-upload fieldset.inline-edit-col label,
176
  .quick-edit-row-view fieldset.inline-edit-col label {
177
  float:left;
178
+ width: 26em
179
  }
180
 
181
  .quick-edit-row-upload fieldset.inline-edit-col input.inline-edit-menu-order,
includes/class-mla-data.php CHANGED
@@ -5,7 +5,7 @@
5
  * @package Media Library Assistant
6
  * @since 0.1
7
  */
8
-
9
  /**
10
  * Class MLA (Media Library Assistant) Data provides database and template file access for MLA needs
11
  *
@@ -17,21 +17,24 @@
17
  */
18
  class MLAData {
19
  /**
20
- * Provides a unique suffix for the ALT Text SQL VIEW
 
 
 
21
  *
22
  * @since 0.40
23
  */
24
  const MLA_ALT_TEXT_VIEW_SUFFIX = 'alt_text_view';
25
-
26
  /**
27
- * Provides a unique name for the ALT Text SQL VIEW
28
  *
29
  * @since 0.40
30
  *
31
  * @var array
32
  */
33
  private static $mla_alt_text_view = NULL;
34
-
35
  /**
36
  * Initialization function, similar to __construct()
37
  *
@@ -45,7 +48,7 @@ class MLAData {
45
  add_action( 'edit_attachment', 'MLAData::mla_save_post_action', 10, 1);
46
  add_action( 'add_attachment', 'MLAData::mla_save_post_action', 10, 1);
47
  }
48
-
49
  /**
50
  * Load an HTML template from a file
51
  *
@@ -56,7 +59,7 @@ class MLAData {
56
  * @since 0.1
57
  *
58
  * @param string Complete path and name of the template file, option name or the raw template
59
- * @param string Optional type of template source; 'file' (default), 'option', 'string'
60
  *
61
  * @return string|array|false|NULL
62
  * string for files that do not contain template divider comments,
@@ -67,12 +70,35 @@ class MLAData {
67
  public static function mla_load_template( $source, $type = 'file' ) {
68
  switch ( $type ) {
69
  case 'file':
70
- if ( !file_exists( $source ) )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  return false;
72
-
 
73
  $template = file_get_contents( $source, true );
74
  if ( $template == false ) {
75
- error_log( 'ERROR: mla_load_template file not found ' . var_export( $source, true ), 0 );
 
76
  return NULL;
77
  }
78
  break;
@@ -89,17 +115,19 @@ class MLAData {
89
  }
90
  break;
91
  default:
92
- error_log( 'ERROR: mla_load_template bad source type ' . var_export( $type, true ), 0 );
 
93
  return NULL;
94
  }
95
-
96
  $match_count = preg_match_all( '#\<!-- template=".+" --\>#', $template, $matches, PREG_OFFSET_CAPTURE );
97
-
98
- if ( ( $match_count == false ) || ( $match_count == 0 ) )
99
  return $template;
100
-
 
101
  $matches = array_reverse( $matches[0] );
102
-
103
  $template_array = array();
104
  $current_offset = strlen( $template );
105
  foreach ( $matches as $key => $value ) {
@@ -109,44 +137,47 @@ class MLAData {
109
  /*
110
  * Trim exactly one newline sequence from the start of the value
111
  */
112
- if ( 0 === strpos( $template_value, "\r\n" ) )
113
  $offset = 2;
114
- elseif ( 0 === strpos( $template_value, "\n\r" ) )
115
  $offset = 2;
116
- elseif ( 0 === strpos( $template_value, "\n" ) )
117
  $offset = 1;
118
- elseif ( 0 === strpos( $template_value, "\r" ) )
119
  $offset = 1;
120
- else
121
  $offset = 0;
 
122
 
123
  $template_value = substr( $template_value, $offset );
124
-
125
  /*
126
  * Trim exactly one newline sequence from the end of the value
127
  */
128
  $length = strlen( $template_value );
129
- if ( $length > 2)
130
  $postfix = substr( $template_value, ($length - 2), 2 );
131
- else
132
  $postfix = $template_value;
133
-
134
- if ( 0 === strpos( $postfix, "\r\n" ) )
 
135
  $length -= 2;
136
- elseif ( 0 === strpos( $postfix, "\n\r" ) )
137
  $length -= 2;
138
- elseif ( 0 === strpos( $postfix, "\n" ) )
139
  $length -= 1;
140
- elseif ( 0 === strpos( $postfix, "\r" ) )
141
  $length -= 1;
142
-
 
143
  $template_array[ $template_key ] = substr( $template_value, 0, $length );
144
  $current_offset = $value[1];
145
  } // foreach $matches
146
-
147
  return $template_array;
148
  }
149
-
150
  /**
151
  * Find a complete template, balancing opening and closing delimiters
152
  *
@@ -163,26 +194,25 @@ class MLAData {
163
  do {
164
  $template_end = strpos( $tpl, '+]', $nest );
165
  if ( false === $template_end ) {
166
- error_log( 'ERROR: mla_parse_template no template end delimiter tail = ' . var_export( substr( $tpl, $offset ), true ), 0 );
 
167
  return '';
168
  }
169
-
170
  $nest = strpos( $tpl, '[+', $nest );
171
  if ( false === $nest ) {
172
  $nest = $template_end + 2;
173
  $level--;
174
- }
175
- elseif ( $nest < $template_end ) {
176
  $nest += 2;
177
  $level++;
178
- }
179
- else {
180
  $nest = $template_end + 2;
181
  $level--;
182
  }
183
-
184
  } while ( $level );
185
-
186
  $template_length = $template_end + 2;
187
  $template_content = substr( $tpl, 0, $template_length );
188
  return $template_content;
@@ -190,7 +220,7 @@ class MLAData {
190
 
191
  return '';
192
  }
193
-
194
  /**
195
  * Expand a template, replacing placeholders with their values
196
  *
@@ -201,15 +231,17 @@ class MLAData {
201
  * @param string A formatting string containing [+placeholders+]
202
  * @param array An associative array containing keys and values e.g. array('key' => 'value')
203
  *
204
- * @return mixed string or array, depending on placeholder values. Placeholders corresponding to the keys of the markup_values will be replaced with their values.
 
205
  */
206
  public static function mla_parse_array_template( $tpl, $markup_values ) {
207
  $result = array();
208
  $offset = 0;
209
  while ( false !== $start = strpos( $tpl, '[+', $offset ) ) {
210
- if ( $offset < $start )
211
  $result[] = substr( $tpl, $offset, ( $start - $offset ) );
212
-
 
213
  if ( $template_content = self::_find_template_substring( substr( $tpl, $start ) ) ) {
214
  $template_length = strlen( $template_content );
215
  $template_content = substr( $template_content, 11, $template_length - (11 + 2) );
@@ -217,29 +249,29 @@ class MLAData {
217
 
218
  foreach ( $template_content as $value )
219
  $result[] = $value;
220
-
221
  $offset = $start + $template_length;
222
- } // found template
223
- else {
224
  if ( false === $end = strpos( $tpl, '+]', $offset ) ) {
225
- error_log( 'ERROR: mla_parse_array_template no end delimiter, tail = ' . var_export( substr( $tpl, $offset ), true ), 0 );
 
226
  return $tpl;
227
  } // no end delimiter
228
 
229
  $key = substr( $tpl, $start + 2, $end - $start - 2 );
230
  if ( isset( $markup_values[ $key ] ) ) {
231
  $result[] = $markup_values[ $key ];
232
- } // found key and scalar value
233
- else {
234
  $result[] = substr( $tpl, $start, ( $end + 2 ) - $start );
235
  }
236
 
237
  $offset = $end + 2;
238
  } // simple substitution
239
  } // while substitution parameter present
240
-
241
- if ( $offset < strlen( $tpl ) )
242
  $result[] = substr( $tpl, $offset );
 
243
 
244
  /*
245
  * Build a final result, eliminating empty elements and expanding array elements
@@ -248,36 +280,40 @@ class MLAData {
248
  foreach ( $result as $element ) {
249
  if ( is_scalar( $element ) ) {
250
  $element = trim( $element );
251
- if ( ! empty( $element ) )
252
- $final[] = $element;
253
- }
254
- elseif ( is_array( $element ) ) {
255
  foreach ($element as $key => $value ) {
256
- if ( is_scalar( $value ) )
257
  $value = trim( $value );
258
- elseif ( ! empty( $value ) )
259
  $value = var_export( $value, true );
 
260
 
261
  /*
262
  * Preserve any keys with string values
263
  */
264
- if ( ! empty( $value ) )
265
- if ( is_integer( $key ) )
266
  $final[] = $value;
267
- else
268
  $final[ $key ] = $value;
 
 
269
  }
270
- }
271
- elseif ( ! empty( $element ) )
272
  $final[] = var_export( $element, true );
 
273
  }
274
-
275
- if ( 1 == count( $final ) )
276
  $final = $final[0];
277
-
 
278
  return $final;
279
  }
280
-
281
  /**
282
  * Expand a template, replacing placeholders with their values
283
  *
@@ -303,10 +339,10 @@ class MLAData {
303
  $template_content = self::_expand_field_level_template( $template_content, $markup_values );
304
  $tpl = substr_replace( $tpl, $template_content, $start, $template_length );
305
  $offset = $start;
306
- } // found template
307
- else {
308
  if ( false === $end = strpos( $tpl, '+]', $offset ) ) {
309
- error_log( 'ERROR: mla_parse_template no end delimiter, tail = ' . var_export( substr( $tpl, $offset ), true ), 0 );
 
310
  return $tpl;
311
  } // no end delimiter
312
 
@@ -314,24 +350,25 @@ class MLAData {
314
  if ( isset( $markup_values[ $key ] ) && is_scalar( $markup_values[ $key ] ) ) {
315
  $tpl = substr_replace( $tpl, $markup_values[ $key ], $start, strlen( $key ) + 4 );
316
  $offset = $start;
317
- } // found key and scalar value
318
- else
319
  $offset += strlen( $key ) + 4;
 
320
  } // simple substitution
321
  } // while substitution parameter present
322
- } // template(s) present
323
- else
324
  /*
325
  * No templates means a simple string substitution will suffice
326
  */
327
  foreach ( $markup_values as $key => $value ) {
328
- if ( is_scalar( $value ) )
329
  $tpl = str_replace( '[+' . $key . '+]', $value, $tpl );
 
330
  }
331
-
 
332
  return $tpl;
333
  }
334
-
335
  /**
336
  * Find a complete (test) element, balancing opening and closing delimiters
337
  *
@@ -348,25 +385,24 @@ class MLAData {
348
  do {
349
  $test_end = strpos( $tpl, ')', $nest );
350
  if ( false === $test_end ) {
351
- error_log( 'ERROR: _find_test_substring no end delimiter tail = ' . var_export( substr( $tpl, $nest ), true ), 0 );
 
352
  return '';
353
  }
354
-
355
  $nest = strpos( $tpl, '(', $nest );
356
  if ( false === $nest ) {
357
  $nest = $test_end + 1;
358
  $level--;
359
- }
360
- elseif ( $nest < $test_end ) {
361
  $nest += 1;
362
  $level++;
363
- }
364
- else {
365
  $nest = $test_end + 1;
366
  $level--;
367
  }
368
  } while ( $level );
369
-
370
  $test_length = $test_end + 1;
371
  $test_content = substr( $tpl, 0, $test_length );
372
  return $test_content;
@@ -374,7 +410,7 @@ class MLAData {
374
 
375
  return '';
376
  }
377
-
378
  /**
379
  * Convert field-level "template:" string into its component parts
380
  *
@@ -398,7 +434,7 @@ class MLAData {
398
  $output .= $byte;
399
  continue;
400
  } // template ends with a backslash
401
-
402
  switch ( $tpl[ $index ] ) {
403
  case 'n':
404
  $output .= chr( 0x0A );
@@ -416,25 +452,26 @@ class MLAData {
416
  $output .= chr( 0x0C );
417
  break;
418
  default: // could be a 1- to 3-digit octal value
419
- if ( $max_length < ( $digit_limit = $index + 3 ) )
420
  $digit_limit = $max_length;
421
-
 
422
  $digit_index = $index;
423
  while ( $digit_index < $digit_limit )
424
- if ( ! ctype_digit( $tpl[ $digit_index ] ) )
425
  break;
426
- else
427
  $digit_index++;
 
428
 
429
  if ( $digit_count = $digit_index - $index ) {
430
  $output .= chr( octdec( substr( $tpl, $index, $digit_count ) ) );
431
  $index += $digit_count - 1;
432
- }
433
- else {// accept the character following the backslash
434
  $output .= $tpl[ $index ];
435
  }
436
  } // switch
437
-
438
  $index++;
439
  } // REVERSE SOLIDUS (backslash)
440
  elseif ( '(' == $byte ) {
@@ -449,10 +486,10 @@ class MLAData {
449
  $output_values[] = array( 'type' => 'test', 'value' => $values, 'length' => strlen( $test_content ) );
450
  $index += strlen( $test_content ) - 1;
451
  } // found a value
452
- elseif ( 2 == $test_length )
453
  $index++; // empty test string
454
- else {
455
- $test_content = ' ERROR: Test; no closing parenthesis ';
456
  $output_values[] = array( 'type' => 'string', 'value' => $test_content, 'length' => strlen( $test_content ) );
457
  } // bad test string
458
  } // (test) element
@@ -460,7 +497,7 @@ class MLAData {
460
  /*
461
  * Turn each alternative within a choice element into a conditional
462
  */
463
-
464
  if ( ! empty( $output ) ) {
465
  $output_values[] = array( 'type' => 'string', 'value' => $output, 'length' => strlen( $output ) );
466
  $output = '';
@@ -468,9 +505,10 @@ class MLAData {
468
 
469
  $length = 0;
470
  foreach ( $output_values as $value )
471
- if ( isset( $value['length'] ) )
472
  $length += $value['length'];
473
-
 
474
  $choice_values[] = array( 'type' => 'test', 'value' => $output_values, 'length' => $length );
475
  $output_values = array();
476
  } // choice element
@@ -482,40 +520,43 @@ class MLAData {
482
 
483
  $template_content = self::_find_template_substring( substr( $tpl, $index - 1 ) );
484
  $values = self::_parse_field_level_template( substr( $template_content, 11, strlen( $template_content ) - (11 + 2) ) );
485
- if ( 'template' == $values['type'] )
486
  $output_values = array_merge( $output_values, $values['value'] );
487
- else
488
  $output_values[] = $values;
489
-
 
490
  $index += strlen( $template_content ) - 1;
491
- } // nested template
492
- else
493
  $output .= $byte;
 
494
  } // $index < $max_length
495
 
496
  if ( ! empty( $output ) ) {
497
  $output_values[] = array( 'type' => 'string', 'value' => $output, 'length' => strlen( $output ) );
498
  }
499
-
500
  if ( ! empty( $choice_values ) ) {
501
  if ( ! empty( $output_values ) ) {
502
  $length = 0;
503
  foreach ( $output_values as $value )
504
- if ( isset( $value['length'] ) )
505
  $length += $value['length'];
506
-
 
507
  $choice_values[] = array( 'type' => 'test', 'value' => $output_values, 'length' => $length );
508
  }
509
-
510
  return array( 'type' => 'choice', 'value' => $choice_values, 'length' => $max_length );
511
  }
512
 
513
- if ( 1 == count( $output_values ) )
514
  return $output_values[0];
 
515
 
516
  return array ( 'type' => 'template', 'value' => $output_values, 'length' => $max_length );
517
  }
518
-
519
  /**
520
  * Analyze a field-level "template:" element, expanding Field-level Markup Substitution Parameters
521
  *
@@ -539,41 +580,38 @@ class MLAData {
539
  foreach ( $node_result as $value )
540
  $result[] = $value;
541
  }
542
- } // array of sub-nodes
543
- else {
544
  switch ( $node['type'] ) {
545
  case 'string':
546
  $result[] = self::mla_parse_array_template( $node['value'], $markup_values );
547
  break;
548
  case 'test':
549
  $node_value = $node['value'];
550
-
551
  if ( isset( $node_value['type'] ) ) {
552
  $node_result = self::_evaluate_template_array_node( $node_value, $markup_values );
553
  foreach ( $node_result as $value )
554
  $result[] = $value;
555
- } // single node
556
- else {
557
  foreach ( $node_value as $value ) {
558
  $node_result = self::_evaluate_template_array_node( $value, $markup_values );
559
  foreach ( $node_result as $value )
560
  $result[] = $value;
561
  }
562
  } // array of nodes
563
-
564
  foreach ($result as $element )
565
  if ( is_scalar( $element ) && false !== strpos( $element, '[+' ) ) {
566
  $result = array();
567
  break;
568
- }
569
- elseif ( is_array( $element ) ) {
570
  foreach ( $element as $value )
571
  if ( is_scalar( $value ) && false !== strpos( $value, '[+' ) ) {
572
  $result = array();
573
  break;
574
  }
575
  } // is_array
576
-
577
  break;
578
  case 'choice':
579
  foreach ( $node['value'] as $value ) {
@@ -584,7 +622,7 @@ class MLAData {
584
  break;
585
  }
586
  }
587
-
588
  break;
589
  case 'template':
590
  foreach ( $node['value'] as $value ) {
@@ -595,13 +633,14 @@ class MLAData {
595
 
596
  break;
597
  default:
598
- error_log( 'ERROR: _evaluate_template_node unknown type = ' . var_export( $node, true ), 0 );
 
599
  } // node type
600
  } // isset node type
601
 
602
  return $result;
603
  }
604
-
605
  /**
606
  * Analyze a field-level "template:" element, expanding Field-level Markup Substitution Parameters
607
  *
@@ -623,7 +662,7 @@ class MLAData {
623
 
624
  return $results;
625
  } // array of sub-nodes
626
-
627
  switch ( $node['type'] ) {
628
  case 'string':
629
  return self::mla_parse_template( $node['value'], $markup_values );
@@ -632,14 +671,14 @@ class MLAData {
632
 
633
  if ( isset( $node_value['type'] ) ) {
634
  $results = self::_evaluate_template_node( $node_value, $markup_values );
635
- } // single node
636
- else {
637
  foreach ( $node_value as $value )
638
  $results .= self::_evaluate_template_node( $value, $markup_values );
639
  } // array of nodes
640
-
641
- if ( false === strpos( $results, '[+' ) )
642
  return $results;
 
643
 
644
  break;
645
  case 'choice':
@@ -649,20 +688,21 @@ class MLAData {
649
  return $results;
650
  }
651
  }
652
-
653
  break;
654
  case 'template':
655
  foreach ( $node['value'] as $value )
656
  $results .= self::_evaluate_template_node( $value, $markup_values );
657
-
658
  return $results;
659
  default:
660
- error_log( 'ERROR: _evaluate_template_node unknown type = ' . var_export( $node, true ), 0 );
 
661
  } // node type
662
 
663
  return '';
664
  }
665
-
666
  /**
667
  * Analyze a field-level "template:" element, expanding Field-level Markup Substitution Parameters
668
  *
@@ -681,30 +721,33 @@ class MLAData {
681
  */
682
  $root_element = self::_parse_field_level_template( $tpl );
683
  unset( $markup_values['[+template_count+]'] );
684
-
685
  /*
686
  * Step 2: Remove all the empty elements from the $markup_values,
687
  * so the evaluation of conditional and choice elements is simplified.
688
  */
689
  foreach ( $markup_values as $key => $value ) {
690
- if ( is_scalar( $value ) )
691
  $value = trim( $value );
692
-
693
- if ( empty( $value ) )
 
694
  unset( $markup_values[ $key ] );
 
695
  }
696
-
697
  /*
698
  * Step 3: walk the element tree and process each node
699
  */
700
- if ( $return_arrays )
701
  $results = self::_evaluate_template_array_node( $root_element, $markup_values );
702
- else
703
  $results = self::_evaluate_template_node( $root_element, $markup_values );
704
-
 
705
  return $results;
706
  }
707
-
708
  /**
709
  * Process an markup field array value according to the supplied data-format option
710
  *
@@ -738,10 +781,10 @@ class MLAData {
738
  $text .= strlen( $text ) ? ', ' . $term_name : $term_name;
739
  }
740
  } // $option
741
-
742
  return $text;
743
  }
744
-
745
  /**
746
  * Analyze a template, expanding Field-level Markup Substitution Parameters
747
  *
@@ -767,46 +810,51 @@ class MLAData {
767
  $attachment_metadata = NULL;
768
  $cached_post_id = $post_id;
769
  }
770
-
771
  $placeholders = self::mla_get_template_placeholders( $tpl, $default_option );
772
  $template_count = 0;
773
  foreach ($placeholders as $key => $value ) {
774
- if ( isset( $markup_values[ $key ] ) )
775
  continue;
776
-
 
777
  switch ( $value['prefix'] ) {
778
  case 'template':
779
  $markup_values = self::mla_expand_field_level_parameters( $value['value'], $query , $markup_values, $post_id, $keep_existing, $default_option );
780
  $template_count++;
781
  break;
782
  case 'meta':
783
- if ( is_null( $item_metadata ) )
784
- if ( 0 < $post_id )
785
  $item_metadata = get_metadata( 'post', $post_id, '_wp_attachment_metadata', true );
786
- else
787
  break;
 
 
788
 
789
  $markup_values[ $key ] = self::mla_find_array_element( $value['value'], $item_metadata, $value['option'] );
790
  break;
791
  case 'query':
792
- if ( isset( $query ) && isset( $query[ $value['value'] ] ) )
793
  $markup_values[ $key ] = $query[ $value['value'] ];
794
- else
795
  $markup_values[ $key ] = '';
 
796
 
797
  break;
798
  case 'request':
799
- if ( isset( $_REQUEST[ $value['value'] ] ) )
800
  $record = $_REQUEST[ $value['value'] ];
801
- else
802
  $record = '';
 
803
 
804
- if ( is_scalar( $record ) )
805
  $text = sanitize_text_field( (string) $record );
806
- elseif ( is_array( $record ) ) {
807
- if ( 'export' == $value['option'] )
808
  $text = sanitize_text_field( var_export( $record, true ) );
809
- else {
810
  $text = '';
811
  foreach ( $record as $term ) {
812
  $term_name = sanitize_text_field( $term );
@@ -818,27 +866,28 @@ class MLAData {
818
  $markup_values[ $key ] = $text;
819
  break;
820
  case 'terms':
821
- if ( 0 < $post_id )
822
  $terms = wp_get_object_terms( $post_id, $value['value'] );
823
- else
824
  break;
825
-
 
826
  $text = '';
827
  if ( is_wp_error( $terms ) ) {
828
  $text = implode( ',', $terms->get_error_messages() );
829
- }
830
- elseif ( ! empty( $terms ) ) {
831
- if ( 'single' == $value['option'] || 1 == count( $terms ) )
832
  $text = sanitize_term_field( 'name', $terms[0]->name, $terms[0]->term_id, $value, 'display' );
833
- elseif ( 'export' == $value['option'] )
834
  $text = sanitize_text_field( var_export( $terms, true ) );
835
- else
836
  foreach ( $terms as $term ) {
837
  $term_name = sanitize_term_field( 'name', $term->name, $term->term_id, $value, 'display' );
838
  $text .= strlen( $text ) ? ', ' . $term_name : $term_name;
839
  }
 
840
  }
841
-
842
  $markup_values[ $key ] = $text;
843
  break;
844
  case 'custom':
@@ -848,18 +897,20 @@ class MLAData {
848
  $meta_values = self::mla_fetch_attachment_metadata( $post_id );
849
  $clean_data = array();
850
  foreach( $meta_values as $meta_key => $meta_value ) {
851
- if ( 0 !== strpos( $meta_key, 'mla_item_' ) )
852
  continue;
853
-
 
854
  $meta_key = substr( $meta_key, 9 );
855
- if ( is_array( $meta_value ) )
856
  $clean_data[ $meta_key ] = '(ARRAY)';
857
- elseif ( is_string( $meta_value ) )
858
  $clean_data[ $meta_key ] = self::_bin_to_utf8( substr( $meta_value, 0, 256 ) );
859
- else
860
  $clean_data[ $meta_key ] = $meta_value;
 
861
  } // foreach value
862
-
863
  /*
864
  * Convert the array to text, strip the outer "array( ... ,)" literal,
865
  * the interior linefeed/space/space separators and backslashes.
@@ -869,20 +920,20 @@ class MLAData {
869
  $record = str_replace( chr(0x0A).' ', ' ', $record );
870
  $record = str_replace( '\\', '', $record );
871
  } // ALL_CUSTOM
872
- }
873
- else
874
  break;
875
-
 
876
  $text = '';
877
- if ( is_wp_error( $record ) )
878
  $text = implode( ',', $terms->get_error_messages() );
879
- elseif ( ! empty( $record ) ) {
880
- if ( is_scalar( $record ) )
881
  $text = sanitize_text_field( (string) $record );
882
- elseif ( is_array( $record ) ) {
883
- if ( 'export' == $value['option'] )
884
  $text = sanitize_text_field( var_export( $record, true ) );
885
- else {
886
  $text = '';
887
  foreach ( $record as $term ) {
888
  $term_name = sanitize_text_field( $term );
@@ -891,63 +942,72 @@ class MLAData {
891
  }
892
  } // is_array
893
  } // ! empty
894
-
895
  $markup_values[ $key ] = $text;
896
  break;
897
  case 'iptc':
898
  if ( is_null( $attachment_metadata ) ) {
899
- if ( 0 < $post_id )
900
  $attachment_metadata = self::mla_fetch_attachment_image_metadata( $post_id );
901
- else
902
  break;
 
903
  }
904
-
905
  $record = self::mla_iptc_metadata_value( $value['value'], $attachment_metadata );
906
- if ( is_array( $record ) )
907
  $markup_values[ $key ] = self::_process_field_level_array( $record, $value['option'], $keep_existing );
908
- else
909
  $markup_values[ $key ] = $record;
 
910
 
911
  break;
912
  case 'exif':
913
  if ( is_null( $attachment_metadata ) ) {
914
- if ( 0 < $post_id )
915
  $attachment_metadata = self::mla_fetch_attachment_image_metadata( $post_id );
916
- else
917
  break;
 
918
  }
919
-
920
  $record = self::mla_exif_metadata_value( $value['value'], $attachment_metadata );
921
- if ( is_array( $record ) )
922
  $markup_values[ $key ] = self::_process_field_level_array( $record, $value['option'], $keep_existing );
923
- else
924
  $markup_values[ $key ] = $record;
 
 
925
  break;
926
  case 'pdf':
927
  if ( is_null( $attachment_metadata ) ) {
928
- if ( 0 < $post_id )
929
  $attachment_metadata = self::mla_fetch_attachment_image_metadata( $post_id );
930
- else
931
  break;
 
932
  }
933
-
934
  $record = self::mla_pdf_metadata_value( $value['value'], $attachment_metadata );
935
- if ( is_array( $record ) )
936
  $markup_values[ $key ] = self::_process_field_level_array( $record, $value['option'], $keep_existing );
937
- else
938
  $markup_values[ $key ] = $record;
 
 
939
  break;
940
  default:
941
  // ignore anything else
942
  } // switch
943
  } // foreach placeholder
944
-
945
- if ( $template_count )
946
  $markup_values['[+template_count+]'] = $template_count;
947
-
 
948
  return $markup_values;
949
  }
950
-
951
  /**
952
  * Analyze a template, returning an array of the placeholders it contains
953
  *
@@ -972,26 +1032,25 @@ class MLAData {
972
  do {
973
  $template_end = strpos( $tpl, '+]', $nest );
974
  if ( false === $template_end ) {
975
- error_log( 'ERROR: mla_get_template_placeholders no template-end delimiter dump = ' . var_export( self::_hex_dump( substr( $tpl, $template_offset, 128 ), 128, 16 ), true ), 0 );
 
976
  return array();
977
  }
978
-
979
  $nest = strpos( $tpl, '[+', $nest );
980
  if ( false === $nest ) {
981
  $nest = $template_end + 2;
982
  $level--;
983
- }
984
- elseif ( $nest < $template_end ) {
985
  $nest += 2;
986
  $level++;
987
- }
988
- else {
989
  $nest = $template_end + 2;
990
  $level--;
991
  }
992
-
993
  } while ( $level );
994
-
995
  $template_length = $template_end + 2 - $template_offset;
996
  $template_content = substr( $tpl, $template_offset + 11, $template_length - (11 + 2) );
997
  $placeholders = self::mla_get_template_placeholders( $template_content );
@@ -999,11 +1058,12 @@ class MLAData {
999
  $results = array_merge( $results, $result, $placeholders );
1000
  $tpl = substr_replace( $tpl, '', $template_offset, $template_length );
1001
  } // found a template
1002
-
1003
  $match_count = preg_match_all( '/\[\+[^+]+\+\]/', $tpl, $matches );
1004
- if ( ( $match_count == false ) || ( $match_count == 0 ) )
1005
  return $results;
1006
-
 
1007
  foreach ( $matches[0] as $match ) {
1008
  $key = substr( $match, 2, (strlen( $match ) - 4 ) );
1009
  $result = array( 'prefix' => '', 'value' => '', 'option' => $default_option );
@@ -1011,26 +1071,24 @@ class MLAData {
1011
  if ( 1 == $match_count ) {
1012
  $result['prefix'] = $matches[1];
1013
  $tail = $matches[2];
1014
- }
1015
- else {
1016
  $tail = substr( $match, 2);
1017
  }
1018
-
1019
  $match_count = preg_match( '/([^,]+)(,(text|single|export|array|multi))\+\]/', $tail, $matches );
1020
  if ( 1 == $match_count ) {
1021
  $result['value'] = $matches[1];
1022
  $result['option'] = $matches[3];
1023
- }
1024
- else {
1025
  $result['value'] = substr( $tail, 0, (strlen( $tail ) - 2 ) );
1026
  }
1027
-
1028
  $results[ $key ] = $result;
1029
  } // foreach
1030
-
1031
  return $results;
1032
  }
1033
-
1034
  /**
1035
  * Cache the results of mla_count_list_table_items for reuse in mla_query_list_table_items
1036
  *
@@ -1039,7 +1097,7 @@ class MLAData {
1039
  * @var array
1040
  */
1041
  private static $mla_list_table_items = NULL;
1042
-
1043
  /**
1044
  * Get the total number of attachment posts
1045
  *
@@ -1062,10 +1120,10 @@ class MLAData {
1062
  $request = self::_prepare_list_table_query( $request );
1063
  $results = self::_execute_list_table_query( $request );
1064
  self::$mla_list_table_items = NULL;
1065
-
1066
  return $results->found_posts;
1067
  }
1068
-
1069
  /**
1070
  * Retrieve attachment objects for list table display
1071
  *
@@ -1095,7 +1153,7 @@ class MLAData {
1095
  foreach ( $parent_data as $parent_key => $parent_value ) {
1096
  $attachments[ $index ]->$parent_key = $parent_value;
1097
  }
1098
-
1099
  /*
1100
  * Add meta data
1101
  */
@@ -1109,10 +1167,10 @@ class MLAData {
1109
  $references = self::mla_fetch_attachment_references( $attachment->ID, $attachment->post_parent );
1110
  $attachments[ $index ]->mla_references = $references;
1111
  }
1112
-
1113
  return $attachments;
1114
  }
1115
-
1116
  /**
1117
  * Retrieve attachment objects for the WordPress Media Manager
1118
  *
@@ -1130,7 +1188,7 @@ class MLAData {
1130
  $request = self::_prepare_list_table_query( $request, $offset, $count );
1131
  return self::_execute_list_table_query( $request );
1132
  }
1133
-
1134
  /**
1135
  * WP_Query filter "parameters"
1136
  *
@@ -1166,10 +1224,11 @@ class MLAData {
1166
  * sanitize or validate them.
1167
  */
1168
  if ( ! is_array( $raw_request ) ) {
1169
- error_log( 'ERROR: _prepare_list_table_query $raw_request = ' . var_export( $raw_request, true ), 0 );
 
1170
  return null;
1171
  }
1172
-
1173
  /*
1174
  * Make sure the current orderby choice still exists or revert to default.
1175
  */
@@ -1197,7 +1256,7 @@ class MLAData {
1197
  'mla_search_connector' => 'AND',
1198
  'mla_search_fields' => array()
1199
  );
1200
-
1201
  foreach ( $raw_request as $key => $value ) {
1202
  switch ( $key ) {
1203
  /*
@@ -1211,9 +1270,9 @@ class MLAData {
1211
  $clean_request[ $key ] = sanitize_key( $value );
1212
  break;
1213
  case 'orderby':
1214
- if ( 'none' == $value )
1215
  $clean_request[ $key ] = $value;
1216
- else {
1217
  $sortable_columns = MLA_List_Table::mla_get_sortable_columns( );
1218
  foreach ($sortable_columns as $sort_key => $sort_value ) {
1219
  if ( $value == $sort_value[0] ) {
@@ -1259,12 +1318,16 @@ class MLAData {
1259
  }
1260
  break;
1261
  case 'detached':
1262
- if ( '1' == $value )
1263
  $clean_request['detached'] = '1';
 
 
1264
  break;
1265
  case 'status':
1266
- if ( 'trash' == $value )
1267
  $clean_request['post_status'] = 'trash';
 
 
1268
  break;
1269
  /*
1270
  * ['s'] - Search Media by one or more keywords
@@ -1279,14 +1342,17 @@ class MLAData {
1279
  $clean_request['debug'] = 'log';
1280
  break;
1281
  }
1282
-
1283
- if ( isset( $clean_request['debug'] ) )
1284
  $value = substr( $value, 3 );
1285
-
 
1286
  $value = stripslashes( trim( $value ) );
1287
-
1288
- if ( ! empty( $value ) )
1289
  $clean_request[ $key ] = $value;
 
 
1290
  break;
1291
  case 'mla_search_connector':
1292
  case 'mla_search_fields':
@@ -1298,25 +1364,26 @@ class MLAData {
1298
  break;
1299
  case 'meta_query':
1300
  if ( ! empty( $value ) ) {
1301
- if ( is_array( $value ) )
1302
  $clean_request[ $key ] = $value;
1303
- else {
1304
  $clean_request[ $key ] = unserialize( stripslashes( $value ) );
1305
  unset( $clean_request[ $key ]['slug'] );
1306
  } // not array
1307
  }
 
1308
  break;
1309
  default:
1310
  // ignore anything else in $_REQUEST
1311
  } // switch $key
1312
  } // foreach $raw_request
1313
-
1314
  /*
1315
  * Pass query parameters to the filters for _execute_list_table_query
1316
  */
1317
  self::$query_parameters = array( 'use_postmeta_view' => false, 'orderby' => $clean_request['orderby'], 'order' => $clean_request['order'] );
1318
  self::$query_parameters['detached'] = isset( $clean_request['detached'] );
1319
-
1320
  /*
1321
  * Matching a meta_value to NULL requires a LEFT JOIN to a view and a special WHERE clause
1322
  * Matching a wildcard pattern requires mainpulating the WHERE clause, too
@@ -1326,8 +1393,7 @@ class MLAData {
1326
  self::$query_parameters['postmeta_key'] = $clean_request['meta_query']['key'];
1327
  self::$query_parameters['postmeta_value'] = NULL;
1328
  unset( $clean_request['meta_query'] );
1329
- }
1330
- elseif ( isset( $clean_request['meta_query']['patterns'] ) ) {
1331
  self::$query_parameters['patterns'] = $clean_request['meta_query']['patterns'];
1332
  unset( $clean_request['meta_query']['patterns'] );
1333
  }
@@ -1336,12 +1402,13 @@ class MLAData {
1336
  self::$query_parameters['debug'] = $clean_request['debug'];
1337
  unset( $clean_request['debug'] );
1338
  }
1339
-
1340
  /*
1341
  * We must patch the WHERE clause if there are leading spaces in the meta_value
1342
  */
1343
- if ( isset( $clean_request['mla-metavalue'] ) && (' ' == $clean_request['mla-metavalue'][0] ) )
1344
  self::$query_parameters['mla-metavalue'] = $clean_request['mla-metavalue'];
 
1345
 
1346
  /*
1347
  * We will handle keyword search in the mla_query_posts_search_filter.
@@ -1354,12 +1421,13 @@ class MLAData {
1354
  self::$query_parameters['mla_search_fields'] = $clean_request['mla_search_fields'];
1355
  self::$query_parameters['sentence'] = isset( $clean_request['sentence'] );
1356
  self::$query_parameters['exact'] = isset( $clean_request['exact'] );
1357
-
1358
- if ( in_array( 'alt-text', self::$query_parameters['mla_search_fields'] ) )
1359
  self::$query_parameters['use_postmeta_view'] = true;
1360
  self::$query_parameters['postmeta_key'] = '_wp_attachment_image_alt';
 
1361
  } // !empty
1362
-
1363
  // unset( $clean_request['s'] ); // WP v3.7 requires this to be present for posts_search filter
1364
  unset( $clean_request['mla_search_connector'] );
1365
  unset( $clean_request['mla_search_fields'] );
@@ -1376,13 +1444,16 @@ class MLAData {
1376
  if ( isset( $option_value['name'] ) ) {
1377
  self::$query_parameters['use_postmeta_view'] = true;
1378
  self::$query_parameters['postmeta_key'] = $option_value['name'];
1379
- if ( isset($clean_request['orderby']) )
 
1380
  unset($clean_request['orderby']);
1381
- if ( isset($clean_request['order']) )
 
 
1382
  unset($clean_request['order']);
 
1383
  }
1384
- } // custom field
1385
- else {
1386
  switch ( self::$query_parameters['orderby'] ) {
1387
  /*
1388
  * '_wp_attachment_image_alt' is special; we'll handle it in the JOIN and ORDERBY filters
@@ -1390,10 +1461,14 @@ class MLAData {
1390
  case '_wp_attachment_image_alt':
1391
  self::$query_parameters['use_postmeta_view'] = true;
1392
  self::$query_parameters['postmeta_key'] = '_wp_attachment_image_alt';
1393
- if ( isset($clean_request['orderby']) )
1394
  unset($clean_request['orderby']);
1395
- if ( isset($clean_request['order']) )
 
 
1396
  unset($clean_request['order']);
 
 
1397
  break;
1398
  case '_wp_attached_file':
1399
  $clean_request['meta_key'] = '_wp_attached_file';
@@ -1409,10 +1484,10 @@ class MLAData {
1409
  if ( ( (int) $count ) > 0 ) {
1410
  $clean_request['offset'] = $offset;
1411
  $clean_request['posts_per_page'] = $count;
1412
- }
1413
- elseif ( ( (int) $count ) == -1 )
1414
  $clean_request['posts_per_page'] = $count;
1415
-
 
1416
  /*
1417
  * ['mla_filter_term'] - filter by taxonomy
1418
  *
@@ -1435,8 +1510,7 @@ class MLAData {
1435
  'operator' => 'NOT IN'
1436
  )
1437
  );
1438
- } // mla_filter_term == -1
1439
- else {
1440
  $clean_request['tax_query'] = array(
1441
  array(
1442
  'taxonomy' => $tax_filter,
@@ -1449,10 +1523,10 @@ class MLAData {
1449
  );
1450
  } // mla_filter_term != -1
1451
  } // mla_filter_term != 0
1452
-
1453
  unset( $clean_request['mla_filter_term'] );
1454
  } // isset mla_filter_term
1455
-
1456
  if ( isset( $clean_request['mla-tax'] ) && isset( $clean_request['mla-term'] )) {
1457
  $clean_request['tax_query'] = array(
1458
  array(
@@ -1462,11 +1536,11 @@ class MLAData {
1462
  'include_children' => false
1463
  )
1464
  );
1465
-
1466
  unset( $clean_request['mla-tax'] );
1467
  unset( $clean_request['mla-term'] );
1468
  } // isset mla_tax
1469
-
1470
  if ( isset( $clean_request['mla-metakey'] ) && isset( $clean_request['mla-metavalue'] ) ) {
1471
  $clean_request['meta_key'] = $clean_request['mla-metakey'];
1472
  $clean_request['meta_value'] = $clean_request['mla-metavalue'];
@@ -1474,7 +1548,7 @@ class MLAData {
1474
  unset( $clean_request['mla-metakey'] );
1475
  unset( $clean_request['mla-metavalue'] );
1476
  } // isset mla_tax
1477
-
1478
  return $clean_request;
1479
  }
1480
 
@@ -1518,25 +1592,27 @@ class MLAData {
1518
  if ( isset( self::$query_parameters['debug'] ) ) {
1519
  global $wp_filter;
1520
  $debug_array = array( 'posts_search' => $wp_filter['posts_search'], 'posts_join' => $wp_filter['posts_join'], 'posts_where' => $wp_filter['posts_where'], 'posts_orderby' => $wp_filter['posts_orderby'] );
1521
-
1522
  if ( 'console' == self::$query_parameters['debug'] ) {
1523
- trigger_error( '_execute_list_table_query $wp_filter = ' . var_export( $debug_array, true ), E_USER_WARNING );
1524
- }
1525
- else {
1526
- error_log( 'DEBUG: _execute_list_table_query $wp_filter = ' . var_export( $debug_array, true ), 0 );
 
1527
  }
1528
  } // debug
1529
 
1530
  $results = new WP_Query( $request );
1531
-
1532
  if ( isset( self::$query_parameters['debug'] ) ) {
1533
  $debug_array = array( 'request' => $request, 'query_parameters' => self::$query_parameters, 'SQL_request' => $results->request, 'post_count' => $results->post_count, 'found_posts' => $results->found_posts );
1534
 
1535
  if ( 'console' == self::$query_parameters['debug'] ) {
1536
- trigger_error( '_execute_list_table_query WP_Query = ' . var_export( $debug_array, true ), E_USER_WARNING );
1537
- }
1538
- else {
1539
- error_log( 'DEBUG: _execute_list_table_query WP_Query = ' . var_export( $debug_array, true ), 0 );
 
1540
  }
1541
  } // debug
1542
 
@@ -1551,7 +1627,7 @@ class MLAData {
1551
 
1552
  return $results;
1553
  }
1554
-
1555
  /**
1556
  * Replaces a WordPress function deprecated in v3.7
1557
  *
@@ -1566,7 +1642,7 @@ class MLAData {
1566
  public static function mla_search_terms_tidy( $term ) {
1567
  return trim( $term, "\"'\n\r " );
1568
  }
1569
-
1570
  /**
1571
  * Adds a keyword search to the WHERE clause, if required
1572
  *
@@ -1586,33 +1662,34 @@ class MLAData {
1586
  */
1587
  $search_clause = '';
1588
  if ( isset( self::$query_parameters['s'] ) ) {
1589
-
1590
  if ( isset( self::$query_parameters['debug'] ) ) {
1591
  $debug_array = array( 's' => self::$query_parameters['s'] );
1592
  } // debug
1593
-
1594
  /*
1595
  * Interpret a numeric value as the ID of a specific attachment or the ID of a parent post/page
1596
  */
1597
- if( is_numeric( self::$query_parameters['s'] ) ) {
1598
  $id = absint( self::$query_parameters['s'] );
1599
  $search_clause = ' AND ( ( ' . $wpdb->posts . '.ID = ' . $id . ' ) OR ( ' . $wpdb->posts . '.post_parent = ' . $id . ' ) ) ';
1600
-
1601
  if ( isset( self::$query_parameters['debug'] ) ) {
1602
  $debug_array['search_clause'] = $search_clause;
1603
  $debug_array['search_string'] = $search_string;
1604
-
1605
  if ( 'console' == self::$query_parameters['debug'] ) {
1606
- trigger_error( 'mla_query_posts_search_filter is_numeric = ' . var_export( $debug_array, true ), E_USER_WARNING );
1607
- }
1608
- else {
1609
- error_log( 'DEBUG: mla_query_posts_search_filter is_numeric = ' . var_export( $debug_array, true ), 0 );
 
1610
  }
1611
  } // debug
1612
-
1613
  return $search_clause;
1614
  }
1615
-
1616
  // WordPress v3.7 says: there are no line breaks in <input /> fields
1617
  self::$query_parameters['s'] = str_replace( array( "\r", "\n" ), '', self::$query_parameters['s'] );
1618
 
@@ -1623,7 +1700,7 @@ class MLAData {
1623
  preg_match_all('/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', self::$query_parameters['s'], $matches);
1624
  $search_terms = array_map('MLAData::mla_search_terms_tidy', $matches[0]);
1625
  }
1626
-
1627
  $fields = self::$query_parameters['mla_search_fields'];
1628
  $percent = self::$query_parameters['exact'] ? '' : '%';
1629
  $connector = '';
@@ -1631,55 +1708,57 @@ class MLAData {
1631
  $term = esc_sql( like_escape( $term ) );
1632
  $inner_connector = '';
1633
  $search_clause .= "{$connector}(";
1634
-
1635
  if ( in_array( 'content', $fields ) ) {
1636
  $search_clause .= "{$inner_connector}({$wpdb->posts}.post_content LIKE '{$percent}{$term}{$percent}')";
1637
  $inner_connector = ' OR ';
1638
  }
1639
-
1640
  if ( in_array( 'title', $fields ) ) {
1641
  $search_clause .= "{$inner_connector}({$wpdb->posts}.post_title LIKE '{$percent}{$term}{$percent}')";
1642
  $inner_connector = ' OR ';
1643
  }
1644
-
1645
  if ( in_array( 'excerpt', $fields ) ) {
1646
  $search_clause .= "{$inner_connector}({$wpdb->posts}.post_excerpt LIKE '{$percent}{$term}{$percent}')";
1647
  $inner_connector = ' OR ';
1648
  }
1649
-
1650
  if ( in_array( 'alt-text', $fields ) ) {
1651
  $view_name = self::$mla_alt_text_view;
1652
  $search_clause .= "{$inner_connector}({$view_name}.meta_value LIKE '{$percent}{$term}{$percent}')";
1653
  $inner_connector = ' OR ';
1654
  }
1655
-
1656
  if ( in_array( 'name', $fields ) ) {
1657
  $search_clause .= "{$inner_connector}({$wpdb->posts}.post_name LIKE '{$percent}{$term}{$percent}')";
1658
  }
1659
-
1660
  $search_clause .= ")";
1661
  $connector = ' ' . self::$query_parameters['mla_search_connector'] . ' ';
1662
  } // foreach
1663
 
1664
  if ( !empty($search_clause) ) {
1665
  $search_clause = " AND ({$search_clause}) ";
1666
- if ( !is_user_logged_in() )
1667
  $search_clause .= " AND ($wpdb->posts.post_password = '') ";
 
1668
  }
1669
-
1670
  if ( isset( self::$query_parameters['debug'] ) ) {
1671
  $debug_array['search_clause'] = $search_clause;
1672
  $debug_array['search_string'] = $search_string;
1673
-
1674
  if ( 'console' == self::$query_parameters['debug'] ) {
1675
- trigger_error( 'mla_query_posts_search_filter not numeric = ' . var_export( $debug_array, true ), E_USER_WARNING );
1676
- }
1677
- else {
1678
- error_log( 'DEBUG: mla_query_posts_search_filter not numeric = ' . var_export( $debug_array, true ), 0 );
 
1679
  }
1680
  } // debug
1681
  } // isset 's'
1682
-
1683
  return $search_clause;
1684
  }
1685
 
@@ -1730,14 +1809,14 @@ class MLAData {
1730
  if ( isset( self::$query_parameters['mla-metavalue'] ) ) {
1731
  $where_clause = preg_replace( '/(^.*meta_value AS CHAR\) = \')([^\']*)/', '${1}' . self::$query_parameters['mla-metavalue'], $where_clause );
1732
  }
1733
-
1734
  /*
1735
  * Matching a NULL meta value
1736
  */
1737
  if ( array_key_exists( 'postmeta_value', self::$query_parameters ) && NULL == self::$query_parameters['postmeta_value'] ) {
1738
  $where_clause .= ' AND ' . self::$mla_alt_text_view . '.meta_value IS NULL';
1739
  }
1740
-
1741
  /*
1742
  * WordPress modifies the LIKE clause - which we must reverse
1743
  */
@@ -1747,12 +1826,13 @@ class MLAData {
1747
  $where_clause = str_replace( "LIKE '{$match_clause}'", "LIKE '{$pattern}'", $where_clause );
1748
  }
1749
  }
1750
-
1751
  /*
1752
  * Unattached items require some help
1753
  */
1754
- if ( self::$query_parameters['detached'] )
1755
  $where_clause .= " AND {$table_prefix}posts.post_parent < 1";
 
1756
 
1757
  return $where_clause;
1758
  }
@@ -1775,8 +1855,7 @@ class MLAData {
1775
  if ( isset( self::$query_parameters['orderby'] ) ) {
1776
  if ( 'c_' == substr( self::$query_parameters['orderby'], 0, 2 ) ) {
1777
  $orderby = self::$mla_alt_text_view . '.meta_value';
1778
- } // custom field sort
1779
- else {
1780
  switch ( self::$query_parameters['orderby'] ) {
1781
  case 'none':
1782
  $orderby = '';
@@ -1808,14 +1887,15 @@ class MLAData {
1808
  $orderby = "{$table_prefix}posts." . self::$query_parameters['orderby'];
1809
  } // $query_parameters['orderby']
1810
  }
1811
-
1812
- if ( ! empty( $orderby ) )
1813
  $orderby_clause = $orderby . ' ' . self::$query_parameters['order'];
 
1814
  } // isset
1815
 
1816
  return $orderby_clause;
1817
  }
1818
-
1819
  /**
1820
  * Retrieve an Attachment array given a $post_id
1821
  *
@@ -1831,48 +1911,50 @@ class MLAData {
1831
  function mla_get_attachment_by_id( $post_id ) {
1832
  global $post;
1833
  static $save_id = -1, $post_data;
1834
-
1835
- if ( $post_id == $save_id )
1836
  return $post_data;
1837
- elseif ( $post_id == -1 ) {
1838
  $save_id = -1;
1839
  return NULL;
1840
  }
1841
-
1842
  $item = get_post( $post_id );
1843
  if ( empty( $item ) ) {
1844
- error_log( "ERROR: mla_get_attachment_by_id({$post_id}) not found", 0 );
 
1845
  return NULL;
1846
  }
1847
-
1848
  if ( $item->post_type != 'attachment' ) {
1849
- error_log( "ERROR: mla_get_attachment_by_id({$post_id}) wrong post_type: " . $item->post_type, 0 );
 
1850
  return NULL;
1851
  }
1852
-
1853
  $post_data = (array) $item;
1854
  $post = $item;
1855
  setup_postdata( $item );
1856
-
1857
  /*
1858
  * Add parent data
1859
  */
1860
  $post_data = array_merge( $post_data, self::mla_fetch_attachment_parent_data( $post_data['post_parent'] ) );
1861
-
1862
  /*
1863
  * Add meta data
1864
  */
1865
  $post_data = array_merge( $post_data, self::mla_fetch_attachment_metadata( $post_id ) );
1866
-
1867
  /*
1868
  * Add references
1869
  */
1870
  $post_data['mla_references'] = self::mla_fetch_attachment_references( $post_id, $post_data['post_parent'] );
1871
-
1872
  $save_id = $post_id;
1873
  return $post_data;
1874
  }
1875
-
1876
  /**
1877
  * Returns information about an attachment's parent, if found
1878
  *
@@ -1884,25 +1966,32 @@ class MLAData {
1884
  */
1885
  public static function mla_fetch_attachment_parent_data( $parent_id ) {
1886
  static $save_id = -1, $parent_data;
1887
-
1888
- if ( $save_id == $parent_id )
1889
  return $parent_data;
1890
-
 
1891
  $parent_data = array();
1892
  if ( $parent_id ) {
1893
  $parent = get_post( $parent_id );
1894
- if ( isset( $parent->post_date ) )
 
1895
  $parent_data['parent_date'] = $parent->post_date;
1896
- if ( isset( $parent->post_title ) )
 
 
1897
  $parent_data['parent_title'] = $parent->post_title;
1898
- if ( isset( $parent->post_type ) )
 
 
1899
  $parent_data['parent_type'] = $parent->post_type;
 
1900
  }
1901
-
1902
  $save_id = $parent_id;
1903
  return $parent_data;
1904
  }
1905
-
1906
  /**
1907
  * Adds or replaces the value of a key in a possibly nested array structure
1908
  *
@@ -1917,7 +2006,7 @@ class MLAData {
1917
  private static function _set_array_element( $needle, &$value, &$haystack ) {
1918
  $key_array = explode( '.', $needle );
1919
  $key = array_shift( $key_array );
1920
-
1921
  if ( empty( $key_array ) ) {
1922
  $haystack[ $key ] = $value;
1923
  return true;
@@ -1928,15 +2017,16 @@ class MLAData {
1928
  * If an intermediate key does not exist, create an empty array for it.
1929
  */
1930
  if ( isset( $haystack[ $key ] ) ) {
1931
- if ( ! is_array( $haystack[ $key ] ) )
1932
  return false;
1933
- }
1934
- else
1935
  $haystack[ $key ] = array();
1936
-
 
1937
  return self::_set_array_element( implode( $key_array, '.' ), $value, $haystack[ $key ] );
1938
  }
1939
-
1940
  /**
1941
  * Deletes the value of a key in a possibly nested array structure
1942
  *
@@ -1950,22 +2040,23 @@ class MLAData {
1950
  private static function _unset_array_element( $needle, &$haystack ) {
1951
  $key_array = explode( '.', $needle );
1952
  $key = array_shift( $key_array );
1953
-
1954
  if ( empty( $key_array ) ) {
1955
  if ( isset( $haystack[ $key ] ) ) {
1956
  unset( $haystack[ $key ] );
1957
  return true;
1958
  }
1959
-
1960
  return false;
1961
  } // lowest level
1962
 
1963
- if ( isset( $haystack[ $key ] ) )
1964
  return self::_unset_array_element( implode( $key_array, '.' ), $haystack[ $key ] );
 
1965
 
1966
  return false;
1967
  }
1968
-
1969
  /**
1970
  * Finds the value of a key in a possibly nested array structure
1971
  *
@@ -1986,16 +2077,18 @@ class MLAData {
1986
  if ( is_array( $key_array ) ) {
1987
  foreach ( $key_array as $key ) {
1988
  if ( is_array( $haystack ) ) {
1989
- if ( isset( $haystack[ $key ] ) )
1990
  $haystack = $haystack[ $key ];
1991
- else
1992
  $haystack = '';
1993
- }
1994
- else
1995
  $haystack = '';
 
1996
  } // foreach $key
 
 
1997
  }
1998
- else $haystack = '';
1999
 
2000
  if ( is_array( $haystack ) ) {
2001
  switch ( $option ) {
@@ -2016,10 +2109,10 @@ class MLAData {
2016
  $haystack = implode( ', ', $haystack );
2017
  } // $option
2018
  }
2019
-
2020
  return sanitize_text_field( $haystack );
2021
  } // mla_find_array_element
2022
-
2023
  /**
2024
  * Fetch and filter meta data for an attachment
2025
  *
@@ -2034,18 +2127,20 @@ class MLAData {
2034
  */
2035
  public static function mla_fetch_attachment_metadata( $post_id ) {
2036
  static $save_id = 0, $results;
2037
-
2038
- if ( $save_id == $post_id )
2039
  return $results;
2040
-
 
2041
  $attached_file = NULL;
2042
  $results = array();
2043
  $post_meta = get_metadata( 'post', $post_id );
2044
  if ( is_array( $post_meta ) ) {
2045
  foreach ( $post_meta as $post_meta_key => $post_meta_value ) {
2046
- if ( empty( $post_meta_key ) )
2047
  continue;
2048
-
 
2049
  if ( '_' == $post_meta_key{0} ) {
2050
  if ( stripos( $post_meta_key, '_wp_attached_file' ) === 0 ) {
2051
  $key = 'mla_wp_attached_file';
@@ -2058,23 +2153,26 @@ class MLAData {
2058
  continue;
2059
  }
2060
  } else {
2061
- if ( stripos( $post_meta_key, 'mla_' ) === 0 )
2062
  $key = $post_meta_key;
2063
- else
2064
  $key = 'mla_item_' . $post_meta_key;
 
2065
  }
2066
-
2067
  /*
2068
  * At this point, every value is an array; one element per instance of the key.
2069
  * We'll test anyway, just to be sure, then convert single-instance values to a scalar.
2070
  * Metadata array values are serialized for storage in the database.
2071
  */
2072
  if ( is_array( $post_meta_value ) ) {
2073
- if ( count( $post_meta_value ) == 1 )
2074
  $post_meta_value = maybe_unserialize( $post_meta_value[0] );
2075
- else
2076
- foreach ( $post_meta_value as $single_key => $single_value )
2077
  $post_meta_value[ $single_key ] = maybe_unserialize( $single_value );
 
 
2078
  }
2079
 
2080
  $results[ $key ] = $post_meta_value;
@@ -2085,18 +2183,17 @@ class MLAData {
2085
  if ( false === $last_slash ) {
2086
  $results['mla_wp_attached_path'] = '';
2087
  $results['mla_wp_attached_filename'] = $attached_file;
2088
- }
2089
- else {
2090
  $results['mla_wp_attached_path'] = substr( $attached_file, 0, $last_slash + 1 );
2091
  $results['mla_wp_attached_filename'] = substr( $attached_file, $last_slash + 1 );
2092
  }
2093
  } // $attached_file
2094
  } // is_array($post_meta)
2095
-
2096
  $save_id = $post_id;
2097
  return $results;
2098
  }
2099
-
2100
  /**
2101
  * Find Featured Image and inserted image/link references to an attachment
2102
  *
@@ -2113,10 +2210,11 @@ class MLAData {
2113
  public static function mla_fetch_attachment_references( $ID, $parent ) {
2114
  global $wpdb;
2115
  static $save_id = 0, $references, $inserted_in_option = NULL;
2116
-
2117
- if ( $save_id == $ID )
2118
  return $references;
2119
-
 
2120
  /*
2121
  * tested_reference true if any of the four where-used types was processed
2122
  * found_reference true if any where-used array is not empty()
@@ -2158,23 +2256,27 @@ class MLAData {
2158
  'parent_title' => '',
2159
  'parent_errors' => ''
2160
  );
2161
-
2162
  /*
2163
  * Fill in Parent data
2164
  */
2165
  $parent_data = self::mla_fetch_attachment_parent_data( $parent );
2166
- if ( isset( $parent_data['parent_type'] ) )
2167
  $references['parent_type'] = $parent_data['parent_type'];
2168
- if ( isset( $parent_data['parent_title'] ) )
 
 
2169
  $references['parent_title'] = $parent_data['parent_title'];
 
2170
 
2171
  $references['base_file'] = get_post_meta( $ID, '_wp_attached_file', true );
2172
  $pathinfo = pathinfo($references['base_file']);
2173
  $references['file'] = $pathinfo['basename'];
2174
- if ( '.' == $pathinfo['dirname'] )
2175
  $references['path'] = '/';
2176
- else
2177
  $references['path'] = $pathinfo['dirname'] . '/';
 
2178
 
2179
  $attachment_metadata = get_post_meta( $ID, '_wp_attachment_metadata', true );
2180
  $sizes = isset( $attachment_metadata['sizes'] ) ? $attachment_metadata['sizes'] : NULL;
@@ -2184,16 +2286,17 @@ class MLAData {
2184
  $references['files'][ $references['path'] . $size['file'] ] = $size;
2185
  }
2186
  }
2187
-
2188
  $references['files'][ $references['base_file'] ] = $references['base_file'];
2189
 
2190
  /*
2191
  * Process the where-used settings option
2192
  */
2193
- if ('checked' == MLAOptions::mla_get_option( MLAOptions::MLA_EXCLUDE_REVISIONS ) )
2194
  $exclude_revisions = "(post_type <> 'revision') AND ";
2195
- else
2196
  $exclude_revisions = '';
 
2197
 
2198
  /*
2199
  * Accumulate reference test types, e.g., 0 = no tests, 4 = all tests
@@ -2212,7 +2315,7 @@ class MLAData {
2212
  WHERE meta_key = '_thumbnail_id' AND meta_value = {$ID}
2213
  "
2214
  );
2215
-
2216
  if ( !empty( $features ) ) {
2217
  foreach ( $features as $feature ) {
2218
  $feature_results = $wpdb->get_results(
@@ -2222,11 +2325,11 @@ class MLAData {
2222
  WHERE {$exclude_revisions}(ID = {$feature->post_id})
2223
  "
2224
  );
2225
-
2226
  if ( !empty( $feature_results ) ) {
2227
  $references['found_reference'] = true;
2228
  $references['features'][ $feature->post_id ] = $feature_results[0];
2229
-
2230
  if ( $feature->post_id == $parent ) {
2231
  $references['found_parent'] = true;
2232
  }
@@ -2234,16 +2337,17 @@ class MLAData {
2234
  } // foreach $feature
2235
  }
2236
  } // $process_featured_in
2237
-
2238
  /*
2239
  * Look for item(s) inserted in post_content
2240
  */
2241
  if ( MLAOptions::$process_inserted_in ) {
2242
  $reference_tests++;
2243
 
2244
- if ( NULL == $inserted_in_option )
2245
  $inserted_in_option = MLAOptions::mla_get_option( MLAOptions::MLA_INSERTED_IN_TUNING );
2246
-
 
2247
  if ( 'base' == $inserted_in_option ) {
2248
  $like1 = like_escape( $references['path'] . $pathinfo['filename'] ) . '.' . like_escape( $pathinfo['extension'] );
2249
  $like2 = like_escape( $references['path'] . $pathinfo['filename'] ) . '-%.' . like_escape( $pathinfo['extension'] );
@@ -2258,15 +2362,14 @@ class MLAData {
2258
  if ( !empty( $inserts ) ) {
2259
  $references['found_reference'] = true;
2260
  $references['inserts'][ $pathinfo['filename'] ] = $inserts;
2261
-
2262
  foreach ( $inserts as $insert ) {
2263
  if ( $insert->ID == $parent ) {
2264
  $references['found_parent'] = true;
2265
  }
2266
  } // foreach $insert
2267
  } // !empty
2268
- } // process base names
2269
- else {
2270
  foreach ( $references['files'] as $file => $file_data ) {
2271
  $like = like_escape( $file );
2272
  $inserts = $wpdb->get_results(
@@ -2275,11 +2378,11 @@ class MLAData {
2275
  WHERE {$exclude_revisions}(CONVERT(`post_content` USING utf8 ) LIKE %s)", "%{$like}%"
2276
  )
2277
  );
2278
-
2279
  if ( !empty( $inserts ) ) {
2280
  $references['found_reference'] = true;
2281
  $references['inserts'][ $file ] = $inserts;
2282
-
2283
  foreach ( $inserts as $insert ) {
2284
  if ( $insert->ID == $parent ) {
2285
  $references['found_parent'] = true;
@@ -2289,7 +2392,7 @@ class MLAData {
2289
  } // foreach $file
2290
  } // process intermediate sizes
2291
  } // $process_inserted_in
2292
-
2293
  /*
2294
  * Look for [mla_gallery] references
2295
  */
@@ -2300,18 +2403,18 @@ class MLAData {
2300
  if ( !empty( $galleries ) ) {
2301
  $references['found_reference'] = true;
2302
  $references['mla_galleries'] = $galleries;
2303
-
2304
  foreach ( $galleries as $post_id => $gallery ) {
2305
  if ( $post_id == $parent ) {
2306
  $references['found_parent'] = true;
2307
  }
2308
  } // foreach $gallery
2309
- } // !empty
2310
- else
2311
  $references['mla_galleries'] = array();
 
2312
  }
2313
  } // $process_mla_gallery_in
2314
-
2315
  /*
2316
  * Look for [gallery] references
2317
  */
@@ -2322,48 +2425,50 @@ class MLAData {
2322
  if ( !empty( $galleries ) ) {
2323
  $references['found_reference'] = true;
2324
  $references['galleries'] = $galleries;
2325
-
2326
  foreach ( $galleries as $post_id => $gallery ) {
2327
  if ( $post_id == $parent ) {
2328
  $references['found_parent'] = true;
2329
  }
2330
  } // foreach $gallery
2331
- } // !empty
2332
- else
2333
  $references['galleries'] = array();
 
2334
  }
2335
  } // $process_gallery_in
2336
-
2337
  /*
2338
  * Evaluate and summarize reference tests
2339
  */
2340
  $errors = '';
2341
  if ( 0 == $reference_tests ) {
2342
  $references['tested_reference'] = false;
2343
- $errors .= '(NO REFERENCE TESTS)';
2344
- }
2345
- else {
2346
  $references['tested_reference'] = true;
2347
  $suffix = ( 4 == $reference_tests ) ? '' : '?';
2348
 
2349
- if ( !$references['found_reference'] )
2350
- $errors .= "(ORPHAN{$suffix}) ";
2351
-
2352
- if ( !$references['found_parent'] && !empty( $references['parent_title'] ) )
2353
- $errors .= "(BAD PARENT{$suffix})";
 
 
 
 
 
 
 
 
2354
  }
2355
-
2356
- if ( $references['is_unattached'] )
2357
- $errors .= '(UNATTACHED) ';
2358
- elseif ( empty( $references['parent_title'] ) )
2359
- $errors .= '(INVALID PARENT) ';
2360
 
2361
  $references['parent_errors'] = trim( $errors );
2362
-
2363
  $save_id = $ID;
2364
  return $references;
2365
  }
2366
-
2367
  /**
2368
  * Objects containing [gallery] shortcodes
2369
  *
@@ -2421,7 +2526,7 @@ class MLAData {
2421
  // ignore everything else
2422
  } // switch
2423
  }
2424
-
2425
  /**
2426
  * Invalidates $mla_galleries and $galleries arrays and cached values after post, page or attachment updates
2427
  *
@@ -2435,7 +2540,7 @@ class MLAData {
2435
  self::mla_flush_mla_galleries( MLAOptions::MLA_GALLERY_IN_TUNING );
2436
  self::mla_flush_mla_galleries( MLAOptions::MLA_MLA_GALLERY_IN_TUNING );
2437
  }
2438
-
2439
  /**
2440
  * Builds the $mla_galleries or $galleries array
2441
  *
@@ -2460,9 +2565,9 @@ class MLAData {
2460
  }
2461
 
2462
  $option_value = MLAOptions::mla_get_option( $option_name );
2463
- if ( 'disabled' == $option_value )
2464
  return false;
2465
- elseif ( 'cached' == $option_value ) {
2466
  $galleries_array = get_transient( MLA_OPTION_PREFIX . 't_' . $option_name );
2467
  if ( is_array( $galleries_array ) ) {
2468
  if ( ! empty( $galleries_array ) ) {
@@ -2470,21 +2575,22 @@ class MLAData {
2470
  } else {
2471
  return false;
2472
  }
2473
- }
2474
- else
2475
  $galleries_array = NULL;
 
2476
  } // cached
2477
-
2478
  /*
2479
  * $galleries_array is null, so build the array
2480
  */
2481
  $galleries_array = array();
2482
-
2483
- if ( $exclude_revisions )
2484
  $exclude_revisions = "(post_type <> 'revision') AND ";
2485
- else
2486
  $exclude_revisions = '';
2487
-
 
2488
  $like = like_escape( $shortcode );
2489
  $results = $wpdb->get_results(
2490
  $wpdb->prepare(
@@ -2498,9 +2604,10 @@ class MLAData {
2498
  )
2499
  );
2500
 
2501
- if ( empty( $results ) )
2502
  return false;
2503
-
 
2504
  foreach ( $results as $result ) {
2505
  $count = preg_match_all( "/\\{$shortcode}([^\\]]*)\\]/", $result->post_content, $matches, PREG_PATTERN_ORDER );
2506
  if ( $count ) {
@@ -2510,7 +2617,7 @@ class MLAData {
2510
  $galleries_array[ $result_id ]['results'] = array();
2511
  $galleries_array[ $result_id ]['galleries'] = array();
2512
  $instance = 0;
2513
-
2514
  foreach ( $matches[1] as $index => $match ) {
2515
  /*
2516
  * Filter out shortcodes that are not an exact match
@@ -2526,13 +2633,15 @@ class MLAData {
2526
  $attachments = MLAShortcodes::mla_get_shortcode_attachments( $result_id, $galleries_array[ $result_id ]['galleries'][ $instance ]['query'] . ' where_used_query=this-is-a-where-used-query' );
2527
 
2528
  if ( is_string( $attachments ) ) {
2529
- trigger_error( htmlentities( sprintf( '(%1$s) %2$s (ID %3$d) query "%4$s" failed, returning "%5$s"', $result->post_type, $result->post_title, $result->ID, $galleries_array[ $result_id ]['galleries'][ $instance ]['query'], $attachments) ), E_USER_WARNING );
2530
- }
2531
- elseif ( ! empty( $attachments ) )
 
2532
  foreach ( $attachments as $attachment ) {
2533
  $galleries_array[ $result_id ]['results'][ $attachment->ID ] = $attachment->ID;
2534
  $galleries_array[ $result_id ]['galleries'][ $instance ]['results'][] = $attachment->ID;
2535
- } // foreach $attachment
 
2536
  } // exact match
2537
  } // foreach $match
2538
  } // if $count
@@ -2547,7 +2656,7 @@ class MLAData {
2547
 
2548
  return true;
2549
  }
2550
-
2551
  /**
2552
  * Search the $mla_galleries or $galleries array
2553
  *
@@ -2568,10 +2677,10 @@ class MLAData {
2568
  }
2569
  } // foreach gallery
2570
  } // !empty
2571
-
2572
  return $gallery_refs;
2573
  }
2574
-
2575
  /**
2576
  * Array of PDF indirect objects
2577
  *
@@ -2606,17 +2715,19 @@ class MLAData {
2606
  if ( $match_count ) {
2607
  if ( 'n' == $matches[3] ) {
2608
  $key = ( $object_id * 1000 ) + $matches[2];
2609
- if ( ! isset( self::$pdf_indirect_objects[ $key ] ) )
2610
  self::$pdf_indirect_objects[ $key ] = array( 'number' => $object_id, 'generation' => (integer) $matches[2], 'start' => (integer) $matches[1] );
 
2611
  }
 
2612
  $object_id++;
2613
  $offset += 20;
2614
- }
2615
- else
2616
  break;
 
2617
  }
2618
  }
2619
-
2620
  /**
2621
  * Parse a cross-reference table section into the array of indirect object definitions
2622
  *
@@ -2632,24 +2743,24 @@ class MLAData {
2632
  $xref_max = $chunksize = 16384;
2633
  $xref_section = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
2634
  $xref_length = 0;
2635
-
2636
  while ( preg_match( '/^[\x00-\x20]*(\d+) (\d+)[\x00-\x20]*/', substr($xref_section, $xref_length), $matches, 0 ) ) {
2637
  $object_id = $matches[1];
2638
  $count = $matches[2];
2639
  $offset = $xref_length + strlen( $matches[0] );
2640
  $xref_length = $offset + ( 20 * $count );
2641
-
2642
  if ( $xref_max < $xref_length ) {
2643
  $xref_max += $chunksize;
2644
  $xref_section = file_get_contents( $file_name, true, NULL, $file_offset, $xref_max );
2645
  }
2646
-
2647
  self::_parse_pdf_xref_subsection( $xref_section, $offset, $object_id, $count );
2648
  } // while preg_match subsection header
2649
 
2650
  return $xref_length;
2651
  }
2652
-
2653
  /**
2654
  * Parse a cross-reference steam into the array of indirect object definitions
2655
  *
@@ -2668,12 +2779,13 @@ class MLAData {
2668
 
2669
  if ( 'stream' == substr( $xref_section, 0, 6 ) ) {
2670
  $tag_length = 7;
2671
- if ( chr(0x0D) == $xref_section[6] )
2672
  $tag_length++;
2673
- }
2674
- else
2675
  return 0;
2676
-
 
2677
  /*
2678
  * If necessary and possible, expand the $xmp_chunk until it contains the end tag
2679
  */
@@ -2687,45 +2799,49 @@ class MLAData {
2687
  } // while not found
2688
  } // if not found
2689
 
2690
- if ( false == $end_tag )
2691
  $length = 0;
2692
- else
2693
  $length = $end_tag - $tag_length;
2694
-
2695
- if ( false == $end_tag )
 
2696
  return 0;
2697
-
 
2698
  return $length;
2699
-
2700
  $entry_parms = explode( ' ', $entry_parms_string );
2701
  $object_id = $matches[1];
2702
  $count = $matches[2];
2703
  $offset = strlen( $matches[0] );
2704
  $length = $offset + ( 20 * $count );
2705
-
2706
  if ( $chunksize < $length ) {
2707
  $xref_section = file_get_contents( $file_name, true, NULL, $file_offset, $length );
2708
  $offset = 0;
2709
  }
2710
-
2711
  while ( $count-- ) {
2712
  $match_count = preg_match( '/(\d+) (\d+) (.)/', $xref_section, $matches, 0, $offset);
2713
  if ( $match_count ) {
2714
  if ( 'n' == $matches[3] ) {
2715
  $key = ( $object_id * 1000 ) + $matches[2];
2716
- if ( ! isset( self::$pdf_indirect_objects[ $key ] ) )
2717
  self::$pdf_indirect_objects[ $key ] = array( 'number' => $object_id, 'generation' => (integer) $matches[2], 'start' => (integer) $matches[1] );
 
2718
  }
 
2719
  $object_id++;
2720
  $offset += 20;
2721
- }
2722
- else
2723
  break;
 
2724
  }
2725
 
2726
  return $length;
2727
  }
2728
-
2729
  /**
2730
  * Build an array of indirect object definitions
2731
  *
@@ -2737,9 +2853,10 @@ class MLAData {
2737
  * @return void
2738
  */
2739
  private static function _build_pdf_indirect_objects( &$string ) {
2740
- if ( ! is_null( self::$pdf_indirect_objects ) )
2741
  return;
2742
-
 
2743
  $match_count = preg_match_all( '!(\d+)\\h+(\d+)\\h+obj|endobj|stream(\x0D\x0A|\x0A)|endstream!', $string, $matches, PREG_OFFSET_CAPTURE );
2744
  self::$pdf_indirect_objects = array();
2745
  $object_level = 0;
@@ -2749,28 +2866,26 @@ class MLAData {
2749
  if ( 'endstream' == substr( $matches[0][ $index ][0], 0, 9 ) ) {
2750
  $is_stream = false;
2751
  }
2752
- }
2753
- elseif ( 'endobj' == substr( $matches[0][ $index ][0], 0, 6 ) ) {
2754
  $object_level--;
2755
  $object_entry['/length'] = $matches[0][ $index ][1] - $object_entry['start'];
2756
  self::$pdf_indirect_objects[ ($object_entry['number'] * 1000) + $object_entry['generation'] ] = $object_entry;
2757
- }
2758
- elseif ( 'obj' == substr( $matches[0][ $index ][0], -3 ) ) {
2759
  $object_level++;
2760
  $object_entry = array(
2761
  'number' => $matches[1][ $index ][0],
2762
  'generation' => $matches[2][ $index ][0],
2763
  'start' => $matches[0][ $index ][1] + strlen( $matches[0][ $index ][0] )
2764
  );
2765
- }
2766
- elseif ( 'stream' == substr( $matches[0][ $index ][0], 0, 6 ) ) {
2767
  $is_stream = true;
 
 
 
2768
  }
2769
- else
2770
- error_log( 'ERROR: _build_pdf_indirect_objects bad value $index = ' . $index, 0 );
2771
  } // for each match
2772
  }
2773
-
2774
  /**
2775
  * Find the offset, length and contents of an indirect object containing a dictionary
2776
  *
@@ -2790,13 +2905,13 @@ class MLAData {
2790
  $key = ( $object * 1000 ) + $generation;
2791
  if ( isset( self::$pdf_indirect_objects ) && isset( self::$pdf_indirect_objects[ $key ] ) ) {
2792
  $file_offset = self::$pdf_indirect_objects[ $key ]['start'];
2793
- } // found object location
2794
- else
2795
  $file_offset = 0;
 
2796
 
2797
  $object_starts = array();
2798
  $object_content = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
2799
-
2800
  /*
2801
  * Match the object header
2802
  */
@@ -2806,7 +2921,7 @@ class MLAData {
2806
  $object_starts[] = array( 'offset' => $file_offset, 'start' => $matches[1][1]);
2807
  $match_count = 0;
2808
  }
2809
-
2810
  /*
2811
  * If necessary and possible, advance the $object_content through the file until it contains the start tag
2812
  */
@@ -2814,33 +2929,33 @@ class MLAData {
2814
  $file_offset += ( $chunksize - 16 );
2815
  $object_content = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
2816
  $match_count = preg_match( $pattern, $object_content, $matches, PREG_OFFSET_CAPTURE );
2817
-
2818
  if ( $match_count ) {
2819
  $object_starts[] = array( 'offset' => $file_offset, 'start' => $matches[1][1]);
2820
  $match_count = 0;
2821
  }
2822
-
2823
  while ( 0 == $match_count && ( $chunksize == strlen( $object_content ) ) ) {
2824
  $file_offset += ( $chunksize - 16 );
2825
  $object_content = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
2826
  $match_count = preg_match( $pattern, $object_content, $matches, PREG_OFFSET_CAPTURE );
2827
-
2828
  if ( $match_count ) {
2829
  $object_starts[] = array( 'offset' => $file_offset, 'start' => $matches[1][1]);
2830
  $match_count = 0;
2831
  }
2832
  } // while not found
2833
  } // if not found
2834
-
2835
  $object_start = array_pop( $object_starts );
2836
- if ( is_null( $object_start ) )
2837
  return NULL;
2838
- else {
2839
  $file_offset = $object_start['offset'];
2840
  $object_content = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
2841
  $start = $object_start['start'];
2842
  }
2843
-
2844
  /*
2845
  * If necessary and possible, expand the $object_content until it contains the end tag
2846
  */
@@ -2860,8 +2975,9 @@ class MLAData {
2860
  } // while not found
2861
  } // if not found
2862
 
2863
- if ( 0 == $match_count )
2864
  return NULL;
 
2865
 
2866
  if ($match_count) {
2867
  $results = array( 'start' => $file_offset + $start, 'length' => ($matches[0][1] + 2) - $start );
@@ -2871,7 +2987,7 @@ class MLAData {
2871
 
2872
  return NULL;
2873
  }
2874
-
2875
  /**
2876
  * Parse a ISO 8601 Timestamp
2877
  *
@@ -2882,7 +2998,7 @@ class MLAData {
2882
  * @return string formatted date string YYYY-MM-DD HH:mm:SS
2883
  */
2884
  private static function _parse_iso8601_date( $source_string ) {
2885
- if ( 1 == preg_match( '/^\\d\\d\\d\\d-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d-\\d\\d:\\d\\d/', $source_string ) )
2886
  return sprintf( '%1$s-%2$s-%3$s %4$s:%5$s:%6$s',
2887
  substr( $source_string, 0, 4),
2888
  substr( $source_string, 5, 2),
@@ -2890,10 +3006,11 @@ class MLAData {
2890
  substr( $source_string, 11, 2),
2891
  substr( $source_string, 14, 2),
2892
  substr( $source_string, 17, 2) );
2893
- else
2894
- return $source_string;
 
2895
  }
2896
-
2897
  /**
2898
  * Parse a PDF date string
2899
  *
@@ -2904,7 +3021,7 @@ class MLAData {
2904
  * @return string formatted date string YYYY-MM-DD HH:mm:SS
2905
  */
2906
  private static function _parse_pdf_date( $source_string ) {
2907
- if ( 'D:' == substr( $source_string, 0, 2) && ctype_digit( substr( $source_string, 2, 12 ) ) )
2908
  return sprintf( '%1$s-%2$s-%3$s %4$s:%5$s:%6$s',
2909
  substr( $source_string, 2, 4),
2910
  substr( $source_string, 6, 2),
@@ -2912,10 +3029,11 @@ class MLAData {
2912
  substr( $source_string, 10, 2),
2913
  substr( $source_string, 12, 2),
2914
  substr( $source_string, 14, 2) );
2915
- else
2916
- return $source_string;
 
2917
  }
2918
-
2919
  /**
2920
  * Parse a PDF Unicode (16-bit Big Endian) object
2921
  *
@@ -2929,18 +3047,18 @@ class MLAData {
2929
  $output = '';
2930
  for ($index = 2; $index < strlen( $source_string ); ) {
2931
  $value = ( ord( $source_string[ $index++ ] ) << 8 ) + ord( $source_string[ $index++ ] );
2932
- if ( $value < 0x80 )
2933
  $output .= chr( $value );
2934
- elseif ( $value < 0x100 )
2935
  $output .= self::$utf8_chars[ $value - 0x80 ];
2936
- else {
2937
  $output .= '.'; // TODO encode the rest
2938
  }
2939
  }
2940
 
2941
  return $output;
2942
  }
2943
-
2944
  /**
2945
  * Parse a PDF string object
2946
  *
@@ -2955,8 +3073,9 @@ class MLAData {
2955
  * @return array ( key => array( 'type' => type, 'value' => value, '/length' => length ) ) for the string
2956
  */
2957
  private static function _parse_pdf_string( &$source_string, $offset ) {
2958
- if ( '(' != $source_string[ $offset ] )
2959
  return array( 'type' => 'unknown', 'value' => '', '/length' => 0 );
 
2960
 
2961
  /*
2962
  * Brute force, here we come...
@@ -2970,12 +3089,16 @@ class MLAData {
2970
  if ( '\\' == $byte ) {
2971
  switch ( $source_string[ $index ] ) {
2972
  case chr( 0x0A ):
2973
- if ( chr( 0x0D ) == $source_string[ $index + 1 ] )
2974
  $index++;
 
 
2975
  break;
2976
  case chr( 0x0D ):
2977
- if ( chr( 0x0A ) == $source_string[ $index + 1 ] )
2978
  $index++;
 
 
2979
  break;
2980
  case 'n':
2981
  $output .= chr( 0x0A );
@@ -2995,39 +3118,40 @@ class MLAData {
2995
  default: // could be a 1- to 3-digit octal value
2996
  $digit_limit = $index + 3;
2997
  $digit_index = $index;
2998
- while ( $digit_index < $digit_limit )
2999
- if ( ! ctype_digit( $source_string[ $digit_index ] ) )
3000
  break;
3001
- else
3002
  $digit_index++;
 
 
3003
 
3004
  if ( $digit_count = $digit_index - $index ) {
3005
  $output .= chr( octdec( substr( $source_string, $index, $digit_count ) ) );
3006
  $index += $digit_count - 1;
3007
- }
3008
- else // accept the character following the backslash
3009
  $output .= $source_string[ $index ];
 
3010
  } // switch
3011
-
3012
  $index++;
3013
- } // REVERSE SOLIDUS
3014
- else {
3015
- if ( '(' == $byte )
3016
  $level++;
3017
- elseif ( ')' == $byte ) {
3018
  if ( 0 == $level-- ) {
3019
  $in_string = false;
3020
  continue;
3021
  }
3022
  }
3023
-
3024
  $output .= $byte;
3025
  } // just another 8-bit value, but check for balanced parentheses
3026
  } // $in_string
3027
-
3028
  return array( 'type' => 'string', 'value' => $output, '/length' => $index - $offset );
3029
  }
3030
-
3031
  /**
3032
  * Parse a PDF Linearization Parameter Dictionary object
3033
  *
@@ -3046,12 +3170,13 @@ class MLAData {
3046
  $header = substr( $source_string, 0, 1024 );
3047
  $match_count = preg_match( '!obj[\x00-\x20]*<<(/Linearized).*(>>)[\x00-\x20]*endobj!', $header, $matches, PREG_OFFSET_CAPTURE );
3048
 
3049
- if ( $match_count )
3050
  $LPD = self::_parse_pdf_dictionary( $header, $matches[1][1] );
3051
-
 
3052
  return false;
3053
  }
3054
-
3055
  /**
3056
  * Parse a PDF dictionary object
3057
  *
@@ -3070,30 +3195,31 @@ class MLAData {
3070
  /*
3071
  * Find the end of the dictionary
3072
  */
3073
- if ( '<<' == substr( $source_string, $offset, 2 ) )
3074
  $nest = $offset + 2;
3075
- else
3076
  $nest = $offset;
 
3077
 
3078
  $level = 1;
3079
  do {
3080
  $dictionary_end = strpos( $source_string, '>>', $nest );
3081
  if ( false === $dictionary_end ) {
3082
- error_log( "ERROR: _parse_pdf_dictionary offset = {$offset}, nest = {$nest}", 0 );
3083
- error_log( 'ERROR: _parse_pdf_dictionary no end delimiter dump = ' . var_export( self::_hex_dump( substr( $source_string, $offset, 128 ), 128, 16 ), true ), 0 );
 
 
3084
  return array( '/length' => 0 );
3085
  }
3086
-
3087
  $nest = strpos( $source_string, '<<', $nest );
3088
  if ( false === $nest ) {
3089
  $nest = $dictionary_end + 2;
3090
  $level--;
3091
- }
3092
- elseif ( $nest < $dictionary_end ) {
3093
  $nest += 2;
3094
  $level++;
3095
- }
3096
- else {
3097
  $nest = $dictionary_end + 2;
3098
  $level--;
3099
  }
@@ -3113,9 +3239,10 @@ class MLAData {
3113
  /*
3114
  * Skip over false matches within a string or nested dictionary
3115
  */
3116
- if ( $value_start < $end_data )
3117
  continue;
3118
-
 
3119
  $end_data = -1;
3120
  $value_count = preg_match(
3121
  '!(\/?[^\/\x0D\x0A]*)!',
@@ -3126,57 +3253,53 @@ class MLAData {
3126
  $length = strlen( $value );
3127
  $dictionary[ $name ]['value'] = $value;
3128
  if ( ! isset( $value[0] ) ) {
3129
- error_log( "ERROR: _parse_pdf_dictionary bad value [ {$name} ] dump = " . var_export( self::_hex_dump( $value, 32, 16 ), true ), 0 );
 
3130
  continue;
3131
  }
3132
-
3133
- if ( in_array( $value, array( 'true', 'false' ) ) )
3134
  $dictionary[ $name ]['type'] = 'boolean';
3135
- elseif ( is_numeric( $value ) )
3136
  $dictionary[ $name ]['type'] = 'numeric';
3137
- elseif ( '(' == $value[0] ) {
3138
  $dictionary[ $name ] = self::_parse_pdf_string( $source_string, $value_start );
3139
  $end_data = $value_start + $dictionary[ $name ]['/length'];
3140
  unset( $dictionary[ $name ]['/length'] );
3141
- }
3142
- elseif ( '<' == $value[0] ) {
3143
  if ( '<' == $value[1] ) {
3144
  $dictionary[ $name ]['value'] = self::_parse_pdf_dictionary( $source_string, $value_start );
3145
  $dictionary[ $name ]['type'] = 'dictionary';
3146
  $end_data = $value_start + 4 + $dictionary[ $name ]['value']['/length'];
3147
  unset( $dictionary[ $name ]['value']['/length'] );
3148
- }
3149
- else
3150
  $dictionary[ $name ]['type'] = 'hex';
3151
- }
3152
- elseif ( '/' == $value[0] ) {
3153
  $dictionary[ $name ]['value'] = substr( $value, 1 );
3154
  $dictionary[ $name ]['type'] = 'name';
3155
  $match_index++; // Skip to the next key
3156
- }
3157
- elseif ( '[' == $value[0] ) {
3158
  $dictionary[ $name ]['type'] = 'array';
3159
  $array_length = strpos( $source_string, ']', $value_start ) - ($value_start + 1);
3160
  $dictionary[ $name ]['value'] = substr( $source_string, $value_start + 1, $array_length );
3161
  $end_data = 2 + $value_start + $array_length;
3162
- }
3163
- elseif ( 'null' == $value )
3164
  $dictionary[ $name ]['type'] = 'null';
3165
- elseif ( 'stream' == substr( $value, 0, 6 ) )
3166
  $dictionary[ $name ]['type'] = 'stream';
3167
- else {
3168
  $object_count = preg_match( '!(\d+)\h+(\d+)\h+R!', $value, $object_matches );
 
3169
  if ( 1 == $object_count ) {
3170
  $dictionary[ $name ]['type'] = 'indirect';
3171
  $dictionary[ $name ]['object'] = $object_matches[1];
3172
  $dictionary[ $name ]['generation'] = $object_matches[2];
3173
- }
3174
- else {
3175
  $dictionary[ $name ]['type'] = 'unknown';
3176
  }
3177
  }
3178
- }
3179
- else {
3180
  $dictionary[ $matches[1][ $match_index ][0] ] = array( 'value' => '' );
3181
  $dictionary[ $matches[1][ $match_index ][0] ]['type'] = 'nomatch';
3182
  }
@@ -3185,7 +3308,7 @@ class MLAData {
3185
  $dictionary['/length'] = $dictionary_length;
3186
  return $dictionary;
3187
  }
3188
-
3189
  /**
3190
  * Parse an XMP object
3191
  *
@@ -3214,13 +3337,14 @@ class MLAData {
3214
  $new_offset = $new_offset + ( $chunksize - 16 );
3215
  $xmp_chunk = file_get_contents( $file_name, true, NULL, $new_offset, $chunksize );
3216
  } // while not found
3217
- } // if not found
3218
- else
3219
  $new_offset = $file_offset;
3220
-
3221
- if ( false === $start_tag )
 
3222
  return NULL;
3223
-
 
3224
  /*
3225
  * If necessary and possible, expand the $xmp_chunk until it contains the start tag
3226
  */
@@ -3235,24 +3359,27 @@ class MLAData {
3235
  } // while not found
3236
  } // if not found
3237
 
3238
- if ( false === $end_tag )
3239
  return NULL;
 
3240
 
3241
  $xmp_string = "<?xml version='1.0'?>\n" . substr($xmp_chunk, $start_tag, ( $end_tag + 12 ) - $start_tag );
3242
  $xmp_values = array();
3243
  $xml_parser = xml_parser_create('UTF-8');
3244
  if ( xml_parser_set_option( $xml_parser, XML_OPTION_SKIP_WHITE, 0 ) && xml_parser_set_option( $xml_parser, XML_OPTION_CASE_FOLDING, 0 ) ) {
3245
- if (xml_parse_into_struct( $xml_parser, $xmp_string, $xmp_values ) == 0)
3246
- error_log( 'ERROR: _parse_xmp_metadata xml_parse_into_struct failed.' );
 
 
 
3247
  }
3248
- else
3249
- error_log( 'ERROR: _parse_xmp_metadata set option failed.' );
3250
 
3251
  xml_parser_free($xml_parser);
3252
 
3253
- if ( empty( $xmp_values ) )
3254
  return NULL;
3255
-
 
3256
  $results = array();
3257
  $xmlns = array();
3258
  $array_name = '';
@@ -3261,15 +3388,16 @@ class MLAData {
3261
  $language = 'x-default';
3262
  if ( isset( $value['attributes'] ) ) {
3263
  foreach ( $value['attributes'] as $att_tag => $att_value ) {
3264
- if ( 'xmlns:' == substr( $att_tag, 0, 6 ) )
3265
  $xmlns[ substr( $att_tag, 6 ) ] = $att_value;
3266
- elseif ( 'x:xmptk' == $att_tag )
3267
  $results['xmptk'] = $att_value;
3268
- elseif ( 'xml:lang' == $att_tag )
3269
  $language = $att_value;
 
3270
  }
3271
  } // attributes
3272
-
3273
  switch ( $value['tag'] ) {
3274
  case 'x:xmpmeta':
3275
  case 'rdf:RDF':
@@ -3279,17 +3407,19 @@ class MLAData {
3279
  break;
3280
  case 'rdf:li':
3281
  if ( $value['type'] == 'complete' ) {
3282
- if ( 'x-default' != $language )
3283
  break;
3284
-
 
3285
  if ( ! empty ( $array_name ) ) {
3286
- if ( isset( $value['value'] ) )
3287
  $results[ $array_name ][ $array_index++ ] = $value['value'];
3288
- else
3289
  $results[ $array_name ][ $array_index++ ] = '';
 
3290
  }
3291
  } // complete
3292
-
3293
  break;
3294
  case 'rdf:Seq':
3295
  case 'rdf:Bag':
@@ -3301,7 +3431,7 @@ class MLAData {
3301
  case 'close':
3302
  $array_index = -1;
3303
  }
3304
-
3305
  break;
3306
  default:
3307
  switch ( $value['type'] ) {
@@ -3312,12 +3442,13 @@ class MLAData {
3312
  $array_name = '';
3313
  break;
3314
  case 'complete':
3315
- if ( isset( $value['attributes'] ) )
3316
  $results[ $value['tag'] ] = $value['attributes'];
3317
- elseif ( isset( $value['value'] ) )
3318
  $results[ $value['tag'] ] = $value['value'];
3319
- else
3320
  $results[ $value['tag'] ] = '';
 
3321
  } // type
3322
  } // switch tag
3323
  } // foreach value
@@ -3330,25 +3461,27 @@ class MLAData {
3330
  */
3331
  $namespace_arrays = array();
3332
  foreach ( $results as $key => $value ) {
3333
- if ( is_string( $value ) )
3334
  $value = self::_parse_iso8601_date( self::_parse_pdf_date( $value ) );
3335
-
 
3336
  if ( false !== ($colon = strpos( $key, ':' ) ) ) {
3337
  $array_name = substr( $key, 0, $colon );
3338
  $array_index = substr( $key, $colon + 1 );
3339
  $namespace_arrays[ $array_name ][ $array_index ] = $value;
3340
 
3341
  if ( ! isset( $results[ $array_index ] ) && in_array( $array_name, array( 'xmp', 'xmpMM', 'xmpRights', 'xap', 'xapMM', 'dc', 'pdf', 'pdfx' ) ) ) {
3342
- if ( is_array( $value ) && 1 == count( $value ) && isset( $value[0] ) )
3343
  $results[ $array_index ] = $value[0];
3344
- else
3345
  $results[ $array_index ] = $value;
 
3346
  }
3347
 
3348
  unset( $results[ $key ] );
3349
  }
3350
  }
3351
-
3352
  /*
3353
  * Try to populate all the PDF-standard keys (except Trapped)
3354
  * Title - The document's title
@@ -3361,20 +3494,23 @@ class MLAData {
3361
  * ModDate - The date and time the document was most recently modified
3362
  */
3363
  if ( ! isset( $results['Title'] ) ) {
3364
- if ( isset( $namespace_arrays['dc'] ) && isset( $namespace_arrays['dc']['title'] ) )
3365
  $results['Title'] = implode( ',', $namespace_arrays['dc']['title'] );
 
3366
  }
3367
-
3368
  if ( ! isset( $results['Author'] ) ) {
3369
- if ( isset( $namespace_arrays['dc'] ) && isset( $namespace_arrays['dc']['creator'] ) )
3370
  $results['Author'] = implode( ',', $namespace_arrays['dc']['creator'] );
 
3371
  }
3372
-
3373
  if ( ! isset( $results['Subject'] ) ) {
3374
- if ( isset( $namespace_arrays['dc'] ) && isset( $namespace_arrays['dc']['description'] ) )
3375
  $results['Subject'] = implode( ',', $namespace_arrays['dc']['description'] );
 
3376
  }
3377
-
3378
  /*
3379
  * Keywords are special, since they are often assigned to taxonomy terms.
3380
  * Build or preserve an array if there are multiple values; string for single values.
@@ -3385,79 +3521,87 @@ class MLAData {
3385
  if ( false !== strpos( $results['Keywords'], ';' ) ) {
3386
  $terms = array_map( 'trim', explode( ';', $results['Keywords'] ) );
3387
  foreach ( $terms as $term )
3388
- if ( ! empty( $term ) )
3389
  $keywords[ $term ] = $term;
3390
- }
3391
- elseif ( false !== strpos( $results['Keywords'], ',' ) ) {
3392
  $terms = array_map( 'trim', explode( ',', $results['Keywords'] ) );
3393
  foreach ( $terms as $term )
3394
- if ( ! empty( $term ) )
3395
  $keywords[ $term ] = $term;
3396
- }
3397
- else {
3398
  $term = trim( $results['Keywords'] );
3399
- if ( ! empty( $term ) )
3400
  $keywords[ $term ] = $term;
 
3401
  }
3402
  } // Keywords
3403
-
3404
  if ( isset( $namespace_arrays['dc'] ) && isset( $namespace_arrays['dc']['subject'] ) ) {
3405
- if ( is_array( $namespace_arrays['dc']['subject'] ) )
3406
  foreach ( $namespace_arrays['dc']['subject'] as $term ) {
3407
  $term = trim( $term );
3408
- if ( ! empty( $term ) )
3409
  $keywords[ $term ] = $term;
 
3410
  }
3411
- elseif ( is_string( $namespace_arrays['dc']['subject'] ) ) {
3412
  $term = trim ( $namespace_arrays['dc']['subject'] );
3413
- if ( ! empty( $term ) )
3414
- $keywords[ $term ] = $term;
3415
  }
 
3416
  } // dc:subject
3417
-
3418
  if ( ! empty( $keywords ) ) {
3419
- if ( 1 == count( $keywords ) )
3420
  $results['Keywords'] = array_shift( $keywords );
3421
- else {
3422
  $results['Keywords'] = array();
3423
- foreach ( $keywords as $term )
3424
  $results['Keywords'][] = $term;
 
3425
  }
3426
  }
3427
-
3428
  // if ( ! isset( $results['Producer'] ) ) {
3429
  // }
3430
-
3431
  if ( ! isset( $results['Creator'] ) ) {
3432
- if ( isset( $namespace_arrays['xmp'] ) && isset( $namespace_arrays['xmp']['CreatorTool'] ) )
3433
  $results['Creator'] = $namespace_arrays['xmp']['CreatorTool'];
3434
- elseif ( isset( $namespace_arrays['xap'] ) && isset( $namespace_arrays['xap']['CreatorTool'] ) )
3435
  $results['Creator'] = $namespace_arrays['xap']['CreatorTool'];
3436
- elseif ( ! empty( $results['Producer'] ) )
3437
  $results['Creator'] = $results['Producer'];
 
3438
  }
3439
-
3440
  if ( ! isset( $results['CreationDate'] ) ) {
3441
- if ( isset( $namespace_arrays['xmp'] ) && isset( $namespace_arrays['xmp']['CreateDate'] ) )
3442
  $results['CreationDate'] = $namespace_arrays['xmp']['CreateDate'];
3443
- elseif ( isset( $namespace_arrays['xap'] ) && isset( $namespace_arrays['xap']['CreateDate'] ) )
3444
  $results['CreationDate'] = $namespace_arrays['xap']['CreateDate'];
 
3445
  }
3446
-
3447
  if ( ! isset( $results['ModDate'] ) ) {
3448
- if ( isset( $namespace_arrays['xmp'] ) && isset( $namespace_arrays['xmp']['ModifyDate'] ) )
3449
  $results['ModDate'] = $namespace_arrays['xmp']['ModifyDate'];
3450
- elseif ( isset( $namespace_arrays['xap'] ) && isset( $namespace_arrays['xap']['ModifyDate'] ) )
3451
  $results['ModDate'] = $namespace_arrays['xap']['ModifyDate'];
 
3452
  }
3453
-
3454
- if ( ! empty( $xmlns ) )
3455
  $results['xmlns'] = $xmlns;
 
3456
 
3457
  $results = array_merge( $results, $namespace_arrays );
3458
  return $results;
3459
  }
3460
-
3461
  /**
3462
  * Extract dictionary from traditional cross-reference + trailer documents
3463
  *
@@ -3472,7 +3616,7 @@ class MLAData {
3472
  $chunksize = 16384;
3473
  $tail = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
3474
  $chunk_offset = 0;
3475
-
3476
  /*
3477
  * look for traditional xref and trailer
3478
  */
@@ -3485,7 +3629,7 @@ class MLAData {
3485
  $tail = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
3486
  $chunk_offset = 0;
3487
  }
3488
-
3489
  $match_count = preg_match( '/[\x00-\x20]*trailer[\x00-\x20]+/', $tail, $matches, PREG_OFFSET_CAPTURE, $chunk_offset );
3490
  if ( $match_count ) {
3491
  $chunk_offset = $matches[0][1] + strlen( $matches[0][0] );
@@ -3494,21 +3638,21 @@ class MLAData {
3494
  if ( 0 < $match_count ) {
3495
  $dictionary = self::_parse_pdf_dictionary( $matches[0], 0 );
3496
 
3497
- if ( isset( $dictionary['Prev'] ) )
3498
  $other_trailers = self::_extract_pdf_trailer( $file_name, $dictionary['Prev']['value'] );
3499
- else
3500
  $other_trailers = NULL;
3501
-
 
3502
  if ( is_array( $other_trailers ) ) {
3503
  $other_trailers = array_merge( $other_trailers, array( $dictionary ) );
3504
  return $other_trailers;
3505
- }
3506
- else
3507
  return array( $dictionary );
 
3508
  } // found trailer dictionary
3509
  } // found 'trailer'
3510
- } // found 'xref'
3511
- else {
3512
  /*
3513
  * Look for a cross-reference stream
3514
  */
@@ -3522,27 +3666,29 @@ class MLAData {
3522
  /*
3523
  * Parse the cross-reference stream following the dictionary, if present
3524
  */
3525
- if ( isset( $dictionary['Type'] ) && 'XRef' == $dictionary['Type']['value'] )
3526
  $xref_length = self::_parse_pdf_xref_stream( $file_name, $file_offset + $chunk_offset + (integer) $dictionary['/length'], $dictionary['W']['value'] );
3527
-
3528
- if ( isset( $dictionary['Prev'] ) )
 
3529
  $other_trailers = self::_extract_pdf_trailer( $file_name, $dictionary['Prev']['value'] );
3530
- else
3531
  $other_trailers = NULL;
3532
-
 
3533
  if ( is_array( $other_trailers ) ) {
3534
  $other_trailers = array_merge( array( $dictionary ), $other_trailers );
3535
  return $other_trailers;
3536
- }
3537
- else
3538
  return array( $dictionary );
 
3539
  } // found cross-reference stream dictionary
3540
  } // found cross-reference stream object
3541
  }
3542
 
3543
  return NULL;
3544
  }
3545
-
3546
  /**
3547
  * Extract Metadata from a PDF file
3548
  *
@@ -3556,33 +3702,36 @@ class MLAData {
3556
  $metadata = array();
3557
  self::$pdf_indirect_objects = NULL;
3558
  $chunksize = 16384;
3559
-
3560
- if ( ! file_exists( $file_name ) )
3561
  return $metadata;
 
3562
 
3563
  $filesize = filesize( $file_name );
3564
  $file_offset = ( $chunksize < $filesize ) ? ( $filesize - $chunksize ) : 0;
3565
  $tail = file_get_contents( $file_name, false, NULL, $file_offset );
3566
-
3567
- if ( 0 == $file_offset )
3568
  $header = substr( $tail, 0, 128 );
3569
- else
3570
  $header = file_get_contents( $file_name, false, NULL, 0, 128 );
3571
-
 
3572
  if ( '%PDF-' == substr( $header, 0, 5 ) ) {
3573
  $metadata['PDF_Version'] = substr( $header, 1, 7 );
3574
  $metadata['PDF_VersionNumber'] = substr( $header, 5, 3 );
3575
  }
3576
-
3577
  /*
3578
  * Find the xref and (optional) trailer
3579
  */
3580
  $match_count = preg_match_all( '/startxref[\x00-\x20]+(\d+)[\x00-\x20]+\%\%EOF/', $tail, $matches, PREG_OFFSET_CAPTURE );
3581
  if ( 0 == $match_count ) {
3582
- error_log( 'ERROR: startxref not found ' . var_export( $path, true ), 0 );
 
3583
  return $metadata;
3584
  }
3585
-
3586
  $startxref = (integer) $matches[1][ $match_count - 1 ][0];
3587
  $trailer_dictionaries = self::_extract_pdf_trailer( $file_name, $startxref );
3588
  if ( is_array( $trailer_dictionaries ) ) {
@@ -3592,7 +3741,7 @@ class MLAData {
3592
  $info_reference = $trailer_dictionary['Info'];
3593
  break;
3594
  }
3595
-
3596
  if ( isset( $info_reference ) ) {
3597
  $info_object = self::_find_pdf_indirect_dictionary( $file_name, $info_reference['object'], $info_reference['generation'] );
3598
  if ( $info_object ) {
@@ -3602,19 +3751,20 @@ class MLAData {
3602
  foreach ( $info_dictionary as $name => $value ) {
3603
  if ( 'string' == $value['type'] ) {
3604
  $prefix = substr( $value['value'], 0, 2 );
3605
- if ( 'D:' == $prefix )
3606
  $metadata[ $name ] = self::_parse_pdf_date( $value['value'] );
3607
- elseif ( ( chr(0xFE) . chr(0xFF) ) == $prefix )
3608
  $metadata[ $name ] = self::_parse_pdf_UTF16BE( $value['value'] );
3609
- else
3610
  $metadata[ $name ] = $value['value'];
3611
- }
3612
- else
3613
  $metadata[ $name ] = $value['value'];
 
3614
  } // each info entry
3615
  } // found Info object
3616
  } // found Info reference
3617
-
3618
  /*
3619
  * Look for XMP Metadata
3620
  */
@@ -3624,7 +3774,7 @@ class MLAData {
3624
  $root_reference = $trailer_dictionary['Root'];
3625
  break;
3626
  }
3627
-
3628
  if ( isset( $root_reference ) ) {
3629
  $root_object = self::_find_pdf_indirect_dictionary( $file_name, $root_reference['object'], $root_reference['generation'] );
3630
  if ( $root_object ) {
@@ -3634,16 +3784,18 @@ class MLAData {
3634
  if ( isset( $root_dictionary['Metadata'] ) ) {
3635
  $xmp_object = self::_find_pdf_indirect_dictionary( $file_name, $root_dictionary['Metadata']['object'], $root_dictionary['Metadata']['generation'] );
3636
  $xmp = self::_parse_xmp_metadata( $file_name, $xmp_object['start'] + $xmp_object['length'] );
3637
- if ( is_array( $xmp ) )
 
3638
  $metadata = array_merge( $metadata, $xmp );
 
3639
  } // found Metadata reference
3640
  } // found Root object
3641
  } // found Root reference
3642
  } // found trailer_dictionaries
3643
-
3644
  return $metadata;
3645
  }
3646
-
3647
  /**
3648
  * UTF-8 replacements for invalid SQL characters
3649
  *
@@ -3680,25 +3832,27 @@ class MLAData {
3680
  * @return string UTF-8 encoded string
3681
  */
3682
  private static function _bin_to_utf8( $string ) {
3683
- if ( seems_utf8( $string ) )
3684
  return $string;
 
3685
 
3686
- if(function_exists('utf8_encode')) {
3687
  return utf8_encode( $string );
3688
  }
3689
 
3690
  $output = '';
3691
  for ($index = 0; $index < strlen( $string ); $index++ ) {
3692
  $value = ord( $string[ $index ] );
3693
- if ( $value < 0x80 )
3694
  $output .= chr( $value );
3695
- else
3696
  $output .= self::$utf8_chars[ $value - 0x80 ];
 
3697
  }
3698
 
3699
  return $output;
3700
  }
3701
-
3702
  /**
3703
  * IPTC Dataset identifiers and names
3704
  *
@@ -3725,7 +3879,7 @@ class MLAData {
3725
  "1#100" => "UNO",
3726
  "1#120" => "ARM Identifier",
3727
  "1#122" => "ARM Version",
3728
-
3729
  // Application Record
3730
  "2#000" => "Record Version",
3731
  "2#003" => "Object Type Reference",
@@ -3784,16 +3938,16 @@ class MLAData {
3784
  "2#200" => "ObjectData Preview File Format",
3785
  "2#201" => "ObjectData Preview File Format Version",
3786
  "2#202" => "ObjectData Preview Data",
3787
-
3788
  // Pre ObjectData Descriptor Record
3789
  "7#010" => "Size Mode",
3790
  "7#020" => "Max Subfile Size",
3791
  "7#090" => "ObjectData Size Announced",
3792
  "7#095" => "Maximum ObjectData Size",
3793
-
3794
  // ObjectData Record
3795
  "8#010" => "Subfile",
3796
-
3797
  // Post ObjectData Descriptor Record
3798
  "9#010" => "Confirmed ObjectData Size"
3799
  );
@@ -3883,16 +4037,16 @@ class MLAData {
3883
  'objectdata-preview-file-format' => '2#200',
3884
  'objectdata-preview-file-format-version' => '2#201',
3885
  'objectdata-preview-data' => '2#202',
3886
-
3887
  // Pre ObjectData Descriptor Record
3888
  'size-mode' => '7#010',
3889
  'max-subfile-size' => '7#020',
3890
  'objectdata-size-announced' => '7#090',
3891
  'maximum-objectdata-size' => '7#095',
3892
-
3893
  // ObjectData Record
3894
  'subfile' => '8#010',
3895
-
3896
  // Post ObjectData Descriptor Record
3897
  'confirmed-objectdata-size' => '9#010'
3898
  );
@@ -3923,7 +4077,7 @@ class MLAData {
3923
  "1#100" => "14 to 80 characters of eternal, globally unique identification for objects",
3924
  "1#120" => "2 octet binary Abstract Relationship Model Identifier",
3925
  "1#122" => "2 octet binary Abstract Relationship Model Version",
3926
-
3927
  // Application Record
3928
  "2#000" => "2 octet binary Information Interchange Model, Part II version number",
3929
  "2#003" => "3 to 67 Characters of Object Type Reference number and optional text",
@@ -3982,16 +4136,16 @@ class MLAData {
3982
  "2#200" => "2 octet binary file format of the ObjectData Preview",
3983
  "2#201" => "2 octet binary particular version of the ObjectData Preview File Format",
3984
  "2#202" => "Max 256000 binary octets containing the ObjectData Preview data",
3985
-
3986
  // Pre ObjectData Descriptor Record
3987
  "7#010" => "1 numeric character - 0=objectdata size not known, 1=objectdata size known at beginning of transfer",
3988
  "7#020" => "4 octet binary maximum subfile dataset(s) size",
3989
  "7#090" => "4 octet binary objectdata size if known at beginning of transfer",
3990
  "7#095" => "4 octet binary largest possible objectdata size",
3991
-
3992
  // ObjectData Record
3993
  "8#010" => "Subfile DataSet containing the objectdata itself; repeatable",
3994
-
3995
  // Post ObjectData Descriptor Record
3996
  "9#010" => "4 octet binary total objectdata size"
3997
  );
@@ -4087,14 +4241,14 @@ class MLAData {
4087
  if ( is_array( $text ) ) {
4088
  foreach ($text as $key => $value )
4089
  $text[ $key ] = self::_bin_to_utf8( $value );
4090
- }
4091
- elseif ( is_string( $text ) )
4092
  $text = self::_bin_to_utf8( $text );
 
4093
  }
4094
-
4095
  return $text;
4096
  }
4097
-
4098
  /**
4099
  * Parse one EXIF metadata field
4100
  *
@@ -4113,25 +4267,27 @@ class MLAData {
4113
  $text = $item_metadata['mla_exif_metadata'][ $exif_key ];
4114
  if ( is_array( $text ) ) {
4115
  foreach ($text as $key => $value ) {
4116
- if ( is_array( $value ) )
4117
  $text[ $key ] = self::_bin_to_utf8( var_export( $value, true ) );
4118
- else
4119
  $text[ $key ] = self::_bin_to_utf8( $value );
 
4120
  }
4121
- }
4122
- elseif ( is_string( $text ) )
4123
  $text = self::_bin_to_utf8( $text );
 
4124
  } elseif ( 'ALL_EXIF' == $exif_key ) {
4125
  $clean_data = array();
4126
  foreach ( $item_metadata['mla_exif_metadata'] as $key => $value ) {
4127
- if ( is_array( $value ) )
4128
  $clean_data[ $key ] = '(ARRAY)';
4129
- elseif ( is_string( $value ) )
4130
  $clean_data[ $key ] = self::_bin_to_utf8( substr( $value, 0, 256 ) );
4131
- else
4132
  $clean_data[ $key ] = $value;
 
4133
  }
4134
-
4135
  $text = var_export( $clean_data, true);
4136
  } elseif ( 'ALL_IPTC' == $exif_key ) {
4137
  $clean_data = array();
@@ -4139,21 +4295,21 @@ class MLAData {
4139
  if ( is_array( $value ) ) {
4140
  foreach ($value as $text_key => $text )
4141
  $value[ $text_key ] = self::_bin_to_utf8( $text );
4142
-
4143
  $clean_data[ $key ] = 'ARRAY(' . implode( ',', $value ) . ')';
4144
- }
4145
- elseif ( is_string( $value ) )
4146
  $clean_data[ $key ] = self::_bin_to_utf8( substr( $value, 0, 256 ) );
4147
- else
4148
  $clean_data[ $key ] = self::_bin_to_utf8( $value );
 
4149
  }
4150
 
4151
  $text = var_export( $clean_data, true);
4152
  }
4153
-
4154
  return $text;
4155
  }
4156
-
4157
  /**
4158
  * Parse one PDF metadata field
4159
  *
@@ -4172,31 +4328,33 @@ class MLAData {
4172
  $text = $item_metadata['mla_pdf_metadata'][ $pdf_key ];
4173
  if ( is_array( $text ) ) {
4174
  foreach ($text as $key => $value ) {
4175
- if ( is_array( $value ) )
4176
  $text[ $key ] = self::_bin_to_utf8( var_export( $value, true ) );
4177
- else
4178
  $text[ $key ] = self::_bin_to_utf8( $value );
 
4179
  }
4180
- }
4181
- elseif ( is_string( $text ) )
4182
  $text = self::_bin_to_utf8( $text );
 
4183
  } elseif ( 'ALL_PDF' == $pdf_key ) {
4184
  $clean_data = array();
4185
  foreach ( $item_metadata['mla_pdf_metadata'] as $key => $value ) {
4186
- if ( is_array( $value ) )
4187
  $clean_data[ $key ] = '(ARRAY)';
4188
- elseif ( is_string( $value ) )
4189
  $clean_data[ $key ] = self::_bin_to_utf8( substr( $value, 0, 256 ) );
4190
- else
4191
  $clean_data[ $key ] = $value;
 
4192
  }
4193
-
4194
  $text = var_export( $clean_data, true);
4195
  } // ALL_PDF
4196
-
4197
  return $text;
4198
  }
4199
-
4200
  /**
4201
  * Convert an EXIF GPS rational value to a PHP float value
4202
  *
@@ -4210,7 +4368,7 @@ class MLAData {
4210
  $parts = explode('/', $rational);
4211
  return $parts[0] / ( $parts[1] ? $parts[1] : 1);
4212
  }
4213
-
4214
  /**
4215
  * Fetch and filter IPTC and EXIF or PDF metadata for an image attachment
4216
  *
@@ -4229,8 +4387,9 @@ class MLAData {
4229
  'mla_pdf_metadata' => array()
4230
  );
4231
 
4232
- if ( 0 != $post_id )
4233
  $path = get_attached_file($post_id);
 
4234
 
4235
  if ( ! empty( $path ) ) {
4236
  if ( 'pdf' == strtolower( pathinfo( $path, PATHINFO_EXTENSION ) ) ) {
@@ -4239,32 +4398,32 @@ class MLAData {
4239
  }
4240
 
4241
  $size = getimagesize( $path, $info );
4242
-
4243
  if ( is_callable( 'iptcparse' ) ) {
4244
  if ( !empty( $info['APP13'] ) ) {
4245
  $iptc_values = iptcparse( $info['APP13'] );
4246
- if ( ! is_array( $iptc_values ) )
4247
  $iptc_values = array();
4248
-
 
4249
  foreach ( $iptc_values as $key => $value ) {
4250
  if ( in_array( $key, array( '1#000', '1#020', '1#022', '1#120', '1#122', '2#000', '2#200', '2#201' ) ) ) {
4251
  $value = unpack( 'nbinary', $value[0] );
4252
  $results['mla_iptc_metadata'][ $key ] = (string) $value['binary'];
4253
- }
4254
- elseif ( 1 == count( $value ) )
4255
  $results['mla_iptc_metadata'][ $key ] = $value[0];
4256
- else
4257
  $results['mla_iptc_metadata'][ $key ] = $value;
4258
-
4259
  } // foreach $value
4260
  } // !empty
4261
  }
4262
-
4263
  if ( is_callable( 'exif_read_data' ) && in_array( $size[2], array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) ) ) {
4264
  $results['mla_exif_metadata'] = $exif_data = exif_read_data( $path );
4265
  }
4266
  }
4267
-
4268
  /*
4269
  * Expand EXIF GPS values
4270
  */
@@ -4272,18 +4431,17 @@ class MLAData {
4272
  if ( isset( $exif_data['GPSVersion'] ) ) {
4273
  $gps_data['Version'] = sprintf( '%1$d.%2$d.%3$d.%4$d', ord( $exif_data['GPSVersion'][0] ), ord( $exif_data['GPSVersion'][1] ), ord( $exif_data['GPSVersion'][2] ), ord( $exif_data['GPSVersion'][3] ) );
4274
  }
4275
-
4276
  if ( isset( $exif_data['GPSLatitudeRef'] ) ) {
4277
  $gps_data['LatitudeRef'] = $exif_data['GPSLatitudeRef'];
4278
  $gps_data['LatitudeRefS'] = ( 'N' == $exif_data['GPSLatitudeRef'] ) ? '' : '-';
4279
  $ref = $gps_data['LatitudeRef'];
4280
  $refs = $gps_data['LatitudeRefS'];
4281
- }
4282
- else {
4283
  $ref = '';
4284
  $refs = '';
4285
  }
4286
-
4287
  if ( isset( $exif_data['GPSLatitude'] ) ) {
4288
  $rational = $exif_data['GPSLatitude'];
4289
  $gps_data['LatitudeD'] = $degrees = self::_rational_to_decimal( $rational[0] );
@@ -4291,7 +4449,7 @@ class MLAData {
4291
  $gps_data['LatitudeS'] = sprintf( '%1$01.4f', $seconds = self::_rational_to_decimal( $rational[2] ) );
4292
  $decimal_minutes = $minutes + ( $seconds / 60 );
4293
  $decimal_degrees = ( $decimal_minutes / 60 );
4294
-
4295
  $gps_data['Latitude'] = sprintf( '%1$dd %2$d\' %3$01.4f" %4$s', $degrees, $minutes, $seconds, $ref );
4296
  $gps_data['LatitudeDM'] = sprintf( '%1$d %2$01.4f', $degrees, $decimal_minutes );
4297
  $gps_data['LatitudeDD'] = sprintf( '%1$01f', $degrees + $decimal_degrees );
@@ -4302,18 +4460,17 @@ class MLAData {
4302
  $gps_data['LatitudeDM'] = $gps_data['LatitudeDM'] . $ref;
4303
  $gps_data['LatitudeDD'] = $gps_data['LatitudeDD'] . $ref;
4304
  }
4305
-
4306
  if ( isset( $exif_data['GPSLongitudeRef'] ) ) {
4307
  $gps_data['LongitudeRef'] = $exif_data['GPSLongitudeRef'];
4308
  $gps_data['LongitudeRefS'] = ( 'E' == $exif_data['GPSLongitudeRef'] ) ? '' : '-';
4309
  $ref = $gps_data['LongitudeRef'];
4310
  $refs = $gps_data['LongitudeRefS'];
4311
- }
4312
- else {
4313
  $ref = '';
4314
  $refs = '';
4315
  }
4316
-
4317
  if ( isset( $exif_data['GPSLongitude'] ) ) {
4318
  $rational = $exif_data['GPSLongitude'];
4319
  $gps_data['LongitudeD'] = $degrees = self::_rational_to_decimal( $rational[0] );
@@ -4321,7 +4478,7 @@ class MLAData {
4321
  $gps_data['LongitudeS'] = sprintf( '%1$01.4f', $seconds = self::_rational_to_decimal( $rational[2] ) );
4322
  $decimal_minutes = $minutes + ( $seconds / 60 );
4323
  $decimal_degrees = ( $decimal_minutes / 60 );
4324
-
4325
  $gps_data['Longitude'] = sprintf( '%1$dd %2$d\' %3$01.4f" %4$s', $degrees, $minutes, $seconds, $ref );
4326
  $gps_data['LongitudeDM'] = sprintf( '%1$d %2$01.4f', $degrees, $decimal_minutes );
4327
  $gps_data['LongitudeDD'] = sprintf( '%1$01f', $degrees + $decimal_degrees );
@@ -4332,13 +4489,12 @@ class MLAData {
4332
  $gps_data['LongitudeDM'] = $gps_data['LongitudeDM'] . $ref;
4333
  $gps_data['LongitudeDD'] = $gps_data['LongitudeDD'] . $ref;
4334
  }
4335
-
4336
  if ( isset( $exif_data['GPSAltitudeRef'] ) ) {
4337
  $gps_data['AltitudeRef'] = sprintf( '%1$d', ord( $exif_data['GPSAltitudeRef'][0] ) );
4338
  $gps_data['AltitudeRefS'] = ( '0' == $gps_data['AltitudeRef'] ) ? '' : '-';
4339
  $refs = $gps_data['AltitudeRefS'];
4340
- }
4341
- else {
4342
  $refs = '';
4343
  }
4344
 
@@ -4346,7 +4502,7 @@ class MLAData {
4346
  $gps_data['Altitude'] = sprintf( '%1$s%2$01.4f', $refs, $meters = self::_rational_to_decimal( $exif_data['GPSAltitude'] ) );
4347
  $gps_data['AltitudeFeet'] = sprintf( '%1$s%2$01.2f', $refs, $meters * 3.280839895013 );
4348
  }
4349
-
4350
  if ( isset( $exif_data['GPSTimeStamp'] ) ) {
4351
  $rational = $exif_data['GPSTimeStamp'];
4352
  $gps_data['TimeStampH'] = sprintf( '%1$02d', $hours = self::_rational_to_decimal( $rational[0] ) );
@@ -4354,7 +4510,7 @@ class MLAData {
4354
  $gps_data['TimeStampS'] = sprintf( '%1$02d', $seconds = self::_rational_to_decimal( $rational[2] ) );
4355
  $gps_data['TimeStamp'] = sprintf( '%1$02d:%2$02d:%3$02d', $hours, $minutes, $seconds );
4356
  }
4357
-
4358
  if ( isset( $exif_data['GPSDateStamp'] ) ) {
4359
  $parts = explode( ':', $exif_data['GPSDateStamp'] );
4360
  $gps_data['DateStampY'] = $parts[0];
@@ -4367,8 +4523,9 @@ class MLAData {
4367
  $gps_data['MapDatum'] = $exif_data['GPSMapDatum'];
4368
  }
4369
 
4370
- if ( ! empty( $gps_data ) )
4371
  $results['mla_exif_metadata']['GPS'] = $gps_data;
 
4372
 
4373
  /*
4374
  * Expand EXIF array values
@@ -4383,9 +4540,9 @@ class MLAData {
4383
 
4384
  return $results;
4385
  }
4386
-
4387
  /**
4388
- * Update one "meta:" data for a single attachment
4389
  *
4390
  * @since 1.51
4391
  *
@@ -4394,9 +4551,9 @@ class MLAData {
4394
  *
4395
  * @return string success/failure message(s); empty string if no changes.
4396
  */
4397
- private static function _update_wp_attachment_metadata( &$current_values, $new_meta ) {
4398
  $message = '';
4399
-
4400
  foreach( $new_meta as $key => $value ) {
4401
  /*
4402
  * The "Multi" option has no meaning for attachment_metadata;
@@ -4406,56 +4563,67 @@ class MLAData {
4406
  unset( $value[0x80000000] );
4407
  unset( $value[0x80000001] );
4408
  unset( $value[0x80000002] );
4409
-
4410
  if ( 1 == count( $value ) ) {
4411
- foreach ( $value as $single_key => $single_value )
4412
- if ( is_integer( $single_key ) )
4413
  $value = $single_value;
 
 
4414
  } // one-element array
4415
  } // Multi-key value
4416
-
4417
  $old_value = self::mla_find_array_element( $key, $current_values, 'array' );
4418
  if ( ! empty( $old_value ) ) {
4419
  if ( empty( $value ) ) {
4420
- if ( self::_unset_array_element( $key, $current_values ) )
4421
- $message .= sprintf( 'Deleting meta:%1$s<br>', $key );
4422
- else
4423
- $message .= sprintf( 'ERROR: meta:%1$s not found<br>', $key );
4424
-
 
 
 
4425
  continue;
4426
  }
4427
- } // old_value present
4428
- else {
4429
  if ( ! empty( $value ) ) {
4430
- if ( self::_set_array_element( $key, $value, $current_values ) )
4431
- $message .= sprintf( 'Adding meta:%1$s = %2$s<br>', $key,
 
4432
  ( is_array( $value ) ) ? var_export( $value, true ) : $value );
4433
- else
4434
- $message .= sprintf( 'ERROR: Adding meta:%1$s; not found<br>', $key );
 
 
4435
 
4436
  continue;
4437
- }
4438
- elseif ( NULL == $value ) {
4439
- if ( self::_unset_array_element( $key, $current_values ) )
4440
- $message .= sprintf( 'Deleting Null meta:%1$s<br>', $key );
4441
-
 
4442
  continue;
4443
  }
4444
  } // old_value empty
4445
-
4446
  if ( $old_value != $value ) {
4447
- if ( self::_set_array_element( $key, $value, $current_values ) )
4448
- $message .= sprintf( 'Changing meta:%1$s from "%2$s" to "%3$s"<br>', $key,
4449
- ( is_array( $old_value ) ) ? var_export( $old_value, true ) : $old_value,
4450
- ( is_array( $value ) ) ? var_export( $value, true ) : $value );
4451
- else
4452
- $message .= sprintf( 'ERROR: Changing meta:%1$s; not found<br>', $key );
 
 
 
4453
  }
4454
  } // foreach new_meta
4455
-
4456
  return $message;
4457
  }
4458
-
4459
  /**
4460
  * Update custom field and "meta:" data for a single attachment
4461
  *
@@ -4477,54 +4645,62 @@ class MLAData {
4477
  $attachment_meta_values[ $meta_key ] = $meta_value;
4478
  continue;
4479
  }
4480
-
4481
- if ( $multi_key = isset( $meta_value[0x80000000] ) )
4482
  unset( $meta_value[0x80000000] );
4483
-
 
4484
  if ( $keep_existing = isset( $meta_value[0x80000001] ) ) {
4485
  $keep_existing = (boolean) $meta_value[0x80000001];
4486
  unset( $meta_value[0x80000001] );
4487
  }
4488
-
4489
  if ( $no_null = isset( $meta_value[0x80000002] ) ) {
4490
  $no_null = (boolean) $meta_value[0x80000002];
4491
  unset( $meta_value[0x80000002] );
4492
  }
4493
-
4494
  if ( isset( $post_data[ 'mla_item_' . $meta_key ] ) ) {
4495
  $old_meta_value = $post_data[ 'mla_item_' . $meta_key ];
4496
-
4497
  if ( $multi_key && $no_null ) {
4498
- if ( is_string( $old_meta_value ) )
4499
  $old_meta_value = trim( $old_meta_value );
4500
-
 
4501
  $delete = empty( $old_meta_value );
4502
- }
4503
- else
4504
  $delete = NULL == $meta_value;
4505
-
 
4506
  if ( $delete) {
4507
- if ( delete_post_meta( $post_id, $meta_key ) )
4508
- $message .= sprintf( 'Deleting %1$s<br>', $meta_key );
4509
-
 
 
4510
  continue;
4511
  }
4512
- }
4513
- else {
4514
  if ( NULL != $meta_value ) {
4515
- if ( $multi_key )
4516
  foreach ( $meta_value as $new_value ) {
4517
- if ( add_post_meta( $post_id, $meta_key, $new_value ) )
4518
- $message .= sprintf( 'Adding %1$s = [%2$s]<br>', $meta_key, $new_value );
 
 
 
 
 
 
 
4519
  }
4520
- else
4521
- if ( add_post_meta( $post_id, $meta_key, $meta_value ) )
4522
- $message .= sprintf( 'Adding %1$s = %2$s<br>', $meta_key, $meta_value );
4523
  }
4524
 
4525
  continue; // no change or message if old and new are both NULL
4526
  } // no old value
4527
-
4528
  $old_text = ( is_array( $old_meta_value ) ) ? var_export( $old_meta_value, true ) : $old_meta_value;
4529
 
4530
  /*
@@ -4534,16 +4710,20 @@ class MLAData {
4534
  /*
4535
  * Test for "no changes"
4536
  */
4537
- if ( $meta_value == (array) $old_meta_value )
4538
  continue;
4539
-
 
4540
  if ( ! $keep_existing ) {
4541
- if ( delete_post_meta( $post_id, $meta_key ) )
4542
- $message .= sprintf( 'Deleting old %1$s values<br>', $meta_key );
 
 
 
4543
  $old_meta_value = array();
4544
- }
4545
- elseif ( $old_text == $old_meta_value ) // single value
4546
  $old_meta_value = array( $old_meta_value );
 
4547
 
4548
  $updated = 0;
4549
  foreach ( $meta_value as $new_value ) {
@@ -4553,53 +4733,61 @@ class MLAData {
4553
  $updated++;
4554
  }
4555
  }
4556
-
4557
  if ( $updated ) {
4558
  $meta_value = get_post_meta( $post_id, $meta_key );
4559
- if ( is_array( $meta_value ) )
4560
- if ( 1 == count( $meta_value ) )
4561
  $new_text = $meta_value[0];
4562
- else
4563
  $new_text = var_export( $meta_value, true );
4564
- else
 
4565
  $new_text = $meta_value;
4566
-
4567
- $message .= sprintf( 'Changing %1$s from "%2$s" to "%3$s"; %4$d updates<br>', $meta_key, $old_text, $new_text, $updated );
 
 
4568
  }
4569
- }
4570
- elseif ( $old_meta_value != $meta_value ) {
4571
- if ( is_array( $old_meta_value ) )
4572
  delete_post_meta( $post_id, $meta_key );
 
4573
 
4574
- if ( is_array( $meta_value ) )
4575
  $new_text = var_export( $meta_value, true );
4576
- else
4577
  $new_text = $meta_value;
4578
-
4579
- if ( update_post_meta( $post_id, $meta_key, $meta_value ) )
4580
- $message .= sprintf( 'Changing %1$s from "%2$s" to "%3$s"<br>', $meta_key, $old_text, $new_text );
 
 
 
4581
  }
4582
  } // foreach $new_meta
4583
-
4584
  /*
4585
  * Process the "meta:" updates, if any
4586
  */
4587
  if ( ! empty( $attachment_meta_values ) ) {
4588
- if ( isset( $post_data['mla_wp_attachment_metadata'] ) )
4589
  $current_values = $post_data['mla_wp_attachment_metadata'];
4590
- else
4591
  $current_values = array();
4592
-
4593
- $results = self::_update_wp_attachment_metadata( $current_values, $attachment_meta_values );
 
4594
  if ( ! empty( $results ) ) {
4595
- if ( update_post_meta( $post_id, '_wp_attachment_metadata', $current_values ) )
4596
  $message .= $results;
 
4597
  }
4598
  }
4599
-
4600
  return $message;
4601
  }
4602
-
4603
  /**
4604
  * Update a single item; change the "post" data, taxonomy terms
4605
  * and meta data for a single attachment
@@ -4615,12 +4803,13 @@ class MLAData {
4615
  */
4616
  public static function mla_update_single_item( $post_id, $new_data, $tax_input = NULL, $tax_actions = NULL ) {
4617
  $post_data = self::mla_get_attachment_by_id( $post_id );
4618
- if ( !isset( $post_data ) )
4619
  return array(
4620
- 'message' => 'ERROR: Could not retrieve Attachment.',
4621
  'body' => ''
4622
  );
4623
-
 
4624
  $message = '';
4625
  $updates = array( 'ID' => $post_id );
4626
  $new_data = stripslashes_deep( $new_data );
@@ -4629,18 +4818,21 @@ class MLAData {
4629
  foreach ( $new_data as $key => $value ) {
4630
  switch ( $key ) {
4631
  case 'post_title':
4632
- if ( $value == $post_data[ $key ] )
4633
  break;
4634
-
4635
- $message .= sprintf( 'Changing Title from "%1$s" to "%2$s"<br>', esc_attr( $post_data[ $key ] ), esc_attr( $value ) );
 
 
4636
  $updates[ $key ] = $value;
4637
  break;
4638
  case 'post_name':
4639
- if ( $value == $post_data[ $key ] )
4640
  break;
4641
-
 
4642
  $value = sanitize_title( $value );
4643
-
4644
  /*
4645
  * Make sure new slug is unique
4646
  */
@@ -4651,75 +4843,95 @@ class MLAData {
4651
  'showposts' => 1
4652
  );
4653
  $my_posts = get_posts( $args );
4654
-
4655
  if ( $my_posts ) {
4656
- $message .= sprintf( 'ERROR: Could not change Name/Slug "%1$s"; name already exists<br>', $value );
 
4657
  } else {
4658
- $message .= sprintf( 'Changing Name/Slug from "%1$s" to "%2$s"<br>', esc_attr( $post_data[ $key ] ), $value );
 
4659
  $updates[ $key ] = $value;
4660
  }
4661
  break;
4662
  case 'image_alt':
4663
  $key = 'mla_wp_attachment_image_alt';
4664
- if ( !isset( $post_data[ $key ] ) )
4665
  $post_data[ $key ] = '';
4666
-
4667
- if ( $value == $post_data[ $key ] )
 
4668
  break;
4669
-
 
4670
  if ( empty( $value ) ) {
4671
- if ( delete_post_meta( $post_id, '_wp_attachment_image_alt', $value ) )
4672
- $message .= sprintf( 'Deleting Alternate Text, was "%1$s"<br>', esc_attr( $post_data[ $key ] ) );
4673
- else
4674
- $message .= sprintf( 'ERROR: Could not delete Alternate Text, remains "%1$s"<br>', esc_attr( $post_data[ $key ] ) );
 
 
 
4675
  } else {
4676
- if ( update_post_meta( $post_id, '_wp_attachment_image_alt', $value ) )
4677
- $message .= sprintf( 'Changing Alternate Text from "%1$s" to "%2$s"<br>', esc_attr( $post_data[ $key ] ), esc_attr( $value ) );
4678
- else
4679
- $message .= sprintf( 'ERROR: Could not change Alternate Text from "%1$s" to "%2$s"<br>', esc_attr( $post_data[ $key ] ), esc_attr( $value ) );
 
 
 
4680
  }
4681
  break;
4682
  case 'post_excerpt':
4683
- if ( $value == $post_data[ $key ] )
4684
  break;
4685
-
4686
- $message .= sprintf( 'Changing Caption from "%1$s" to "%2$s"<br>', esc_attr( $post_data[ $key ] ), esc_attr( $value ) );
 
 
4687
  $updates[ $key ] = $value;
4688
  break;
4689
  case 'post_content':
4690
- if ( $value == $post_data[ $key ] )
4691
  break;
4692
-
4693
- $message .= sprintf( 'Changing Description from "%1$s" to "%2$s"<br>', esc_textarea( $post_data[ $key ] ), esc_textarea( $value ) );
 
 
4694
  $updates[ $key ] = $value;
4695
  break;
4696
  case 'post_parent':
4697
- if ( $value == $post_data[ $key ] )
4698
  break;
4699
-
 
4700
  $value = absint( $value );
4701
-
4702
- $message .= sprintf( 'Changing Parent from "%1$s" to "%2$s"<br>', $post_data[ $key ], $value );
 
4703
  $updates[ $key ] = $value;
4704
  break;
4705
  case 'menu_order':
4706
- if ( $value == $post_data[ $key ] )
4707
  break;
4708
-
 
4709
  $value = absint( $value );
4710
-
4711
- $message .= sprintf( 'Changing Menu Order from "%1$s" to "%2$s"<br>', $post_data[ $key ], $value );
 
4712
  $updates[ $key ] = $value;
4713
  break;
4714
  case 'post_author':
4715
- if ( $value == $post_data[ $key ] )
4716
  break;
4717
-
 
4718
  $value = absint( $value );
4719
-
4720
  $from_user = get_userdata( $post_data[ $key ] );
4721
  $to_user = get_userdata( $value );
4722
- $message .= sprintf( 'Changing Author from "%1$s" to "%2$s"<br>', $from_user->display_name, $to_user->display_name );
 
4723
  $updates[ $key ] = $value;
4724
  break;
4725
  case 'taxonomy_updates':
@@ -4733,14 +4945,15 @@ class MLAData {
4733
  // Ignore anything else
4734
  } // switch $key
4735
  } // foreach $new_data
4736
-
4737
  if ( !empty( $tax_input ) ) {
4738
  foreach ( $tax_input as $taxonomy => $tags ) {
4739
- if ( !empty( $tax_actions ) )
4740
  $tax_action = $tax_actions[ $taxonomy ];
4741
- else
4742
  $tax_action = 'replace';
4743
-
 
4744
  $taxonomy_obj = get_taxonomy( $taxonomy );
4745
 
4746
  if ( current_user_can( $taxonomy_obj->cap->assign_terms ) ) {
@@ -4749,72 +4962,78 @@ class MLAData {
4749
  ) );
4750
  if ( is_array( $tags ) ) // array = hierarchical, string = non-hierarchical.
4751
  $tags = array_filter( $tags );
4752
-
4753
  switch ( $tax_action ) {
4754
  case 'add':
4755
- $action_name = 'Adding';
4756
  $result = wp_set_post_terms( $post_id, $tags, $taxonomy, true );
4757
  break;
4758
  case 'remove':
4759
- $action_name = 'Removing';
4760
  $tags = self::_remove_tags( $terms_before, $tags, $taxonomy_obj );
4761
  $result = wp_set_post_terms( $post_id, $tags, $taxonomy );
4762
  break;
4763
  case 'replace':
4764
- $action_name = 'Replacing';
4765
  $result = wp_set_post_terms( $post_id, $tags, $taxonomy );
4766
  break;
4767
  default:
4768
- $action_name = 'Ignoring';
4769
  $result = NULL;
4770
  // ignore anything else
4771
  }
4772
-
4773
  $terms_after = wp_get_post_terms( $post_id, $taxonomy, array(
4774
  'fields' => 'ids' // all'
4775
  ) );
4776
-
4777
- if ( $terms_before != $terms_after )
4778
- $message .= sprintf( '%1$s "%2$s" terms<br>', $action_name, $taxonomy );
4779
- } // current_user_can
4780
- else {
4781
- $message .= sprintf( 'You cannot assign "%1$s" terms<br>', $action_name, $taxonomy );
 
 
4782
  }
4783
  } // foreach $tax_input
4784
  } // !empty $tax_input
4785
-
4786
- if ( is_array( $new_meta ) )
4787
  $message .= self::mla_update_item_postmeta( $post_id, $new_meta );
4788
-
4789
- if ( empty( $message ) )
 
4790
  return array(
4791
- 'message' => 'Item: ' . $post_id . ', no changes detected.',
 
4792
  'body' => ''
4793
  );
4794
- else {
4795
  self::mla_get_attachment_by_id( -1 ); // invalidate the cached item
4796
 
4797
  if ( wp_update_post( $updates ) ) {
4798
- $final_message = 'Item: ' . $post_id . ' updated.';
 
4799
  /*
4800
  * Uncomment this for debugging.
4801
  */
4802
  // $final_message .= '<br>' . $message;
4803
  // error_log( 'DEBUG: message = ' . var_export( $message, true ), 0 );
4804
-
4805
  return array(
4806
  'message' => $final_message,
4807
  'body' => ''
4808
  );
4809
- }
4810
- else
4811
  return array(
4812
- 'message' => 'ERROR: Item ' . $post_id . ' update failed.',
 
4813
  'body' => ''
4814
  );
 
4815
  }
4816
  }
4817
-
4818
  /**
4819
  * Remove tags from a term ids list
4820
  *
@@ -4831,33 +5050,38 @@ class MLAData {
4831
  /*
4832
  * Convert names to term ids
4833
  */
4834
- $comma = _x( ',', 'tag delimiter' );
4835
- if ( ',' !== $comma )
4836
  $tags = str_replace( $comma, ',', $tags );
 
 
4837
  $terms = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) );
4838
 
4839
  $tags = array();
4840
  foreach ( (array) $terms as $term) {
4841
- if ( !strlen(trim($term)) )
4842
  continue;
 
4843
 
4844
  // Skip if a non-existent term name is passed.
4845
- if ( ! $term_info = term_exists($term, $taxonomy_obj->name ) )
4846
  continue;
 
4847
 
4848
- if ( is_wp_error($term_info) )
4849
  continue;
 
4850
 
4851
  $tags[] = $term_info['term_id'];
4852
  } // foreach term
4853
  } // not an array
4854
-
4855
  $tags = array_map( 'intval', $tags );
4856
  $tags = array_unique( $tags );
4857
  $terms_after = array_diff( array_map( 'intval', $terms_before ), $tags );
4858
  return $terms_after;
4859
  }
4860
-
4861
  /**
4862
  * Format printable version of binary data
4863
  *
@@ -4870,54 +5094,60 @@ class MLAData {
4870
  *
4871
  * @return string Printable representation of $data
4872
  */
4873
- private static function _hex_dump( $data, $limit = 0, $bytes_per_row = 16, $offset = -1 ) {
4874
- if ( 0 == $limit )
4875
  $limit = strlen( $data );
4876
-
 
4877
  $position = 0;
4878
  $output = "\r\n";
4879
  $print_offset = ( 0 <= $offset );
4880
-
4881
- if ( $print_offset )
4882
  $print_length = $bytes_per_row += 5;
4883
- else
4884
  $print_length = $bytes_per_row;
4885
-
 
4886
  while ( $position < $limit ) {
4887
  $row_length = strlen( substr( $data, $position ) );
4888
-
4889
- if ( 0 == $row_length )
4890
  break;
4891
-
4892
- if ( $row_length > ( $limit - $position ) )
 
4893
  $row_length = $limit - $position;
 
4894
 
4895
- if ( $row_length > $bytes_per_row )
4896
  $row_length = $bytes_per_row;
 
4897
 
4898
  $row_data = substr( $data, $position, $row_length );
4899
-
4900
  if ( $print_offset ) {
4901
  $print_string = sprintf( '%04X ', $position + $offset );
4902
- }
4903
- else
4904
  $print_string = '';
4905
-
 
4906
  $hex_string = '';
4907
  for ( $index = 0; $index < $row_length; $index++ ) {
4908
  $char = ord( substr( $row_data, $index, 1 ) );
4909
- if ( ( 31 < $char ) && ( 127 > $char ) )
4910
  $print_string .= chr($char);
4911
- else
4912
  $print_string .= '.';
4913
-
 
4914
  $hex_string .= ' ' . bin2hex( chr($char) );
4915
  } // for
4916
-
4917
  $output .= str_pad( $print_string, $print_length, ' ', STR_PAD_RIGHT ) . $hex_string . "\r\n";
4918
  $position += $row_length;
4919
  } // while
4920
-
4921
  return $output;
4922
  }
4923
  } // class MLAData
5
  * @package Media Library Assistant
6
  * @since 0.1
7
  */
8
+
9
  /**
10
  * Class MLA (Media Library Assistant) Data provides database and template file access for MLA needs
11
  *
17
  */
18
  class MLAData {
19
  /**
20
+ * Provides a unique suffix for the ALT Text/custom field SQL View
21
+ *
22
+ * The SQL View is used to sort the Media/Assistant submenu table on
23
+ * ALT Text and custom field columns.
24
  *
25
  * @since 0.40
26
  */
27
  const MLA_ALT_TEXT_VIEW_SUFFIX = 'alt_text_view';
28
+
29
  /**
30
+ * Provides a unique name for the ALT Text/custom field SQL View
31
  *
32
  * @since 0.40
33
  *
34
  * @var array
35
  */
36
  private static $mla_alt_text_view = NULL;
37
+
38
  /**
39
  * Initialization function, similar to __construct()
40
  *
48
  add_action( 'edit_attachment', 'MLAData::mla_save_post_action', 10, 1);
49
  add_action( 'add_attachment', 'MLAData::mla_save_post_action', 10, 1);
50
  }
51
+
52
  /**
53
  * Load an HTML template from a file
54
  *
59
  * @since 0.1
60
  *
61
  * @param string Complete path and name of the template file, option name or the raw template
62
+ * @param string Optional type of template source; 'path', 'file' (default), 'option', 'string'
63
  *
64
  * @return string|array|false|NULL
65
  * string for files that do not contain template divider comments,
70
  public static function mla_load_template( $source, $type = 'file' ) {
71
  switch ( $type ) {
72
  case 'file':
73
+ /*
74
+ * Look in three places, in this order:
75
+ * 1) Custom templates
76
+ * 2) Language-specific templates
77
+ * 3) Standard templates
78
+ */
79
+ $text_domain = 'media-library-assistant';
80
+ $locale = apply_filters( 'mla_plugin_locale', get_locale(), $text_domain );
81
+ $path = trailingslashit( WP_LANG_DIR ) . $text_domain . '/tpls/' . $locale . '/' . $source;
82
+ if ( file_exists( $path ) ) {
83
+ $source = $path;
84
+ } else {
85
+ $path = MLA_PLUGIN_PATH . 'languages/tpls/' . $locale . '/' . $source;
86
+ if ( file_exists( $path ) ) {
87
+ $source = $path;
88
+ } else {
89
+ $source = MLA_PLUGIN_PATH . '/tpls/' . $source;
90
+ }
91
+ }
92
+ // fallthru
93
+ case 'path':
94
+ if ( !file_exists( $source ) ) {
95
  return false;
96
+ }
97
+
98
  $template = file_get_contents( $source, true );
99
  if ( $template == false ) {
100
+ /* translators: 1: path and file name */
101
+ error_log( sprintf( _x( 'ERROR: mla_load_template file "%1$s" not found.', 'error_log', 'media-library-assistant' ), var_export( $source, true ) ), 0 );
102
  return NULL;
103
  }
104
  break;
115
  }
116
  break;
117
  default:
118
+ /* translators: 1: path and file name 2: source type, e.g., file, option, string */
119
+ error_log( sprintf( _x( 'ERROR: mla_load_template file "%1$s" bad source type "%2$s".', 'error_log', 'media-library-assistant' ), $source, $type ), 0 );
120
  return NULL;
121
  }
122
+
123
  $match_count = preg_match_all( '#\<!-- template=".+" --\>#', $template, $matches, PREG_OFFSET_CAPTURE );
124
+
125
+ if ( ( $match_count == false ) || ( $match_count == 0 ) ) {
126
  return $template;
127
+ }
128
+
129
  $matches = array_reverse( $matches[0] );
130
+
131
  $template_array = array();
132
  $current_offset = strlen( $template );
133
  foreach ( $matches as $key => $value ) {
137
  /*
138
  * Trim exactly one newline sequence from the start of the value
139
  */
140
+ if ( 0 === strpos( $template_value, "\r\n" ) ) {
141
  $offset = 2;
142
+ } elseif ( 0 === strpos( $template_value, "\n\r" ) ) {
143
  $offset = 2;
144
+ } elseif ( 0 === strpos( $template_value, "\n" ) ) {
145
  $offset = 1;
146
+ } elseif ( 0 === strpos( $template_value, "\r" ) ) {
147
  $offset = 1;
148
+ } else {
149
  $offset = 0;
150
+ }
151
 
152
  $template_value = substr( $template_value, $offset );
153
+
154
  /*
155
  * Trim exactly one newline sequence from the end of the value
156
  */
157
  $length = strlen( $template_value );
158
+ if ( $length > 2) {
159
  $postfix = substr( $template_value, ($length - 2), 2 );
160
+ } else {
161
  $postfix = $template_value;
162
+ }
163
+
164
+ if ( 0 === strpos( $postfix, "\r\n" ) ) {
165
  $length -= 2;
166
+ } elseif ( 0 === strpos( $postfix, "\n\r" ) ) {
167
  $length -= 2;
168
+ } elseif ( 0 === strpos( $postfix, "\n" ) ) {
169
  $length -= 1;
170
+ } elseif ( 0 === strpos( $postfix, "\r" ) ) {
171
  $length -= 1;
172
+ }
173
+
174
  $template_array[ $template_key ] = substr( $template_value, 0, $length );
175
  $current_offset = $value[1];
176
  } // foreach $matches
177
+
178
  return $template_array;
179
  }
180
+
181
  /**
182
  * Find a complete template, balancing opening and closing delimiters
183
  *
194
  do {
195
  $template_end = strpos( $tpl, '+]', $nest );
196
  if ( false === $template_end ) {
197
+ /* translators: 1: template excerpt */
198
+ error_log( sprintf( _x( 'ERROR: _find_template_substring no template end delimiter, tail = "%1$s".', 'error_log', 'media-library-assistant' ), substr( $tpl, $offset ) ), 0 );
199
  return '';
200
  }
201
+
202
  $nest = strpos( $tpl, '[+', $nest );
203
  if ( false === $nest ) {
204
  $nest = $template_end + 2;
205
  $level--;
206
+ } elseif ( $nest < $template_end ) {
 
207
  $nest += 2;
208
  $level++;
209
+ } else {
 
210
  $nest = $template_end + 2;
211
  $level--;
212
  }
213
+
214
  } while ( $level );
215
+
216
  $template_length = $template_end + 2;
217
  $template_content = substr( $tpl, 0, $template_length );
218
  return $template_content;
220
 
221
  return '';
222
  }
223
+
224
  /**
225
  * Expand a template, replacing placeholders with their values
226
  *
231
  * @param string A formatting string containing [+placeholders+]
232
  * @param array An associative array containing keys and values e.g. array('key' => 'value')
233
  *
234
+ * @return mixed string or array, depending on placeholder values. Placeholders corresponding
235
+ * to the keys of the markup_values will be replaced with their values.
236
  */
237
  public static function mla_parse_array_template( $tpl, $markup_values ) {
238
  $result = array();
239
  $offset = 0;
240
  while ( false !== $start = strpos( $tpl, '[+', $offset ) ) {
241
+ if ( $offset < $start ) {
242
  $result[] = substr( $tpl, $offset, ( $start - $offset ) );
243
+ }
244
+
245
  if ( $template_content = self::_find_template_substring( substr( $tpl, $start ) ) ) {
246
  $template_length = strlen( $template_content );
247
  $template_content = substr( $template_content, 11, $template_length - (11 + 2) );
249
 
250
  foreach ( $template_content as $value )
251
  $result[] = $value;
252
+
253
  $offset = $start + $template_length;
254
+ } else { // found template
 
255
  if ( false === $end = strpos( $tpl, '+]', $offset ) ) {
256
+ /* translators: 1: template excerpt */
257
+ error_log( sprintf( _x( 'ERROR: mla_parse_array_template no template end delimiter, tail = "%1$s".', 'error_log', 'media-library-assistant' ), substr( $tpl, $offset ) ), 0 );
258
  return $tpl;
259
  } // no end delimiter
260
 
261
  $key = substr( $tpl, $start + 2, $end - $start - 2 );
262
  if ( isset( $markup_values[ $key ] ) ) {
263
  $result[] = $markup_values[ $key ];
264
+ } else { // found key and scalar value
 
265
  $result[] = substr( $tpl, $start, ( $end + 2 ) - $start );
266
  }
267
 
268
  $offset = $end + 2;
269
  } // simple substitution
270
  } // while substitution parameter present
271
+
272
+ if ( $offset < strlen( $tpl ) ) {
273
  $result[] = substr( $tpl, $offset );
274
+ }
275
 
276
  /*
277
  * Build a final result, eliminating empty elements and expanding array elements
280
  foreach ( $result as $element ) {
281
  if ( is_scalar( $element ) ) {
282
  $element = trim( $element );
283
+ if ( ! empty( $element ) ) {
284
+ $final[] = $element;
285
+ }
286
+ } elseif ( is_array( $element ) ) {
287
  foreach ($element as $key => $value ) {
288
+ if ( is_scalar( $value ) ) {
289
  $value = trim( $value );
290
+ } elseif ( ! empty( $value ) ) {
291
  $value = var_export( $value, true );
292
+ }
293
 
294
  /*
295
  * Preserve any keys with string values
296
  */
297
+ if ( ! empty( $value ) ) {
298
+ if ( is_integer( $key ) ) {
299
  $final[] = $value;
300
+ } else {
301
  $final[ $key ] = $value;
302
+ }
303
+ }
304
  }
305
+ } elseif ( ! empty( $element ) ) {
 
306
  $final[] = var_export( $element, true );
307
+ }
308
  }
309
+
310
+ if ( 1 == count( $final ) ) {
311
  $final = $final[0];
312
+ }
313
+
314
  return $final;
315
  }
316
+
317
  /**
318
  * Expand a template, replacing placeholders with their values
319
  *
339
  $template_content = self::_expand_field_level_template( $template_content, $markup_values );
340
  $tpl = substr_replace( $tpl, $template_content, $start, $template_length );
341
  $offset = $start;
342
+ } else { // found template
 
343
  if ( false === $end = strpos( $tpl, '+]', $offset ) ) {
344
+ /* translators: 1: template excerpt */
345
+ error_log( sprintf( _x( 'ERROR: mla_parse_template no end delimiter, tail = "%1$s".', 'error_log', 'media-library-assistant' ), substr( $tpl, $offset ) ), 0 );
346
  return $tpl;
347
  } // no end delimiter
348
 
350
  if ( isset( $markup_values[ $key ] ) && is_scalar( $markup_values[ $key ] ) ) {
351
  $tpl = substr_replace( $tpl, $markup_values[ $key ], $start, strlen( $key ) + 4 );
352
  $offset = $start;
353
+ } else { // found key and scalar value
 
354
  $offset += strlen( $key ) + 4;
355
+ }
356
  } // simple substitution
357
  } // while substitution parameter present
358
+ } else { // template(s) present
 
359
  /*
360
  * No templates means a simple string substitution will suffice
361
  */
362
  foreach ( $markup_values as $key => $value ) {
363
+ if ( is_scalar( $value ) ) {
364
  $tpl = str_replace( '[+' . $key . '+]', $value, $tpl );
365
+ }
366
  }
367
+ }
368
+
369
  return $tpl;
370
  }
371
+
372
  /**
373
  * Find a complete (test) element, balancing opening and closing delimiters
374
  *
385
  do {
386
  $test_end = strpos( $tpl, ')', $nest );
387
  if ( false === $test_end ) {
388
+ /* translators: 1: template string */
389
+ error_log( sprintf( _x( 'ERROR: _find_test_substring no end delimiter, tail = "%1$s".', 'error_log', 'media-library-assistant' ), substr( $tpl, $nest ) ), 0 );
390
  return '';
391
  }
392
+
393
  $nest = strpos( $tpl, '(', $nest );
394
  if ( false === $nest ) {
395
  $nest = $test_end + 1;
396
  $level--;
397
+ } elseif ( $nest < $test_end ) {
 
398
  $nest += 1;
399
  $level++;
400
+ } else {
 
401
  $nest = $test_end + 1;
402
  $level--;
403
  }
404
  } while ( $level );
405
+
406
  $test_length = $test_end + 1;
407
  $test_content = substr( $tpl, 0, $test_length );
408
  return $test_content;
410
 
411
  return '';
412
  }
413
+
414
  /**
415
  * Convert field-level "template:" string into its component parts
416
  *
434
  $output .= $byte;
435
  continue;
436
  } // template ends with a backslash
437
+
438
  switch ( $tpl[ $index ] ) {
439
  case 'n':
440
  $output .= chr( 0x0A );
452
  $output .= chr( 0x0C );
453
  break;
454
  default: // could be a 1- to 3-digit octal value
455
+ if ( $max_length < ( $digit_limit = $index + 3 ) ) {
456
  $digit_limit = $max_length;
457
+ }
458
+
459
  $digit_index = $index;
460
  while ( $digit_index < $digit_limit )
461
+ if ( ! ctype_digit( $tpl[ $digit_index ] ) ) {
462
  break;
463
+ } else {
464
  $digit_index++;
465
+ }
466
 
467
  if ( $digit_count = $digit_index - $index ) {
468
  $output .= chr( octdec( substr( $tpl, $index, $digit_count ) ) );
469
  $index += $digit_count - 1;
470
+ } else { // accept the character following the backslash
 
471
  $output .= $tpl[ $index ];
472
  }
473
  } // switch
474
+
475
  $index++;
476
  } // REVERSE SOLIDUS (backslash)
477
  elseif ( '(' == $byte ) {
486
  $output_values[] = array( 'type' => 'test', 'value' => $values, 'length' => strlen( $test_content ) );
487
  $index += strlen( $test_content ) - 1;
488
  } // found a value
489
+ elseif ( 2 == $test_length ) {
490
  $index++; // empty test string
491
+ } else {
492
+ $test_content = __( 'ERROR: Test; no closing parenthesis ', 'media-library-assistant' );
493
  $output_values[] = array( 'type' => 'string', 'value' => $test_content, 'length' => strlen( $test_content ) );
494
  } // bad test string
495
  } // (test) element
497
  /*
498
  * Turn each alternative within a choice element into a conditional
499
  */
500
+
501
  if ( ! empty( $output ) ) {
502
  $output_values[] = array( 'type' => 'string', 'value' => $output, 'length' => strlen( $output ) );
503
  $output = '';
505
 
506
  $length = 0;
507
  foreach ( $output_values as $value )
508
+ if ( isset( $value['length'] ) ) {
509
  $length += $value['length'];
510
+ }
511
+
512
  $choice_values[] = array( 'type' => 'test', 'value' => $output_values, 'length' => $length );
513
  $output_values = array();
514
  } // choice element
520
 
521
  $template_content = self::_find_template_substring( substr( $tpl, $index - 1 ) );
522
  $values = self::_parse_field_level_template( substr( $template_content, 11, strlen( $template_content ) - (11 + 2) ) );
523
+ if ( 'template' == $values['type'] ) {
524
  $output_values = array_merge( $output_values, $values['value'] );
525
+ } else {
526
  $output_values[] = $values;
527
+ }
528
+
529
  $index += strlen( $template_content ) - 1;
530
+ } else { // nested template
 
531
  $output .= $byte;
532
+ }
533
  } // $index < $max_length
534
 
535
  if ( ! empty( $output ) ) {
536
  $output_values[] = array( 'type' => 'string', 'value' => $output, 'length' => strlen( $output ) );
537
  }
538
+
539
  if ( ! empty( $choice_values ) ) {
540
  if ( ! empty( $output_values ) ) {
541
  $length = 0;
542
  foreach ( $output_values as $value )
543
+ if ( isset( $value['length'] ) ) {
544
  $length += $value['length'];
545
+ }
546
+
547
  $choice_values[] = array( 'type' => 'test', 'value' => $output_values, 'length' => $length );
548
  }
549
+
550
  return array( 'type' => 'choice', 'value' => $choice_values, 'length' => $max_length );
551
  }
552
 
553
+ if ( 1 == count( $output_values ) ) {
554
  return $output_values[0];
555
+ }
556
 
557
  return array ( 'type' => 'template', 'value' => $output_values, 'length' => $max_length );
558
  }
559
+
560
  /**
561
  * Analyze a field-level "template:" element, expanding Field-level Markup Substitution Parameters
562
  *
580
  foreach ( $node_result as $value )
581
  $result[] = $value;
582
  }
583
+ } else { // array of sub-nodes
 
584
  switch ( $node['type'] ) {
585
  case 'string':
586
  $result[] = self::mla_parse_array_template( $node['value'], $markup_values );
587
  break;
588
  case 'test':
589
  $node_value = $node['value'];
590
+
591
  if ( isset( $node_value['type'] ) ) {
592
  $node_result = self::_evaluate_template_array_node( $node_value, $markup_values );
593
  foreach ( $node_result as $value )
594
  $result[] = $value;
595
+ } else { // single node
 
596
  foreach ( $node_value as $value ) {
597
  $node_result = self::_evaluate_template_array_node( $value, $markup_values );
598
  foreach ( $node_result as $value )
599
  $result[] = $value;
600
  }
601
  } // array of nodes
602
+
603
  foreach ($result as $element )
604
  if ( is_scalar( $element ) && false !== strpos( $element, '[+' ) ) {
605
  $result = array();
606
  break;
607
+ } elseif ( is_array( $element ) ) {
 
608
  foreach ( $element as $value )
609
  if ( is_scalar( $value ) && false !== strpos( $value, '[+' ) ) {
610
  $result = array();
611
  break;
612
  }
613
  } // is_array
614
+
615
  break;
616
  case 'choice':
617
  foreach ( $node['value'] as $value ) {
622
  break;
623
  }
624
  }
625
+
626
  break;
627
  case 'template':
628
  foreach ( $node['value'] as $value ) {
633
 
634
  break;
635
  default:
636
+ /* translators: 1: node type, e.g., template */
637
+ error_log( sprintf( _x( 'ERROR: _evaluate_template_array_node unknown type "%1$s".', 'error_log', 'media-library-assistant' ), $node ), 0 );
638
  } // node type
639
  } // isset node type
640
 
641
  return $result;
642
  }
643
+
644
  /**
645
  * Analyze a field-level "template:" element, expanding Field-level Markup Substitution Parameters
646
  *
662
 
663
  return $results;
664
  } // array of sub-nodes
665
+
666
  switch ( $node['type'] ) {
667
  case 'string':
668
  return self::mla_parse_template( $node['value'], $markup_values );
671
 
672
  if ( isset( $node_value['type'] ) ) {
673
  $results = self::_evaluate_template_node( $node_value, $markup_values );
674
+ } else { // single node
 
675
  foreach ( $node_value as $value )
676
  $results .= self::_evaluate_template_node( $value, $markup_values );
677
  } // array of nodes
678
+
679
+ if ( false === strpos( $results, '[+' ) ) {
680
  return $results;
681
+ }
682
 
683
  break;
684
  case 'choice':
688
  return $results;
689
  }
690
  }
691
+
692
  break;
693
  case 'template':
694
  foreach ( $node['value'] as $value )
695
  $results .= self::_evaluate_template_node( $value, $markup_values );
696
+
697
  return $results;
698
  default:
699
+ /* translators: 1: node type, e.g., template */
700
+ error_log( sprintf( _x( 'ERROR: _evaluate_template_node unknown type "%1$s".', 'error_log', 'media-library-assistant' ), $node ), 0 );
701
  } // node type
702
 
703
  return '';
704
  }
705
+
706
  /**
707
  * Analyze a field-level "template:" element, expanding Field-level Markup Substitution Parameters
708
  *
721
  */
722
  $root_element = self::_parse_field_level_template( $tpl );
723
  unset( $markup_values['[+template_count+]'] );
724
+
725
  /*
726
  * Step 2: Remove all the empty elements from the $markup_values,
727
  * so the evaluation of conditional and choice elements is simplified.
728
  */
729
  foreach ( $markup_values as $key => $value ) {
730
+ if ( is_scalar( $value ) ) {
731
  $value = trim( $value );
732
+ }
733
+
734
+ if ( empty( $value ) ) {
735
  unset( $markup_values[ $key ] );
736
+ }
737
  }
738
+
739
  /*
740
  * Step 3: walk the element tree and process each node
741
  */
742
+ if ( $return_arrays ) {
743
  $results = self::_evaluate_template_array_node( $root_element, $markup_values );
744
+ } else {
745
  $results = self::_evaluate_template_node( $root_element, $markup_values );
746
+ }
747
+
748
  return $results;
749
  }
750
+
751
  /**
752
  * Process an markup field array value according to the supplied data-format option
753
  *
781
  $text .= strlen( $text ) ? ', ' . $term_name : $term_name;
782
  }
783
  } // $option
784
+
785
  return $text;
786
  }
787
+
788
  /**
789
  * Analyze a template, expanding Field-level Markup Substitution Parameters
790
  *
810
  $attachment_metadata = NULL;
811
  $cached_post_id = $post_id;
812
  }
813
+
814
  $placeholders = self::mla_get_template_placeholders( $tpl, $default_option );
815
  $template_count = 0;
816
  foreach ($placeholders as $key => $value ) {
817
+ if ( isset( $markup_values[ $key ] ) ) {
818
  continue;
819
+ }
820
+
821
  switch ( $value['prefix'] ) {
822
  case 'template':
823
  $markup_values = self::mla_expand_field_level_parameters( $value['value'], $query , $markup_values, $post_id, $keep_existing, $default_option );
824
  $template_count++;
825
  break;
826
  case 'meta':
827
+ if ( is_null( $item_metadata ) ) {
828
+ if ( 0 < $post_id ) {
829
  $item_metadata = get_metadata( 'post', $post_id, '_wp_attachment_metadata', true );
830
+ } else {
831
  break;
832
+ }
833
+ }
834
 
835
  $markup_values[ $key ] = self::mla_find_array_element( $value['value'], $item_metadata, $value['option'] );
836
  break;
837
  case 'query':
838
+ if ( isset( $query ) && isset( $query[ $value['value'] ] ) ) {
839
  $markup_values[ $key ] = $query[ $value['value'] ];
840
+ } else {
841
  $markup_values[ $key ] = '';
842
+ }
843
 
844
  break;
845
  case 'request':
846
+ if ( isset( $_REQUEST[ $value['value'] ] ) ) {
847
  $record = $_REQUEST[ $value['value'] ];
848
+ } else {
849
  $record = '';
850
+ }
851
 
852
+ if ( is_scalar( $record ) ) {
853
  $text = sanitize_text_field( (string) $record );
854
+ } elseif ( is_array( $record ) ) {
855
+ if ( 'export' == $value['option'] ) {
856
  $text = sanitize_text_field( var_export( $record, true ) );
857
+ } else {
858
  $text = '';
859
  foreach ( $record as $term ) {
860
  $term_name = sanitize_text_field( $term );
866
  $markup_values[ $key ] = $text;
867
  break;
868
  case 'terms':
869
+ if ( 0 < $post_id ) {
870
  $terms = wp_get_object_terms( $post_id, $value['value'] );
871
+ } else {
872
  break;
873
+ }
874
+
875
  $text = '';
876
  if ( is_wp_error( $terms ) ) {
877
  $text = implode( ',', $terms->get_error_messages() );
878
+ } elseif ( ! empty( $terms ) ) {
879
+ if ( 'single' == $value['option'] || 1 == count( $terms ) ) {
 
880
  $text = sanitize_term_field( 'name', $terms[0]->name, $terms[0]->term_id, $value, 'display' );
881
+ } elseif ( 'export' == $value['option'] ) {
882
  $text = sanitize_text_field( var_export( $terms, true ) );
883
+ } else {
884
  foreach ( $terms as $term ) {
885
  $term_name = sanitize_term_field( 'name', $term->name, $term->term_id, $value, 'display' );
886
  $text .= strlen( $text ) ? ', ' . $term_name : $term_name;
887
  }
888
+ }
889
  }
890
+
891
  $markup_values[ $key ] = $text;
892
  break;
893
  case 'custom':
897
  $meta_values = self::mla_fetch_attachment_metadata( $post_id );
898
  $clean_data = array();
899
  foreach( $meta_values as $meta_key => $meta_value ) {
900
+ if ( 0 !== strpos( $meta_key, 'mla_item_' ) ) {
901
  continue;
902
+ }
903
+
904
  $meta_key = substr( $meta_key, 9 );
905
+ if ( is_array( $meta_value ) ) {
906
  $clean_data[ $meta_key ] = '(ARRAY)';
907
+ } elseif ( is_string( $meta_value ) ) {
908
  $clean_data[ $meta_key ] = self::_bin_to_utf8( substr( $meta_value, 0, 256 ) );
909
+ } else {
910
  $clean_data[ $meta_key ] = $meta_value;
911
+ }
912
  } // foreach value
913
+
914
  /*
915
  * Convert the array to text, strip the outer "array( ... ,)" literal,
916
  * the interior linefeed/space/space separators and backslashes.
920
  $record = str_replace( chr(0x0A).' ', ' ', $record );
921
  $record = str_replace( '\\', '', $record );
922
  } // ALL_CUSTOM
923
+ } else {
 
924
  break;
925
+ }
926
+
927
  $text = '';
928
+ if ( is_wp_error( $record ) ) {
929
  $text = implode( ',', $terms->get_error_messages() );
930
+ } elseif ( ! empty( $record ) ) {
931
+ if ( is_scalar( $record ) ) {
932
  $text = sanitize_text_field( (string) $record );
933
+ } elseif ( is_array( $record ) ) {
934
+ if ( 'export' == $value['option'] ) {
935
  $text = sanitize_text_field( var_export( $record, true ) );
936
+ } else {
937
  $text = '';
938
  foreach ( $record as $term ) {
939
  $term_name = sanitize_text_field( $term );
942
  }
943
  } // is_array
944
  } // ! empty
945
+
946
  $markup_values[ $key ] = $text;
947
  break;
948
  case 'iptc':
949
  if ( is_null( $attachment_metadata ) ) {
950
+ if ( 0 < $post_id ) {
951
  $attachment_metadata = self::mla_fetch_attachment_image_metadata( $post_id );
952
+ } else {
953
  break;
954
+ }
955
  }
956
+
957
  $record = self::mla_iptc_metadata_value( $value['value'], $attachment_metadata );
958
+ if ( is_array( $record ) ) {
959
  $markup_values[ $key ] = self::_process_field_level_array( $record, $value['option'], $keep_existing );
960
+ } else {
961
  $markup_values[ $key ] = $record;
962
+ }
963
 
964
  break;
965
  case 'exif':
966
  if ( is_null( $attachment_metadata ) ) {
967
+ if ( 0 < $post_id ) {
968
  $attachment_metadata = self::mla_fetch_attachment_image_metadata( $post_id );
969
+ } else {
970
  break;
971
+ }
972
  }
973
+
974
  $record = self::mla_exif_metadata_value( $value['value'], $attachment_metadata );
975
+ if ( is_array( $record ) ) {
976
  $markup_values[ $key ] = self::_process_field_level_array( $record, $value['option'], $keep_existing );
977
+ } else {
978
  $markup_values[ $key ] = $record;
979
+ }
980
+
981
  break;
982
  case 'pdf':
983
  if ( is_null( $attachment_metadata ) ) {
984
+ if ( 0 < $post_id ) {
985
  $attachment_metadata = self::mla_fetch_attachment_image_metadata( $post_id );
986
+ } else {
987
  break;
988
+ }
989
  }
990
+
991
  $record = self::mla_pdf_metadata_value( $value['value'], $attachment_metadata );
992
+ if ( is_array( $record ) ) {
993
  $markup_values[ $key ] = self::_process_field_level_array( $record, $value['option'], $keep_existing );
994
+ } else {
995
  $markup_values[ $key ] = $record;
996
+ }
997
+
998
  break;
999
  default:
1000
  // ignore anything else
1001
  } // switch
1002
  } // foreach placeholder
1003
+
1004
+ if ( $template_count ) {
1005
  $markup_values['[+template_count+]'] = $template_count;
1006
+ }
1007
+
1008
  return $markup_values;
1009
  }
1010
+
1011
  /**
1012
  * Analyze a template, returning an array of the placeholders it contains
1013
  *
1032
  do {
1033
  $template_end = strpos( $tpl, '+]', $nest );
1034
  if ( false === $template_end ) {
1035
+ /* translators: 1: template excerpt */
1036
+ error_log( sprintf( _x( 'ERROR: mla_get_template_placeholders no template-end delimiter dump = "%1$s".', 'error_log', 'media-library-assistant' ), self::_hex_dump( substr( $tpl, $template_offset, 128 ), 128, 16 ) ), 0 );
1037
  return array();
1038
  }
1039
+
1040
  $nest = strpos( $tpl, '[+', $nest );
1041
  if ( false === $nest ) {
1042
  $nest = $template_end + 2;
1043
  $level--;
1044
+ } elseif ( $nest < $template_end ) {
 
1045
  $nest += 2;
1046
  $level++;
1047
+ } else {
 
1048
  $nest = $template_end + 2;
1049
  $level--;
1050
  }
1051
+
1052
  } while ( $level );
1053
+
1054
  $template_length = $template_end + 2 - $template_offset;
1055
  $template_content = substr( $tpl, $template_offset + 11, $template_length - (11 + 2) );
1056
  $placeholders = self::mla_get_template_placeholders( $template_content );
1058
  $results = array_merge( $results, $result, $placeholders );
1059
  $tpl = substr_replace( $tpl, '', $template_offset, $template_length );
1060
  } // found a template
1061
+
1062
  $match_count = preg_match_all( '/\[\+[^+]+\+\]/', $tpl, $matches );
1063
+ if ( ( $match_count == false ) || ( $match_count == 0 ) ) {
1064
  return $results;
1065
+ }
1066
+
1067
  foreach ( $matches[0] as $match ) {
1068
  $key = substr( $match, 2, (strlen( $match ) - 4 ) );
1069
  $result = array( 'prefix' => '', 'value' => '', 'option' => $default_option );
1071
  if ( 1 == $match_count ) {
1072
  $result['prefix'] = $matches[1];
1073
  $tail = $matches[2];
1074
+ } else {
 
1075
  $tail = substr( $match, 2);
1076
  }
1077
+
1078
  $match_count = preg_match( '/([^,]+)(,(text|single|export|array|multi))\+\]/', $tail, $matches );
1079
  if ( 1 == $match_count ) {
1080
  $result['value'] = $matches[1];
1081
  $result['option'] = $matches[3];
1082
+ } else {
 
1083
  $result['value'] = substr( $tail, 0, (strlen( $tail ) - 2 ) );
1084
  }
1085
+
1086
  $results[ $key ] = $result;
1087
  } // foreach
1088
+
1089
  return $results;
1090
  }
1091
+
1092
  /**
1093
  * Cache the results of mla_count_list_table_items for reuse in mla_query_list_table_items
1094
  *
1097
  * @var array
1098
  */
1099
  private static $mla_list_table_items = NULL;
1100
+
1101
  /**
1102
  * Get the total number of attachment posts
1103
  *
1120
  $request = self::_prepare_list_table_query( $request );
1121
  $results = self::_execute_list_table_query( $request );
1122
  self::$mla_list_table_items = NULL;
1123
+
1124
  return $results->found_posts;
1125
  }
1126
+
1127
  /**
1128
  * Retrieve attachment objects for list table display
1129
  *
1153
  foreach ( $parent_data as $parent_key => $parent_value ) {
1154
  $attachments[ $index ]->$parent_key = $parent_value;
1155
  }
1156
+
1157
  /*
1158
  * Add meta data
1159
  */
1167
  $references = self::mla_fetch_attachment_references( $attachment->ID, $attachment->post_parent );
1168
  $attachments[ $index ]->mla_references = $references;
1169
  }
1170
+
1171
  return $attachments;
1172
  }
1173
+
1174
  /**
1175
  * Retrieve attachment objects for the WordPress Media Manager
1176
  *
1188
  $request = self::_prepare_list_table_query( $request, $offset, $count );
1189
  return self::_execute_list_table_query( $request );
1190
  }
1191
+
1192
  /**
1193
  * WP_Query filter "parameters"
1194
  *
1224
  * sanitize or validate them.
1225
  */
1226
  if ( ! is_array( $raw_request ) ) {
1227
+ /* translators: 1: function name 2: non-array value */
1228
+ error_log( sprintf( _x( 'ERROR: %1$s non-array "%2$s"', 'error_log', 'media-library-assistant' ), 'MLAData::_prepare_list_table_query', var_export( $raw_request, true ) ), 0 );
1229
  return null;
1230
  }
1231
+
1232
  /*
1233
  * Make sure the current orderby choice still exists or revert to default.
1234
  */
1256
  'mla_search_connector' => 'AND',
1257
  'mla_search_fields' => array()
1258
  );
1259
+
1260
  foreach ( $raw_request as $key => $value ) {
1261
  switch ( $key ) {
1262
  /*
1270
  $clean_request[ $key ] = sanitize_key( $value );
1271
  break;
1272
  case 'orderby':
1273
+ if ( 'none' == $value ) {
1274
  $clean_request[ $key ] = $value;
1275
+ } else {
1276
  $sortable_columns = MLA_List_Table::mla_get_sortable_columns( );
1277
  foreach ($sortable_columns as $sort_key => $sort_value ) {
1278
  if ( $value == $sort_value[0] ) {
1318
  }
1319
  break;
1320
  case 'detached':
1321
+ if ( '1' == $value ) {
1322
  $clean_request['detached'] = '1';
1323
+ }
1324
+
1325
  break;
1326
  case 'status':
1327
+ if ( 'trash' == $value ) {
1328
  $clean_request['post_status'] = 'trash';
1329
+ }
1330
+
1331
  break;
1332
  /*
1333
  * ['s'] - Search Media by one or more keywords
1342
  $clean_request['debug'] = 'log';
1343
  break;
1344
  }
1345
+
1346
+ if ( isset( $clean_request['debug'] ) ) {
1347
  $value = substr( $value, 3 );
1348
+ }
1349
+
1350
  $value = stripslashes( trim( $value ) );
1351
+
1352
+ if ( ! empty( $value ) ) {
1353
  $clean_request[ $key ] = $value;
1354
+ }
1355
+
1356
  break;
1357
  case 'mla_search_connector':
1358
  case 'mla_search_fields':
1364
  break;
1365
  case 'meta_query':
1366
  if ( ! empty( $value ) ) {
1367
+ if ( is_array( $value ) ) {
1368
  $clean_request[ $key ] = $value;
1369
+ } else {
1370
  $clean_request[ $key ] = unserialize( stripslashes( $value ) );
1371
  unset( $clean_request[ $key ]['slug'] );
1372
  } // not array
1373
  }
1374
+
1375
  break;
1376
  default:
1377
  // ignore anything else in $_REQUEST
1378
  } // switch $key
1379
  } // foreach $raw_request
1380
+
1381
  /*
1382
  * Pass query parameters to the filters for _execute_list_table_query
1383
  */
1384
  self::$query_parameters = array( 'use_postmeta_view' => false, 'orderby' => $clean_request['orderby'], 'order' => $clean_request['order'] );
1385
  self::$query_parameters['detached'] = isset( $clean_request['detached'] );
1386
+
1387
  /*
1388
  * Matching a meta_value to NULL requires a LEFT JOIN to a view and a special WHERE clause
1389
  * Matching a wildcard pattern requires mainpulating the WHERE clause, too
1393
  self::$query_parameters['postmeta_key'] = $clean_request['meta_query']['key'];
1394
  self::$query_parameters['postmeta_value'] = NULL;
1395
  unset( $clean_request['meta_query'] );
1396
+ } elseif ( isset( $clean_request['meta_query']['patterns'] ) ) {
 
1397
  self::$query_parameters['patterns'] = $clean_request['meta_query']['patterns'];
1398
  unset( $clean_request['meta_query']['patterns'] );
1399
  }
1402
  self::$query_parameters['debug'] = $clean_request['debug'];
1403
  unset( $clean_request['debug'] );
1404
  }
1405
+
1406
  /*
1407
  * We must patch the WHERE clause if there are leading spaces in the meta_value
1408
  */
1409
+ if ( isset( $clean_request['mla-metavalue'] ) && (' ' == $clean_request['mla-metavalue'][0] ) ) {
1410
  self::$query_parameters['mla-metavalue'] = $clean_request['mla-metavalue'];
1411
+ }
1412
 
1413
  /*
1414
  * We will handle keyword search in the mla_query_posts_search_filter.
1421
  self::$query_parameters['mla_search_fields'] = $clean_request['mla_search_fields'];
1422
  self::$query_parameters['sentence'] = isset( $clean_request['sentence'] );
1423
  self::$query_parameters['exact'] = isset( $clean_request['exact'] );
1424
+
1425
+ if ( in_array( 'alt-text', self::$query_parameters['mla_search_fields'] ) ) {
1426
  self::$query_parameters['use_postmeta_view'] = true;
1427
  self::$query_parameters['postmeta_key'] = '_wp_attachment_image_alt';
1428
+ }
1429
  } // !empty
1430
+
1431
  // unset( $clean_request['s'] ); // WP v3.7 requires this to be present for posts_search filter
1432
  unset( $clean_request['mla_search_connector'] );
1433
  unset( $clean_request['mla_search_fields'] );
1444
  if ( isset( $option_value['name'] ) ) {
1445
  self::$query_parameters['use_postmeta_view'] = true;
1446
  self::$query_parameters['postmeta_key'] = $option_value['name'];
1447
+
1448
+ if ( isset($clean_request['orderby']) ) {
1449
  unset($clean_request['orderby']);
1450
+ }
1451
+
1452
+ if ( isset($clean_request['order']) ) {
1453
  unset($clean_request['order']);
1454
+ }
1455
  }
1456
+ } else { // custom field
 
1457
  switch ( self::$query_parameters['orderby'] ) {
1458
  /*
1459
  * '_wp_attachment_image_alt' is special; we'll handle it in the JOIN and ORDERBY filters
1461
  case '_wp_attachment_image_alt':
1462
  self::$query_parameters['use_postmeta_view'] = true;
1463
  self::$query_parameters['postmeta_key'] = '_wp_attachment_image_alt';
1464
+ if ( isset($clean_request['orderby']) ) {
1465
  unset($clean_request['orderby']);
1466
+ }
1467
+
1468
+ if ( isset($clean_request['order']) ) {
1469
  unset($clean_request['order']);
1470
+ }
1471
+
1472
  break;
1473
  case '_wp_attached_file':
1474
  $clean_request['meta_key'] = '_wp_attached_file';
1484
  if ( ( (int) $count ) > 0 ) {
1485
  $clean_request['offset'] = $offset;
1486
  $clean_request['posts_per_page'] = $count;
1487
+ } elseif ( ( (int) $count ) == -1 ) {
 
1488
  $clean_request['posts_per_page'] = $count;
1489
+ }
1490
+
1491
  /*
1492
  * ['mla_filter_term'] - filter by taxonomy
1493
  *
1510
  'operator' => 'NOT IN'
1511
  )
1512
  );
1513
+ } else { // mla_filter_term == -1
 
1514
  $clean_request['tax_query'] = array(
1515
  array(
1516
  'taxonomy' => $tax_filter,
1523
  );
1524
  } // mla_filter_term != -1
1525
  } // mla_filter_term != 0
1526
+
1527
  unset( $clean_request['mla_filter_term'] );
1528
  } // isset mla_filter_term
1529
+
1530
  if ( isset( $clean_request['mla-tax'] ) && isset( $clean_request['mla-term'] )) {
1531
  $clean_request['tax_query'] = array(
1532
  array(
1536
  'include_children' => false
1537
  )
1538
  );
1539
+
1540
  unset( $clean_request['mla-tax'] );
1541
  unset( $clean_request['mla-term'] );
1542
  } // isset mla_tax
1543
+
1544
  if ( isset( $clean_request['mla-metakey'] ) && isset( $clean_request['mla-metavalue'] ) ) {
1545
  $clean_request['meta_key'] = $clean_request['mla-metakey'];
1546
  $clean_request['meta_value'] = $clean_request['mla-metavalue'];
1548
  unset( $clean_request['mla-metakey'] );
1549
  unset( $clean_request['mla-metavalue'] );
1550
  } // isset mla_tax
1551
+
1552
  return $clean_request;
1553
  }
1554
 
1592
  if ( isset( self::$query_parameters['debug'] ) ) {
1593
  global $wp_filter;
1594
  $debug_array = array( 'posts_search' => $wp_filter['posts_search'], 'posts_join' => $wp_filter['posts_join'], 'posts_where' => $wp_filter['posts_where'], 'posts_orderby' => $wp_filter['posts_orderby'] );
1595
+
1596
  if ( 'console' == self::$query_parameters['debug'] ) {
1597
+ /* translators: 1: query filter details */
1598
+ trigger_error( sprintf( __( '_execute_list_table_query $wp_filter = "%1$s".', 'media-library-assistant' ), var_export( $debug_array, true ) ), E_USER_WARNING );
1599
+ } else {
1600
+ /* translators: 1: query filter details */
1601
+ error_log( sprintf( _x( 'DEBUG: _execute_list_table_query $wp_filter = "%1$s".', 'error_log', 'media-library-assistant' ), var_export( $debug_array, true ) ), 0 );
1602
  }
1603
  } // debug
1604
 
1605
  $results = new WP_Query( $request );
1606
+
1607
  if ( isset( self::$query_parameters['debug'] ) ) {
1608
  $debug_array = array( 'request' => $request, 'query_parameters' => self::$query_parameters, 'SQL_request' => $results->request, 'post_count' => $results->post_count, 'found_posts' => $results->found_posts );
1609
 
1610
  if ( 'console' == self::$query_parameters['debug'] ) {
1611
+ /* translators: 1: query details */
1612
+ trigger_error( sprintf( __( '_execute_list_table_query WP_Query = "%1$s".', 'media-library-assistant' ), var_export( $debug_array, true ) ), E_USER_WARNING );
1613
+ } else {
1614
+ /* translators: 1: query details */
1615
+ error_log( sprintf( _x( 'DEBUG: _execute_list_table_query WP_Query = "%1$s".', 'error_log', 'media-library-assistant' ), var_export( $debug_array, true ) ), 0 );
1616
  }
1617
  } // debug
1618
 
1627
 
1628
  return $results;
1629
  }
1630
+
1631
  /**
1632
  * Replaces a WordPress function deprecated in v3.7
1633
  *
1642
  public static function mla_search_terms_tidy( $term ) {
1643
  return trim( $term, "\"'\n\r " );
1644
  }
1645
+
1646
  /**
1647
  * Adds a keyword search to the WHERE clause, if required
1648
  *
1662
  */
1663
  $search_clause = '';
1664
  if ( isset( self::$query_parameters['s'] ) ) {
1665
+
1666
  if ( isset( self::$query_parameters['debug'] ) ) {
1667
  $debug_array = array( 's' => self::$query_parameters['s'] );
1668
  } // debug
1669
+
1670
  /*
1671
  * Interpret a numeric value as the ID of a specific attachment or the ID of a parent post/page
1672
  */
1673
+ if ( is_numeric( self::$query_parameters['s'] ) ) {
1674
  $id = absint( self::$query_parameters['s'] );
1675
  $search_clause = ' AND ( ( ' . $wpdb->posts . '.ID = ' . $id . ' ) OR ( ' . $wpdb->posts . '.post_parent = ' . $id . ' ) ) ';
1676
+
1677
  if ( isset( self::$query_parameters['debug'] ) ) {
1678
  $debug_array['search_clause'] = $search_clause;
1679
  $debug_array['search_string'] = $search_string;
1680
+
1681
  if ( 'console' == self::$query_parameters['debug'] ) {
1682
+ /* translators: 1: numeric search box details */
1683
+ trigger_error( sprintf( __( 'mla_query_posts_search_filter is_numeric, = "%1$s".', 'media-library-assistant' ), var_export( $debug_array, true ) ), E_USER_WARNING );
1684
+ } else {
1685
+ /* translators: 1: numeric search box details */
1686
+ error_log( sprintf( _x( 'DEBUG: mla_query_posts_search_filter is_numeric, = "%1$s".', 'error_log', 'media-library-assistant' ), var_export( $debug_array, true ) ), 0 );
1687
  }
1688
  } // debug
1689
+
1690
  return $search_clause;
1691
  }
1692
+
1693
  // WordPress v3.7 says: there are no line breaks in <input /> fields
1694
  self::$query_parameters['s'] = str_replace( array( "\r", "\n" ), '', self::$query_parameters['s'] );
1695
 
1700
  preg_match_all('/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', self::$query_parameters['s'], $matches);
1701
  $search_terms = array_map('MLAData::mla_search_terms_tidy', $matches[0]);
1702
  }
1703
+
1704
  $fields = self::$query_parameters['mla_search_fields'];
1705
  $percent = self::$query_parameters['exact'] ? '' : '%';
1706
  $connector = '';
1708
  $term = esc_sql( like_escape( $term ) );
1709
  $inner_connector = '';
1710
  $search_clause .= "{$connector}(";
1711
+
1712
  if ( in_array( 'content', $fields ) ) {
1713
  $search_clause .= "{$inner_connector}({$wpdb->posts}.post_content LIKE '{$percent}{$term}{$percent}')";
1714
  $inner_connector = ' OR ';
1715
  }
1716
+
1717
  if ( in_array( 'title', $fields ) ) {
1718
  $search_clause .= "{$inner_connector}({$wpdb->posts}.post_title LIKE '{$percent}{$term}{$percent}')";
1719
  $inner_connector = ' OR ';
1720
  }
1721
+
1722
  if ( in_array( 'excerpt', $fields ) ) {
1723
  $search_clause .= "{$inner_connector}({$wpdb->posts}.post_excerpt LIKE '{$percent}{$term}{$percent}')";
1724
  $inner_connector = ' OR ';
1725
  }
1726
+
1727
  if ( in_array( 'alt-text', $fields ) ) {
1728
  $view_name = self::$mla_alt_text_view;
1729
  $search_clause .= "{$inner_connector}({$view_name}.meta_value LIKE '{$percent}{$term}{$percent}')";
1730
  $inner_connector = ' OR ';
1731
  }
1732
+
1733
  if ( in_array( 'name', $fields ) ) {
1734
  $search_clause .= "{$inner_connector}({$wpdb->posts}.post_name LIKE '{$percent}{$term}{$percent}')";
1735
  }
1736
+
1737
  $search_clause .= ")";
1738
  $connector = ' ' . self::$query_parameters['mla_search_connector'] . ' ';
1739
  } // foreach
1740
 
1741
  if ( !empty($search_clause) ) {
1742
  $search_clause = " AND ({$search_clause}) ";
1743
+ if ( !is_user_logged_in() ) {
1744
  $search_clause .= " AND ($wpdb->posts.post_password = '') ";
1745
+ }
1746
  }
1747
+
1748
  if ( isset( self::$query_parameters['debug'] ) ) {
1749
  $debug_array['search_clause'] = $search_clause;
1750
  $debug_array['search_string'] = $search_string;
1751
+
1752
  if ( 'console' == self::$query_parameters['debug'] ) {
1753
+ /* translators: 1: search box details */
1754
+ trigger_error( sprintf( __( 'mla_query_posts_search_filter not numeric, = "%1$s".', 'media-library-assistant' ), var_export( $debug_array, true ) ), E_USER_WARNING );
1755
+ } else {
1756
+ /* translators: 1: search box details */
1757
+ error_log( sprintf( _x( 'DEBUG: mla_query_posts_search_filter not numeric, = "%1$s".', 'error_log', 'media-library-assistant' ), var_export( $debug_array, true ) ), 0 );
1758
  }
1759
  } // debug
1760
  } // isset 's'
1761
+
1762
  return $search_clause;
1763
  }
1764
 
1809
  if ( isset( self::$query_parameters['mla-metavalue'] ) ) {
1810
  $where_clause = preg_replace( '/(^.*meta_value AS CHAR\) = \')([^\']*)/', '${1}' . self::$query_parameters['mla-metavalue'], $where_clause );
1811
  }
1812
+
1813
  /*
1814
  * Matching a NULL meta value
1815
  */
1816
  if ( array_key_exists( 'postmeta_value', self::$query_parameters ) && NULL == self::$query_parameters['postmeta_value'] ) {
1817
  $where_clause .= ' AND ' . self::$mla_alt_text_view . '.meta_value IS NULL';
1818
  }
1819
+
1820
  /*
1821
  * WordPress modifies the LIKE clause - which we must reverse
1822
  */
1826
  $where_clause = str_replace( "LIKE '{$match_clause}'", "LIKE '{$pattern}'", $where_clause );
1827
  }
1828
  }
1829
+
1830
  /*
1831
  * Unattached items require some help
1832
  */
1833
+ if ( self::$query_parameters['detached'] ) {
1834
  $where_clause .= " AND {$table_prefix}posts.post_parent < 1";
1835
+ }
1836
 
1837
  return $where_clause;
1838
  }
1855
  if ( isset( self::$query_parameters['orderby'] ) ) {
1856
  if ( 'c_' == substr( self::$query_parameters['orderby'], 0, 2 ) ) {
1857
  $orderby = self::$mla_alt_text_view . '.meta_value';
1858
+ } else { // custom field sort
 
1859
  switch ( self::$query_parameters['orderby'] ) {
1860
  case 'none':
1861
  $orderby = '';
1887
  $orderby = "{$table_prefix}posts." . self::$query_parameters['orderby'];
1888
  } // $query_parameters['orderby']
1889
  }
1890
+
1891
+ if ( ! empty( $orderby ) ) {
1892
  $orderby_clause = $orderby . ' ' . self::$query_parameters['order'];
1893
+ }
1894
  } // isset
1895
 
1896
  return $orderby_clause;
1897
  }
1898
+
1899
  /**
1900
  * Retrieve an Attachment array given a $post_id
1901
  *
1911
  function mla_get_attachment_by_id( $post_id ) {
1912
  global $post;
1913
  static $save_id = -1, $post_data;
1914
+
1915
+ if ( $post_id == $save_id ) {
1916
  return $post_data;
1917
+ } elseif ( $post_id == -1 ) {
1918
  $save_id = -1;
1919
  return NULL;
1920
  }
1921
+
1922
  $item = get_post( $post_id );
1923
  if ( empty( $item ) ) {
1924
+ /* translators: 1: post ID */
1925
+ error_log( sprintf( _x( 'ERROR: mla_get_attachment_by_id(%1$d) not found.', 'error_log', 'media-library-assistant' ), $post_id ), 0 );
1926
  return NULL;
1927
  }
1928
+
1929
  if ( $item->post_type != 'attachment' ) {
1930
+ /* translators: 1: post ID 2: post_type */
1931
+ error_log( sprintf( _x( 'ERROR: mla_get_attachment_by_id(%1$d) wrong post_type "%2$s".', 'error_log', 'media-library-assistant' ), $post_id, $item->post_type ), 0 );
1932
  return NULL;
1933
  }
1934
+
1935
  $post_data = (array) $item;
1936
  $post = $item;
1937
  setup_postdata( $item );
1938
+
1939
  /*
1940
  * Add parent data
1941
  */
1942
  $post_data = array_merge( $post_data, self::mla_fetch_attachment_parent_data( $post_data['post_parent'] ) );
1943
+
1944
  /*
1945
  * Add meta data
1946
  */
1947
  $post_data = array_merge( $post_data, self::mla_fetch_attachment_metadata( $post_id ) );
1948
+
1949
  /*
1950
  * Add references
1951
  */
1952
  $post_data['mla_references'] = self::mla_fetch_attachment_references( $post_id, $post_data['post_parent'] );
1953
+
1954
  $save_id = $post_id;
1955
  return $post_data;
1956
  }
1957
+
1958
  /**
1959
  * Returns information about an attachment's parent, if found
1960
  *
1966
  */
1967
  public static function mla_fetch_attachment_parent_data( $parent_id ) {
1968
  static $save_id = -1, $parent_data;
1969
+
1970
+ if ( $save_id == $parent_id ) {
1971
  return $parent_data;
1972
+ }
1973
+
1974
  $parent_data = array();
1975
  if ( $parent_id ) {
1976
  $parent = get_post( $parent_id );
1977
+
1978
+ if ( isset( $parent->post_date ) ) {
1979
  $parent_data['parent_date'] = $parent->post_date;
1980
+ }
1981
+
1982
+ if ( isset( $parent->post_title ) ) {
1983
  $parent_data['parent_title'] = $parent->post_title;
1984
+ }
1985
+
1986
+ if ( isset( $parent->post_type ) ) {
1987
  $parent_data['parent_type'] = $parent->post_type;
1988
+ }
1989
  }
1990
+
1991
  $save_id = $parent_id;
1992
  return $parent_data;
1993
  }
1994
+
1995
  /**
1996
  * Adds or replaces the value of a key in a possibly nested array structure
1997
  *
2006
  private static function _set_array_element( $needle, &$value, &$haystack ) {
2007
  $key_array = explode( '.', $needle );
2008
  $key = array_shift( $key_array );
2009
+
2010
  if ( empty( $key_array ) ) {
2011
  $haystack[ $key ] = $value;
2012
  return true;
2017
  * If an intermediate key does not exist, create an empty array for it.
2018
  */
2019
  if ( isset( $haystack[ $key ] ) ) {
2020
+ if ( ! is_array( $haystack[ $key ] ) ) {
2021
  return false;
2022
+ }
2023
+ } else {
2024
  $haystack[ $key ] = array();
2025
+ }
2026
+
2027
  return self::_set_array_element( implode( $key_array, '.' ), $value, $haystack[ $key ] );
2028
  }
2029
+
2030
  /**
2031
  * Deletes the value of a key in a possibly nested array structure
2032
  *
2040
  private static function _unset_array_element( $needle, &$haystack ) {
2041
  $key_array = explode( '.', $needle );
2042
  $key = array_shift( $key_array );
2043
+
2044
  if ( empty( $key_array ) ) {
2045
  if ( isset( $haystack[ $key ] ) ) {
2046
  unset( $haystack[ $key ] );
2047
  return true;
2048
  }
2049
+
2050
  return false;
2051
  } // lowest level
2052
 
2053
+ if ( isset( $haystack[ $key ] ) ) {
2054
  return self::_unset_array_element( implode( $key_array, '.' ), $haystack[ $key ] );
2055
+ }
2056
 
2057
  return false;
2058
  }
2059
+
2060
  /**
2061
  * Finds the value of a key in a possibly nested array structure
2062
  *
2077
  if ( is_array( $key_array ) ) {
2078
  foreach ( $key_array as $key ) {
2079
  if ( is_array( $haystack ) ) {
2080
+ if ( isset( $haystack[ $key ] ) ) {
2081
  $haystack = $haystack[ $key ];
2082
+ } else {
2083
  $haystack = '';
2084
+ }
2085
+ } else {
2086
  $haystack = '';
2087
+ }
2088
  } // foreach $key
2089
+ } else {
2090
+ $haystack = '';
2091
  }
 
2092
 
2093
  if ( is_array( $haystack ) ) {
2094
  switch ( $option ) {
2109
  $haystack = implode( ', ', $haystack );
2110
  } // $option
2111
  }
2112
+
2113
  return sanitize_text_field( $haystack );
2114
  } // mla_find_array_element
2115
+
2116
  /**
2117
  * Fetch and filter meta data for an attachment
2118
  *
2127
  */
2128
  public static function mla_fetch_attachment_metadata( $post_id ) {
2129
  static $save_id = 0, $results;
2130
+
2131
+ if ( $save_id == $post_id ) {
2132
  return $results;
2133
+ }
2134
+
2135
  $attached_file = NULL;
2136
  $results = array();
2137
  $post_meta = get_metadata( 'post', $post_id );
2138
  if ( is_array( $post_meta ) ) {
2139
  foreach ( $post_meta as $post_meta_key => $post_meta_value ) {
2140
+ if ( empty( $post_meta_key ) ) {
2141
  continue;
2142
+ }
2143
+
2144
  if ( '_' == $post_meta_key{0} ) {
2145
  if ( stripos( $post_meta_key, '_wp_attached_file' ) === 0 ) {
2146
  $key = 'mla_wp_attached_file';
2153
  continue;
2154
  }
2155
  } else {
2156
+ if ( stripos( $post_meta_key, 'mla_' ) === 0 ) {
2157
  $key = $post_meta_key;
2158
+ } else {
2159
  $key = 'mla_item_' . $post_meta_key;
2160
+ }
2161
  }
2162
+
2163
  /*
2164
  * At this point, every value is an array; one element per instance of the key.
2165
  * We'll test anyway, just to be sure, then convert single-instance values to a scalar.
2166
  * Metadata array values are serialized for storage in the database.
2167
  */
2168
  if ( is_array( $post_meta_value ) ) {
2169
+ if ( count( $post_meta_value ) == 1 ) {
2170
  $post_meta_value = maybe_unserialize( $post_meta_value[0] );
2171
+ } else {
2172
+ foreach ( $post_meta_value as $single_key => $single_value ) {
2173
  $post_meta_value[ $single_key ] = maybe_unserialize( $single_value );
2174
+ }
2175
+ }
2176
  }
2177
 
2178
  $results[ $key ] = $post_meta_value;
2183
  if ( false === $last_slash ) {
2184
  $results['mla_wp_attached_path'] = '';
2185
  $results['mla_wp_attached_filename'] = $attached_file;
2186
+ } else {
 
2187
  $results['mla_wp_attached_path'] = substr( $attached_file, 0, $last_slash + 1 );
2188
  $results['mla_wp_attached_filename'] = substr( $attached_file, $last_slash + 1 );
2189
  }
2190
  } // $attached_file
2191
  } // is_array($post_meta)
2192
+
2193
  $save_id = $post_id;
2194
  return $results;
2195
  }
2196
+
2197
  /**
2198
  * Find Featured Image and inserted image/link references to an attachment
2199
  *
2210
  public static function mla_fetch_attachment_references( $ID, $parent ) {
2211
  global $wpdb;
2212
  static $save_id = 0, $references, $inserted_in_option = NULL;
2213
+
2214
+ if ( $save_id == $ID ) {
2215
  return $references;
2216
+ }
2217
+
2218
  /*
2219
  * tested_reference true if any of the four where-used types was processed
2220
  * found_reference true if any where-used array is not empty()
2256
  'parent_title' => '',
2257
  'parent_errors' => ''
2258
  );
2259
+
2260
  /*
2261
  * Fill in Parent data
2262
  */
2263
  $parent_data = self::mla_fetch_attachment_parent_data( $parent );
2264
+ if ( isset( $parent_data['parent_type'] ) ) {
2265
  $references['parent_type'] = $parent_data['parent_type'];
2266
+ }
2267
+
2268
+ if ( isset( $parent_data['parent_title'] ) ) {
2269
  $references['parent_title'] = $parent_data['parent_title'];
2270
+ }
2271
 
2272
  $references['base_file'] = get_post_meta( $ID, '_wp_attached_file', true );
2273
  $pathinfo = pathinfo($references['base_file']);
2274
  $references['file'] = $pathinfo['basename'];
2275
+ if ( '.' == $pathinfo['dirname'] ) {
2276
  $references['path'] = '/';
2277
+ } else {
2278
  $references['path'] = $pathinfo['dirname'] . '/';
2279
+ }
2280
 
2281
  $attachment_metadata = get_post_meta( $ID, '_wp_attachment_metadata', true );
2282
  $sizes = isset( $attachment_metadata['sizes'] ) ? $attachment_metadata['sizes'] : NULL;
2286
  $references['files'][ $references['path'] . $size['file'] ] = $size;
2287
  }
2288
  }
2289
+
2290
  $references['files'][ $references['base_file'] ] = $references['base_file'];
2291
 
2292
  /*
2293
  * Process the where-used settings option
2294
  */
2295
+ if ('checked' == MLAOptions::mla_get_option( MLAOptions::MLA_EXCLUDE_REVISIONS ) ) {
2296
  $exclude_revisions = "(post_type <> 'revision') AND ";
2297
+ } else {
2298
  $exclude_revisions = '';
2299
+ }
2300
 
2301
  /*
2302
  * Accumulate reference test types, e.g., 0 = no tests, 4 = all tests
2315
  WHERE meta_key = '_thumbnail_id' AND meta_value = {$ID}
2316
  "
2317
  );
2318
+
2319
  if ( !empty( $features ) ) {
2320
  foreach ( $features as $feature ) {
2321
  $feature_results = $wpdb->get_results(
2325
  WHERE {$exclude_revisions}(ID = {$feature->post_id})
2326
  "
2327
  );
2328
+
2329
  if ( !empty( $feature_results ) ) {
2330
  $references['found_reference'] = true;
2331
  $references['features'][ $feature->post_id ] = $feature_results[0];
2332
+
2333
  if ( $feature->post_id == $parent ) {
2334
  $references['found_parent'] = true;
2335
  }
2337
  } // foreach $feature
2338
  }
2339
  } // $process_featured_in
2340
+
2341
  /*
2342
  * Look for item(s) inserted in post_content
2343
  */
2344
  if ( MLAOptions::$process_inserted_in ) {
2345
  $reference_tests++;
2346
 
2347
+ if ( NULL == $inserted_in_option ) {
2348
  $inserted_in_option = MLAOptions::mla_get_option( MLAOptions::MLA_INSERTED_IN_TUNING );
2349
+ }
2350
+
2351
  if ( 'base' == $inserted_in_option ) {
2352
  $like1 = like_escape( $references['path'] . $pathinfo['filename'] ) . '.' . like_escape( $pathinfo['extension'] );
2353
  $like2 = like_escape( $references['path'] . $pathinfo['filename'] ) . '-%.' . like_escape( $pathinfo['extension'] );
2362
  if ( !empty( $inserts ) ) {
2363
  $references['found_reference'] = true;
2364
  $references['inserts'][ $pathinfo['filename'] ] = $inserts;
2365
+
2366
  foreach ( $inserts as $insert ) {
2367
  if ( $insert->ID == $parent ) {
2368
  $references['found_parent'] = true;
2369
  }
2370
  } // foreach $insert
2371
  } // !empty
2372
+ } else { // process base names
 
2373
  foreach ( $references['files'] as $file => $file_data ) {
2374
  $like = like_escape( $file );
2375
  $inserts = $wpdb->get_results(
2378
  WHERE {$exclude_revisions}(CONVERT(`post_content` USING utf8 ) LIKE %s)", "%{$like}%"
2379
  )
2380
  );
2381
+
2382
  if ( !empty( $inserts ) ) {
2383
  $references['found_reference'] = true;
2384
  $references['inserts'][ $file ] = $inserts;
2385
+
2386
  foreach ( $inserts as $insert ) {
2387
  if ( $insert->ID == $parent ) {
2388
  $references['found_parent'] = true;
2392
  } // foreach $file
2393
  } // process intermediate sizes
2394
  } // $process_inserted_in
2395
+
2396
  /*
2397
  * Look for [mla_gallery] references
2398
  */
2403
  if ( !empty( $galleries ) ) {
2404
  $references['found_reference'] = true;
2405
  $references['mla_galleries'] = $galleries;
2406
+
2407
  foreach ( $galleries as $post_id => $gallery ) {
2408
  if ( $post_id == $parent ) {
2409
  $references['found_parent'] = true;
2410
  }
2411
  } // foreach $gallery
2412
+ } else { // !empty
 
2413
  $references['mla_galleries'] = array();
2414
+ }
2415
  }
2416
  } // $process_mla_gallery_in
2417
+
2418
  /*
2419
  * Look for [gallery] references
2420
  */
2425
  if ( !empty( $galleries ) ) {
2426
  $references['found_reference'] = true;
2427
  $references['galleries'] = $galleries;
2428
+
2429
  foreach ( $galleries as $post_id => $gallery ) {
2430
  if ( $post_id == $parent ) {
2431
  $references['found_parent'] = true;
2432
  }
2433
  } // foreach $gallery
2434
+ } else { // !empty
 
2435
  $references['galleries'] = array();
2436
+ }
2437
  }
2438
  } // $process_gallery_in
2439
+
2440
  /*
2441
  * Evaluate and summarize reference tests
2442
  */
2443
  $errors = '';
2444
  if ( 0 == $reference_tests ) {
2445
  $references['tested_reference'] = false;
2446
+ $errors .= '(' . __( 'NO REFERENCE TESTS', 'media-library-assistant' ) . ')';
2447
+ } else {
 
2448
  $references['tested_reference'] = true;
2449
  $suffix = ( 4 == $reference_tests ) ? '' : '?';
2450
 
2451
+ if ( !$references['found_reference'] ) {
2452
+ $errors .= '(' . sprintf( __( 'ORPHAN', 'media-library-assistant' ) . '%1$s) ', $suffix );
2453
+ }
2454
+
2455
+ if ( !$references['found_parent'] && !empty( $references['parent_title'] ) ) {
2456
+ $errors .= '(' . sprintf( __( 'BAD PARENT', 'media-library-assistant' ) . '%1$s) ', $suffix );
2457
+ }
2458
+ }
2459
+
2460
+ if ( $references['is_unattached'] ) {
2461
+ $errors .= '(' . __( 'UNATTACHED', 'media-library-assistant' ) . ')';
2462
+ } elseif ( empty( $references['parent_title'] ) ) {
2463
+ $errors .= '(' . __( 'INVALID PARENT', 'media-library-assistant' ) . ')';
2464
  }
 
 
 
 
 
2465
 
2466
  $references['parent_errors'] = trim( $errors );
2467
+
2468
  $save_id = $ID;
2469
  return $references;
2470
  }
2471
+
2472
  /**
2473
  * Objects containing [gallery] shortcodes
2474
  *
2526
  // ignore everything else
2527
  } // switch
2528
  }
2529
+
2530
  /**
2531
  * Invalidates $mla_galleries and $galleries arrays and cached values after post, page or attachment updates
2532
  *
2540
  self::mla_flush_mla_galleries( MLAOptions::MLA_GALLERY_IN_TUNING );
2541
  self::mla_flush_mla_galleries( MLAOptions::MLA_MLA_GALLERY_IN_TUNING );
2542
  }
2543
+
2544
  /**
2545
  * Builds the $mla_galleries or $galleries array
2546
  *
2565
  }
2566
 
2567
  $option_value = MLAOptions::mla_get_option( $option_name );
2568
+ if ( 'disabled' == $option_value ) {
2569
  return false;
2570
+ } elseif ( 'cached' == $option_value ) {
2571
  $galleries_array = get_transient( MLA_OPTION_PREFIX . 't_' . $option_name );
2572
  if ( is_array( $galleries_array ) ) {
2573
  if ( ! empty( $galleries_array ) ) {
2575
  } else {
2576
  return false;
2577
  }
2578
+ } else {
 
2579
  $galleries_array = NULL;
2580
+ }
2581
  } // cached
2582
+
2583
  /*
2584
  * $galleries_array is null, so build the array
2585
  */
2586
  $galleries_array = array();
2587
+
2588
+ if ( $exclude_revisions ) {
2589
  $exclude_revisions = "(post_type <> 'revision') AND ";
2590
+ } else {
2591
  $exclude_revisions = '';
2592
+ }
2593
+
2594
  $like = like_escape( $shortcode );
2595
  $results = $wpdb->get_results(
2596
  $wpdb->prepare(
2604
  )
2605
  );
2606
 
2607
+ if ( empty( $results ) ) {
2608
  return false;
2609
+ }
2610
+
2611
  foreach ( $results as $result ) {
2612
  $count = preg_match_all( "/\\{$shortcode}([^\\]]*)\\]/", $result->post_content, $matches, PREG_PATTERN_ORDER );
2613
  if ( $count ) {
2617
  $galleries_array[ $result_id ]['results'] = array();
2618
  $galleries_array[ $result_id ]['galleries'] = array();
2619
  $instance = 0;
2620
+
2621
  foreach ( $matches[1] as $index => $match ) {
2622
  /*
2623
  * Filter out shortcodes that are not an exact match
2633
  $attachments = MLAShortcodes::mla_get_shortcode_attachments( $result_id, $galleries_array[ $result_id ]['galleries'][ $instance ]['query'] . ' where_used_query=this-is-a-where-used-query' );
2634
 
2635
  if ( is_string( $attachments ) ) {
2636
+ /* translators: 1: post_type, 2: post_title, 3: post ID, 4: query string, 5: error message */
2637
+ trigger_error( htmlentities( sprintf( __( '(%1$s) %2$s (ID %3$d) query "%4$s" failed, returning "%5$s"', 'media-library-assistant' ), $result->post_type, $result->post_title, $result->ID, $galleries_array[ $result_id ]['galleries'][ $instance ]['query'], $attachments) ), E_USER_WARNING );
2638
+ trigger_error( sprintf( __( 'mla_query_posts_search_filter not numeric, = "%1$s".', 'media-library-assistant' ), var_export( $debug_array, true ) ), E_USER_WARNING );
2639
+ } elseif ( ! empty( $attachments ) ) {
2640
  foreach ( $attachments as $attachment ) {
2641
  $galleries_array[ $result_id ]['results'][ $attachment->ID ] = $attachment->ID;
2642
  $galleries_array[ $result_id ]['galleries'][ $instance ]['results'][] = $attachment->ID;
2643
+ }
2644
+ }
2645
  } // exact match
2646
  } // foreach $match
2647
  } // if $count
2656
 
2657
  return true;
2658
  }
2659
+
2660
  /**
2661
  * Search the $mla_galleries or $galleries array
2662
  *
2677
  }
2678
  } // foreach gallery
2679
  } // !empty
2680
+
2681
  return $gallery_refs;
2682
  }
2683
+
2684
  /**
2685
  * Array of PDF indirect objects
2686
  *
2715
  if ( $match_count ) {
2716
  if ( 'n' == $matches[3] ) {
2717
  $key = ( $object_id * 1000 ) + $matches[2];
2718
+ if ( ! isset( self::$pdf_indirect_objects[ $key ] ) ) {
2719
  self::$pdf_indirect_objects[ $key ] = array( 'number' => $object_id, 'generation' => (integer) $matches[2], 'start' => (integer) $matches[1] );
2720
+ }
2721
  }
2722
+
2723
  $object_id++;
2724
  $offset += 20;
2725
+ } else {
 
2726
  break;
2727
+ }
2728
  }
2729
  }
2730
+
2731
  /**
2732
  * Parse a cross-reference table section into the array of indirect object definitions
2733
  *
2743
  $xref_max = $chunksize = 16384;
2744
  $xref_section = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
2745
  $xref_length = 0;
2746
+
2747
  while ( preg_match( '/^[\x00-\x20]*(\d+) (\d+)[\x00-\x20]*/', substr($xref_section, $xref_length), $matches, 0 ) ) {
2748
  $object_id = $matches[1];
2749
  $count = $matches[2];
2750
  $offset = $xref_length + strlen( $matches[0] );
2751
  $xref_length = $offset + ( 20 * $count );
2752
+
2753
  if ( $xref_max < $xref_length ) {
2754
  $xref_max += $chunksize;
2755
  $xref_section = file_get_contents( $file_name, true, NULL, $file_offset, $xref_max );
2756
  }
2757
+
2758
  self::_parse_pdf_xref_subsection( $xref_section, $offset, $object_id, $count );
2759
  } // while preg_match subsection header
2760
 
2761
  return $xref_length;
2762
  }
2763
+
2764
  /**
2765
  * Parse a cross-reference steam into the array of indirect object definitions
2766
  *
2779
 
2780
  if ( 'stream' == substr( $xref_section, 0, 6 ) ) {
2781
  $tag_length = 7;
2782
+ if ( chr(0x0D) == $xref_section[6] ) {
2783
  $tag_length++;
2784
+ }
2785
+ } else {
2786
  return 0;
2787
+ }
2788
+
2789
  /*
2790
  * If necessary and possible, expand the $xmp_chunk until it contains the end tag
2791
  */
2799
  } // while not found
2800
  } // if not found
2801
 
2802
+ if ( false == $end_tag ) {
2803
  $length = 0;
2804
+ } else {
2805
  $length = $end_tag - $tag_length;
2806
+ }
2807
+
2808
+ if ( false == $end_tag ) {
2809
  return 0;
2810
+ }
2811
+
2812
  return $length;
2813
+
2814
  $entry_parms = explode( ' ', $entry_parms_string );
2815
  $object_id = $matches[1];
2816
  $count = $matches[2];
2817
  $offset = strlen( $matches[0] );
2818
  $length = $offset + ( 20 * $count );
2819
+
2820
  if ( $chunksize < $length ) {
2821
  $xref_section = file_get_contents( $file_name, true, NULL, $file_offset, $length );
2822
  $offset = 0;
2823
  }
2824
+
2825
  while ( $count-- ) {
2826
  $match_count = preg_match( '/(\d+) (\d+) (.)/', $xref_section, $matches, 0, $offset);
2827
  if ( $match_count ) {
2828
  if ( 'n' == $matches[3] ) {
2829
  $key = ( $object_id * 1000 ) + $matches[2];
2830
+ if ( ! isset( self::$pdf_indirect_objects[ $key ] ) ) {
2831
  self::$pdf_indirect_objects[ $key ] = array( 'number' => $object_id, 'generation' => (integer) $matches[2], 'start' => (integer) $matches[1] );
2832
+ }
2833
  }
2834
+
2835
  $object_id++;
2836
  $offset += 20;
2837
+ } else {
 
2838
  break;
2839
+ }
2840
  }
2841
 
2842
  return $length;
2843
  }
2844
+
2845
  /**
2846
  * Build an array of indirect object definitions
2847
  *
2853
  * @return void
2854
  */
2855
  private static function _build_pdf_indirect_objects( &$string ) {
2856
+ if ( ! is_null( self::$pdf_indirect_objects ) ) {
2857
  return;
2858
+ }
2859
+
2860
  $match_count = preg_match_all( '!(\d+)\\h+(\d+)\\h+obj|endobj|stream(\x0D\x0A|\x0A)|endstream!', $string, $matches, PREG_OFFSET_CAPTURE );
2861
  self::$pdf_indirect_objects = array();
2862
  $object_level = 0;
2866
  if ( 'endstream' == substr( $matches[0][ $index ][0], 0, 9 ) ) {
2867
  $is_stream = false;
2868
  }
2869
+ } elseif ( 'endobj' == substr( $matches[0][ $index ][0], 0, 6 ) ) {
 
2870
  $object_level--;
2871
  $object_entry['/length'] = $matches[0][ $index ][1] - $object_entry['start'];
2872
  self::$pdf_indirect_objects[ ($object_entry['number'] * 1000) + $object_entry['generation'] ] = $object_entry;
2873
+ } elseif ( 'obj' == substr( $matches[0][ $index ][0], -3 ) ) {
 
2874
  $object_level++;
2875
  $object_entry = array(
2876
  'number' => $matches[1][ $index ][0],
2877
  'generation' => $matches[2][ $index ][0],
2878
  'start' => $matches[0][ $index ][1] + strlen( $matches[0][ $index ][0] )
2879
  );
2880
+ } elseif ( 'stream' == substr( $matches[0][ $index ][0], 0, 6 ) ) {
 
2881
  $is_stream = true;
2882
+ } else {
2883
+ /* translators: 1: index */
2884
+ error_log( sprintf( _x( 'ERROR: _build_pdf_indirect_objects bad value at $index = "%1$d".', 'error_log', 'media-library-assistant' ), $index ), 0 );
2885
  }
 
 
2886
  } // for each match
2887
  }
2888
+
2889
  /**
2890
  * Find the offset, length and contents of an indirect object containing a dictionary
2891
  *
2905
  $key = ( $object * 1000 ) + $generation;
2906
  if ( isset( self::$pdf_indirect_objects ) && isset( self::$pdf_indirect_objects[ $key ] ) ) {
2907
  $file_offset = self::$pdf_indirect_objects[ $key ]['start'];
2908
+ } else { // found object location
 
2909
  $file_offset = 0;
2910
+ }
2911
 
2912
  $object_starts = array();
2913
  $object_content = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
2914
+
2915
  /*
2916
  * Match the object header
2917
  */
2921
  $object_starts[] = array( 'offset' => $file_offset, 'start' => $matches[1][1]);
2922
  $match_count = 0;
2923
  }
2924
+
2925
  /*
2926
  * If necessary and possible, advance the $object_content through the file until it contains the start tag
2927
  */
2929
  $file_offset += ( $chunksize - 16 );
2930
  $object_content = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
2931
  $match_count = preg_match( $pattern, $object_content, $matches, PREG_OFFSET_CAPTURE );
2932
+
2933
  if ( $match_count ) {
2934
  $object_starts[] = array( 'offset' => $file_offset, 'start' => $matches[1][1]);
2935
  $match_count = 0;
2936
  }
2937
+
2938
  while ( 0 == $match_count && ( $chunksize == strlen( $object_content ) ) ) {
2939
  $file_offset += ( $chunksize - 16 );
2940
  $object_content = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
2941
  $match_count = preg_match( $pattern, $object_content, $matches, PREG_OFFSET_CAPTURE );
2942
+
2943
  if ( $match_count ) {
2944
  $object_starts[] = array( 'offset' => $file_offset, 'start' => $matches[1][1]);
2945
  $match_count = 0;
2946
  }
2947
  } // while not found
2948
  } // if not found
2949
+
2950
  $object_start = array_pop( $object_starts );
2951
+ if ( is_null( $object_start ) ) {
2952
  return NULL;
2953
+ } else {
2954
  $file_offset = $object_start['offset'];
2955
  $object_content = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
2956
  $start = $object_start['start'];
2957
  }
2958
+
2959
  /*
2960
  * If necessary and possible, expand the $object_content until it contains the end tag
2961
  */
2975
  } // while not found
2976
  } // if not found
2977
 
2978
+ if ( 0 == $match_count ) {
2979
  return NULL;
2980
+ }
2981
 
2982
  if ($match_count) {
2983
  $results = array( 'start' => $file_offset + $start, 'length' => ($matches[0][1] + 2) - $start );
2987
 
2988
  return NULL;
2989
  }
2990
+
2991
  /**
2992
  * Parse a ISO 8601 Timestamp
2993
  *
2998
  * @return string formatted date string YYYY-MM-DD HH:mm:SS
2999
  */
3000
  private static function _parse_iso8601_date( $source_string ) {
3001
+ if ( 1 == preg_match( '/^\\d\\d\\d\\d-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d-\\d\\d:\\d\\d/', $source_string ) ) {
3002
  return sprintf( '%1$s-%2$s-%3$s %4$s:%5$s:%6$s',
3003
  substr( $source_string, 0, 4),
3004
  substr( $source_string, 5, 2),
3006
  substr( $source_string, 11, 2),
3007
  substr( $source_string, 14, 2),
3008
  substr( $source_string, 17, 2) );
3009
+ }
3010
+
3011
+ return $source_string;
3012
  }
3013
+
3014
  /**
3015
  * Parse a PDF date string
3016
  *
3021
  * @return string formatted date string YYYY-MM-DD HH:mm:SS
3022
  */
3023
  private static function _parse_pdf_date( $source_string ) {
3024
+ if ( 'D:' == substr( $source_string, 0, 2) && ctype_digit( substr( $source_string, 2, 12 ) ) ) {
3025
  return sprintf( '%1$s-%2$s-%3$s %4$s:%5$s:%6$s',
3026
  substr( $source_string, 2, 4),
3027
  substr( $source_string, 6, 2),
3029
  substr( $source_string, 10, 2),
3030
  substr( $source_string, 12, 2),
3031
  substr( $source_string, 14, 2) );
3032
+ }
3033
+
3034
+ return $source_string;
3035
  }
3036
+
3037
  /**
3038
  * Parse a PDF Unicode (16-bit Big Endian) object
3039
  *
3047
  $output = '';
3048
  for ($index = 2; $index < strlen( $source_string ); ) {
3049
  $value = ( ord( $source_string[ $index++ ] ) << 8 ) + ord( $source_string[ $index++ ] );
3050
+ if ( $value < 0x80 ) {
3051
  $output .= chr( $value );
3052
+ } elseif ( $value < 0x100 ) {
3053
  $output .= self::$utf8_chars[ $value - 0x80 ];
3054
+ } else {
3055
  $output .= '.'; // TODO encode the rest
3056
  }
3057
  }
3058
 
3059
  return $output;
3060
  }
3061
+
3062
  /**
3063
  * Parse a PDF string object
3064
  *
3073
  * @return array ( key => array( 'type' => type, 'value' => value, '/length' => length ) ) for the string
3074
  */
3075
  private static function _parse_pdf_string( &$source_string, $offset ) {
3076
+ if ( '(' != $source_string[ $offset ] ) {
3077
  return array( 'type' => 'unknown', 'value' => '', '/length' => 0 );
3078
+ }
3079
 
3080
  /*
3081
  * Brute force, here we come...
3089
  if ( '\\' == $byte ) {
3090
  switch ( $source_string[ $index ] ) {
3091
  case chr( 0x0A ):
3092
+ if ( chr( 0x0D ) == $source_string[ $index + 1 ] ) {
3093
  $index++;
3094
+ }
3095
+
3096
  break;
3097
  case chr( 0x0D ):
3098
+ if ( chr( 0x0A ) == $source_string[ $index + 1 ] ) {
3099
  $index++;
3100
+ }
3101
+
3102
  break;
3103
  case 'n':
3104
  $output .= chr( 0x0A );
3118
  default: // could be a 1- to 3-digit octal value
3119
  $digit_limit = $index + 3;
3120
  $digit_index = $index;
3121
+ while ( $digit_index < $digit_limit ) {
3122
+ if ( ! ctype_digit( $source_string[ $digit_index ] ) ) {
3123
  break;
3124
+ } else {
3125
  $digit_index++;
3126
+ }
3127
+ }
3128
 
3129
  if ( $digit_count = $digit_index - $index ) {
3130
  $output .= chr( octdec( substr( $source_string, $index, $digit_count ) ) );
3131
  $index += $digit_count - 1;
3132
+ } else { // accept the character following the backslash
 
3133
  $output .= $source_string[ $index ];
3134
+ }
3135
  } // switch
3136
+
3137
  $index++;
3138
+ } else { // REVERSE SOLIDUS
3139
+ if ( '(' == $byte ) {
 
3140
  $level++;
3141
+ } elseif ( ')' == $byte ) {
3142
  if ( 0 == $level-- ) {
3143
  $in_string = false;
3144
  continue;
3145
  }
3146
  }
3147
+
3148
  $output .= $byte;
3149
  } // just another 8-bit value, but check for balanced parentheses
3150
  } // $in_string
3151
+
3152
  return array( 'type' => 'string', 'value' => $output, '/length' => $index - $offset );
3153
  }
3154
+
3155
  /**
3156
  * Parse a PDF Linearization Parameter Dictionary object
3157
  *
3170
  $header = substr( $source_string, 0, 1024 );
3171
  $match_count = preg_match( '!obj[\x00-\x20]*<<(/Linearized).*(>>)[\x00-\x20]*endobj!', $header, $matches, PREG_OFFSET_CAPTURE );
3172
 
3173
+ if ( $match_count ) {
3174
  $LPD = self::_parse_pdf_dictionary( $header, $matches[1][1] );
3175
+ }
3176
+
3177
  return false;
3178
  }
3179
+
3180
  /**
3181
  * Parse a PDF dictionary object
3182
  *
3195
  /*
3196
  * Find the end of the dictionary
3197
  */
3198
+ if ( '<<' == substr( $source_string, $offset, 2 ) ) {
3199
  $nest = $offset + 2;
3200
+ } else {
3201
  $nest = $offset;
3202
+ }
3203
 
3204
  $level = 1;
3205
  do {
3206
  $dictionary_end = strpos( $source_string, '>>', $nest );
3207
  if ( false === $dictionary_end ) {
3208
+ /* translators: 1: source offset 2: nest level */
3209
+ error_log( sprintf( _x( 'ERROR: _parse_pdf_dictionary offset = %1$d, nest = %2$d.', 'error_log', 'media-library-assistant' ), $offset, $nest ), 0 );
3210
+ /* translators: 1: dictionary excerpt */
3211
+ error_log( sprintf( _x( 'ERROR: _parse_pdf_dictionary no end delimiter dump = %1$s.', 'error_log', 'media-library-assistant' ), self::_hex_dump( substr( $source_string, $offset, 128 ), 128, 16 ) ), 0 );
3212
  return array( '/length' => 0 );
3213
  }
3214
+
3215
  $nest = strpos( $source_string, '<<', $nest );
3216
  if ( false === $nest ) {
3217
  $nest = $dictionary_end + 2;
3218
  $level--;
3219
+ } elseif ( $nest < $dictionary_end ) {
 
3220
  $nest += 2;
3221
  $level++;
3222
+ } else {
 
3223
  $nest = $dictionary_end + 2;
3224
  $level--;
3225
  }
3239
  /*
3240
  * Skip over false matches within a string or nested dictionary
3241
  */
3242
+ if ( $value_start < $end_data ) {
3243
  continue;
3244
+ }
3245
+
3246
  $end_data = -1;
3247
  $value_count = preg_match(
3248
  '!(\/?[^\/\x0D\x0A]*)!',
3253
  $length = strlen( $value );
3254
  $dictionary[ $name ]['value'] = $value;
3255
  if ( ! isset( $value[0] ) ) {
3256
+ /* translators: 1: entry name 2: value excerpt */
3257
+ error_log( sprintf( _x( 'ERROR: _parse_pdf_dictionary bad value [ %1$s ] dump = %2$s', 'error_log', 'media-library-assistant' ), $name, self::_hex_dump( $value, 32, 16 ) ), 0 );
3258
  continue;
3259
  }
3260
+
3261
+ if ( in_array( $value, array( 'true', 'false' ) ) ) {
3262
  $dictionary[ $name ]['type'] = 'boolean';
3263
+ } elseif ( is_numeric( $value ) ) {
3264
  $dictionary[ $name ]['type'] = 'numeric';
3265
+ } elseif ( '(' == $value[0] ) {
3266
  $dictionary[ $name ] = self::_parse_pdf_string( $source_string, $value_start );
3267
  $end_data = $value_start + $dictionary[ $name ]['/length'];
3268
  unset( $dictionary[ $name ]['/length'] );
3269
+ } elseif ( '<' == $value[0] ) {
 
3270
  if ( '<' == $value[1] ) {
3271
  $dictionary[ $name ]['value'] = self::_parse_pdf_dictionary( $source_string, $value_start );
3272
  $dictionary[ $name ]['type'] = 'dictionary';
3273
  $end_data = $value_start + 4 + $dictionary[ $name ]['value']['/length'];
3274
  unset( $dictionary[ $name ]['value']['/length'] );
3275
+ } else {
 
3276
  $dictionary[ $name ]['type'] = 'hex';
3277
+ }
3278
+ } elseif ( '/' == $value[0] ) {
3279
  $dictionary[ $name ]['value'] = substr( $value, 1 );
3280
  $dictionary[ $name ]['type'] = 'name';
3281
  $match_index++; // Skip to the next key
3282
+ } elseif ( '[' == $value[0] ) {
 
3283
  $dictionary[ $name ]['type'] = 'array';
3284
  $array_length = strpos( $source_string, ']', $value_start ) - ($value_start + 1);
3285
  $dictionary[ $name ]['value'] = substr( $source_string, $value_start + 1, $array_length );
3286
  $end_data = 2 + $value_start + $array_length;
3287
+ } elseif ( 'null' == $value ) {
 
3288
  $dictionary[ $name ]['type'] = 'null';
3289
+ } elseif ( 'stream' == substr( $value, 0, 6 ) ) {
3290
  $dictionary[ $name ]['type'] = 'stream';
3291
+ } else {
3292
  $object_count = preg_match( '!(\d+)\h+(\d+)\h+R!', $value, $object_matches );
3293
+
3294
  if ( 1 == $object_count ) {
3295
  $dictionary[ $name ]['type'] = 'indirect';
3296
  $dictionary[ $name ]['object'] = $object_matches[1];
3297
  $dictionary[ $name ]['generation'] = $object_matches[2];
3298
+ } else {
 
3299
  $dictionary[ $name ]['type'] = 'unknown';
3300
  }
3301
  }
3302
+ } else {
 
3303
  $dictionary[ $matches[1][ $match_index ][0] ] = array( 'value' => '' );
3304
  $dictionary[ $matches[1][ $match_index ][0] ]['type'] = 'nomatch';
3305
  }
3308
  $dictionary['/length'] = $dictionary_length;
3309
  return $dictionary;
3310
  }
3311
+
3312
  /**
3313
  * Parse an XMP object
3314
  *
3337
  $new_offset = $new_offset + ( $chunksize - 16 );
3338
  $xmp_chunk = file_get_contents( $file_name, true, NULL, $new_offset, $chunksize );
3339
  } // while not found
3340
+ } else { // if not found
 
3341
  $new_offset = $file_offset;
3342
+ }
3343
+
3344
+ if ( false === $start_tag ) {
3345
  return NULL;
3346
+ }
3347
+
3348
  /*
3349
  * If necessary and possible, expand the $xmp_chunk until it contains the start tag
3350
  */
3359
  } // while not found
3360
  } // if not found
3361
 
3362
+ if ( false === $end_tag ) {
3363
  return NULL;
3364
+ }
3365
 
3366
  $xmp_string = "<?xml version='1.0'?>\n" . substr($xmp_chunk, $start_tag, ( $end_tag + 12 ) - $start_tag );
3367
  $xmp_values = array();
3368
  $xml_parser = xml_parser_create('UTF-8');
3369
  if ( xml_parser_set_option( $xml_parser, XML_OPTION_SKIP_WHITE, 0 ) && xml_parser_set_option( $xml_parser, XML_OPTION_CASE_FOLDING, 0 ) ) {
3370
+ if (xml_parse_into_struct( $xml_parser, $xmp_string, $xmp_values ) == 0) {
3371
+ error_log( _x( 'ERROR: _parse_xmp_metadata xml_parse_into_struct failed.', 'error_log', 'media-library-assistant' ), 0 );
3372
+ }
3373
+ } else {
3374
+ error_log( _x( 'ERROR: _parse_xmp_metadata set option failed.', 'error_log', 'media-library-assistant' ), 0 );
3375
  }
 
 
3376
 
3377
  xml_parser_free($xml_parser);
3378
 
3379
+ if ( empty( $xmp_values ) ) {
3380
  return NULL;
3381
+ }
3382
+
3383
  $results = array();
3384
  $xmlns = array();
3385
  $array_name = '';
3388
  $language = 'x-default';
3389
  if ( isset( $value['attributes'] ) ) {
3390
  foreach ( $value['attributes'] as $att_tag => $att_value ) {
3391
+ if ( 'xmlns:' == substr( $att_tag, 0, 6 ) ) {
3392
  $xmlns[ substr( $att_tag, 6 ) ] = $att_value;
3393
+ } elseif ( 'x:xmptk' == $att_tag ) {
3394
  $results['xmptk'] = $att_value;
3395
+ } elseif ( 'xml:lang' == $att_tag ) {
3396
  $language = $att_value;
3397
+ }
3398
  }
3399
  } // attributes
3400
+
3401
  switch ( $value['tag'] ) {
3402
  case 'x:xmpmeta':
3403
  case 'rdf:RDF':
3407
  break;
3408
  case 'rdf:li':
3409
  if ( $value['type'] == 'complete' ) {
3410
+ if ( 'x-default' != $language ) {
3411
  break;
3412
+ }
3413
+
3414
  if ( ! empty ( $array_name ) ) {
3415
+ if ( isset( $value['value'] ) ) {
3416
  $results[ $array_name ][ $array_index++ ] = $value['value'];
3417
+ } else {
3418
  $results[ $array_name ][ $array_index++ ] = '';
3419
+ }
3420
  }
3421
  } // complete
3422
+
3423
  break;
3424
  case 'rdf:Seq':
3425
  case 'rdf:Bag':
3431
  case 'close':
3432
  $array_index = -1;
3433
  }
3434
+
3435
  break;
3436
  default:
3437
  switch ( $value['type'] ) {
3442
  $array_name = '';
3443
  break;
3444
  case 'complete':
3445
+ if ( isset( $value['attributes'] ) ) {
3446
  $results[ $value['tag'] ] = $value['attributes'];
3447
+ } elseif ( isset( $value['value'] ) ) {
3448
  $results[ $value['tag'] ] = $value['value'];
3449
+ } else {
3450
  $results[ $value['tag'] ] = '';
3451
+ }
3452
  } // type
3453
  } // switch tag
3454
  } // foreach value
3461
  */
3462
  $namespace_arrays = array();
3463
  foreach ( $results as $key => $value ) {
3464
+ if ( is_string( $value ) ) {
3465
  $value = self::_parse_iso8601_date( self::_parse_pdf_date( $value ) );
3466
+ }
3467
+
3468
  if ( false !== ($colon = strpos( $key, ':' ) ) ) {
3469
  $array_name = substr( $key, 0, $colon );
3470
  $array_index = substr( $key, $colon + 1 );
3471
  $namespace_arrays[ $array_name ][ $array_index ] = $value;
3472
 
3473
  if ( ! isset( $results[ $array_index ] ) && in_array( $array_name, array( 'xmp', 'xmpMM', 'xmpRights', 'xap', 'xapMM', 'dc', 'pdf', 'pdfx' ) ) ) {
3474
+ if ( is_array( $value ) && 1 == count( $value ) && isset( $value[0] ) ) {
3475
  $results[ $array_index ] = $value[0];
3476
+ } else {
3477
  $results[ $array_index ] = $value;
3478
+ }
3479
  }
3480
 
3481
  unset( $results[ $key ] );
3482
  }
3483
  }
3484
+
3485
  /*
3486
  * Try to populate all the PDF-standard keys (except Trapped)
3487
  * Title - The document's title
3494
  * ModDate - The date and time the document was most recently modified
3495
  */
3496
  if ( ! isset( $results['Title'] ) ) {
3497
+ if ( isset( $namespace_arrays['dc'] ) && isset( $namespace_arrays['dc']['title'] ) ) {
3498
  $results['Title'] = implode( ',', $namespace_arrays['dc']['title'] );
3499
+ }
3500
  }
3501
+
3502
  if ( ! isset( $results['Author'] ) ) {
3503
+ if ( isset( $namespace_arrays['dc'] ) && isset( $namespace_arrays['dc']['creator'] ) ) {
3504
  $results['Author'] = implode( ',', $namespace_arrays['dc']['creator'] );
3505
+ }
3506
  }
3507
+
3508
  if ( ! isset( $results['Subject'] ) ) {
3509
+ if ( isset( $namespace_arrays['dc'] ) && isset( $namespace_arrays['dc']['description'] ) ) {
3510
  $results['Subject'] = implode( ',', $namespace_arrays['dc']['description'] );
3511
+ }
3512
  }
3513
+
3514
  /*
3515
  * Keywords are special, since they are often assigned to taxonomy terms.
3516
  * Build or preserve an array if there are multiple values; string for single values.
3521
  if ( false !== strpos( $results['Keywords'], ';' ) ) {
3522
  $terms = array_map( 'trim', explode( ';', $results['Keywords'] ) );
3523
  foreach ( $terms as $term )
3524
+ if ( ! empty( $term ) ) {
3525
  $keywords[ $term ] = $term;
3526
+ }
3527
+ } elseif ( false !== strpos( $results['Keywords'], ',' ) ) {
3528
  $terms = array_map( 'trim', explode( ',', $results['Keywords'] ) );
3529
  foreach ( $terms as $term )
3530
+ if ( ! empty( $term ) ) {
3531
  $keywords[ $term ] = $term;
3532
+ }
3533
+ } else {
3534
  $term = trim( $results['Keywords'] );
3535
+ if ( ! empty( $term ) ) {
3536
  $keywords[ $term ] = $term;
3537
+ }
3538
  }
3539
  } // Keywords
3540
+
3541
  if ( isset( $namespace_arrays['dc'] ) && isset( $namespace_arrays['dc']['subject'] ) ) {
3542
+ if ( is_array( $namespace_arrays['dc']['subject'] ) ) {
3543
  foreach ( $namespace_arrays['dc']['subject'] as $term ) {
3544
  $term = trim( $term );
3545
+ if ( ! empty( $term ) ) {
3546
  $keywords[ $term ] = $term;
3547
+ }
3548
  }
3549
+ } elseif ( is_string( $namespace_arrays['dc']['subject'] ) ) {
3550
  $term = trim ( $namespace_arrays['dc']['subject'] );
3551
+ if ( ! empty( $term ) ) {
3552
+ $keywords[ $term ] = $term;
3553
  }
3554
+ }
3555
  } // dc:subject
3556
+
3557
  if ( ! empty( $keywords ) ) {
3558
+ if ( 1 == count( $keywords ) ) {
3559
  $results['Keywords'] = array_shift( $keywords );
3560
+ } else {
3561
  $results['Keywords'] = array();
3562
+ foreach ( $keywords as $term ) {
3563
  $results['Keywords'][] = $term;
3564
+ }
3565
  }
3566
  }
3567
+
3568
  // if ( ! isset( $results['Producer'] ) ) {
3569
  // }
3570
+
3571
  if ( ! isset( $results['Creator'] ) ) {
3572
+ if ( isset( $namespace_arrays['xmp'] ) && isset( $namespace_arrays['xmp']['CreatorTool'] ) ) {
3573
  $results['Creator'] = $namespace_arrays['xmp']['CreatorTool'];
3574
+ } elseif ( isset( $namespace_arrays['xap'] ) && isset( $namespace_arrays['xap']['CreatorTool'] ) ) {
3575
  $results['Creator'] = $namespace_arrays['xap']['CreatorTool'];
3576
+ } elseif ( ! empty( $results['Producer'] ) ) {
3577
  $results['Creator'] = $results['Producer'];
3578
+ }
3579
  }
3580
+
3581
  if ( ! isset( $results['CreationDate'] ) ) {
3582
+ if ( isset( $namespace_arrays['xmp'] ) && isset( $namespace_arrays['xmp']['CreateDate'] ) ) {
3583
  $results['CreationDate'] = $namespace_arrays['xmp']['CreateDate'];
3584
+ } elseif ( isset( $namespace_arrays['xap'] ) && isset( $namespace_arrays['xap']['CreateDate'] ) ) {
3585
  $results['CreationDate'] = $namespace_arrays['xap']['CreateDate'];
3586
+ }
3587
  }
3588
+
3589
  if ( ! isset( $results['ModDate'] ) ) {
3590
+ if ( isset( $namespace_arrays['xmp'] ) && isset( $namespace_arrays['xmp']['ModifyDate'] ) ) {
3591
  $results['ModDate'] = $namespace_arrays['xmp']['ModifyDate'];
3592
+ } elseif ( isset( $namespace_arrays['xap'] ) && isset( $namespace_arrays['xap']['ModifyDate'] ) ) {
3593
  $results['ModDate'] = $namespace_arrays['xap']['ModifyDate'];
3594
+ }
3595
  }
3596
+
3597
+ if ( ! empty( $xmlns ) ) {
3598
  $results['xmlns'] = $xmlns;
3599
+ }
3600
 
3601
  $results = array_merge( $results, $namespace_arrays );
3602
  return $results;
3603
  }
3604
+
3605
  /**
3606
  * Extract dictionary from traditional cross-reference + trailer documents
3607
  *
3616
  $chunksize = 16384;
3617
  $tail = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
3618
  $chunk_offset = 0;
3619
+
3620
  /*
3621
  * look for traditional xref and trailer
3622
  */
3629
  $tail = file_get_contents( $file_name, true, NULL, $file_offset, $chunksize );
3630
  $chunk_offset = 0;
3631
  }
3632
+
3633
  $match_count = preg_match( '/[\x00-\x20]*trailer[\x00-\x20]+/', $tail, $matches, PREG_OFFSET_CAPTURE, $chunk_offset );
3634
  if ( $match_count ) {
3635
  $chunk_offset = $matches[0][1] + strlen( $matches[0][0] );
3638
  if ( 0 < $match_count ) {
3639
  $dictionary = self::_parse_pdf_dictionary( $matches[0], 0 );
3640
 
3641
+ if ( isset( $dictionary['Prev'] ) ) {
3642
  $other_trailers = self::_extract_pdf_trailer( $file_name, $dictionary['Prev']['value'] );
3643
+ } else {
3644
  $other_trailers = NULL;
3645
+ }
3646
+
3647
  if ( is_array( $other_trailers ) ) {
3648
  $other_trailers = array_merge( $other_trailers, array( $dictionary ) );
3649
  return $other_trailers;
3650
+ } else {
 
3651
  return array( $dictionary );
3652
+ }
3653
  } // found trailer dictionary
3654
  } // found 'trailer'
3655
+ } else { // found 'xref'
 
3656
  /*
3657
  * Look for a cross-reference stream
3658
  */
3666
  /*
3667
  * Parse the cross-reference stream following the dictionary, if present
3668
  */
3669
+ if ( isset( $dictionary['Type'] ) && 'XRef' == $dictionary['Type']['value'] ) {
3670
  $xref_length = self::_parse_pdf_xref_stream( $file_name, $file_offset + $chunk_offset + (integer) $dictionary['/length'], $dictionary['W']['value'] );
3671
+ }
3672
+
3673
+ if ( isset( $dictionary['Prev'] ) ) {
3674
  $other_trailers = self::_extract_pdf_trailer( $file_name, $dictionary['Prev']['value'] );
3675
+ } else {
3676
  $other_trailers = NULL;
3677
+ }
3678
+
3679
  if ( is_array( $other_trailers ) ) {
3680
  $other_trailers = array_merge( array( $dictionary ), $other_trailers );
3681
  return $other_trailers;
3682
+ } else {
 
3683
  return array( $dictionary );
3684
+ }
3685
  } // found cross-reference stream dictionary
3686
  } // found cross-reference stream object
3687
  }
3688
 
3689
  return NULL;
3690
  }
3691
+
3692
  /**
3693
  * Extract Metadata from a PDF file
3694
  *
3702
  $metadata = array();
3703
  self::$pdf_indirect_objects = NULL;
3704
  $chunksize = 16384;
3705
+
3706
+ if ( ! file_exists( $file_name ) ) {
3707
  return $metadata;
3708
+ }
3709
 
3710
  $filesize = filesize( $file_name );
3711
  $file_offset = ( $chunksize < $filesize ) ? ( $filesize - $chunksize ) : 0;
3712
  $tail = file_get_contents( $file_name, false, NULL, $file_offset );
3713
+
3714
+ if ( 0 == $file_offset ) {
3715
  $header = substr( $tail, 0, 128 );
3716
+ } else {
3717
  $header = file_get_contents( $file_name, false, NULL, 0, 128 );
3718
+ }
3719
+
3720
  if ( '%PDF-' == substr( $header, 0, 5 ) ) {
3721
  $metadata['PDF_Version'] = substr( $header, 1, 7 );
3722
  $metadata['PDF_VersionNumber'] = substr( $header, 5, 3 );
3723
  }
3724
+
3725
  /*
3726
  * Find the xref and (optional) trailer
3727
  */
3728
  $match_count = preg_match_all( '/startxref[\x00-\x20]+(\d+)[\x00-\x20]+\%\%EOF/', $tail, $matches, PREG_OFFSET_CAPTURE );
3729
  if ( 0 == $match_count ) {
3730
+ /* translators: 1: path and file */
3731
+ error_log( sprintf( _x( 'ERROR: File "%1$s", startxref not found.', 'error_log', 'media-library-assistant' ), $path ), 0 );
3732
  return $metadata;
3733
  }
3734
+
3735
  $startxref = (integer) $matches[1][ $match_count - 1 ][0];
3736
  $trailer_dictionaries = self::_extract_pdf_trailer( $file_name, $startxref );
3737
  if ( is_array( $trailer_dictionaries ) ) {
3741
  $info_reference = $trailer_dictionary['Info'];
3742
  break;
3743
  }
3744
+
3745
  if ( isset( $info_reference ) ) {
3746
  $info_object = self::_find_pdf_indirect_dictionary( $file_name, $info_reference['object'], $info_reference['generation'] );
3747
  if ( $info_object ) {
3751
  foreach ( $info_dictionary as $name => $value ) {
3752
  if ( 'string' == $value['type'] ) {
3753
  $prefix = substr( $value['value'], 0, 2 );
3754
+ if ( 'D:' == $prefix ) {
3755
  $metadata[ $name ] = self::_parse_pdf_date( $value['value'] );
3756
+ } elseif ( ( chr(0xFE) . chr(0xFF) ) == $prefix ) {
3757
  $metadata[ $name ] = self::_parse_pdf_UTF16BE( $value['value'] );
3758
+ } else {
3759
  $metadata[ $name ] = $value['value'];
3760
+ }
3761
+ } else {
3762
  $metadata[ $name ] = $value['value'];
3763
+ }
3764
  } // each info entry
3765
  } // found Info object
3766
  } // found Info reference
3767
+
3768
  /*
3769
  * Look for XMP Metadata
3770
  */
3774
  $root_reference = $trailer_dictionary['Root'];
3775
  break;
3776
  }
3777
+
3778
  if ( isset( $root_reference ) ) {
3779
  $root_object = self::_find_pdf_indirect_dictionary( $file_name, $root_reference['object'], $root_reference['generation'] );
3780
  if ( $root_object ) {
3784
  if ( isset( $root_dictionary['Metadata'] ) ) {
3785
  $xmp_object = self::_find_pdf_indirect_dictionary( $file_name, $root_dictionary['Metadata']['object'], $root_dictionary['Metadata']['generation'] );
3786
  $xmp = self::_parse_xmp_metadata( $file_name, $xmp_object['start'] + $xmp_object['length'] );
3787
+
3788
+ if ( is_array( $xmp ) ) {
3789
  $metadata = array_merge( $metadata, $xmp );
3790
+ }
3791
  } // found Metadata reference
3792
  } // found Root object
3793
  } // found Root reference
3794
  } // found trailer_dictionaries
3795
+
3796
  return $metadata;
3797
  }
3798
+
3799
  /**
3800
  * UTF-8 replacements for invalid SQL characters
3801
  *
3832
  * @return string UTF-8 encoded string
3833
  */
3834
  private static function _bin_to_utf8( $string ) {
3835
+ if ( seems_utf8( $string ) ) {
3836
  return $string;
3837
+ }
3838
 
3839
+ if (function_exists('utf8_encode')) {
3840
  return utf8_encode( $string );
3841
  }
3842
 
3843
  $output = '';
3844
  for ($index = 0; $index < strlen( $string ); $index++ ) {
3845
  $value = ord( $string[ $index ] );
3846
+ if ( $value < 0x80 ) {
3847
  $output .= chr( $value );
3848
+ } else {
3849
  $output .= self::$utf8_chars[ $value - 0x80 ];
3850
+ }
3851
  }
3852
 
3853
  return $output;
3854
  }
3855
+
3856
  /**
3857
  * IPTC Dataset identifiers and names
3858
  *
3879
  "1#100" => "UNO",
3880
  "1#120" => "ARM Identifier",
3881
  "1#122" => "ARM Version",
3882
+
3883
  // Application Record
3884
  "2#000" => "Record Version",
3885
  "2#003" => "Object Type Reference",
3938
  "2#200" => "ObjectData Preview File Format",
3939
  "2#201" => "ObjectData Preview File Format Version",
3940
  "2#202" => "ObjectData Preview Data",
3941
+
3942
  // Pre ObjectData Descriptor Record
3943
  "7#010" => "Size Mode",
3944
  "7#020" => "Max Subfile Size",
3945
  "7#090" => "ObjectData Size Announced",
3946
  "7#095" => "Maximum ObjectData Size",
3947
+
3948
  // ObjectData Record
3949
  "8#010" => "Subfile",
3950
+
3951
  // Post ObjectData Descriptor Record
3952
  "9#010" => "Confirmed ObjectData Size"
3953
  );
4037
  'objectdata-preview-file-format' => '2#200',
4038
  'objectdata-preview-file-format-version' => '2#201',
4039
  'objectdata-preview-data' => '2#202',
4040
+
4041
  // Pre ObjectData Descriptor Record
4042
  'size-mode' => '7#010',
4043
  'max-subfile-size' => '7#020',
4044
  'objectdata-size-announced' => '7#090',
4045
  'maximum-objectdata-size' => '7#095',
4046
+
4047
  // ObjectData Record
4048
  'subfile' => '8#010',
4049
+
4050
  // Post ObjectData Descriptor Record
4051
  'confirmed-objectdata-size' => '9#010'
4052
  );
4077
  "1#100" => "14 to 80 characters of eternal, globally unique identification for objects",
4078
  "1#120" => "2 octet binary Abstract Relationship Model Identifier",
4079
  "1#122" => "2 octet binary Abstract Relationship Model Version",
4080
+
4081
  // Application Record
4082
  "2#000" => "2 octet binary Information Interchange Model, Part II version number",
4083
  "2#003" => "3 to 67 Characters of Object Type Reference number and optional text",
4136
  "2#200" => "2 octet binary file format of the ObjectData Preview",
4137
  "2#201" => "2 octet binary particular version of the ObjectData Preview File Format",
4138
  "2#202" => "Max 256000 binary octets containing the ObjectData Preview data",
4139
+
4140
  // Pre ObjectData Descriptor Record
4141
  "7#010" => "1 numeric character - 0=objectdata size not known, 1=objectdata size known at beginning of transfer",
4142
  "7#020" => "4 octet binary maximum subfile dataset(s) size",
4143
  "7#090" => "4 octet binary objectdata size if known at beginning of transfer",
4144
  "7#095" => "4 octet binary largest possible objectdata size",
4145
+
4146
  // ObjectData Record
4147
  "8#010" => "Subfile DataSet containing the objectdata itself; repeatable",
4148
+
4149
  // Post ObjectData Descriptor Record
4150
  "9#010" => "4 octet binary total objectdata size"
4151
  );
4241
  if ( is_array( $text ) ) {
4242
  foreach ($text as $key => $value )
4243
  $text[ $key ] = self::_bin_to_utf8( $value );
4244
+ } elseif ( is_string( $text ) ) {
 
4245
  $text = self::_bin_to_utf8( $text );
4246
+ }
4247
  }
4248
+
4249
  return $text;
4250
  }
4251
+
4252
  /**
4253
  * Parse one EXIF metadata field
4254
  *
4267
  $text = $item_metadata['mla_exif_metadata'][ $exif_key ];
4268
  if ( is_array( $text ) ) {
4269
  foreach ($text as $key => $value ) {
4270
+ if ( is_array( $value ) ) {
4271
  $text[ $key ] = self::_bin_to_utf8( var_export( $value, true ) );
4272
+ } else {
4273
  $text[ $key ] = self::_bin_to_utf8( $value );
4274
+ }
4275
  }
4276
+ } elseif ( is_string( $text ) ) {
 
4277
  $text = self::_bin_to_utf8( $text );
4278
+ }
4279
  } elseif ( 'ALL_EXIF' == $exif_key ) {
4280
  $clean_data = array();
4281
  foreach ( $item_metadata['mla_exif_metadata'] as $key => $value ) {
4282
+ if ( is_array( $value ) ) {
4283
  $clean_data[ $key ] = '(ARRAY)';
4284
+ } elseif ( is_string( $value ) ) {
4285
  $clean_data[ $key ] = self::_bin_to_utf8( substr( $value, 0, 256 ) );
4286
+ } else {
4287
  $clean_data[ $key ] = $value;
4288
+ }
4289
  }
4290
+
4291
  $text = var_export( $clean_data, true);
4292
  } elseif ( 'ALL_IPTC' == $exif_key ) {
4293
  $clean_data = array();
4295
  if ( is_array( $value ) ) {
4296
  foreach ($value as $text_key => $text )
4297
  $value[ $text_key ] = self::_bin_to_utf8( $text );
4298
+
4299
  $clean_data[ $key ] = 'ARRAY(' . implode( ',', $value ) . ')';
4300
+ } elseif ( is_string( $value ) ) {
 
4301
  $clean_data[ $key ] = self::_bin_to_utf8( substr( $value, 0, 256 ) );
4302
+ } else {
4303
  $clean_data[ $key ] = self::_bin_to_utf8( $value );
4304
+ }
4305
  }
4306
 
4307
  $text = var_export( $clean_data, true);
4308
  }
4309
+
4310
  return $text;
4311
  }
4312
+
4313
  /**
4314
  * Parse one PDF metadata field
4315
  *
4328
  $text = $item_metadata['mla_pdf_metadata'][ $pdf_key ];
4329
  if ( is_array( $text ) ) {
4330
  foreach ($text as $key => $value ) {
4331
+ if ( is_array( $value ) ) {
4332
  $text[ $key ] = self::_bin_to_utf8( var_export( $value, true ) );
4333
+ } else {
4334
  $text[ $key ] = self::_bin_to_utf8( $value );
4335
+ }
4336
  }
4337
+ } elseif ( is_string( $text ) ) {
 
4338
  $text = self::_bin_to_utf8( $text );
4339
+ }
4340
  } elseif ( 'ALL_PDF' == $pdf_key ) {
4341
  $clean_data = array();
4342
  foreach ( $item_metadata['mla_pdf_metadata'] as $key => $value ) {
4343
+ if ( is_array( $value ) ) {
4344
  $clean_data[ $key ] = '(ARRAY)';
4345
+ } elseif ( is_string( $value ) ) {
4346
  $clean_data[ $key ] = self::_bin_to_utf8( substr( $value, 0, 256 ) );
4347
+ } else {
4348
  $clean_data[ $key ] = $value;
4349
+ }
4350
  }
4351
+
4352
  $text = var_export( $clean_data, true);
4353
  } // ALL_PDF
4354
+
4355
  return $text;
4356
  }
4357
+
4358
  /**
4359
  * Convert an EXIF GPS rational value to a PHP float value
4360
  *
4368
  $parts = explode('/', $rational);
4369
  return $parts[0] / ( $parts[1] ? $parts[1] : 1);
4370
  }
4371
+
4372
  /**
4373
  * Fetch and filter IPTC and EXIF or PDF metadata for an image attachment
4374
  *
4387
  'mla_pdf_metadata' => array()
4388
  );
4389
 
4390
+ if ( 0 != $post_id ) {
4391
  $path = get_attached_file($post_id);
4392
+ }
4393
 
4394
  if ( ! empty( $path ) ) {
4395
  if ( 'pdf' == strtolower( pathinfo( $path, PATHINFO_EXTENSION ) ) ) {
4398
  }
4399
 
4400
  $size = getimagesize( $path, $info );
4401
+
4402
  if ( is_callable( 'iptcparse' ) ) {
4403
  if ( !empty( $info['APP13'] ) ) {
4404
  $iptc_values = iptcparse( $info['APP13'] );
4405
+ if ( ! is_array( $iptc_values ) ) {
4406
  $iptc_values = array();
4407
+ }
4408
+
4409
  foreach ( $iptc_values as $key => $value ) {
4410
  if ( in_array( $key, array( '1#000', '1#020', '1#022', '1#120', '1#122', '2#000', '2#200', '2#201' ) ) ) {
4411
  $value = unpack( 'nbinary', $value[0] );
4412
  $results['mla_iptc_metadata'][ $key ] = (string) $value['binary'];
4413
+ } elseif ( 1 == count( $value ) ) {
 
4414
  $results['mla_iptc_metadata'][ $key ] = $value[0];
4415
+ } else {
4416
  $results['mla_iptc_metadata'][ $key ] = $value;
4417
+ }
4418
  } // foreach $value
4419
  } // !empty
4420
  }
4421
+
4422
  if ( is_callable( 'exif_read_data' ) && in_array( $size[2], array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) ) ) {
4423
  $results['mla_exif_metadata'] = $exif_data = exif_read_data( $path );
4424
  }
4425
  }
4426
+
4427
  /*
4428
  * Expand EXIF GPS values
4429
  */
4431
  if ( isset( $exif_data['GPSVersion'] ) ) {
4432
  $gps_data['Version'] = sprintf( '%1$d.%2$d.%3$d.%4$d', ord( $exif_data['GPSVersion'][0] ), ord( $exif_data['GPSVersion'][1] ), ord( $exif_data['GPSVersion'][2] ), ord( $exif_data['GPSVersion'][3] ) );
4433
  }
4434
+
4435
  if ( isset( $exif_data['GPSLatitudeRef'] ) ) {
4436
  $gps_data['LatitudeRef'] = $exif_data['GPSLatitudeRef'];
4437
  $gps_data['LatitudeRefS'] = ( 'N' == $exif_data['GPSLatitudeRef'] ) ? '' : '-';
4438
  $ref = $gps_data['LatitudeRef'];
4439
  $refs = $gps_data['LatitudeRefS'];
4440
+ } else {
 
4441
  $ref = '';
4442
  $refs = '';
4443
  }
4444
+
4445
  if ( isset( $exif_data['GPSLatitude'] ) ) {
4446
  $rational = $exif_data['GPSLatitude'];
4447
  $gps_data['LatitudeD'] = $degrees = self::_rational_to_decimal( $rational[0] );
4449
  $gps_data['LatitudeS'] = sprintf( '%1$01.4f', $seconds = self::_rational_to_decimal( $rational[2] ) );
4450
  $decimal_minutes = $minutes + ( $seconds / 60 );
4451
  $decimal_degrees = ( $decimal_minutes / 60 );
4452
+
4453
  $gps_data['Latitude'] = sprintf( '%1$dd %2$d\' %3$01.4f" %4$s', $degrees, $minutes, $seconds, $ref );
4454
  $gps_data['LatitudeDM'] = sprintf( '%1$d %2$01.4f', $degrees, $decimal_minutes );
4455
  $gps_data['LatitudeDD'] = sprintf( '%1$01f', $degrees + $decimal_degrees );
4460
  $gps_data['LatitudeDM'] = $gps_data['LatitudeDM'] . $ref;
4461
  $gps_data['LatitudeDD'] = $gps_data['LatitudeDD'] . $ref;
4462
  }
4463
+
4464
  if ( isset( $exif_data['GPSLongitudeRef'] ) ) {
4465
  $gps_data['LongitudeRef'] = $exif_data['GPSLongitudeRef'];
4466
  $gps_data['LongitudeRefS'] = ( 'E' == $exif_data['GPSLongitudeRef'] ) ? '' : '-';
4467
  $ref = $gps_data['LongitudeRef'];
4468
  $refs = $gps_data['LongitudeRefS'];
4469
+ } else {
 
4470
  $ref = '';
4471
  $refs = '';
4472
  }
4473
+
4474
  if ( isset( $exif_data['GPSLongitude'] ) ) {
4475
  $rational = $exif_data['GPSLongitude'];
4476
  $gps_data['LongitudeD'] = $degrees = self::_rational_to_decimal( $rational[0] );
4478
  $gps_data['LongitudeS'] = sprintf( '%1$01.4f', $seconds = self::_rational_to_decimal( $rational[2] ) );
4479
  $decimal_minutes = $minutes + ( $seconds / 60 );
4480
  $decimal_degrees = ( $decimal_minutes / 60 );
4481
+
4482
  $gps_data['Longitude'] = sprintf( '%1$dd %2$d\' %3$01.4f" %4$s', $degrees, $minutes, $seconds, $ref );
4483
  $gps_data['LongitudeDM'] = sprintf( '%1$d %2$01.4f', $degrees, $decimal_minutes );
4484
  $gps_data['LongitudeDD'] = sprintf( '%1$01f', $degrees + $decimal_degrees );
4489
  $gps_data['LongitudeDM'] = $gps_data['LongitudeDM'] . $ref;
4490
  $gps_data['LongitudeDD'] = $gps_data['LongitudeDD'] . $ref;
4491
  }
4492
+
4493
  if ( isset( $exif_data['GPSAltitudeRef'] ) ) {
4494
  $gps_data['AltitudeRef'] = sprintf( '%1$d', ord( $exif_data['GPSAltitudeRef'][0] ) );
4495
  $gps_data['AltitudeRefS'] = ( '0' == $gps_data['AltitudeRef'] ) ? '' : '-';
4496
  $refs = $gps_data['AltitudeRefS'];
4497
+ } else {
 
4498
  $refs = '';
4499
  }
4500
 
4502
  $gps_data['Altitude'] = sprintf( '%1$s%2$01.4f', $refs, $meters = self::_rational_to_decimal( $exif_data['GPSAltitude'] ) );
4503
  $gps_data['AltitudeFeet'] = sprintf( '%1$s%2$01.2f', $refs, $meters * 3.280839895013 );
4504
  }
4505
+
4506
  if ( isset( $exif_data['GPSTimeStamp'] ) ) {
4507
  $rational = $exif_data['GPSTimeStamp'];
4508
  $gps_data['TimeStampH'] = sprintf( '%1$02d', $hours = self::_rational_to_decimal( $rational[0] ) );
4510
  $gps_data['TimeStampS'] = sprintf( '%1$02d', $seconds = self::_rational_to_decimal( $rational[2] ) );
4511
  $gps_data['TimeStamp'] = sprintf( '%1$02d:%2$02d:%3$02d', $hours, $minutes, $seconds );
4512
  }
4513
+
4514
  if ( isset( $exif_data['GPSDateStamp'] ) ) {
4515
  $parts = explode( ':', $exif_data['GPSDateStamp'] );
4516
  $gps_data['DateStampY'] = $parts[0];
4523
  $gps_data['MapDatum'] = $exif_data['GPSMapDatum'];
4524
  }
4525
 
4526
+ if ( ! empty( $gps_data ) ) {
4527
  $results['mla_exif_metadata']['GPS'] = $gps_data;
4528
+ }
4529
 
4530
  /*
4531
  * Expand EXIF array values
4540
 
4541
  return $results;
4542
  }
4543
+
4544
  /**
4545
+ * Update "meta:" data for a single attachment
4546
  *
4547
  * @since 1.51
4548
  *
4551
  *
4552
  * @return string success/failure message(s); empty string if no changes.
4553
  */
4554
+ public static function mla_update_wp_attachment_metadata( &$current_values, $new_meta ) {
4555
  $message = '';
4556
+
4557
  foreach( $new_meta as $key => $value ) {
4558
  /*
4559
  * The "Multi" option has no meaning for attachment_metadata;
4563
  unset( $value[0x80000000] );
4564
  unset( $value[0x80000001] );
4565
  unset( $value[0x80000002] );
4566
+
4567
  if ( 1 == count( $value ) ) {
4568
+ foreach ( $value as $single_key => $single_value ) {
4569
+ if ( is_integer( $single_key ) ) {
4570
  $value = $single_value;
4571
+ }
4572
+ }
4573
  } // one-element array
4574
  } // Multi-key value
4575
+
4576
  $old_value = self::mla_find_array_element( $key, $current_values, 'array' );
4577
  if ( ! empty( $old_value ) ) {
4578
  if ( empty( $value ) ) {
4579
+ if ( self::_unset_array_element( $key, $current_values ) ) {
4580
+ /* translators: 1: meta_key */
4581
+ $message .= sprintf( __( 'Deleting meta:%1$s', 'media-library-assistant' ) . '<br>', $key );
4582
+ } else {
4583
+ /* translators: 1: meta_key */
4584
+ $message .= sprintf( __( 'ERROR: meta:%1$s not found', 'media-library-assistant' ) . '<br>', $key );
4585
+ }
4586
+
4587
  continue;
4588
  }
4589
+ } else { // old_value present
 
4590
  if ( ! empty( $value ) ) {
4591
+ if ( self::_set_array_element( $key, $value, $current_values ) ) {
4592
+ /* translators: 1: meta_key 2: meta_value */
4593
+ $message .= sprintf( __( 'Adding meta:%1$s = %2$s', 'media-library-assistant' ) . '<br>', $key,
4594
  ( is_array( $value ) ) ? var_export( $value, true ) : $value );
4595
+ } else {
4596
+ /* translators: 1: meta_key */
4597
+ $message .= sprintf( __( 'ERROR: Adding meta:%1$s; not found', 'media-library-assistant' ) . '<br>', $key );
4598
+ }
4599
 
4600
  continue;
4601
+ } elseif ( NULL == $value ) {
4602
+ if ( self::_unset_array_element( $key, $current_values ) ) {
4603
+ /* translators: 1: meta_key */
4604
+ $message .= sprintf( __( 'Deleting Null meta:%1$s', 'media-library-assistant' ) . '<br>', $key );
4605
+ }
4606
+
4607
  continue;
4608
  }
4609
  } // old_value empty
4610
+
4611
  if ( $old_value != $value ) {
4612
+ if ( self::_set_array_element( $key, $value, $current_values ) ) {
4613
+ /* translators: 1: element name 2: old_value 3: new_value */
4614
+ $message .= sprintf( __( 'Changing %1$s from "%2$s" to "%3$s"', 'media-library-assistant' ) . '<br>', 'meta:' . $key,
4615
+ ( is_array( $old_value ) ) ? var_export( $old_value, true ) : $old_value,
4616
+ ( is_array( $value ) ) ? var_export( $value, true ) : $value );
4617
+ } else {
4618
+ /* translators: 1: meta_key */
4619
+ $message .= sprintf( __( 'ERROR: Changing meta:%1$s; not found', 'media-library-assistant' ) . '<br>', $key );
4620
+ }
4621
  }
4622
  } // foreach new_meta
4623
+
4624
  return $message;
4625
  }
4626
+
4627
  /**
4628
  * Update custom field and "meta:" data for a single attachment
4629
  *
4645
  $attachment_meta_values[ $meta_key ] = $meta_value;
4646
  continue;
4647
  }
4648
+
4649
+ if ( $multi_key = isset( $meta_value[0x80000000] ) ) {
4650
  unset( $meta_value[0x80000000] );
4651
+ }
4652
+
4653
  if ( $keep_existing = isset( $meta_value[0x80000001] ) ) {
4654
  $keep_existing = (boolean) $meta_value[0x80000001];
4655
  unset( $meta_value[0x80000001] );
4656
  }
4657
+
4658
  if ( $no_null = isset( $meta_value[0x80000002] ) ) {
4659
  $no_null = (boolean) $meta_value[0x80000002];
4660
  unset( $meta_value[0x80000002] );
4661
  }
4662
+
4663
  if ( isset( $post_data[ 'mla_item_' . $meta_key ] ) ) {
4664
  $old_meta_value = $post_data[ 'mla_item_' . $meta_key ];
4665
+
4666
  if ( $multi_key && $no_null ) {
4667
+ if ( is_string( $old_meta_value ) ) {
4668
  $old_meta_value = trim( $old_meta_value );
4669
+ }
4670
+
4671
  $delete = empty( $old_meta_value );
4672
+ } else {
 
4673
  $delete = NULL == $meta_value;
4674
+ }
4675
+
4676
  if ( $delete) {
4677
+ if ( delete_post_meta( $post_id, $meta_key ) ) {
4678
+ /* translators: 1: meta_key */
4679
+ $message .= sprintf( __( 'Deleting %1$s', 'media-library-assistant' ) . '<br>', $meta_key );
4680
+ }
4681
+
4682
  continue;
4683
  }
4684
+ } else {
 
4685
  if ( NULL != $meta_value ) {
4686
+ if ( $multi_key ) {
4687
  foreach ( $meta_value as $new_value ) {
4688
+ if ( add_post_meta( $post_id, $meta_key, $new_value ) ) {
4689
+ /* translators: 1: meta_key 2: new_value */
4690
+ $message .= sprintf( __( 'Adding %1$s = [%2$s]', 'media-library-assistant' ) . '<br>', $meta_key, $new_value );
4691
+ }
4692
+ }
4693
+ } else {
4694
+ if ( add_post_meta( $post_id, $meta_key, $meta_value ) ) {
4695
+ /* translators: 1: meta_key 2: meta_value */
4696
+ $message .= sprintf( __( 'Adding %1$s = %2$s', 'media-library-assistant' ) . '<br>', $meta_key, $meta_value );
4697
  }
4698
+ }
 
 
4699
  }
4700
 
4701
  continue; // no change or message if old and new are both NULL
4702
  } // no old value
4703
+
4704
  $old_text = ( is_array( $old_meta_value ) ) ? var_export( $old_meta_value, true ) : $old_meta_value;
4705
 
4706
  /*
4710
  /*
4711
  * Test for "no changes"
4712
  */
4713
+ if ( $meta_value == (array) $old_meta_value ) {
4714
  continue;
4715
+ }
4716
+
4717
  if ( ! $keep_existing ) {
4718
+ if ( delete_post_meta( $post_id, $meta_key ) ) {
4719
+ /* translators: 1: meta_key */
4720
+ $message .= sprintf( __( 'Deleting old %1$s values', 'media-library-assistant' ) . '<br>', $meta_key );
4721
+ }
4722
+
4723
  $old_meta_value = array();
4724
+ } elseif ( $old_text == $old_meta_value ) { // single value
 
4725
  $old_meta_value = array( $old_meta_value );
4726
+ }
4727
 
4728
  $updated = 0;
4729
  foreach ( $meta_value as $new_value ) {
4733
  $updated++;
4734
  }
4735
  }
4736
+
4737
  if ( $updated ) {
4738
  $meta_value = get_post_meta( $post_id, $meta_key );
4739
+ if ( is_array( $meta_value ) ) {
4740
+ if ( 1 == count( $meta_value ) ) {
4741
  $new_text = $meta_value[0];
4742
+ } else {
4743
  $new_text = var_export( $meta_value, true );
4744
+ }
4745
+ } else {
4746
  $new_text = $meta_value;
4747
+ }
4748
+
4749
+ /* translators: 1: meta_key 2: old_value 3: new_value 4: update count*/
4750
+ $message .= sprintf( __( 'Changing %1$s from "%2$s" to "%3$s"; %4$d updates', 'media-library-assistant' ) . '<br>', 'meta:' . $meta_key, $old_text, $new_text, $updated );
4751
  }
4752
+ } elseif ( $old_meta_value != $meta_value ) {
4753
+ if ( is_array( $old_meta_value ) ) {
 
4754
  delete_post_meta( $post_id, $meta_key );
4755
+ }
4756
 
4757
+ if ( is_array( $meta_value ) ) {
4758
  $new_text = var_export( $meta_value, true );
4759
+ } else {
4760
  $new_text = $meta_value;
4761
+ }
4762
+
4763
+ if ( update_post_meta( $post_id, $meta_key, $meta_value ) ) {
4764
+ /* translators: 1: element name 2: old_value 3: new_value */
4765
+ $message .= sprintf( __( 'Changing %1$s from "%2$s" to "%3$s"', 'media-library-assistant' ) . '<br>', 'meta:' . $meta_key, $old_text, $new_text );
4766
+ }
4767
  }
4768
  } // foreach $new_meta
4769
+
4770
  /*
4771
  * Process the "meta:" updates, if any
4772
  */
4773
  if ( ! empty( $attachment_meta_values ) ) {
4774
+ if ( isset( $post_data['mla_wp_attachment_metadata'] ) ) {
4775
  $current_values = $post_data['mla_wp_attachment_metadata'];
4776
+ } else {
4777
  $current_values = array();
4778
+ }
4779
+
4780
+ $results = self::mla_update_wp_attachment_metadata( $current_values, $attachment_meta_values );
4781
  if ( ! empty( $results ) ) {
4782
+ if ( update_post_meta( $post_id, '_wp_attachment_metadata', $current_values ) ) {
4783
  $message .= $results;
4784
+ }
4785
  }
4786
  }
4787
+
4788
  return $message;
4789
  }
4790
+
4791
  /**
4792
  * Update a single item; change the "post" data, taxonomy terms
4793
  * and meta data for a single attachment
4803
  */
4804
  public static function mla_update_single_item( $post_id, $new_data, $tax_input = NULL, $tax_actions = NULL ) {
4805
  $post_data = self::mla_get_attachment_by_id( $post_id );
4806
+ if ( !isset( $post_data ) ) {
4807
  return array(
4808
+ 'message' => __( 'ERROR: Could not retrieve Attachment.', 'media-library-assistant' ),
4809
  'body' => ''
4810
  );
4811
+ }
4812
+
4813
  $message = '';
4814
  $updates = array( 'ID' => $post_id );
4815
  $new_data = stripslashes_deep( $new_data );
4818
  foreach ( $new_data as $key => $value ) {
4819
  switch ( $key ) {
4820
  case 'post_title':
4821
+ if ( $value == $post_data[ $key ] ) {
4822
  break;
4823
+ }
4824
+
4825
+ /* translators: 1: element name 2: old_value 3: new_value */
4826
+ $message .= sprintf( __( 'Changing %1$s from "%2$s" to "%3$s"', 'media-library-assistant' ) . '<br>', __( 'Title', 'media-library-assistant' ), esc_attr( $post_data[ $key ] ), esc_attr( $value ) );
4827
  $updates[ $key ] = $value;
4828
  break;
4829
  case 'post_name':
4830
+ if ( $value == $post_data[ $key ] ) {
4831
  break;
4832
+ }
4833
+
4834
  $value = sanitize_title( $value );
4835
+
4836
  /*
4837
  * Make sure new slug is unique
4838
  */
4843
  'showposts' => 1
4844
  );
4845
  $my_posts = get_posts( $args );
4846
+
4847
  if ( $my_posts ) {
4848
+ /* translators: 1: old_value */
4849
+ $message .= sprintf( __( 'ERROR: Could not change Name/Slug "%1$s"; name already exists', 'media-library-assistant' ) . '<br>', $value );
4850
  } else {
4851
+ /* translators: 1: element name 2: old_value 3: new_value */
4852
+ $message .= sprintf( __( 'Changing %1$s from "%2$s" to "%3$s"', 'media-library-assistant' ) . '<br>', __( 'Name/Slug', 'media-library-assistant' ), esc_attr( $post_data[ $key ] ), esc_attr( $value ) );
4853
  $updates[ $key ] = $value;
4854
  }
4855
  break;
4856
  case 'image_alt':
4857
  $key = 'mla_wp_attachment_image_alt';
4858
+ if ( !isset( $post_data[ $key ] ) ) {
4859
  $post_data[ $key ] = '';
4860
+ }
4861
+
4862
+ if ( $value == $post_data[ $key ] ) {
4863
  break;
4864
+ }
4865
+
4866
  if ( empty( $value ) ) {
4867
+ if ( delete_post_meta( $post_id, '_wp_attachment_image_alt', $value ) ) {
4868
+ /* translators: 1: old_value */
4869
+ $message .= sprintf( __( 'Deleting ALT Text, was "%1$s"', 'media-library-assistant' ) . '<br>', esc_attr( $post_data[ $key ] ) );
4870
+ } else {
4871
+ /* translators: 1: old_value */
4872
+ $message .= sprintf( __( 'ERROR: Could not delete ALT Text, remains "%1$s"', 'media-library-assistant' ) . '<br>', esc_attr( $post_data[ $key ] ) );
4873
+ }
4874
  } else {
4875
+ if ( update_post_meta( $post_id, '_wp_attachment_image_alt', $value ) ) {
4876
+ /* translators: 1: element name 2: old_value 3: new_value */
4877
+ $message .= sprintf( __( 'Changing %1$s from "%2$s" to "%3$s"', 'media-library-assistant' ) . '<br>', __( 'ALT Text', 'media-library-assistant' ), esc_attr( $post_data[ $key ] ), esc_attr( $value ) );
4878
+ } else {
4879
+ /* translators: 1: old_value 2: new_value */
4880
+ $message .= sprintf( __( 'ERROR: Could not change ALT Text from "%1$s" to "%2$s"', 'media-library-assistant' ) . '<br>', esc_attr( $post_data[ $key ] ), esc_attr( $value ) );
4881
+ }
4882
  }
4883
  break;
4884
  case 'post_excerpt':
4885
+ if ( $value == $post_data[ $key ] ) {
4886
  break;
4887
+ }
4888
+
4889
+ /* translators: 1: element name 2: old_value 3: new_value */
4890
+ $message .= sprintf( __( 'Changing %1$s from "%2$s" to "%3$s"', 'media-library-assistant' ) . '<br>', __( 'Caption', 'media-library-assistant' ), esc_attr( $post_data[ $key ] ), esc_attr( $value ) );
4891
  $updates[ $key ] = $value;
4892
  break;
4893
  case 'post_content':
4894
+ if ( $value == $post_data[ $key ] ) {
4895
  break;
4896
+ }
4897
+
4898
+ /* translators: 1: element name 2: old_value 3: new_value */
4899
+ $message .= sprintf( __( 'Changing %1$s from "%2$s" to "%3$s"', 'media-library-assistant' ) . '<br>', __( 'Description', 'media-library-assistant' ), esc_textarea( $post_data[ $key ] ), esc_textarea( $value ) );
4900
  $updates[ $key ] = $value;
4901
  break;
4902
  case 'post_parent':
4903
+ if ( $value == $post_data[ $key ] ) {
4904
  break;
4905
+ }
4906
+
4907
  $value = absint( $value );
4908
+
4909
+ /* translators: 1: element name 2: old_value 3: new_value */
4910
+ $message .= sprintf( __( 'Changing %1$s from "%2$s" to "%3$s"', 'media-library-assistant' ) . '<br>', __( 'Parent', 'media-library-assistant' ), $post_data[ $key ], $value );
4911
  $updates[ $key ] = $value;
4912
  break;
4913
  case 'menu_order':
4914
+ if ( $value == $post_data[ $key ] ) {
4915
  break;
4916
+ }
4917
+
4918
  $value = absint( $value );
4919
+
4920
+ /* translators: 1: element name 2: old_value 3: new_value */
4921
+ $message .= sprintf( __( 'Changing %1$s from "%2$s" to "%3$s"', 'media-library-assistant' ) . '<br>', __( 'Menu Order', 'media-library-assistant' ), $post_data[ $key ], $value );
4922
  $updates[ $key ] = $value;
4923
  break;
4924
  case 'post_author':
4925
+ if ( $value == $post_data[ $key ] ) {
4926
  break;
4927
+ }
4928
+
4929
  $value = absint( $value );
4930
+
4931
  $from_user = get_userdata( $post_data[ $key ] );
4932
  $to_user = get_userdata( $value );
4933
+ /* translators: 1: element name 2: old_value 3: new_value */
4934
+ $message .= sprintf( __( 'Changing %1$s from "%2$s" to "%3$s"', 'media-library-assistant' ) . '<br>', __( 'Author', 'media-library-assistant' ), $from_user->display_name, $to_user->display_name );
4935
  $updates[ $key ] = $value;
4936
  break;
4937
  case 'taxonomy_updates':
4945
  // Ignore anything else
4946
  } // switch $key
4947
  } // foreach $new_data
4948
+
4949
  if ( !empty( $tax_input ) ) {
4950
  foreach ( $tax_input as $taxonomy => $tags ) {
4951
+ if ( !empty( $tax_actions ) ) {
4952
  $tax_action = $tax_actions[ $taxonomy ];
4953
+ } else {
4954
  $tax_action = 'replace';
4955
+ }
4956
+
4957
  $taxonomy_obj = get_taxonomy( $taxonomy );
4958
 
4959
  if ( current_user_can( $taxonomy_obj->cap->assign_terms ) ) {
4962
  ) );
4963
  if ( is_array( $tags ) ) // array = hierarchical, string = non-hierarchical.
4964
  $tags = array_filter( $tags );
4965
+
4966
  switch ( $tax_action ) {
4967
  case 'add':
4968
+ $action_name = __( 'Adding', 'media-library-assistant' );
4969
  $result = wp_set_post_terms( $post_id, $tags, $taxonomy, true );
4970
  break;
4971
  case 'remove':
4972
+ $action_name = __( 'Removing', 'media-library-assistant' );
4973
  $tags = self::_remove_tags( $terms_before, $tags, $taxonomy_obj );
4974
  $result = wp_set_post_terms( $post_id, $tags, $taxonomy );
4975
  break;
4976
  case 'replace':
4977
+ $action_name = __( 'Replacing', 'media-library-assistant' );
4978
  $result = wp_set_post_terms( $post_id, $tags, $taxonomy );
4979
  break;
4980
  default:
4981
+ $action_name = __( 'Ignoring', 'media-library-assistant' );
4982
  $result = NULL;
4983
  // ignore anything else
4984
  }
4985
+
4986
  $terms_after = wp_get_post_terms( $post_id, $taxonomy, array(
4987
  'fields' => 'ids' // all'
4988
  ) );
4989
+
4990
+ if ( $terms_before != $terms_after ) {
4991
+ /* translators: 1: action_name, 2: taxonomy */
4992
+ $message .= sprintf( __( '%1$s "%2$s" terms', 'media-library-assistant' ) . '<br>', $action_name, $taxonomy );
4993
+ }
4994
+ } else { // current_user_can
4995
+ /* translators: 1: taxonomy */
4996
+ $message .= sprintf( __( 'You cannot assign "%1$s" terms', 'media-library-assistant' ) . '<br>', $taxonomy );
4997
  }
4998
  } // foreach $tax_input
4999
  } // !empty $tax_input
5000
+
5001
+ if ( is_array( $new_meta ) ) {
5002
  $message .= self::mla_update_item_postmeta( $post_id, $new_meta );
5003
+ }
5004
+
5005
+ if ( empty( $message ) ) {
5006
  return array(
5007
+ /* translators: 1: post ID */
5008
+ 'message' => sprintf( __( 'Item %1$d, no changes detected.', 'media-library-assistant' ), $post_id ),
5009
  'body' => ''
5010
  );
5011
+ } else {
5012
  self::mla_get_attachment_by_id( -1 ); // invalidate the cached item
5013
 
5014
  if ( wp_update_post( $updates ) ) {
5015
+ /* translators: 1: post ID */
5016
+ $final_message = sprintf( __( 'Item %1$d updated.', 'media-library-assistant' ), $post_id );
5017
  /*
5018
  * Uncomment this for debugging.
5019
  */
5020
  // $final_message .= '<br>' . $message;
5021
  // error_log( 'DEBUG: message = ' . var_export( $message, true ), 0 );
5022
+
5023
  return array(
5024
  'message' => $final_message,
5025
  'body' => ''
5026
  );
5027
+ } else {
 
5028
  return array(
5029
+ /* translators: 1: post ID */
5030
+ 'message' => sprintf( __( 'ERROR: Item %1$d update failed.', 'media-library-assistant' ), $post_id ),
5031
  'body' => ''
5032
  );
5033
+ }
5034
  }
5035
  }
5036
+
5037
  /**
5038
  * Remove tags from a term ids list
5039
  *
5050
  /*
5051
  * Convert names to term ids
5052
  */
5053
+ $comma = _x( ',', 'tag_delimiter', 'media-library-assistant' );
5054
+ if ( ',' !== $comma ) {
5055
  $tags = str_replace( $comma, ',', $tags );
5056
+ }
5057
+
5058
  $terms = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) );
5059
 
5060
  $tags = array();
5061
  foreach ( (array) $terms as $term) {
5062
+ if ( !strlen(trim($term)) ) {
5063
  continue;
5064
+ }
5065
 
5066
  // Skip if a non-existent term name is passed.
5067
+ if ( ! $term_info = term_exists($term, $taxonomy_obj->name ) ) {
5068
  continue;
5069
+ }
5070
 
5071
+ if ( is_wp_error($term_info) ) {
5072
  continue;
5073
+ }
5074
 
5075
  $tags[] = $term_info['term_id'];
5076
  } // foreach term
5077
  } // not an array
5078
+
5079
  $tags = array_map( 'intval', $tags );
5080
  $tags = array_unique( $tags );
5081
  $terms_after = array_diff( array_map( 'intval', $terms_before ), $tags );
5082
  return $terms_after;
5083
  }
5084
+
5085
  /**
5086
  * Format printable version of binary data
5087
  *
5094
  *
5095
  * @return string Printable representation of $data
5096
  */
5097
+ public static function _hex_dump( $data, $limit = 0, $bytes_per_row = 16, $offset = -1 ) {
5098
+ if ( 0 == $limit ) {
5099
  $limit = strlen( $data );
5100
+ }
5101
+
5102
  $position = 0;
5103
  $output = "\r\n";
5104
  $print_offset = ( 0 <= $offset );
5105
+
5106
+ if ( $print_offset ) {
5107
  $print_length = $bytes_per_row += 5;
5108
+ } else {
5109
  $print_length = $bytes_per_row;
5110
+ }
5111
+
5112
  while ( $position < $limit ) {
5113
  $row_length = strlen( substr( $data, $position ) );
5114
+
5115
+ if ( 0 == $row_length ) {
5116
  break;
5117
+ }
5118
+
5119
+ if ( $row_length > ( $limit - $position ) ) {
5120
  $row_length = $limit - $position;
5121
+ }
5122
 
5123
+ if ( $row_length > $bytes_per_row ) {
5124
  $row_length = $bytes_per_row;
5125
+ }
5126
 
5127
  $row_data = substr( $data, $position, $row_length );
5128
+
5129
  if ( $print_offset ) {
5130
  $print_string = sprintf( '%04X ', $position + $offset );
5131
+ } else {
 
5132
  $print_string = '';
5133
+ }
5134
+
5135
  $hex_string = '';
5136
  for ( $index = 0; $index < $row_length; $index++ ) {
5137
  $char = ord( substr( $row_data, $index, 1 ) );
5138
+ if ( ( 31 < $char ) && ( 127 > $char ) ) {
5139
  $print_string .= chr($char);
5140
+ } else {
5141
  $print_string .= '.';
5142
+ }
5143
+
5144
  $hex_string .= ' ' . bin2hex( chr($char) );
5145
  } // for
5146
+
5147
  $output .= str_pad( $print_string, $print_length, ' ', STR_PAD_RIGHT ) . $hex_string . "\r\n";
5148
  $position += $row_length;
5149
  } // while
5150
+
5151
  return $output;
5152
  }
5153
  } // class MLAData
includes/class-mla-edit-media.php CHANGED
@@ -27,7 +27,7 @@ class MLAEdit {
27
  */
28
  if ( MLATest::$wordpress_3point5_plus ) {
29
  add_action( 'admin_init', 'MLAEdit::mla_admin_init_action' );
30
-
31
  add_action( 'add_meta_boxes', 'MLAEdit::mla_add_meta_boxes_action', 10, 2 );
32
 
33
  // apply_filters( 'post_updated_messages', $messages ) in wp-admin/edit-form-advanced.php
@@ -35,10 +35,10 @@ class MLAEdit {
35
 
36
  // do_action in wp-admin/includes/meta-boxes.php function attachment_submit_meta_box
37
  add_action( 'attachment_submitbox_misc_actions', 'MLAEdit::mla_attachment_submitbox_action' );
38
-
39
  // do_action in wp-includes/post.php function wp_insert_post
40
  add_action( 'edit_attachment', 'MLAEdit::mla_edit_attachment_action', 10, 1 );
41
-
42
  // apply_filters( 'admin_title', $admin_title, $title ) in /wp-admin/admin-header.php
43
  add_filter( 'admin_title', 'MLAEdit::mla_edit_add_help_tab', 10, 2 );
44
  } // $wordpress_3point5_plus
@@ -54,7 +54,7 @@ class MLAEdit {
54
  */
55
  public static function mla_admin_init_action( ) {
56
  static $mc_att_category_metabox = array();
57
-
58
  /*
59
  * Enable the enhanced "Media Categories" searchable metaboxes for hiearchical taxonomies
60
  */
@@ -66,12 +66,13 @@ class MLAEdit {
66
  foreach ( $taxonomies as $key => $value ) {
67
  if ( MLAOptions::mla_taxonomy_support( $key ) ) {
68
  if ( $value->hierarchical ) {
69
- if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_DETAILS_CATEGORY_METABOX ) )
70
  $mc_att_category_metabox[] = new Media_Categories( $key );
71
- } // hierarchical
72
- else {
73
- if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_DETAILS_TAG_METABOX ) )
74
  $mc_att_category_metabox[] = new Media_Categories( $key );
 
75
  } // flat
76
  } // is supported
77
  } // foreach
@@ -92,10 +93,10 @@ class MLAEdit {
92
  */
93
  public static function mla_post_updated_messages_filter( $messages ) {
94
  if ( isset( $messages['attachment'] ) ) {
95
- $messages['attachment'][101] = 'Custom Field mapping updated.';
96
- $messages['attachment'][102] = 'IPTC/EXIF mapping updated.';
97
  }
98
-
99
  return $messages;
100
  } // mla_post_updated_messages_filter
101
 
@@ -110,25 +111,28 @@ class MLAEdit {
110
  public static function mla_attachment_submitbox_action( ) {
111
  global $post;
112
 
113
- $datef = __( 'M j, Y @ G:i' );
114
- $stamp = __('Last modified: <b>%1$s</b>');
115
- $date = date_i18n( $datef, strtotime( $post->post_modified ) );
116
  echo '<div class="misc-pub-section curtime">' . "\r\n";
117
- echo '<span id="timestamp">' . sprintf($stamp, $date) . "</span>\r\n";
118
  echo "</div><!-- .misc-pub-section -->\r\n";
119
  echo '<div class="misc-pub-section mla-links">' . "\r\n";
120
-
121
  $view_args = array( 'page' => MLA::ADMIN_PAGE_SLUG, 'mla_item_ID' => $post->ID );
122
- if ( isset( $_REQUEST['mla_source'] ) )
123
  $view_args['mla_source'] = $_REQUEST['mla_source'];
124
-
 
125
  echo '<span id="mla_metadata_links" style="font-weight: bold; line-height: 2em">';
126
- echo '<a href="' . add_query_arg( $view_args, wp_nonce_url( 'upload.php?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_CUSTOM_FIELD_MAP, MLA::MLA_ADMIN_NONCE ) ) . '" title="Map Custom Field metadata for this item">Map Custom Field Metadata</a><br>';
127
- echo '<a href="' . add_query_arg( $view_args, wp_nonce_url( 'upload.php?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_MAP, MLA::MLA_ADMIN_NONCE ) ) . '" title="Map IPTC/EXIF metadata for this item">Map IPTC/EXIF Metadata</a>';
 
 
 
128
  echo "</span>\r\n";
129
  echo "</div><!-- .misc-pub-section -->\r\n";
130
  } // mla_attachment_submitbox_action
131
-
132
  /**
133
  * Registers meta boxes for the Edit Media screen.
134
  * Declared public because it is an action.
@@ -144,28 +148,37 @@ class MLAEdit {
144
  /*
145
  * Plugins call this action with varying numbers of arguments!
146
  */
147
- if ( NULL == $post )
148
  $post = (object) array ( 'ID' => 0 );
149
-
 
150
  if ( 'attachment' == $post_type ) {
151
- add_meta_box( 'mla-parent-info', 'Parent Info', 'MLAEdit::mla_parent_info_handler', 'attachment', 'normal', 'core' );
152
- add_meta_box( 'mla-menu-order', 'Menu Order', 'MLAEdit::mla_menu_order_handler', 'attachment', 'normal', 'core' );
153
-
154
  $image_metadata = get_metadata( 'post', $post->ID, '_wp_attachment_metadata', true );
155
- if ( !empty( $image_metadata ) )
156
- add_meta_box( 'mla-image-metadata', 'Attachment Metadata', 'MLAEdit::mla_image_metadata_handler', 'attachment', 'normal', 'core' );
157
-
158
- if ( MLAOptions::$process_featured_in )
159
- add_meta_box( 'mla-featured-in', 'Featured in', 'MLAEdit::mla_featured_in_handler', 'attachment', 'normal', 'core' );
160
- if ( MLAOptions::$process_inserted_in )
161
- add_meta_box( 'mla-inserted-in', 'Inserted in', 'MLAEdit::mla_inserted_in_handler', 'attachment', 'normal', 'core' );
162
- if ( MLAOptions::$process_gallery_in )
163
- add_meta_box( 'mla-gallery-in', 'Gallery in', 'MLAEdit::mla_gallery_in_handler', 'attachment', 'normal', 'core' );
164
- if ( MLAOptions::$process_mla_gallery_in )
165
- add_meta_box( 'mla-mla-gallery-in', 'MLA Gallery in', 'MLAEdit::mla_mla_gallery_in_handler', 'attachment', 'normal', 'core' );
 
 
 
 
 
 
 
 
166
  } // 'attachment'
167
  } // mla_add_meta_boxes_action
168
-
169
  /**
170
  * Add contextual help tabs to the WordPress Edit Media page
171
  *
@@ -179,22 +192,23 @@ class MLAEdit {
179
  public static function mla_edit_add_help_tab( $admin_title, $title ) {
180
  $screen = get_current_screen();
181
 
182
- if ( ( 'attachment' != $screen->id ) || ( 'attachment' != $screen->post_type ) || ( 'post' != $screen->base ) )
183
  return $admin_title;
184
-
185
- $template_array = MLAData::mla_load_template( MLA_PLUGIN_PATH . 'tpls/help-for-edit_attachment.tpl' );
 
186
  if ( empty( $template_array ) ) {
187
  return $admin_title;
188
  }
189
-
190
  /*
191
  * Provide explicit control over tab order
192
  */
193
  $tab_array = array();
194
-
195
  foreach ( $template_array as $id => $content ) {
196
  $match_count = preg_match( '#\<!-- title="(.+)" order="(.+)" --\>#', $content, $matches, PREG_OFFSET_CAPTURE );
197
-
198
  if ( $match_count > 0 ) {
199
  $tab_array[ $matches[ 2 ][ 0 ] ] = array(
200
  'id' => $id,
@@ -202,10 +216,11 @@ class MLAEdit {
202
  'content' => $content
203
  );
204
  } else {
205
- error_log( 'ERROR: mla_edit_add_help_tab discarding '.var_export( $id, true ), 0 );
 
206
  }
207
  }
208
-
209
  ksort( $tab_array, SORT_NUMERIC );
210
  foreach ( $tab_array as $indx => $value ) {
211
  $screen->add_help_tab( $value );
@@ -213,7 +228,7 @@ class MLAEdit {
213
 
214
  return $admin_title;
215
  }
216
-
217
  /**
218
  * Where-used values for the current item
219
  *
@@ -237,20 +252,22 @@ class MLAEdit {
237
  * @return void echoes the HTML markup for the meta box content
238
  */
239
  public static function mla_parent_info_handler( $post ) {
240
- if ( is_null( self::$mla_references ) )
241
  self::$mla_references = MLAData::mla_fetch_attachment_references( $post->ID, $post->post_parent );
242
-
 
243
  if ( is_array( self::$mla_references ) ) {
244
- if ( empty(self::$mla_references['parent_title'] ) )
245
  $parent_info = self::$mla_references['parent_errors'];
246
- else
247
  $parent_info = sprintf( '(%1$s) %2$s %3$s', self::$mla_references['parent_type'], self::$mla_references['parent_title'], self::$mla_references['parent_errors'] );
 
248
  } // is_array
249
 
250
- echo '<label class="screen-reader-text" for="mla_post_parent">Post Parent</label><input name="mla_post_parent" type="text" size="4" id="mla_post_parent" value="' . $post->post_parent . "\" />\r\n";
251
- echo '<label class="screen-reader-text" for="mla_parent_info">Parent Info</label><input class="readonly" name="mla_parent_info" type="text" readonly="readonly" size="60" id="mla_parent_info" value="' . esc_attr( $parent_info ) . "\" />\r\n";
252
  }
253
-
254
  /**
255
  * Renders the Menu Order meta box on the Edit Media page.
256
  * Declared public because it is a callback function.
@@ -263,9 +280,9 @@ class MLAEdit {
263
  */
264
  public static function mla_menu_order_handler( $post ) {
265
 
266
- echo '<label class="screen-reader-text" for="mla_menu_order">Menu Order</label><input name="mla_menu_order" type="text" size="4" id="mla_menu_order" value="' . $post->menu_order . "\" />\r\n";
267
  }
268
-
269
  /**
270
  * Renders the Image Metadata meta box on the Edit Media page.
271
  * Declared public because it is a callback function.
@@ -279,14 +296,15 @@ class MLAEdit {
279
  public static function mla_image_metadata_handler( $post ) {
280
  $metadata = MLAData::mla_fetch_attachment_metadata( $post->ID );
281
 
282
- if ( isset( $metadata['mla_wp_attachment_metadata'] ) )
283
  $value = var_export( $metadata['mla_wp_attachment_metadata'], true );
284
- else
285
  $value = '';
 
286
 
287
- echo '<label class="screen-reader-text" for="mla_image_metadata">Attachment Metadata</label><textarea class="readonly" id="mla_image_metadata" rows="5" cols="80" readonly="readonly" name="mla_image_metadata" >' . esc_textarea( $value ) . "</textarea>\r\n";
288
  }
289
-
290
  /**
291
  * Renders the Featured in meta box on the Edit Media page.
292
  * Declared public because it is a callback function.
@@ -298,25 +316,27 @@ class MLAEdit {
298
  * @return void echoes the HTML markup for the meta box content
299
  */
300
  public static function mla_featured_in_handler( $post ) {
301
- if ( is_null( self::$mla_references ) )
302
  self::$mla_references = MLAData::mla_fetch_attachment_references( $post->ID, $post->post_parent );
303
-
 
304
  if ( is_array( self::$mla_references ) ) {
305
  $features = '';
306
-
307
  foreach ( self::$mla_references['features'] as $feature_id => $feature ) {
308
- if ( $feature_id == $post->post_parent )
309
- $parent = 'PARENT ';
310
- else
311
  $parent = '';
312
-
 
313
  $features .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $feature->post_type, /*$3%s*/ $feature_id, /*$4%s*/ $feature->post_title ) . "\r\n";
314
  } // foreach $feature
315
  }
316
 
317
- echo '<label class="screen-reader-text" for="mla_featured_in">Featured in</label><textarea class="readonly" id="mla_featured_in" rows="5" cols="80" readonly="readonly" name="mla_featured_in" >' . esc_textarea( $features ) . "</textarea>\r\n";
318
  }
319
-
320
  /**
321
  * Renders the Inserted in meta box on the Edit Media page.
322
  * Declared public because it is a callback function.
@@ -328,29 +348,31 @@ class MLAEdit {
328
  * @return void echoes the HTML markup for the meta box content
329
  */
330
  public static function mla_inserted_in_handler( $post ) {
331
- if ( is_null( self::$mla_references ) )
332
  self::$mla_references = MLAData::mla_fetch_attachment_references( $post->ID, $post->post_parent );
333
-
 
334
  if ( is_array( self::$mla_references ) ) {
335
  $inserts = '';
336
-
337
  foreach ( self::$mla_references['inserts'] as $file => $insert_array ) {
338
  $inserts .= $file . "\r\n";
339
-
340
  foreach ( $insert_array as $insert ) {
341
- if ( $insert->ID == $post->post_parent )
342
- $parent = ' PARENT ';
343
- else
344
  $parent = ' ';
345
-
 
346
  $inserts .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $insert->post_type, /*$3%s*/ $insert->ID, /*$4%s*/ $insert->post_title ) . "\r\n";
347
  } // foreach $insert
348
  } // foreach $file
349
  } // is_array
350
 
351
- echo '<label class="screen-reader-text" for="mla_inserted_in">Inserted in</label><textarea class="readonly" id="mla_inserted_in" rows="5" cols="80" readonly="readonly" name="mla_inserted_in" >' . esc_textarea( $inserts ) . "</textarea>\r\n";
352
  }
353
-
354
  /**
355
  * Renders the Gallery in meta box on the Edit Media page.
356
  * Declared public because it is a callback function.
@@ -362,25 +384,27 @@ class MLAEdit {
362
  * @return void echoes the HTML markup for the meta box content
363
  */
364
  public static function mla_gallery_in_handler( $post ) {
365
- if ( is_null( self::$mla_references ) )
366
  self::$mla_references = MLAData::mla_fetch_attachment_references( $post->ID, $post->post_parent );
367
-
 
368
  $galleries = '';
369
-
370
  if ( is_array( self::$mla_references ) ) {
371
  foreach ( self::$mla_references['galleries'] as $gallery_id => $gallery ) {
372
- if ( $gallery_id == $post->post_parent )
373
- $parent = 'PARENT ';
374
- else
375
  $parent = '';
376
-
 
377
  $galleries .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $gallery['post_type'], /*$3%s*/ $gallery_id, /*$4%s*/ $gallery['post_title'] ) . "\r\n";
378
  } // foreach $feature
379
  }
380
 
381
- echo '<label class="screen-reader-text" for="mla_gallery_in">Gallery in</label><textarea class="readonly" id="mla_gallery_in" rows="5" cols="80" readonly="readonly" name="mla_gallery_in" >' . esc_textarea( $galleries ) . "</textarea>\r\n";
382
  }
383
-
384
  /**
385
  * Renders the Gallery in meta box on the Edit Media page.
386
  * Declared public because it is a callback function.
@@ -392,25 +416,27 @@ class MLAEdit {
392
  * @return void echoes the HTML markup for the meta box content
393
  */
394
  public static function mla_mla_gallery_in_handler( $post ) {
395
- if ( is_null( self::$mla_references ) )
396
  self::$mla_references = MLAData::mla_fetch_attachment_references( $post->ID, $post->post_parent );
397
-
 
398
  $galleries = '';
399
-
400
  if ( is_array( self::$mla_references ) ) {
401
  foreach ( self::$mla_references['mla_galleries'] as $gallery_id => $gallery ) {
402
- if ( $gallery_id == $post->post_parent )
403
- $parent = 'PARENT ';
404
- else
405
  $parent = '';
406
-
 
407
  $galleries .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $gallery['post_type'], /*$3%s*/ $gallery_id, /*$4%s*/ $gallery['post_title'] ) . "\r\n";
408
  } // foreach $feature
409
  }
410
 
411
- echo '<label class="screen-reader-text" for="mla_mla_gallery_in">MLA Gallery in</label><textarea class="readonly" id="mla_mla_gallery_in" rows="5" cols="80" readonly="readonly" name="mla_mla_gallery_in" >' . esc_textarea( $galleries ) . "</textarea>\r\n";
412
  }
413
-
414
  /**
415
  * Saves updates from the Edit Media screen.
416
  * Declared public because it is an action.
@@ -423,12 +449,14 @@ class MLAEdit {
423
  */
424
  public static function mla_edit_attachment_action( $post_ID ) {
425
  $new_data = array();
426
- if ( isset( $_REQUEST['mla_post_parent'] ) )
427
  $new_data['post_parent'] = $_REQUEST['mla_post_parent'];
428
-
429
- if ( isset( $_REQUEST['mla_menu_order'] ) )
 
430
  $new_data['menu_order'] = $_REQUEST['mla_menu_order'];
431
-
 
432
  if ( !empty( $new_data ) ) {
433
  MLAData::mla_update_single_item( $post_ID, $new_data );
434
  }
27
  */
28
  if ( MLATest::$wordpress_3point5_plus ) {
29
  add_action( 'admin_init', 'MLAEdit::mla_admin_init_action' );
30
+
31
  add_action( 'add_meta_boxes', 'MLAEdit::mla_add_meta_boxes_action', 10, 2 );
32
 
33
  // apply_filters( 'post_updated_messages', $messages ) in wp-admin/edit-form-advanced.php
35
 
36
  // do_action in wp-admin/includes/meta-boxes.php function attachment_submit_meta_box
37
  add_action( 'attachment_submitbox_misc_actions', 'MLAEdit::mla_attachment_submitbox_action' );
38
+
39
  // do_action in wp-includes/post.php function wp_insert_post
40
  add_action( 'edit_attachment', 'MLAEdit::mla_edit_attachment_action', 10, 1 );
41
+
42
  // apply_filters( 'admin_title', $admin_title, $title ) in /wp-admin/admin-header.php
43
  add_filter( 'admin_title', 'MLAEdit::mla_edit_add_help_tab', 10, 2 );
44
  } // $wordpress_3point5_plus
54
  */
55
  public static function mla_admin_init_action( ) {
56
  static $mc_att_category_metabox = array();
57
+
58
  /*
59
  * Enable the enhanced "Media Categories" searchable metaboxes for hiearchical taxonomies
60
  */
66
  foreach ( $taxonomies as $key => $value ) {
67
  if ( MLAOptions::mla_taxonomy_support( $key ) ) {
68
  if ( $value->hierarchical ) {
69
+ if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_DETAILS_CATEGORY_METABOX ) ) {
70
  $mc_att_category_metabox[] = new Media_Categories( $key );
71
+ }
72
+ } else { // hierarchical
73
+ if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_DETAILS_TAG_METABOX ) ) {
74
  $mc_att_category_metabox[] = new Media_Categories( $key );
75
+ }
76
  } // flat
77
  } // is supported
78
  } // foreach
93
  */
94
  public static function mla_post_updated_messages_filter( $messages ) {
95
  if ( isset( $messages['attachment'] ) ) {
96
+ $messages['attachment'][101] = __( 'Custom field mapping updated.', 'media-library-assistant' );
97
+ $messages['attachment'][102] = __('IPTC/EXIF mapping updated.', 'media-library-assistant' );
98
  }
99
+
100
  return $messages;
101
  } // mla_post_updated_messages_filter
102
 
111
  public static function mla_attachment_submitbox_action( ) {
112
  global $post;
113
 
114
+ /* translators: date_i18n format for last modified date and time */
115
+ $date = date_i18n( __( 'M j, Y @ G:i', 'media-library-assistant' ), strtotime( $post->post_modified ) );
 
116
  echo '<div class="misc-pub-section curtime">' . "\r\n";
117
+ echo '<span id="timestamp">' . sprintf(__( 'Last modified', 'media-library-assistant' ) . ": <b>%1\$s</b></span>\r\n", $date);
118
  echo "</div><!-- .misc-pub-section -->\r\n";
119
  echo '<div class="misc-pub-section mla-links">' . "\r\n";
120
+
121
  $view_args = array( 'page' => MLA::ADMIN_PAGE_SLUG, 'mla_item_ID' => $post->ID );
122
+ if ( isset( $_REQUEST['mla_source'] ) ) {
123
  $view_args['mla_source'] = $_REQUEST['mla_source'];
124
+ }
125
+
126
  echo '<span id="mla_metadata_links" style="font-weight: bold; line-height: 2em">';
127
+
128
+ echo '<a href="' . add_query_arg( $view_args, wp_nonce_url( 'upload.php?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_CUSTOM_FIELD_MAP, MLA::MLA_ADMIN_NONCE ) ) . '" title="' . __( 'Map Custom Field metadata for this item', 'media-library-assistant' ) . '">' . __( 'Map Custom Field Metadata', 'media-library-assistant' ) . '</a><br>';
129
+
130
+ echo '<a href="' . add_query_arg( $view_args, wp_nonce_url( 'upload.php?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_MAP, MLA::MLA_ADMIN_NONCE ) ) . '" title="' . __( 'Map IPTC/EXIF metadata for this item', 'media-library-assistant' ) . '">' . __( 'Map IPTC/EXIF Metadata', 'media-library-assistant' ) . '</a>';
131
+
132
  echo "</span>\r\n";
133
  echo "</div><!-- .misc-pub-section -->\r\n";
134
  } // mla_attachment_submitbox_action
135
+
136
  /**
137
  * Registers meta boxes for the Edit Media screen.
138
  * Declared public because it is an action.
148
  /*
149
  * Plugins call this action with varying numbers of arguments!
150
  */
151
+ if ( NULL == $post ) {
152
  $post = (object) array ( 'ID' => 0 );
153
+ }
154
+
155
  if ( 'attachment' == $post_type ) {
156
+ add_meta_box( 'mla-parent-info', __( 'Parent Info', 'media-library-assistant' ), 'MLAEdit::mla_parent_info_handler', 'attachment', 'normal', 'core' );
157
+ add_meta_box( 'mla-menu-order', __( 'Menu Order', 'media-library-assistant' ), 'MLAEdit::mla_menu_order_handler', 'attachment', 'normal', 'core' );
158
+
159
  $image_metadata = get_metadata( 'post', $post->ID, '_wp_attachment_metadata', true );
160
+ if ( !empty( $image_metadata ) ) {
161
+ add_meta_box( 'mla-image-metadata', __( 'Attachment Metadata', 'media-library-assistant' ), 'MLAEdit::mla_image_metadata_handler', 'attachment', 'normal', 'core' );
162
+ }
163
+
164
+ if ( MLAOptions::$process_featured_in ) {
165
+ add_meta_box( 'mla-featured-in', __( 'Featured in', 'media-library-assistant' ), 'MLAEdit::mla_featured_in_handler', 'attachment', 'normal', 'core' );
166
+ }
167
+
168
+ if ( MLAOptions::$process_inserted_in ) {
169
+ add_meta_box( 'mla-inserted-in', __( 'Inserted in', 'media-library-assistant' ), 'MLAEdit::mla_inserted_in_handler', 'attachment', 'normal', 'core' );
170
+ }
171
+
172
+ if ( MLAOptions::$process_gallery_in ) {
173
+ add_meta_box( 'mla-gallery-in', __( 'Gallery in', 'media-library-assistant' ), 'MLAEdit::mla_gallery_in_handler', 'attachment', 'normal', 'core' );
174
+ }
175
+
176
+ if ( MLAOptions::$process_mla_gallery_in ) {
177
+ add_meta_box( 'mla-mla-gallery-in', __( 'MLA Gallery in', 'media-library-assistant' ), 'MLAEdit::mla_mla_gallery_in_handler', 'attachment', 'normal', 'core' );
178
+ }
179
  } // 'attachment'
180
  } // mla_add_meta_boxes_action
181
+
182
  /**
183
  * Add contextual help tabs to the WordPress Edit Media page
184
  *
192
  public static function mla_edit_add_help_tab( $admin_title, $title ) {
193
  $screen = get_current_screen();
194
 
195
+ if ( ( 'attachment' != $screen->id ) || ( 'attachment' != $screen->post_type ) || ( 'post' != $screen->base ) ) {
196
  return $admin_title;
197
+ }
198
+
199
+ $template_array = MLAData::mla_load_template( 'help-for-edit_attachment.tpl' );
200
  if ( empty( $template_array ) ) {
201
  return $admin_title;
202
  }
203
+
204
  /*
205
  * Provide explicit control over tab order
206
  */
207
  $tab_array = array();
208
+
209
  foreach ( $template_array as $id => $content ) {
210
  $match_count = preg_match( '#\<!-- title="(.+)" order="(.+)" --\>#', $content, $matches, PREG_OFFSET_CAPTURE );
211
+
212
  if ( $match_count > 0 ) {
213
  $tab_array[ $matches[ 2 ][ 0 ] ] = array(
214
  'id' => $id,
216
  'content' => $content
217
  );
218
  } else {
219
+ /* translators: 1: function name 2: template key */
220
+ error_log( sprintf( _x( 'ERROR: %1$s discarding "%2$s"; no title/order', 'error_log', 'media-library-assistant' ), 'mla_edit_add_help_tab', $id ), 0 );
221
  }
222
  }
223
+
224
  ksort( $tab_array, SORT_NUMERIC );
225
  foreach ( $tab_array as $indx => $value ) {
226
  $screen->add_help_tab( $value );
228
 
229
  return $admin_title;
230
  }
231
+
232
  /**
233
  * Where-used values for the current item
234
  *
252
  * @return void echoes the HTML markup for the meta box content
253
  */
254
  public static function mla_parent_info_handler( $post ) {
255
+ if ( is_null( self::$mla_references ) ) {
256
  self::$mla_references = MLAData::mla_fetch_attachment_references( $post->ID, $post->post_parent );
257
+ }
258
+
259
  if ( is_array( self::$mla_references ) ) {
260
+ if ( empty(self::$mla_references['parent_title'] ) ) {
261
  $parent_info = self::$mla_references['parent_errors'];
262
+ } else {
263
  $parent_info = sprintf( '(%1$s) %2$s %3$s', self::$mla_references['parent_type'], self::$mla_references['parent_title'], self::$mla_references['parent_errors'] );
264
+ }
265
  } // is_array
266
 
267
+ echo '<label class="screen-reader-text" for="mla_post_parent">' . __( 'Post Parent', 'media-library-assistant' ) . '</label><input name="mla_post_parent" type="text" size="4" id="mla_post_parent" value="' . $post->post_parent . "\" />\r\n";
268
+ echo '<label class="screen-reader-text" for="mla_parent_info">' . __( 'Parent Info', 'media-library-assistant' ) . '</label><input class="readonly" name="mla_parent_info" type="text" readonly="readonly" size="60" id="mla_parent_info" value="' . esc_attr( $parent_info ) . "\" />\r\n";
269
  }
270
+
271
  /**
272
  * Renders the Menu Order meta box on the Edit Media page.
273
  * Declared public because it is a callback function.
280
  */
281
  public static function mla_menu_order_handler( $post ) {
282
 
283
+ echo '<label class="screen-reader-text" for="mla_menu_order">' . __( 'Menu Order', 'media-library-assistant' ) . '</label><input name="mla_menu_order" type="text" size="4" id="mla_menu_order" value="' . $post->menu_order . "\" />\r\n";
284
  }
285
+
286
  /**
287
  * Renders the Image Metadata meta box on the Edit Media page.
288
  * Declared public because it is a callback function.
296
  public static function mla_image_metadata_handler( $post ) {
297
  $metadata = MLAData::mla_fetch_attachment_metadata( $post->ID );
298
 
299
+ if ( isset( $metadata['mla_wp_attachment_metadata'] ) ) {
300
  $value = var_export( $metadata['mla_wp_attachment_metadata'], true );
301
+ } else {
302
  $value = '';
303
+ }
304
 
305
+ echo '<label class="screen-reader-text" for="mla_image_metadata">' . __( 'Attachment Metadata', 'media-library-assistant' ) . '</label><textarea class="readonly" id="mla_image_metadata" rows="5" cols="80" readonly="readonly" name="mla_image_metadata" >' . esc_textarea( $value ) . "</textarea>\r\n";
306
  }
307
+
308
  /**
309
  * Renders the Featured in meta box on the Edit Media page.
310
  * Declared public because it is a callback function.
316
  * @return void echoes the HTML markup for the meta box content
317
  */
318
  public static function mla_featured_in_handler( $post ) {
319
+ if ( is_null( self::$mla_references ) ) {
320
  self::$mla_references = MLAData::mla_fetch_attachment_references( $post->ID, $post->post_parent );
321
+ }
322
+
323
  if ( is_array( self::$mla_references ) ) {
324
  $features = '';
325
+
326
  foreach ( self::$mla_references['features'] as $feature_id => $feature ) {
327
+ if ( $feature_id == $post->post_parent ) {
328
+ $parent = __( 'PARENT', 'media-library-assistant' ) . ' ';
329
+ } else {
330
  $parent = '';
331
+ }
332
+
333
  $features .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $feature->post_type, /*$3%s*/ $feature_id, /*$4%s*/ $feature->post_title ) . "\r\n";
334
  } // foreach $feature
335
  }
336
 
337
+ echo '<label class="screen-reader-text" for="mla_featured_in">' . __( 'Featured in', 'media-library-assistant' ) . '</label><textarea class="readonly" id="mla_featured_in" rows="5" cols="80" readonly="readonly" name="mla_featured_in" >' . esc_textarea( $features ) . "</textarea>\r\n";
338
  }
339
+
340
  /**
341
  * Renders the Inserted in meta box on the Edit Media page.
342
  * Declared public because it is a callback function.
348
  * @return void echoes the HTML markup for the meta box content
349
  */
350
  public static function mla_inserted_in_handler( $post ) {
351
+ if ( is_null( self::$mla_references ) ) {
352
  self::$mla_references = MLAData::mla_fetch_attachment_references( $post->ID, $post->post_parent );
353
+ }
354
+
355
  if ( is_array( self::$mla_references ) ) {
356
  $inserts = '';
357
+
358
  foreach ( self::$mla_references['inserts'] as $file => $insert_array ) {
359
  $inserts .= $file . "\r\n";
360
+
361
  foreach ( $insert_array as $insert ) {
362
+ if ( $insert->ID == $post->post_parent ) {
363
+ $parent = ' ' . __( 'PARENT', 'media-library-assistant' ) . ' ';
364
+ } else {
365
  $parent = ' ';
366
+ }
367
+
368
  $inserts .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $insert->post_type, /*$3%s*/ $insert->ID, /*$4%s*/ $insert->post_title ) . "\r\n";
369
  } // foreach $insert
370
  } // foreach $file
371
  } // is_array
372
 
373
+ echo '<label class="screen-reader-text" for="mla_inserted_in">' . __( 'Inserted in', 'media-library-assistant' ) . '</label><textarea class="readonly" id="mla_inserted_in" rows="5" cols="80" readonly="readonly" name="mla_inserted_in" >' . esc_textarea( $inserts ) . "</textarea>\r\n";
374
  }
375
+
376
  /**
377
  * Renders the Gallery in meta box on the Edit Media page.
378
  * Declared public because it is a callback function.
384
  * @return void echoes the HTML markup for the meta box content
385
  */
386
  public static function mla_gallery_in_handler( $post ) {
387
+ if ( is_null( self::$mla_references ) ) {
388
  self::$mla_references = MLAData::mla_fetch_attachment_references( $post->ID, $post->post_parent );
389
+ }
390
+
391
  $galleries = '';
392
+
393
  if ( is_array( self::$mla_references ) ) {
394
  foreach ( self::$mla_references['galleries'] as $gallery_id => $gallery ) {
395
+ if ( $gallery_id == $post->post_parent ) {
396
+ $parent = __( 'PARENT', 'media-library-assistant' ) . ' ';
397
+ } else {
398
  $parent = '';
399
+ }
400
+
401
  $galleries .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $gallery['post_type'], /*$3%s*/ $gallery_id, /*$4%s*/ $gallery['post_title'] ) . "\r\n";
402
  } // foreach $feature
403
  }
404
 
405
+ echo '<label class="screen-reader-text" for="mla_gallery_in">' . __( 'Gallery in', 'media-library-assistant' ) . '</label><textarea class="readonly" id="mla_gallery_in" rows="5" cols="80" readonly="readonly" name="mla_gallery_in" >' . esc_textarea( $galleries ) . "</textarea>\r\n";
406
  }
407
+
408
  /**
409
  * Renders the Gallery in meta box on the Edit Media page.
410
  * Declared public because it is a callback function.
416
  * @return void echoes the HTML markup for the meta box content
417
  */
418
  public static function mla_mla_gallery_in_handler( $post ) {
419
+ if ( is_null( self::$mla_references ) ) {
420
  self::$mla_references = MLAData::mla_fetch_attachment_references( $post->ID, $post->post_parent );
421
+ }
422
+
423
  $galleries = '';
424
+
425
  if ( is_array( self::$mla_references ) ) {
426
  foreach ( self::$mla_references['mla_galleries'] as $gallery_id => $gallery ) {
427
+ if ( $gallery_id == $post->post_parent ) {
428
+ $parent = __( 'PARENT', 'media-library-assistant' ) . ' ';
429
+ } else {
430
  $parent = '';
431
+ }
432
+
433
  $galleries .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $gallery['post_type'], /*$3%s*/ $gallery_id, /*$4%s*/ $gallery['post_title'] ) . "\r\n";
434
  } // foreach $feature
435
  }
436
 
437
+ echo '<label class="screen-reader-text" for="mla_mla_gallery_in">' . __( 'MLA Gallery in', 'media-library-assistant' ) . '</label><textarea class="readonly" id="mla_mla_gallery_in" rows="5" cols="80" readonly="readonly" name="mla_mla_gallery_in" >' . esc_textarea( $galleries ) . "</textarea>\r\n";
438
  }
439
+
440
  /**
441
  * Saves updates from the Edit Media screen.
442
  * Declared public because it is an action.
449
  */
450
  public static function mla_edit_attachment_action( $post_ID ) {
451
  $new_data = array();
452
+ if ( isset( $_REQUEST['mla_post_parent'] ) ) {
453
  $new_data['post_parent'] = $_REQUEST['mla_post_parent'];
454
+ }
455
+
456
+ if ( isset( $_REQUEST['mla_menu_order'] ) ) {
457
  $new_data['menu_order'] = $_REQUEST['mla_menu_order'];
458
+ }
459
+
460
  if ( !empty( $new_data ) ) {
461
  MLAData::mla_update_single_item( $post_ID, $new_data );
462
  }
includes/class-mla-list-table.php CHANGED
@@ -47,11 +47,12 @@ class MLA_List_Table extends WP_List_Table {
47
  * @var array
48
  */
49
  private $currently_hidden = array();
50
-
51
  /*
52
- * These arrays define the table columns.
 
53
  */
54
-
55
  /**
56
  * Table column definitions
57
  *
@@ -63,40 +64,14 @@ class MLA_List_Table extends WP_List_Table {
63
  * column in your table you must create a column_cb() method. If you don't need
64
  * bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
65
  *
66
- * Taxonomy columns are added to this array by mla_admin_init_action.
67
- * Custom field columns are added to this array by mla_admin_init_action.
68
- *
69
  * @since 0.1
70
  *
71
  * @var array
72
  */
73
- private static $default_columns = array(
74
- 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
75
- 'icon' => '',
76
- 'ID_parent' => 'ID/Parent',
77
- 'title_name' => 'Title/Name',
78
- 'post_title' => 'Title',
79
- 'post_name' => 'Name',
80
- 'parent' => 'Parent ID',
81
- 'menu_order' => 'Menu Order',
82
- 'featured' => 'Featured in',
83
- 'inserted' => 'Inserted in',
84
- 'galleries' => 'Gallery in',
85
- 'mla_galleries' => 'MLA Gallery in',
86
- 'alt_text' => 'ALT Text',
87
- 'caption' => 'Caption',
88
- 'description' => 'Description',
89
- 'post_mime_type' => 'MIME Type',
90
- 'file_url' => 'File URL',
91
- 'base_file' => 'Base File',
92
- 'date' => 'Date',
93
- 'modified' => 'Last Modified',
94
- 'author' => 'Author',
95
- 'attached_to' => 'Attached to'
96
- // taxonomy columns added by mla_admin_init_action
97
- // custom field columns added by mla_admin_init_action
98
- );
99
-
100
  /**
101
  * Default values for hidden columns
102
  *
@@ -106,8 +81,8 @@ class MLA_List_Table extends WP_List_Table {
106
  * The value on the right-hand side must match the column slug, e.g.,
107
  * array(0 => 'ID_parent, 1 => 'title_name').
108
  *
109
- * Taxonomy columns are added to this array by mla_admin_init_action.
110
- * Custom field columns are added to this array by mla_admin_init_action.
111
  *
112
  * @since 0.1
113
  *
@@ -137,7 +112,7 @@ class MLA_List_Table extends WP_List_Table {
137
  // taxonomy columns added by mla_admin_init_action
138
  // custom field columns added by mla_admin_init_action
139
  );
140
-
141
  /**
142
  * Sortable column definitions
143
  *
@@ -149,8 +124,8 @@ class MLA_List_Table extends WP_List_Table {
149
  * The array value also contains a boolean which is 'true' if the data is currently
150
  * sorted by that column. This is computed each time the table is displayed.
151
  *
152
- * Taxonomy columns, if any, are added to this array by mla_admin_init_action.
153
- * Custom field columns are added to this array by mla_admin_init_action.
154
  *
155
  * @since 0.1
156
  *
@@ -191,7 +166,7 @@ class MLA_List_Table extends WP_List_Table {
191
  private static function _default_hidden_columns( ) {
192
  return MLA_List_Table::$default_hidden_columns;
193
  }
194
-
195
  /**
196
  * Get MIME types with one or more attachments for view preparation
197
  *
@@ -206,15 +181,16 @@ class MLA_List_Table extends WP_List_Table {
206
  */
207
  private function _avail_mime_types( $num_posts ) {
208
  $available = array();
209
-
210
  foreach ( $num_posts as $mime_type => $number ) {
211
- if ( ( $number > 0 ) && ( $mime_type <> 'trash' ) )
212
  $available[ ] = $mime_type;
 
213
  }
214
-
215
  return $available;
216
  }
217
-
218
  /**
219
  * Get dropdown box of terms to filter by, if available
220
  *
@@ -227,12 +203,12 @@ class MLA_List_Table extends WP_List_Table {
227
  public static function mla_get_taxonomy_filter_dropdown( $selected = 0 ) {
228
  $dropdown = '';
229
  $tax_filter = MLAOptions::mla_taxonomy_support('', 'filter');
230
-
231
  if ( ( '' != $tax_filter ) && ( is_object_in_taxonomy( 'attachment', $tax_filter ) ) ) {
232
  $tax_object = get_taxonomy( $tax_filter );
233
  $dropdown_options = array(
234
- 'show_option_all' => 'All ' . $tax_object->labels->name,
235
- 'show_option_none' => 'No ' . $tax_object->labels->name,
236
  'orderby' => 'name',
237
  'order' => 'ASC',
238
  'show_count' => false,
@@ -252,16 +228,16 @@ class MLA_List_Table extends WP_List_Table {
252
  'taxonomy' => $tax_filter,
253
  'hide_if_empty' => false
254
  );
255
-
256
  ob_start();
257
  wp_dropdown_categories( $dropdown_options );
258
  $dropdown = ob_get_contents();
259
  ob_end_clean();
260
  }
261
-
262
  return $dropdown;
263
  }
264
-
265
  /**
266
  * Return the names and display values of the sortable columns
267
  *
@@ -272,15 +248,15 @@ class MLA_List_Table extends WP_List_Table {
272
  public static function mla_get_sortable_columns( )
273
  {
274
  $results = array() ;
275
-
276
  foreach ( MLA_List_Table::$default_sortable_columns as $key => $value ) {
277
  $value[1] = MLA_List_Table::$default_columns[ $key ];
278
  $results[ $key ] = $value;
279
  }
280
-
281
  return $results;
282
  }
283
-
284
  /**
285
  * Handler for filter 'get_user_option_managemedia_page_mla-menucolumnshidden'
286
  *
@@ -297,12 +273,13 @@ class MLA_List_Table extends WP_List_Table {
297
  * @return array updated list of hidden columns
298
  */
299
  public static function mla_manage_hidden_columns_filter( $result, $option, $user_data ) {
300
- if ( $result )
301
  return $result;
302
- else
303
- return self::_default_hidden_columns();
 
304
  }
305
-
306
  /**
307
  * Handler for filter 'manage_media_page_mla-menu_columns'
308
  *
@@ -318,7 +295,7 @@ class MLA_List_Table extends WP_List_Table {
318
  {
319
  return MLA_List_Table::$default_columns;
320
  }
321
-
322
  /**
323
  * Adds support for taxonomy and custom field columns
324
  *
@@ -331,6 +308,36 @@ class MLA_List_Table extends WP_List_Table {
331
  */
332
  public static function mla_admin_init_action( )
333
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  $taxonomies = get_taxonomies( array ( 'show_ui' => true ), 'names' );
335
 
336
  foreach ( $taxonomies as $tax_name ) {
@@ -341,12 +348,12 @@ class MLA_List_Table extends WP_List_Table {
341
  // MLA_List_Table::$default_sortable_columns [] = none at this time
342
  } // supported taxonomy
343
  } // foreach $tax_name
344
-
345
  MLA_List_Table::$default_columns = array_merge( MLA_List_Table::$default_columns, MLAOptions::mla_custom_field_support( 'default_columns' ) );
346
  MLA_List_Table::$default_hidden_columns = array_merge( MLA_List_Table::$default_hidden_columns, MLAOptions::mla_custom_field_support( 'default_hidden_columns' ) );
347
  MLA_List_Table::$default_sortable_columns = array_merge( MLA_List_Table::$default_sortable_columns, MLAOptions::mla_custom_field_support( 'default_sortable_columns' ) );
348
  }
349
-
350
  /**
351
  * Initializes some properties from $_REQUEST variables, then
352
  * calls the parent constructor to set some default configs.
@@ -358,23 +365,26 @@ class MLA_List_Table extends WP_List_Table {
358
  function __construct( ) {
359
  $this->detached = isset( $_REQUEST['detached'] );
360
  $this->is_trash = isset( $_REQUEST['status'] ) && $_REQUEST['status'] == 'trash';
361
-
362
  //Set parent defaults
363
  parent::__construct( array(
364
  'singular' => 'attachment', //singular name of the listed records
365
  'plural' => 'attachments', //plural name of the listed records
366
  'ajax' => true, //does this table support ajax?
367
  'screen' => 'media_page_' . MLA::ADMIN_PAGE_SLUG
368
- ) );
369
-
370
  $this->currently_hidden = self::get_hidden_columns();
371
-
372
  /*
373
  * NOTE: There is one add_action call at the end of this source file.
374
  * NOTE: There are two add_filter calls at the end of this source file.
 
 
 
375
  */
376
  }
377
-
378
  /**
379
  * Supply a column value if no column-specific function has been defined
380
  *
@@ -393,61 +403,64 @@ class MLA_List_Table extends WP_List_Table {
393
  $taxonomy = substr( $column_name, 2 );
394
  $tax_object = get_taxonomy( $taxonomy );
395
  $terms = wp_get_object_terms( $item->ID, $taxonomy );
396
-
397
  if ( !is_wp_error( $terms ) ) {
398
- if ( empty( $terms ) )
399
- return 'none';
 
400
 
401
  $list = array();
402
  foreach ( $terms as $term ) {
403
  $term_name = esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'category', 'display' ) );
404
- $list[ ] = sprintf( '<a href="%1$s" title="Filter by &#8220;%2$s&#8221;">%3$s</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
405
  'page' => MLA::ADMIN_PAGE_SLUG,
406
  'mla-tax' => $taxonomy,
407
  'mla-term' => $term->slug,
408
  'heading_suffix' => urlencode( $tax_object->label . ': ' . $term->name )
409
  ) ), 'upload.php' ) ), $term_name, $term_name );
410
  } // foreach $term
411
-
412
  return join( ', ', $list );
413
- } // if !is_wp_error
414
- else {
415
- return 'not supported';
416
  }
417
  } // 't_'
418
  elseif ( 'c_' == substr( $column_name, 0, 2 ) ) {
419
  $values = get_post_meta( $item->ID, MLA_List_Table::$default_columns[ $column_name ], false );
420
- if ( empty( $values ) )
421
  return '';
422
-
 
423
  $list = array();
424
  foreach ( $values as $index => $value ) {
425
  /*
426
  * For display purposes, convert array values.
427
  * They are not links because no search will match them.
428
  */
429
- if ( is_array( $value ) )
430
  $list[ ] = 'array( ' . implode( ', ', $value ) . ' )';
431
- else
432
- $list[ ] = sprintf( '<a href="%1$s" title="Filter by &#8220;%2$s&#8221;">%3$s</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
433
  'page' => MLA::ADMIN_PAGE_SLUG,
434
  'mla-metakey' => urlencode( MLA_List_Table::$default_columns[ $column_name ] ),
435
  'mla-metavalue' => urlencode( $value ),
436
  'heading_suffix' => urlencode( MLA_List_Table::$default_columns[ $column_name ] . ': ' . $value )
437
  ) ), 'upload.php' ) ), esc_html( substr( $value, 0, 64 ) ), esc_html( $value ) );
 
438
  }
439
 
440
- if ( count( $list ) > 1 )
441
  return '[' . join( '], [', $list ) . ']';
442
- else
443
  return $list[0];
444
- } // 'c_'
445
- else {
446
  //Show the whole array for troubleshooting purposes
447
- return 'column_default: ' . $column_name . ', ' . print_r( $item, true );
 
448
  }
449
  }
450
-
451
  /**
452
  * Displays checkboxes for using bulk actions. The 'cb' column
453
  * is given special treatment when columns are processed.
@@ -464,7 +477,7 @@ class MLA_List_Table extends WP_List_Table {
464
  /*%2$s*/ $item->ID //The value of the checkbox should be the object's id
465
  );
466
  }
467
-
468
  /**
469
  * Supply the content for a custom column
470
  *
@@ -475,17 +488,19 @@ class MLA_List_Table extends WP_List_Table {
475
  */
476
  function column_icon( $item )
477
  {
478
- if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) )
479
  $thumb = wp_get_attachment_image( $item->ID, array( 64, 64 ), true, array( 'class' => 'mla_media_thumbnail_64_64' ) );
480
- else
481
  $thumb = wp_get_attachment_image( $item->ID, array( 80, 60 ), true, array( 'class' => 'mla_media_thumbnail_80_60' ) );
 
482
 
483
- if ( $this->is_trash || ! current_user_can( 'edit_post', $item->ID ) )
484
  return $thumb;
485
-
486
- return sprintf( '<a href="%1$s" title="Edit &#8220;%2$s&#8221;">%3$s</a>', get_edit_post_link( $item->ID, true ), esc_attr( $item->post_title ), $thumb );
487
  }
488
-
 
 
 
489
  /**
490
  * Add rollover actions to exactly one of the following displayed columns:
491
  * 'ID_parent', 'title_name', 'post_title', 'post_name'
@@ -499,7 +514,7 @@ class MLA_List_Table extends WP_List_Table {
499
  */
500
  private function _build_rollover_actions( $item, $column ) {
501
  $actions = array();
502
-
503
  if ( ( $this->rollover_id != $item->ID ) && !in_array( $column, $this->currently_hidden ) ) {
504
  /*
505
  * Build rollover actions
@@ -507,45 +522,45 @@ class MLA_List_Table extends WP_List_Table {
507
  $view_args = array_merge( array( 'page' => MLA::ADMIN_PAGE_SLUG, 'mla_item_ID' => $item->ID ),
508
  self::mla_submenu_arguments() );
509
 
510
- if ( isset( $_REQUEST['paged'] ) )
511
  $view_args['paged'] = $_REQUEST['paged'];
512
-
 
513
  if ( current_user_can( 'edit_post', $item->ID ) ) {
514
- if ( $this->is_trash )
515
- $actions['restore'] = '<a class="submitdelete" href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_RESTORE, MLA::MLA_ADMIN_NONCE ) ) . '" title="Restore this item from the Trash">Restore</a>';
516
- else {
517
  /*
518
  * Use the WordPress Edit Media screen for 3.5 and later
519
  */
520
- if( MLATest::$wordpress_3point5_plus ) {
521
- $actions['edit'] = '<a href="' . admin_url( 'post.php' ) . '?post=' . $item->ID . '&action=edit&mla_source=edit" title="Edit this item">Edit</a>';
522
- }
523
- else {
524
- $actions['edit'] = '<a href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_EDIT_DISPLAY, MLA::MLA_ADMIN_NONCE ) ) . '" title="Edit this item">Edit</a>';
525
  }
526
- $actions['inline hide-if-no-js'] = '<a class="editinline" href="#" title="Edit this item inline">Quick Edit</a>';
527
  }
528
  } // edit_post
529
-
530
  if ( current_user_can( 'delete_post', $item->ID ) ) {
531
- if ( !$this->is_trash && EMPTY_TRASH_DAYS && MEDIA_TRASH )
532
- $actions['trash'] = '<a class="submitdelete" href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_TRASH, MLA::MLA_ADMIN_NONCE ) ) . '" title="Move this item to the Trash">Move to Trash</a>';
533
- else {
534
  // If using trash for posts and pages but not for attachments, warn before permanently deleting
535
  $delete_ays = EMPTY_TRASH_DAYS && !MEDIA_TRASH ? ' onclick="return showNotice.warn();"' : '';
536
-
537
- $actions['delete'] = '<a class="submitdelete"' . $delete_ays . ' href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_DELETE, MLA::MLA_ADMIN_NONCE ) ) . '" title="Delete this item Permanently">Delete Permanently</a>';
538
  }
539
  } // delete_post
540
-
541
- $actions['view'] = '<a href="' . site_url( ) . '?attachment_id=' . $item->ID . '" rel="permalink" title="View &#8220;' . esc_attr( $item->post_title ) . '&#8221;">View</a>';
542
-
543
  $this->rollover_id = $item->ID;
544
  } // $this->rollover_id != $item->ID
545
-
546
  return $actions;
547
  }
548
-
549
  /**
550
  * Add hidden fields with the data for use in the inline editor
551
  *
@@ -561,27 +576,28 @@ class MLA_List_Table extends WP_List_Table {
561
  $inline_data .= ' <div class="post_name">' . esc_attr( $item->post_name ) . "</div>\r\n";
562
  $inline_data .= ' <div class="post_excerpt">' . esc_attr( $item->post_excerpt ) . "</div>\r\n";
563
  $inline_data .= ' <div class="post_content">' . esc_attr( $item->post_content ) . "</div>\r\n";
564
-
565
  if ( !empty( $item->mla_wp_attachment_metadata ) ) {
566
- if ( isset( $item->mla_wp_attachment_image_alt ) )
567
  $inline_data .= ' <div class="image_alt">' . esc_attr( $item->mla_wp_attachment_image_alt ) . "</div>\r\n";
568
- else
569
  $inline_data .= ' <div class="image_alt">' . "</div>\r\n";
 
570
  }
571
-
572
  $inline_data .= ' <div class="post_parent">' . $item->post_parent . "</div>\r\n";
573
  $inline_data .= ' <div class="menu_order">' . $item->menu_order . "</div>\r\n";
574
  $inline_data .= ' <div class="post_author">' . $item->post_author . "</div>\r\n";
575
-
576
  $custom_fields = MLAOptions::mla_custom_field_support( 'quick_edit' );
577
  $custom_fields = array_merge( $custom_fields, MLAOptions::mla_custom_field_support( 'bulk_edit' ) );
578
  foreach ($custom_fields as $slug => $label ) {
579
  $value = get_metadata( 'post', $item->ID, $label, true );
580
  $inline_data .= ' <div class="' . $slug . '">' . esc_html( $value ) . "</div>\r\n";
581
  }
582
-
583
  $taxonomies = get_object_taxonomies( 'attachment', 'objects' );
584
-
585
  foreach ( $taxonomies as $tax_name => $tax_object ) {
586
  if ( $tax_object->hierarchical && $tax_object->show_ui && MLAOptions::mla_taxonomy_support($tax_name, 'quick-edit') ) {
587
  $inline_data .= ' <div class="mla_category" id="' . $tax_name . '_' . $item->ID . '">'
@@ -591,11 +607,11 @@ class MLA_List_Table extends WP_List_Table {
591
  . esc_html( str_replace( ',', ', ', get_terms_to_edit( $item->ID, $tax_name ) ) ) . "</div>\r\n";
592
  }
593
  }
594
-
595
  $inline_data .= "</div>\r\n";
596
  return $inline_data;
597
  }
598
-
599
  /**
600
  * Supply the content for a custom column
601
  *
@@ -607,19 +623,20 @@ class MLA_List_Table extends WP_List_Table {
607
  function column_ID_parent( $item ) {
608
  $row_actions = self::_build_rollover_actions( $item, 'ID_parent' );
609
  if ( $item->post_parent ) {
610
- if ( isset( $item->parent_title ) )
611
  $parent_title = $item->parent_title;
612
- else
613
- $parent_title = '(no title: bad ID)';
 
614
 
615
- $parent = sprintf( '<a href="%1$s" title="Filter by Parent ID">(parent:%2$s)</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
616
  'page' => MLA::ADMIN_PAGE_SLUG,
617
  'parent' => $item->post_parent,
618
- 'heading_suffix' => urlencode( 'Parent: ' . $parent_title )
619
  ) ), 'upload.php' ) ), (string) $item->post_parent );
620
- } // $item->post_parent
621
- else
622
  $parent = 'parent:0';
 
623
 
624
  if ( !empty( $row_actions ) ) {
625
  return sprintf( '%1$s<br><span style="color:silver">%2$s</span><br>%3$s%4$s', /*%1$s*/ $item->ID, /*%2$s*/ $parent, /*%3$s*/ $this->row_actions( $row_actions ), /*%4$s*/ $this->_build_inline_data( $item ) );
@@ -627,7 +644,7 @@ class MLA_List_Table extends WP_List_Table {
627
  return sprintf( '%1$s<br><span style="color:silver">%2$s</span>', /*%1$s*/ $item->ID, /*%2$s*/ $parent );
628
  }
629
  }
630
-
631
  /**
632
  * Supply the content for a custom column
633
  *
@@ -641,16 +658,17 @@ class MLA_List_Table extends WP_List_Table {
641
  $post_title = esc_attr( $item->post_title );
642
  $post_name = esc_attr( $item->post_name );
643
  $errors = $item->mla_references['parent_errors'];
644
- if ( '(NO REFERENCE TESTS)' == $errors )
645
  $errors = '';
646
-
 
647
  if ( !empty( $row_actions ) ) {
648
  return sprintf( '%1$s<br>%2$s<br>%3$s%4$s%5$s', /*%1$s*/ $post_title, /*%2$s*/ $post_name, /*%3$s*/ $errors, /*%4$s*/ $this->row_actions( $row_actions ), /*%5$s*/ $this->_build_inline_data( $item ) );
649
  } else {
650
  return sprintf( '%1$s<br>%2$s<br>%3$s', /*%1$s*/ $post_title, /*%2$s*/ $post_name, /*%3$s*/ $errors );
651
  }
652
  }
653
-
654
  /**
655
  * Supply the content for a custom column
656
  *
@@ -661,14 +679,14 @@ class MLA_List_Table extends WP_List_Table {
661
  */
662
  function column_post_title( $item ) {
663
  $row_actions = self::_build_rollover_actions( $item, 'post_title' );
664
-
665
  if ( !empty( $row_actions ) ) {
666
  return sprintf( '%1$s<br>%2$s%3$s', /*%1$s*/ esc_attr( $item->post_title ), /*%2$s*/ $this->row_actions( $row_actions ), /*%3$s*/ $this->_build_inline_data( $item ) );
667
  } else {
668
  return esc_attr( $item->post_title );
669
  }
670
  }
671
-
672
  /**
673
  * Supply the content for a custom column
674
  *
@@ -679,14 +697,14 @@ class MLA_List_Table extends WP_List_Table {
679
  */
680
  function column_post_name( $item ) {
681
  $row_actions = self::_build_rollover_actions( $item, 'post_name' );
682
-
683
  if ( !empty( $row_actions ) ) {
684
  return sprintf( '%1$s<br>%2$s%3$s', /*%1$s*/ esc_attr( $item->post_name ), /*%2$s*/ $this->row_actions( $row_actions ), /*%3$s*/ $this->_build_inline_data( $item ) );
685
  } else {
686
  return esc_attr( $item->post_name );
687
  }
688
  }
689
-
690
  /**
691
  * Supply the content for a custom column
692
  *
@@ -697,21 +715,22 @@ class MLA_List_Table extends WP_List_Table {
697
  */
698
  function column_parent( $item ) {
699
  if ( $item->post_parent ){
700
- if ( isset( $item->parent_title ) )
701
  $parent_title = $item->parent_title;
702
- else
703
- $parent_title = '(no title: bad ID)';
 
704
 
705
- return sprintf( '<a href="%1$s" title="Filter by Parent ID">%2$s</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
706
  'page' => MLA::ADMIN_PAGE_SLUG,
707
  'parent' => $item->post_parent,
708
- 'heading_suffix' => urlencode( 'Parent: ' . $parent_title )
709
  ) ), 'upload.php' ) ), (string) $item->post_parent );
710
- }
711
- else
712
  return (string) $item->post_parent;
 
713
  }
714
-
715
  /**
716
  * Supply the content for a custom column
717
  *
@@ -723,7 +742,7 @@ class MLA_List_Table extends WP_List_Table {
723
  function column_menu_order( $item ) {
724
  return (string) $item->menu_order;
725
  }
726
-
727
  /**
728
  * Supply the content for a custom column
729
  *
@@ -733,18 +752,20 @@ class MLA_List_Table extends WP_List_Table {
733
  * @return string HTML markup to be placed inside the column
734
  */
735
  function column_featured( $item ) {
736
- if ( !MLAOptions::$process_featured_in )
737
- return 'disabled';
738
-
 
739
  $value = '';
740
-
741
  foreach ( $item->mla_references['features'] as $feature_id => $feature ) {
742
- if ( $feature_id == $item->post_parent )
743
- $parent = ',<br>PARENT';
744
- else
745
  $parent = '';
746
-
747
- $value .= sprintf( '(%1$s %2$s%3$s), <a href="%4$s" title="Edit &#8220;%5$s&#8221;">%6$s</a>',
 
748
  /*%1$s*/ esc_attr( $feature->post_type ),
749
  /*%2$s*/ $feature_id,
750
  /*%3$s*/ $parent,
@@ -752,10 +773,10 @@ class MLA_List_Table extends WP_List_Table {
752
  /*%5$s*/ esc_attr( $feature->post_title ),
753
  /*%6$s*/ esc_attr( $feature->post_title ) ) . "<br>\r\n";
754
  } // foreach $feature
755
-
756
  return $value;
757
  }
758
-
759
  /**
760
  * Supply the content for a custom column
761
  *
@@ -765,21 +786,23 @@ class MLA_List_Table extends WP_List_Table {
765
  * @return string HTML markup to be placed inside the column
766
  */
767
  function column_inserted( $item ) {
768
- if ( !MLAOptions::$process_inserted_in )
769
- return 'disabled';
770
-
 
771
  $value = '';
772
-
773
  foreach ( $item->mla_references['inserts'] as $file => $inserts ) {
774
  $value .= sprintf( '<strong>%1$s</strong><br>', $file );
775
-
776
  foreach ( $inserts as $insert ) {
777
- if ( $insert->ID == $item->post_parent )
778
- $parent = ',<br>PARENT';
779
- else
780
  $parent = '';
781
-
782
- $value .= sprintf( '(%1$s %2$s%3$s), <a href="%4$s" title="Edit &#8220;%5$s&#8221;">%6$s</a>',
 
783
  /*%1$s*/ esc_attr( $insert->post_type ),
784
  /*%2$s*/ $insert->ID,
785
  /*%3$s*/ $parent,
@@ -788,10 +811,10 @@ class MLA_List_Table extends WP_List_Table {
788
  /*%6$s*/ esc_attr( $insert->post_title ) ) . "<br>\r\n";
789
  } // foreach $insert
790
  } // foreach $file
791
-
792
  return $value;
793
  }
794
-
795
  /**
796
  * Supply the content for a custom column
797
  *
@@ -801,18 +824,20 @@ class MLA_List_Table extends WP_List_Table {
801
  * @return string HTML markup to be placed inside the column
802
  */
803
  function column_galleries( $item ) {
804
- if ( !MLAOptions::$process_gallery_in )
805
- return 'disabled';
806
-
 
807
  $value = '';
808
-
809
  foreach ( $item->mla_references['galleries'] as $ID => $gallery ) {
810
- if ( $ID == $item->post_parent )
811
- $parent = ',<br>PARENT';
812
- else
813
  $parent = '';
814
-
815
- $value .= sprintf( '(%1$s %2$s%3$s), <a href="%4$s" title="Edit &#8220;%5$s&#8221;">%6$s</a>',
 
816
  /*%1$s*/ esc_attr( $gallery['post_type'] ),
817
  /*%2$s*/ $ID,
818
  /*%3$s*/ $parent,
@@ -820,10 +845,10 @@ class MLA_List_Table extends WP_List_Table {
820
  /*%5$s*/ esc_attr( $gallery['post_title'] ),
821
  /*%6$s*/ esc_attr( $gallery['post_title'] ) ) . "<br>\r\n";
822
  } // foreach $gallery
823
-
824
  return $value;
825
  }
826
-
827
  /**
828
  * Supply the content for a custom column
829
  *
@@ -833,18 +858,20 @@ class MLA_List_Table extends WP_List_Table {
833
  * @return string HTML markup to be placed inside the column
834
  */
835
  function column_mla_galleries( $item ) {
836
- if ( !MLAOptions::$process_mla_gallery_in )
837
- return 'disabled';
838
-
 
839
  $value = '';
840
-
841
  foreach ( $item->mla_references['mla_galleries'] as $ID => $gallery ) {
842
- if ( $ID == $item->post_parent )
843
- $parent = ',<br>PARENT ';
844
- else
845
  $parent = '';
846
-
847
- $value .= sprintf( '(%1$s %2$s%3$s), <a href="%4$s" title="Edit &#8220;%5$s&#8221;">%6$s</a>',
 
848
  /*%1$s*/ esc_attr( $gallery['post_type'] ),
849
  /*%2$s*/ $ID,
850
  /*%3$s*/ $parent,
@@ -852,10 +879,10 @@ class MLA_List_Table extends WP_List_Table {
852
  /*%5$s*/ esc_attr( $gallery['post_title'] ),
853
  /*%6$s*/ esc_attr( $gallery['post_title'] ) ) . "<br>\r\n";
854
  } // foreach $gallery
855
-
856
  return $value;
857
  }
858
-
859
  /**
860
  * Supply the content for a custom column
861
  *
@@ -865,17 +892,18 @@ class MLA_List_Table extends WP_List_Table {
865
  * @return string HTML markup to be placed inside the column
866
  */
867
  function column_alt_text( $item ) {
868
- if ( isset( $item->mla_wp_attachment_image_alt ) )
869
- return sprintf( '<a href="%1$s" title="Filter by &#8220;%2$s&#8221;">%3$s</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
870
  'page' => MLA::ADMIN_PAGE_SLUG,
871
  'mla-metakey' => '_wp_attachment_image_alt',
872
  'mla-metavalue' => urlencode( $item->mla_wp_attachment_image_alt ),
873
- 'heading_suffix' => urlencode( 'ALT Text: ' . $item->mla_wp_attachment_image_alt )
874
  ) ), 'upload.php' ) ), esc_html( $item->mla_wp_attachment_image_alt ), esc_html( $item->mla_wp_attachment_image_alt ) );
875
- else
876
- return '';
 
877
  }
878
-
879
  /**
880
  * Supply the content for a custom column
881
  *
@@ -887,7 +915,7 @@ class MLA_List_Table extends WP_List_Table {
887
  function column_caption( $item ) {
888
  return esc_attr( $item->post_excerpt );
889
  }
890
-
891
  /**
892
  * Supply the content for a custom column
893
  *
@@ -899,7 +927,7 @@ class MLA_List_Table extends WP_List_Table {
899
  function column_description( $item ) {
900
  return esc_textarea( $item->post_content );
901
  }
902
-
903
  /**
904
  * Supply the content for a custom column
905
  *
@@ -909,13 +937,13 @@ class MLA_List_Table extends WP_List_Table {
909
  * @return string HTML markup to be placed inside the column
910
  */
911
  function column_post_mime_type( $item ) {
912
- return sprintf( '<a href="%1$s" title="Filter by &#8220;%2$s&#8221;">%2$s</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
913
  'page' => MLA::ADMIN_PAGE_SLUG,
914
  'post_mime_type' => urlencode( $item->post_mime_type ),
915
- 'heading_suffix' => urlencode( 'MIME Type: ' . $item->post_mime_type )
916
  ) ), 'upload.php' ) ), esc_html( $item->post_mime_type ), esc_html( $item->post_mime_type ) );
917
  }
918
-
919
  /**
920
  * Supply the content for a custom column
921
  *
@@ -927,9 +955,9 @@ class MLA_List_Table extends WP_List_Table {
927
  function column_file_url( $item ) {
928
  $attachment_url = wp_get_attachment_url( $item->ID );
929
 
930
- return $attachment_url ? $attachment_url : 'none';
931
  }
932
-
933
  /**
934
  * Supply the content for a custom column
935
  *
@@ -941,7 +969,7 @@ class MLA_List_Table extends WP_List_Table {
941
  function column_base_file( $item ) {
942
  return $item->mla_references['base_file'];
943
  }
944
-
945
  /**
946
  * Supply the content for a custom column
947
  *
@@ -952,25 +980,28 @@ class MLA_List_Table extends WP_List_Table {
952
  */
953
  function column_date( $item ) {
954
  if ( '0000-00-00 00:00:00' == $item->post_date ) {
955
- $t_time = $h_time = __( 'Unpublished' );
956
  } else {
957
- $t_time = get_the_time( __( 'Y/m/d g:i:s A' ), $item );
958
  $m_time = $item->post_date;
959
  $time = get_post_time( 'G', true, $item, false );
960
-
961
  if ( ( abs( $t_diff = time() - $time ) ) < 86400 ) {
962
- if ( $t_diff < 0 )
963
- $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
964
- else
965
- $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
 
 
 
966
  } else {
967
- $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
 
968
  }
969
  }
970
-
971
  return $h_time;
972
  }
973
-
974
  /**
975
  * Supply the content for a custom column
976
  *
@@ -981,25 +1012,25 @@ class MLA_List_Table extends WP_List_Table {
981
  */
982
  function column_modified( $item ) {
983
  if ( '0000-00-00 00:00:00' == $item->post_modified ) {
984
- $t_time = $h_time = __( 'Unpublished' );
985
  } else {
986
- $t_time = get_the_time( __( 'Y/m/d g:i:s A' ), $item );
987
  $m_time = $item->post_modified;
988
  $time = get_post_time( 'G', true, $item, false );
989
-
990
  if ( ( abs( $t_diff = time() - $time ) ) < 86400 ) {
991
- if ( $t_diff < 0 )
992
- $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
993
- else
994
- $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
 
995
  } else {
996
- $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
997
  }
998
  }
999
-
1000
  return $h_time;
1001
  }
1002
-
1003
  /**
1004
  * Supply the content for a custom column
1005
  *
@@ -1010,17 +1041,18 @@ class MLA_List_Table extends WP_List_Table {
1010
  */
1011
  function column_author( $item ) {
1012
  $user = get_user_by( 'id', $item->post_author );
1013
-
1014
- if ( isset( $user->data->display_name ) )
1015
- return sprintf( '<a href="%s" title="Filter by Author ID">%s</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
1016
  'page' => MLA::ADMIN_PAGE_SLUG,
1017
  'author' => $item->post_author,
1018
- 'heading_suffix' => urlencode( 'Author: ' . $user->data->display_name )
1019
  ) ), 'upload.php' ) ), esc_html( $user->data->display_name ) );
1020
- else
1021
- return 'unknown';
 
1022
  }
1023
-
1024
  /**
1025
  * Supply the content for a custom column
1026
  *
@@ -1030,27 +1062,30 @@ class MLA_List_Table extends WP_List_Table {
1030
  * @return string HTML markup to be placed inside the column
1031
  */
1032
  function column_attached_to( $item ) {
1033
- if ( isset( $item->parent_date ) )
1034
  $parent_date = $item->parent_date;
1035
- else
1036
  $parent_date = '';
1037
-
1038
- if ( isset( $item->parent_title ) )
1039
- $parent_title = sprintf( '<a href="%1$s" title="Edit &#8220;%2$s&#8221;">%3$s</a>', esc_url( add_query_arg( array(
 
1040
  'post' => $item->post_parent,
1041
  'action' => 'edit'
1042
  ), 'post.php' ) ), esc_attr( $item->parent_title ), esc_attr( $item->parent_title ) );
1043
- else
1044
- $parent_title = '(Unattached)';
1045
-
1046
- if ( isset( $item->parent_type ) )
 
1047
  $parent_type = '(' . $item->parent_type . ' ' . (string) $item->post_parent . ')';
1048
- else
1049
  $parent_type = '';
1050
-
1051
- return sprintf( '%1$s<br>%2$s<br>%3$s', /*%1$s*/ $parent_title, /*%2$s*/ mysql2date( __( 'Y/m/d' ), $parent_date ), /*%3$s*/ $parent_type ) . "<br>\r\n";
 
1052
  }
1053
-
1054
  /**
1055
  * Process $_REQUEST, building $submenu_arguments
1056
  *
@@ -1062,29 +1097,33 @@ class MLA_List_Table extends WP_List_Table {
1062
  */
1063
  public static function mla_submenu_arguments( $include_filters = true ) {
1064
  static $submenu_arguments = NULL, $has_filters = NULL;
1065
-
1066
- if ( is_array( $submenu_arguments ) && ( $has_filters == $include_filters ) )
1067
  return $submenu_arguments;
1068
- else {
1069
  $submenu_arguments = array();
1070
  $has_filters = $include_filters;
1071
  }
1072
-
1073
  /*
1074
  * View arguments
1075
  */
1076
- if ( isset( $_REQUEST['post_mime_type'] ) )
1077
  $submenu_arguments['post_mime_type'] = $_REQUEST['post_mime_type'];
1078
-
1079
- if ( isset( $_REQUEST['detached'] ) )
 
1080
  $submenu_arguments['detached'] = $_REQUEST['detached'];
1081
-
1082
- if ( isset( $_REQUEST['status'] ) )
 
1083
  $submenu_arguments['status'] = $_REQUEST['status'];
1084
-
1085
- if ( isset( $_REQUEST['meta_query'] ) )
 
1086
  $submenu_arguments['meta_query'] = $_REQUEST['meta_query'];
1087
-
 
1088
  /*
1089
  * Search box arguments
1090
  */
@@ -1093,54 +1132,65 @@ class MLA_List_Table extends WP_List_Table {
1093
  $submenu_arguments['mla_search_connector'] = $_REQUEST['mla_search_connector'];
1094
  $submenu_arguments['mla_search_fields'] = $_REQUEST['mla_search_fields'];
1095
  }
1096
-
1097
  /*
1098
  * Filter arguments (from table header)
1099
  */
1100
- if ( isset( $_REQUEST['m'] ) && ( '0' != $_REQUEST['m'] ) )
1101
  $submenu_arguments['m'] = $_REQUEST['m'];
1102
-
1103
- if ( isset( $_REQUEST['mla_filter_term'] ) && ( '0' != $_REQUEST['mla_filter_term'] ) )
 
1104
  $submenu_arguments['mla_filter_term'] = $_REQUEST['mla_filter_term'];
1105
-
 
1106
  /*
1107
  * Sort arguments (from column header)
1108
  */
1109
- if ( isset( $_REQUEST['order'] ) )
1110
  $submenu_arguments['order'] = $_REQUEST['order'];
1111
-
1112
- if ( isset( $_REQUEST['orderby'] ) )
 
1113
  $submenu_arguments['orderby'] = $_REQUEST['orderby'];
1114
-
 
1115
  /*
1116
  * Filter arguments (from interior table cells)
1117
  */
1118
  if ( $include_filters ) {
1119
- if ( isset( $_REQUEST['heading_suffix'] ) )
1120
  $submenu_arguments['heading_suffix'] = $_REQUEST['heading_suffix'];
1121
-
1122
- if ( isset( $_REQUEST['parent'] ) )
 
1123
  $submenu_arguments['parent'] = $_REQUEST['parent'];
1124
-
1125
- if ( isset( $_REQUEST['author'] ) )
 
1126
  $submenu_arguments['author'] = $_REQUEST['author'];
1127
-
1128
- if ( isset( $_REQUEST['mla-tax'] ) )
 
1129
  $submenu_arguments['mla-tax'] = $_REQUEST['mla-tax'];
1130
-
1131
- if ( isset( $_REQUEST['mla-term'] ) )
 
1132
  $submenu_arguments['mla-term'] = $_REQUEST['mla-term'];
1133
-
1134
- if ( isset( $_REQUEST['mla-metakey'] ) )
 
1135
  $submenu_arguments['mla-metakey'] = $_REQUEST['mla-metakey'];
1136
-
1137
- if ( isset( $_REQUEST['mla-metavalue'] ) )
 
1138
  $submenu_arguments['mla-metavalue'] = $_REQUEST['mla-metavalue'];
 
1139
  }
1140
-
1141
  return $submenu_arguments;
1142
  }
1143
-
1144
  /**
1145
  * Display the pagination, adding view, search and filter arguments
1146
  *
@@ -1155,7 +1205,7 @@ class MLA_List_Table extends WP_List_Table {
1155
  parent::pagination( $which );
1156
  $_SERVER['REQUEST_URI'] = $save_uri;
1157
  }
1158
-
1159
  /**
1160
  * This method dictates the table's columns and titles
1161
  *
@@ -1166,7 +1216,7 @@ class MLA_List_Table extends WP_List_Table {
1166
  function get_columns( ) {
1167
  return $columns = MLA_List_Table::mla_manage_columns_filter();
1168
  }
1169
-
1170
  /**
1171
  * Returns the list of currently hidden columns from a user option or
1172
  * from default values if the option is not set
@@ -1179,12 +1229,13 @@ class MLA_List_Table extends WP_List_Table {
1179
  {
1180
  $columns = get_user_option( 'managemedia_page_' . MLA::ADMIN_PAGE_SLUG . 'columnshidden' );
1181
 
1182
- if ( is_array( $columns ) )
1183
  return $columns;
1184
- else
1185
- return self::_default_hidden_columns();
 
1186
  }
1187
-
1188
  /**
1189
  * Returns an array where the key is the column that needs to be sortable
1190
  * and the value is db column to sort by. Also notes the current sort column,
@@ -1197,7 +1248,7 @@ class MLA_List_Table extends WP_List_Table {
1197
  */
1198
  function get_sortable_columns( ) {
1199
  $columns = MLA_List_Table::$default_sortable_columns;
1200
-
1201
  if ( isset( $_REQUEST['orderby'] ) ) {
1202
  $needle = array(
1203
  $_REQUEST['orderby'],
@@ -1227,7 +1278,7 @@ class MLA_List_Table extends WP_List_Table {
1227
  parent::print_column_headers( $with_id );
1228
  $_SERVER['REQUEST_URI'] = $save_uri;
1229
  }
1230
-
1231
  /**
1232
  * Returns HTML markup for one view that can be used with this table
1233
  *
@@ -1241,27 +1292,31 @@ class MLA_List_Table extends WP_List_Table {
1241
  function _get_view( $view_slug, $current_view ) {
1242
  global $wpdb;
1243
  static $mla_types = NULL, $posts_per_type, $post_mime_types, $avail_post_mime_types, $matches, $num_posts;
1244
-
1245
  /*
1246
  * Calculate the common values once per page load
1247
  */
1248
  if ( is_null( $mla_types ) ) {
1249
  $query_types = MLAMime::mla_query_view_items( array( 'orderby' => 'menu_order' ), 0, 0 );
1250
- if ( ! is_array( $query_types ) )
1251
  $query_types = array ();
1252
-
 
1253
  $mla_types = array ();
1254
- foreach ( $query_types as $value )
1255
  $mla_types[ $value->slug ] = $value;
 
1256
 
1257
  $posts_per_type = (array) wp_count_attachments();
1258
  $post_mime_types = get_post_mime_types();
1259
  $avail_post_mime_types = $this->_avail_mime_types( $posts_per_type );
1260
  $matches = wp_match_mime_types( array_keys( $post_mime_types ), array_keys( $posts_per_type ) );
1261
 
1262
- foreach ( $matches as $type => $reals )
1263
- foreach ( $reals as $real )
1264
  $num_posts[ $type ] = ( isset( $num_posts[ $type ] ) ) ? $num_posts[ $type ] + $posts_per_type[ $real ] : $posts_per_type[ $real ];
 
 
1265
  }
1266
 
1267
  $class = ( $view_slug == $current_view ) ? ' class="current"' : '';
@@ -1273,7 +1328,7 @@ class MLA_List_Table extends WP_List_Table {
1273
  switch( $view_slug ) {
1274
  case 'all':
1275
  $total_items = array_sum( $posts_per_type ) - $posts_per_type['trash'];
1276
- return "<a href='{$base_url}'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_items, 'uploaded files' ), number_format_i18n( $total_items ) ) . '</a>';
1277
  case 'unattached':
1278
  $total_items = $wpdb->get_var(
1279
  "
@@ -1282,64 +1337,76 @@ class MLA_List_Table extends WP_List_Table {
1282
  "
1283
  );
1284
 
1285
- if ( $total_items )
1286
- return '<a href="' . add_query_arg( array( 'detached' => '1' ), $base_url ) . '"' . $class . '>' . sprintf( _nx( 'Unattached <span class="count">(%s)</span>', 'Unattached <span class="count">(%s)</span>', $total_items, 'detached files' ), number_format_i18n( $total_items ) ) . '</a>';
1287
- else
1288
- return false;
 
 
 
 
1289
  case 'trash':
1290
- if ( $posts_per_type['trash'] )
 
 
 
1291
  return '<a href="' . add_query_arg( array(
1292
  'status' => 'trash'
1293
- ), $base_url ) . '"' . $class . '>' . sprintf( _nx( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', $posts_per_type['trash'], 'uploaded files' ), number_format_i18n( $posts_per_type['trash'] ) ) . '</a>';
1294
- else
1295
- return false;
 
1296
  } // switch special cases
1297
 
1298
  /*
1299
  * Make sure the slug is in our list
1300
  */
1301
- if ( array_key_exists( $view_slug, $mla_types ) )
1302
  $mla_type = $mla_types[ $view_slug ];
1303
- else
1304
  return false;
1305
-
 
1306
  /*
1307
  * Handle post_mime_types
1308
  */
1309
  if ( $mla_type->post_mime_type ) {
1310
- if ( !empty( $num_posts[ $view_slug ] ) )
1311
  return "<a href='" . add_query_arg( array(
1312
  'post_mime_type' => $view_slug
1313
- ), $base_url ) . "'$class>" . sprintf( translate_nooped_plural( $post_mime_types[ $view_slug ][ 2 ], $num_posts[ $view_slug ] ), number_format_i18n( $num_posts[ $view_slug ] ) ) . '</a>';
1314
- else
1315
- return false;
 
1316
  }
1317
 
1318
  /*
1319
  * Handle extended specification types
1320
  */
1321
- if ( empty( $mla_type->specification ) )
1322
  $query = array ( 'post_mime_type' => $view_slug );
1323
- else
1324
  $query = MLAMime::mla_prepare_view_query( $view_slug, $mla_type->specification );
1325
-
 
1326
  $total_items = MLAData::mla_count_list_table_items( $query );
1327
  if ( $total_items ) {
1328
  $singular = sprintf('%s <span class="count">(%%s)</span>', $mla_type->singular );
1329
  $plural = sprintf('%s <span class="count">(%%s)</span>', $mla_type->plural );
1330
- $nooped_plural = _n_noop( $singular, $plural );
1331
-
1332
- if ( isset( $query['post_mime_type'] ) )
1333
  $query['post_mime_type'] = urlencode( $query['post_mime_type'] );
1334
- else
1335
  $query['meta_query'] = urlencode( serialize( $query['meta_query'] ) );
 
1336
 
1337
- return "<a href='" . add_query_arg( $query, $base_url ) . "'$class>" . sprintf( translate_nooped_plural( $nooped_plural, $total_items ), number_format_i18n( $total_items ) ) . '</a>';
1338
  }
1339
 
1340
  return false;
1341
  } // _get_view
1342
-
1343
  /**
1344
  * Returns an associative array listing all the views that can be used with this table.
1345
  * These are listed across the top of the page and managed by WordPress.
@@ -1352,42 +1419,45 @@ class MLA_List_Table extends WP_List_Table {
1352
  /*
1353
  * Find current view
1354
  */
1355
- if ( $this->detached )
1356
  $current_view = 'unattached';
1357
- elseif ( $this->is_trash )
1358
  $current_view = 'trash';
1359
- elseif ( empty( $_REQUEST['post_mime_type'] ) ) {
1360
  if ( isset( $_REQUEST['meta_query'] ) ) {
1361
  $query = unserialize( stripslashes( $_REQUEST['meta_query'] ) );
1362
  $current_view = $query['slug'];
1363
- }
1364
- else
1365
  $current_view = 'all';
1366
- }
1367
- else
1368
  $current_view = $_REQUEST['post_mime_type'];
1369
-
 
1370
  $mla_types = MLAMime::mla_query_view_items( array( 'orderby' => 'menu_order' ), 0, 0 );
1371
- if ( ! is_array( $mla_types ) )
1372
  $mla_types = array ();
1373
-
 
1374
  /*
1375
  * Filter the list, generate the views
1376
  */
1377
  $view_links = array();
1378
  foreach ( $mla_types as $value ) {
1379
  if ( $value->table_view ) {
1380
- if ( $current_view == $value->specification )
1381
  $current_view = $value->slug;
1382
-
1383
- if ( $link = self::_get_view( $value->slug, $current_view ) )
 
1384
  $view_links[ $value->slug ] = $link;
 
1385
  }
1386
  }
1387
 
1388
  return $view_links;
1389
  }
1390
-
1391
  /**
1392
  * Get an associative array ( option_name => option_title ) with the list
1393
  * of bulk actions available on this table.
@@ -1399,23 +1469,23 @@ class MLA_List_Table extends WP_List_Table {
1399
  function get_bulk_actions( )
1400
  {
1401
  $actions = array();
1402
-
1403
  if ( $this->is_trash ) {
1404
- $actions['restore'] = 'Restore';
1405
- $actions['delete'] = 'Delete Permanently';
1406
  } else {
1407
- $actions['edit'] = 'Edit';
1408
- // $actions['attach'] = 'Attach';
1409
-
1410
- if ( EMPTY_TRASH_DAYS && MEDIA_TRASH )
1411
- $actions['trash'] = 'Move to Trash';
1412
- else
1413
- $actions['delete'] = 'Delete Permanently';
1414
  }
1415
-
1416
  return $actions;
1417
  }
1418
-
1419
  /**
1420
  * Extra controls to be displayed between bulk actions and pagination
1421
  *
@@ -1430,28 +1500,28 @@ class MLA_List_Table extends WP_List_Table {
1430
  function extra_tablenav( $which )
1431
  {
1432
  echo ( '<div class="alignleft actions">' );
1433
-
1434
  if ( 'top' == $which ) {
1435
  $this->months_dropdown( 'attachment' );
1436
-
1437
  echo self::mla_get_taxonomy_filter_dropdown( isset( $_REQUEST['mla_filter_term'] ) ? $_REQUEST['mla_filter_term'] : 0 );
1438
-
1439
- submit_button( __( 'Filter' ), 'secondary', 'mla_filter', false, array(
1440
  'id' => 'post-query-submit'
1441
  ) );
1442
  }
1443
-
1444
  if ( self::mla_submenu_arguments( true ) != self::mla_submenu_arguments( false ) ) {
1445
- submit_button( __( 'Clear Filter-by' ), 'button apply', 'clear_filter_by', false );
1446
  }
1447
-
1448
  if ( $this->is_trash && current_user_can( 'edit_others_posts' ) ) {
1449
- submit_button( __( 'Empty Trash' ), 'button apply', 'delete_all', false );
1450
  }
1451
-
1452
  echo ( '</div>' );
1453
  }
1454
-
1455
  /**
1456
  * Prepares the list of items for displaying
1457
  *
@@ -1470,7 +1540,7 @@ class MLA_List_Table extends WP_List_Table {
1470
  $this->get_hidden_columns(),
1471
  $this->get_sortable_columns()
1472
  );
1473
-
1474
  /*
1475
  * REQUIRED for pagination.
1476
  */
@@ -1491,7 +1561,7 @@ class MLA_List_Table extends WP_List_Table {
1491
  */
1492
  $total_items = MLAData::mla_count_list_table_items( $_REQUEST, ( ( $current_page - 1 ) * $per_page ), $per_page );
1493
  $this->items = MLAData::mla_query_list_table_items( $_REQUEST, ( ( $current_page - 1 ) * $per_page ), $per_page );
1494
-
1495
  /*
1496
  * REQUIRED. We also have to register our pagination options & calculations.
1497
  */
@@ -1501,7 +1571,7 @@ class MLA_List_Table extends WP_List_Table {
1501
  'total_pages' => ceil( $total_items / $per_page ) //WE have to calculate the total number of pages
1502
  ) );
1503
  }
1504
-
1505
  /**
1506
  * Generates (echoes) content for a single row of the table
1507
  *
47
  * @var array
48
  */
49
  private $currently_hidden = array();
50
+
51
  /*
52
+ * The $default_columns, $default_hidden_columns, and $default_sortable_columns
53
+ * arrays define the table columns.
54
  */
55
+
56
  /**
57
  * Table column definitions
58
  *
64
  * column in your table you must create a column_cb() method. If you don't need
65
  * bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
66
  *
67
+ * All of the columns are added to this array by MLA_List_Table::mla_admin_init_action.
68
+ *
 
69
  * @since 0.1
70
  *
71
  * @var array
72
  */
73
+ private static $default_columns = array();
74
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  /**
76
  * Default values for hidden columns
77
  *
81
  * The value on the right-hand side must match the column slug, e.g.,
82
  * array(0 => 'ID_parent, 1 => 'title_name').
83
  *
84
+ * Taxonomy and custom field columns are added to this array by
85
+ * MLA_List_Table::mla_admin_init_action.
86
  *
87
  * @since 0.1
88
  *
112
  // taxonomy columns added by mla_admin_init_action
113
  // custom field columns added by mla_admin_init_action
114
  );
115
+
116
  /**
117
  * Sortable column definitions
118
  *
124
  * The array value also contains a boolean which is 'true' if the data is currently
125
  * sorted by that column. This is computed each time the table is displayed.
126
  *
127
+ * Taxonomy and custom field columns are added to this array by
128
+ * MLA_List_Table::mla_admin_init_action.
129
  *
130
  * @since 0.1
131
  *
166
  private static function _default_hidden_columns( ) {
167
  return MLA_List_Table::$default_hidden_columns;
168
  }
169
+
170
  /**
171
  * Get MIME types with one or more attachments for view preparation
172
  *
181
  */
182
  private function _avail_mime_types( $num_posts ) {
183
  $available = array();
184
+
185
  foreach ( $num_posts as $mime_type => $number ) {
186
+ if ( ( $number > 0 ) && ( $mime_type <> 'trash' ) ) {
187
  $available[ ] = $mime_type;
188
+ }
189
  }
190
+
191
  return $available;
192
  }
193
+
194
  /**
195
  * Get dropdown box of terms to filter by, if available
196
  *
203
  public static function mla_get_taxonomy_filter_dropdown( $selected = 0 ) {
204
  $dropdown = '';
205
  $tax_filter = MLAOptions::mla_taxonomy_support('', 'filter');
206
+
207
  if ( ( '' != $tax_filter ) && ( is_object_in_taxonomy( 'attachment', $tax_filter ) ) ) {
208
  $tax_object = get_taxonomy( $tax_filter );
209
  $dropdown_options = array(
210
+ 'show_option_all' => __( 'All', 'media-library-assistant' ) . ' ' . $tax_object->labels->name,
211
+ 'show_option_none' => __( 'No', 'media-library-assistant' ) . ' ' . $tax_object->labels->name,
212
  'orderby' => 'name',
213
  'order' => 'ASC',
214
  'show_count' => false,
228
  'taxonomy' => $tax_filter,
229
  'hide_if_empty' => false
230
  );
231
+
232
  ob_start();
233
  wp_dropdown_categories( $dropdown_options );
234
  $dropdown = ob_get_contents();
235
  ob_end_clean();
236
  }
237
+
238
  return $dropdown;
239
  }
240
+
241
  /**
242
  * Return the names and display values of the sortable columns
243
  *
248
  public static function mla_get_sortable_columns( )
249
  {
250
  $results = array() ;
251
+
252
  foreach ( MLA_List_Table::$default_sortable_columns as $key => $value ) {
253
  $value[1] = MLA_List_Table::$default_columns[ $key ];
254
  $results[ $key ] = $value;
255
  }
256
+
257
  return $results;
258
  }
259
+
260
  /**
261
  * Handler for filter 'get_user_option_managemedia_page_mla-menucolumnshidden'
262
  *
273
  * @return array updated list of hidden columns
274
  */
275
  public static function mla_manage_hidden_columns_filter( $result, $option, $user_data ) {
276
+ if ( $result ) {
277
  return $result;
278
+ }
279
+
280
+ return self::_default_hidden_columns();
281
  }
282
+
283
  /**
284
  * Handler for filter 'manage_media_page_mla-menu_columns'
285
  *
295
  {
296
  return MLA_List_Table::$default_columns;
297
  }
298
+
299
  /**
300
  * Adds support for taxonomy and custom field columns
301
  *
308
  */
309
  public static function mla_admin_init_action( )
310
  {
311
+ /*
312
+ * Build the default columns array at runtime to accomodate calls to the localization functions
313
+ */
314
+
315
+ self::$default_columns = array(
316
+ 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
317
+ 'icon' => '',
318
+ 'ID_parent' => _x( 'ID/Parent', 'list_table_column', 'media-library-assistant' ),
319
+ 'title_name' => _x( 'Title/Name', 'list_table_column', 'media-library-assistant' ),
320
+ 'post_title' => _x( 'Title', 'list_table_column', 'media-library-assistant' ),
321
+ 'post_name' => _x( 'Name', 'list_table_column', 'media-library-assistant' ),
322
+ 'parent' => _x( 'Parent ID', 'list_table_column', 'media-library-assistant' ),
323
+ 'menu_order' => _x( 'Menu Order', 'list_table_column', 'media-library-assistant' ),
324
+ 'featured' => _x( 'Featured in', 'list_table_column', 'media-library-assistant' ),
325
+ 'inserted' => _x( 'Inserted in', 'list_table_column', 'media-library-assistant' ),
326
+ 'galleries' => _x( 'Gallery in', 'list_table_column', 'media-library-assistant' ),
327
+ 'mla_galleries' => _x( 'MLA Gallery in', 'list_table_column', 'media-library-assistant' ),
328
+ 'alt_text' => _x( 'ALT Text', 'list_table_column', 'media-library-assistant' ),
329
+ 'caption' => _x( 'Caption', 'list_table_column', 'media-library-assistant' ),
330
+ 'description' => _x( 'Description', 'list_table_column', 'media-library-assistant' ),
331
+ 'post_mime_type' => _x( 'MIME Type', 'list_table_column', 'media-library-assistant' ),
332
+ 'file_url' => _x( 'File URL', 'list_table_column', 'media-library-assistant' ),
333
+ 'base_file' => _x( 'Base File', 'list_table_column', 'media-library-assistant' ),
334
+ 'date' => _x( 'Date', 'list_table_column', 'media-library-assistant' ),
335
+ 'modified' => _x( 'Last Modified', 'list_table_column', 'media-library-assistant' ),
336
+ 'author' => _x( 'Author', 'list_table_column', 'media-library-assistant' ),
337
+ 'attached_to' => _x( 'Attached to', 'list_table_column', 'media-library-assistant' ),
338
+ // taxonomy and custom field columns added below
339
+ );
340
+
341
  $taxonomies = get_taxonomies( array ( 'show_ui' => true ), 'names' );
342
 
343
  foreach ( $taxonomies as $tax_name ) {
348
  // MLA_List_Table::$default_sortable_columns [] = none at this time
349
  } // supported taxonomy
350
  } // foreach $tax_name
351
+
352
  MLA_List_Table::$default_columns = array_merge( MLA_List_Table::$default_columns, MLAOptions::mla_custom_field_support( 'default_columns' ) );
353
  MLA_List_Table::$default_hidden_columns = array_merge( MLA_List_Table::$default_hidden_columns, MLAOptions::mla_custom_field_support( 'default_hidden_columns' ) );
354
  MLA_List_Table::$default_sortable_columns = array_merge( MLA_List_Table::$default_sortable_columns, MLAOptions::mla_custom_field_support( 'default_sortable_columns' ) );
355
  }
356
+
357
  /**
358
  * Initializes some properties from $_REQUEST variables, then
359
  * calls the parent constructor to set some default configs.
365
  function __construct( ) {
366
  $this->detached = isset( $_REQUEST['detached'] );
367
  $this->is_trash = isset( $_REQUEST['status'] ) && $_REQUEST['status'] == 'trash';
368
+
369
  //Set parent defaults
370
  parent::__construct( array(
371
  'singular' => 'attachment', //singular name of the listed records
372
  'plural' => 'attachments', //plural name of the listed records
373
  'ajax' => true, //does this table support ajax?
374
  'screen' => 'media_page_' . MLA::ADMIN_PAGE_SLUG
375
+ ), self::$default_columns );
376
+
377
  $this->currently_hidden = self::get_hidden_columns();
378
+
379
  /*
380
  * NOTE: There is one add_action call at the end of this source file.
381
  * NOTE: There are two add_filter calls at the end of this source file.
382
+ *
383
+ * Filters are added when the source file is loaded because the MLA_List_Table
384
+ * object is created too late to be useful.
385
  */
386
  }
387
+
388
  /**
389
  * Supply a column value if no column-specific function has been defined
390
  *
403
  $taxonomy = substr( $column_name, 2 );
404
  $tax_object = get_taxonomy( $taxonomy );
405
  $terms = wp_get_object_terms( $item->ID, $taxonomy );
406
+
407
  if ( !is_wp_error( $terms ) ) {
408
+ if ( empty( $terms ) ) {
409
+ return __( 'None', 'media-library-assistant' );
410
+ }
411
 
412
  $list = array();
413
  foreach ( $terms as $term ) {
414
  $term_name = esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'category', 'display' ) );
415
+ $list[ ] = sprintf( '<a href="%1$s" title="' . __( 'Filter by', 'media-library-assistant' ) . ' &#8220;%2$s&#8221;">%3$s</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
416
  'page' => MLA::ADMIN_PAGE_SLUG,
417
  'mla-tax' => $taxonomy,
418
  'mla-term' => $term->slug,
419
  'heading_suffix' => urlencode( $tax_object->label . ': ' . $term->name )
420
  ) ), 'upload.php' ) ), $term_name, $term_name );
421
  } // foreach $term
422
+
423
  return join( ', ', $list );
424
+ } else { // if !is_wp_error
425
+ return __( 'not supported', 'media-library-assistant' );
 
426
  }
427
  } // 't_'
428
  elseif ( 'c_' == substr( $column_name, 0, 2 ) ) {
429
  $values = get_post_meta( $item->ID, MLA_List_Table::$default_columns[ $column_name ], false );
430
+ if ( empty( $values ) ) {
431
  return '';
432
+ }
433
+
434
  $list = array();
435
  foreach ( $values as $index => $value ) {
436
  /*
437
  * For display purposes, convert array values.
438
  * They are not links because no search will match them.
439
  */
440
+ if ( is_array( $value ) ) {
441
  $list[ ] = 'array( ' . implode( ', ', $value ) . ' )';
442
+ } else {
443
+ $list[ ] = sprintf( '<a href="%1$s" title="' . __( 'Filter by', 'media-library-assistant' ) . ' &#8220;%2$s&#8221;">%3$s</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
444
  'page' => MLA::ADMIN_PAGE_SLUG,
445
  'mla-metakey' => urlencode( MLA_List_Table::$default_columns[ $column_name ] ),
446
  'mla-metavalue' => urlencode( $value ),
447
  'heading_suffix' => urlencode( MLA_List_Table::$default_columns[ $column_name ] . ': ' . $value )
448
  ) ), 'upload.php' ) ), esc_html( substr( $value, 0, 64 ) ), esc_html( $value ) );
449
+ }
450
  }
451
 
452
+ if ( count( $list ) > 1 ) {
453
  return '[' . join( '], [', $list ) . ']';
454
+ } else {
455
  return $list[0];
456
+ }
457
+ } else { // 'c_'
458
  //Show the whole array for troubleshooting purposes
459
+ /* translators: 1: column_name 2: column_values */
460
+ return sprintf( __( 'column_default: %1$s, %2$s', 'media-library-assistant' ), $column_name, print_r( $item, true ) );
461
  }
462
  }
463
+
464
  /**
465
  * Displays checkboxes for using bulk actions. The 'cb' column
466
  * is given special treatment when columns are processed.
477
  /*%2$s*/ $item->ID //The value of the checkbox should be the object's id
478
  );
479
  }
480
+
481
  /**
482
  * Supply the content for a custom column
483
  *
488
  */
489
  function column_icon( $item )
490
  {
491
+ if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) ) {
492
  $thumb = wp_get_attachment_image( $item->ID, array( 64, 64 ), true, array( 'class' => 'mla_media_thumbnail_64_64' ) );
493
+ } else {
494
  $thumb = wp_get_attachment_image( $item->ID, array( 80, 60 ), true, array( 'class' => 'mla_media_thumbnail_80_60' ) );
495
+ }
496
 
497
+ if ( $this->is_trash || ! current_user_can( 'edit_post', $item->ID ) ) {
498
  return $thumb;
 
 
499
  }
500
+
501
+ return sprintf( '<a href="%1$s" title="' . __( 'Edit', 'media-library-assistant' ) . ' &#8220;%2$s&#8221;">%3$s</a>', get_edit_post_link( $item->ID, true ), esc_attr( $item->post_title ), $thumb );
502
+ }
503
+
504
  /**
505
  * Add rollover actions to exactly one of the following displayed columns:
506
  * 'ID_parent', 'title_name', 'post_title', 'post_name'
514
  */
515
  private function _build_rollover_actions( $item, $column ) {
516
  $actions = array();
517
+
518
  if ( ( $this->rollover_id != $item->ID ) && !in_array( $column, $this->currently_hidden ) ) {
519
  /*
520
  * Build rollover actions
522
  $view_args = array_merge( array( 'page' => MLA::ADMIN_PAGE_SLUG, 'mla_item_ID' => $item->ID ),
523
  self::mla_submenu_arguments() );
524
 
525
+ if ( isset( $_REQUEST['paged'] ) ) {
526
  $view_args['paged'] = $_REQUEST['paged'];
527
+ }
528
+
529
  if ( current_user_can( 'edit_post', $item->ID ) ) {
530
+ if ( $this->is_trash ) {
531
+ $actions['restore'] = '<a class="submitdelete" href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_RESTORE, MLA::MLA_ADMIN_NONCE ) ) . '" title="' . __( 'Restore this item from the Trash', 'media-library-assistant' ) . '">' . __( 'Restore', 'media-library-assistant' ) . '</a>';
532
+ } else {
533
  /*
534
  * Use the WordPress Edit Media screen for 3.5 and later
535
  */
536
+ if ( MLATest::$wordpress_3point5_plus ) {
537
+ $actions['edit'] = '<a href="' . admin_url( 'post.php' ) . '?post=' . $item->ID . '&action=edit&mla_source=edit" title="' . __( 'Edit this item', 'media-library-assistant' ) . '">' . __( 'Edit', 'media-library-assistant' ) . '</a>';
538
+ } else {
539
+ $actions['edit'] = '<a href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_EDIT_DISPLAY, MLA::MLA_ADMIN_NONCE ) ) . '" title="' . __( 'Edit this item', 'media-library-assistant' ) . '">' . __( 'Edit', 'media-library-assistant' ) . '</a>';
 
540
  }
541
+ $actions['inline hide-if-no-js'] = '<a class="editinline" href="#" title="' . __( 'Edit this item inline', 'media-library-assistant' ) . '">' . __( 'Quick Edit', 'media-library-assistant' ) . '</a>';
542
  }
543
  } // edit_post
544
+
545
  if ( current_user_can( 'delete_post', $item->ID ) ) {
546
+ if ( !$this->is_trash && EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
547
+ $actions['trash'] = '<a class="submitdelete" href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_TRASH, MLA::MLA_ADMIN_NONCE ) ) . '" title="' . __( 'Move this item to the Trash', 'media-library-assistant' ) . '">' . __( 'Move to Trash', 'media-library-assistant' ) . '</a>';
548
+ } else {
549
  // If using trash for posts and pages but not for attachments, warn before permanently deleting
550
  $delete_ays = EMPTY_TRASH_DAYS && !MEDIA_TRASH ? ' onclick="return showNotice.warn();"' : '';
551
+
552
+ $actions['delete'] = '<a class="submitdelete"' . $delete_ays . ' href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_DELETE, MLA::MLA_ADMIN_NONCE ) ) . '" title="' . __( 'Delete this item Permanently', 'media-library-assistant' ) . '">' . __( 'Delete Permanently', 'media-library-assistant' ) . '</a>';
553
  }
554
  } // delete_post
555
+
556
+ $actions['view'] = '<a href="' . site_url( ) . '?attachment_id=' . $item->ID . '" rel="permalink" title="' . __( 'View', 'media-library-assistant' ) . ' &#8220;' . esc_attr( $item->post_title ) . '&#8221;">' . __( 'View', 'media-library-assistant' ) . '</a>';
557
+
558
  $this->rollover_id = $item->ID;
559
  } // $this->rollover_id != $item->ID
560
+
561
  return $actions;
562
  }
563
+
564
  /**
565
  * Add hidden fields with the data for use in the inline editor
566
  *
576
  $inline_data .= ' <div class="post_name">' . esc_attr( $item->post_name ) . "</div>\r\n";
577
  $inline_data .= ' <div class="post_excerpt">' . esc_attr( $item->post_excerpt ) . "</div>\r\n";
578
  $inline_data .= ' <div class="post_content">' . esc_attr( $item->post_content ) . "</div>\r\n";
579
+
580
  if ( !empty( $item->mla_wp_attachment_metadata ) ) {
581
+ if ( isset( $item->mla_wp_attachment_image_alt ) ) {
582
  $inline_data .= ' <div class="image_alt">' . esc_attr( $item->mla_wp_attachment_image_alt ) . "</div>\r\n";
583
+ } else {
584
  $inline_data .= ' <div class="image_alt">' . "</div>\r\n";
585
+ }
586
  }
587
+
588
  $inline_data .= ' <div class="post_parent">' . $item->post_parent . "</div>\r\n";
589
  $inline_data .= ' <div class="menu_order">' . $item->menu_order . "</div>\r\n";
590
  $inline_data .= ' <div class="post_author">' . $item->post_author . "</div>\r\n";
591
+
592
  $custom_fields = MLAOptions::mla_custom_field_support( 'quick_edit' );
593
  $custom_fields = array_merge( $custom_fields, MLAOptions::mla_custom_field_support( 'bulk_edit' ) );
594
  foreach ($custom_fields as $slug => $label ) {
595
  $value = get_metadata( 'post', $item->ID, $label, true );
596
  $inline_data .= ' <div class="' . $slug . '">' . esc_html( $value ) . "</div>\r\n";
597
  }
598
+
599
  $taxonomies = get_object_taxonomies( 'attachment', 'objects' );
600
+
601
  foreach ( $taxonomies as $tax_name => $tax_object ) {
602
  if ( $tax_object->hierarchical && $tax_object->show_ui && MLAOptions::mla_taxonomy_support($tax_name, 'quick-edit') ) {
603
  $inline_data .= ' <div class="mla_category" id="' . $tax_name . '_' . $item->ID . '">'
607
  . esc_html( str_replace( ',', ', ', get_terms_to_edit( $item->ID, $tax_name ) ) ) . "</div>\r\n";
608
  }
609
  }
610
+
611
  $inline_data .= "</div>\r\n";
612
  return $inline_data;
613
  }
614
+
615
  /**
616
  * Supply the content for a custom column
617
  *
623
  function column_ID_parent( $item ) {
624
  $row_actions = self::_build_rollover_actions( $item, 'ID_parent' );
625
  if ( $item->post_parent ) {
626
+ if ( isset( $item->parent_title ) ) {
627
  $parent_title = $item->parent_title;
628
+ } else {
629
+ $parent_title = sprintf( '%1$d %2$s', $item->post_parent, __( '(no title)', 'media-library-assistant' ) );
630
+ }
631
 
632
+ $parent = sprintf( '<a href="%1$s" title="' . __( 'Filter by Parent ID', 'media-library-assistant' ) . '">(parent:%2$s)</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
633
  'page' => MLA::ADMIN_PAGE_SLUG,
634
  'parent' => $item->post_parent,
635
+ 'heading_suffix' => urlencode( __( 'Parent', 'media-library-assistant' ) . ': ' . $parent_title )
636
  ) ), 'upload.php' ) ), (string) $item->post_parent );
637
+ } else {// $item->post_parent
 
638
  $parent = 'parent:0';
639
+ }
640
 
641
  if ( !empty( $row_actions ) ) {
642
  return sprintf( '%1$s<br><span style="color:silver">%2$s</span><br>%3$s%4$s', /*%1$s*/ $item->ID, /*%2$s*/ $parent, /*%3$s*/ $this->row_actions( $row_actions ), /*%4$s*/ $this->_build_inline_data( $item ) );
644
  return sprintf( '%1$s<br><span style="color:silver">%2$s</span>', /*%1$s*/ $item->ID, /*%2$s*/ $parent );
645
  }
646
  }
647
+
648
  /**
649
  * Supply the content for a custom column
650
  *
658
  $post_title = esc_attr( $item->post_title );
659
  $post_name = esc_attr( $item->post_name );
660
  $errors = $item->mla_references['parent_errors'];
661
+ if ( '(' . __( 'NO REFERENCE TESTS', 'media-library-assistant' ) . ')' == $errors ) {
662
  $errors = '';
663
+ }
664
+
665
  if ( !empty( $row_actions ) ) {
666
  return sprintf( '%1$s<br>%2$s<br>%3$s%4$s%5$s', /*%1$s*/ $post_title, /*%2$s*/ $post_name, /*%3$s*/ $errors, /*%4$s*/ $this->row_actions( $row_actions ), /*%5$s*/ $this->_build_inline_data( $item ) );
667
  } else {
668
  return sprintf( '%1$s<br>%2$s<br>%3$s', /*%1$s*/ $post_title, /*%2$s*/ $post_name, /*%3$s*/ $errors );
669
  }
670
  }
671
+
672
  /**
673
  * Supply the content for a custom column
674
  *
679
  */
680
  function column_post_title( $item ) {
681
  $row_actions = self::_build_rollover_actions( $item, 'post_title' );
682
+
683
  if ( !empty( $row_actions ) ) {
684
  return sprintf( '%1$s<br>%2$s%3$s', /*%1$s*/ esc_attr( $item->post_title ), /*%2$s*/ $this->row_actions( $row_actions ), /*%3$s*/ $this->_build_inline_data( $item ) );
685
  } else {
686
  return esc_attr( $item->post_title );
687
  }
688
  }
689
+
690
  /**
691
  * Supply the content for a custom column
692
  *
697
  */
698
  function column_post_name( $item ) {
699
  $row_actions = self::_build_rollover_actions( $item, 'post_name' );
700
+
701
  if ( !empty( $row_actions ) ) {
702
  return sprintf( '%1$s<br>%2$s%3$s', /*%1$s*/ esc_attr( $item->post_name ), /*%2$s*/ $this->row_actions( $row_actions ), /*%3$s*/ $this->_build_inline_data( $item ) );
703
  } else {
704
  return esc_attr( $item->post_name );
705
  }
706
  }
707
+
708
  /**
709
  * Supply the content for a custom column
710
  *
715
  */
716
  function column_parent( $item ) {
717
  if ( $item->post_parent ){
718
+ if ( isset( $item->parent_title ) ) {
719
  $parent_title = $item->parent_title;
720
+ } else {
721
+ $parent_title = __( '(no title: bad ID)', 'media-library-assistant' );
722
+ }
723
 
724
+ return sprintf( '<a href="%1$s" title="' . __( 'Filter by Parent ID', 'media-library-assistant' ) . '">%2$s</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
725
  'page' => MLA::ADMIN_PAGE_SLUG,
726
  'parent' => $item->post_parent,
727
+ 'heading_suffix' => urlencode( __( 'Parent', 'media-library-assistant' ) . ': ' . $parent_title )
728
  ) ), 'upload.php' ) ), (string) $item->post_parent );
729
+ } else {
 
730
  return (string) $item->post_parent;
731
+ }
732
  }
733
+
734
  /**
735
  * Supply the content for a custom column
736
  *
742
  function column_menu_order( $item ) {
743
  return (string) $item->menu_order;
744
  }
745
+
746
  /**
747
  * Supply the content for a custom column
748
  *
752
  * @return string HTML markup to be placed inside the column
753
  */
754
  function column_featured( $item ) {
755
+ if ( !MLAOptions::$process_featured_in ) {
756
+ return __( 'Disabled', 'media-library-assistant' );
757
+ }
758
+
759
  $value = '';
760
+
761
  foreach ( $item->mla_references['features'] as $feature_id => $feature ) {
762
+ if ( $feature_id == $item->post_parent ) {
763
+ $parent = ',<br>' . __( 'PARENT', 'media-library-assistant' );
764
+ } else {
765
  $parent = '';
766
+ }
767
+
768
+ $value .= sprintf( '(%1$s %2$s%3$s), <a href="%4$s" title="' . __( 'Edit', 'media-library-assistant' ) . ' &#8220;%5$s&#8221;">%6$s</a>',
769
  /*%1$s*/ esc_attr( $feature->post_type ),
770
  /*%2$s*/ $feature_id,
771
  /*%3$s*/ $parent,
773
  /*%5$s*/ esc_attr( $feature->post_title ),
774
  /*%6$s*/ esc_attr( $feature->post_title ) ) . "<br>\r\n";
775
  } // foreach $feature
776
+
777
  return $value;
778
  }
779
+
780
  /**
781
  * Supply the content for a custom column
782
  *
786
  * @return string HTML markup to be placed inside the column
787
  */
788
  function column_inserted( $item ) {
789
+ if ( !MLAOptions::$process_inserted_in ) {
790
+ return __( 'Disabled', 'media-library-assistant' );
791
+ }
792
+
793
  $value = '';
794
+
795
  foreach ( $item->mla_references['inserts'] as $file => $inserts ) {
796
  $value .= sprintf( '<strong>%1$s</strong><br>', $file );
797
+
798
  foreach ( $inserts as $insert ) {
799
+ if ( $insert->ID == $item->post_parent ) {
800
+ $parent = ',<br>' . __( 'PARENT', 'media-library-assistant' );
801
+ } else {
802
  $parent = '';
803
+ }
804
+
805
+ $value .= sprintf( '(%1$s %2$s%3$s), <a href="%4$s" title="' . __( 'Edit', 'media-library-assistant' ) . ' &#8220;%5$s&#8221;">%6$s</a>',
806
  /*%1$s*/ esc_attr( $insert->post_type ),
807
  /*%2$s*/ $insert->ID,
808
  /*%3$s*/ $parent,
811
  /*%6$s*/ esc_attr( $insert->post_title ) ) . "<br>\r\n";
812
  } // foreach $insert
813
  } // foreach $file
814
+
815
  return $value;
816
  }
817
+
818
  /**
819
  * Supply the content for a custom column
820
  *
824
  * @return string HTML markup to be placed inside the column
825
  */
826
  function column_galleries( $item ) {
827
+ if ( !MLAOptions::$process_gallery_in ) {
828
+ return __( 'Disabled', 'media-library-assistant' );
829
+ }
830
+
831
  $value = '';
832
+
833
  foreach ( $item->mla_references['galleries'] as $ID => $gallery ) {
834
+ if ( $ID == $item->post_parent ) {
835
+ $parent = ',<br>' . __( 'PARENT', 'media-library-assistant' );
836
+ } else {
837
  $parent = '';
838
+ }
839
+
840
+ $value .= sprintf( '(%1$s %2$s%3$s), <a href="%4$s" title="' . __( 'Edit', 'media-library-assistant' ) . ' &#8220;%5$s&#8221;">%6$s</a>',
841
  /*%1$s*/ esc_attr( $gallery['post_type'] ),
842
  /*%2$s*/ $ID,
843
  /*%3$s*/ $parent,
845
  /*%5$s*/ esc_attr( $gallery['post_title'] ),
846
  /*%6$s*/ esc_attr( $gallery['post_title'] ) ) . "<br>\r\n";
847
  } // foreach $gallery
848
+
849
  return $value;
850
  }
851
+
852
  /**
853
  * Supply the content for a custom column
854
  *
858
  * @return string HTML markup to be placed inside the column
859
  */
860
  function column_mla_galleries( $item ) {
861
+ if ( !MLAOptions::$process_mla_gallery_in ) {
862
+ return __( 'Disabled', 'media-library-assistant' );
863
+ }
864
+
865
  $value = '';
866
+
867
  foreach ( $item->mla_references['mla_galleries'] as $ID => $gallery ) {
868
+ if ( $ID == $item->post_parent ) {
869
+ $parent = ',<br>' . __( 'PARENT', 'media-library-assistant' );
870
+ } else {
871
  $parent = '';
872
+ }
873
+
874
+ $value .= sprintf( '(%1$s %2$s%3$s), <a href="%4$s" title="' . __( 'Edit', 'media-library-assistant' ) . ' &#8220;%5$s&#8221;">%6$s</a>',
875
  /*%1$s*/ esc_attr( $gallery['post_type'] ),
876
  /*%2$s*/ $ID,
877
  /*%3$s*/ $parent,
879
  /*%5$s*/ esc_attr( $gallery['post_title'] ),
880
  /*%6$s*/ esc_attr( $gallery['post_title'] ) ) . "<br>\r\n";
881
  } // foreach $gallery
882
+
883
  return $value;
884
  }
885
+
886
  /**
887
  * Supply the content for a custom column
888
  *
892
  * @return string HTML markup to be placed inside the column
893
  */
894
  function column_alt_text( $item ) {
895
+ if ( isset( $item->mla_wp_attachment_image_alt ) ) {
896
+ return sprintf( '<a href="%1$s" title="' . __( 'Filter by', 'media-library-assistant' ) . ' &#8220;%2$s&#8221;">%3$s</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
897
  'page' => MLA::ADMIN_PAGE_SLUG,
898
  'mla-metakey' => '_wp_attachment_image_alt',
899
  'mla-metavalue' => urlencode( $item->mla_wp_attachment_image_alt ),
900
+ 'heading_suffix' => urlencode( __( 'ALT Text', 'media-library-assistant' ) . ': ' . $item->mla_wp_attachment_image_alt )
901
  ) ), 'upload.php' ) ), esc_html( $item->mla_wp_attachment_image_alt ), esc_html( $item->mla_wp_attachment_image_alt ) );
902
+ }
903
+
904
+ return '';
905
  }
906
+
907
  /**
908
  * Supply the content for a custom column
909
  *
915
  function column_caption( $item ) {
916
  return esc_attr( $item->post_excerpt );
917
  }
918
+
919
  /**
920
  * Supply the content for a custom column
921
  *
927
  function column_description( $item ) {
928
  return esc_textarea( $item->post_content );
929
  }
930
+
931
  /**
932
  * Supply the content for a custom column
933
  *
937
  * @return string HTML markup to be placed inside the column
938
  */
939
  function column_post_mime_type( $item ) {
940
+ return sprintf( '<a href="%1$s" title="' . __( 'Filter by', 'media-library-assistant' ) . ' &#8220;%2$s&#8221;">%2$s</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
941
  'page' => MLA::ADMIN_PAGE_SLUG,
942
  'post_mime_type' => urlencode( $item->post_mime_type ),
943
+ 'heading_suffix' => urlencode( __( 'MIME Type', 'media-library-assistant' ) . ': ' . $item->post_mime_type )
944
  ) ), 'upload.php' ) ), esc_html( $item->post_mime_type ), esc_html( $item->post_mime_type ) );
945
  }
946
+
947
  /**
948
  * Supply the content for a custom column
949
  *
955
  function column_file_url( $item ) {
956
  $attachment_url = wp_get_attachment_url( $item->ID );
957
 
958
+ return $attachment_url ? $attachment_url : __( 'None', 'media-library-assistant' );
959
  }
960
+
961
  /**
962
  * Supply the content for a custom column
963
  *
969
  function column_base_file( $item ) {
970
  return $item->mla_references['base_file'];
971
  }
972
+
973
  /**
974
  * Supply the content for a custom column
975
  *
980
  */
981
  function column_date( $item ) {
982
  if ( '0000-00-00 00:00:00' == $item->post_date ) {
983
+ $h_time = __( 'Unpublished', 'media-library-assistant' );
984
  } else {
 
985
  $m_time = $item->post_date;
986
  $time = get_post_time( 'G', true, $item, false );
987
+
988
  if ( ( abs( $t_diff = time() - $time ) ) < 86400 ) {
989
+ if ( $t_diff < 0 ) {
990
+ /* translators: 1: upload/last modified date and time */
991
+ $h_time = sprintf( __( '%1$s from now', 'media-library-assistant' ), human_time_diff( $time ) );
992
+ } else {
993
+ /* translators: 1: upload/last modified date and time */
994
+ $h_time = sprintf( __( '%1$s ago', 'media-library-assistant' ), human_time_diff( $time ) );
995
+ }
996
  } else {
997
+ /* translators: format for upload/last modified date */
998
+ $h_time = mysql2date( __( 'Y/m/d', 'media-library-assistant' ), $m_time );
999
  }
1000
  }
1001
+
1002
  return $h_time;
1003
  }
1004
+
1005
  /**
1006
  * Supply the content for a custom column
1007
  *
1012
  */
1013
  function column_modified( $item ) {
1014
  if ( '0000-00-00 00:00:00' == $item->post_modified ) {
1015
+ $h_time = __( 'Unpublished', 'media-library-assistant' );
1016
  } else {
 
1017
  $m_time = $item->post_modified;
1018
  $time = get_post_time( 'G', true, $item, false );
1019
+
1020
  if ( ( abs( $t_diff = time() - $time ) ) < 86400 ) {
1021
+ if ( $t_diff < 0 ) {
1022
+ $h_time = sprintf( __( '%1$s from now', 'media-library-assistant' ), human_time_diff( $time ) );
1023
+ } else {
1024
+ $h_time = sprintf( __( '%1$s ago', 'media-library-assistant' ), human_time_diff( $time ) );
1025
+ }
1026
  } else {
1027
+ $h_time = mysql2date( __( 'Y/m/d', 'media-library-assistant' ), $m_time );
1028
  }
1029
  }
1030
+
1031
  return $h_time;
1032
  }
1033
+
1034
  /**
1035
  * Supply the content for a custom column
1036
  *
1041
  */
1042
  function column_author( $item ) {
1043
  $user = get_user_by( 'id', $item->post_author );
1044
+
1045
+ if ( isset( $user->data->display_name ) ) {
1046
+ return sprintf( '<a href="%s" title="' . __( 'Filter by Author ID', 'media-library-assistant' ) . '">%s</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
1047
  'page' => MLA::ADMIN_PAGE_SLUG,
1048
  'author' => $item->post_author,
1049
+ 'heading_suffix' => urlencode( __( 'Author', 'media-library-assistant' ) . ': ' . $user->data->display_name )
1050
  ) ), 'upload.php' ) ), esc_html( $user->data->display_name ) );
1051
+ }
1052
+
1053
+ return 'unknown';
1054
  }
1055
+
1056
  /**
1057
  * Supply the content for a custom column
1058
  *
1062
  * @return string HTML markup to be placed inside the column
1063
  */
1064
  function column_attached_to( $item ) {
1065
+ if ( isset( $item->parent_date ) ) {
1066
  $parent_date = $item->parent_date;
1067
+ } else {
1068
  $parent_date = '';
1069
+ }
1070
+
1071
+ if ( isset( $item->parent_title ) ) {
1072
+ $parent_title = sprintf( '<a href="%1$s" title="' . __( 'Edit', 'media-library-assistant' ) . ' &#8220;%2$s&#8221;">%3$s</a>', esc_url( add_query_arg( array(
1073
  'post' => $item->post_parent,
1074
  'action' => 'edit'
1075
  ), 'post.php' ) ), esc_attr( $item->parent_title ), esc_attr( $item->parent_title ) );
1076
+ } else {
1077
+ $parent_title = '(' . _x( 'Unattached', 'post_mime_types_singular', 'media-library-assistant' ) . ')';
1078
+ }
1079
+
1080
+ if ( isset( $item->parent_type ) ) {
1081
  $parent_type = '(' . $item->parent_type . ' ' . (string) $item->post_parent . ')';
1082
+ } else {
1083
  $parent_type = '';
1084
+ }
1085
+
1086
+ return sprintf( '%1$s<br>%2$s<br>%3$s', /*%1$s*/ $parent_title, /*%2$s*/ mysql2date( __( 'Y/m/d', 'media-library-assistant' ), $parent_date ), /*%3$s*/ $parent_type ) . "<br>\r\n";
1087
  }
1088
+
1089
  /**
1090
  * Process $_REQUEST, building $submenu_arguments
1091
  *
1097
  */
1098
  public static function mla_submenu_arguments( $include_filters = true ) {
1099
  static $submenu_arguments = NULL, $has_filters = NULL;
1100
+
1101
+ if ( is_array( $submenu_arguments ) && ( $has_filters == $include_filters ) ) {
1102
  return $submenu_arguments;
1103
+ } else {
1104
  $submenu_arguments = array();
1105
  $has_filters = $include_filters;
1106
  }
1107
+
1108
  /*
1109
  * View arguments
1110
  */
1111
+ if ( isset( $_REQUEST['post_mime_type'] ) ) {
1112
  $submenu_arguments['post_mime_type'] = $_REQUEST['post_mime_type'];
1113
+ }
1114
+
1115
+ if ( isset( $_REQUEST['detached'] ) ) {
1116
  $submenu_arguments['detached'] = $_REQUEST['detached'];
1117
+ }
1118
+
1119
+ if ( isset( $_REQUEST['status'] ) ) {
1120
  $submenu_arguments['status'] = $_REQUEST['status'];
1121
+ }
1122
+
1123
+ if ( isset( $_REQUEST['meta_query'] ) ) {
1124
  $submenu_arguments['meta_query'] = $_REQUEST['meta_query'];
1125
+ }
1126
+
1127
  /*
1128
  * Search box arguments
1129
  */
1132
  $submenu_arguments['mla_search_connector'] = $_REQUEST['mla_search_connector'];
1133
  $submenu_arguments['mla_search_fields'] = $_REQUEST['mla_search_fields'];
1134
  }
1135
+
1136
  /*
1137
  * Filter arguments (from table header)
1138
  */
1139
+ if ( isset( $_REQUEST['m'] ) && ( '0' != $_REQUEST['m'] ) ) {
1140
  $submenu_arguments['m'] = $_REQUEST['m'];
1141
+ }
1142
+
1143
+ if ( isset( $_REQUEST['mla_filter_term'] ) && ( '0' != $_REQUEST['mla_filter_term'] ) ) {
1144
  $submenu_arguments['mla_filter_term'] = $_REQUEST['mla_filter_term'];
1145
+ }
1146
+
1147
  /*
1148
  * Sort arguments (from column header)
1149
  */
1150
+ if ( isset( $_REQUEST['order'] ) ) {
1151
  $submenu_arguments['order'] = $_REQUEST['order'];
1152
+ }
1153
+
1154
+ if ( isset( $_REQUEST['orderby'] ) ) {
1155
  $submenu_arguments['orderby'] = $_REQUEST['orderby'];
1156
+ }
1157
+
1158
  /*
1159
  * Filter arguments (from interior table cells)
1160
  */
1161
  if ( $include_filters ) {
1162
+ if ( isset( $_REQUEST['heading_suffix'] ) ) {
1163
  $submenu_arguments['heading_suffix'] = $_REQUEST['heading_suffix'];
1164
+ }
1165
+
1166
+ if ( isset( $_REQUEST['parent'] ) ) {
1167
  $submenu_arguments['parent'] = $_REQUEST['parent'];
1168
+ }
1169
+
1170
+ if ( isset( $_REQUEST['author'] ) ) {
1171
  $submenu_arguments['author'] = $_REQUEST['author'];
1172
+ }
1173
+
1174
+ if ( isset( $_REQUEST['mla-tax'] ) ) {
1175
  $submenu_arguments['mla-tax'] = $_REQUEST['mla-tax'];
1176
+ }
1177
+
1178
+ if ( isset( $_REQUEST['mla-term'] ) ) {
1179
  $submenu_arguments['mla-term'] = $_REQUEST['mla-term'];
1180
+ }
1181
+
1182
+ if ( isset( $_REQUEST['mla-metakey'] ) ) {
1183
  $submenu_arguments['mla-metakey'] = $_REQUEST['mla-metakey'];
1184
+ }
1185
+
1186
+ if ( isset( $_REQUEST['mla-metavalue'] ) ) {
1187
  $submenu_arguments['mla-metavalue'] = $_REQUEST['mla-metavalue'];
1188
+ }
1189
  }
1190
+
1191
  return $submenu_arguments;
1192
  }
1193
+
1194
  /**
1195
  * Display the pagination, adding view, search and filter arguments
1196
  *
1205
  parent::pagination( $which );
1206
  $_SERVER['REQUEST_URI'] = $save_uri;
1207
  }
1208
+
1209
  /**
1210
  * This method dictates the table's columns and titles
1211
  *
1216
  function get_columns( ) {
1217
  return $columns = MLA_List_Table::mla_manage_columns_filter();
1218
  }
1219
+
1220
  /**
1221
  * Returns the list of currently hidden columns from a user option or
1222
  * from default values if the option is not set
1229
  {
1230
  $columns = get_user_option( 'managemedia_page_' . MLA::ADMIN_PAGE_SLUG . 'columnshidden' );
1231
 
1232
+ if ( is_array( $columns ) ) {
1233
  return $columns;
1234
+ }
1235
+
1236
+ return self::_default_hidden_columns();
1237
  }
1238
+
1239
  /**
1240
  * Returns an array where the key is the column that needs to be sortable
1241
  * and the value is db column to sort by. Also notes the current sort column,
1248
  */
1249
  function get_sortable_columns( ) {
1250
  $columns = MLA_List_Table::$default_sortable_columns;
1251
+
1252
  if ( isset( $_REQUEST['orderby'] ) ) {
1253
  $needle = array(
1254
  $_REQUEST['orderby'],
1278
  parent::print_column_headers( $with_id );
1279
  $_SERVER['REQUEST_URI'] = $save_uri;
1280
  }
1281
+
1282
  /**
1283
  * Returns HTML markup for one view that can be used with this table
1284
  *
1292
  function _get_view( $view_slug, $current_view ) {
1293
  global $wpdb;
1294
  static $mla_types = NULL, $posts_per_type, $post_mime_types, $avail_post_mime_types, $matches, $num_posts;
1295
+
1296
  /*
1297
  * Calculate the common values once per page load
1298
  */
1299
  if ( is_null( $mla_types ) ) {
1300
  $query_types = MLAMime::mla_query_view_items( array( 'orderby' => 'menu_order' ), 0, 0 );
1301
+ if ( ! is_array( $query_types ) ) {
1302
  $query_types = array ();
1303
+ }
1304
+
1305
  $mla_types = array ();
1306
+ foreach ( $query_types as $value ) {
1307
  $mla_types[ $value->slug ] = $value;
1308
+ }
1309
 
1310
  $posts_per_type = (array) wp_count_attachments();
1311
  $post_mime_types = get_post_mime_types();
1312
  $avail_post_mime_types = $this->_avail_mime_types( $posts_per_type );
1313
  $matches = wp_match_mime_types( array_keys( $post_mime_types ), array_keys( $posts_per_type ) );
1314
 
1315
+ foreach ( $matches as $type => $reals ) {
1316
+ foreach ( $reals as $real ) {
1317
  $num_posts[ $type ] = ( isset( $num_posts[ $type ] ) ) ? $num_posts[ $type ] + $posts_per_type[ $real ] : $posts_per_type[ $real ];
1318
+ }
1319
+ }
1320
  }
1321
 
1322
  $class = ( $view_slug == $current_view ) ? ' class="current"' : '';
1328
  switch( $view_slug ) {
1329
  case 'all':
1330
  $total_items = array_sum( $posts_per_type ) - $posts_per_type['trash'];
1331
+ return "<a href='{$base_url}'$class>" . sprintf( _nx( 'All', 'All', $total_items, 'uploaded files', 'media-library-assistant' ) . ' <span class="count">(%1$s)</span></a>', number_format_i18n( $total_items ) );
1332
  case 'unattached':
1333
  $total_items = $wpdb->get_var(
1334
  "
1337
  "
1338
  );
1339
 
1340
+ if ( $total_items ) {
1341
+ $value = MLAOptions::$mla_option_definitions[ MLAOptions::MLA_POST_MIME_TYPES ]['std']['unattached'];
1342
+ $singular = sprintf('%s <span class="count">(%%s)</span>', $value['singular'] );
1343
+ $plural = sprintf('%s <span class="count">(%%s)</span>', $value['plural'] );
1344
+ return '<a href="' . add_query_arg( array( 'detached' => '1' ), $base_url ) . '"' . $class . '>' . sprintf( _nx( $singular, $plural, $total_items, 'detached files', 'media-library-assistant' ), number_format_i18n( $total_items ) ) . '</a>';
1345
+ }
1346
+
1347
+ return false;
1348
  case 'trash':
1349
+ if ( $posts_per_type['trash'] ) {
1350
+ $value = MLAOptions::$mla_option_definitions[ MLAOptions::MLA_POST_MIME_TYPES ]['std']['trash'];
1351
+ $singular = sprintf('%s <span class="count">(%%s)</span>', $value['singular'] );
1352
+ $plural = sprintf('%s <span class="count">(%%s)</span>', $value['plural'] );
1353
  return '<a href="' . add_query_arg( array(
1354
  'status' => 'trash'
1355
+ ), $base_url ) . '"' . $class . '>' . sprintf( _nx( $singular, $plural, $posts_per_type['trash'], 'uploaded files', 'media-library-assistant' ), number_format_i18n( $posts_per_type['trash'] ) ) . '</a>';
1356
+ }
1357
+
1358
+ return false;
1359
  } // switch special cases
1360
 
1361
  /*
1362
  * Make sure the slug is in our list
1363
  */
1364
+ if ( array_key_exists( $view_slug, $mla_types ) ) {
1365
  $mla_type = $mla_types[ $view_slug ];
1366
+ } else {
1367
  return false;
1368
+ }
1369
+
1370
  /*
1371
  * Handle post_mime_types
1372
  */
1373
  if ( $mla_type->post_mime_type ) {
1374
+ if ( !empty( $num_posts[ $view_slug ] ) ) {
1375
  return "<a href='" . add_query_arg( array(
1376
  'post_mime_type' => $view_slug
1377
+ ), $base_url ) . "'$class>" . sprintf( translate_nooped_plural( $post_mime_types[ $view_slug ][ 2 ], $num_posts[ $view_slug ], 'media-library-assistant' ), number_format_i18n( $num_posts[ $view_slug ] ) ) . '</a>';
1378
+ }
1379
+
1380
+ return false;
1381
  }
1382
 
1383
  /*
1384
  * Handle extended specification types
1385
  */
1386
+ if ( empty( $mla_type->specification ) ) {
1387
  $query = array ( 'post_mime_type' => $view_slug );
1388
+ } else {
1389
  $query = MLAMime::mla_prepare_view_query( $view_slug, $mla_type->specification );
1390
+ }
1391
+
1392
  $total_items = MLAData::mla_count_list_table_items( $query );
1393
  if ( $total_items ) {
1394
  $singular = sprintf('%s <span class="count">(%%s)</span>', $mla_type->singular );
1395
  $plural = sprintf('%s <span class="count">(%%s)</span>', $mla_type->plural );
1396
+ $nooped_plural = _n_noop( $singular, $plural, 'media-library-assistant' );
1397
+
1398
+ if ( isset( $query['post_mime_type'] ) ) {
1399
  $query['post_mime_type'] = urlencode( $query['post_mime_type'] );
1400
+ } else {
1401
  $query['meta_query'] = urlencode( serialize( $query['meta_query'] ) );
1402
+ }
1403
 
1404
+ return "<a href='" . add_query_arg( $query, $base_url ) . "'$class>" . sprintf( translate_nooped_plural( $nooped_plural, $total_items, 'media-library-assistant' ), number_format_i18n( $total_items ) ) . '</a>';
1405
  }
1406
 
1407
  return false;
1408
  } // _get_view
1409
+
1410
  /**
1411
  * Returns an associative array listing all the views that can be used with this table.
1412
  * These are listed across the top of the page and managed by WordPress.
1419
  /*
1420
  * Find current view
1421
  */
1422
+ if ( $this->detached ) {
1423
  $current_view = 'unattached';
1424
+ } elseif ( $this->is_trash ) {
1425
  $current_view = 'trash';
1426
+ } elseif ( empty( $_REQUEST['post_mime_type'] ) ) {
1427
  if ( isset( $_REQUEST['meta_query'] ) ) {
1428
  $query = unserialize( stripslashes( $_REQUEST['meta_query'] ) );
1429
  $current_view = $query['slug'];
1430
+ } else {
 
1431
  $current_view = 'all';
1432
+ }
1433
+ } else {
1434
  $current_view = $_REQUEST['post_mime_type'];
1435
+ }
1436
+
1437
  $mla_types = MLAMime::mla_query_view_items( array( 'orderby' => 'menu_order' ), 0, 0 );
1438
+ if ( ! is_array( $mla_types ) ) {
1439
  $mla_types = array ();
1440
+ }
1441
+
1442
  /*
1443
  * Filter the list, generate the views
1444
  */
1445
  $view_links = array();
1446
  foreach ( $mla_types as $value ) {
1447
  if ( $value->table_view ) {
1448
+ if ( $current_view == $value->specification ) {
1449
  $current_view = $value->slug;
1450
+ }
1451
+
1452
+ if ( $link = self::_get_view( $value->slug, $current_view ) ) {
1453
  $view_links[ $value->slug ] = $link;
1454
+ }
1455
  }
1456
  }
1457
 
1458
  return $view_links;
1459
  }
1460
+
1461
  /**
1462
  * Get an associative array ( option_name => option_title ) with the list
1463
  * of bulk actions available on this table.
1469
  function get_bulk_actions( )
1470
  {
1471
  $actions = array();
1472
+
1473
  if ( $this->is_trash ) {
1474
+ $actions['restore'] = __( 'Restore', 'media-library-assistant' );
1475
+ $actions['delete'] = __( 'Delete Permanently', 'media-library-assistant' );
1476
  } else {
1477
+ $actions['edit'] = __( 'Edit', 'media-library-assistant' );
1478
+
1479
+ if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
1480
+ $actions['trash'] = __( 'Move to Trash', 'media-library-assistant' );
1481
+ } else {
1482
+ $actions['delete'] = __( 'Delete Permanently', 'media-library-assistant' );
1483
+ }
1484
  }
1485
+
1486
  return $actions;
1487
  }
1488
+
1489
  /**
1490
  * Extra controls to be displayed between bulk actions and pagination
1491
  *
1500
  function extra_tablenav( $which )
1501
  {
1502
  echo ( '<div class="alignleft actions">' );
1503
+
1504
  if ( 'top' == $which ) {
1505
  $this->months_dropdown( 'attachment' );
1506
+
1507
  echo self::mla_get_taxonomy_filter_dropdown( isset( $_REQUEST['mla_filter_term'] ) ? $_REQUEST['mla_filter_term'] : 0 );
1508
+
1509
+ submit_button( __( 'Filter', 'media-library-assistant' ), 'secondary', 'mla_filter', false, array(
1510
  'id' => 'post-query-submit'
1511
  ) );
1512
  }
1513
+
1514
  if ( self::mla_submenu_arguments( true ) != self::mla_submenu_arguments( false ) ) {
1515
+ submit_button( __( 'Clear Filter-by', 'media-library-assistant' ), 'button apply', 'clear_filter_by', false );
1516
  }
1517
+
1518
  if ( $this->is_trash && current_user_can( 'edit_others_posts' ) ) {
1519
+ submit_button( __( 'Empty Trash', 'media-library-assistant' ), 'button apply', 'delete_all', false );
1520
  }
1521
+
1522
  echo ( '</div>' );
1523
  }
1524
+
1525
  /**
1526
  * Prepares the list of items for displaying
1527
  *
1540
  $this->get_hidden_columns(),
1541
  $this->get_sortable_columns()
1542
  );
1543
+
1544
  /*
1545
  * REQUIRED for pagination.
1546
  */
1561
  */
1562
  $total_items = MLAData::mla_count_list_table_items( $_REQUEST, ( ( $current_page - 1 ) * $per_page ), $per_page );
1563
  $this->items = MLAData::mla_query_list_table_items( $_REQUEST, ( ( $current_page - 1 ) * $per_page ), $per_page );
1564
+
1565
  /*
1566
  * REQUIRED. We also have to register our pagination options & calculations.
1567
  */
1571
  'total_pages' => ceil( $total_items / $per_page ) //WE have to calculate the total number of pages
1572
  ) );
1573
  }
1574
+
1575
  /**
1576
  * Generates (echoes) content for a single row of the table
1577
  *
includes/class-mla-main.php CHANGED
@@ -22,15 +22,6 @@ if ( !function_exists( 'post_categories_meta_box' ) ) {
22
  */
23
  class MLA {
24
 
25
- /**
26
- * Display name for this plugin
27
- *
28
- * @since 0.1
29
- *
30
- * @var string
31
- */
32
- const PLUGIN_NAME = 'Media Library Assistant';
33
-
34
  /**
35
  * Current version number
36
  *
@@ -38,7 +29,7 @@ class MLA {
38
  *
39
  * @var string
40
  */
41
- const CURRENT_MLA_VERSION = '1.61';
42
 
43
  /**
44
  * Slug for registering and enqueueing plugin style sheet
@@ -93,7 +84,7 @@ class MLA {
93
  * @var string
94
  */
95
  const ADMIN_PAGE_SLUG = 'mla-menu';
96
-
97
  /**
98
  * Action name; uniquely identifies the nonce
99
  *
@@ -102,7 +93,7 @@ class MLA {
102
  * @var string
103
  */
104
  const MLA_ADMIN_NONCE = 'mla_admin';
105
-
106
  /**
107
  * mla_admin_action value for permanently deleting a single item
108
  *
@@ -111,7 +102,7 @@ class MLA {
111
  * @var string
112
  */
113
  const MLA_ADMIN_SINGLE_DELETE = 'single_item_delete';
114
-
115
  /**
116
  * mla_admin_action value for displaying a single item
117
  *
@@ -120,7 +111,7 @@ class MLA {
120
  * @var string
121
  */
122
  const MLA_ADMIN_SINGLE_EDIT_DISPLAY = 'single_item_edit_display';
123
-
124
  /**
125
  * mla_admin_action value for updating a single item
126
  *
@@ -129,7 +120,7 @@ class MLA {
129
  * @var string
130
  */
131
  const MLA_ADMIN_SINGLE_EDIT_UPDATE = 'single_item_edit_update';
132
-
133
  /**
134
  * mla_admin_action value for restoring a single item from the trash
135
  *
@@ -138,7 +129,7 @@ class MLA {
138
  * @var string
139
  */
140
  const MLA_ADMIN_SINGLE_RESTORE = 'single_item_restore';
141
-
142
  /**
143
  * mla_admin_action value for moving a single item to the trash
144
  *
@@ -147,7 +138,7 @@ class MLA {
147
  * @var string
148
  */
149
  const MLA_ADMIN_SINGLE_TRASH = 'single_item_trash';
150
-
151
  /**
152
  * mla_admin_action value for mapping Custom Field metadata
153
  *
@@ -156,7 +147,7 @@ class MLA {
156
  * @var string
157
  */
158
  const MLA_ADMIN_SINGLE_CUSTOM_FIELD_MAP = 'single_item_custom_field_map';
159
-
160
  /**
161
  * mla_admin_action value for mapping IPTC/EXIF metadata
162
  *
@@ -165,7 +156,7 @@ class MLA {
165
  * @var string
166
  */
167
  const MLA_ADMIN_SINGLE_MAP = 'single_item_map';
168
-
169
  /**
170
  * Holds screen ids to match help text to corresponding screen
171
  *
@@ -174,7 +165,7 @@ class MLA {
174
  * @var array
175
  */
176
  private static $page_hooks = array();
177
-
178
  /**
179
  * Initialization function, similar to __construct()
180
  *
@@ -194,7 +185,37 @@ class MLA {
194
  add_filter( 'set-screen-option', 'MLA::mla_set_screen_option_filter', 10, 3 ); // $status, $option, $value
195
  add_filter( 'screen_options_show_screen', 'MLA::mla_screen_options_show_screen_filter', 10, 2 ); // $show_screen, $this
196
  }
197
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  /**
199
  * Load the plugin's Ajax handler or process Edit Media update actions
200
  *
@@ -208,13 +229,14 @@ class MLA {
208
  */
209
  if ( !empty( $_REQUEST['mla_admin_action'] ) ) {
210
  check_admin_referer( self::MLA_ADMIN_NONCE );
211
-
212
  switch ( $_REQUEST['mla_admin_action'] ) {
213
  case self::MLA_ADMIN_SINGLE_CUSTOM_FIELD_MAP:
214
  $updates = MLAOptions::mla_evaluate_custom_field_mapping( $_REQUEST['mla_item_ID'], 'single_attachment_mapping' );
215
-
216
- if ( !empty( $updates ) )
217
  $item_content = MLAData::mla_update_single_item( $_REQUEST['mla_item_ID'], $updates );
 
218
 
219
  $view_args = isset( $_REQUEST['mla_source'] ) ? array( 'mla_source' => $_REQUEST['mla_source']) : array();
220
  wp_redirect( add_query_arg( $view_args, admin_url( 'post.php' ) . '?post=' . $_REQUEST['mla_item_ID'] . '&action=edit&message=101' ), 302 );
@@ -231,10 +253,10 @@ class MLA {
231
  // ignore the rest
232
  } // switch ($_REQUEST['mla_admin_action'])
233
  } // (!empty($_REQUEST['mla_admin_action'])
234
-
235
  add_action( 'wp_ajax_' . self::JAVASCRIPT_INLINE_EDIT_SLUG, 'MLA::mla_inline_edit_action' );
236
  }
237
-
238
  /**
239
  * Load the plugin's Style Sheet and Javascript files
240
  *
@@ -246,20 +268,21 @@ class MLA {
246
  */
247
  public static function mla_admin_enqueue_scripts_action( $page_hook ) {
248
  $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
249
-
250
  if ( 'checked' != MLAOptions::mla_get_option( MLAOptions::MLA_SCREEN_DISPLAY_LIBRARY ) ) {
251
  wp_register_style( self::STYLESHEET_SLUG . '-nolibrary', MLA_PLUGIN_URL . 'css/mla-nolibrary.css', false, self::CURRENT_MLA_VERSION );
252
  wp_enqueue_style( self::STYLESHEET_SLUG . '-nolibrary' );
253
  }
254
 
255
- if( 'edit-tags.php' == $page_hook ) {
256
  wp_register_style( self::STYLESHEET_SLUG, MLA_PLUGIN_URL . 'css/mla-edit-tags-style.css', false, self::CURRENT_MLA_VERSION );
257
  wp_enqueue_style( self::STYLESHEET_SLUG );
258
  return;
259
  }
260
-
261
- if ( 'media_page_' . self::ADMIN_PAGE_SLUG != $page_hook )
262
  return;
 
263
 
264
  wp_register_style( self::STYLESHEET_SLUG, MLA_PLUGIN_URL . 'css/mla-style.css', false, self::CURRENT_MLA_VERSION );
265
  wp_enqueue_style( self::STYLESHEET_SLUG );
@@ -268,15 +291,14 @@ class MLA {
268
  wp_enqueue_script( self::JAVASCRIPT_SINGLE_EDIT_SLUG, MLA_PLUGIN_URL . "js/mla-single-edit-scripts{$suffix}.js",
269
  array( 'wp-lists', 'suggest', 'jquery' ), self::CURRENT_MLA_VERSION, false );
270
  $script_variables = array(
271
- 'comma' => _x( ',', 'tag delimiter' ),
272
  'Ajax_Url' => admin_url( 'admin-ajax.php' )
273
  );
274
  wp_localize_script( self::JAVASCRIPT_SINGLE_EDIT_SLUG, self::JAVASCRIPT_SINGLE_EDIT_OBJECT, $script_variables );
275
- }
276
- else {
277
  wp_enqueue_script( self::JAVASCRIPT_INLINE_EDIT_SLUG, MLA_PLUGIN_URL . "js/mla-inline-edit-scripts{$suffix}.js",
278
  array( 'wp-lists', 'suggest', 'jquery' ), self::CURRENT_MLA_VERSION, false );
279
-
280
  $fields = array( 'post_title', 'post_name', 'post_excerpt', 'post_content', 'image_alt', 'post_parent', 'menu_order', 'post_author' );
281
  $custom_fields = MLAOptions::mla_custom_field_support( 'quick_edit' );
282
  $custom_fields = array_merge( $custom_fields, MLAOptions::mla_custom_field_support( 'bulk_edit' ) );
@@ -286,17 +308,17 @@ class MLA {
286
 
287
  $script_variables = array(
288
  'fields' => $fields,
289
- 'error' => 'Error while saving the changes.',
290
- 'ntdeltitle' => 'Remove From Bulk Edit',
291
- 'notitle' => '(no title)',
292
- 'comma' => _x( ',', 'tag delimiter' ),
293
  'ajax_action' => self::JAVASCRIPT_INLINE_EDIT_SLUG,
294
  'ajax_nonce' => wp_create_nonce( self::MLA_ADMIN_NONCE )
295
  );
296
  wp_localize_script( self::JAVASCRIPT_INLINE_EDIT_SLUG, self::JAVASCRIPT_INLINE_EDIT_OBJECT, $script_variables );
297
  }
298
  }
299
-
300
  /**
301
  * Add the submenu pages
302
  *
@@ -313,43 +335,41 @@ class MLA {
313
  * @return void
314
  */
315
  public static function mla_admin_menu_action( ) {
316
- // if ( 'checked' != MLAOptions::mla_get_option( MLAOptions::MLA_SCREEN_DISPLAY_LIBRARY ) )
317
- // remove_submenu_page( 'upload.php', 'upload.php' );
318
-
319
- if ( 'checked' != MLAOptions::mla_get_option( MLAOptions::MLA_SCREEN_DISPLAY_LIBRARY ) )
320
  add_action( 'load-upload.php', 'MLA::mla_load_media_action' );
321
-
 
322
  $page_title = MLAOptions::mla_get_option( MLAOptions::MLA_SCREEN_PAGE_TITLE );
323
  $menu_title = MLAOptions::mla_get_option( MLAOptions::MLA_SCREEN_MENU_TITLE );
324
  $hook = add_submenu_page( 'upload.php', $page_title, $menu_title, 'upload_files', self::ADMIN_PAGE_SLUG, 'MLA::mla_render_admin_page' );
325
  add_action( 'load-' . $hook, 'MLA::mla_add_menu_options' );
326
  add_action( 'load-' . $hook, 'MLA::mla_add_help_tab' );
327
  self::$page_hooks[ $hook ] = $hook;
328
-
329
  $taxonomies = get_object_taxonomies( 'attachment', 'objects' );
330
  if ( !empty( $taxonomies ) ) {
331
  foreach ( $taxonomies as $tax_name => $tax_object ) {
332
  /*
333
  * WordPress 3.5 adds native support for taxonomies
334
  */
335
- if( ! MLATest::$wordpress_3point5_plus ) {
336
  $hook = add_submenu_page( 'upload.php', $tax_object->label, $tax_object->label, 'manage_categories', 'mla-edit-tax-' . $tax_name, 'MLA::mla_edit_tax_redirect' );
337
  add_action( 'load-' . $hook, 'MLA::mla_edit_tax_redirect' );
338
  } // ! MLATest::$wordpress_3point5_plus
339
-
340
  /*
341
  * The page_hook we need for taxonomy edits is slightly different
342
  */
343
  $hook = 'edit-' . $tax_name;
344
  self::$page_hooks[ $hook ] = 't_' . $tax_name;
345
  } // foreach $taxonomies
346
-
347
  /*
348
  * Load here, not 'load-edit-tags.php', to put our tab after the defaults
349
  */
350
  add_action( 'admin_head-edit-tags.php', 'MLA::mla_add_help_tab' );
351
  }
352
-
353
  /*
354
  * If we are suppressing the Media/Library submenu, force Media/Assistant to come first
355
  */
@@ -373,7 +393,7 @@ class MLA {
373
 
374
  add_filter( 'parent_file', 'MLA::mla_parent_file_filter', 10, 1 );
375
  }
376
-
377
  /**
378
  * Redirect to Media/Assistant if Media/Library is hidden
379
  *
@@ -384,23 +404,24 @@ class MLA {
384
  public static function mla_load_media_action( ) {
385
  if ( 'checked' != MLAOptions::mla_get_option( MLAOptions::MLA_SCREEN_DISPLAY_LIBRARY ) ) {
386
  $query_args = '?page=mla-menu';
387
-
388
  /*
389
  * Compose a message if returning from the Edit Media screen
390
  */
391
  if ( ! empty( $_GET['deleted'] ) && $deleted = absint( $_GET['deleted'] ) ) {
392
- $query_args .= '&mla_admin_message=' . urlencode( sprintf( _n( 'Item permanently deleted.', '%d items permanently deleted.', $deleted ), number_format_i18n( $_GET['deleted'] ) ) );
393
  }
394
-
395
  if ( ! empty( $_GET['trashed'] ) && $trashed = absint( $_GET['trashed'] ) ) {
396
- $query_args .= '&mla_admin_message=' . urlencode( sprintf( 'Item $1%d: moved to Trash.', number_format_i18n( $_GET['ids'] ) ) );
 
397
  }
398
-
399
  wp_redirect( admin_url( 'upload.php' ) . $query_args, 302 );
400
  exit;
401
  }
402
  }
403
-
404
  /**
405
  * Add the "XX Entries per page" filter to the Screen Options tab
406
  *
@@ -410,16 +431,16 @@ class MLA {
410
  */
411
  public static function mla_add_menu_options( ) {
412
  $option = 'per_page';
413
-
414
  $args = array(
415
- 'label' => 'Entries per page',
416
  'default' => 10,
417
  'option' => 'mla_entries_per_page'
418
  );
419
-
420
  add_screen_option( $option, $args );
421
  }
422
-
423
  /**
424
  * Add contextual help tabs to all the MLA pages
425
  *
@@ -433,14 +454,16 @@ class MLA {
433
  /*
434
  * Is this one of our pages?
435
  */
436
- if ( !array_key_exists( $screen->id, self::$page_hooks ) )
437
  return;
438
-
439
- if ( 'edit-tags' == $screen->base && 'attachment' != $screen->post_type )
 
440
  return;
441
-
 
442
  $file_suffix = $screen->id;
443
-
444
  /*
445
  * Override the screen suffix if we are going to display something other than the attachment table
446
  */
@@ -450,8 +473,7 @@ class MLA {
450
  $file_suffix = self::MLA_ADMIN_SINGLE_EDIT_DISPLAY;
451
  break;
452
  } // switch
453
- } // isset( $_REQUEST['mla_admin_action'] )
454
- else {
455
  /*
456
  * Use a generic page for edit taxonomy screens
457
  */
@@ -464,36 +486,38 @@ class MLA {
464
  default:
465
  $tax_object = get_taxonomy( $taxonomy );
466
 
467
- if ( $tax_object->hierarchical )
468
  $file_suffix = 'edit-hierarchical-taxonomy';
469
- else
470
  $file_suffix = 'edit-flat-taxonomy';
 
471
  } // $taxonomy switch
472
  } // is taxonomy
473
  }
474
-
475
- $template_array = MLAData::mla_load_template( MLA_PLUGIN_PATH . 'tpls/help-for-' . $file_suffix . '.tpl' );
476
  if ( empty( $template_array ) ) {
477
  return;
478
  }
479
-
480
  /*
481
  * Don't add sidebar to the WordPress category and post_tag screens
482
  */
483
- if ( ! ( 'edit-tags' == $screen->base && in_array( $screen->taxonomy, array( 'post_tag', 'category' ) ) ) )
484
  if ( !empty( $template_array['sidebar'] ) ) {
485
  $screen->set_help_sidebar( $template_array['sidebar'] );
486
- unset( $template_array['sidebar'] );
487
  }
488
-
 
 
489
  /*
490
  * Provide explicit control over tab order
491
  */
492
  $tab_array = array();
493
-
494
  foreach ( $template_array as $id => $content ) {
495
  $match_count = preg_match( '#\<!-- title="(.+)" order="(.+)" --\>#', $content, $matches, PREG_OFFSET_CAPTURE );
496
-
497
  if ( $match_count > 0 ) {
498
  $tab_array[ $matches[ 2 ][ 0 ] ] = array(
499
  'id' => $id,
@@ -501,23 +525,26 @@ class MLA {
501
  'content' => $content
502
  );
503
  } else {
504
- error_log( 'ERROR: mla_add_help_tab discarding '.var_export( $id, true ), 0 );
 
505
  }
506
  }
507
-
508
  ksort( $tab_array, SORT_NUMERIC );
509
  foreach ( $tab_array as $indx => $value ) {
510
  /*
511
  * Don't add duplicate tabs to the WordPress category and post_tag screens
512
  */
513
- if ( 'edit-tags' == $screen->base && in_array( $screen->taxonomy, array( 'post_tag', 'category' ) ) )
514
- if ( 'mla-attachments-column' != $value['id'] )
515
  continue;
516
-
 
 
517
  $screen->add_help_tab( $value );
518
  }
519
  }
520
-
521
  /**
522
  * Only show screen options on the table-list screen
523
  *
@@ -529,12 +556,13 @@ class MLA {
529
  * @return boolean True to display "Screen Options", false to suppress them
530
  */
531
  public static function mla_screen_options_show_screen_filter( $show_screen, $this_screen ) {
532
- if ( isset( $_REQUEST['mla_admin_action'] ) && ( $_REQUEST['mla_admin_action'] == self::MLA_ADMIN_SINGLE_EDIT_DISPLAY ) )
533
  return false;
 
534
 
535
  return $show_screen;
536
  }
537
-
538
  /**
539
  * Save the "Entries per page" option set by this user
540
  *
@@ -548,12 +576,13 @@ class MLA {
548
  */
549
  public static function mla_set_screen_option_filter( $status, $option, $value )
550
  {
551
- if ( 'mla_entries_per_page' == $option )
552
  return $value;
553
- elseif ( $status )
554
  return $status;
 
555
  }
556
-
557
  /**
558
  * Redirect to the Edit Tags/Categories page
559
  *
@@ -570,8 +599,9 @@ class MLA {
570
  /*
571
  * WordPress 3.5 adds native support for taxonomies
572
  */
573
- if( MLATest::$wordpress_3point5_plus )
574
  return;
 
575
 
576
  $screen = get_current_screen();
577
 
@@ -581,7 +611,7 @@ class MLA {
581
  exit;
582
  }
583
  }
584
-
585
  /**
586
  * Cleanup menus for Edit Tags/Categories page
587
  *
@@ -607,7 +637,7 @@ class MLA {
607
  if ( 'media_page_' . self::ADMIN_PAGE_SLUG == $hook_suffix ) {
608
  $submenu_file = self::ADMIN_PAGE_SLUG;
609
  }
610
-
611
  /*
612
  * Make sure the "Assistant" submenu line is bolded if the Media/Library submenu is hidden
613
  */
@@ -615,29 +645,29 @@ class MLA {
615
  'upload.php' == $parent_file && 'upload.php' == $submenu_file ) {
616
  $submenu_file = self::ADMIN_PAGE_SLUG;
617
  }
618
-
619
  /*
620
  * Make sure the "Assistant" submenu line is bolded when we go to the Edit Media page
621
  */
622
  if ( isset( $_REQUEST['mla_source'] ) ) {
623
  $submenu_file = self::ADMIN_PAGE_SLUG;
624
  }
625
-
626
  /*
627
  * WordPress 3.5 adds native support for taxonomies
628
  */
629
- if( MLATest::$wordpress_3point5_plus ) {
630
  return $parent_file;
631
  }
632
 
633
  if ( isset( $_REQUEST['taxonomy'] ) ) {
634
  $taxonomies = get_object_taxonomies( 'attachment', 'objects' );
635
-
636
  foreach ( $taxonomies as $tax_name => $tax_object ) {
637
  if ( $_REQUEST['taxonomy'] == $tax_name ) {
638
  $mla_page = 'mla-edit-tax-' . $tax_name;
639
  $real_page = 'edit-tags.php?taxonomy=' . $tax_name . '&post_type=attachment';
640
-
641
  foreach ( $submenu['upload.php'] as $submenu_index => $submenu_entry ) {
642
  if ( $submenu_entry[ 2 ] == $mla_page ) {
643
  $submenu['upload.php'][ $submenu_index ][ 2 ] = $real_page;
@@ -647,10 +677,10 @@ class MLA {
647
  }
648
  }
649
  }
650
-
651
  return $parent_file;
652
  }
653
-
654
  /**
655
  * Render the "Assistant" subpage in the Media section, using the list_table package
656
  *
@@ -663,53 +693,57 @@ class MLA {
663
  * WordPress class-wp-list-table.php doesn't look in hidden fields to set
664
  * the month filter dropdown or sorting parameters
665
  */
666
- if ( isset( $_REQUEST['m'] ) )
667
  $_GET['m'] = $_REQUEST['m'];
668
-
669
- if ( isset( $_REQUEST['order'] ) )
 
670
  $_GET['order'] = $_REQUEST['order'];
671
-
672
- if ( isset( $_REQUEST['orderby'] ) )
 
673
  $_GET['orderby'] = $_REQUEST['orderby'];
674
-
 
675
  $bulk_action = self::_current_bulk_action();
676
 
677
  $page_title = MLAOptions::mla_get_option( MLAOptions::MLA_SCREEN_PAGE_TITLE );
678
  echo "<div class=\"wrap\">\r\n";
679
  echo "<div id=\"icon-upload\" class=\"icon32\"><br/></div>\r\n";
680
  echo "<h2>{$page_title}"; // trailing </h2> is action-specific
681
-
682
  if ( !current_user_can( 'upload_files' ) ) {
683
  echo " - Error</h2>\r\n";
684
- wp_die( __( 'You do not have permission to manage attachments.' ) );
685
  }
686
-
687
  $page_content = array(
688
  'message' => '',
689
  'body' => ''
690
  );
691
-
692
  if ( !empty( $_REQUEST['mla_admin_message'] ) ) {
693
  $page_content['message'] = $_REQUEST['mla_admin_message'];
694
  }
695
-
696
  /*
697
  * The category taxonomy (edit screens) is a special case because
698
  * post_categories_meta_box() changes the input name
699
  */
700
- if ( !isset( $_REQUEST['tax_input'] ) )
701
  $_REQUEST['tax_input'] = array();
702
-
 
703
  if ( isset( $_REQUEST['post_category'] ) ) {
704
  $_REQUEST['tax_input']['category'] = $_REQUEST['post_category'];
705
  unset ( $_REQUEST['post_category'] );
706
  }
707
-
708
  /*
709
  * Process bulk actions that affect an array of items
710
  */
711
  if ( $bulk_action && ( $bulk_action != 'none' ) ) {
712
-
713
  if ( isset( $_REQUEST['cb_attachment'] ) ) {
714
  foreach ( $_REQUEST['cb_attachment'] as $index => $post_id ) {
715
  switch ( $bulk_action ) {
@@ -722,42 +756,46 @@ class MLA {
722
  $item_content = MLAData::mla_update_single_item( $post_id, $updates );
723
  break;
724
  }
725
-
726
  if ( !empty( $_REQUEST['bulk_map'] ) ) {
727
  $item = get_post( $post_id );
728
  $updates = MLAOptions::mla_evaluate_iptc_exif_mapping( $item, 'iptc_exif_mapping' );
729
  $item_content = MLAData::mla_update_single_item( $post_id, $updates );
730
  break;
731
  }
732
-
733
  /*
734
  * Copy the edit form contents to $new_data
735
  */
736
  $new_data = array() ;
737
  if ( isset( $_REQUEST['post_parent'] ) ) {
738
- if ( is_numeric( $_REQUEST['post_parent'] ) )
739
  $new_data['post_parent'] = $_REQUEST['post_parent'];
 
740
  }
741
-
742
  if ( isset( $_REQUEST['post_author'] ) ) {
743
- if ( -1 != $_REQUEST['post_author'] )
744
  $new_data['post_author'] = $_REQUEST['post_author'];
 
745
  }
746
-
747
  /*
748
  * Custom field support
749
  */
750
  $custom_fields = array();
751
  foreach (MLAOptions::mla_custom_field_support( 'bulk_edit' ) as $slug => $label ) {
752
  if ( isset( $_REQUEST[ $slug ] ) ) {
753
- if ( ! empty( $_REQUEST[ $slug ] ) )
754
  $custom_fields[ $label ] = $_REQUEST[ $slug ];
 
755
  }
756
  } // foreach
757
-
758
- if ( ! empty( $custom_fields ) )
759
  $new_data[ 'custom_updates' ] = $custom_fields;
760
-
 
761
  $item_content = MLAData::mla_update_single_item( $post_id, $new_data, $_REQUEST['tax_input'], $_REQUEST['tax_action'] );
762
  break;
763
  case 'restore':
@@ -769,11 +807,12 @@ class MLA {
769
  break;
770
  default:
771
  $item_content = array(
772
- 'message' => sprintf( 'Unknown bulk action %s', $bulk_action ),
 
773
  'body' => ''
774
  );
775
  } // switch $bulk_action
776
-
777
  $page_content['message'] .= $item_content['message'] . '<br>';
778
  } // foreach cb_attachment
779
 
@@ -786,16 +825,16 @@ class MLA {
786
  unset( $_REQUEST[ $slug ] );
787
 
788
  unset( $_REQUEST['cb_attachment'] );
789
- } // isset cb_attachment
790
- else {
791
- $page_content['message'] = 'Bulk Action ' . $bulk_action . ' - no items selected.';
792
  }
793
 
794
  unset( $_REQUEST['action'] );
795
  unset( $_REQUEST['bulk_edit'] );
796
  unset( $_REQUEST['action2'] );
797
  } // $bulk_action
798
-
799
  if ( isset( $_REQUEST['clear_filter_by'] ) ) {
800
  unset( $_REQUEST['heading_suffix'] );
801
  unset( $_REQUEST['parent'] );
@@ -805,39 +844,41 @@ class MLA {
805
  unset( $_REQUEST['mla-metakey'] );
806
  unset( $_REQUEST['mla-metavalue'] );
807
  }
808
-
809
  if ( isset( $_REQUEST['delete_all'] ) ) {
810
  global $wpdb;
811
-
812
  $ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", 'attachment', 'trash' ) );
813
  $delete_count = 0;
814
  foreach ( $ids as $post_id ) {
815
  $item_content = self::_delete_single_item( $post_id );
816
-
817
- if ( false !== strpos( $item_content['message'], 'ERROR:' ) )
818
  $page_content['message'] .= $item_content['message'] . '<br>';
819
- else
820
  $delete_count++;
 
821
  }
822
 
823
- if ( $delete_count )
824
- $page_content['message'] .= sprintf( _nx( '%s item deleted.', '%s items deleted.', $delete_count, 'deleted items' ), number_format_i18n( $delete_count ) );
825
- else
826
- $page_content['message'] .= 'No items deleted.';
 
827
  }
828
-
829
  /*
830
  * Process row-level actions that affect a single item
831
  */
832
  if ( !empty( $_REQUEST['mla_admin_action'] ) ) {
833
  check_admin_referer( self::MLA_ADMIN_NONCE );
834
-
835
  switch ( $_REQUEST['mla_admin_action'] ) {
836
  case self::MLA_ADMIN_SINGLE_DELETE:
837
  $page_content = self::_delete_single_item( $_REQUEST['mla_item_ID'] );
838
  break;
839
  case self::MLA_ADMIN_SINGLE_EDIT_DISPLAY:
840
- echo " - Edit single item</h2>";
841
  $page_content = self::_display_single_item( $_REQUEST['mla_item_ID'] );
842
  break;
843
  case self::MLA_ADMIN_SINGLE_EDIT_UPDATE:
@@ -849,7 +890,8 @@ class MLA {
849
  $page_content = MLAData::mla_update_single_item( $_REQUEST['mla_item_ID'], $updates );
850
  } else {
851
  $page_content = array(
852
- 'message' => 'Item: ' . $_REQUEST['mla_item_ID'] . ' cancelled.',
 
853
  'body' => ''
854
  );
855
  }
@@ -862,25 +904,27 @@ class MLA {
862
  break;
863
  default:
864
  $page_content = array(
865
- 'message' => sprintf( 'Unknown mla_admin_action - "%1$s"', $_REQUEST['mla_admin_action'] ),
 
866
  'body' => ''
867
  );
868
  break;
869
  } // switch ($_REQUEST['mla_admin_action'])
870
  } // (!empty($_REQUEST['mla_admin_action'])
871
-
872
  if ( !empty( $page_content['body'] ) ) {
873
  if ( !empty( $page_content['message'] ) ) {
874
- if ( false !== strpos( $page_content['message'], 'ERROR:' ) )
875
  $messages_class = 'mla_errors';
876
- else
877
  $messages_class = 'mla_messages';
 
878
 
879
  echo " <div class=\"{$messages_class}\"><p>\r\n";
880
  echo ' ' . $page_content['message'] . "\r\n";
881
  echo " </p></div>\r\n"; // id="message"
882
  }
883
-
884
  echo $page_content['body'];
885
  } else {
886
  /*
@@ -890,28 +934,31 @@ class MLA {
890
  echo ' - ' . esc_html( $_REQUEST['heading_suffix'] ) . "</h2>\r\n";
891
  } elseif ( !empty( $_REQUEST['s'] ) && !empty( $_REQUEST['mla_search_fields'] ) ) {
892
  echo ' - search results for "' . esc_html( stripslashes( trim( $_REQUEST['s'] ) ) ) . "\"</h2>\r\n";
893
- } else
894
  echo "</h2>\r\n";
895
-
 
896
  if ( !empty( $page_content['message'] ) ) {
897
- if ( false !== strpos( $page_content['message'], 'ERROR:' ) )
898
  $messages_class = 'mla_errors';
899
- else
900
  $messages_class = 'mla_messages';
 
901
 
902
  echo " <div class=\"{$messages_class}\"><p>\r\n";
903
  echo ' ' . $page_content['message'] . "\r\n";
904
  echo " </p></div>\r\n"; // id="message"
905
  }
906
-
907
  /*
908
  * Optional - limit width of the views list
909
  */
910
  $view_width = MLAOptions::mla_get_option( MLAOptions::MLA_TABLE_VIEWS_WIDTH );
911
  if ( !empty( $view_width ) ) {
912
- if ( is_numeric( $view_width ) )
913
  $view_width .= 'px';
914
-
 
915
  echo " <style type='text/css'>\r\n";
916
  echo " ul.subsubsub {\r\n";
917
  echo " width: {$view_width};\r\n";
@@ -922,11 +969,11 @@ class MLA {
922
 
923
  // Create an instance of our package class...
924
  $MLAListTable = new MLA_List_Table();
925
-
926
  // Fetch, prepare, sort, and filter our data...
927
  $MLAListTable->prepare_items();
928
  $MLAListTable->views();
929
-
930
  // Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions
931
  // echo '<form action="' . admin_url( 'upload.php' ) . '" method="get" id="mla-filter">' . "\r\n";
932
  echo '<form action="' . admin_url( 'upload.php?page=' . self::ADMIN_PAGE_SLUG ) . '" method="post" id="mla-filter">' . "\r\n";
@@ -943,43 +990,48 @@ class MLA {
943
  $search_fields = array ( 'title', 'content' );
944
  $search_connector = 'AND';
945
  }
946
-
947
  echo '<p class="search-box">' . "\r\n";
948
- echo '<label class="screen-reader-text" for="media-search-input">Search Media:</label>' . "\r\n";
949
  echo '<input type="text" size="45" id="media-search-input" name="s" value="' . $search_value . '" />' . "\r\n";
950
  echo '<input type="submit" name="mla-search-submit" id="search-submit" class="button" value="Search Media" /><br>' . "\r\n";
951
  if ( 'OR' == $search_connector ) {
952
- echo '<input type="radio" name="mla_search_connector" value="AND" />&nbsp;and&nbsp;' . "\r\n";
953
- echo '<input type="radio" name="mla_search_connector" checked="checked" value="OR" />&nbsp;or&nbsp;' . "\r\n";
 
 
 
 
 
 
 
954
  } else {
955
- echo '<input type="radio" name="mla_search_connector" checked="checked" value="AND" />&nbsp;and&nbsp;' . "\r\n";
956
- echo '<input type="radio" name="mla_search_connector" value="OR" />&nbsp;or&nbsp;' . "\r\n";
957
  }
958
 
959
- if ( in_array( 'title', $search_fields ) )
960
- echo '<input type="checkbox" name="mla_search_fields[]" id="search-title" checked="checked" value="title" />&nbsp;title&nbsp;' . "\r\n";
961
- else
962
- echo '<input type="checkbox" name="mla_search_fields[]" id="search-title" value="title" />&nbsp;title&nbsp;' . "\r\n";
963
-
964
- if ( in_array( 'name', $search_fields ) )
965
- echo '<input type="checkbox" name="mla_search_fields[]" id="search-name" checked="checked" value="name" />&nbsp;name&nbsp;' . "\r\n";
966
- else
967
- echo '<input type="checkbox" name="mla_search_fields[]" id="search-name" value="name" />&nbsp;name&nbsp;' . "\r\n";
968
-
969
- if ( in_array( 'alt-text', $search_fields ) )
970
- echo '<input type="checkbox" name="mla_search_fields[]" id="search-alt-text" checked="checked" value="alt-text" />&nbsp;ALT text&nbsp;' . "\r\n";
971
- else
972
- echo '<input type="checkbox" name="mla_search_fields[]" id="search-alt-text" value="alt-text" />&nbsp;ALT text&nbsp;' . "\r\n";
973
-
974
- if ( in_array( 'excerpt', $search_fields ) )
975
- echo '<input type="checkbox" name="mla_search_fields[]" id="search-excerpt" checked="checked" value="excerpt" />&nbsp;caption&nbsp;' . "\r\n";
976
- else
977
- echo '<input type="checkbox" name="mla_search_fields[]" id="search-excerpt" value="excerpt" />&nbsp;caption&nbsp;' . "\r\n";
978
-
979
- if ( in_array( 'content', $search_fields ) )
980
- echo '<input type="checkbox" name="mla_search_fields[]" id="search-content" checked="checked" value="content" />&nbsp;description&nbsp;' . "\r\n";
981
- else
982
- echo '<input type="checkbox" name="mla_search_fields[]" id="search-content" value="content" />&nbsp;description&nbsp;' . "\r\n";
983
 
984
  echo '</p>' . "\r\n";
985
 
@@ -987,41 +1039,43 @@ class MLA {
987
  * We also need to ensure that the form posts back to our current page and remember all the view arguments
988
  */
989
  echo sprintf( '<input type="hidden" name="page" value="%1$s" />', $_REQUEST['page'] ) . "\r\n";
990
-
991
  $view_arguments = MLA_List_Table::mla_submenu_arguments();
992
  foreach ( $view_arguments as $key => $value ) {
993
- if ( 'meta_query' == $key )
994
  $value = stripslashes( $_REQUEST['meta_query'] );
 
995
 
996
  /*
997
  * Search box elements are already set up in the above "search-box"
998
  */
999
- if ( in_array( $key, array( 's', 'mla_search_connector', 'mla_search_fields' ) ) )
1000
  continue;
1001
-
 
1002
  if ( is_array( $value ) ) {
1003
  foreach ( $value as $element_key => $element_value )
1004
  echo sprintf( '<input type="hidden" name="%1$s[%2$s]" value="%3$s" />', $key, $element_key, esc_attr( $element_value ) ) . "\r\n";
1005
- }
1006
- else
1007
  echo sprintf( '<input type="hidden" name="%1$s" value="%2$s" />', $key, esc_attr( $value ) ) . "\r\n";
 
1008
  }
1009
 
1010
  // Now we can render the completed list table
1011
  $MLAListTable->display();
1012
  echo "</form><!-- id=mla-filter -->\r\n";
1013
-
1014
  /*
1015
  * Insert the hidden form and table for inline edits (quick & bulk)
1016
  */
1017
  echo self::_build_inline_edit_form($MLAListTable);
1018
-
1019
  echo "<div id=\"ajax-response\"></div>\r\n";
1020
  echo "<br class=\"clear\" />\r\n";
1021
  echo "</div><!-- class=wrap -->\r\n";
1022
  } // display attachments list
1023
  }
1024
-
1025
  /**
1026
  * Ajax handler for inline editing (quick and bulk edit)
1027
  *
@@ -1035,16 +1089,17 @@ class MLA {
1035
  set_current_screen( $_REQUEST['screen'] );
1036
 
1037
  check_ajax_referer( self::MLA_ADMIN_NONCE, 'nonce' );
1038
-
1039
  if ( empty( $_REQUEST['post_ID'] ) ) {
1040
- echo 'Error: no post ID found';
1041
  die();
1042
- }
1043
- else
1044
  $post_id = $_REQUEST['post_ID'];
1045
-
1046
- if ( ! current_user_can( 'edit_post', $post_id ) )
1047
- wp_die( __( 'You are not allowed to edit this Attachment.' ) );
 
 
1048
 
1049
  /*
1050
  * Custom field support
@@ -1057,20 +1112,22 @@ class MLA {
1057
  }
1058
  }
1059
 
1060
- if ( ! empty( $custom_fields ) )
1061
  $_REQUEST[ 'custom_updates' ] = $custom_fields;
1062
-
 
1063
  /*
1064
  * The category taxonomy is a special case because post_categories_meta_box() changes the input name
1065
  */
1066
- if ( !isset( $_REQUEST['tax_input'] ) )
1067
  $_REQUEST['tax_input'] = array();
1068
-
 
1069
  if ( isset( $_REQUEST['post_category'] ) ) {
1070
  $_REQUEST['tax_input']['category'] = $_REQUEST['post_category'];
1071
  unset ( $_REQUEST['post_category'] );
1072
  }
1073
-
1074
  if ( ! empty( $_REQUEST['tax_input'] ) ) {
1075
  /*
1076
  * Flat taxonomy strings must be cleaned up and duplicates removed
@@ -1079,32 +1136,34 @@ class MLA {
1079
  $tax_input = $_REQUEST['tax_input'];
1080
  foreach ( $tax_input as $tax_name => $tax_value ) {
1081
  if ( ! is_array( $tax_value ) ) {
1082
- $comma = _x( ',', 'tag delimiter' );
1083
- if ( ',' != $comma )
1084
  $tax_value = str_replace( $comma, ',', $tax_value );
1085
-
 
1086
  $tax_value = preg_replace( '#\s*,\s*#', ',', $tax_value );
1087
  $tax_value = preg_replace( '#,+#', ',', $tax_value );
1088
  $tax_value = preg_replace( '#[,\s]+$#', '', $tax_value );
1089
  $tax_value = preg_replace( '#^[,\s]+#', '', $tax_value );
1090
-
1091
- if ( ',' != $comma )
1092
  $tax_value = str_replace( ',', $comma, $tax_value );
1093
-
 
1094
  $tax_array = array();
1095
  $dedup_array = explode( $comma, $tax_value );
1096
  foreach ( $dedup_array as $tax_value )
1097
  $tax_array [$tax_value] = $tax_value;
1098
-
1099
  $tax_value = implode( $comma, $tax_array );
1100
  } // ! array( $tax_value )
1101
-
1102
  $tax_output[$tax_name] = $tax_value;
1103
  } // foreach $tax_input
1104
- } // ! empty( $_REQUEST['tax_input'] )
1105
- else
1106
  $tax_output = NULL;
1107
-
 
1108
  $results = MLAData::mla_update_single_item( $post_id, $_REQUEST, $tax_output );
1109
  $new_item = (object) MLAData::mla_get_attachment_by_id( $post_id );
1110
 
@@ -1113,7 +1172,7 @@ class MLA {
1113
  $MLAListTable->single_row( $new_item );
1114
  die(); // this is required to return a proper result
1115
  }
1116
-
1117
  /**
1118
  * Build the hidden row templates for inline editing (quick and bulk edit)
1119
  *
@@ -1127,7 +1186,7 @@ class MLA {
1127
  */
1128
  private static function _build_inline_edit_form( $MLAListTable ) {
1129
  $taxonomies = get_object_taxonomies( 'attachment', 'objects' );
1130
-
1131
  $hierarchical_taxonomies = array();
1132
  $flat_taxonomies = array();
1133
  foreach ( $taxonomies as $tax_name => $tax_object ) {
@@ -1138,20 +1197,21 @@ class MLA {
1138
  }
1139
  }
1140
 
1141
- $page_template_array = MLAData::mla_load_template( MLA_PLUGIN_PATH . 'tpls/admin-inline-edit-form.tpl' );
1142
  if ( ! array( $page_template_array ) ) {
1143
- error_log( "ERROR: MLA::_build_inline_edit_form \$page_template_array = " . var_export( $page_template_array, true ), 0 );
 
1144
  return '';
1145
  }
1146
-
1147
  if ( $authors = self::_authors_dropdown() ) {
1148
  $authors_dropdown = ' <label class="inline-edit-author">' . "\r\n";
1149
- $authors_dropdown .= ' <span class="title">' . __( 'Author' ) . '</span>' . "\r\n";
1150
  $authors_dropdown .= $authors . "\r\n";
1151
  $authors_dropdown .= ' </label>' . "\r\n";
1152
- }
1153
- else
1154
  $authors_dropdown = '';
 
1155
 
1156
  $custom_fields = '';
1157
  foreach (MLAOptions::mla_custom_field_support( 'quick_edit' ) as $slug => $label ) {
@@ -1161,13 +1221,13 @@ class MLA {
1161
  );
1162
  $custom_fields .= MLAData::mla_parse_template( $page_template_array['custom_field'], $page_values );
1163
  }
1164
-
1165
  /*
1166
  * The middle column contains the hierarchical taxonomies, e.g., Attachment Category
1167
  */
1168
  $quick_middle_column = '';
1169
  $bulk_middle_column = '';
1170
-
1171
  if ( count( $hierarchical_taxonomies ) ) {
1172
  $quick_category_blocks = '';
1173
  $bulk_category_blocks = '';
@@ -1181,8 +1241,13 @@ class MLA {
1181
 
1182
  $page_values = array(
1183
  'tax_html' => esc_html( $tax_object->labels->name ),
 
 
1184
  'tax_attr' => esc_attr( $tax_name ),
1185
- 'tax_checklist' => $tax_checklist
 
 
 
1186
  );
1187
  $category_block = MLAData::mla_parse_template( $page_template_array['category_block'], $page_values );
1188
  $taxonomy_options = MLAData::mla_parse_template( $page_template_array['taxonomy_options'], $page_values );
@@ -1202,13 +1267,13 @@ class MLA {
1202
  );
1203
  $bulk_middle_column = MLAData::mla_parse_template( $page_template_array['category_fieldset'], $page_values );
1204
  } // count( $hierarchical_taxonomies )
1205
-
1206
  /*
1207
  * The right-hand column contains the flat taxonomies, e.g., Attachment Tag
1208
  */
1209
  $quick_right_column = '';
1210
  $bulk_right_column = '';
1211
-
1212
  if ( count( $flat_taxonomies ) ) {
1213
  $quick_tag_blocks = '';
1214
  $bulk_tag_blocks = '';
@@ -1217,7 +1282,10 @@ class MLA {
1217
  if ( current_user_can( $tax_object->cap->assign_terms ) ) {
1218
  $page_values = array(
1219
  'tax_html' => esc_html( $tax_object->labels->name ),
1220
- 'tax_attr' => esc_attr( $tax_name )
 
 
 
1221
  );
1222
  $tag_block = MLAData::mla_parse_template( $page_template_array['tag_block'], $page_values );
1223
  $taxonomy_options = MLAData::mla_parse_template( $page_template_array['taxonomy_options'], $page_values );
@@ -1237,15 +1305,15 @@ class MLA {
1237
  );
1238
  $bulk_right_column = MLAData::mla_parse_template( $page_template_array['tag_fieldset'], $page_values );
1239
  } // count( $flat_taxonomies )
1240
-
1241
  if ( $authors = self::_authors_dropdown( -1 ) ) {
1242
  $bulk_authors_dropdown = ' <label class="inline-edit-author">' . "\r\n";
1243
- $bulk_authors_dropdown .= ' <span class="title">' . __( 'Author' ) . '</span>' . "\r\n";
1244
  $bulk_authors_dropdown .= $authors . "\r\n";
1245
  $bulk_authors_dropdown .= ' </label>' . "\r\n";
1246
- }
1247
- else
1248
  $bulk_authors_dropdown = '';
 
1249
 
1250
  $bulk_custom_fields = '';
1251
  foreach (MLAOptions::mla_custom_field_support( 'bulk_edit' ) as $slug => $label ) {
@@ -1258,19 +1326,32 @@ class MLA {
1258
 
1259
  $page_values = array(
1260
  'colspan' => count( $MLAListTable->get_columns() ),
 
 
 
 
 
 
 
 
1261
  'authors' => $authors_dropdown,
1262
  'custom_fields' => $custom_fields,
1263
  'quick_middle_column' => $quick_middle_column,
1264
  'quick_right_column' => $quick_right_column,
 
 
 
1265
  'bulk_middle_column' => $bulk_middle_column,
1266
  'bulk_right_column' => $bulk_right_column,
1267
  'bulk_authors' => $bulk_authors_dropdown,
1268
- 'bulk_custom_fields' => $bulk_custom_fields
 
 
1269
  );
1270
  $page_template = MLAData::mla_parse_template( $page_template_array['page'], $page_values );
1271
  return $page_template;
1272
  }
1273
-
1274
  /**
1275
  * Get the edit Authors dropdown box, if user has suitable permissions
1276
  *
@@ -1293,22 +1374,22 @@ class MLA {
1293
  'multi' => 1,
1294
  'echo' => 0
1295
  );
1296
-
1297
  if ( $author > 0 ) {
1298
  $users_opt['selected'] = $author;
1299
  $users_opt['include_selected'] = true;
 
 
1300
  }
1301
- elseif ( -1 == $author )
1302
- $users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
1303
 
1304
  if ( $authors = wp_dropdown_users( $users_opt ) ) {
1305
  return $authors;
1306
  }
1307
  }
1308
-
1309
  return false;
1310
  }
1311
-
1312
  /**
1313
  * Get the current action selected from the bulk actions dropdown
1314
  *
@@ -1318,24 +1399,26 @@ class MLA {
1318
  */
1319
  private static function _current_bulk_action( ) {
1320
  $action = false;
1321
-
1322
  if ( isset( $_REQUEST['action'] ) ) {
1323
- if ( -1 != $_REQUEST['action'] )
1324
  return $_REQUEST['action'];
1325
- else
1326
  $action = 'none';
 
1327
  } // isset action
1328
-
1329
  if ( isset( $_REQUEST['action2'] ) ) {
1330
- if ( -1 != $_REQUEST['action2'] )
1331
  return $_REQUEST['action2'];
1332
- else
1333
  $action = 'none';
 
1334
  } // isset action2
1335
-
1336
  return $action;
1337
  }
1338
-
1339
  /**
1340
  * Delete a single item permanently
1341
  *
@@ -1346,24 +1429,28 @@ class MLA {
1346
  * @return array success/failure message and NULL content
1347
  */
1348
  private static function _delete_single_item( $post_id ) {
1349
- if ( !current_user_can( 'delete_post', $post_id ) )
1350
  return array(
1351
- 'message' => 'ERROR: You are not allowed to delete this item.',
1352
  'body' => ''
1353
  );
1354
-
1355
- if ( !wp_delete_attachment( $post_id, true ) )
 
1356
  return array(
1357
- 'message' => 'ERROR: Item ' . $post_id . ' could NOT be deleted.',
 
1358
  'body' => ''
1359
  );
1360
-
 
1361
  return array(
1362
- 'message' => 'Item: ' . $post_id . ' permanently deleted.',
 
1363
  'body' => ''
1364
  );
1365
  }
1366
-
1367
  /**
1368
  * Display a single item sub page; prepare the form to
1369
  * change the meta data for a single attachment.
@@ -1383,159 +1470,175 @@ class MLA {
1383
  * This function sets the global $post
1384
  */
1385
  $post_data = MLAData::mla_get_attachment_by_id( $post_id );
1386
- if ( !isset( $post_data ) )
1387
  return array(
1388
- 'message' => 'ERROR: Could not retrieve Attachment.',
1389
  'body' => ''
1390
  );
1391
-
1392
- if ( ! current_user_can( 'edit_post', $post_id ) )
 
1393
  return array(
1394
- 'message' => 'You are not allowed to edit this Attachment.',
1395
  'body' => ''
1396
  );
 
1397
 
1398
- if ( !empty( $post_data['mla_wp_attachment_metadata'] ) ) {
1399
- $page_template_array = MLAData::mla_load_template( MLA_PLUGIN_PATH . 'tpls/admin-display-single-image.tpl' );
1400
  $width = isset( $post_data['mla_wp_attachment_metadata']['width'] ) ? $post_data['mla_wp_attachment_metadata']['width'] : '';
1401
  $height = isset( $post_data['mla_wp_attachment_metadata']['height'] ) ? $post_data['mla_wp_attachment_metadata']['height'] : '';
1402
  $image_meta = var_export( $post_data['mla_wp_attachment_metadata'], true );
1403
-
1404
- if ( !isset( $post_data['mla_wp_attachment_image_alt'] ) )
1405
  $post_data['mla_wp_attachment_image_alt'] = '';
 
1406
  } else {
1407
- $page_template_array = MLAData::mla_load_template( MLA_PLUGIN_PATH . 'tpls/admin-display-single-document.tpl' );
1408
  $width = '';
1409
  $height = '';
1410
  $image_meta = '';
1411
  }
1412
-
1413
  if ( array( $page_template_array ) ) {
1414
  $page_template = $page_template_array['page'];
1415
  $authors_template = $page_template_array['authors'];
1416
  $postbox_template = $page_template_array['postbox'];
1417
  } else {
1418
- error_log( "ERROR: MLA::_display_single_item \$page_template_array = " . var_export( $page_template_array, true ), 0 );
 
1419
  $page_template = $page_template_array;
1420
  $authors_template = '';
1421
  $postbox_template = '';
1422
  }
1423
-
1424
- if ( empty($post_data['mla_references']['parent_title'] ) )
1425
  $parent_info = $post_data['mla_references']['parent_errors'];
1426
- else
1427
  $parent_info = sprintf( '(%1$s) %2$s %3$s', $post_data['mla_references']['parent_type'], $post_data['mla_references']['parent_title'], $post_data['mla_references']['parent_errors'] );
 
1428
 
1429
  if ( $authors = self::_authors_dropdown( $post_data['post_author'], 'attachments[' . $post_data['ID'] . '][post_author]' ) ) {
1430
  $args = array (
1431
  'ID' => $post_data['ID'],
 
1432
  'authors' => $authors
1433
  );
1434
  $authors = MLAData::mla_parse_template( $authors_template, $args );
1435
- }
1436
- else
1437
  $authors = '';
 
1438
 
1439
  if ( MLAOptions::$process_featured_in ) {
1440
  $features = '';
1441
-
1442
  foreach ( $post_data['mla_references']['features'] as $feature_id => $feature ) {
1443
- if ( $feature_id == $post_data['post_parent'] )
1444
- $parent = 'PARENT ';
1445
- else
1446
  $parent = '';
1447
-
 
1448
  $features .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $feature->post_type, /*$3%s*/ $feature_id, /*$4%s*/ $feature->post_title ) . "\r\n";
1449
  } // foreach $feature
 
 
1450
  }
1451
- else
1452
- $features = 'disabled';
1453
-
1454
  if ( MLAOptions::$process_inserted_in ) {
1455
  $inserts = '';
1456
-
1457
  foreach ( $post_data['mla_references']['inserts'] as $file => $insert_array ) {
1458
  $inserts .= $file . "\r\n";
1459
-
1460
  foreach ( $insert_array as $insert ) {
1461
- if ( $insert->ID == $post_data['post_parent'] )
1462
- $parent = ' PARENT ';
1463
- else
1464
  $parent = ' ';
1465
-
 
1466
  $inserts .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $insert->post_type, /*$3%s*/ $insert->ID, /*$4%s*/ $insert->post_title ) . "\r\n";
1467
  } // foreach $insert
1468
  } // foreach $file
 
 
1469
  }
1470
- else
1471
- $inserts = 'disabled';
1472
-
1473
  if ( MLAOptions::$process_gallery_in ) {
1474
  $galleries = '';
1475
-
1476
  foreach ( $post_data['mla_references']['galleries'] as $gallery_id => $gallery ) {
1477
- if ( $gallery_id == $post_data['post_parent'] )
1478
- $parent = 'PARENT ';
1479
- else
1480
  $parent = '';
1481
-
 
1482
  $galleries .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $gallery['post_type'], /*$3%s*/ $gallery_id, /*$4%s*/ $gallery['post_title'] ) . "\r\n";
1483
  } // foreach $gallery
 
 
1484
  }
1485
- else
1486
- $galleries = 'disabled';
1487
 
1488
  if ( MLAOptions::$process_mla_gallery_in ) {
1489
  $mla_galleries = '';
1490
-
1491
  foreach ( $post_data['mla_references']['mla_galleries'] as $gallery_id => $gallery ) {
1492
- if ( $gallery_id == $post_data['post_parent'] )
1493
- $parent = 'PARENT ';
1494
- else
1495
  $parent = '';
1496
-
 
1497
  $mla_galleries .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $gallery['post_type'], /*$3%s*/ $gallery_id, /*$4%s*/ $gallery['post_title'] ) . "\r\n";
1498
  } // foreach $gallery
 
 
1499
  }
1500
- else
1501
- $mla_galleries = 'disabled';
1502
-
1503
  /*
1504
  * WordPress doesn't look in hidden fields to set the month filter dropdown or sorting parameters
1505
  */
1506
- if ( isset( $_REQUEST['m'] ) )
1507
  $url_args = '&m=' . $_REQUEST['m'];
1508
- else
1509
  $url_args = '';
1510
-
1511
- if ( isset( $_REQUEST['post_mime_type'] ) )
 
1512
  $url_args .= '&post_mime_type=' . $_REQUEST['post_mime_type'];
1513
-
1514
- if ( isset( $_REQUEST['order'] ) )
 
1515
  $url_args .= '&order=' . $_REQUEST['order'];
1516
-
1517
- if ( isset( $_REQUEST['orderby'] ) )
 
1518
  $url_args .= '&orderby=' . $_REQUEST['orderby'];
1519
-
 
1520
  /*
1521
  * Add the current view arguments
1522
  */
1523
- if ( isset( $_REQUEST['detached'] ) )
1524
  $view_args = '<input type="hidden" name="detached" value="' . $_REQUEST['detached'] . "\" />\r\n";
1525
- elseif ( isset( $_REQUEST['status'] ) )
1526
  $view_args = '<input type="hidden" name="status" value="' . $_REQUEST['status'] . "\" />\r\n";
1527
- else
1528
  $view_args = '';
1529
-
1530
- if ( isset( $_REQUEST['paged'] ) )
 
1531
  $view_args .= sprintf( '<input type="hidden" name="paged" value="%1$s" />', $_REQUEST['paged'] ) . "\r\n";
1532
-
 
1533
  $side_info_column = '';
1534
  $taxonomies = get_object_taxonomies( 'attachment', 'objects' );
1535
-
1536
  foreach ( $taxonomies as $tax_name => $tax_object ) {
1537
  ob_start();
1538
-
1539
  if ( $tax_object->hierarchical && $tax_object->show_ui ) {
1540
  $box = array(
1541
  'id' => $tax_name . 'div',
@@ -1559,44 +1662,69 @@ class MLA {
1559
  );
1560
  post_tags_meta_box( $post, $box );
1561
  }
1562
-
1563
  $box['inside_html'] = ob_get_contents();
1564
  ob_end_clean();
1565
  $side_info_column .= MLAData::mla_parse_template( $postbox_template, $box );
1566
  }
1567
-
1568
  $page_values = array(
 
1569
  'ID' => $post_data['ID'],
1570
  'post_mime_type' => $post_data['post_mime_type'],
1571
  'menu_order' => $post_data['menu_order'],
1572
- 'post_date' => $post_data['post_date'],
1573
- 'post_modified' => $post_data['post_modified'],
1574
- 'post_parent' => $post_data['post_parent'],
1575
- 'menu_order' => $post_data['menu_order'],
 
 
1576
  'attachment_icon' => wp_get_attachment_image( $post_id, array( 160, 120 ), true ),
 
1577
  'file_name' => esc_html( $post_data['mla_references']['file'] ),
 
 
 
 
 
 
1578
  'width' => $width,
1579
  'height' => $height,
 
 
1580
  'post_title_attr' => esc_attr( $post_data['post_title'] ),
 
1581
  'post_name_attr' => esc_attr( $post_data['post_name'] ),
 
 
1582
  'image_alt_attr' => '',
 
 
1583
  'post_excerpt_attr' => esc_attr( $post_data['post_excerpt'] ),
 
1584
  'post_content' => esc_textarea( $post_data['post_content'] ),
1585
- 'image_meta' => esc_textarea( $image_meta ),
 
1586
  'parent_info' => esc_attr( $parent_info ),
1587
- 'guid_attr' => esc_attr( $post_data['guid'] ),
 
1588
  'authors' => $authors,
 
 
 
 
 
 
1589
  'features' => esc_textarea( $features ),
 
1590
  'inserts' => esc_textarea( $inserts ),
 
1591
  'galleries' => esc_textarea( $galleries ),
 
1592
  'mla_galleries' => esc_textarea( $mla_galleries ),
1593
- 'mla_admin_action' => self::MLA_ADMIN_SINGLE_EDIT_UPDATE,
1594
- 'form_url' => admin_url( 'upload.php' ) . '?page=' . self::ADMIN_PAGE_SLUG . $url_args,
1595
- 'view_args' => $view_args,
1596
- 'wpnonce' => wp_nonce_field( self::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1597
  'side_info_column' => $side_info_column
1598
  );
1599
-
1600
  if ( !empty( $post_data['mla_wp_attachment_image_alt'] ) ) {
1601
  $page_values['image_alt_attr'] = esc_attr( $post_data['mla_wp_attachment_image_alt'] );
1602
  }
@@ -1606,7 +1734,7 @@ class MLA {
1606
  'body' => MLAData::mla_parse_template( $page_template, $page_values )
1607
  );
1608
  }
1609
-
1610
  /**
1611
  * Restore a single item from the Trash
1612
  *
@@ -1617,18 +1745,21 @@ class MLA {
1617
  * @return array success/failure message and NULL content
1618
  */
1619
  private static function _restore_single_item( $post_id ) {
1620
- if ( !current_user_can( 'delete_post', $post_id ) )
1621
  return array(
1622
- 'message' => 'ERROR: You are not allowed to move this item out of the Trash.',
1623
  'body' => ''
1624
  );
1625
-
1626
- if ( !wp_untrash_post( $post_id ) )
 
1627
  return array(
1628
- 'message' => 'ERROR: Item ' . $post_id . ' could NOT be restored from Trash.',
 
1629
  'body' => ''
1630
  );
1631
-
 
1632
  /*
1633
  * Posts are restored to "draft" status, so this must be updated.
1634
  */
@@ -1636,13 +1767,14 @@ class MLA {
1636
  $update_post['ID'] = $post_id;
1637
  $update_post['post_status'] = 'inherit';
1638
  wp_update_post( $update_post );
1639
-
1640
  return array(
1641
- 'message' => 'Item: ' . $post_id . ' restored from Trash.',
 
1642
  'body' => ''
1643
  );
1644
  }
1645
-
1646
  /**
1647
  * Move a single item to Trash
1648
  *
@@ -1653,20 +1785,24 @@ class MLA {
1653
  * @return array success/failure message and NULL content
1654
  */
1655
  private static function _trash_single_item( $post_id ) {
1656
- if ( !current_user_can( 'delete_post', $post_id ) )
1657
  return array(
1658
- 'message' => 'ERROR: You are not allowed to move this item to the Trash.',
1659
  'body' => ''
1660
  );
1661
-
1662
- if ( !wp_trash_post( $post_id, false ) )
 
1663
  return array(
1664
- 'message' => 'ERROR: Item ' . $post_id . ' could NOT be moved to Trash.',
 
1665
  'body' => ''
1666
  );
1667
-
 
1668
  return array(
1669
- 'message' => 'Item: ' . $post_id . ' moved to Trash.',
 
1670
  'body' => ''
1671
  );
1672
  }
22
  */
23
  class MLA {
24
 
 
 
 
 
 
 
 
 
 
25
  /**
26
  * Current version number
27
  *
29
  *
30
  * @var string
31
  */
32
+ const CURRENT_MLA_VERSION = '1.70';
33
 
34
  /**
35
  * Slug for registering and enqueueing plugin style sheet
84
  * @var string
85
  */
86
  const ADMIN_PAGE_SLUG = 'mla-menu';
87
+
88
  /**
89
  * Action name; uniquely identifies the nonce
90
  *
93
  * @var string
94
  */
95
  const MLA_ADMIN_NONCE = 'mla_admin';
96
+
97
  /**
98
  * mla_admin_action value for permanently deleting a single item
99
  *
102
  * @var string
103
  */
104
  const MLA_ADMIN_SINGLE_DELETE = 'single_item_delete';
105
+
106
  /**
107
  * mla_admin_action value for displaying a single item
108
  *
111
  * @var string
112
  */
113
  const MLA_ADMIN_SINGLE_EDIT_DISPLAY = 'single_item_edit_display';
114
+
115
  /**
116
  * mla_admin_action value for updating a single item
117
  *
120
  * @var string
121
  */
122
  const MLA_ADMIN_SINGLE_EDIT_UPDATE = 'single_item_edit_update';
123
+
124
  /**
125
  * mla_admin_action value for restoring a single item from the trash
126
  *
129
  * @var string
130
  */
131
  const MLA_ADMIN_SINGLE_RESTORE = 'single_item_restore';
132
+
133
  /**
134
  * mla_admin_action value for moving a single item to the trash
135
  *
138
  * @var string
139
  */
140
  const MLA_ADMIN_SINGLE_TRASH = 'single_item_trash';
141
+
142
  /**
143
  * mla_admin_action value for mapping Custom Field metadata
144
  *
147
  * @var string
148
  */
149
  const MLA_ADMIN_SINGLE_CUSTOM_FIELD_MAP = 'single_item_custom_field_map';
150
+
151
  /**
152
  * mla_admin_action value for mapping IPTC/EXIF metadata
153
  *
156
  * @var string
157
  */
158
  const MLA_ADMIN_SINGLE_MAP = 'single_item_map';
159
+
160
  /**
161
  * Holds screen ids to match help text to corresponding screen
162
  *
165
  * @var array
166
  */
167
  private static $page_hooks = array();
168
+
169
  /**
170
  * Initialization function, similar to __construct()
171
  *
185
  add_filter( 'set-screen-option', 'MLA::mla_set_screen_option_filter', 10, 3 ); // $status, $option, $value
186
  add_filter( 'screen_options_show_screen', 'MLA::mla_screen_options_show_screen_filter', 10, 2 ); // $show_screen, $this
187
  }
188
+
189
+ /**
190
+ * Load a plugin text domain
191
+ *
192
+ * The "add_action" for this function is in mla-plugin-loader.php, because the "initialize"
193
+ * function above doesn't run in time.
194
+ * Defined as public because it's an action.
195
+ *
196
+ * @since 1.60
197
+ *
198
+ * @return void
199
+ */
200
+ public static function mla_plugins_loaded_action(){
201
+ $text_domain = 'media-library-assistant';
202
+ $locale = apply_filters( 'mla_plugin_locale', get_locale(), $text_domain );
203
+
204
+ /*
205
+ * To override the plugin's translation files for one, some or all strings,
206
+ * create a sub-directory named 'media-library-assistant' in the WordPress
207
+ * WP_LANG_DIR (e.g., /wp-content/languages) directory.
208
+ */
209
+ load_textdomain( $text_domain, trailingslashit( WP_LANG_DIR ) . $text_domain . '/' . $text_domain . '-' . $locale . '.mo' );
210
+ load_plugin_textdomain( $text_domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
211
+
212
+ /*
213
+ * Now we can localize values in other plugin components
214
+ */
215
+ MLAOptions::mla_localize_option_definitions_array();
216
+ MLASettings::mla_localize_tablist();
217
+ }
218
+
219
  /**
220
  * Load the plugin's Ajax handler or process Edit Media update actions
221
  *
229
  */
230
  if ( !empty( $_REQUEST['mla_admin_action'] ) ) {
231
  check_admin_referer( self::MLA_ADMIN_NONCE );
232
+
233
  switch ( $_REQUEST['mla_admin_action'] ) {
234
  case self::MLA_ADMIN_SINGLE_CUSTOM_FIELD_MAP:
235
  $updates = MLAOptions::mla_evaluate_custom_field_mapping( $_REQUEST['mla_item_ID'], 'single_attachment_mapping' );
236
+
237
+ if ( !empty( $updates ) ) {
238
  $item_content = MLAData::mla_update_single_item( $_REQUEST['mla_item_ID'], $updates );
239
+ }
240
 
241
  $view_args = isset( $_REQUEST['mla_source'] ) ? array( 'mla_source' => $_REQUEST['mla_source']) : array();
242
  wp_redirect( add_query_arg( $view_args, admin_url( 'post.php' ) . '?post=' . $_REQUEST['mla_item_ID'] . '&action=edit&message=101' ), 302 );
253
  // ignore the rest
254
  } // switch ($_REQUEST['mla_admin_action'])
255
  } // (!empty($_REQUEST['mla_admin_action'])
256
+
257
  add_action( 'wp_ajax_' . self::JAVASCRIPT_INLINE_EDIT_SLUG, 'MLA::mla_inline_edit_action' );
258
  }
259
+
260
  /**
261
  * Load the plugin's Style Sheet and Javascript files
262
  *
268
  */
269
  public static function mla_admin_enqueue_scripts_action( $page_hook ) {
270
  $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
271
+
272
  if ( 'checked' != MLAOptions::mla_get_option( MLAOptions::MLA_SCREEN_DISPLAY_LIBRARY ) ) {
273
  wp_register_style( self::STYLESHEET_SLUG . '-nolibrary', MLA_PLUGIN_URL . 'css/mla-nolibrary.css', false, self::CURRENT_MLA_VERSION );
274
  wp_enqueue_style( self::STYLESHEET_SLUG . '-nolibrary' );
275
  }
276
 
277
+ if ( 'edit-tags.php' == $page_hook ) {
278
  wp_register_style( self::STYLESHEET_SLUG, MLA_PLUGIN_URL . 'css/mla-edit-tags-style.css', false, self::CURRENT_MLA_VERSION );
279
  wp_enqueue_style( self::STYLESHEET_SLUG );
280
  return;
281
  }
282
+
283
+ if ( 'media_page_' . self::ADMIN_PAGE_SLUG != $page_hook ) {
284
  return;
285
+ }
286
 
287
  wp_register_style( self::STYLESHEET_SLUG, MLA_PLUGIN_URL . 'css/mla-style.css', false, self::CURRENT_MLA_VERSION );
288
  wp_enqueue_style( self::STYLESHEET_SLUG );
291
  wp_enqueue_script( self::JAVASCRIPT_SINGLE_EDIT_SLUG, MLA_PLUGIN_URL . "js/mla-single-edit-scripts{$suffix}.js",
292
  array( 'wp-lists', 'suggest', 'jquery' ), self::CURRENT_MLA_VERSION, false );
293
  $script_variables = array(
294
+ 'comma' => _x( ',', 'tag_delimiter', 'media-library-assistant' ),
295
  'Ajax_Url' => admin_url( 'admin-ajax.php' )
296
  );
297
  wp_localize_script( self::JAVASCRIPT_SINGLE_EDIT_SLUG, self::JAVASCRIPT_SINGLE_EDIT_OBJECT, $script_variables );
298
+ } else {
 
299
  wp_enqueue_script( self::JAVASCRIPT_INLINE_EDIT_SLUG, MLA_PLUGIN_URL . "js/mla-inline-edit-scripts{$suffix}.js",
300
  array( 'wp-lists', 'suggest', 'jquery' ), self::CURRENT_MLA_VERSION, false );
301
+
302
  $fields = array( 'post_title', 'post_name', 'post_excerpt', 'post_content', 'image_alt', 'post_parent', 'menu_order', 'post_author' );
303
  $custom_fields = MLAOptions::mla_custom_field_support( 'quick_edit' );
304
  $custom_fields = array_merge( $custom_fields, MLAOptions::mla_custom_field_support( 'bulk_edit' ) );
308
 
309
  $script_variables = array(
310
  'fields' => $fields,
311
+ 'error' => __( 'Error while saving the changes.', 'media-library-assistant' ),
312
+ 'ntdeltitle' => __( 'Remove From Bulk Edit', 'media-library-assistant' ),
313
+ 'notitle' => __( '(no title)', 'media-library-assistant' ),
314
+ 'comma' => _x( ',', 'tag_delimiter', 'media-library-assistant' ),
315
  'ajax_action' => self::JAVASCRIPT_INLINE_EDIT_SLUG,
316
  'ajax_nonce' => wp_create_nonce( self::MLA_ADMIN_NONCE )
317
  );
318
  wp_localize_script( self::JAVASCRIPT_INLINE_EDIT_SLUG, self::JAVASCRIPT_INLINE_EDIT_OBJECT, $script_variables );
319
  }
320
  }
321
+
322
  /**
323
  * Add the submenu pages
324
  *
335
  * @return void
336
  */
337
  public static function mla_admin_menu_action( ) {
338
+ if ( 'checked' != MLAOptions::mla_get_option( MLAOptions::MLA_SCREEN_DISPLAY_LIBRARY ) ) {
 
 
 
339
  add_action( 'load-upload.php', 'MLA::mla_load_media_action' );
340
+ }
341
+
342
  $page_title = MLAOptions::mla_get_option( MLAOptions::MLA_SCREEN_PAGE_TITLE );
343
  $menu_title = MLAOptions::mla_get_option( MLAOptions::MLA_SCREEN_MENU_TITLE );
344
  $hook = add_submenu_page( 'upload.php', $page_title, $menu_title, 'upload_files', self::ADMIN_PAGE_SLUG, 'MLA::mla_render_admin_page' );
345
  add_action( 'load-' . $hook, 'MLA::mla_add_menu_options' );
346
  add_action( 'load-' . $hook, 'MLA::mla_add_help_tab' );
347
  self::$page_hooks[ $hook ] = $hook;
348
+
349
  $taxonomies = get_object_taxonomies( 'attachment', 'objects' );
350
  if ( !empty( $taxonomies ) ) {
351
  foreach ( $taxonomies as $tax_name => $tax_object ) {
352
  /*
353
  * WordPress 3.5 adds native support for taxonomies
354
  */
355
+ if ( ! MLATest::$wordpress_3point5_plus ) {
356
  $hook = add_submenu_page( 'upload.php', $tax_object->label, $tax_object->label, 'manage_categories', 'mla-edit-tax-' . $tax_name, 'MLA::mla_edit_tax_redirect' );
357
  add_action( 'load-' . $hook, 'MLA::mla_edit_tax_redirect' );
358
  } // ! MLATest::$wordpress_3point5_plus
359
+
360
  /*
361
  * The page_hook we need for taxonomy edits is slightly different
362
  */
363
  $hook = 'edit-' . $tax_name;
364
  self::$page_hooks[ $hook ] = 't_' . $tax_name;
365
  } // foreach $taxonomies
366
+
367
  /*
368
  * Load here, not 'load-edit-tags.php', to put our tab after the defaults
369
  */
370
  add_action( 'admin_head-edit-tags.php', 'MLA::mla_add_help_tab' );
371
  }
372
+
373
  /*
374
  * If we are suppressing the Media/Library submenu, force Media/Assistant to come first
375
  */
393
 
394
  add_filter( 'parent_file', 'MLA::mla_parent_file_filter', 10, 1 );
395
  }
396
+
397
  /**
398
  * Redirect to Media/Assistant if Media/Library is hidden
399
  *
404
  public static function mla_load_media_action( ) {
405
  if ( 'checked' != MLAOptions::mla_get_option( MLAOptions::MLA_SCREEN_DISPLAY_LIBRARY ) ) {
406
  $query_args = '?page=mla-menu';
407
+
408
  /*
409
  * Compose a message if returning from the Edit Media screen
410
  */
411
  if ( ! empty( $_GET['deleted'] ) && $deleted = absint( $_GET['deleted'] ) ) {
412
+ $query_args .= '&mla_admin_message=' . urlencode( sprintf( _n( 'Item permanently deleted.', '%d items permanently deleted.', $deleted, 'media-library-assistant' ), number_format_i18n( $_GET['deleted'] ) ) );
413
  }
414
+
415
  if ( ! empty( $_GET['trashed'] ) && $trashed = absint( $_GET['trashed'] ) ) {
416
+ /* translators: 1: post ID */
417
+ $query_args .= '&mla_admin_message=' . urlencode( sprintf( __( 'Item %1$d moved to Trash.', 'media-library-assistant' ), $_GET['ids'] ) );
418
  }
419
+
420
  wp_redirect( admin_url( 'upload.php' ) . $query_args, 302 );
421
  exit;
422
  }
423
  }
424
+
425
  /**
426
  * Add the "XX Entries per page" filter to the Screen Options tab
427
  *
431
  */
432
  public static function mla_add_menu_options( ) {
433
  $option = 'per_page';
434
+
435
  $args = array(
436
+ 'label' => __( 'Entries per page', 'media-library-assistant' ),
437
  'default' => 10,
438
  'option' => 'mla_entries_per_page'
439
  );
440
+
441
  add_screen_option( $option, $args );
442
  }
443
+
444
  /**
445
  * Add contextual help tabs to all the MLA pages
446
  *
454
  /*
455
  * Is this one of our pages?
456
  */
457
+ if ( !array_key_exists( $screen->id, self::$page_hooks ) ) {
458
  return;
459
+ }
460
+
461
+ if ( 'edit-tags' == $screen->base && 'attachment' != $screen->post_type ) {
462
  return;
463
+ }
464
+
465
  $file_suffix = $screen->id;
466
+
467
  /*
468
  * Override the screen suffix if we are going to display something other than the attachment table
469
  */
473
  $file_suffix = self::MLA_ADMIN_SINGLE_EDIT_DISPLAY;
474
  break;
475
  } // switch
476
+ } else { // isset( $_REQUEST['mla_admin_action'] )
 
477
  /*
478
  * Use a generic page for edit taxonomy screens
479
  */
486
  default:
487
  $tax_object = get_taxonomy( $taxonomy );
488
 
489
+ if ( $tax_object->hierarchical ) {
490
  $file_suffix = 'edit-hierarchical-taxonomy';
491
+ } else {
492
  $file_suffix = 'edit-flat-taxonomy';
493
+ }
494
  } // $taxonomy switch
495
  } // is taxonomy
496
  }
497
+
498
+ $template_array = MLAData::mla_load_template( 'help-for-' . $file_suffix . '.tpl' );
499
  if ( empty( $template_array ) ) {
500
  return;
501
  }
502
+
503
  /*
504
  * Don't add sidebar to the WordPress category and post_tag screens
505
  */
506
+ if ( ! ( 'edit-tags' == $screen->base && in_array( $screen->taxonomy, array( 'post_tag', 'category' ) ) ) ) {
507
  if ( !empty( $template_array['sidebar'] ) ) {
508
  $screen->set_help_sidebar( $template_array['sidebar'] );
 
509
  }
510
+ }
511
+ unset( $template_array['sidebar'] );
512
+
513
  /*
514
  * Provide explicit control over tab order
515
  */
516
  $tab_array = array();
517
+
518
  foreach ( $template_array as $id => $content ) {
519
  $match_count = preg_match( '#\<!-- title="(.+)" order="(.+)" --\>#', $content, $matches, PREG_OFFSET_CAPTURE );
520
+
521
  if ( $match_count > 0 ) {
522
  $tab_array[ $matches[ 2 ][ 0 ] ] = array(
523
  'id' => $id,
525
  'content' => $content
526
  );
527
  } else {
528
+ /* translators: 1: function name 2: template key */
529
+ error_log( sprintf( _x( 'ERROR: %1$s discarding "%2$s"; no title/order', 'error_log', 'media-library-assistant' ), 'mla_add_help_tab', $id ), 0 );
530
  }
531
  }
532
+
533
  ksort( $tab_array, SORT_NUMERIC );
534
  foreach ( $tab_array as $indx => $value ) {
535
  /*
536
  * Don't add duplicate tabs to the WordPress category and post_tag screens
537
  */
538
+ if ( 'edit-tags' == $screen->base && in_array( $screen->taxonomy, array( 'post_tag', 'category' ) ) ) {
539
+ if ( 'mla-attachments-column' != $value['id'] ) {
540
  continue;
541
+ }
542
+ }
543
+
544
  $screen->add_help_tab( $value );
545
  }
546
  }
547
+
548
  /**
549
  * Only show screen options on the table-list screen
550
  *
556
  * @return boolean True to display "Screen Options", false to suppress them
557
  */
558
  public static function mla_screen_options_show_screen_filter( $show_screen, $this_screen ) {
559
+ if ( isset( $_REQUEST['mla_admin_action'] ) && ( $_REQUEST['mla_admin_action'] == self::MLA_ADMIN_SINGLE_EDIT_DISPLAY ) ) {
560
  return false;
561
+ }
562
 
563
  return $show_screen;
564
  }
565
+
566
  /**
567
  * Save the "Entries per page" option set by this user
568
  *
576
  */
577
  public static function mla_set_screen_option_filter( $status, $option, $value )
578
  {
579
+ if ( 'mla_entries_per_page' == $option ) {
580
  return $value;
581
+ } elseif ( $status ) {
582
  return $status;
583
+ }
584
  }
585
+
586
  /**
587
  * Redirect to the Edit Tags/Categories page
588
  *
599
  /*
600
  * WordPress 3.5 adds native support for taxonomies
601
  */
602
+ if ( MLATest::$wordpress_3point5_plus ) {
603
  return;
604
+ }
605
 
606
  $screen = get_current_screen();
607
 
611
  exit;
612
  }
613
  }
614
+
615
  /**
616
  * Cleanup menus for Edit Tags/Categories page
617
  *
637
  if ( 'media_page_' . self::ADMIN_PAGE_SLUG == $hook_suffix ) {
638
  $submenu_file = self::ADMIN_PAGE_SLUG;
639
  }
640
+
641
  /*
642
  * Make sure the "Assistant" submenu line is bolded if the Media/Library submenu is hidden
643
  */
645
  'upload.php' == $parent_file && 'upload.php' == $submenu_file ) {
646
  $submenu_file = self::ADMIN_PAGE_SLUG;
647
  }
648
+
649
  /*
650
  * Make sure the "Assistant" submenu line is bolded when we go to the Edit Media page
651
  */
652
  if ( isset( $_REQUEST['mla_source'] ) ) {
653
  $submenu_file = self::ADMIN_PAGE_SLUG;
654
  }
655
+
656
  /*
657
  * WordPress 3.5 adds native support for taxonomies
658
  */
659
+ if ( MLATest::$wordpress_3point5_plus ) {
660
  return $parent_file;
661
  }
662
 
663
  if ( isset( $_REQUEST['taxonomy'] ) ) {
664
  $taxonomies = get_object_taxonomies( 'attachment', 'objects' );
665
+
666
  foreach ( $taxonomies as $tax_name => $tax_object ) {
667
  if ( $_REQUEST['taxonomy'] == $tax_name ) {
668
  $mla_page = 'mla-edit-tax-' . $tax_name;
669
  $real_page = 'edit-tags.php?taxonomy=' . $tax_name . '&post_type=attachment';
670
+
671
  foreach ( $submenu['upload.php'] as $submenu_index => $submenu_entry ) {
672
  if ( $submenu_entry[ 2 ] == $mla_page ) {
673
  $submenu['upload.php'][ $submenu_index ][ 2 ] = $real_page;
677
  }
678
  }
679
  }
680
+
681
  return $parent_file;
682
  }
683
+
684
  /**
685
  * Render the "Assistant" subpage in the Media section, using the list_table package
686
  *
693
  * WordPress class-wp-list-table.php doesn't look in hidden fields to set
694
  * the month filter dropdown or sorting parameters
695
  */
696
+ if ( isset( $_REQUEST['m'] ) ) {
697
  $_GET['m'] = $_REQUEST['m'];
698
+ }
699
+
700
+ if ( isset( $_REQUEST['order'] ) ) {
701
  $_GET['order'] = $_REQUEST['order'];
702
+ }
703
+
704
+ if ( isset( $_REQUEST['orderby'] ) ) {
705
  $_GET['orderby'] = $_REQUEST['orderby'];
706
+ }
707
+
708
  $bulk_action = self::_current_bulk_action();
709
 
710
  $page_title = MLAOptions::mla_get_option( MLAOptions::MLA_SCREEN_PAGE_TITLE );
711
  echo "<div class=\"wrap\">\r\n";
712
  echo "<div id=\"icon-upload\" class=\"icon32\"><br/></div>\r\n";
713
  echo "<h2>{$page_title}"; // trailing </h2> is action-specific
714
+
715
  if ( !current_user_can( 'upload_files' ) ) {
716
  echo " - Error</h2>\r\n";
717
+ wp_die( __( 'You do not have permission to manage attachments.', 'media-library-assistant' ) );
718
  }
719
+
720
  $page_content = array(
721
  'message' => '',
722
  'body' => ''
723
  );
724
+
725
  if ( !empty( $_REQUEST['mla_admin_message'] ) ) {
726
  $page_content['message'] = $_REQUEST['mla_admin_message'];
727
  }
728
+
729
  /*
730
  * The category taxonomy (edit screens) is a special case because
731
  * post_categories_meta_box() changes the input name
732
  */
733
+ if ( !isset( $_REQUEST['tax_input'] ) ) {
734
  $_REQUEST['tax_input'] = array();
735
+ }
736
+
737
  if ( isset( $_REQUEST['post_category'] ) ) {
738
  $_REQUEST['tax_input']['category'] = $_REQUEST['post_category'];
739
  unset ( $_REQUEST['post_category'] );
740
  }
741
+
742
  /*
743
  * Process bulk actions that affect an array of items
744
  */
745
  if ( $bulk_action && ( $bulk_action != 'none' ) ) {
746
+
747
  if ( isset( $_REQUEST['cb_attachment'] ) ) {
748
  foreach ( $_REQUEST['cb_attachment'] as $index => $post_id ) {
749
  switch ( $bulk_action ) {
756
  $item_content = MLAData::mla_update_single_item( $post_id, $updates );
757
  break;
758
  }
759
+
760
  if ( !empty( $_REQUEST['bulk_map'] ) ) {
761
  $item = get_post( $post_id );
762
  $updates = MLAOptions::mla_evaluate_iptc_exif_mapping( $item, 'iptc_exif_mapping' );
763
  $item_content = MLAData::mla_update_single_item( $post_id, $updates );
764
  break;
765
  }
766
+
767
  /*
768
  * Copy the edit form contents to $new_data
769
  */
770
  $new_data = array() ;
771
  if ( isset( $_REQUEST['post_parent'] ) ) {
772
+ if ( is_numeric( $_REQUEST['post_parent'] ) ) {
773
  $new_data['post_parent'] = $_REQUEST['post_parent'];
774
+ }
775
  }
776
+
777
  if ( isset( $_REQUEST['post_author'] ) ) {
778
+ if ( -1 != $_REQUEST['post_author'] ) {
779
  $new_data['post_author'] = $_REQUEST['post_author'];
780
+ }
781
  }
782
+
783
  /*
784
  * Custom field support
785
  */
786
  $custom_fields = array();
787
  foreach (MLAOptions::mla_custom_field_support( 'bulk_edit' ) as $slug => $label ) {
788
  if ( isset( $_REQUEST[ $slug ] ) ) {
789
+ if ( ! empty( $_REQUEST[ $slug ] ) ) {
790
  $custom_fields[ $label ] = $_REQUEST[ $slug ];
791
+ }
792
  }
793
  } // foreach
794
+
795
+ if ( ! empty( $custom_fields ) ) {
796
  $new_data[ 'custom_updates' ] = $custom_fields;
797
+ }
798
+
799
  $item_content = MLAData::mla_update_single_item( $post_id, $new_data, $_REQUEST['tax_input'], $_REQUEST['tax_action'] );
800
  break;
801
  case 'restore':
807
  break;
808
  default:
809
  $item_content = array(
810
+ /* translators: 1: bulk_action, e.g., delete, edit, restore, trash */
811
+ 'message' => sprintf( __( 'Unknown bulk action %1$s', 'media-library-assistant' ), $bulk_action ),
812
  'body' => ''
813
  );
814
  } // switch $bulk_action
815
+
816
  $page_content['message'] .= $item_content['message'] . '<br>';
817
  } // foreach cb_attachment
818
 
825
  unset( $_REQUEST[ $slug ] );
826
 
827
  unset( $_REQUEST['cb_attachment'] );
828
+ } else { // isset cb_attachment
829
+ /* translators: 1: action name, e.g., edit */
830
+ $page_content['message'] = sprintf( __( 'Bulk Action %1$s - no items selected.', 'media-library-assistant' ), $bulk_action );
831
  }
832
 
833
  unset( $_REQUEST['action'] );
834
  unset( $_REQUEST['bulk_edit'] );
835
  unset( $_REQUEST['action2'] );
836
  } // $bulk_action
837
+
838
  if ( isset( $_REQUEST['clear_filter_by'] ) ) {
839
  unset( $_REQUEST['heading_suffix'] );
840
  unset( $_REQUEST['parent'] );
844
  unset( $_REQUEST['mla-metakey'] );
845
  unset( $_REQUEST['mla-metavalue'] );
846
  }
847
+
848
  if ( isset( $_REQUEST['delete_all'] ) ) {
849
  global $wpdb;
850
+
851
  $ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", 'attachment', 'trash' ) );
852
  $delete_count = 0;
853
  foreach ( $ids as $post_id ) {
854
  $item_content = self::_delete_single_item( $post_id );
855
+
856
+ if ( false !== strpos( $item_content['message'], __( 'ERROR:', 'media-library-assistant' ) ) ) {
857
  $page_content['message'] .= $item_content['message'] . '<br>';
858
+ } else {
859
  $delete_count++;
860
+ }
861
  }
862
 
863
+ if ( $delete_count ) {
864
+ $page_content['message'] .= sprintf( _nx( '%s item deleted.', '%s items deleted.', $delete_count, 'deleted items', 'media-library-assistant' ), number_format_i18n( $delete_count ) );
865
+ } else {
866
+ $page_content['message'] .= __( 'No items deleted.', 'media-library-assistant' );
867
+ }
868
  }
869
+
870
  /*
871
  * Process row-level actions that affect a single item
872
  */
873
  if ( !empty( $_REQUEST['mla_admin_action'] ) ) {
874
  check_admin_referer( self::MLA_ADMIN_NONCE );
875
+
876
  switch ( $_REQUEST['mla_admin_action'] ) {
877
  case self::MLA_ADMIN_SINGLE_DELETE:
878
  $page_content = self::_delete_single_item( $_REQUEST['mla_item_ID'] );
879
  break;
880
  case self::MLA_ADMIN_SINGLE_EDIT_DISPLAY:
881
+ echo ' - ' . __( 'Edit single item', 'media-library-assistant' ) . '</h2>';
882
  $page_content = self::_display_single_item( $_REQUEST['mla_item_ID'] );
883
  break;
884
  case self::MLA_ADMIN_SINGLE_EDIT_UPDATE:
890
  $page_content = MLAData::mla_update_single_item( $_REQUEST['mla_item_ID'], $updates );
891
  } else {
892
  $page_content = array(
893
+ /* translators: 1: post ID */
894
+ 'message' => sprintf( __( 'Item %1$d cancelled.', 'media-library-assistant' ), $_REQUEST['mla_item_ID'] ),
895
  'body' => ''
896
  );
897
  }
904
  break;
905
  default:
906
  $page_content = array(
907
+ /* translators: 1: bulk_action, e.g., single_item_delete, single_item_edit */
908
+ 'message' => sprintf( __( 'Unknown mla_admin_action - "%1$s"', 'media-library-assistant' ), $_REQUEST['mla_admin_action'] ),
909
  'body' => ''
910
  );
911
  break;
912
  } // switch ($_REQUEST['mla_admin_action'])
913
  } // (!empty($_REQUEST['mla_admin_action'])
914
+
915
  if ( !empty( $page_content['body'] ) ) {
916
  if ( !empty( $page_content['message'] ) ) {
917
+ if ( false !== strpos( $page_content['message'], __( 'ERROR:', 'media-library-assistant' ) ) ) {
918
  $messages_class = 'mla_errors';
919
+ } else {
920
  $messages_class = 'mla_messages';
921
+ }
922
 
923
  echo " <div class=\"{$messages_class}\"><p>\r\n";
924
  echo ' ' . $page_content['message'] . "\r\n";
925
  echo " </p></div>\r\n"; // id="message"
926
  }
927
+
928
  echo $page_content['body'];
929
  } else {
930
  /*
934
  echo ' - ' . esc_html( $_REQUEST['heading_suffix'] ) . "</h2>\r\n";
935
  } elseif ( !empty( $_REQUEST['s'] ) && !empty( $_REQUEST['mla_search_fields'] ) ) {
936
  echo ' - search results for "' . esc_html( stripslashes( trim( $_REQUEST['s'] ) ) ) . "\"</h2>\r\n";
937
+ } else {
938
  echo "</h2>\r\n";
939
+ }
940
+
941
  if ( !empty( $page_content['message'] ) ) {
942
+ if ( false !== strpos( $page_content['message'], __( 'ERROR:', 'media-library-assistant' ) ) ) {
943
  $messages_class = 'mla_errors';
944
+ } else {
945
  $messages_class = 'mla_messages';
946
+ }
947
 
948
  echo " <div class=\"{$messages_class}\"><p>\r\n";
949
  echo ' ' . $page_content['message'] . "\r\n";
950
  echo " </p></div>\r\n"; // id="message"
951
  }
952
+
953
  /*
954
  * Optional - limit width of the views list
955
  */
956
  $view_width = MLAOptions::mla_get_option( MLAOptions::MLA_TABLE_VIEWS_WIDTH );
957
  if ( !empty( $view_width ) ) {
958
+ if ( is_numeric( $view_width ) ) {
959
  $view_width .= 'px';
960
+ }
961
+
962
  echo " <style type='text/css'>\r\n";
963
  echo " ul.subsubsub {\r\n";
964
  echo " width: {$view_width};\r\n";
969
 
970
  // Create an instance of our package class...
971
  $MLAListTable = new MLA_List_Table();
972
+
973
  // Fetch, prepare, sort, and filter our data...
974
  $MLAListTable->prepare_items();
975
  $MLAListTable->views();
976
+
977
  // Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions
978
  // echo '<form action="' . admin_url( 'upload.php' ) . '" method="get" id="mla-filter">' . "\r\n";
979
  echo '<form action="' . admin_url( 'upload.php?page=' . self::ADMIN_PAGE_SLUG ) . '" method="post" id="mla-filter">' . "\r\n";
990
  $search_fields = array ( 'title', 'content' );
991
  $search_connector = 'AND';
992
  }
993
+
994
  echo '<p class="search-box">' . "\r\n";
995
+ echo '<label class="screen-reader-text" for="media-search-input">' . __( 'Search Media', 'media-library-assistant' ) . ':</label>' . "\r\n";
996
  echo '<input type="text" size="45" id="media-search-input" name="s" value="' . $search_value . '" />' . "\r\n";
997
  echo '<input type="submit" name="mla-search-submit" id="search-submit" class="button" value="Search Media" /><br>' . "\r\n";
998
  if ( 'OR' == $search_connector ) {
999
+ echo '<input type="radio" name="mla_search_connector" value="AND" />&nbsp;' . __( 'and', 'media-library-assistant' ) . "&nbsp;\r\n";
1000
+ echo '<input type="radio" name="mla_search_connector" checked="checked" value="OR" />&nbsp;' . __( 'or', 'media-library-assistant' ) . "&nbsp;\r\n";
1001
+ } else {
1002
+ echo '<input type="radio" name="mla_search_connector" checked="checked" value="AND" />&nbsp;' . __( 'and', 'media-library-assistant' ) . "&nbsp;\r\n";
1003
+ echo '<input type="radio" name="mla_search_connector" value="OR" />&nbsp;' . __( 'or', 'media-library-assistant' ) . "&nbsp;\r\n";
1004
+ }
1005
+
1006
+ if ( in_array( 'title', $search_fields ) ) {
1007
+ echo '<input type="checkbox" name="mla_search_fields[]" id="search-title" checked="checked" value="title" />&nbsp;' . __( 'Title', 'media-library-assistant' ) . "&nbsp;\r\n";
1008
  } else {
1009
+ echo '<input type="checkbox" name="mla_search_fields[]" id="search-title" value="title" />&nbsp;' . __( 'Title', 'media-library-assistant' ) . "&nbsp;\r\n";
 
1010
  }
1011
 
1012
+ if ( in_array( 'name', $search_fields ) ) {
1013
+ echo '<input type="checkbox" name="mla_search_fields[]" id="search-name" checked="checked" value="name" />&nbsp;' . __( 'Name', 'media-library-assistant' ) . "&nbsp;\r\n";
1014
+ } else {
1015
+ echo '<input type="checkbox" name="mla_search_fields[]" id="search-name" value="name" />&nbsp;' . __( 'Name', 'media-library-assistant' ) . "&nbsp;\r\n";
1016
+ }
1017
+
1018
+ if ( in_array( 'alt-text', $search_fields ) ) {
1019
+ echo '<input type="checkbox" name="mla_search_fields[]" id="search-alt-text" checked="checked" value="alt-text" />&nbsp;' . __( 'ALT Text', 'media-library-assistant' ) . "&nbsp;\r\n";
1020
+ } else {
1021
+ echo '<input type="checkbox" name="mla_search_fields[]" id="search-alt-text" value="alt-text" />&nbsp;' . __( 'ALT Text', 'media-library-assistant' ) . "&nbsp;\r\n";
1022
+ }
1023
+
1024
+ if ( in_array( 'excerpt', $search_fields ) ) {
1025
+ echo '<input type="checkbox" name="mla_search_fields[]" id="search-excerpt" checked="checked" value="excerpt" />&nbsp;' . __( 'Caption', 'media-library-assistant' ) . "&nbsp;\r\n";
1026
+ } else {
1027
+ echo '<input type="checkbox" name="mla_search_fields[]" id="search-excerpt" value="excerpt" />&nbsp;' . __( 'Caption', 'media-library-assistant' ) . "&nbsp;\r\n";
1028
+ }
1029
+
1030
+ if ( in_array( 'content', $search_fields ) ) {
1031
+ echo '<input type="checkbox" name="mla_search_fields[]" id="search-content" checked="checked" value="content" />&nbsp;' . __( 'Description', 'media-library-assistant' ) . "&nbsp;\r\n";
1032
+ } else {
1033
+ echo '<input type="checkbox" name="mla_search_fields[]" id="search-content" value="content" />&nbsp;' . __( 'Description', 'media-library-assistant' ) . "&nbsp;\r\n";
1034
+ }
 
1035
 
1036
  echo '</p>' . "\r\n";
1037
 
1039
  * We also need to ensure that the form posts back to our current page and remember all the view arguments
1040
  */
1041
  echo sprintf( '<input type="hidden" name="page" value="%1$s" />', $_REQUEST['page'] ) . "\r\n";
1042
+
1043
  $view_arguments = MLA_List_Table::mla_submenu_arguments();
1044
  foreach ( $view_arguments as $key => $value ) {
1045
+ if ( 'meta_query' == $key ) {
1046
  $value = stripslashes( $_REQUEST['meta_query'] );
1047
+ }
1048
 
1049
  /*
1050
  * Search box elements are already set up in the above "search-box"
1051
  */
1052
+ if ( in_array( $key, array( 's', 'mla_search_connector', 'mla_search_fields' ) ) ) {
1053
  continue;
1054
+ }
1055
+
1056
  if ( is_array( $value ) ) {
1057
  foreach ( $value as $element_key => $element_value )
1058
  echo sprintf( '<input type="hidden" name="%1$s[%2$s]" value="%3$s" />', $key, $element_key, esc_attr( $element_value ) ) . "\r\n";
1059
+ } else {
 
1060
  echo sprintf( '<input type="hidden" name="%1$s" value="%2$s" />', $key, esc_attr( $value ) ) . "\r\n";
1061
+ }
1062
  }
1063
 
1064
  // Now we can render the completed list table
1065
  $MLAListTable->display();
1066
  echo "</form><!-- id=mla-filter -->\r\n";
1067
+
1068
  /*
1069
  * Insert the hidden form and table for inline edits (quick & bulk)
1070
  */
1071
  echo self::_build_inline_edit_form($MLAListTable);
1072
+
1073
  echo "<div id=\"ajax-response\"></div>\r\n";
1074
  echo "<br class=\"clear\" />\r\n";
1075
  echo "</div><!-- class=wrap -->\r\n";
1076
  } // display attachments list
1077
  }
1078
+
1079
  /**
1080
  * Ajax handler for inline editing (quick and bulk edit)
1081
  *
1089
  set_current_screen( $_REQUEST['screen'] );
1090
 
1091
  check_ajax_referer( self::MLA_ADMIN_NONCE, 'nonce' );
1092
+
1093
  if ( empty( $_REQUEST['post_ID'] ) ) {
1094
+ echo __( 'ERROR: No post ID found', 'media-library-assistant' );
1095
  die();
1096
+ } else {
 
1097
  $post_id = $_REQUEST['post_ID'];
1098
+ }
1099
+
1100
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
1101
+ wp_die( __( 'You are not allowed to edit this Attachment.', 'media-library-assistant' ) );
1102
+ }
1103
 
1104
  /*
1105
  * Custom field support
1112
  }
1113
  }
1114
 
1115
+ if ( ! empty( $custom_fields ) ) {
1116
  $_REQUEST[ 'custom_updates' ] = $custom_fields;
1117
+ }
1118
+
1119
  /*
1120
  * The category taxonomy is a special case because post_categories_meta_box() changes the input name
1121
  */
1122
+ if ( !isset( $_REQUEST['tax_input'] ) ) {
1123
  $_REQUEST['tax_input'] = array();
1124
+ }
1125
+
1126
  if ( isset( $_REQUEST['post_category'] ) ) {
1127
  $_REQUEST['tax_input']['category'] = $_REQUEST['post_category'];
1128
  unset ( $_REQUEST['post_category'] );
1129
  }
1130
+
1131
  if ( ! empty( $_REQUEST['tax_input'] ) ) {
1132
  /*
1133
  * Flat taxonomy strings must be cleaned up and duplicates removed
1136
  $tax_input = $_REQUEST['tax_input'];
1137
  foreach ( $tax_input as $tax_name => $tax_value ) {
1138
  if ( ! is_array( $tax_value ) ) {
1139
+ $comma = _x( ',', 'tag_delimiter', 'media-library-assistant' );
1140
+ if ( ',' != $comma ) {
1141
  $tax_value = str_replace( $comma, ',', $tax_value );
1142
+ }
1143
+
1144
  $tax_value = preg_replace( '#\s*,\s*#', ',', $tax_value );
1145
  $tax_value = preg_replace( '#,+#', ',', $tax_value );
1146
  $tax_value = preg_replace( '#[,\s]+$#', '', $tax_value );
1147
  $tax_value = preg_replace( '#^[,\s]+#', '', $tax_value );
1148
+
1149
+ if ( ',' != $comma ) {
1150
  $tax_value = str_replace( ',', $comma, $tax_value );
1151
+ }
1152
+
1153
  $tax_array = array();
1154
  $dedup_array = explode( $comma, $tax_value );
1155
  foreach ( $dedup_array as $tax_value )
1156
  $tax_array [$tax_value] = $tax_value;
1157
+
1158
  $tax_value = implode( $comma, $tax_array );
1159
  } // ! array( $tax_value )
1160
+
1161
  $tax_output[$tax_name] = $tax_value;
1162
  } // foreach $tax_input
1163
+ } else { // ! empty( $_REQUEST['tax_input'] )
 
1164
  $tax_output = NULL;
1165
+ }
1166
+
1167
  $results = MLAData::mla_update_single_item( $post_id, $_REQUEST, $tax_output );
1168
  $new_item = (object) MLAData::mla_get_attachment_by_id( $post_id );
1169
 
1172
  $MLAListTable->single_row( $new_item );
1173
  die(); // this is required to return a proper result
1174
  }
1175
+
1176
  /**
1177
  * Build the hidden row templates for inline editing (quick and bulk edit)
1178
  *
1186
  */
1187
  private static function _build_inline_edit_form( $MLAListTable ) {
1188
  $taxonomies = get_object_taxonomies( 'attachment', 'objects' );
1189
+
1190
  $hierarchical_taxonomies = array();
1191
  $flat_taxonomies = array();
1192
  foreach ( $taxonomies as $tax_name => $tax_object ) {
1197
  }
1198
  }
1199
 
1200
+ $page_template_array = MLAData::mla_load_template( 'admin-inline-edit-form.tpl' );
1201
  if ( ! array( $page_template_array ) ) {
1202
+ /* translators: 1: function name 2: non-array value */
1203
+ error_log( sprintf( _x( 'ERROR: %1$s non-array "%2$s"', 'error_log', 'media-library-assistant' ), 'MLA::_build_inline_edit_form', var_export( $page_template_array, true ) ), 0 );
1204
  return '';
1205
  }
1206
+
1207
  if ( $authors = self::_authors_dropdown() ) {
1208
  $authors_dropdown = ' <label class="inline-edit-author">' . "\r\n";
1209
+ $authors_dropdown .= ' <span class="title">' . __( 'Author', 'media-library-assistant' ) . '</span>' . "\r\n";
1210
  $authors_dropdown .= $authors . "\r\n";
1211
  $authors_dropdown .= ' </label>' . "\r\n";
1212
+ } else {
 
1213
  $authors_dropdown = '';
1214
+ }
1215
 
1216
  $custom_fields = '';
1217
  foreach (MLAOptions::mla_custom_field_support( 'quick_edit' ) as $slug => $label ) {
1221
  );
1222
  $custom_fields .= MLAData::mla_parse_template( $page_template_array['custom_field'], $page_values );
1223
  }
1224
+
1225
  /*
1226
  * The middle column contains the hierarchical taxonomies, e.g., Attachment Category
1227
  */
1228
  $quick_middle_column = '';
1229
  $bulk_middle_column = '';
1230
+
1231
  if ( count( $hierarchical_taxonomies ) ) {
1232
  $quick_category_blocks = '';
1233
  $bulk_category_blocks = '';
1241
 
1242
  $page_values = array(
1243
  'tax_html' => esc_html( $tax_object->labels->name ),
1244
+ 'more' => __( 'more', 'media-library-assistant' ),
1245
+ 'less' => __( 'less', 'media-library-assistant' ),
1246
  'tax_attr' => esc_attr( $tax_name ),
1247
+ 'tax_checklist' => $tax_checklist,
1248
+ 'Add' => __( 'Add', 'media-library-assistant' ),
1249
+ 'Remove' => __( 'Remove', 'media-library-assistant' ),
1250
+ 'Replace' => __( 'Replace', 'media-library-assistant' ),
1251
  );
1252
  $category_block = MLAData::mla_parse_template( $page_template_array['category_block'], $page_values );
1253
  $taxonomy_options = MLAData::mla_parse_template( $page_template_array['taxonomy_options'], $page_values );
1267
  );
1268
  $bulk_middle_column = MLAData::mla_parse_template( $page_template_array['category_fieldset'], $page_values );
1269
  } // count( $hierarchical_taxonomies )
1270
+
1271
  /*
1272
  * The right-hand column contains the flat taxonomies, e.g., Attachment Tag
1273
  */
1274
  $quick_right_column = '';
1275
  $bulk_right_column = '';
1276
+
1277
  if ( count( $flat_taxonomies ) ) {
1278
  $quick_tag_blocks = '';
1279
  $bulk_tag_blocks = '';
1282
  if ( current_user_can( $tax_object->cap->assign_terms ) ) {
1283
  $page_values = array(
1284
  'tax_html' => esc_html( $tax_object->labels->name ),
1285
+ 'tax_attr' => esc_attr( $tax_name ),
1286
+ 'Add' => __( 'Add', 'media-library-assistant' ),
1287
+ 'Remove' => __( 'Remove', 'media-library-assistant' ),
1288
+ 'Replace' => __( 'Replace', 'media-library-assistant' ),
1289
  );
1290
  $tag_block = MLAData::mla_parse_template( $page_template_array['tag_block'], $page_values );
1291
  $taxonomy_options = MLAData::mla_parse_template( $page_template_array['taxonomy_options'], $page_values );
1305
  );
1306
  $bulk_right_column = MLAData::mla_parse_template( $page_template_array['tag_fieldset'], $page_values );
1307
  } // count( $flat_taxonomies )
1308
+
1309
  if ( $authors = self::_authors_dropdown( -1 ) ) {
1310
  $bulk_authors_dropdown = ' <label class="inline-edit-author">' . "\r\n";
1311
+ $bulk_authors_dropdown .= ' <span class="title">' . __( 'Author', 'media-library-assistant' ) . '</span>' . "\r\n";
1312
  $bulk_authors_dropdown .= $authors . "\r\n";
1313
  $bulk_authors_dropdown .= ' </label>' . "\r\n";
1314
+ } else {
 
1315
  $bulk_authors_dropdown = '';
1316
+ }
1317
 
1318
  $bulk_custom_fields = '';
1319
  foreach (MLAOptions::mla_custom_field_support( 'bulk_edit' ) as $slug => $label ) {
1326
 
1327
  $page_values = array(
1328
  'colspan' => count( $MLAListTable->get_columns() ),
1329
+ 'Quick Edit' => __( 'Quick Edit', 'media-library-assistant' ),
1330
+ 'Title' => __( 'Title', 'media-library-assistant' ),
1331
+ 'Name/Slug' => __( 'Name/Slug', 'media-library-assistant' ),
1332
+ 'Caption' => __( 'Caption', 'media-library-assistant' ),
1333
+ 'Description' => __( 'Description', 'media-library-assistant' ),
1334
+ 'ALT Text' => __( 'ALT Text', 'media-library-assistant' ),
1335
+ 'Parent ID' => __( 'Parent ID', 'media-library-assistant' ),
1336
+ 'Menu Order' => __( 'Menu Order', 'media-library-assistant' ),
1337
  'authors' => $authors_dropdown,
1338
  'custom_fields' => $custom_fields,
1339
  'quick_middle_column' => $quick_middle_column,
1340
  'quick_right_column' => $quick_right_column,
1341
+ 'Cancel' => __( 'Cancel', 'media-library-assistant' ),
1342
+ 'Update' => __( 'Update', 'media-library-assistant' ),
1343
+ 'Bulk Edit' => __( 'Bulk Edit', 'media-library-assistant' ),
1344
  'bulk_middle_column' => $bulk_middle_column,
1345
  'bulk_right_column' => $bulk_right_column,
1346
  'bulk_authors' => $bulk_authors_dropdown,
1347
+ 'bulk_custom_fields' => $bulk_custom_fields,
1348
+ 'Map IPTC/EXIF metadata' => __( 'Map IPTC/EXIF metadata', 'media-library-assistant' ),
1349
+ 'Map Custom Field metadata' => __( 'Map Custom Field Metadata', 'media-library-assistant' ),
1350
  );
1351
  $page_template = MLAData::mla_parse_template( $page_template_array['page'], $page_values );
1352
  return $page_template;
1353
  }
1354
+
1355
  /**
1356
  * Get the edit Authors dropdown box, if user has suitable permissions
1357
  *
1374
  'multi' => 1,
1375
  'echo' => 0
1376
  );
1377
+
1378
  if ( $author > 0 ) {
1379
  $users_opt['selected'] = $author;
1380
  $users_opt['include_selected'] = true;
1381
+ } elseif ( -1 == $author ) {
1382
+ $users_opt['show_option_none'] = '&mdash; ' . __( 'No Change', 'media-library-assistant' ) . ' &mdash;';
1383
  }
 
 
1384
 
1385
  if ( $authors = wp_dropdown_users( $users_opt ) ) {
1386
  return $authors;
1387
  }
1388
  }
1389
+
1390
  return false;
1391
  }
1392
+
1393
  /**
1394
  * Get the current action selected from the bulk actions dropdown
1395
  *
1399
  */
1400
  private static function _current_bulk_action( ) {
1401
  $action = false;
1402
+
1403
  if ( isset( $_REQUEST['action'] ) ) {
1404
+ if ( -1 != $_REQUEST['action'] ) {
1405
  return $_REQUEST['action'];
1406
+ } else {
1407
  $action = 'none';
1408
+ }
1409
  } // isset action
1410
+
1411
  if ( isset( $_REQUEST['action2'] ) ) {
1412
+ if ( -1 != $_REQUEST['action2'] ) {
1413
  return $_REQUEST['action2'];
1414
+ } else {
1415
  $action = 'none';
1416
+ }
1417
  } // isset action2
1418
+
1419
  return $action;
1420
  }
1421
+
1422
  /**
1423
  * Delete a single item permanently
1424
  *
1429
  * @return array success/failure message and NULL content
1430
  */
1431
  private static function _delete_single_item( $post_id ) {
1432
+ if ( !current_user_can( 'delete_post', $post_id ) ) {
1433
  return array(
1434
+ 'message' => __( 'ERROR: You are not allowed to delete this item.', 'media-library-assistant' ),
1435
  'body' => ''
1436
  );
1437
+ }
1438
+
1439
+ if ( !wp_delete_attachment( $post_id, true ) ) {
1440
  return array(
1441
+ /* translators: 1: post ID */
1442
+ 'message' => sprintf( __( 'ERROR: Item %1$d could NOT be deleted.', 'media-library-assistant' ), $post_id ),
1443
  'body' => ''
1444
  );
1445
+ }
1446
+
1447
  return array(
1448
+ /* translators: 1: post ID */
1449
+ 'message' => sprintf( __( 'Item %1$d permanently deleted.', 'media-library-assistant' ), $post_id ),
1450
  'body' => ''
1451
  );
1452
  }
1453
+
1454
  /**
1455
  * Display a single item sub page; prepare the form to
1456
  * change the meta data for a single attachment.
1470
  * This function sets the global $post
1471
  */
1472
  $post_data = MLAData::mla_get_attachment_by_id( $post_id );
1473
+ if ( !isset( $post_data ) ) {
1474
  return array(
1475
+ 'message' => __( 'ERROR: Could not retrieve Attachment.', 'media-library-assistant' ),
1476
  'body' => ''
1477
  );
1478
+ }
1479
+
1480
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
1481
  return array(
1482
+ 'message' => __( 'You are not allowed to edit this Attachment.', 'media-library-assistant' ),
1483
  'body' => ''
1484
  );
1485
+ }
1486
 
1487
+ if ( 0 === strpos( strtolower( $post_data['post_mime_type'] ), 'image' ) ) {
1488
+ $page_template_array = MLAData::mla_load_template( 'admin-display-single-image.tpl' );
1489
  $width = isset( $post_data['mla_wp_attachment_metadata']['width'] ) ? $post_data['mla_wp_attachment_metadata']['width'] : '';
1490
  $height = isset( $post_data['mla_wp_attachment_metadata']['height'] ) ? $post_data['mla_wp_attachment_metadata']['height'] : '';
1491
  $image_meta = var_export( $post_data['mla_wp_attachment_metadata'], true );
1492
+
1493
+ if ( !isset( $post_data['mla_wp_attachment_image_alt'] ) ) {
1494
  $post_data['mla_wp_attachment_image_alt'] = '';
1495
+ }
1496
  } else {
1497
+ $page_template_array = MLAData::mla_load_template( 'admin-display-single-document.tpl' );
1498
  $width = '';
1499
  $height = '';
1500
  $image_meta = '';
1501
  }
1502
+
1503
  if ( array( $page_template_array ) ) {
1504
  $page_template = $page_template_array['page'];
1505
  $authors_template = $page_template_array['authors'];
1506
  $postbox_template = $page_template_array['postbox'];
1507
  } else {
1508
+ /* translators: 1: page_template_array */
1509
+ error_log( sprintf( _x( 'ERROR: MLA::_display_single_item \$page_template_array = "%1$s"', 'error_log', 'media-library-assistant' ), var_export( $page_template_array, true ) ), 0 );
1510
  $page_template = $page_template_array;
1511
  $authors_template = '';
1512
  $postbox_template = '';
1513
  }
1514
+
1515
+ if ( empty($post_data['mla_references']['parent_title'] ) ) {
1516
  $parent_info = $post_data['mla_references']['parent_errors'];
1517
+ } else {
1518
  $parent_info = sprintf( '(%1$s) %2$s %3$s', $post_data['mla_references']['parent_type'], $post_data['mla_references']['parent_title'], $post_data['mla_references']['parent_errors'] );
1519
+ }
1520
 
1521
  if ( $authors = self::_authors_dropdown( $post_data['post_author'], 'attachments[' . $post_data['ID'] . '][post_author]' ) ) {
1522
  $args = array (
1523
  'ID' => $post_data['ID'],
1524
+ 'Author' => __( 'Author', 'media-library-assistant' ),
1525
  'authors' => $authors
1526
  );
1527
  $authors = MLAData::mla_parse_template( $authors_template, $args );
1528
+ } else {
 
1529
  $authors = '';
1530
+ }
1531
 
1532
  if ( MLAOptions::$process_featured_in ) {
1533
  $features = '';
1534
+
1535
  foreach ( $post_data['mla_references']['features'] as $feature_id => $feature ) {
1536
+ if ( $feature_id == $post_data['post_parent'] ) {
1537
+ $parent = __( 'PARENT', 'media-library-assistant' ) . ' ';
1538
+ } else {
1539
  $parent = '';
1540
+ }
1541
+
1542
  $features .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $feature->post_type, /*$3%s*/ $feature_id, /*$4%s*/ $feature->post_title ) . "\r\n";
1543
  } // foreach $feature
1544
+ } else {
1545
+ $features = __( 'Disabled', 'media-library-assistant' );
1546
  }
1547
+
 
 
1548
  if ( MLAOptions::$process_inserted_in ) {
1549
  $inserts = '';
1550
+
1551
  foreach ( $post_data['mla_references']['inserts'] as $file => $insert_array ) {
1552
  $inserts .= $file . "\r\n";
1553
+
1554
  foreach ( $insert_array as $insert ) {
1555
+ if ( $insert->ID == $post_data['post_parent'] ) {
1556
+ $parent = ' ' . __( 'PARENT', 'media-library-assistant' ) . ' ';
1557
+ } else {
1558
  $parent = ' ';
1559
+ }
1560
+
1561
  $inserts .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $insert->post_type, /*$3%s*/ $insert->ID, /*$4%s*/ $insert->post_title ) . "\r\n";
1562
  } // foreach $insert
1563
  } // foreach $file
1564
+ } else {
1565
+ $inserts = __( 'Disabled', 'media-library-assistant' );
1566
  }
1567
+
 
 
1568
  if ( MLAOptions::$process_gallery_in ) {
1569
  $galleries = '';
1570
+
1571
  foreach ( $post_data['mla_references']['galleries'] as $gallery_id => $gallery ) {
1572
+ if ( $gallery_id == $post_data['post_parent'] ) {
1573
+ $parent = __( 'PARENT', 'media-library-assistant' ) . ' ';
1574
+ } else {
1575
  $parent = '';
1576
+ }
1577
+
1578
  $galleries .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $gallery['post_type'], /*$3%s*/ $gallery_id, /*$4%s*/ $gallery['post_title'] ) . "\r\n";
1579
  } // foreach $gallery
1580
+ } else {
1581
+ $galleries = __( 'Disabled', 'media-library-assistant' );
1582
  }
 
 
1583
 
1584
  if ( MLAOptions::$process_mla_gallery_in ) {
1585
  $mla_galleries = '';
1586
+
1587
  foreach ( $post_data['mla_references']['mla_galleries'] as $gallery_id => $gallery ) {
1588
+ if ( $gallery_id == $post_data['post_parent'] ) {
1589
+ $parent = __( 'PARENT', 'media-library-assistant' ) . ' ';
1590
+ } else {
1591
  $parent = '';
1592
+ }
1593
+
1594
  $mla_galleries .= sprintf( '%1$s (%2$s %3$s), %4$s', /*$1%s*/ $parent, /*$2%s*/ $gallery['post_type'], /*$3%s*/ $gallery_id, /*$4%s*/ $gallery['post_title'] ) . "\r\n";
1595
  } // foreach $gallery
1596
+ } else {
1597
+ $mla_galleries = __( 'Disabled', 'media-library-assistant' );
1598
  }
1599
+
 
 
1600
  /*
1601
  * WordPress doesn't look in hidden fields to set the month filter dropdown or sorting parameters
1602
  */
1603
+ if ( isset( $_REQUEST['m'] ) ) {
1604
  $url_args = '&m=' . $_REQUEST['m'];
1605
+ } else {
1606
  $url_args = '';
1607
+ }
1608
+
1609
+ if ( isset( $_REQUEST['post_mime_type'] ) ) {
1610
  $url_args .= '&post_mime_type=' . $_REQUEST['post_mime_type'];
1611
+ }
1612
+
1613
+ if ( isset( $_REQUEST['order'] ) ) {
1614
  $url_args .= '&order=' . $_REQUEST['order'];
1615
+ }
1616
+
1617
+ if ( isset( $_REQUEST['orderby'] ) ) {
1618
  $url_args .= '&orderby=' . $_REQUEST['orderby'];
1619
+ }
1620
+
1621
  /*
1622
  * Add the current view arguments
1623
  */
1624
+ if ( isset( $_REQUEST['detached'] ) ) {
1625
  $view_args = '<input type="hidden" name="detached" value="' . $_REQUEST['detached'] . "\" />\r\n";
1626
+ } elseif ( isset( $_REQUEST['status'] ) ) {
1627
  $view_args = '<input type="hidden" name="status" value="' . $_REQUEST['status'] . "\" />\r\n";
1628
+ } else {
1629
  $view_args = '';
1630
+ }
1631
+
1632
+ if ( isset( $_REQUEST['paged'] ) ) {
1633
  $view_args .= sprintf( '<input type="hidden" name="paged" value="%1$s" />', $_REQUEST['paged'] ) . "\r\n";
1634
+ }
1635
+
1636
  $side_info_column = '';
1637
  $taxonomies = get_object_taxonomies( 'attachment', 'objects' );
1638
+
1639
  foreach ( $taxonomies as $tax_name => $tax_object ) {
1640
  ob_start();
1641
+
1642
  if ( $tax_object->hierarchical && $tax_object->show_ui ) {
1643
  $box = array(
1644
  'id' => $tax_name . 'div',
1662
  );
1663
  post_tags_meta_box( $post, $box );
1664
  }
1665
+
1666
  $box['inside_html'] = ob_get_contents();
1667
  ob_end_clean();
1668
  $side_info_column .= MLAData::mla_parse_template( $postbox_template, $box );
1669
  }
1670
+
1671
  $page_values = array(
1672
+ 'form_url' => admin_url( 'upload.php' ) . '?page=' . self::ADMIN_PAGE_SLUG . $url_args,
1673
  'ID' => $post_data['ID'],
1674
  'post_mime_type' => $post_data['post_mime_type'],
1675
  'menu_order' => $post_data['menu_order'],
1676
+ 'mla_admin_action' => self::MLA_ADMIN_SINGLE_EDIT_UPDATE,
1677
+ 'view_args' => $view_args,
1678
+ 'wpnonce' => wp_nonce_field( self::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1679
+ 'Cancel' => __( 'Cancel', 'media-library-assistant' ),
1680
+ 'Update' => __( 'Update', 'media-library-assistant' ),
1681
+ 'Map IPTC/EXIF metadata' => __( 'Map IPTC/EXIF metadata', 'media-library-assistant' ),
1682
  'attachment_icon' => wp_get_attachment_image( $post_id, array( 160, 120 ), true ),
1683
+ 'File name' => __( 'File name', 'media-library-assistant' ),
1684
  'file_name' => esc_html( $post_data['mla_references']['file'] ),
1685
+ 'File type' => __( 'File type', 'media-library-assistant' ),
1686
+ 'Upload date' => __( 'Upload date', 'media-library-assistant' ),
1687
+ 'post_date' => $post_data['post_date'],
1688
+ 'Last modified' => __( 'Last modified', 'media-library-assistant' ),
1689
+ 'post_modified' => $post_data['post_modified'],
1690
+ 'Dimensions' => __( 'Dimensions', 'media-library-assistant' ),
1691
  'width' => $width,
1692
  'height' => $height,
1693
+ 'Title' => __( 'Title', 'media-library-assistant' ),
1694
+ 'required' => __( 'required', 'media-library-assistant' ),
1695
  'post_title_attr' => esc_attr( $post_data['post_title'] ),
1696
+ 'Name/Slug' => __( 'Name/Slug', 'media-library-assistant' ),
1697
  'post_name_attr' => esc_attr( $post_data['post_name'] ),
1698
+ 'Must be unique' => __( 'Must be unique; will be validated.', 'media-library-assistant' ),
1699
+ 'ALT Text' => __( 'ALT Text', 'media-library-assistant' ),
1700
  'image_alt_attr' => '',
1701
+ 'ALT Text Help' => __( 'Alternate text for the image, e.g. &#8220;The Mona Lisa&#8221;', 'media-library-assistant' ),
1702
+ 'Caption' => __( 'Caption', 'media-library-assistant' ),
1703
  'post_excerpt_attr' => esc_attr( $post_data['post_excerpt'] ),
1704
+ 'Description' => __( 'Description', 'media-library-assistant' ),
1705
  'post_content' => esc_textarea( $post_data['post_content'] ),
1706
+ 'Parent Info' => __( 'Parent Info', 'media-library-assistant' ),
1707
+ 'post_parent' => $post_data['post_parent'],
1708
  'parent_info' => esc_attr( $parent_info ),
1709
+ 'Parent Info Help' => __( 'ID, type and title of parent, if any.', 'media-library-assistant' ),
1710
+ 'Menu Order' => __( 'Menu Order', 'media-library-assistant' ),
1711
  'authors' => $authors,
1712
+ 'File URL' => __( 'File URL', 'media-library-assistant' ),
1713
+ 'guid_attr' => esc_attr( $post_data['guid'] ),
1714
+ 'File URL Help' => __( 'Location of the uploaded file.', 'media-library-assistant' ),
1715
+ 'Image Metadata' => __( 'Image Metadata', 'media-library-assistant' ),
1716
+ 'image_meta' => esc_textarea( $image_meta ),
1717
+ 'Featured in' => __( 'Featured in', 'media-library-assistant' ),
1718
  'features' => esc_textarea( $features ),
1719
+ 'Inserted in' => __( 'Inserted in', 'media-library-assistant' ),
1720
  'inserts' => esc_textarea( $inserts ),
1721
+ 'Gallery in' => __( 'Gallery in', 'media-library-assistant' ),
1722
  'galleries' => esc_textarea( $galleries ),
1723
+ 'MLA Gallery in' => __( 'MLA Gallery in', 'media-library-assistant' ),
1724
  'mla_galleries' => esc_textarea( $mla_galleries ),
 
 
 
 
1725
  'side_info_column' => $side_info_column
1726
  );
1727
+
1728
  if ( !empty( $post_data['mla_wp_attachment_image_alt'] ) ) {
1729
  $page_values['image_alt_attr'] = esc_attr( $post_data['mla_wp_attachment_image_alt'] );
1730
  }
1734
  'body' => MLAData::mla_parse_template( $page_template, $page_values )
1735
  );
1736
  }
1737
+
1738
  /**
1739
  * Restore a single item from the Trash
1740
  *
1745
  * @return array success/failure message and NULL content
1746
  */
1747
  private static function _restore_single_item( $post_id ) {
1748
+ if ( !current_user_can( 'delete_post', $post_id ) ) {
1749
  return array(
1750
+ 'message' => __( 'ERROR: You are not allowed to move this item out of the Trash.', 'media-library-assistant' ),
1751
  'body' => ''
1752
  );
1753
+ }
1754
+
1755
+ if ( !wp_untrash_post( $post_id ) ) {
1756
  return array(
1757
+ /* translators: 1: post ID */
1758
+ 'message' => sprintf( __( 'ERROR: Item %1$d could NOT be restored from Trash.', 'media-library-assistant' ), $post_id ),
1759
  'body' => ''
1760
  );
1761
+ }
1762
+
1763
  /*
1764
  * Posts are restored to "draft" status, so this must be updated.
1765
  */
1767
  $update_post['ID'] = $post_id;
1768
  $update_post['post_status'] = 'inherit';
1769
  wp_update_post( $update_post );
1770
+
1771
  return array(
1772
+ /* translators: 1: post ID */
1773
+ 'message' => sprintf( __( 'Item %1$d restored from Trash.', 'media-library-assistant' ), $post_id ),
1774
  'body' => ''
1775
  );
1776
  }
1777
+
1778
  /**
1779
  * Move a single item to Trash
1780
  *
1785
  * @return array success/failure message and NULL content
1786
  */
1787
  private static function _trash_single_item( $post_id ) {
1788
+ if ( !current_user_can( 'delete_post', $post_id ) ) {
1789
  return array(
1790
+ 'message' => __( 'ERROR: You are not allowed to move this item to the Trash.', 'media-library-assistant' ),
1791
  'body' => ''
1792
  );
1793
+ }
1794
+
1795
+ if ( !wp_trash_post( $post_id, false ) ) {
1796
  return array(
1797
+ /* translators: 1: post ID */
1798
+ 'message' => sprintf( __( 'ERROR: Item %1$d could NOT be moved to Trash.', 'media-library-assistant' ), $post_id ),
1799
  'body' => ''
1800
  );
1801
+ }
1802
+
1803
  return array(
1804
+ /* translators: 1: post ID */
1805
+ 'message' => sprintf( __( 'Item %1$d moved to Trash.', 'media-library-assistant' ), $post_id ),
1806
  'body' => ''
1807
  );
1808
  }
includes/class-mla-media-modal.php CHANGED
@@ -62,8 +62,7 @@ class MLAModal {
62
  * Finally wp_enqueue_media() contains:
63
  * do_action( 'wp_enqueue_media' );
64
  */
65
- if ( MLATest::$wordpress_3point5_plus && ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_TOOLBAR ) )
66
- ) {
67
  add_filter( 'media_view_settings', 'MLAModal::mla_media_view_settings_filter', 10, 2 );
68
  add_filter( 'media_view_strings', 'MLAModal::mla_media_view_strings_filter', 10, 2 );
69
  add_action( 'wp_enqueue_media', 'MLAModal::mla_wp_enqueue_media_action', 10, 0 );
@@ -95,22 +94,24 @@ class MLAModal {
95
  ", $post_type ) );
96
 
97
  $month_count = count( $months );
98
- $month_array = array( '0' => 'Show all dates' );
99
-
100
- if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
101
  return $month_array;
 
102
 
103
  foreach ( $months as $arc_row ) {
104
- if ( 0 == $arc_row->year )
105
  continue;
 
106
 
107
  $month = zeroise( $arc_row->month, 2 );
108
  $year = $arc_row->year;
109
  $month_array[ esc_attr( $arc_row->year . $month ) ] =
110
  /* translators: 1: month name, 2: 4-digit year */
111
- sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year );
112
  }
113
-
114
  return $month_array;
115
  }
116
 
@@ -125,24 +126,26 @@ class MLAModal {
125
  */
126
  private static function _terms_options( $markup ) {
127
  $match_count = preg_match_all( "#\<option(( class=\"([^\"]+)\" )|( ))value=((\'([^\']+)\')|(\"([^\"]+)\"))([^\>]*)\>([^\<]*)\<.*#", $markup, $matches );
128
- if ( ( $match_count == false ) || ( $match_count == 0 ) )
129
  return array( 'class' => array( '' ), 'value' => array( '0' ), 'text' => array( 'Show all terms' ) );
130
-
 
131
  $class_array = array();
132
  $value_array = array();
133
  $text_array = array();
134
-
135
  foreach ( $matches[11] as $index => $text ) {
136
  $class_array[ $index ] = $matches[3][ $index ];
137
  $value_array[ $index ] = ( ! '' == $matches[6][ $index ] )? $matches[7][ $index ] : $matches[9][ $index ];
138
 
139
- if ( version_compare( get_bloginfo( 'version' ), '3.6', '>=' ) )
140
  $text_array[ $index ] = str_replace( '&nbsp;', '-', $text);
141
- else
142
  $text_array[ $index ] = $text;
143
-
 
144
  } // foreach
145
-
146
  return array( 'class' => $class_array, 'value' => $value_array, 'text' => $text_array );
147
  }
148
 
@@ -170,7 +173,7 @@ class MLAModal {
170
  'searchFields' => array( 'title', 'content' ),
171
  'searchConnector' => 'AND'
172
  );
173
-
174
  /**
175
  * Adds settings values to be passed to the Media Manager in /wp-includes/js/media-views.js.
176
  * Declared public because it is a filter.
@@ -185,14 +188,14 @@ class MLAModal {
185
  public static function mla_media_view_settings_filter( $settings, $post ) {
186
  self::$mla_media_modal_settings['ajaxNonce'] = wp_create_nonce( MLA::MLA_ADMIN_NONCE );
187
  self::$mla_media_modal_settings['mimeTypes'] = MLAMime::mla_pluck_table_views();
188
- self::$mla_media_modal_settings['mimeTypes']['detached'] = 'Unattached';
189
  self::$mla_media_modal_settings['months'] = self::_months_dropdown('attachment');
190
 
191
  $terms_options = self::_terms_options( MLA_List_Table::mla_get_taxonomy_filter_dropdown() );
192
  self::$mla_media_modal_settings['termsClass'] = $terms_options['class'];
193
  self::$mla_media_modal_settings['termsValue'] = $terms_options['value'];
194
  self::$mla_media_modal_settings['termsText'] = $terms_options['text'];
195
-
196
  self::$mla_media_modal_settings['enableMimeTypes'] = ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_MIMETYPES ) );
197
  self::$mla_media_modal_settings['enableMonthsDropdown'] = ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_MONTHS ) );
198
  self::$mla_media_modal_settings['enableTermsDropdown'] = ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_TERMS ) );
@@ -206,7 +209,7 @@ class MLAModal {
206
  self::$mla_media_modal_settings['searchConnector'] = 'AND';
207
  self::$mla_media_modal_settings['searchFields'] = array( 'title', 'content' );
208
  self::$mla_media_modal_settings['searchValue'] = '';
209
-
210
  $settings = array_merge( $settings, array( 'mla_settings' => self::$mla_media_modal_settings ) );
211
  return $settings;
212
  } // mla_mla_media_view_settings_filter
@@ -226,7 +229,7 @@ class MLAModal {
226
  $mla_strings = array(
227
  'searchBoxPlaceholder' => 'Search Box',
228
  );
229
-
230
  $strings = array_merge( $strings, array( 'mla_strings' => $mla_strings ) );
231
  return $strings;
232
  } // mla_mla_media_view_strings_filter
@@ -262,15 +265,17 @@ class MLAModal {
262
  * Adjust the toolbar styles based on which controls are present
263
  */
264
  if ( self::$mla_media_modal_settings['enableSearchBox'] ) {
265
- if ( self::$mla_media_modal_settings['enableMonthsDropdown'] && self::$mla_media_modal_settings['enableTermsDropdown'] )
266
  $height = '100px';
267
- else
268
  $height = '70px';
269
- } else
 
270
  $height = '50px';
 
271
 
272
  echo '<style type="text/css">' . "\r\n";
273
-
274
  if ( self::$mla_media_modal_settings['enableSearchBox'] ) {
275
  echo "\t\t.media-frame .media-frame-content .media-toolbar-secondary {\r\n";
276
  echo "\t\t\twidth: 150px; }\r\n";
@@ -289,62 +294,70 @@ class MLAModal {
289
  echo "\t\t\tfont-family: sans-serif;\r\n";
290
  echo "\t\t\t-webkit-appearance: none; }\r\n";
291
  echo "\t" . '</style>' . "\r\n";
292
-
293
  /*
294
  * Compose the Search Media box
295
  */
296
- if ( isset( $_REQUEST['query']['mla_search_value'] ) )
297
  $search_value = esc_attr( stripslashes( trim( $_REQUEST['query']['mla_search_value'] ) ) );
298
- else
299
  $search_value = '';
300
-
301
- if ( isset( $_REQUEST['query']['mla_search_fields'] ) )
 
302
  $search_fields = $_REQUEST['query']['mla_search_fields'];
303
- else
304
  $search_fields = array ( 'title', 'content' );
 
305
 
306
- if ( isset( $_REQUEST['query']['mla_search_connector'] ) )
307
  $search_connector = $_REQUEST['query']['mla_search_connector'];
308
- else
309
  $search_connector = 'AND';
 
310
 
311
  echo "\t" . '<script type="text/html" id="tmpl-mla-search-box">' . "\r\n";
312
  echo "\t\t" . '<p class="search-box">' . "\r\n";
313
- echo "\t\t" . '<label class="screen-reader-text" for="media-search-input">Search Media:</label>' . "\r\n";
314
  echo "\t\t" . '<input type="text" name="s[mla_search_value]" id="media-search-input" size="43" value="' . $search_value . '" />' . "\r\n";
315
- echo "\t\t" . '<input type="submit" name="mla_search_submit" id="search-submit" class="button" value="Search Media" /><br>' . "\r\n";
316
  if ( 'OR' == $search_connector ) {
317
- echo "\t\t" . '<input type="radio" name="s[mla_search_connector]" value="AND" />&nbsp;and&nbsp;' . "\r\n";
318
- echo "\t\t" . '<input type="radio" name="s[mla_search_connector]" checked="checked" value="OR" />&nbsp;or&nbsp;' . "\r\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
  } else {
320
- echo "\t\t" . '<input type="radio" name="s[mla_search_connector]" checked="checked" value="AND" />&nbsp;and&nbsp;' . "\r\n";
321
- echo "\t\t" . '<input type="radio" name="s[mla_search_connector]" value="OR" />&nbsp;or&nbsp;' . "\r\n";
322
  }
323
 
324
- if ( in_array( 'title', $search_fields ) )
325
- echo "\t\t" . '<input type="checkbox" name="s[mla_search_title]" id="search-title" checked="checked" value="title" />&nbsp;title&nbsp;' . "\r\n";
326
- else
327
- echo "\t\t" . '<input type="checkbox" name="s[mla_search_title]" id="search-title" value="title" />&nbsp;title&nbsp;' . "\r\n";
328
-
329
- if ( in_array( 'name', $search_fields ) )
330
- echo "\t\t" . '<input type="checkbox" name="s[mla_search_name]" id="search-name" checked="checked" value="name" />&nbsp;name&nbsp;' . "\r\n";
331
- else
332
- echo "\t\t" . '<input type="checkbox" name="s[mla_search_name]" id="search-name" value="name" />&nbsp;name&nbsp;' . "\r\n";
333
-
334
- if ( in_array( 'alt-text', $search_fields ) )
335
- echo "\t\t" . '<input type="checkbox" name="s[mla_search_alt_text]" id="search-alt-text" checked="checked" value="alt-text" />&nbsp;ALT text&nbsp;' . "\r\n";
336
- else
337
- echo "\t\t" . '<input type="checkbox" name="s[mla_search_alt_text]" id="search-alt-text" value="alt-text" />&nbsp;ALT text&nbsp;' . "\r\n";
338
-
339
- if ( in_array( 'excerpt', $search_fields ) )
340
- echo "\t\t" . '<input type="checkbox" name="s[mla_search_excerpt]" id="search-excerpt" checked="checked" value="excerpt" />&nbsp;caption&nbsp;' . "\r\n";
341
- else
342
- echo "\t\t" . '<input type="checkbox" name="s[mla_search_excerpt]" id="search-excerpt" value="excerpt" />&nbsp;caption&nbsp;' . "\r\n";
343
-
344
- if ( in_array( 'content', $search_fields ) )
345
- echo "\t\t" . '<input type="checkbox" name="s[mla_search_content]" id="search-content" checked="checked" value="content" />&nbsp;description&nbsp;' . "\r\n";
346
- else
347
- echo "\t\t" . '<input type="checkbox" name="s[mla_search_content]" id="search-content" value="content" />&nbsp;description&nbsp;' . "\r\n";
348
 
349
  echo "\t\t" . '</p>' . "\r\n";
350
  echo "\t" . '</script>' . "\r\n";
@@ -366,7 +379,7 @@ class MLAModal {
366
  $_POST['query'][ $key ] = $value;
367
  $_REQUEST['query'][ $key ] = $value;
368
  }
369
-
370
  unset( $_POST['query']['s'] );
371
  unset( $_REQUEST['query']['s'] );
372
  $_POST['action'] = self::JAVASCRIPT_MEDIA_MODAL_SLUG;
@@ -385,8 +398,9 @@ class MLAModal {
385
  * @return void echo HTML <tr> markup for updated row or error message, then die()
386
  */
387
  public static function mla_query_attachments_action() {
388
- if ( ! current_user_can( 'upload_files' ) )
389
  wp_send_json_error();
 
390
 
391
  /*
392
  * Pick out and clean up the query terms we can process
@@ -402,45 +416,39 @@ class MLAModal {
402
  if ( 'detached' == $query['post_mime_type'] ) {
403
  $query['detached'] = '1';
404
  unset( $query['post_mime_type'] );
405
- }
406
- else {
407
  $view = $query['post_mime_type'];
408
  unset( $query['post_mime_type'] );
409
  $query = array_merge( $query, MLAMime::mla_prepare_view_query( 'view', $view ) );
410
  }
411
  }
412
-
413
  /*
414
  * Convert mla_filter_month back to the WordPress "m" parameter
415
  */
416
  if ( isset( $query['mla_filter_month'] ) ) {
417
- if ( '0' != $query['mla_filter_month'] )
418
  $query['m'] = $query['mla_filter_month'];
419
-
 
420
  unset( $query['mla_filter_month'] );
421
  }
422
-
423
  /*
424
  * Process the enhanced search box OR fix up the default search box
425
  */
426
  if ( isset( $query['mla_search_value'] ) ) {
427
- if ( ! empty( $query['mla_search_value'] ) )
428
  $query['s'] = $query['mla_search_value'];
429
- // else
430
- // unset( $query['s'] );
431
-
432
  unset( $query['mla_search_value'] );
433
  }
434
- /* elseif ( ! empty( $query['s'] ) ) {
435
- $query['mla_search_fields'] = array( 'title', 'content' );
436
- $query['mla_search_connector'] = 'AND';
437
- } // */
438
-
439
  if ( isset( $query['posts_per_page'] ) ) {
440
  $count = $query['posts_per_page'];
441
  $offset = $count * (isset( $query['paged'] ) ? $query['paged'] - 1 : 0);
442
- }
443
- else {
444
  $count = 0;
445
  $offset = 0;
446
  }
@@ -461,7 +469,7 @@ class MLAModal {
461
  break;
462
  }
463
  }
464
-
465
  if ( ! $found_current ) {
466
  MLAOptions::mla_delete_option( MLAOptions::MLA_DEFAULT_ORDERBY );
467
  $option = MLAOptions::mla_get_option( MLAOptions::MLA_DEFAULT_ORDERBY );
@@ -469,21 +477,23 @@ class MLAModal {
469
 
470
  $query['orderby'] = $option;
471
  }
472
-
473
  $option = MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_ORDER );
474
- if ( 'default' != $option )
475
  $query['order'] = $option;
 
476
 
477
  $query['post_type'] = 'attachment';
478
  $query['post_status'] = 'inherit';
479
- if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) )
480
  $query['post_status'] .= ',private';
481
-
 
482
  $query = MLAData::mla_query_media_modal_items( $query, $offset, $count );
483
-
484
  $posts = array_map( 'wp_prepare_attachment_for_js', $query->posts );
485
  $posts = array_filter( $posts );
486
-
487
  wp_send_json_success( $posts );
488
  }
489
  } //Class MLAModal
62
  * Finally wp_enqueue_media() contains:
63
  * do_action( 'wp_enqueue_media' );
64
  */
65
+ if ( MLATest::$wordpress_3point5_plus && ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_TOOLBAR ) ) ) {
 
66
  add_filter( 'media_view_settings', 'MLAModal::mla_media_view_settings_filter', 10, 2 );
67
  add_filter( 'media_view_strings', 'MLAModal::mla_media_view_strings_filter', 10, 2 );
68
  add_action( 'wp_enqueue_media', 'MLAModal::mla_wp_enqueue_media_action', 10, 0 );
94
  ", $post_type ) );
95
 
96
  $month_count = count( $months );
97
+ $month_array = array( '0' => __( 'Show all dates', 'media-library-assistant' ) );
98
+
99
+ if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
100
  return $month_array;
101
+ }
102
 
103
  foreach ( $months as $arc_row ) {
104
+ if ( 0 == $arc_row->year ) {
105
  continue;
106
+ }
107
 
108
  $month = zeroise( $arc_row->month, 2 );
109
  $year = $arc_row->year;
110
  $month_array[ esc_attr( $arc_row->year . $month ) ] =
111
  /* translators: 1: month name, 2: 4-digit year */
112
+ sprintf( __( '%1$s %2$d', 'media-library-assistant' ), $wp_locale->get_month( $month ), $year );
113
  }
114
+
115
  return $month_array;
116
  }
117
 
126
  */
127
  private static function _terms_options( $markup ) {
128
  $match_count = preg_match_all( "#\<option(( class=\"([^\"]+)\" )|( ))value=((\'([^\']+)\')|(\"([^\"]+)\"))([^\>]*)\>([^\<]*)\<.*#", $markup, $matches );
129
+ if ( ( $match_count == false ) || ( $match_count == 0 ) ) {
130
  return array( 'class' => array( '' ), 'value' => array( '0' ), 'text' => array( 'Show all terms' ) );
131
+ }
132
+
133
  $class_array = array();
134
  $value_array = array();
135
  $text_array = array();
136
+
137
  foreach ( $matches[11] as $index => $text ) {
138
  $class_array[ $index ] = $matches[3][ $index ];
139
  $value_array[ $index ] = ( ! '' == $matches[6][ $index ] )? $matches[7][ $index ] : $matches[9][ $index ];
140
 
141
+ if ( version_compare( get_bloginfo( 'version' ), '3.6', '>=' ) ) {
142
  $text_array[ $index ] = str_replace( '&nbsp;', '-', $text);
143
+ } else {
144
  $text_array[ $index ] = $text;
145
+ }
146
+
147
  } // foreach
148
+
149
  return array( 'class' => $class_array, 'value' => $value_array, 'text' => $text_array );
150
  }
151
 
173
  'searchFields' => array( 'title', 'content' ),
174
  'searchConnector' => 'AND'
175
  );
176
+
177
  /**
178
  * Adds settings values to be passed to the Media Manager in /wp-includes/js/media-views.js.
179
  * Declared public because it is a filter.
188
  public static function mla_media_view_settings_filter( $settings, $post ) {
189
  self::$mla_media_modal_settings['ajaxNonce'] = wp_create_nonce( MLA::MLA_ADMIN_NONCE );
190
  self::$mla_media_modal_settings['mimeTypes'] = MLAMime::mla_pluck_table_views();
191
+ self::$mla_media_modal_settings['mimeTypes']['detached'] = MLAOptions::$mla_option_definitions[ MLAOptions::MLA_POST_MIME_TYPES ]['std']['unattached']['plural'];
192
  self::$mla_media_modal_settings['months'] = self::_months_dropdown('attachment');
193
 
194
  $terms_options = self::_terms_options( MLA_List_Table::mla_get_taxonomy_filter_dropdown() );
195
  self::$mla_media_modal_settings['termsClass'] = $terms_options['class'];
196
  self::$mla_media_modal_settings['termsValue'] = $terms_options['value'];
197
  self::$mla_media_modal_settings['termsText'] = $terms_options['text'];
198
+
199
  self::$mla_media_modal_settings['enableMimeTypes'] = ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_MIMETYPES ) );
200
  self::$mla_media_modal_settings['enableMonthsDropdown'] = ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_MONTHS ) );
201
  self::$mla_media_modal_settings['enableTermsDropdown'] = ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_TERMS ) );
209
  self::$mla_media_modal_settings['searchConnector'] = 'AND';
210
  self::$mla_media_modal_settings['searchFields'] = array( 'title', 'content' );
211
  self::$mla_media_modal_settings['searchValue'] = '';
212
+
213
  $settings = array_merge( $settings, array( 'mla_settings' => self::$mla_media_modal_settings ) );
214
  return $settings;
215
  } // mla_mla_media_view_settings_filter
229
  $mla_strings = array(
230
  'searchBoxPlaceholder' => 'Search Box',
231
  );
232
+
233
  $strings = array_merge( $strings, array( 'mla_strings' => $mla_strings ) );
234
  return $strings;
235
  } // mla_mla_media_view_strings_filter
265
  * Adjust the toolbar styles based on which controls are present
266
  */
267
  if ( self::$mla_media_modal_settings['enableSearchBox'] ) {
268
+ if ( self::$mla_media_modal_settings['enableMonthsDropdown'] && self::$mla_media_modal_settings['enableTermsDropdown'] ) {
269
  $height = '100px';
270
+ } else {
271
  $height = '70px';
272
+ }
273
+ } else {
274
  $height = '50px';
275
+ }
276
 
277
  echo '<style type="text/css">' . "\r\n";
278
+
279
  if ( self::$mla_media_modal_settings['enableSearchBox'] ) {
280
  echo "\t\t.media-frame .media-frame-content .media-toolbar-secondary {\r\n";
281
  echo "\t\t\twidth: 150px; }\r\n";
294
  echo "\t\t\tfont-family: sans-serif;\r\n";
295
  echo "\t\t\t-webkit-appearance: none; }\r\n";
296
  echo "\t" . '</style>' . "\r\n";
297
+
298
  /*
299
  * Compose the Search Media box
300
  */
301
+ if ( isset( $_REQUEST['query']['mla_search_value'] ) ) {
302
  $search_value = esc_attr( stripslashes( trim( $_REQUEST['query']['mla_search_value'] ) ) );
303
+ } else {
304
  $search_value = '';
305
+ }
306
+
307
+ if ( isset( $_REQUEST['query']['mla_search_fields'] ) ) {
308
  $search_fields = $_REQUEST['query']['mla_search_fields'];
309
+ } else {
310
  $search_fields = array ( 'title', 'content' );
311
+ }
312
 
313
+ if ( isset( $_REQUEST['query']['mla_search_connector'] ) ) {
314
  $search_connector = $_REQUEST['query']['mla_search_connector'];
315
+ } else {
316
  $search_connector = 'AND';
317
+ }
318
 
319
  echo "\t" . '<script type="text/html" id="tmpl-mla-search-box">' . "\r\n";
320
  echo "\t\t" . '<p class="search-box">' . "\r\n";
321
+ echo "\t\t" . '<label class="screen-reader-text" for="media-search-input">' . __( 'Search Media', 'media-library-assistant' ) . ':</label>' . "\r\n";
322
  echo "\t\t" . '<input type="text" name="s[mla_search_value]" id="media-search-input" size="43" value="' . $search_value . '" />' . "\r\n";
323
+ echo "\t\t" . '<input type="submit" name="mla_search_submit" id="search-submit" class="button" value="' . __( 'Search Media', 'media-library-assistant' ) . '" /><br>' . "\r\n";
324
  if ( 'OR' == $search_connector ) {
325
+ echo "\t\t" . '<input type="radio" name="s[mla_search_connector]" value="AND" />&nbsp;' . __( 'and', 'media-library-assistant' ) . "&nbsp;\r\n";
326
+ echo "\t\t" . '<input type="radio" name="s[mla_search_connector]" checked="checked" value="OR" />&nbsp;' . __( 'or', 'media-library-assistant' ) . "&nbsp;\r\n";
327
+ } else {
328
+ echo "\t\t" . '<input type="radio" name="s[mla_search_connector]" checked="checked" value="AND" />&nbsp;' . __( 'and', 'media-library-assistant' ) . "&nbsp;\r\n";
329
+ echo "\t\t" . '<input type="radio" name="s[mla_search_connector]" value="OR" />&nbsp;' . __( 'or', 'media-library-assistant' ) . "&nbsp;\r\n";
330
+ }
331
+
332
+ if ( in_array( 'title', $search_fields ) ) {
333
+ echo "\t\t" . '<input type="checkbox" name="s[mla_search_title]" id="search-title" checked="checked" value="title" />&nbsp;' . __( 'Title', 'media-library-assistant' ) . "&nbsp;\r\n";
334
+ } else {
335
+ echo "\t\t" . '<input type="checkbox" name="s[mla_search_title]" id="search-title" value="title" />&nbsp;' . __( 'Title', 'media-library-assistant' ) . "&nbsp;\r\n";
336
+ }
337
+
338
+ if ( in_array( 'name', $search_fields ) ) {
339
+ echo "\t\t" . '<input type="checkbox" name="s[mla_search_name]" id="search-name" checked="checked" value="name" />&nbsp;' . __( 'Name', 'media-library-assistant' ) . "&nbsp;\r\n";
340
+ } else {
341
+ echo "\t\t" . '<input type="checkbox" name="s[mla_search_name]" id="search-name" value="name" />&nbsp;' . __( 'Name', 'media-library-assistant' ) . "&nbsp;\r\n";
342
+ }
343
+
344
+ if ( in_array( 'alt-text', $search_fields ) ) {
345
+ echo "\t\t" . '<input type="checkbox" name="s[mla_search_alt_text]" id="search-alt-text" checked="checked" value="alt-text" />&nbsp;' . __( 'ALT Text', 'media-library-assistant' ) . "&nbsp;\r\n";
346
  } else {
347
+ echo "\t\t" . '<input type="checkbox" name="s[mla_search_alt_text]" id="search-alt-text" value="alt-text" />&nbsp;' . __( 'ALT Text', 'media-library-assistant' ) . "&nbsp;\r\n";
 
348
  }
349
 
350
+ if ( in_array( 'excerpt', $search_fields ) ) {
351
+ echo "\t\t" . '<input type="checkbox" name="s[mla_search_excerpt]" id="search-excerpt" checked="checked" value="excerpt" />&nbsp;' . __( 'Caption', 'media-library-assistant' ) . "&nbsp;\r\n";
352
+ } else {
353
+ echo "\t\t" . '<input type="checkbox" name="s[mla_search_excerpt]" id="search-excerpt" value="excerpt" />&nbsp;' . __( 'Caption', 'media-library-assistant' ) . "&nbsp;\r\n";
354
+ }
355
+
356
+ if ( in_array( 'content', $search_fields ) ) {
357
+ echo "\t\t" . '<input type="checkbox" name="s[mla_search_content]" id="search-content" checked="checked" value="content" />&nbsp;' . __( 'Description', 'media-library-assistant' ) . "&nbsp;\r\n";
358
+ } else {
359
+ echo "\t\t" . '<input type="checkbox" name="s[mla_search_content]" id="search-content" value="content" />&nbsp;' . __( 'Description', 'media-library-assistant' ) . "&nbsp;\r\n";
360
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
361
 
362
  echo "\t\t" . '</p>' . "\r\n";
363
  echo "\t" . '</script>' . "\r\n";
379
  $_POST['query'][ $key ] = $value;
380
  $_REQUEST['query'][ $key ] = $value;
381
  }
382
+
383
  unset( $_POST['query']['s'] );
384
  unset( $_REQUEST['query']['s'] );
385
  $_POST['action'] = self::JAVASCRIPT_MEDIA_MODAL_SLUG;
398
  * @return void echo HTML <tr> markup for updated row or error message, then die()
399
  */
400
  public static function mla_query_attachments_action() {
401
+ if ( ! current_user_can( 'upload_files' ) ) {
402
  wp_send_json_error();
403
+ }
404
 
405
  /*
406
  * Pick out and clean up the query terms we can process
416
  if ( 'detached' == $query['post_mime_type'] ) {
417
  $query['detached'] = '1';
418
  unset( $query['post_mime_type'] );
419
+ } else {
 
420
  $view = $query['post_mime_type'];
421
  unset( $query['post_mime_type'] );
422
  $query = array_merge( $query, MLAMime::mla_prepare_view_query( 'view', $view ) );
423
  }
424
  }
425
+
426
  /*
427
  * Convert mla_filter_month back to the WordPress "m" parameter
428
  */
429
  if ( isset( $query['mla_filter_month'] ) ) {
430
+ if ( '0' != $query['mla_filter_month'] ) {
431
  $query['m'] = $query['mla_filter_month'];
432
+ }
433
+
434
  unset( $query['mla_filter_month'] );
435
  }
436
+
437
  /*
438
  * Process the enhanced search box OR fix up the default search box
439
  */
440
  if ( isset( $query['mla_search_value'] ) ) {
441
+ if ( ! empty( $query['mla_search_value'] ) ) {
442
  $query['s'] = $query['mla_search_value'];
443
+ }
444
+
 
445
  unset( $query['mla_search_value'] );
446
  }
447
+
 
 
 
 
448
  if ( isset( $query['posts_per_page'] ) ) {
449
  $count = $query['posts_per_page'];
450
  $offset = $count * (isset( $query['paged'] ) ? $query['paged'] - 1 : 0);
451
+ } else {
 
452
  $count = 0;
453
  $offset = 0;
454
  }
469
  break;
470
  }
471
  }
472
+
473
  if ( ! $found_current ) {
474
  MLAOptions::mla_delete_option( MLAOptions::MLA_DEFAULT_ORDERBY );
475
  $option = MLAOptions::mla_get_option( MLAOptions::MLA_DEFAULT_ORDERBY );
477
 
478
  $query['orderby'] = $option;
479
  }
480
+
481
  $option = MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_ORDER );
482
+ if ( 'default' != $option ) {
483
  $query['order'] = $option;
484
+ }
485
 
486
  $query['post_type'] = 'attachment';
487
  $query['post_status'] = 'inherit';
488
+ if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) ) {
489
  $query['post_status'] .= ',private';
490
+ }
491
+
492
  $query = MLAData::mla_query_media_modal_items( $query, $offset, $count );
493
+
494
  $posts = array_map( 'wp_prepare_attachment_for_js', $query->posts );
495
  $posts = array_filter( $posts );
496
+
497
  wp_send_json_success( $posts );
498
  }
499
  } //Class MLAModal
includes/class-mla-mime-types.php CHANGED
@@ -27,14 +27,16 @@ class MLAMime {
27
  // add_filter( 'wp_check_filetype_and_ext', 'MLAMime::mla_wp_check_filetype_and_ext_filter', 0x7FFFFFFF, 4 );
28
 
29
  if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_UPLOAD_MIMES ) ) {
30
- if ( function_exists('wp_get_mime_types') )
31
  add_filter( 'mime_types', 'MLAMime::mla_mime_types_filter', 0x7FFFFFFF, 1 );
32
-
33
- add_filter( 'upload_mimes', 'MLAMime::mla_upload_mimes_filter', 0x7FFFFFFF, 1 );
 
34
  }
35
 
36
- if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_POST_MIME_TYPES ) )
37
  add_filter( 'post_mime_types', 'MLAMime::mla_post_mime_types_filter', 0x7FFFFFFF, 1 );
 
38
 
39
  add_filter( 'icon_dir', 'MLAMime::mla_icon_dir_filter', 0x7FFFFFFF, 1 );
40
  add_filter( 'icon_dir_uri', 'MLAMime::mla_icon_dir_uri_filter', 0x7FFFFFFF, 1 );
@@ -50,7 +52,7 @@ class MLAMime {
50
  * @var boolean
51
  */
52
  private static $disable_mla_filtering = false;
53
-
54
  /**
55
  * Sanitize a MIME type
56
  *
@@ -110,25 +112,28 @@ class MLAMime {
110
  return $standard_types;
111
  }
112
 
113
- if ( NULL != self::$mla_icon_type_associations )
114
  return self::$mla_icon_type_associations;
 
115
 
116
- if ( ! self::_get_upload_mime_templates() )
117
  return $standard_types;
118
-
 
119
  /*
120
  * Build and sort the type => extensions list
121
  */
122
  $items = self::mla_query_upload_items( array( 'mla_upload_view' => 'active' ), 0, 0 );
123
  $pairs = array();
124
  foreach ( $items as $value )
125
- if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) )
126
  $pairs[ $value->slug ] = $value->icon_type;
127
- else
128
  $pairs[ $value->slug ] = $value->wp_icon_type;
129
-
 
130
  asort( $pairs );
131
-
132
  /*
133
  * Compress the list, grouping by icon_type
134
  */
@@ -140,9 +145,9 @@ class MLAMime {
140
  self::$mla_icon_type_associations[ $icon_type ] = $extensions;
141
  $extensions = array( $this_extension );
142
  $icon_type = $this_type;
143
- }
144
- else
145
  $extensions[] = $this_extension;
 
146
  }
147
 
148
  self::$mla_icon_type_associations[ $icon_type ] = $extensions;
@@ -194,10 +199,11 @@ class MLAMime {
194
  */
195
  public static function mla_mime_types_filter( $mime_types ) {
196
  global $wp_filter;
197
-
198
- if ( self::$disable_mla_filtering || ! self::_get_upload_mime_templates() )
199
  return $mime_types;
200
-
 
201
  /*
202
  * Build and sort the extension => type list
203
  */
@@ -205,9 +211,9 @@ class MLAMime {
205
  $pairs = array();
206
  foreach ( $items as $value )
207
  $pairs[ $value->slug ] = $value->mime_type;
208
-
209
  asort( $pairs );
210
-
211
  /*
212
  * Compress the list, grouping my mime_type
213
  */
@@ -219,14 +225,14 @@ class MLAMime {
219
  $items[ $extensions ] = $mime_type;
220
  $extensions = $this_extension;
221
  $mime_type = $this_type;
222
- }
223
- else
224
  $extensions .= '|' . $this_extension;
 
225
  }
226
 
227
  $items[ $extensions ] = $mime_type;
228
  unset( $items['.bad.value.'] );
229
-
230
  return $items; // $mime_types;
231
  } // mla_mime_types_filter
232
 
@@ -248,15 +254,17 @@ class MLAMime {
248
  * @since 1.40
249
  *
250
  * @param array Mime types keyed by the file extension regex corresponding to those types
 
251
  *
252
  * @return array Updated allowed MIME types
253
  */
254
- public static function mla_upload_mimes_filter( $mime_types ) {
255
  global $wp_filter;
256
-
257
- if ( self::$disable_mla_filtering || ! self::_get_upload_mime_templates() )
258
  return $mime_types;
259
-
 
260
  /*
261
  * Build and sort the extension => type list
262
  */
@@ -264,9 +272,9 @@ class MLAMime {
264
  $pairs = array();
265
  foreach ( $items as $value )
266
  $pairs[ $value->slug ] = $value->mime_type;
267
-
268
  asort( $pairs );
269
-
270
  /*
271
  * Compress the list, grouping by mime_type
272
  */
@@ -278,15 +286,30 @@ class MLAMime {
278
  $items[ $extensions ] = $mime_type;
279
  $extensions = $this_extension;
280
  $mime_type = $this_type;
281
- }
282
- else
283
  $extensions .= '|' . $this_extension;
 
284
  }
285
 
286
  $items[ $extensions ] = $mime_type;
287
  unset( $items['.bad.value.'] );
 
 
 
 
 
 
 
 
 
288
 
289
- return $mime_types;
 
 
 
 
 
 
290
  } // mla_upload_mimes_filter
291
 
292
  /**
@@ -306,17 +329,18 @@ class MLAMime {
306
  * @since 1.40
307
  *
308
  * @param array Content types (image, audio, video) and presentation strings, e.g.
309
- * 'image' => array(__('Images'), __('Manage Images'),
310
- * _n_noop('Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>')),
311
  *
312
  * @return array Updated allowed MIME types
313
  */
314
  public static function mla_post_mime_types_filter( $post_mime_types ) {
315
  global $wp_filter;
316
 
317
- if ( self::$disable_mla_filtering || ! self::_get_post_mime_templates() )
318
  return $post_mime_types;
319
-
 
320
  /*
321
  * Filter the list and sort by menu_order
322
  */
@@ -331,15 +355,21 @@ class MLAMime {
331
 
332
  /*
333
  * Generate the merged, sorted list
 
 
 
 
 
334
  */
 
335
  $new_mime_types = array();
336
  foreach ( $sorted_types as $value ) {
337
  $singular = sprintf('%s <span class="count">(%%s)</span>', $value['singular'] );
338
  $plural = sprintf('%s <span class="count">(%%s)</span>', $value['plural'] );
339
  $new_mime_types[ $value['slug'] ] = array(
340
- __( $value['plural'] ),
341
- __( 'Manage ' . $value['plural'] ),
342
- _n_noop( $singular, $plural )
343
  );
344
  }
345
 
@@ -363,8 +393,9 @@ class MLAMime {
363
  public static function mla_icon_dir_filter( $path ) {
364
  global $wp_filter;
365
 
366
- if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) )
367
  return MLA_PLUGIN_PATH . 'images/crystal';
 
368
 
369
  return $path;
370
  } // mla_icon_dir_filter
@@ -384,9 +415,10 @@ class MLAMime {
384
  public static function mla_icon_dir_uri_filter( $uri ) {
385
  global $wp_filter;
386
 
387
- if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) )
388
  return MLA_PLUGIN_URL . 'images/crystal';
389
-
 
390
  return $uri;
391
  } // mla_icon_dir_uri_filter
392
 
@@ -404,10 +436,11 @@ class MLAMime {
404
  */
405
  public static function mla_icon_dirs_filter( $path_uri_array ) {
406
  global $wp_filter;
407
-
408
- if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) )
409
  $path_uri_array [ MLA_PLUGIN_PATH . 'images/crystal' ] = MLA_PLUGIN_URL . 'images/crystal';
410
-
 
411
  return $path_uri_array;
412
  } // mla_icon_dirs_filter
413
 
@@ -446,7 +479,8 @@ class MLAMime {
446
  * sanitize or validate them.
447
  */
448
  if ( ! is_array( $raw_request ) ) {
449
- error_log( 'ERROR: _prepare_view_items_query $raw_request = ' . var_export( $raw_request, true ), 0 );
 
450
  return NULL;
451
  }
452
 
@@ -459,9 +493,9 @@ class MLAMime {
459
  foreach ( $raw_request as $key => $value ) {
460
  switch ( $key ) {
461
  case 'orderby':
462
- if ( 'none' == $value )
463
  $clean_request[ $key ] = $value;
464
- else {
465
  $sortable_columns = MLA_View_List_Table::mla_get_sortable_columns();
466
  foreach ($sortable_columns as $sort_key => $sort_value ) {
467
  if ( $value == $sort_value[0] ) {
@@ -513,8 +547,9 @@ class MLAMime {
513
  * @return array query results; array of MLA post_mime_type objects
514
  */
515
  private static function _execute_view_items_query( $request ) {
516
- if ( ! self::_get_post_mime_templates() )
517
  return array ();
 
518
 
519
  /*
520
  * Sort and filter the list
@@ -532,8 +567,9 @@ class MLAMime {
532
  $found |= false !== stripos( $value['plural'], $keyword );
533
  $found |= false !== stripos( $value['description'], $keyword );
534
 
535
- if ( ! $found )
536
  continue;
 
537
  }
538
 
539
  $value['slug'] = $slug;
@@ -570,8 +606,9 @@ class MLAMime {
570
  }
571
  ksort( $sorted_types );
572
 
573
- if ( 'DESC' == $request['order'] )
574
  $sorted_types = array_reverse( $sorted_types, true );
 
575
 
576
  /*
577
  * Paginate the sorted list
@@ -580,12 +617,13 @@ class MLAMime {
580
  $offset = isset( $request['offset'] ) ? $request['offset'] : 0;
581
  $count = isset( $request['posts_per_page'] ) ? $request['posts_per_page'] : -1;
582
  foreach ( $sorted_types as $value ) {
583
- if ( $offset )
584
  $offset--;
585
- elseif ( $count-- )
586
  $results[] = $value;
587
- else
588
  break;
 
589
  }
590
 
591
  return $results;
@@ -632,22 +670,25 @@ class MLAMime {
632
  */
633
  public static function mla_pluck_table_views() {
634
  $mla_types = MLAMime::mla_query_view_items( array( 'orderby' => 'menu_order' ), 0, 0 );
635
- if ( ! is_array( $mla_types ) )
636
  $mla_types = array ();
637
-
 
638
  /*
639
  * Filter the list, generate the list
640
  */
641
  $results = array();
642
  foreach ( $mla_types as $value ) {
643
- if ( in_array( $value->slug, array( 'all', 'trash', 'unattached' ) ) )
644
  continue;
645
-
 
646
  if ( $value->table_view ) {
647
- if ( empty( $value->specification ) )
648
  $results[ $value->slug ] = $value->plural;
649
- else
650
  $results[ $value->specification ] = $value->plural;
 
651
  }
652
  }
653
 
@@ -671,7 +712,7 @@ class MLAMime {
671
  * @var integer
672
  */
673
  private static $mla_post_mime_highest_ID = 0;
674
-
675
  /**
676
  * Assemble the in-memory representation of the Post MIME Types
677
  *
@@ -682,15 +723,17 @@ class MLAMime {
682
  * @return boolean Success (true) or failure (false) of the operation
683
  */
684
  private static function _get_post_mime_templates( $force_refresh = false ) {
685
- if ( false == $force_refresh && NULL != self::$mla_post_mime_templates )
686
  return true;
687
-
 
688
  /*
689
  * Start with MLA standard types
690
  */
691
  $mla_types = MLAOptions::mla_get_option( MLAOptions::MLA_POST_MIME_TYPES, true );
692
- if ( ! is_array( $mla_types ) )
693
  $mla_types = array ();
 
694
 
695
  /*
696
  * If this is the first time MLA Post MIME support is invoked, match to the
@@ -698,18 +741,17 @@ class MLAMime {
698
  * Otherwise, add the current MLA custom types.
699
  */
700
  $custom_types = MLAOptions::mla_get_option( MLAOptions::MLA_POST_MIME_TYPES, false, true );
701
-
702
  if ( is_array( $custom_types ) ) {
703
  $mla_types = array_merge( $mla_types, $custom_types );
704
- }
705
- else {
706
  /*
707
  * Add existing types that are not already in the MLA list
708
  */
709
  self::$disable_mla_filtering = true;
710
  $post_mime_types = get_post_mime_types();
711
  self::$disable_mla_filtering = false;
712
-
713
  foreach ( $post_mime_types as $slug => $value )
714
  if ( ! isset( $mla_types[ $slug ] ) ) {
715
  $mla_types[ $slug ] = array(
@@ -719,7 +761,7 @@ class MLAMime {
719
  'post_mime_type' => true,
720
  'table_view' => true,
721
  'menu_order' => 0,
722
- 'description' => 'Copied from previous filter/plugin'
723
  );
724
  } // new type
725
  } // First time called
@@ -753,12 +795,13 @@ class MLAMime {
753
 
754
  foreach ( self::$mla_post_mime_templates as $slug => $value ) {
755
  unset( $value['post_ID'] );
756
- if ( isset ( $mla_types[ $slug ] ) && $value == $mla_types[ $slug ] )
757
  continue;
758
-
 
759
  $mla_post_mimes[ $slug ] = $value;
760
  }
761
-
762
  MLAOptions::mla_update_option( MLAOptions::MLA_POST_MIME_TYPES, $mla_post_mimes );
763
  return true;
764
  }
@@ -776,9 +819,9 @@ class MLAMime {
776
  public static function mla_prepare_view_query( $slug, $specification ) {
777
  $query = array ( );
778
  $specification = self::mla_parse_view_specification( $specification );
779
- if ( 'mime' == $specification['prefix'] )
780
  $query['post_mime_type'] = $specification['value'];
781
- else {
782
  $meta_query = array( 'slug' => $slug , 'relation' => 'OR', 'patterns' => array () );
783
  switch( $specification['option'] ) {
784
  case 'match':
@@ -791,14 +834,15 @@ class MLAMime {
791
  */
792
  $meta_query['patterns'][] = $pattern;
793
  $meta_query[] = array( 'key' => $specification['name'], 'value' => $pattern, 'compare' => 'LIKE' );
794
- }
795
- else
796
  $meta_query[] = array( 'key' => $specification['name'], 'value' => $pattern, 'compare' => '=' );
 
797
  } // foreach pattern
798
-
799
- if ( empty( $meta_query['patterns'] ) )
800
  unset( $meta_query['patterns'] );
801
-
 
802
  break;
803
  case 'null':
804
  $meta_query['key'] = $specification['name'];
@@ -807,10 +851,10 @@ class MLAMime {
807
  default: // '', 'any'
808
  $meta_query[] = array( 'key' => $specification['name'], 'value' => NULL, 'compare' => '!=' );
809
  }
810
-
811
  $query['meta_query'] = $meta_query;
812
  } // custom field specification
813
-
814
  return $query;
815
  }
816
 
@@ -829,24 +873,22 @@ class MLAMime {
829
  if ( 1 == $match_count ) {
830
  $result['prefix'] = trim( strtolower( $matches[1] ) );
831
  $tail = $matches[2];
832
-
833
  $match_count = preg_match( '/([^,=]+)((,|=)(.+))$/', $tail, $matches );
834
  if ( 1 == $match_count ) {
835
  $result['name'] = $matches[1];
836
-
837
- if ( ',' == $matches[3] )
838
  $result['option'] = trim( strtolower( $matches[4] ));
839
- else {
840
  $result['option'] = 'match';
841
  $result['value'] = $matches[4];
842
  }
843
- }
844
- else {
845
  $result['option'] = 'any';
846
  $result['name'] = $tail;
847
  }
848
- }
849
- else {
850
  $result['prefix'] = 'mime';
851
  $result['value'] = $specification;
852
  }
@@ -859,20 +901,24 @@ class MLAMime {
859
  foreach ( (array) $mime_types as $raw_mime_type ) {
860
  $no_wildcards = str_replace( '*', 'X', $raw_mime_type );
861
  $clean_mime_type = sanitize_mime_type( $no_wildcards );
862
- if ( $clean_mime_type != $no_wildcards )
863
- $result['error'] = sprintf( '<br>ERROR: Bad specification part "%1$s"', $raw_mime_type );
 
 
864
  } // foreach
865
- } // mime
866
- elseif ( 'custom' == $result['prefix'] ) {
867
- if ( ! in_array( $result['option'], array( '', 'any', 'match', 'null' ) ) )
868
- $result['error'] = sprintf( '<br>ERROR: Bad specification option "%1$s"', $specification['option'] );
 
 
 
 
869
  }
870
- else
871
- $result['error'] = sprintf( '<br>ERROR: Bad specification prefix "%1$s"', $specification['prefix'] );
872
-
873
  return $result;
874
  }
875
-
876
  /**
877
  * Add an MLA post_mime_type object
878
  *
@@ -883,8 +929,9 @@ class MLAMime {
883
  * @return array Message(s) reflecting the results of the operation
884
  */
885
  public static function mla_add_post_mime_type( $request ) {
886
- if ( ! self::_get_post_mime_templates() )
887
  self::$mla_post_mime_templates = array ();
 
888
 
889
  $messages = '';
890
  $errors = '';
@@ -897,33 +944,39 @@ class MLAMime {
897
 
898
  if ( !empty( $request['specification'] ) ) {
899
  $request['specification'] = '';
900
- $messages .= '<br>Ignoring specification for Post MIME Type; using slug';
901
  }
902
  }
903
 
904
- if ( $slug != $request['slug'] )
905
- $messages .= sprintf( '<br>Changing Slug "%1$s" to valid value "%2$s"', $request['slug'], $slug );
 
 
906
 
907
  /*
908
  * Make sure new slug is unique
909
  */
910
- if ( isset( self::$mla_post_mime_templates[ $slug ] ) )
911
- $errors .= sprintf( '<br>ERROR: Could not add Slug "%1$s"; value already exists', $slug );
 
 
912
 
913
  /*
914
  * Validate specification, if present
915
  */
916
  if ( !empty( $request['specification'] ) ) {
917
  $specification = self::mla_parse_view_specification( $request['specification'] );
918
- if ( isset( $specification['error'] ) )
919
  $errors .= $specification['error'];
 
920
  }
921
 
922
- if ( ! empty( $errors ) )
923
  return array(
924
  'message' => substr( $errors . $messages, 4),
925
  'body' => ''
926
  );
 
927
 
928
  $new_type = array();
929
  $new_type['singular'] = sanitize_text_field( $request['singular'] );
@@ -939,7 +992,8 @@ class MLAMime {
939
  self::_put_post_mime_templates();
940
 
941
  return array(
942
- 'message' => substr( $messages . sprintf( '<br>Edit view "%1$s"; added', $slug ), 4),
 
943
  'body' => ''
944
  );
945
  }
@@ -954,18 +1008,19 @@ class MLAMime {
954
  * @return array Message(s) reflecting the results of the operation
955
  */
956
  public static function mla_update_post_mime_type( $request ) {
957
- if ( ! self::_get_post_mime_templates() )
958
  self::$mla_post_mime_templates = array ();
959
-
 
960
  $messages = '';
961
  $errors = '';
962
  $slug = sanitize_mime_type( $request['slug'] );
963
  $original_slug = isset( $request['original_slug'] ) ? $request['original_slug'] : $slug;
964
  unset( $request['original_slug'] );
965
 
966
- if ( isset( self::$mla_post_mime_templates[ $original_slug ] ) )
967
  $original_type = self::$mla_post_mime_templates[ $original_slug ];
968
- else
969
  $original_type = array(
970
  'singular' => '',
971
  'plural' => '',
@@ -975,21 +1030,27 @@ class MLAMime {
975
  'menu_order' => '',
976
  'description' => ''
977
  );
 
978
 
979
  /*
980
  * Validate changed slug value
981
  */
982
  if ( $slug != $original_slug ) {
983
- if ( $slug != $request['slug'] )
984
- $messages .= sprintf( '<br>Changing new Slug "%1$s" to valid value "%2$s"', $request['slug'], $slug );
 
 
985
 
986
  /*
987
  * Make sure new slug is unique
988
  */
989
- if ( isset( self::$mla_post_mime_templates[ $slug ] ) )
990
- $errors .= sprintf( '<br>ERROR: Could not add new Slug "%1$s"; value already exists', $slug );
991
- else
992
- $messages .= sprintf( '<br>Changing Slug from "%1$s" to "%2$s"', $original_slug, $slug );
 
 
 
993
  }
994
 
995
  /*
@@ -1000,21 +1061,23 @@ class MLAMime {
1000
  if ( $post_mime_type ) {
1001
  if ( !empty( $specification ) ) {
1002
  $specification = '';
1003
- $messages .= '<br>Ignoring specification for Post MIME Type; using slug';
1004
  }
1005
  }
1006
 
1007
  if ( !empty( $specification ) ) {
1008
  $result = self::mla_parse_view_specification( $request['specification'] );
1009
- if ( isset( $result['error'] ) )
1010
  $errors .= $result['error'];
 
1011
  }
1012
 
1013
- if ( ! empty( $errors ) )
1014
  return array(
1015
  'message' => substr( $errors . $messages, 4),
1016
  'body' => ''
1017
  );
 
1018
 
1019
  $new_type = array();
1020
  $new_type['singular'] = isset( $request['singular'] ) ? sanitize_text_field( $request['singular'] ) : $original_type['singular'];
@@ -1025,20 +1088,24 @@ class MLAMime {
1025
  $new_type['menu_order'] = isset( $request['menu_order'] ) ? absint( $request['menu_order'] ) : $original_type['menu_order'];
1026
  $new_type['description'] = isset( $request['description'] ) ? sanitize_text_field( $request['description'] ) : $original_type['description'];
1027
 
1028
- if ( ( $slug == $original_slug ) && ( self::$mla_post_mime_templates[ $slug ] == $new_type ) )
1029
  return array(
1030
- 'message' => substr( $messages . sprintf( '<br>Edit view "%1$s"; no changes detected', $slug ), 4),
 
1031
  'body' => ''
1032
  );
 
1033
 
1034
  self::$mla_post_mime_templates[ $slug ] = $new_type;
1035
 
1036
- if ( $slug != $original_slug )
1037
  unset( self::$mla_post_mime_templates[ $original_slug ] );
 
1038
 
1039
  self::_put_post_mime_templates();
1040
  return array(
1041
- 'message' => $messages = substr( $messages . sprintf( '<br>Edit view "%1$s"; updated', $slug ), 4),
 
1042
  'body' => ''
1043
  );
1044
  }
@@ -1053,12 +1120,14 @@ class MLAMime {
1053
  * @return mixed string with slug of the requested object; false if object not found
1054
  */
1055
  public static function mla_get_post_mime_type_slug( $post_ID ) {
1056
- if ( ! self::_get_post_mime_templates() )
1057
  self::$mla_post_mime_templates = array ();
 
1058
 
1059
  foreach ( self::$mla_post_mime_templates as $slug => $value ) {
1060
- if ( $post_ID == $value['post_ID'] )
1061
  return $slug;
 
1062
  }
1063
 
1064
  return false;
@@ -1074,8 +1143,9 @@ class MLAMime {
1074
  * @return mixed Array of elements, including slug, for the requested object; false if object not found
1075
  */
1076
  public static function mla_get_post_mime_type( $slug ) {
1077
- if ( ! self::_get_post_mime_templates() )
1078
  self::$mla_post_mime_templates = array ();
 
1079
 
1080
  if ( isset( self::$mla_post_mime_templates[ $slug ] ) ) {
1081
  $matched_value = self::$mla_post_mime_templates[ $slug ];
@@ -1096,28 +1166,33 @@ class MLAMime {
1096
  * @return array Message(s) reflecting the results of the operation
1097
  */
1098
  public static function mla_delete_post_mime_type( $slug ) {
1099
- if ( ! self::_get_post_mime_templates() )
1100
  self::$mla_post_mime_templates = array ();
 
1101
 
1102
  if ( isset( self::$mla_post_mime_templates[ $slug ] ) ) {
1103
  unset( self::$mla_post_mime_templates[ $slug ] );
1104
  self::_put_post_mime_templates();
1105
  self::_get_post_mime_templates( true );
1106
 
1107
- if ( isset( self::$mla_post_mime_templates[ $slug ] ) )
1108
  return array(
1109
- 'message' => sprintf( 'View "%1$s" reverted to standard', $slug ),
 
1110
  'body' => ''
1111
  );
1112
- else
1113
  return array(
1114
- 'message' => sprintf( 'View "%1$s" deleted', $slug ),
 
1115
  'body' => ''
1116
  );
 
1117
  }
1118
 
1119
  return array(
1120
- 'message' => sprintf( 'ERROR: Did not find view "%1$s"', $slug ),
 
1121
  'body' => ''
1122
  );
1123
  }
@@ -1139,7 +1214,8 @@ class MLAMime {
1139
  * sanitize or validate them.
1140
  */
1141
  if ( ! is_array( $raw_request ) ) {
1142
- error_log( 'ERROR: _prepare_upload_items_query $raw_request = ' . var_export( $raw_request, true ), 0 );
 
1143
  return NULL;
1144
  }
1145
 
@@ -1156,9 +1232,9 @@ class MLAMime {
1156
  $clean_request[ $key ] = $value;
1157
  break;
1158
  case 'orderby':
1159
- if ( 'none' == $value )
1160
  $clean_request[ $key ] = $value;
1161
- else {
1162
  $sortable_columns = MLA_Upload_List_Table::mla_get_sortable_columns();
1163
  foreach ($sortable_columns as $sort_key => $sort_value ) {
1164
  if ( $value == $sort_value[0] ) {
@@ -1210,8 +1286,9 @@ class MLAMime {
1210
  * @return array query results; array of MLA Upload MIME Type objects
1211
  */
1212
  private static function _execute_upload_items_query( $request ) {
1213
- if ( ! self::_get_upload_mime_templates() )
1214
  return array ();
 
1215
 
1216
  /*
1217
  * Sort and filter the list
@@ -1231,12 +1308,13 @@ class MLAMime {
1231
  $found |= false !== stripos( $value['mla_type'], $keyword );
1232
  $found |= false !== stripos( $value['core_icon_type'], $keyword );
1233
  $found |= false !== stripos( $value['description'], $keyword );
1234
- }
1235
- else
1236
  $found = false !== stripos( $slug, $extension );
 
1237
 
1238
- if ( ! $found )
1239
  continue;
 
1240
  }
1241
 
1242
  switch( $view ) {
@@ -1255,8 +1333,9 @@ class MLAMime {
1255
  $found = true;
1256
  }// $view
1257
 
1258
- if ( ! $found )
1259
  continue;
 
1260
 
1261
  $value['slug'] = $slug;
1262
  switch ( $request['orderby'] ) {
@@ -1297,8 +1376,9 @@ class MLAMime {
1297
  }
1298
  ksort( $sorted_types );
1299
 
1300
- if ( 'DESC' == $request['order'] )
1301
  $sorted_types = array_reverse( $sorted_types, true );
 
1302
 
1303
  /*
1304
  * Paginate the sorted list
@@ -1307,12 +1387,13 @@ class MLAMime {
1307
  $offset = isset( $request['offset'] ) ? $request['offset'] : 0;
1308
  $count = isset( $request['posts_per_page'] ) ? $request['posts_per_page'] : -1;
1309
  foreach ( $sorted_types as $value ) {
1310
- if ( $offset )
1311
  $offset--;
1312
- elseif ( $count-- )
1313
  $results[] = $value;
1314
- else
1315
  break;
 
1316
  }
1317
 
1318
  return $results;
@@ -1360,20 +1441,39 @@ class MLAMime {
1360
  * @return array ( 'singular' label, 'plural' label, 'count' of items )
1361
  */
1362
  public static function mla_tabulate_upload_items( $s = '' ) {
1363
- if ( empty( $s ) )
1364
  $request = array( 'mla_upload_view' => 'all' );
1365
- else
1366
  $request = array( 's' => $s );
1367
-
 
1368
  $items = self::mla_query_upload_items( $request, 0, 0 );
1369
 
1370
  $upload_items = array(
1371
- 'all' => array( 'singular' => 'All', 'plural' => 'All', 'count' => 0 ),
1372
- 'active' => array( 'singular' => 'Active', 'plural' => 'Active', 'count' => 0 ),
1373
- 'inactive' => array( 'singular' => 'Inactive', 'plural' => 'Inactive', 'count' => 0 ),
1374
- 'core' => array( 'singular' => 'WordPress', 'plural' => 'WordPress', 'count' => 0 ),
1375
- 'mla' => array( 'singular' => 'MLA', 'plural' => 'MLA', 'count' => 0 ),
1376
- 'custom' => array( 'singular' => 'Custom', 'plural' => 'Custom', 'count' => 0 ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1377
  );
1378
 
1379
  foreach ( $items as $value ) {
@@ -1381,7 +1481,7 @@ class MLAMime {
1381
  $value->disabled ? $upload_items['inactive']['count']++ : $upload_items['active']['count']++;
1382
  $upload_items[ $value->source ]['count']++;
1383
  }
1384
-
1385
  return $upload_items;
1386
  }
1387
 
@@ -1393,7 +1493,7 @@ class MLAMime {
1393
  * @var array extension => ( core_icon_type )
1394
  */
1395
  private static $mla_core_icon_types = NULL;
1396
-
1397
  /**
1398
  * Icon types with MLA filtering - basenames of files in the current icon directory
1399
  *
@@ -1402,7 +1502,7 @@ class MLAMime {
1402
  * @var array ( icon_type => icon_image_uri )
1403
  */
1404
  private static $mla_current_icon_types = NULL;
1405
-
1406
  /**
1407
  * In-memory representation of the Upload MIME Types
1408
  *
@@ -1411,7 +1511,7 @@ class MLAMime {
1411
  * @var array extension => ( post_ID, mime_type, core_type, mla_type, source, standard_source, disabled, description, icon_type, wp_icon_type, mla_icon_type, core_icon_type )
1412
  */
1413
  private static $mla_upload_mime_templates = NULL;
1414
-
1415
  /**
1416
  * Highest existing Upload MIME Type ID value
1417
  *
@@ -1420,7 +1520,7 @@ class MLAMime {
1420
  * @var integer
1421
  */
1422
  private static $mla_upload_mime_highest_ID = 0;
1423
-
1424
  /**
1425
  * Assemble the list of icon types without MLA filtering
1426
  *
@@ -1430,10 +1530,11 @@ class MLAMime {
1430
  */
1431
  private static function _get_core_icon_types() {
1432
  global $wp_filter;
1433
-
1434
- if ( NULL != self::$mla_core_icon_types )
1435
  return true;
1436
-
 
1437
  /*
1438
  * wp_ext2type will apply our filter in a special mode, initializing the list
1439
  */
@@ -1457,7 +1558,7 @@ class MLAMime {
1457
  self::$mla_core_icon_types = $standard_types;
1458
  return true;
1459
  }
1460
-
1461
  /**
1462
  * Assemble the list of icon types with MLA filtering
1463
  *
@@ -1466,8 +1567,9 @@ class MLAMime {
1466
  * @return boolean Success (true) or failure (false) of the operation
1467
  */
1468
  private static function _get_current_icon_types() {
1469
- if ( NULL != self::$mla_current_icon_types )
1470
  return true;
 
1471
 
1472
  /*
1473
  * Get the directories in reverse order, so earlier entries will overwrite later entries and win
@@ -1481,26 +1583,33 @@ class MLAMime {
1481
  $keys = array_keys( $dirs );
1482
  $dir = array_shift( $keys );
1483
  $uri = array_shift( $dirs );
 
1484
  if ( $dh = opendir($dir) ) {
1485
  while ( false !== $file = readdir($dh) ) {
1486
  $file = basename($file);
1487
- if ( substr($file, 0, 1) == '.' )
1488
  continue;
 
 
1489
  if ( !in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg') ) ) {
1490
- if ( is_dir("$dir/$file") )
1491
  $dirs["$dir/$file"] = "$uri/$file";
 
 
1492
  continue;
1493
  }
 
1494
  $name = substr( $file, 0, -4);
1495
  self::$mla_current_icon_types[ $name ] = "$uri/$file";
1496
  }
 
1497
  closedir($dh);
1498
  }
1499
  }
1500
 
1501
  return true;
1502
  }
1503
-
1504
  /**
1505
  * Retrieve a standard icon type, i.e., without MLA filtering
1506
  *
@@ -1511,9 +1620,11 @@ class MLAMime {
1511
  * @return string icon type for the requested extension; 'default' if extension not found
1512
  */
1513
  public static function mla_get_core_icon_type( $extension ) {
1514
- if ( self::_get_core_icon_types() )
1515
- if ( isset( self::$mla_core_icon_types[ $extension ] ) )
1516
  return self::$mla_core_icon_types[ $extension ];
 
 
1517
 
1518
  return 'default';
1519
  }
@@ -1534,16 +1645,16 @@ class MLAMime {
1534
  if (is_array( $size ) ) {
1535
  $width = $size[0];
1536
  $height = $size[1];
1537
- }
1538
- else
1539
  @list($width, $height) = getimagesize($icon_file);
 
1540
 
1541
  $hwstring = image_hwstring($width, $height);
1542
  $size = $width . 'x' . $height;
1543
  $default_attr = array(
1544
  'src' => $icon_file,
1545
  'class' => "attachment-$size",
1546
- 'alt' => $icon_type . ' icon'
1547
  );
1548
 
1549
  $attr = array_map( 'esc_attr', $default_attr );
@@ -1552,7 +1663,7 @@ class MLAMime {
1552
  $html .= " $name=" . '"' . $value . '"';
1553
  }
1554
  $html .= ' />';
1555
-
1556
  return $html;
1557
  }
1558
 
@@ -1564,8 +1675,9 @@ class MLAMime {
1564
  * @return array ( icon_type ) or false on failure.
1565
  */
1566
  public static function mla_get_current_icon_types() {
1567
- if ( self::_get_current_icon_types() )
1568
  return array_keys( self::$mla_current_icon_types );
 
1569
 
1570
  return false;
1571
  }
@@ -1581,10 +1693,11 @@ class MLAMime {
1581
  private static function _get_upload_mime_templates( $force_refresh = false ) {
1582
  self::_get_core_icon_types();
1583
  self::_get_current_icon_types();
1584
-
1585
- if ( false == $force_refresh && NULL != self::$mla_upload_mime_templates )
1586
  return true;
1587
-
 
1588
  /*
1589
  * Find the WordPress-standard (unfiltered) extensions
1590
  * WordPress 3.4.x and earlier do not implement wp_get_mime_types
@@ -1596,19 +1709,18 @@ class MLAMime {
1596
  unset( $wp_filter['mime_types'] );
1597
  $core_types = wp_get_mime_types();
1598
  $wp_filter['mime_types'] = $save_filters;
1599
- }
1600
- else
1601
  $core_types = wp_get_mime_types();
1602
- }
1603
- else {
1604
  if ( isset( $wp_filter['upload_mimes'] ) ) {
1605
  $save_filters = $wp_filter['upload_mimes'];
1606
  unset( $wp_filter['upload_mimes'] );
1607
  $core_types = get_allowed_mime_types();
1608
  $wp_filter['upload_mimes'] = $save_filters;
1609
- }
1610
- else
1611
  $core_types = get_allowed_mime_types();
 
1612
  }
1613
 
1614
  /*
@@ -1620,14 +1732,16 @@ class MLAMime {
1620
  if ( is_array( $mla_upload_mimes ) ) {
1621
  $first_time_called = false;
1622
  $custom_types = $mla_upload_mimes['custom'];
1623
- }
1624
- else {
1625
  $first_time_called = true;
1626
  $mla_upload_mimes = array ( 'custom' => array(), 'disabled' => array(), 'description' => array(), 'icon_type' => array() );
1627
  self::$disable_mla_filtering = true;
1628
- foreach ( get_allowed_mime_types() as $key => $value )
1629
- if ( ! isset( $core_types[ $key ]) )
1630
  $custom_types[ $key ] = $value;
 
 
 
1631
  self::$disable_mla_filtering = false;
1632
  }
1633
 
@@ -1656,7 +1770,7 @@ class MLAMime {
1656
  /*
1657
  * Start with the MLA extensions, initialized to an inactive state
1658
  */
1659
- $template_array = MLAData::mla_load_template( MLA_PLUGIN_PATH . 'tpls/mla-default-mime-types.tpl' );
1660
  if ( isset( $template_array['mla-mime-types'] ) ) {
1661
  $mla_mime_types = preg_split('/[\r\n]+/', $template_array['mla-mime-types'] );
1662
  foreach ( $mla_mime_types as $mla_type ) {
@@ -1677,8 +1791,9 @@ class MLAMime {
1677
  'core_icon_type' => self::mla_get_core_icon_type( $array[0] )
1678
  );
1679
 
1680
- if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) )
1681
  self::$mla_upload_mime_templates[ $key ]['icon_type'] = self::$mla_upload_mime_templates[ $array[0] ]['mla_icon_type'];
 
1682
  }
1683
  }
1684
 
@@ -1695,20 +1810,20 @@ class MLAMime {
1695
  $wp_icon_type = self::$mla_upload_mime_templates[ $key ]['wp_icon_type'];
1696
  $mla_icon_type = self::$mla_upload_mime_templates[ $key ]['mla_icon_type'];
1697
  $core_icon_type = self::$mla_upload_mime_templates[ $key ]['core_icon_type'];
1698
- }
1699
- else {
1700
  $post_ID = ++self::$mla_upload_mime_highest_ID;
1701
  $mla_type = '';
1702
  $description = '';
1703
-
1704
- if ( NULL == $icon_type = wp_ext2type( $key ) )
1705
  $icon_type = 'default';
1706
-
 
1707
  $wp_icon_type = $icon_type;
1708
  $mla_icon_type = $icon_type;
1709
  $core_icon_type = self::mla_get_core_icon_type( $key );
1710
  }
1711
-
1712
 
1713
  self::$mla_upload_mime_templates[ $key ] = array(
1714
  'post_ID' => $post_ID,
@@ -1725,10 +1840,11 @@ class MLAMime {
1725
  'core_icon_type' => $core_icon_type
1726
  );
1727
 
1728
- if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) )
1729
  self::$mla_upload_mime_templates[ $array[0] ]['icon_type'] = self::$mla_upload_mime_templates[ $array[0] ]['mla_icon_type'];
 
1730
  }
1731
-
1732
  /*
1733
  * Add the user-defined custom types
1734
  */
@@ -1739,18 +1855,18 @@ class MLAMime {
1739
  /*
1740
  * Make sure it's really custom
1741
  */
1742
- if ( ( 'core' == $source && $value == $core_type ) ||
1743
- ( 'mla' == $source && $value == $mla_type ) )
1744
  continue;
1745
- } // existing type
1746
- else {
1747
  $core_type = '';
1748
  $mla_type = '';
1749
  $standard_source = '';
1750
  } // brand new type
1751
 
1752
- if ( NULL == $icon_type = wp_ext2type( $key ) )
1753
  $icon_type = 'default';
 
1754
 
1755
  self::$mla_upload_mime_templates[ $key ] = array(
1756
  'post_ID' => ++self::$mla_upload_mime_highest_ID,
@@ -1767,20 +1883,21 @@ class MLAMime {
1767
  'core_icon_type' => self::mla_get_core_icon_type( $key )
1768
  );
1769
  }
1770
-
1771
  if ( $first_time_called ) {
1772
  self::_put_upload_mime_templates();
1773
  return true;
1774
  }
1775
-
1776
  /*
1777
  * Apply the current settings, if any
1778
  */
1779
  foreach ( self::$mla_upload_mime_templates as $key => $value ) {
1780
  self::$mla_upload_mime_templates[ $key ]['disabled'] = isset( $mla_upload_mimes['disabled'][ $key ] );
1781
  self::$mla_upload_mime_templates[ $key ]['description'] = isset( $mla_upload_mimes['description'][ $key ] ) ? $mla_upload_mimes['description'][ $key ] : '';
1782
- if ( isset( $mla_upload_mimes['icon_type'][ $key ] ) )
1783
  self::$mla_upload_mime_templates[ $key ]['icon_type'] = $mla_upload_mimes['icon_type'][ $key ];
 
1784
  }
1785
 
1786
  return true;
@@ -1797,20 +1914,24 @@ class MLAMime {
1797
  $mla_upload_mimes = array ( 'custom' => array(), 'disabled' => array(), 'description' => array(), 'icon_type' => array() );
1798
 
1799
  foreach ( self::$mla_upload_mime_templates as $key => $value ) {
1800
- if ( 'custom' == $value['source'] )
1801
  $mla_upload_mimes['custom'][ $key ] = $value['mime_type'];
 
1802
 
1803
- if ( $value['disabled'] )
1804
  $mla_upload_mimes['disabled'][ $key ] = true;
1805
-
 
1806
  $description = trim( $value['description'] );
1807
- if ( ! empty( $description ) )
1808
  $mla_upload_mimes['description'][ $key ] = $description;
1809
-
1810
- if ( $value['icon_type'] != $value['core_icon_type'] )
 
1811
  $mla_upload_mimes['icon_type'][ $key ] = $value['icon_type'];
 
1812
  }
1813
-
1814
  MLAOptions::mla_update_option( MLAOptions::MLA_UPLOAD_MIMES, $mla_upload_mimes );
1815
  return true;
1816
  }
@@ -1825,56 +1946,65 @@ class MLAMime {
1825
  * @return array Message(s) reflecting the results of the operation
1826
  */
1827
  public static function mla_add_upload_mime( $request ) {
1828
- if ( self::_get_upload_mime_templates() )
1829
  $errors = '';
1830
- else
1831
  return array(
1832
- 'message' => 'ERROR: Cannot load Upload MIME Types',
1833
  'body' => ''
1834
  );
1835
-
 
1836
  $messages = '';
1837
 
1838
  /*
1839
  * Sanitize slug value
1840
  */
1841
- if ( empty( $request['slug'] ) )
1842
- $errors .= '<br>ERROR: Extension is required';
1843
- else {
1844
  $slug = pathinfo( 'X.' . strtolower( trim( $request['slug'] ) ), PATHINFO_EXTENSION );
1845
- if ( $slug != $request['slug'] )
1846
- $messages .= sprintf( '<br>Changing extension "%1$s" to valid value "%2$s"', $request['slug'], $slug );
1847
-
 
 
1848
  /*
1849
  * Make sure new slug is unique
1850
  */
1851
- if ( isset( self::$mla_upload_mime_templates[ $slug ] ) )
1852
- $errors .= sprintf( '<br>ERROR: Could not add extension "%1$s"; value already exists', $slug );
 
 
1853
  }
1854
 
1855
  /*
1856
  * Validate mime_type
1857
  */
1858
- if ( empty( $request['mime_type'] ) )
1859
- $errors .= '<br>ERROR: MIME type is required';
1860
- else {
1861
  $clean_mime_type = sanitize_mime_type( $request['mime_type'] );
1862
- if ( $clean_mime_type != $request['mime_type'] )
1863
- $errors .= sprintf( '<br>ERROR: Bad MIME type; try "%1$s"', $clean_mime_type );
 
 
1864
  }
1865
 
1866
- if ( ! empty( $errors ) )
1867
  return array(
1868
  'message' => substr( $errors . $messages, 4),
1869
  'body' => ''
1870
  );
 
1871
 
1872
  if ( '.none.' == $request['icon_type'] ) {
1873
- if ( NULL == $icon_type = wp_ext2type( $slug ) )
1874
  $icon_type = 'default';
1875
- }
1876
- else
1877
  $icon_type = $request['icon_type'];
 
1878
 
1879
  $new_type = array();
1880
  $new_type['post_ID'] = ++self::$mla_upload_mime_highest_ID;
@@ -1891,14 +2021,16 @@ class MLAMime {
1891
  $new_type['core_icon_type'] = self::mla_get_core_icon_type( $slug );
1892
 
1893
  self::$mla_upload_mime_templates[ $slug ] = $new_type;
1894
- if ( self::_put_upload_mime_templates() )
1895
  return array(
1896
- 'message' => substr( $messages . sprintf( '<br>Upload MIME Type "%1$s"; added', $slug ), 4),
 
1897
  'body' => ''
1898
  );
 
1899
 
1900
  return array(
1901
- 'message' => 'ERROR: Cannot update Upload MIME Types',
1902
  'body' => ''
1903
  );
1904
  }
@@ -1913,22 +2045,23 @@ class MLAMime {
1913
  * @return array Message(s) reflecting the results of the operation
1914
  */
1915
  public static function mla_update_upload_mime( $request ) {
1916
- if ( self::_get_upload_mime_templates() )
1917
  $errors = '';
1918
- else
1919
  return array(
1920
- 'message' => 'ERROR: Cannot load Upload MIME Types',
1921
  'body' => ''
1922
  );
1923
-
 
1924
  $messages = '';
1925
  $slug = pathinfo( 'X.' . strtolower( trim( $request['slug'] ) ), PATHINFO_EXTENSION );
1926
  $original_slug = isset( $request['original_slug'] ) ? $request['original_slug'] : $slug;
1927
  unset( $request['original_slug'] );
1928
 
1929
- if ( isset( self::$mla_upload_mime_templates[ $original_slug ] ) )
1930
  $original_type = self::$mla_upload_mime_templates[ $original_slug ];
1931
- else
1932
  $original_type = array(
1933
  'post_ID' => 0,
1934
  'mime_type' => '',
@@ -1943,22 +2076,28 @@ class MLAMime {
1943
  'icon_type' => '',
1944
  'core_icon_type' => ''
1945
  );
 
1946
 
1947
  /*
1948
  * Validate changed slug value
1949
  */
1950
  if ( $slug != $original_slug ) {
1951
- if ( $slug != $request['slug'] )
1952
- $messages .= sprintf( '<br>Changing new extension "%1$s" to valid value "%2$s"', $request['slug'], $slug );
 
 
1953
 
1954
  /*
1955
  * Make sure new slug is unique
1956
  */
1957
- if ( isset( self::$mla_upload_mime_templates[ $slug ] ) )
1958
- $errors .= sprintf( '<br>ERROR: Could not add new extension "%1$s"; value already exists', $slug );
1959
- else
1960
- $messages .= sprintf( '<br>Changing extension from "%1$s" to "%2$s"', $original_slug, $slug );
1961
-
 
 
 
1962
  /*
1963
  * A new extension cannot have an $original_type
1964
  */
@@ -1981,39 +2120,44 @@ class MLAMime {
1981
  /*
1982
  * Validate mime_type
1983
  */
1984
- if ( empty( $request['mime_type'] ) )
1985
  $clean_mime_type = $original_type['mime_type'];
1986
- else {
1987
  $clean_mime_type = sanitize_mime_type( $request['mime_type'] );
1988
- if ( $clean_mime_type != $request['mime_type'] )
1989
- $errors .= sprintf( '<br>ERROR: Bad MIME type; try "%1$s"', $clean_mime_type );
 
 
1990
  }
1991
 
1992
- if ( ! empty( $errors ) )
1993
  return array(
1994
  'message' => substr( $errors . $messages, 4),
1995
  'body' => ''
1996
  );
 
1997
 
1998
  $new_type = array();
1999
- if( 0 == $original_type['post_ID'] )
2000
  $new_type['post_ID'] = ++self::$mla_upload_mime_highest_ID;
2001
- else
2002
  $new_type['post_ID'] = $original_type['post_ID'];
2003
-
 
2004
  $new_type['mime_type'] = $clean_mime_type;
2005
  $new_type['core_type'] = $original_type['core_type'];
2006
  $new_type['mla_type'] = $original_type['mla_type'];
2007
-
2008
  /*
2009
  * Determine the source
2010
  */
2011
- if ( 'core' == $original_type['standard_source'] && $clean_mime_type == $original_type['core_type'] )
2012
  $new_type['source'] = 'core';
2013
- elseif ( 'mla' == $original_type['standard_source'] && $clean_mime_type == $original_type['mla_type'] )
2014
  $new_type['source'] = 'mla';
2015
- else
2016
  $new_type['source'] = 'custom';
 
2017
 
2018
  /*
2019
  * Determine new icon types
@@ -2022,45 +2166,52 @@ class MLAMime {
2022
 
2023
  if ( isset( $request['icon_type'] ) ) {
2024
  $new_type['icon_type'] = '.none.' == $request['icon_type'] ? 'default' : $request['icon_type'];
2025
- }
2026
- elseif ( ! empty( $original_type['icon_type'] ) )
2027
  $new_type['icon_type'] = $original_type['icon_type'];
2028
- else
2029
  $new_type['icon_type'] = $new_type['core_icon_type'];
 
2030
 
2031
- if ( ! empty( $original_type['wp_icon_type'] ) )
2032
  $new_type['wp_icon_type'] = $original_type['wp_icon_type'];
2033
- else
2034
  $new_type['wp_icon_type'] = $new_type['icon_type'];
 
2035
 
2036
- if ( ! empty( $original_type['mla_icon_type'] ) )
2037
  $new_type['mla_icon_type'] = $original_type['mla_icon_type'];
2038
- else
2039
  $new_type['mla_icon_type'] = $new_type['icon_type'];
 
2040
 
2041
  $new_type['standard_source'] = $original_type['standard_source'];
2042
  $new_type['disabled'] = isset( $request['disabled'] ) ? $request['disabled'] : $original_type['disabled'];
2043
  $new_type['description'] = isset( $request['description'] ) ? sanitize_text_field( $request['description'] ) : $original_type['description'];
2044
 
2045
- if ( ( $slug == $original_slug ) && ( self::$mla_upload_mime_templates[ $slug ] == $new_type ) )
2046
  return array(
2047
- 'message' => substr( $messages . sprintf( '<br>Edit type "%1$s"; no changes detected', $slug ), 4),
 
2048
  'body' => ''
2049
  );
 
2050
 
2051
  self::$mla_upload_mime_templates[ $slug ] = $new_type;
2052
 
2053
- if ( $slug != $original_slug )
2054
  unset( self::$mla_upload_mime_templates[ $original_slug ] );
 
2055
 
2056
- if ( self::_put_upload_mime_templates() )
2057
  return array(
2058
- 'message' => substr( $messages . sprintf( '<br>Edit type "%1$s"; updated', $slug ), 4),
 
2059
  'body' => ''
2060
  );
 
2061
 
2062
  return array(
2063
- 'message' => 'ERROR: Cannot update Upload MIME Types',
2064
  'body' => ''
2065
  );
2066
  }
@@ -2075,10 +2226,13 @@ class MLAMime {
2075
  * @return mixed string with slug of the requested object; false if object not found
2076
  */
2077
  public static function mla_get_upload_mime_slug( $post_ID ) {
2078
- if ( self::_get_upload_mime_templates() )
2079
- foreach ( self::$mla_upload_mime_templates as $slug => $value )
2080
- if ( $post_ID == $value['post_ID'] )
2081
  return $slug;
 
 
 
2082
 
2083
  return false;
2084
  }
@@ -2093,12 +2247,13 @@ class MLAMime {
2093
  * @return mixed Array of elements, including slug, for the requested object; false if object not found
2094
  */
2095
  public static function mla_get_upload_mime( $slug ) {
2096
- if ( self::_get_upload_mime_templates() )
2097
  if ( isset( self::$mla_upload_mime_templates[ $slug ] ) ) {
2098
  $matched_value = self::$mla_upload_mime_templates[ $slug ];
2099
  $matched_value['slug'] = $slug;
2100
  return $matched_value;
2101
  }
 
2102
 
2103
  return false;
2104
  }
@@ -2113,33 +2268,38 @@ class MLAMime {
2113
  * @return array Message(s) reflecting the results of the operation
2114
  */
2115
  public static function mla_delete_upload_mime( $slug ) {
2116
- if ( self::_get_upload_mime_templates() )
2117
  if ( isset( self::$mla_upload_mime_templates[ $slug ] ) ) {
2118
  unset( self::$mla_upload_mime_templates[ $slug ] );
2119
-
2120
  if ( self::_put_upload_mime_templates() ) {
2121
  self::_get_upload_mime_templates( true );
2122
 
2123
- if ( isset( self::$mla_upload_mime_templates[ $slug ] ) )
2124
  return array(
2125
- 'message' => sprintf( 'Upload MIME Type "%1$s"; reverted to standard', $slug ),
 
2126
  'body' => ''
2127
  );
2128
- else
2129
  return array(
2130
- 'message' => sprintf( 'Upload MIME Type "%1$s"; deleted', $slug ),
 
2131
  'body' => ''
2132
  );
2133
- }
2134
- else
2135
  return array(
2136
- 'message' => 'ERROR: Cannot update Upload MIME Types',
2137
  'body' => ''
2138
  );
 
2139
  }
 
2140
 
2141
  return array(
2142
- 'message' => sprintf( 'ERROR: Did not find Upload type "%1$s"', $slug ),
 
2143
  'body' => ''
2144
  );
2145
  }
@@ -2152,7 +2312,7 @@ class MLAMime {
2152
  * @var array ( ID, slug, mime_type, core_type, mla_type, description )
2153
  */
2154
  private static $mla_optional_upload_mime_templates = NULL;
2155
-
2156
  /**
2157
  * Sanitize and expand Optional Upload MIME Type query arguments from request variables
2158
  *
@@ -2170,7 +2330,8 @@ class MLAMime {
2170
  * sanitize or validate them.
2171
  */
2172
  if ( ! is_array( $raw_request ) ) {
2173
- error_log( 'ERROR: _prepare_optional_upload_items_query $raw_request = ' . var_export( $raw_request, true ), 0 );
 
2174
  return NULL;
2175
  }
2176
 
@@ -2183,9 +2344,9 @@ class MLAMime {
2183
  foreach ( $raw_request as $key => $value ) {
2184
  switch ( $key ) {
2185
  case 'orderby':
2186
- if ( 'none' == $value )
2187
  $clean_request[ $key ] = $value;
2188
- else {
2189
  $sortable_columns = MLA_Upload_Optional_List_Table::mla_get_sortable_columns();
2190
  foreach ($sortable_columns as $sort_key => $sort_value ) {
2191
  if ( $value == $sort_value[0] ) {
@@ -2237,8 +2398,9 @@ class MLAMime {
2237
  * @return array query results; array of MLA Optional Upload MIME Type objects
2238
  */
2239
  private static function _execute_optional_upload_items_query( $request ) {
2240
- if ( ! self::_get_optional_upload_mime_templates() )
2241
  return array ();
 
2242
 
2243
  /*
2244
  * Sort and filter the list
@@ -2253,12 +2415,13 @@ class MLAMime {
2253
  $found = false !== stripos( $value['slug'], $keyword );
2254
  $found |= false !== stripos( $value['mime_type'], $keyword );
2255
  $found |= false !== stripos( $value['description'], $keyword );
2256
- }
2257
- else
2258
  $found = false !== stripos( $value['slug'], $extension );
 
2259
 
2260
- if ( ! $found )
2261
  continue;
 
2262
  }
2263
 
2264
  switch ( $request['orderby'] ) {
@@ -2284,8 +2447,9 @@ class MLAMime {
2284
  }
2285
  ksort( $sorted_types );
2286
 
2287
- if ( 'DESC' == $request['order'] )
2288
  $sorted_types = array_reverse( $sorted_types, true );
 
2289
 
2290
  /*
2291
  * Paginate the sorted list
@@ -2294,12 +2458,13 @@ class MLAMime {
2294
  $offset = isset( $request['offset'] ) ? $request['offset'] : 0;
2295
  $count = isset( $request['posts_per_page'] ) ? $request['posts_per_page'] : -1;
2296
  foreach ( $sorted_types as $value ) {
2297
- if ( $offset )
2298
  $offset--;
2299
- elseif ( $count-- )
2300
  $results[] = $value;
2301
- else
2302
  break;
 
2303
  }
2304
 
2305
  return $results;
@@ -2345,11 +2510,12 @@ class MLAMime {
2345
  * @return boolean Success (true) or failure (false) of the operation
2346
  */
2347
  private static function _get_optional_upload_mime_templates() {
2348
- if ( NULL != self::$mla_optional_upload_mime_templates )
2349
  return true;
 
2350
 
2351
  self::$mla_optional_upload_mime_templates = array ();
2352
- $template_array = MLAData::mla_load_template( MLA_PLUGIN_PATH . 'tpls/mla-default-mime-types.tpl' );
2353
  if ( isset( $template_array['mla-optional-mime-types'] ) ) {
2354
  $mla_mime_types = preg_split('/[\r\n]+/', $template_array['mla-optional-mime-types'] );
2355
 
@@ -2360,8 +2526,7 @@ class MLAMime {
2360
  if ( $matched_type = self::mla_get_upload_mime( $slug ) ) {
2361
  $core_type = $matched_type['core_type'];
2362
  $mla_type = $matched_type['mla_type'];
2363
- }
2364
- else {
2365
  $core_type = '';
2366
  $mla_type = '';
2367
  }
@@ -2390,9 +2555,11 @@ class MLAMime {
2390
  * @return mixed the requested object; false if object not found
2391
  */
2392
  public static function mla_get_optional_upload_mime( $ID ) {
2393
- if ( self::_get_optional_upload_mime_templates() )
2394
- if ( isset( self::$mla_optional_upload_mime_templates[ $ID ] ) )
2395
  return self::$mla_optional_upload_mime_templates[ $ID ];
 
 
2396
 
2397
  return false;
2398
  }
27
  // add_filter( 'wp_check_filetype_and_ext', 'MLAMime::mla_wp_check_filetype_and_ext_filter', 0x7FFFFFFF, 4 );
28
 
29
  if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_UPLOAD_MIMES ) ) {
30
+ if ( function_exists('wp_get_mime_types') ) {
31
  add_filter( 'mime_types', 'MLAMime::mla_mime_types_filter', 0x7FFFFFFF, 1 );
32
+ }
33
+
34
+ add_filter( 'upload_mimes', 'MLAMime::mla_upload_mimes_filter', 0x7FFFFFFF, 2 );
35
  }
36
 
37
+ if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_POST_MIME_TYPES ) ) {
38
  add_filter( 'post_mime_types', 'MLAMime::mla_post_mime_types_filter', 0x7FFFFFFF, 1 );
39
+ }
40
 
41
  add_filter( 'icon_dir', 'MLAMime::mla_icon_dir_filter', 0x7FFFFFFF, 1 );
42
  add_filter( 'icon_dir_uri', 'MLAMime::mla_icon_dir_uri_filter', 0x7FFFFFFF, 1 );
52
  * @var boolean
53
  */
54
  private static $disable_mla_filtering = false;
55
+
56
  /**
57
  * Sanitize a MIME type
58
  *
112
  return $standard_types;
113
  }
114
 
115
+ if ( NULL != self::$mla_icon_type_associations ) {
116
  return self::$mla_icon_type_associations;
117
+ }
118
 
119
+ if ( ! self::_get_upload_mime_templates() ) {
120
  return $standard_types;
121
+ }
122
+
123
  /*
124
  * Build and sort the type => extensions list
125
  */
126
  $items = self::mla_query_upload_items( array( 'mla_upload_view' => 'active' ), 0, 0 );
127
  $pairs = array();
128
  foreach ( $items as $value )
129
+ if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) ) {
130
  $pairs[ $value->slug ] = $value->icon_type;
131
+ } else {
132
  $pairs[ $value->slug ] = $value->wp_icon_type;
133
+ }
134
+
135
  asort( $pairs );
136
+
137
  /*
138
  * Compress the list, grouping by icon_type
139
  */
145
  self::$mla_icon_type_associations[ $icon_type ] = $extensions;
146
  $extensions = array( $this_extension );
147
  $icon_type = $this_type;
148
+ } else {
 
149
  $extensions[] = $this_extension;
150
+ }
151
  }
152
 
153
  self::$mla_icon_type_associations[ $icon_type ] = $extensions;
199
  */
200
  public static function mla_mime_types_filter( $mime_types ) {
201
  global $wp_filter;
202
+
203
+ if ( self::$disable_mla_filtering || ! self::_get_upload_mime_templates() ) {
204
  return $mime_types;
205
+ }
206
+
207
  /*
208
  * Build and sort the extension => type list
209
  */
211
  $pairs = array();
212
  foreach ( $items as $value )
213
  $pairs[ $value->slug ] = $value->mime_type;
214
+
215
  asort( $pairs );
216
+
217
  /*
218
  * Compress the list, grouping my mime_type
219
  */
225
  $items[ $extensions ] = $mime_type;
226
  $extensions = $this_extension;
227
  $mime_type = $this_type;
228
+ } else {
 
229
  $extensions .= '|' . $this_extension;
230
+ }
231
  }
232
 
233
  $items[ $extensions ] = $mime_type;
234
  unset( $items['.bad.value.'] );
235
+
236
  return $items; // $mime_types;
237
  } // mla_mime_types_filter
238
 
254
  * @since 1.40
255
  *
256
  * @param array Mime types keyed by the file extension regex corresponding to those types
257
+ * @param mixed User ID (integer) or object for checking against 'unfiltered_html' capability
258
  *
259
  * @return array Updated allowed MIME types
260
  */
261
+ public static function mla_upload_mimes_filter( $mime_types, $user ) {
262
  global $wp_filter;
263
+
264
+ if ( self::$disable_mla_filtering || ! self::_get_upload_mime_templates() ) {
265
  return $mime_types;
266
+ }
267
+
268
  /*
269
  * Build and sort the extension => type list
270
  */
272
  $pairs = array();
273
  foreach ( $items as $value )
274
  $pairs[ $value->slug ] = $value->mime_type;
275
+
276
  asort( $pairs );
277
+
278
  /*
279
  * Compress the list, grouping by mime_type
280
  */
286
  $items[ $extensions ] = $mime_type;
287
  $extensions = $this_extension;
288
  $mime_type = $this_type;
289
+ } else {
 
290
  $extensions .= '|' . $this_extension;
291
+ }
292
  }
293
 
294
  $items[ $extensions ] = $mime_type;
295
  unset( $items['.bad.value.'] );
296
+
297
+ /*
298
+ * Respect the WordPress per-user 'unfiltered_html' capability test
299
+ */
300
+ if ( function_exists( 'current_user_can' ) ) {
301
+ $unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' );
302
+ } else {
303
+ $unfiltered = true;
304
+ }
305
 
306
+ if ( empty( $unfiltered ) ) {
307
+ unset( $items['htm|html'] );
308
+ unset( $items['htm'] );
309
+ unset( $items['html'] );
310
+ }
311
+
312
+ return $items;
313
  } // mla_upload_mimes_filter
314
 
315
  /**
329
  * @since 1.40
330
  *
331
  * @param array Content types (image, audio, video) and presentation strings, e.g.
332
+ * 'image' => array(__('Images', 'media-library-assistant'), __('Manage Images', 'media-library-assistant'),
333
+ * _n_noop('Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>', 'media-library-assistant')),
334
  *
335
  * @return array Updated allowed MIME types
336
  */
337
  public static function mla_post_mime_types_filter( $post_mime_types ) {
338
  global $wp_filter;
339
 
340
+ if ( self::$disable_mla_filtering || ! self::_get_post_mime_templates() ) {
341
  return $post_mime_types;
342
+ }
343
+
344
  /*
345
  * Filter the list and sort by menu_order
346
  */
355
 
356
  /*
357
  * Generate the merged, sorted list
358
+ *
359
+ * The 'singular' and 'plural' strings are already translated. The _n_noop() call
360
+ * will not actually translate anything since the $singular and $plural variables
361
+ * are ignored by Poedit and there will be no "msgid" strings that contain the
362
+ * HTML markup within them.
363
  */
364
+ $manage = _x( 'Manage', 'post_mime_types', 'media-library-assistant' ) . ' ';
365
  $new_mime_types = array();
366
  foreach ( $sorted_types as $value ) {
367
  $singular = sprintf('%s <span class="count">(%%s)</span>', $value['singular'] );
368
  $plural = sprintf('%s <span class="count">(%%s)</span>', $value['plural'] );
369
  $new_mime_types[ $value['slug'] ] = array(
370
+ $value['plural'],
371
+ $manage . $value['plural'],
372
+ _n_noop( $singular, $plural, 'media-library-assistant' )
373
  );
374
  }
375
 
393
  public static function mla_icon_dir_filter( $path ) {
394
  global $wp_filter;
395
 
396
+ if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) ) {
397
  return MLA_PLUGIN_PATH . 'images/crystal';
398
+ }
399
 
400
  return $path;
401
  } // mla_icon_dir_filter
415
  public static function mla_icon_dir_uri_filter( $uri ) {
416
  global $wp_filter;
417
 
418
+ if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) ) {
419
  return MLA_PLUGIN_URL . 'images/crystal';
420
+ }
421
+
422
  return $uri;
423
  } // mla_icon_dir_uri_filter
424
 
436
  */
437
  public static function mla_icon_dirs_filter( $path_uri_array ) {
438
  global $wp_filter;
439
+
440
+ if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) ) {
441
  $path_uri_array [ MLA_PLUGIN_PATH . 'images/crystal' ] = MLA_PLUGIN_URL . 'images/crystal';
442
+ }
443
+
444
  return $path_uri_array;
445
  } // mla_icon_dirs_filter
446
 
479
  * sanitize or validate them.
480
  */
481
  if ( ! is_array( $raw_request ) ) {
482
+ /* translators: 1: function name 2: non-array value */
483
+ error_log( sprintf( _x( 'ERROR: %1$s non-array "%2$s"', 'error_log', 'media-library-assistant' ), 'MLAMime::_prepare_view_items_query', var_export( $raw_request, true ) ), 0 );
484
  return NULL;
485
  }
486
 
493
  foreach ( $raw_request as $key => $value ) {
494
  switch ( $key ) {
495
  case 'orderby':
496
+ if ( 'none' == $value ) {
497
  $clean_request[ $key ] = $value;
498
+ } else {
499
  $sortable_columns = MLA_View_List_Table::mla_get_sortable_columns();
500
  foreach ($sortable_columns as $sort_key => $sort_value ) {
501
  if ( $value == $sort_value[0] ) {
547
  * @return array query results; array of MLA post_mime_type objects
548
  */
549
  private static function _execute_view_items_query( $request ) {
550
+ if ( ! self::_get_post_mime_templates() ) {
551
  return array ();
552
+ }
553
 
554
  /*
555
  * Sort and filter the list
567
  $found |= false !== stripos( $value['plural'], $keyword );
568
  $found |= false !== stripos( $value['description'], $keyword );
569
 
570
+ if ( ! $found ) {
571
  continue;
572
+ }
573
  }
574
 
575
  $value['slug'] = $slug;
606
  }
607
  ksort( $sorted_types );
608
 
609
+ if ( 'DESC' == $request['order'] ) {
610
  $sorted_types = array_reverse( $sorted_types, true );
611
+ }
612
 
613
  /*
614
  * Paginate the sorted list
617
  $offset = isset( $request['offset'] ) ? $request['offset'] : 0;
618
  $count = isset( $request['posts_per_page'] ) ? $request['posts_per_page'] : -1;
619
  foreach ( $sorted_types as $value ) {
620
+ if ( $offset ) {
621
  $offset--;
622
+ } elseif ( $count-- ) {
623
  $results[] = $value;
624
+ } else {
625
  break;
626
+ }
627
  }
628
 
629
  return $results;
670
  */
671
  public static function mla_pluck_table_views() {
672
  $mla_types = MLAMime::mla_query_view_items( array( 'orderby' => 'menu_order' ), 0, 0 );
673
+ if ( ! is_array( $mla_types ) ) {
674
  $mla_types = array ();
675
+ }
676
+
677
  /*
678
  * Filter the list, generate the list
679
  */
680
  $results = array();
681
  foreach ( $mla_types as $value ) {
682
+ if ( in_array( $value->slug, array( 'all', 'trash', 'unattached' ) ) ) {
683
  continue;
684
+ }
685
+
686
  if ( $value->table_view ) {
687
+ if ( empty( $value->specification ) ) {
688
  $results[ $value->slug ] = $value->plural;
689
+ } else {
690
  $results[ $value->specification ] = $value->plural;
691
+ }
692
  }
693
  }
694
 
712
  * @var integer
713
  */
714
  private static $mla_post_mime_highest_ID = 0;
715
+
716
  /**
717
  * Assemble the in-memory representation of the Post MIME Types
718
  *
723
  * @return boolean Success (true) or failure (false) of the operation
724
  */
725
  private static function _get_post_mime_templates( $force_refresh = false ) {
726
+ if ( false == $force_refresh && NULL != self::$mla_post_mime_templates ) {
727
  return true;
728
+ }
729
+
730
  /*
731
  * Start with MLA standard types
732
  */
733
  $mla_types = MLAOptions::mla_get_option( MLAOptions::MLA_POST_MIME_TYPES, true );
734
+ if ( ! is_array( $mla_types ) ) {
735
  $mla_types = array ();
736
+ }
737
 
738
  /*
739
  * If this is the first time MLA Post MIME support is invoked, match to the
741
  * Otherwise, add the current MLA custom types.
742
  */
743
  $custom_types = MLAOptions::mla_get_option( MLAOptions::MLA_POST_MIME_TYPES, false, true );
744
+
745
  if ( is_array( $custom_types ) ) {
746
  $mla_types = array_merge( $mla_types, $custom_types );
747
+ } else {
 
748
  /*
749
  * Add existing types that are not already in the MLA list
750
  */
751
  self::$disable_mla_filtering = true;
752
  $post_mime_types = get_post_mime_types();
753
  self::$disable_mla_filtering = false;
754
+
755
  foreach ( $post_mime_types as $slug => $value )
756
  if ( ! isset( $mla_types[ $slug ] ) ) {
757
  $mla_types[ $slug ] = array(
761
  'post_mime_type' => true,
762
  'table_view' => true,
763
  'menu_order' => 0,
764
+ 'description' => _x( 'Copied from previous filter/plugin', 'post_mime_types_description', 'media-library-assistant' )
765
  );
766
  } // new type
767
  } // First time called
795
 
796
  foreach ( self::$mla_post_mime_templates as $slug => $value ) {
797
  unset( $value['post_ID'] );
798
+ if ( isset ( $mla_types[ $slug ] ) && $value == $mla_types[ $slug ] ) {
799
  continue;
800
+ }
801
+
802
  $mla_post_mimes[ $slug ] = $value;
803
  }
804
+
805
  MLAOptions::mla_update_option( MLAOptions::MLA_POST_MIME_TYPES, $mla_post_mimes );
806
  return true;
807
  }
819
  public static function mla_prepare_view_query( $slug, $specification ) {
820
  $query = array ( );
821
  $specification = self::mla_parse_view_specification( $specification );
822
+ if ( 'mime' == $specification['prefix'] ) {
823
  $query['post_mime_type'] = $specification['value'];
824
+ } else {
825
  $meta_query = array( 'slug' => $slug , 'relation' => 'OR', 'patterns' => array () );
826
  switch( $specification['option'] ) {
827
  case 'match':
834
  */
835
  $meta_query['patterns'][] = $pattern;
836
  $meta_query[] = array( 'key' => $specification['name'], 'value' => $pattern, 'compare' => 'LIKE' );
837
+ } else {
 
838
  $meta_query[] = array( 'key' => $specification['name'], 'value' => $pattern, 'compare' => '=' );
839
+ }
840
  } // foreach pattern
841
+
842
+ if ( empty( $meta_query['patterns'] ) ) {
843
  unset( $meta_query['patterns'] );
844
+ }
845
+
846
  break;
847
  case 'null':
848
  $meta_query['key'] = $specification['name'];
851
  default: // '', 'any'
852
  $meta_query[] = array( 'key' => $specification['name'], 'value' => NULL, 'compare' => '!=' );
853
  }
854
+
855
  $query['meta_query'] = $meta_query;
856
  } // custom field specification
857
+
858
  return $query;
859
  }
860
 
873
  if ( 1 == $match_count ) {
874
  $result['prefix'] = trim( strtolower( $matches[1] ) );
875
  $tail = $matches[2];
876
+
877
  $match_count = preg_match( '/([^,=]+)((,|=)(.+))$/', $tail, $matches );
878
  if ( 1 == $match_count ) {
879
  $result['name'] = $matches[1];
880
+
881
+ if ( ',' == $matches[3] ) {
882
  $result['option'] = trim( strtolower( $matches[4] ));
883
+ } else {
884
  $result['option'] = 'match';
885
  $result['value'] = $matches[4];
886
  }
887
+ } else {
 
888
  $result['option'] = 'any';
889
  $result['name'] = $tail;
890
  }
891
+ } else {
 
892
  $result['prefix'] = 'mime';
893
  $result['value'] = $specification;
894
  }
901
  foreach ( (array) $mime_types as $raw_mime_type ) {
902
  $no_wildcards = str_replace( '*', 'X', $raw_mime_type );
903
  $clean_mime_type = sanitize_mime_type( $no_wildcards );
904
+ if ( $clean_mime_type != $no_wildcards ) {
905
+ /* translators: 1: raw_mime_type */
906
+ $result['error'] = '<br>' . sprintf( __( 'ERROR: Bad specification part "%1$s"', 'media-library-assistant' ), $raw_mime_type );
907
+ }
908
  } // foreach
909
+ } elseif ( 'custom' == $result['prefix'] ) {
910
+ if ( ! in_array( $result['option'], array( '', 'any', 'match', 'null' ) ) ) {
911
+ /* translators: 1: option, e.g., any, match, null */
912
+ $result['error'] = '<br>' . sprintf( __( 'ERROR: Bad specification option "%1$s"', 'media-library-assistant' ), $specification['option'] );
913
+ }
914
+ } else {
915
+ /* translators: 1: prefix, e.g., custom */
916
+ $result['error'] = '<br>' . sprintf( __( 'ERROR: Bad specification prefix "%1$s"', 'media-library-assistant' ), $specification['prefix'] );
917
  }
918
+
 
 
919
  return $result;
920
  }
921
+
922
  /**
923
  * Add an MLA post_mime_type object
924
  *
929
  * @return array Message(s) reflecting the results of the operation
930
  */
931
  public static function mla_add_post_mime_type( $request ) {
932
+ if ( ! self::_get_post_mime_templates() ) {
933
  self::$mla_post_mime_templates = array ();
934
+ }
935
 
936
  $messages = '';
937
  $errors = '';
944
 
945
  if ( !empty( $request['specification'] ) ) {
946
  $request['specification'] = '';
947
+ $messages .= '<br>' . __( 'Ignoring specification for Post MIME Type; using slug', 'media-library-assistant' );
948
  }
949
  }
950
 
951
+ if ( $slug != $request['slug'] ) {
952
+ /* translators: 1: element name 2: bad_value 3: good_value */
953
+ $messages .= sprintf( __( '<br>' . 'Changing %1$s "%2$s" to valid value "%3$s"', 'media-library-assistant' ), __( 'Slug', 'media-library-assistant' ), $request['slug'], $slug );
954
+ }
955
 
956
  /*
957
  * Make sure new slug is unique
958
  */
959
+ if ( isset( self::$mla_post_mime_templates[ $slug ] ) ) {
960
+ /* translators: 1: slug */
961
+ $errors .= '<br>' . sprintf( __( 'ERROR: Could not add Slug "%1$s"; value already exists', 'media-library-assistant' ), $slug );
962
+ }
963
 
964
  /*
965
  * Validate specification, if present
966
  */
967
  if ( !empty( $request['specification'] ) ) {
968
  $specification = self::mla_parse_view_specification( $request['specification'] );
969
+ if ( isset( $specification['error'] ) ) {
970
  $errors .= $specification['error'];
971
+ }
972
  }
973
 
974
+ if ( ! empty( $errors ) ) {
975
  return array(
976
  'message' => substr( $errors . $messages, 4),
977
  'body' => ''
978
  );
979
+ }
980
 
981
  $new_type = array();
982
  $new_type['singular'] = sanitize_text_field( $request['singular'] );
992
  self::_put_post_mime_templates();
993
 
994
  return array(
995
+ /* translators: 1: slug */
996
+ 'message' => substr( $messages . '<br>' . sprintf( __( 'Edit view "%1$s"; added', 'media-library-assistant' ), $slug ), 4),
997
  'body' => ''
998
  );
999
  }
1008
  * @return array Message(s) reflecting the results of the operation
1009
  */
1010
  public static function mla_update_post_mime_type( $request ) {
1011
+ if ( ! self::_get_post_mime_templates() ) {
1012
  self::$mla_post_mime_templates = array ();
1013
+ }
1014
+
1015
  $messages = '';
1016
  $errors = '';
1017
  $slug = sanitize_mime_type( $request['slug'] );
1018
  $original_slug = isset( $request['original_slug'] ) ? $request['original_slug'] : $slug;
1019
  unset( $request['original_slug'] );
1020
 
1021
+ if ( isset( self::$mla_post_mime_templates[ $original_slug ] ) ) {
1022
  $original_type = self::$mla_post_mime_templates[ $original_slug ];
1023
+ } else {
1024
  $original_type = array(
1025
  'singular' => '',
1026
  'plural' => '',
1030
  'menu_order' => '',
1031
  'description' => ''
1032
  );
1033
+ }
1034
 
1035
  /*
1036
  * Validate changed slug value
1037
  */
1038
  if ( $slug != $original_slug ) {
1039
+ if ( $slug != $request['slug'] ) {
1040
+ /* translators: 1: element name 2: bad_value 3: good_value */
1041
+ $messages .= sprintf( __( '<br>' . 'Changing new %1$s "%2$s" to valid value "%3$s"', 'media-library-assistant' ), __( 'Slug', 'media-library-assistant' ), $request['slug'], $slug );
1042
+ }
1043
 
1044
  /*
1045
  * Make sure new slug is unique
1046
  */
1047
+ if ( isset( self::$mla_post_mime_templates[ $slug ] ) ) {
1048
+ /* translators: 1: slug */
1049
+ $errors .= '<br>' . sprintf( __( 'ERROR: Could not add new Slug "%1$s"; value already exists', 'media-library-assistant' ), $slug );
1050
+ } else {
1051
+ /* translators: 1: element name 2: old_value 3: new_value */
1052
+ $messages .= sprintf( '<br>' . __( 'Changing %1$s from "%2$s" to "%3$s"', 'media-library-assistant' ), __( 'Slug', 'media-library-assistant' ), $original_slug, $slug );
1053
+ }
1054
  }
1055
 
1056
  /*
1061
  if ( $post_mime_type ) {
1062
  if ( !empty( $specification ) ) {
1063
  $specification = '';
1064
+ $messages .= '<br>' . __( 'Ignoring specification for Post MIME Type; using slug', 'media-library-assistant' );
1065
  }
1066
  }
1067
 
1068
  if ( !empty( $specification ) ) {
1069
  $result = self::mla_parse_view_specification( $request['specification'] );
1070
+ if ( isset( $result['error'] ) ) {
1071
  $errors .= $result['error'];
1072
+ }
1073
  }
1074
 
1075
+ if ( ! empty( $errors ) ) {
1076
  return array(
1077
  'message' => substr( $errors . $messages, 4),
1078
  'body' => ''
1079
  );
1080
+ }
1081
 
1082
  $new_type = array();
1083
  $new_type['singular'] = isset( $request['singular'] ) ? sanitize_text_field( $request['singular'] ) : $original_type['singular'];
1088
  $new_type['menu_order'] = isset( $request['menu_order'] ) ? absint( $request['menu_order'] ) : $original_type['menu_order'];
1089
  $new_type['description'] = isset( $request['description'] ) ? sanitize_text_field( $request['description'] ) : $original_type['description'];
1090
 
1091
+ if ( ( $slug == $original_slug ) && ( self::$mla_post_mime_templates[ $slug ] == $new_type ) ) {
1092
  return array(
1093
+ /* translators: 1: slug */
1094
+ 'message' => substr( $messages . '<br>' . sprintf( __( 'Edit view "%1$s"; no changes detected', 'media-library-assistant' ), $slug ), 4),
1095
  'body' => ''
1096
  );
1097
+ }
1098
 
1099
  self::$mla_post_mime_templates[ $slug ] = $new_type;
1100
 
1101
+ if ( $slug != $original_slug ) {
1102
  unset( self::$mla_post_mime_templates[ $original_slug ] );
1103
+ }
1104
 
1105
  self::_put_post_mime_templates();
1106
  return array(
1107
+ /* translators: 1: slug */
1108
+ 'message' => $messages = substr( $messages . '<br>' . sprintf( __( 'Edit view "%1$s"; updated', 'media-library-assistant' ), $slug ), 4),
1109
  'body' => ''
1110
  );
1111
  }
1120
  * @return mixed string with slug of the requested object; false if object not found
1121
  */
1122
  public static function mla_get_post_mime_type_slug( $post_ID ) {
1123
+ if ( ! self::_get_post_mime_templates() ) {
1124
  self::$mla_post_mime_templates = array ();
1125
+ }
1126
 
1127
  foreach ( self::$mla_post_mime_templates as $slug => $value ) {
1128
+ if ( $post_ID == $value['post_ID'] ) {
1129
  return $slug;
1130
+ }
1131
  }
1132
 
1133
  return false;
1143
  * @return mixed Array of elements, including slug, for the requested object; false if object not found
1144
  */
1145
  public static function mla_get_post_mime_type( $slug ) {
1146
+ if ( ! self::_get_post_mime_templates() ) {
1147
  self::$mla_post_mime_templates = array ();
1148
+ }
1149
 
1150
  if ( isset( self::$mla_post_mime_templates[ $slug ] ) ) {
1151
  $matched_value = self::$mla_post_mime_templates[ $slug ];
1166
  * @return array Message(s) reflecting the results of the operation
1167
  */
1168
  public static function mla_delete_post_mime_type( $slug ) {
1169
+ if ( ! self::_get_post_mime_templates() ) {
1170
  self::$mla_post_mime_templates = array ();
1171
+ }
1172
 
1173
  if ( isset( self::$mla_post_mime_templates[ $slug ] ) ) {
1174
  unset( self::$mla_post_mime_templates[ $slug ] );
1175
  self::_put_post_mime_templates();
1176
  self::_get_post_mime_templates( true );
1177
 
1178
+ if ( isset( self::$mla_post_mime_templates[ $slug ] ) ) {
1179
  return array(
1180
+ /* translators: 1: slug */
1181
+ 'message' => sprintf( __( 'View "%1$s" reverted to standard', 'media-library-assistant' ), $slug ),
1182
  'body' => ''
1183
  );
1184
+ } else {
1185
  return array(
1186
+ /* translators: 1: slug */
1187
+ 'message' => sprintf( __( 'View "%1$s" deleted', 'media-library-assistant' ), $slug ),
1188
  'body' => ''
1189
  );
1190
+ }
1191
  }
1192
 
1193
  return array(
1194
+ /* translators: 1: slug */
1195
+ 'message' => sprintf( __( 'ERROR: Did not find view "%1$s"', 'media-library-assistant' ), $slug ),
1196
  'body' => ''
1197
  );
1198
  }
1214
  * sanitize or validate them.
1215
  */
1216
  if ( ! is_array( $raw_request ) ) {
1217
+ /* translators: 1: function name 2: non-array value */
1218
+ error_log( sprintf( _x( 'ERROR: %1$s non-array "%2$s"', 'error_log', 'media-library-assistant' ), 'MLAMime::_prepare_upload_items_query', var_export( $raw_request, true ) ), 0 );
1219
  return NULL;
1220
  }
1221
 
1232
  $clean_request[ $key ] = $value;
1233
  break;
1234
  case 'orderby':
1235
+ if ( 'none' == $value ) {
1236
  $clean_request[ $key ] = $value;
1237
+ } else {
1238
  $sortable_columns = MLA_Upload_List_Table::mla_get_sortable_columns();
1239
  foreach ($sortable_columns as $sort_key => $sort_value ) {
1240
  if ( $value == $sort_value[0] ) {
1286
  * @return array query results; array of MLA Upload MIME Type objects
1287
  */
1288
  private static function _execute_upload_items_query( $request ) {
1289
+ if ( ! self::_get_upload_mime_templates() ) {
1290
  return array ();
1291
+ }
1292
 
1293
  /*
1294
  * Sort and filter the list
1308
  $found |= false !== stripos( $value['mla_type'], $keyword );
1309
  $found |= false !== stripos( $value['core_icon_type'], $keyword );
1310
  $found |= false !== stripos( $value['description'], $keyword );
1311
+ } else {
 
1312
  $found = false !== stripos( $slug, $extension );
1313
+ }
1314
 
1315
+ if ( ! $found ) {
1316
  continue;
1317
+ }
1318
  }
1319
 
1320
  switch( $view ) {
1333
  $found = true;
1334
  }// $view
1335
 
1336
+ if ( ! $found ) {
1337
  continue;
1338
+ }
1339
 
1340
  $value['slug'] = $slug;
1341
  switch ( $request['orderby'] ) {
1376
  }
1377
  ksort( $sorted_types );
1378
 
1379
+ if ( 'DESC' == $request['order'] ) {
1380
  $sorted_types = array_reverse( $sorted_types, true );
1381
+ }
1382
 
1383
  /*
1384
  * Paginate the sorted list
1387
  $offset = isset( $request['offset'] ) ? $request['offset'] : 0;
1388
  $count = isset( $request['posts_per_page'] ) ? $request['posts_per_page'] : -1;
1389
  foreach ( $sorted_types as $value ) {
1390
+ if ( $offset ) {
1391
  $offset--;
1392
+ } elseif ( $count-- ) {
1393
  $results[] = $value;
1394
+ } else {
1395
  break;
1396
+ }
1397
  }
1398
 
1399
  return $results;
1441
  * @return array ( 'singular' label, 'plural' label, 'count' of items )
1442
  */
1443
  public static function mla_tabulate_upload_items( $s = '' ) {
1444
+ if ( empty( $s ) ) {
1445
  $request = array( 'mla_upload_view' => 'all' );
1446
+ } else {
1447
  $request = array( 's' => $s );
1448
+ }
1449
+
1450
  $items = self::mla_query_upload_items( $request, 0, 0 );
1451
 
1452
  $upload_items = array(
1453
+ 'all' => array(
1454
+ 'singular' => _x( 'All', 'upload_list_table_view_singular', 'media_library-assistant' ),
1455
+ 'plural' => _x( 'All', 'upload_list_table_view_plural', 'media_library-assistant' ),
1456
+ 'count' => 0 ),
1457
+ 'active' => array(
1458
+ 'singular' => _x( 'Active', 'upload_list_table_view_singular', 'media_library-assistant' ),
1459
+ 'plural' => _x( 'Active', 'upload_list_table_view_plural', 'media_library-assistant' ),
1460
+ 'count' => 0 ),
1461
+ 'inactive' => array(
1462
+ 'singular' => _x( 'Inactive', 'upload_list_table_view_singular', 'media_library-assistant' ),
1463
+ 'plural' => _x( 'Inactive', 'upload_list_table_view_plural', 'media_library-assistant' ),
1464
+ 'count' => 0 ),
1465
+ 'core' => array(
1466
+ 'singular' => _x( 'WordPress', 'upload_list_table_view_singular', 'media_library-assistant' ),
1467
+ 'plural' => _x( 'WordPress', 'upload_list_table_view_plural', 'media_library-assistant' ),
1468
+ 'count' => 0 ),
1469
+ 'mla' => array(
1470
+ 'singular' => _x( 'MLA', 'upload_list_table_view_singular', 'media_library-assistant' ),
1471
+ 'plural' => _x( 'MLA', 'upload_list_table_view_plural', 'media_library-assistant' ),
1472
+ 'count' => 0 ),
1473
+ 'custom' => array(
1474
+ 'singular' => _x( 'Custom', 'upload_list_table_view_singular', 'media_library-assistant' ),
1475
+ 'plural' => _x( 'Custom', 'upload_list_table_view_plural', 'media_library-assistant' ),
1476
+ 'count' => 0 ),
1477
  );
1478
 
1479
  foreach ( $items as $value ) {
1481
  $value->disabled ? $upload_items['inactive']['count']++ : $upload_items['active']['count']++;
1482
  $upload_items[ $value->source ]['count']++;
1483
  }
1484
+
1485
  return $upload_items;
1486
  }
1487
 
1493
  * @var array extension => ( core_icon_type )
1494
  */
1495
  private static $mla_core_icon_types = NULL;
1496
+
1497
  /**
1498
  * Icon types with MLA filtering - basenames of files in the current icon directory
1499
  *
1502
  * @var array ( icon_type => icon_image_uri )
1503
  */
1504
  private static $mla_current_icon_types = NULL;
1505
+
1506
  /**
1507
  * In-memory representation of the Upload MIME Types
1508
  *
1511
  * @var array extension => ( post_ID, mime_type, core_type, mla_type, source, standard_source, disabled, description, icon_type, wp_icon_type, mla_icon_type, core_icon_type )
1512
  */
1513
  private static $mla_upload_mime_templates = NULL;
1514
+
1515
  /**
1516
  * Highest existing Upload MIME Type ID value
1517
  *
1520
  * @var integer
1521
  */
1522
  private static $mla_upload_mime_highest_ID = 0;
1523
+
1524
  /**
1525
  * Assemble the list of icon types without MLA filtering
1526
  *
1530
  */
1531
  private static function _get_core_icon_types() {
1532
  global $wp_filter;
1533
+
1534
+ if ( NULL != self::$mla_core_icon_types ) {
1535
  return true;
1536
+ }
1537
+
1538
  /*
1539
  * wp_ext2type will apply our filter in a special mode, initializing the list
1540
  */
1558
  self::$mla_core_icon_types = $standard_types;
1559
  return true;
1560
  }
1561
+
1562
  /**
1563
  * Assemble the list of icon types with MLA filtering
1564
  *
1567
  * @return boolean Success (true) or failure (false) of the operation
1568
  */
1569
  private static function _get_current_icon_types() {
1570
+ if ( NULL != self::$mla_current_icon_types ) {
1571
  return true;
1572
+ }
1573
 
1574
  /*
1575
  * Get the directories in reverse order, so earlier entries will overwrite later entries and win
1583
  $keys = array_keys( $dirs );
1584
  $dir = array_shift( $keys );
1585
  $uri = array_shift( $dirs );
1586
+
1587
  if ( $dh = opendir($dir) ) {
1588
  while ( false !== $file = readdir($dh) ) {
1589
  $file = basename($file);
1590
+ if ( substr($file, 0, 1) == '.' ) {
1591
  continue;
1592
+ }
1593
+
1594
  if ( !in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg') ) ) {
1595
+ if ( is_dir("$dir/$file") ) {
1596
  $dirs["$dir/$file"] = "$uri/$file";
1597
+ }
1598
+
1599
  continue;
1600
  }
1601
+
1602
  $name = substr( $file, 0, -4);
1603
  self::$mla_current_icon_types[ $name ] = "$uri/$file";
1604
  }
1605
+
1606
  closedir($dh);
1607
  }
1608
  }
1609
 
1610
  return true;
1611
  }
1612
+
1613
  /**
1614
  * Retrieve a standard icon type, i.e., without MLA filtering
1615
  *
1620
  * @return string icon type for the requested extension; 'default' if extension not found
1621
  */
1622
  public static function mla_get_core_icon_type( $extension ) {
1623
+ if ( self::_get_core_icon_types() ) {
1624
+ if ( isset( self::$mla_core_icon_types[ $extension ] ) ) {
1625
  return self::$mla_core_icon_types[ $extension ];
1626
+ }
1627
+ }
1628
 
1629
  return 'default';
1630
  }
1645
  if (is_array( $size ) ) {
1646
  $width = $size[0];
1647
  $height = $size[1];
1648
+ } else {
 
1649
  @list($width, $height) = getimagesize($icon_file);
1650
+ }
1651
 
1652
  $hwstring = image_hwstring($width, $height);
1653
  $size = $width . 'x' . $height;
1654
  $default_attr = array(
1655
  'src' => $icon_file,
1656
  'class' => "attachment-$size",
1657
+ 'alt' => $icon_type . ' ' . __( 'icon', 'media-library-assistant' )
1658
  );
1659
 
1660
  $attr = array_map( 'esc_attr', $default_attr );
1663
  $html .= " $name=" . '"' . $value . '"';
1664
  }
1665
  $html .= ' />';
1666
+
1667
  return $html;
1668
  }
1669
 
1675
  * @return array ( icon_type ) or false on failure.
1676
  */
1677
  public static function mla_get_current_icon_types() {
1678
+ if ( self::_get_current_icon_types() ) {
1679
  return array_keys( self::$mla_current_icon_types );
1680
+ }
1681
 
1682
  return false;
1683
  }
1693
  private static function _get_upload_mime_templates( $force_refresh = false ) {
1694
  self::_get_core_icon_types();
1695
  self::_get_current_icon_types();
1696
+
1697
+ if ( false == $force_refresh && NULL != self::$mla_upload_mime_templates ) {
1698
  return true;
1699
+ }
1700
+
1701
  /*
1702
  * Find the WordPress-standard (unfiltered) extensions
1703
  * WordPress 3.4.x and earlier do not implement wp_get_mime_types
1709
  unset( $wp_filter['mime_types'] );
1710
  $core_types = wp_get_mime_types();
1711
  $wp_filter['mime_types'] = $save_filters;
1712
+ } else {
 
1713
  $core_types = wp_get_mime_types();
1714
+ }
1715
+ } else {
1716
  if ( isset( $wp_filter['upload_mimes'] ) ) {
1717
  $save_filters = $wp_filter['upload_mimes'];
1718
  unset( $wp_filter['upload_mimes'] );
1719
  $core_types = get_allowed_mime_types();
1720
  $wp_filter['upload_mimes'] = $save_filters;
1721
+ } else {
 
1722
  $core_types = get_allowed_mime_types();
1723
+ }
1724
  }
1725
 
1726
  /*
1732
  if ( is_array( $mla_upload_mimes ) ) {
1733
  $first_time_called = false;
1734
  $custom_types = $mla_upload_mimes['custom'];
1735
+ } else {
 
1736
  $first_time_called = true;
1737
  $mla_upload_mimes = array ( 'custom' => array(), 'disabled' => array(), 'description' => array(), 'icon_type' => array() );
1738
  self::$disable_mla_filtering = true;
1739
+ foreach ( get_allowed_mime_types() as $key => $value ) {
1740
+ if ( ! isset( $core_types[ $key ]) ) {
1741
  $custom_types[ $key ] = $value;
1742
+ }
1743
+ }
1744
+
1745
  self::$disable_mla_filtering = false;
1746
  }
1747
 
1770
  /*
1771
  * Start with the MLA extensions, initialized to an inactive state
1772
  */
1773
+ $template_array = MLAData::mla_load_template( 'mla-default-mime-types.tpl' );
1774
  if ( isset( $template_array['mla-mime-types'] ) ) {
1775
  $mla_mime_types = preg_split('/[\r\n]+/', $template_array['mla-mime-types'] );
1776
  foreach ( $mla_mime_types as $mla_type ) {
1791
  'core_icon_type' => self::mla_get_core_icon_type( $array[0] )
1792
  );
1793
 
1794
+ if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) ) {
1795
  self::$mla_upload_mime_templates[ $key ]['icon_type'] = self::$mla_upload_mime_templates[ $array[0] ]['mla_icon_type'];
1796
+ }
1797
  }
1798
  }
1799
 
1810
  $wp_icon_type = self::$mla_upload_mime_templates[ $key ]['wp_icon_type'];
1811
  $mla_icon_type = self::$mla_upload_mime_templates[ $key ]['mla_icon_type'];
1812
  $core_icon_type = self::$mla_upload_mime_templates[ $key ]['core_icon_type'];
1813
+ } else {
 
1814
  $post_ID = ++self::$mla_upload_mime_highest_ID;
1815
  $mla_type = '';
1816
  $description = '';
1817
+
1818
+ if ( NULL == $icon_type = wp_ext2type( $key ) ) {
1819
  $icon_type = 'default';
1820
+ }
1821
+
1822
  $wp_icon_type = $icon_type;
1823
  $mla_icon_type = $icon_type;
1824
  $core_icon_type = self::mla_get_core_icon_type( $key );
1825
  }
1826
+
1827
 
1828
  self::$mla_upload_mime_templates[ $key ] = array(
1829
  'post_ID' => $post_ID,
1840
  'core_icon_type' => $core_icon_type
1841
  );
1842
 
1843
+ if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) ) {
1844
  self::$mla_upload_mime_templates[ $array[0] ]['icon_type'] = self::$mla_upload_mime_templates[ $array[0] ]['mla_icon_type'];
1845
+ }
1846
  }
1847
+
1848
  /*
1849
  * Add the user-defined custom types
1850
  */
1855
  /*
1856
  * Make sure it's really custom
1857
  */
1858
+ if ( ( 'core' == $source && $value == $core_type ) || ( 'mla' == $source && $value == $mla_type ) ) {
 
1859
  continue;
1860
+ }
1861
+ } else { // existing type
1862
  $core_type = '';
1863
  $mla_type = '';
1864
  $standard_source = '';
1865
  } // brand new type
1866
 
1867
+ if ( NULL == $icon_type = wp_ext2type( $key ) ) {
1868
  $icon_type = 'default';
1869
+ }
1870
 
1871
  self::$mla_upload_mime_templates[ $key ] = array(
1872
  'post_ID' => ++self::$mla_upload_mime_highest_ID,
1883
  'core_icon_type' => self::mla_get_core_icon_type( $key )
1884
  );
1885
  }
1886
+
1887
  if ( $first_time_called ) {
1888
  self::_put_upload_mime_templates();
1889
  return true;
1890
  }
1891
+
1892
  /*
1893
  * Apply the current settings, if any
1894
  */
1895
  foreach ( self::$mla_upload_mime_templates as $key => $value ) {
1896
  self::$mla_upload_mime_templates[ $key ]['disabled'] = isset( $mla_upload_mimes['disabled'][ $key ] );
1897
  self::$mla_upload_mime_templates[ $key ]['description'] = isset( $mla_upload_mimes['description'][ $key ] ) ? $mla_upload_mimes['description'][ $key ] : '';
1898
+ if ( isset( $mla_upload_mimes['icon_type'][ $key ] ) ) {
1899
  self::$mla_upload_mime_templates[ $key ]['icon_type'] = $mla_upload_mimes['icon_type'][ $key ];
1900
+ }
1901
  }
1902
 
1903
  return true;
1914
  $mla_upload_mimes = array ( 'custom' => array(), 'disabled' => array(), 'description' => array(), 'icon_type' => array() );
1915
 
1916
  foreach ( self::$mla_upload_mime_templates as $key => $value ) {
1917
+ if ( 'custom' == $value['source'] ) {
1918
  $mla_upload_mimes['custom'][ $key ] = $value['mime_type'];
1919
+ }
1920
 
1921
+ if ( $value['disabled'] ) {
1922
  $mla_upload_mimes['disabled'][ $key ] = true;
1923
+ }
1924
+
1925
  $description = trim( $value['description'] );
1926
+ if ( ! empty( $description ) ) {
1927
  $mla_upload_mimes['description'][ $key ] = $description;
1928
+ }
1929
+
1930
+ if ( $value['icon_type'] != $value['core_icon_type'] ) {
1931
  $mla_upload_mimes['icon_type'][ $key ] = $value['icon_type'];
1932
+ }
1933
  }
1934
+
1935
  MLAOptions::mla_update_option( MLAOptions::MLA_UPLOAD_MIMES, $mla_upload_mimes );
1936
  return true;
1937
  }
1946
  * @return array Message(s) reflecting the results of the operation
1947
  */
1948
  public static function mla_add_upload_mime( $request ) {
1949
+ if ( self::_get_upload_mime_templates() ) {
1950
  $errors = '';
1951
+ } else {
1952
  return array(
1953
+ 'message' => __( 'ERROR: Cannot load Upload MIME Types', 'media-library-assistant' ),
1954
  'body' => ''
1955
  );
1956
+ }
1957
+
1958
  $messages = '';
1959
 
1960
  /*
1961
  * Sanitize slug value
1962
  */
1963
+ if ( empty( $request['slug'] ) ) {
1964
+ $errors .= '<br>' . __( 'ERROR: Extension is required', 'media-library-assistant' );
1965
+ } else {
1966
  $slug = pathinfo( 'X.' . strtolower( trim( $request['slug'] ) ), PATHINFO_EXTENSION );
1967
+ if ( $slug != $request['slug'] ) {
1968
+ /* translators: 1: element name 2: bad_value 3: good_value */
1969
+ $messages .= sprintf( __( '<br>' . 'Changing %1$s "%2$s" to valid value "%3$s"', 'media-library-assistant' ), __( 'extension', 'media-library-assistant' ), $request['slug'], $slug );
1970
+ }
1971
+
1972
  /*
1973
  * Make sure new slug is unique
1974
  */
1975
+ if ( isset( self::$mla_upload_mime_templates[ $slug ] ) ) {
1976
+ /* translators: 1: slug */
1977
+ $errors .= '<br>' . sprintf( __( 'ERROR: Could not add extension "%1$s"; value already exists', 'media-library-assistant' ), $slug );
1978
+ }
1979
  }
1980
 
1981
  /*
1982
  * Validate mime_type
1983
  */
1984
+ if ( empty( $request['mime_type'] ) ) {
1985
+ $errors .= '<br>' . __( 'ERROR: MIME type is required', 'media-library-assistant' );
1986
+ } else {
1987
  $clean_mime_type = sanitize_mime_type( $request['mime_type'] );
1988
+ if ( $clean_mime_type != $request['mime_type'] ) {
1989
+ /* translators: 1: clean_mime_type */
1990
+ $errors .= '<br>' . sprintf( __( 'ERROR: Bad MIME type; try "%1$s"', 'media-library-assistant' ), $clean_mime_type );
1991
+ }
1992
  }
1993
 
1994
+ if ( ! empty( $errors ) ) {
1995
  return array(
1996
  'message' => substr( $errors . $messages, 4),
1997
  'body' => ''
1998
  );
1999
+ }
2000
 
2001
  if ( '.none.' == $request['icon_type'] ) {
2002
+ if ( NULL == $icon_type = wp_ext2type( $slug ) ) {
2003
  $icon_type = 'default';
2004
+ }
2005
+ } else {
2006
  $icon_type = $request['icon_type'];
2007
+ }
2008
 
2009
  $new_type = array();
2010
  $new_type['post_ID'] = ++self::$mla_upload_mime_highest_ID;
2021
  $new_type['core_icon_type'] = self::mla_get_core_icon_type( $slug );
2022
 
2023
  self::$mla_upload_mime_templates[ $slug ] = $new_type;
2024
+ if ( self::_put_upload_mime_templates() ) {
2025
  return array(
2026
+ /* translators: 1: slug */
2027
+ 'message' => substr( $messages . '<br>' . sprintf( __( 'Upload MIME Type "%1$s"; added', 'media-library-assistant' ), $slug ), 4),
2028
  'body' => ''
2029
  );
2030
+ }
2031
 
2032
  return array(
2033
+ 'message' => __( 'ERROR: Cannot update Upload MIME Types', 'media-library-assistant' ),
2034
  'body' => ''
2035
  );
2036
  }
2045
  * @return array Message(s) reflecting the results of the operation
2046
  */
2047
  public static function mla_update_upload_mime( $request ) {
2048
+ if ( self::_get_upload_mime_templates() ) {
2049
  $errors = '';
2050
+ } else {
2051
  return array(
2052
+ 'message' => __( 'ERROR: Cannot load Upload MIME Types', 'media-library-assistant' ),
2053
  'body' => ''
2054
  );
2055
+ }
2056
+
2057
  $messages = '';
2058
  $slug = pathinfo( 'X.' . strtolower( trim( $request['slug'] ) ), PATHINFO_EXTENSION );
2059
  $original_slug = isset( $request['original_slug'] ) ? $request['original_slug'] : $slug;
2060
  unset( $request['original_slug'] );
2061
 
2062
+ if ( isset( self::$mla_upload_mime_templates[ $original_slug ] ) ) {
2063
  $original_type = self::$mla_upload_mime_templates[ $original_slug ];
2064
+ } else {
2065
  $original_type = array(
2066
  'post_ID' => 0,
2067
  'mime_type' => '',
2076
  'icon_type' => '',
2077
  'core_icon_type' => ''
2078
  );
2079
+ }
2080
 
2081
  /*
2082
  * Validate changed slug value
2083
  */
2084
  if ( $slug != $original_slug ) {
2085
+ if ( $slug != $request['slug'] ) {
2086
+ /* translators: 1: element name 2: bad_value 3: good_value */
2087
+ $messages .= sprintf( __( '<br>' . 'Changing new %1$s "%2$s" to valid value "%3$s"', 'media-library-assistant' ), __( 'extension', 'media-library-assistant' ), $request['slug'], $slug );
2088
+ }
2089
 
2090
  /*
2091
  * Make sure new slug is unique
2092
  */
2093
+ if ( isset( self::$mla_upload_mime_templates[ $slug ] ) ) {
2094
+ /* translators: 1: slug */
2095
+ $errors .= '<br>' . sprintf( __( 'ERROR: Could not add new extension "%1$s"; value already exists', 'media-library-assistant' ), $slug );
2096
+ } else {
2097
+ /* translators: 1: element name 2: old_value 3: new_value */
2098
+ $messages .= sprintf( '<br>' . __( 'Changing %1$s from "%2$s" to "%3$s"', 'media-library-assistant' ), __( 'extension', 'media-library-assistant' ), $original_slug, $slug );
2099
+ }
2100
+
2101
  /*
2102
  * A new extension cannot have an $original_type
2103
  */
2120
  /*
2121
  * Validate mime_type
2122
  */
2123
+ if ( empty( $request['mime_type'] ) ) {
2124
  $clean_mime_type = $original_type['mime_type'];
2125
+ } else {
2126
  $clean_mime_type = sanitize_mime_type( $request['mime_type'] );
2127
+ if ( $clean_mime_type != $request['mime_type'] ) {
2128
+ /* translators: 1: clean_mime_type */
2129
+ $errors .= '<br>' . sprintf( __( 'ERROR: Bad MIME type; try "%1$s"', 'media-library-assistant' ), $clean_mime_type );
2130
+ }
2131
  }
2132
 
2133
+ if ( ! empty( $errors ) ) {
2134
  return array(
2135
  'message' => substr( $errors . $messages, 4),
2136
  'body' => ''
2137
  );
2138
+ }
2139
 
2140
  $new_type = array();
2141
+ if ( 0 == $original_type['post_ID'] ) {
2142
  $new_type['post_ID'] = ++self::$mla_upload_mime_highest_ID;
2143
+ } else {
2144
  $new_type['post_ID'] = $original_type['post_ID'];
2145
+ }
2146
+
2147
  $new_type['mime_type'] = $clean_mime_type;
2148
  $new_type['core_type'] = $original_type['core_type'];
2149
  $new_type['mla_type'] = $original_type['mla_type'];
2150
+
2151
  /*
2152
  * Determine the source
2153
  */
2154
+ if ( 'core' == $original_type['standard_source'] && $clean_mime_type == $original_type['core_type'] ) {
2155
  $new_type['source'] = 'core';
2156
+ } elseif ( 'mla' == $original_type['standard_source'] && $clean_mime_type == $original_type['mla_type'] ) {
2157
  $new_type['source'] = 'mla';
2158
+ } else {
2159
  $new_type['source'] = 'custom';
2160
+ }
2161
 
2162
  /*
2163
  * Determine new icon types
2166
 
2167
  if ( isset( $request['icon_type'] ) ) {
2168
  $new_type['icon_type'] = '.none.' == $request['icon_type'] ? 'default' : $request['icon_type'];
2169
+ } elseif ( ! empty( $original_type['icon_type'] ) ) {
 
2170
  $new_type['icon_type'] = $original_type['icon_type'];
2171
+ } else {
2172
  $new_type['icon_type'] = $new_type['core_icon_type'];
2173
+ }
2174
 
2175
+ if ( ! empty( $original_type['wp_icon_type'] ) ) {
2176
  $new_type['wp_icon_type'] = $original_type['wp_icon_type'];
2177
+ } else {
2178
  $new_type['wp_icon_type'] = $new_type['icon_type'];
2179
+ }
2180
 
2181
+ if ( ! empty( $original_type['mla_icon_type'] ) ) {
2182
  $new_type['mla_icon_type'] = $original_type['mla_icon_type'];
2183
+ } else {
2184
  $new_type['mla_icon_type'] = $new_type['icon_type'];
2185
+ }
2186
 
2187
  $new_type['standard_source'] = $original_type['standard_source'];
2188
  $new_type['disabled'] = isset( $request['disabled'] ) ? $request['disabled'] : $original_type['disabled'];
2189
  $new_type['description'] = isset( $request['description'] ) ? sanitize_text_field( $request['description'] ) : $original_type['description'];
2190
 
2191
+ if ( ( $slug == $original_slug ) && ( self::$mla_upload_mime_templates[ $slug ] == $new_type ) ) {
2192
  return array(
2193
+ /* translators: 1: slug */
2194
+ 'message' => substr( $messages . '<br>' . sprintf( __( 'Edit type "%1$s"; no changes detected', 'media-library-assistant' ), $slug ), 4),
2195
  'body' => ''
2196
  );
2197
+ }
2198
 
2199
  self::$mla_upload_mime_templates[ $slug ] = $new_type;
2200
 
2201
+ if ( $slug != $original_slug ) {
2202
  unset( self::$mla_upload_mime_templates[ $original_slug ] );
2203
+ }
2204
 
2205
+ if ( self::_put_upload_mime_templates() ) {
2206
  return array(
2207
+ /* translators: 1: slug */
2208
+ 'message' => substr( $messages . '<br>' . sprintf( __( 'Edit type "%1$s"; updated', 'media-library-assistant' ), $slug ), 4),
2209
  'body' => ''
2210
  );
2211
+ }
2212
 
2213
  return array(
2214
+ 'message' => __( 'ERROR: Cannot update Upload MIME Types', 'media-library-assistant' ),
2215
  'body' => ''
2216
  );
2217
  }
2226
  * @return mixed string with slug of the requested object; false if object not found
2227
  */
2228
  public static function mla_get_upload_mime_slug( $post_ID ) {
2229
+ if ( self::_get_upload_mime_templates() ) {
2230
+ foreach ( self::$mla_upload_mime_templates as $slug => $value ) {
2231
+ if ( $post_ID == $value['post_ID'] ) {
2232
  return $slug;
2233
+ }
2234
+ }
2235
+ }
2236
 
2237
  return false;
2238
  }
2247
  * @return mixed Array of elements, including slug, for the requested object; false if object not found
2248
  */
2249
  public static function mla_get_upload_mime( $slug ) {
2250
+ if ( self::_get_upload_mime_templates() ) {
2251
  if ( isset( self::$mla_upload_mime_templates[ $slug ] ) ) {
2252
  $matched_value = self::$mla_upload_mime_templates[ $slug ];
2253
  $matched_value['slug'] = $slug;
2254
  return $matched_value;
2255
  }
2256
+ }
2257
 
2258
  return false;
2259
  }
2268
  * @return array Message(s) reflecting the results of the operation
2269
  */
2270
  public static function mla_delete_upload_mime( $slug ) {
2271
+ if ( self::_get_upload_mime_templates() ) {
2272
  if ( isset( self::$mla_upload_mime_templates[ $slug ] ) ) {
2273
  unset( self::$mla_upload_mime_templates[ $slug ] );
2274
+
2275
  if ( self::_put_upload_mime_templates() ) {
2276
  self::_get_upload_mime_templates( true );
2277
 
2278
+ if ( isset( self::$mla_upload_mime_templates[ $slug ] ) ) {
2279
  return array(
2280
+ /* translators: 1: slug */
2281
+ 'message' => sprintf( __( 'Upload MIME Type "%1$s"; reverted to standard', 'media-library-assistant' ), $slug ),
2282
  'body' => ''
2283
  );
2284
+ } else {
2285
  return array(
2286
+ /* translators: 1: slug */
2287
+ 'message' => sprintf( __( 'Upload MIME Type "%1$s"; deleted', 'media-library-assistant' ), $slug ),
2288
  'body' => ''
2289
  );
2290
+ }
2291
+ } else {
2292
  return array(
2293
+ 'message' => __( 'ERROR: Cannot update Upload MIME Types', 'media-library-assistant' ),
2294
  'body' => ''
2295
  );
2296
+ }
2297
  }
2298
+ }
2299
 
2300
  return array(
2301
+ /* translators: 1: slug */
2302
+ 'message' => sprintf( __( 'ERROR: Did not find Upload type "%1$s"', 'media-library-assistant' ), $slug ),
2303
  'body' => ''
2304
  );
2305
  }
2312
  * @var array ( ID, slug, mime_type, core_type, mla_type, description )
2313
  */
2314
  private static $mla_optional_upload_mime_templates = NULL;
2315
+
2316
  /**
2317
  * Sanitize and expand Optional Upload MIME Type query arguments from request variables
2318
  *
2330
  * sanitize or validate them.
2331
  */
2332
  if ( ! is_array( $raw_request ) ) {
2333
+ /* translators: 1: function name 2: non-array value */
2334
+ error_log( sprintf( _x( 'ERROR: %1$s non-array "%2$s"', 'error_log', 'media-library-assistant' ), 'MLAMime::_prepare_optional_upload_items_query', var_export( $raw_request, true ) ), 0 );
2335
  return NULL;
2336
  }
2337
 
2344
  foreach ( $raw_request as $key => $value ) {
2345
  switch ( $key ) {
2346
  case 'orderby':
2347
+ if ( 'none' == $value ) {
2348
  $clean_request[ $key ] = $value;
2349
+ } else {
2350
  $sortable_columns = MLA_Upload_Optional_List_Table::mla_get_sortable_columns();
2351
  foreach ($sortable_columns as $sort_key => $sort_value ) {
2352
  if ( $value == $sort_value[0] ) {
2398
  * @return array query results; array of MLA Optional Upload MIME Type objects
2399
  */
2400
  private static function _execute_optional_upload_items_query( $request ) {
2401
+ if ( ! self::_get_optional_upload_mime_templates() ) {
2402
  return array ();
2403
+ }
2404
 
2405
  /*
2406
  * Sort and filter the list
2415
  $found = false !== stripos( $value['slug'], $keyword );
2416
  $found |= false !== stripos( $value['mime_type'], $keyword );
2417
  $found |= false !== stripos( $value['description'], $keyword );
2418
+ } else {
 
2419
  $found = false !== stripos( $value['slug'], $extension );
2420
+ }
2421
 
2422
+ if ( ! $found ) {
2423
  continue;
2424
+ }
2425
  }
2426
 
2427
  switch ( $request['orderby'] ) {
2447
  }
2448
  ksort( $sorted_types );
2449
 
2450
+ if ( 'DESC' == $request['order'] ) {
2451
  $sorted_types = array_reverse( $sorted_types, true );
2452
+ }
2453
 
2454
  /*
2455
  * Paginate the sorted list
2458
  $offset = isset( $request['offset'] ) ? $request['offset'] : 0;
2459
  $count = isset( $request['posts_per_page'] ) ? $request['posts_per_page'] : -1;
2460
  foreach ( $sorted_types as $value ) {
2461
+ if ( $offset ) {
2462
  $offset--;
2463
+ } elseif ( $count-- ) {
2464
  $results[] = $value;
2465
+ } else {
2466
  break;
2467
+ }
2468
  }
2469
 
2470
  return $results;
2510
  * @return boolean Success (true) or failure (false) of the operation
2511
  */
2512
  private static function _get_optional_upload_mime_templates() {
2513
+ if ( NULL != self::$mla_optional_upload_mime_templates ) {
2514
  return true;
2515
+ }
2516
 
2517
  self::$mla_optional_upload_mime_templates = array ();
2518
+ $template_array = MLAData::mla_load_template( 'mla-default-mime-types.tpl' );
2519
  if ( isset( $template_array['mla-optional-mime-types'] ) ) {
2520
  $mla_mime_types = preg_split('/[\r\n]+/', $template_array['mla-optional-mime-types'] );
2521
 
2526
  if ( $matched_type = self::mla_get_upload_mime( $slug ) ) {
2527
  $core_type = $matched_type['core_type'];
2528
  $mla_type = $matched_type['mla_type'];
2529
+ } else {
 
2530
  $core_type = '';
2531
  $mla_type = '';
2532
  }
2555
  * @return mixed the requested object; false if object not found
2556
  */
2557
  public static function mla_get_optional_upload_mime( $ID ) {
2558
+ if ( self::_get_optional_upload_mime_templates() ) {
2559
+ if ( isset( self::$mla_optional_upload_mime_templates[ $ID ] ) ) {
2560
  return self::$mla_optional_upload_mime_templates[ $ID ];
2561
+ }
2562
+ }
2563
 
2564
  return false;
2565
  }
includes/class-mla-objects.php CHANGED
@@ -34,19 +34,19 @@ class MLAObjects {
34
  private static function _build_taxonomies( ) {
35
  if ( MLAOptions::mla_taxonomy_support('attachment_category') ) {
36
  $labels = array(
37
- 'name' => _x( 'Att. Categories', 'taxonomy general name' ),
38
- 'singular_name' => _x( 'Att. Category', 'taxonomy singular name' ),
39
- 'search_items' => __( 'Search Att. Categories' ),
40
- 'all_items' => __( 'All Att. Categories' ),
41
- 'parent_item' => __( 'Parent Att. Category' ),
42
- 'parent_item_colon' => __( 'Parent Att. Category:' ),
43
- 'edit_item' => __( 'Edit Att. Category' ),
44
- 'update_item' => __( 'Update Att. Category' ),
45
- 'add_new_item' => __( 'Add New Att. Category' ),
46
- 'new_item_name' => __( 'New Att. Category Name' ),
47
- 'menu_name' => __( 'Att. Category' )
48
  );
49
-
50
  register_taxonomy(
51
  'attachment_category',
52
  array( 'attachment' ),
@@ -59,22 +59,22 @@ class MLAObjects {
59
  )
60
  );
61
  }
62
-
63
  if ( MLAOptions::mla_taxonomy_support('attachment_tag') ) {
64
  $labels = array(
65
- 'name' => _x( 'Att. Tags', 'taxonomy general name' ),
66
- 'singular_name' => _x( 'Att. Tag', 'taxonomy singular name' ),
67
- 'search_items' => __( 'Search Att. Tags' ),
68
- 'all_items' => __( 'All Att. Tags' ),
69
- 'parent_item' => __( 'Parent Att. Tag' ),
70
- 'parent_item_colon' => __( 'Parent Att. Tag:' ),
71
- 'edit_item' => __( 'Edit Att. Tag' ),
72
- 'update_item' => __( 'Update Att. Tag' ),
73
- 'add_new_item' => __( 'Add New Att. Tag' ),
74
- 'new_item_name' => __( 'New Att. Tag Name' ),
75
- 'menu_name' => __( 'Att. Tag' )
76
  );
77
-
78
  register_taxonomy(
79
  'attachment_tag',
80
  array( 'attachment' ),
@@ -88,13 +88,12 @@ class MLAObjects {
88
  )
89
  );
90
  }
91
-
92
  $taxonomies = get_taxonomies( array ( 'show_ui' => true ), 'names' );
93
  foreach ( $taxonomies as $tax_name ) {
94
  if ( MLAOptions::mla_taxonomy_support( $tax_name ) ) {
95
  register_taxonomy_for_object_type( $tax_name, 'attachment');
96
- if ( 'checked' == MLAOptions::mla_get_option( 'attachments_column' )
97
- ) {
98
 
99
  add_filter( "manage_edit-{$tax_name}_columns", 'MLAObjects::mla_taxonomy_get_columns_filter', 10, 1 ); // $columns
100
  add_filter( "manage_{$tax_name}_custom_column", 'MLAObjects::mla_taxonomy_column_filter', 10, 3 ); // $place_holder, $column_name, $tag->term_id
@@ -102,7 +101,7 @@ class MLAObjects {
102
  } // taxonomy support
103
  } // foreach
104
  } // _build_taxonomies
105
-
106
  /**
107
  * WordPress Filter for edit taxonomy "Attachments" column,
108
  * which replaces the "Posts" column with an equivalent "Attachments" column.
@@ -119,22 +118,22 @@ class MLAObjects {
119
  */
120
  if ( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'add-tag', 'inline-save-tax' ) ) ) {
121
  $post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post';
122
- }
123
- else {
124
  $screen = get_current_screen();
125
  $post_type = !empty( $screen->post_type ) ? $screen->post_type : 'post';
126
  }
127
 
128
  if ( 'attachment' == $post_type ) {
129
- if ( isset ( $columns[ 'posts' ] ) )
130
  unset( $columns[ 'posts' ] );
131
-
132
- $columns[ 'attachments' ] = 'Attachments';
 
133
  }
134
-
135
  return $columns;
136
  }
137
-
138
  /**
139
  * WordPress Filter for edit taxonomy "Attachments" column,
140
  * which returns a count of the attachments assigned a given term
@@ -154,27 +153,28 @@ class MLAObjects {
154
  */
155
  if ( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'add-tag', 'inline-save-tax' ) ) ) {
156
  $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
157
- }
158
- else {
159
  $screen = get_current_screen();
160
  $taxonomy = !empty( $screen->taxonomy ) ? $screen->taxonomy : 'post_tag';
161
  }
162
 
163
  $term = get_term( $term_id, $taxonomy );
164
-
165
  if ( is_wp_error( $term ) ) {
166
- error_log( "ERROR: mla_taxonomy_column_filter( {$taxonomy} ) - get_term " . $term->get_error_message(), 0 );
 
167
  return 0;
168
  }
169
-
170
  $request = array (
171
- // 'fields' => 'ids',
172
  'post_type' => 'attachment',
173
  'post_status' => 'inherit',
174
  'orderby' => 'none',
175
  'nopaging' => true,
176
  'posts_per_page' => 0,
177
  'posts_per_archive_page' => 0,
 
 
178
  'update_post_term_cache' => false,
179
  'tax_query' => array(
180
  array(
@@ -184,10 +184,16 @@ class MLAObjects {
184
  'include_children' => false
185
  ) )
186
  );
187
-
 
 
 
 
188
  $results = new WP_Query( $request );
 
189
  if ( ! empty( $results->error ) ){
190
- error_log( "ERROR: mla_taxonomy_column_filter( {$taxonomy} ) - WP_Query " . $results->error, 0 );
 
191
  return 0;
192
  }
193
 
@@ -206,11 +212,6 @@ class MLAObjects {
206
  */
207
  class MLATextWidget extends WP_Widget {
208
 
209
- /**
210
- * Provides a unique name for the plugin text domain
211
- */
212
- const MLA_TEXT_DOMAIN = 'media_library_assistant';
213
-
214
  /**
215
  * Calls the parent constructor to set some defaults.
216
  *
@@ -221,15 +222,15 @@ class MLATextWidget extends WP_Widget {
221
  function __construct() {
222
  $widget_args = array(
223
  'classname' => 'mla_text_widget',
224
- 'description' => __( 'Shortcode(s), HTML and/or Plain Text', self::MLA_TEXT_DOMAIN )
225
  );
226
-
227
  $control_args = array(
228
  'width' => 400,
229
  'height' => 350
230
  );
231
-
232
- parent::__construct( 'mla-text-widget', __( 'MLA Text', self::MLA_TEXT_DOMAIN ), $widget_args, $control_args );
233
  }
234
 
235
  /**
@@ -263,15 +264,15 @@ class MLATextWidget extends WP_Widget {
263
  */
264
  function form( $instance ) {
265
  $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
266
- $title = strip_tags($instance['title']);
267
- $text = esc_textarea($instance['text']);
268
  ?>
269
- <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', self::MLA_TEXT_DOMAIN); ?></label>
270
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
271
 
272
- <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
273
 
274
- <p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> />&nbsp;<label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs', self::MLA_TEXT_DOMAIN); ?></label></p>
275
  <?php
276
  }
277
 
@@ -287,12 +288,14 @@ class MLATextWidget extends WP_Widget {
287
  */
288
  function update( $new_instance, $old_instance ) {
289
  $instance = $old_instance;
290
- $instance['title'] = strip_tags($new_instance['title']);
291
- if ( current_user_can('unfiltered_html') )
292
  $instance['text'] = $new_instance['text'];
293
- else
294
- $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
295
- $instance['filter'] = isset($new_instance['filter']);
 
 
296
  return $instance;
297
  }
298
 
@@ -306,20 +309,7 @@ class MLATextWidget extends WP_Widget {
306
  * @return void
307
  */
308
  public static function mla_text_widget_widgets_init_action(){
309
- register_widget('MLATextWidget');
310
- }
311
-
312
- /**
313
- * Load a plugin text domain
314
- *
315
- * Defined as public because it's an action.
316
- *
317
- * @since 1.60
318
- *
319
- * @return void
320
- */
321
- public static function mla_text_widget_plugins_loaded_action(){
322
- load_plugin_textdomain( self::MLA_TEXT_DOMAIN, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
323
  }
324
  } // Class MLATextWidget
325
 
@@ -327,6 +317,5 @@ class MLATextWidget extends WP_Widget {
327
  * Actions are added here, when the source file is loaded, because the MLATextWidget
328
  * object(s) are created too late to be useful.
329
  */
330
- add_action('widgets_init','MLATextWidget::mla_text_widget_widgets_init_action');
331
- add_action('plugins_loaded','MLATextWidget::mla_text_widget_plugins_loaded_action');
332
  ?>
34
  private static function _build_taxonomies( ) {
35
  if ( MLAOptions::mla_taxonomy_support('attachment_category') ) {
36
  $labels = array(
37
+ 'name' => _x( 'Att. Categories', 'taxonomy_name_plural', 'media-library-assistant' ),
38
+ 'singular_name' => _x( 'Att. Category', 'taxonomy_name_singular', 'media-library-assistant' ),
39
+ 'search_items' => __( 'Search Att. Categories', 'media-library-assistant' ),
40
+ 'all_items' => __( 'All Att. Categories', 'media-library-assistant' ),
41
+ 'parent_item' => __( 'Parent Att. Category', 'media-library-assistant' ),
42
+ 'parent_item_colon' => __( 'Parent Att. Category', 'media-library-assistant' ) . ':',
43
+ 'edit_item' => __( 'Edit Att. Category', 'media-library-assistant' ),
44
+ 'update_item' => __( 'Update Att. Category', 'media-library-assistant' ),
45
+ 'add_new_item' => __( 'Add New Att. Category', 'media-library-assistant' ),
46
+ 'new_item_name' => __( 'New Att. Category Name', 'media-library-assistant' ),
47
+ 'menu_name' => __( 'Att. Category', 'media-library-assistant' )
48
  );
49
+
50
  register_taxonomy(
51
  'attachment_category',
52
  array( 'attachment' ),
59
  )
60
  );
61
  }
62
+
63
  if ( MLAOptions::mla_taxonomy_support('attachment_tag') ) {
64
  $labels = array(
65
+ 'name' => _x( 'Att. Tags', 'taxonomy_name_plural', 'media-library-assistant' ),
66
+ 'singular_name' => _x( 'Att. Tag', 'taxonomy_name_singular', 'media-library-assistant' ),
67
+ 'search_items' => __( 'Search Att. Tags', 'media-library-assistant' ),
68
+ 'all_items' => __( 'All Att. Tags', 'media-library-assistant' ),
69
+ 'parent_item' => __( 'Parent Att. Tag', 'media-library-assistant' ),
70
+ 'parent_item_colon' => __( 'Parent Att. Tag', 'media-library-assistant' ) . ':',
71
+ 'edit_item' => __( 'Edit Att. Tag', 'media-library-assistant' ),
72
+ 'update_item' => __( 'Update Att. Tag', 'media-library-assistant' ),
73
+ 'add_new_item' => __( 'Add New Att. Tag', 'media-library-assistant' ),
74
+ 'new_item_name' => __( 'New Att. Tag Name', 'media-library-assistant' ),
75
+ 'menu_name' => __( 'Att. Tag', 'media-library-assistant' )
76
  );
77
+
78
  register_taxonomy(
79
  'attachment_tag',
80
  array( 'attachment' ),
88
  )
89
  );
90
  }
91
+
92
  $taxonomies = get_taxonomies( array ( 'show_ui' => true ), 'names' );
93
  foreach ( $taxonomies as $tax_name ) {
94
  if ( MLAOptions::mla_taxonomy_support( $tax_name ) ) {
95
  register_taxonomy_for_object_type( $tax_name, 'attachment');
96
+ if ( 'checked' == MLAOptions::mla_get_option( 'attachments_column' ) ) {
 
97
 
98
  add_filter( "manage_edit-{$tax_name}_columns", 'MLAObjects::mla_taxonomy_get_columns_filter', 10, 1 ); // $columns
99
  add_filter( "manage_{$tax_name}_custom_column", 'MLAObjects::mla_taxonomy_column_filter', 10, 3 ); // $place_holder, $column_name, $tag->term_id
101
  } // taxonomy support
102
  } // foreach
103
  } // _build_taxonomies
104
+
105
  /**
106
  * WordPress Filter for edit taxonomy "Attachments" column,
107
  * which replaces the "Posts" column with an equivalent "Attachments" column.
118
  */
119
  if ( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'add-tag', 'inline-save-tax' ) ) ) {
120
  $post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post';
121
+ } else {
 
122
  $screen = get_current_screen();
123
  $post_type = !empty( $screen->post_type ) ? $screen->post_type : 'post';
124
  }
125
 
126
  if ( 'attachment' == $post_type ) {
127
+ if ( isset ( $columns[ 'posts' ] ) ) {
128
  unset( $columns[ 'posts' ] );
129
+ }
130
+
131
+ $columns[ 'attachments' ] = __( 'Attachments', 'media-library-assistant' );
132
  }
133
+
134
  return $columns;
135
  }
136
+
137
  /**
138
  * WordPress Filter for edit taxonomy "Attachments" column,
139
  * which returns a count of the attachments assigned a given term
153
  */
154
  if ( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'add-tag', 'inline-save-tax' ) ) ) {
155
  $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
156
+ } else {
 
157
  $screen = get_current_screen();
158
  $taxonomy = !empty( $screen->taxonomy ) ? $screen->taxonomy : 'post_tag';
159
  }
160
 
161
  $term = get_term( $term_id, $taxonomy );
162
+
163
  if ( is_wp_error( $term ) ) {
164
+ /* translators: 1: taxonomy 2: error message */
165
+ error_log( sprintf( _x( 'ERROR: mla_taxonomy_column_filter( "%1$s" ) - get_term failed: "%2$s"', 'error_log', 'media-library-assistant' ), $taxonomy, $term->get_error_message() ), 0 );
166
  return 0;
167
  }
168
+
169
  $request = array (
 
170
  'post_type' => 'attachment',
171
  'post_status' => 'inherit',
172
  'orderby' => 'none',
173
  'nopaging' => true,
174
  'posts_per_page' => 0,
175
  'posts_per_archive_page' => 0,
176
+ 'cache_results' => false,
177
+ 'update_post_meta_cache' => false,
178
  'update_post_term_cache' => false,
179
  'tax_query' => array(
180
  array(
184
  'include_children' => false
185
  ) )
186
  );
187
+
188
+ if ( MLATest::$wordpress_3point5_plus ) {
189
+ $request['fields'] = 'ids';
190
+ }
191
+
192
  $results = new WP_Query( $request );
193
+ error_log( 'ids results = ' . var_export( $results, true ), 0 );
194
  if ( ! empty( $results->error ) ){
195
+ /* translators: 1: taxonomy 2: error message */
196
+ error_log( sprintf( _x( 'ERROR: mla_taxonomy_column_filter( "%1$s" ) - WP_Query failed: "%2$s"', 'error_log', 'media-library-assistant' ), $taxonomy, $results->error ), 0 );
197
  return 0;
198
  }
199
 
212
  */
213
  class MLATextWidget extends WP_Widget {
214
 
 
 
 
 
 
215
  /**
216
  * Calls the parent constructor to set some defaults.
217
  *
222
  function __construct() {
223
  $widget_args = array(
224
  'classname' => 'mla_text_widget',
225
+ 'description' => __( 'Shortcode(s), HTML and/or Plain Text', 'media-library-assistant' )
226
  );
227
+
228
  $control_args = array(
229
  'width' => 400,
230
  'height' => 350
231
  );
232
+
233
+ parent::__construct( 'mla-text-widget', __( 'MLA Text', 'media-library-assistant' ), $widget_args, $control_args );
234
  }
235
 
236
  /**
264
  */
265
  function form( $instance ) {
266
  $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
267
+ $title = strip_tags( $instance['title'] );
268
+ $text = esc_textarea( $instance['text'] );
269
  ?>
270
+ <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php echo __( 'Title', 'media-library-assistant' ) . ':'; ?></label>
271
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
272
 
273
+ <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>"><?php echo $text; ?></textarea>
274
 
275
+ <p><input id="<?php echo $this->get_field_id( 'filter' ); ?>" name="<?php echo $this->get_field_name( 'filter' ); ?>" type="checkbox" <?php checked( isset( $instance['filter'] ) ? $instance['filter'] : 0 ); ?> />&nbsp;<label for="<?php echo $this->get_field_id( 'filter' ); ?>"><?php _e( 'Automatically add paragraphs', 'media-library-assistant' ); ?></label></p>
276
  <?php
277
  }
278
 
288
  */
289
  function update( $new_instance, $old_instance ) {
290
  $instance = $old_instance;
291
+ $instance['title'] = strip_tags( $new_instance['title'] );
292
+ if ( current_user_can( 'unfiltered_html' ) ) {
293
  $instance['text'] = $new_instance['text'];
294
+ } else {
295
+ $instance['text'] = stripslashes( wp_filter_post_kses( addslashes( $new_instance['text'] ) ) ); // wp_filter_post_kses() expects slashed
296
+ }
297
+
298
+ $instance['filter'] = isset( $new_instance['filter'] );
299
  return $instance;
300
  }
301
 
309
  * @return void
310
  */
311
  public static function mla_text_widget_widgets_init_action(){
312
+ register_widget( 'MLATextWidget' );
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  }
314
  } // Class MLATextWidget
315
 
317
  * Actions are added here, when the source file is loaded, because the MLATextWidget
318
  * object(s) are created too late to be useful.
319
  */
320
+ add_action( 'widgets_init', 'MLATextWidget::mla_text_widget_widgets_init_action' );
 
321
  ?>
includes/class-mla-options.php CHANGED
@@ -20,7 +20,7 @@ class MLAOptions {
20
  * Provides a unique name for the current version option
21
  */
22
  const MLA_VERSION_OPTION = 'current_version';
23
-
24
  /**
25
  * Provides a unique name for the exclude revisions option
26
  */
@@ -45,144 +45,144 @@ class MLAOptions {
45
  * Provides a unique name for a database tuning option
46
  */
47
  const MLA_MLA_GALLERY_IN_TUNING = 'mla_gallery_in_tuning';
48
-
49
  /**
50
  * Provides a unique name for the taxonomy support option
51
  */
52
  const MLA_TAXONOMY_SUPPORT = 'taxonomy_support';
53
-
54
  /**
55
  * Provides a unique name for the admin screen page title option
56
  */
57
  const MLA_SCREEN_PAGE_TITLE = 'admin_screen_page_title';
58
-
59
  /**
60
  * Provides a unique name for the admin screen menu title option
61
  */
62
  const MLA_SCREEN_MENU_TITLE = 'admin_screen_menu_title';
63
-
64
  /**
65
  * Provides a unique name for the admin screen menu order option
66
  */
67
  const MLA_SCREEN_ORDER = 'admin_screen_menu_order';
68
-
69
  /**
70
  * Provides a unique name for the admin screen remove Media/Library option
71
  */
72
  const MLA_SCREEN_DISPLAY_LIBRARY = 'admin_screen_display_default';
73
-
74
  /**
75
  * Provides a unique name for the default orderby option
76
  */
77
  const MLA_DEFAULT_ORDERBY = 'default_orderby';
78
-
79
  /**
80
  * Provides a unique name for the default order option
81
  */
82
  const MLA_DEFAULT_ORDER = 'default_order';
83
-
84
  /**
85
  * Provides a unique name for the default table views width option
86
  */
87
  const MLA_TABLE_VIEWS_WIDTH = 'table_views_width';
88
-
89
  /**
90
  * Provides a unique name for the taxonomy filter maximum depth option
91
  */
92
  const MLA_TAXONOMY_FILTER_DEPTH = 'taxonomy_filter_depth';
93
-
94
  /**
95
  * Provides a unique name for the taxonomy filter maximum depth option
96
  */
97
  const MLA_TAXONOMY_FILTER_INCLUDE_CHILDREN = 'taxonomy_filter_include_children';
98
-
99
  /**
100
  * Provides a "size" attribute value for the EXIF/Template Value field
101
  */
102
  const MLA_EXIF_SIZE = 30;
103
-
104
  /**
105
  * Provides a unique name for the Custom Field "new rule" key
106
  */
107
  const MLA_NEW_CUSTOM_RULE = '__NEW RULE__';
108
-
109
  /**
110
  * Provides a unique name for the Custom Field "new field" key
111
  */
112
  const MLA_NEW_CUSTOM_FIELD = '__NEW FIELD__';
113
-
114
  /**
115
  * Provides a unique name for the Media Manager toolbar option
116
  */
117
  const MLA_MEDIA_MODAL_TOOLBAR = 'media_modal_toolbar';
118
-
119
  /**
120
  * Provides a unique name for the Media Manager toolbar MIME Types option
121
  */
122
  const MLA_MEDIA_MODAL_MIMETYPES = 'media_modal_mimetypes';
123
-
124
  /**
125
  * Provides a unique name for the Media Manager toolbar Month and Year option
126
  */
127
  const MLA_MEDIA_MODAL_MONTHS = 'media_modal_months';
128
-
129
  /**
130
  * Provides a unique name for the Media Manager toolbar Taxonomy Terms option
131
  */
132
  const MLA_MEDIA_MODAL_TERMS = 'media_modal_terms';
133
-
134
  /**
135
  * Provides a unique name for the Media Manager toolbar Search Box option
136
  */
137
  const MLA_MEDIA_MODAL_SEARCHBOX = 'media_modal_searchbox';
138
-
139
  /**
140
  * Provides a unique name for the Media Manager Attachment Details searchable taxonomy option
141
  * This option is for hierarchical taxonomies, e.g., "Att. Categories".
142
  */
143
  const MLA_MEDIA_MODAL_DETAILS_CATEGORY_METABOX = 'media_modal_details_category_metabox';
144
-
145
  /**
146
  * Provides a unique name for the Media Manager Attachment Details searchable taxonomy option
147
  * This option is for flat taxonomies, e.g., "Att. Tags".
148
  */
149
  const MLA_MEDIA_MODAL_DETAILS_TAG_METABOX = 'media_modal_details_tag_metabox';
150
-
151
  /**
152
  * Provides a unique name for the Media Manager orderby option
153
  */
154
  const MLA_MEDIA_MODAL_ORDERBY = 'media_modal_orderby';
155
-
156
  /**
157
  * Provides a unique name for the Media Manager order option
158
  */
159
  const MLA_MEDIA_MODAL_ORDER = 'media_modal_order';
160
-
161
  /**
162
  * Provides a unique name for the Post MIME Types option
163
  */
164
  const MLA_POST_MIME_TYPES = 'post_mime_types';
165
-
166
  /**
167
  * Provides a unique name for the Enable Post MIME Types option
168
  */
169
  const MLA_ENABLE_POST_MIME_TYPES = 'enable_post_mime_types';
170
-
171
  /**
172
  * Provides a unique name for the Upload MIME Types option
173
  */
174
  const MLA_UPLOAD_MIMES = 'upload_mimes';
175
-
176
  /**
177
  * Provides a unique name for the Enable Upload MIME Types option
178
  */
179
  const MLA_ENABLE_UPLOAD_MIMES = 'enable_upload_mimes';
180
-
181
  /**
182
  * Provides a unique name for the Enable MLA Icons option
183
  */
184
  const MLA_ENABLE_MLA_ICONS = 'enable_mla_icons';
185
-
186
  /**
187
  * Option setting for "Featured in" reporting
188
  *
@@ -228,7 +228,11 @@ class MLAOptions {
228
  public static $process_mla_gallery_in = true;
229
 
230
  /**
231
- * $mla_option_definitions defines the database options and admin page areas for setting/updating them.
 
 
 
 
232
  * Each option is defined by an array with the following elements:
233
  *
234
  * array key => HTML id/name attribute and option database key (OMIT MLA_OPTION_PREFIX)
@@ -252,619 +256,9 @@ class MLAOptions {
252
  * reset => reset function for 'custom' options; returns nothing. Usage:
253
  * $message = ['reset']( 'reset', $key, $value, $_REQUEST );
254
  */
255
- public static $mla_option_definitions = array (
256
- /*
257
- * This option records the highest MLA version so-far installed
258
- */
259
- self::MLA_VERSION_OPTION =>
260
- array('tab' => '',
261
- 'type' => 'hidden',
262
- 'std' => '0'),
263
-
264
- /*
265
- * These checkboxes are no longer used;
266
- * they are retained for the database version/update check
267
- */
268
- 'attachment_category' =>
269
- array('tab' => '',
270
- 'name' => 'Attachment Categories',
271
- 'type' => 'hidden', // checkbox',
272
- 'std' => 'checked',
273
- 'help' => 'Check this option to add support for Attachment Categories.'),
274
-
275
- 'attachment_tag' =>
276
- array('tab' => '',
277
- 'name' => 'Attachment Tags',
278
- 'type' => 'hidden', // checkbox',
279
- 'std' => 'checked',
280
- 'help' => 'Check this option to add support for Attachment Tags.'),
281
-
282
- 'where_used_header' =>
283
- array('tab' => 'general',
284
- 'name' => 'Where-used Reporting',
285
- 'type' => 'header'),
286
-
287
- self::MLA_EXCLUDE_REVISIONS =>
288
- array('tab' => 'general',
289
- 'name' => 'Exclude Revisions',
290
- 'type' => 'checkbox',
291
- 'std' => 'checked',
292
- 'help' => 'Check this option to exclude revisions from where-used reporting.'),
293
-
294
- 'where_used_subheader' =>
295
- array('tab' => 'general',
296
- 'name' => 'Where-used database access tuning',
297
- 'type' => 'subheader'),
298
-
299
- self::MLA_FEATURED_IN_TUNING =>
300
- array('tab' => 'general',
301
- 'name' => 'Featured in',
302
- 'type' => 'select',
303
- 'std' => 'enabled',
304
- 'options' => array('enabled', 'disabled'),
305
- 'texts' => array('Enabled', 'Disabled'),
306
- 'help' => 'Search database posts and pages for Featured Image attachments.'),
307
-
308
- self::MLA_INSERTED_IN_TUNING =>
309
- array('tab' => 'general',
310
- 'name' => 'Inserted in',
311
- 'type' => 'select',
312
- 'std' => 'base',
313
- 'options' => array('enabled', 'base', 'disabled'),
314
- 'texts' => array('Enabled', 'Base', 'Disabled'),
315
- 'help' => 'Search database posts and pages for attachments embedded in content.<br>&nbsp;&nbsp;Base = ignore intermediate size suffixes; use path, base name and extension only.'),
316
-
317
- self::MLA_GALLERY_IN_TUNING =>
318
- array('tab' => 'general',
319
- 'name' => 'Gallery in',
320
- 'type' => 'select',
321
- 'std' => 'cached',
322
- 'options' => array('dynamic', 'refresh', 'cached', 'disabled'),
323
- 'texts' => array('Dynamic', 'Refresh', 'Cached', 'Disabled'),
324
- 'help' => 'Search database posts and pages for [gallery] shortcode results.<br>&nbsp;&nbsp;Dynamic = once every page load, Cached = once every login, Disabled = never.<br>&nbsp;&nbsp;Refresh = update references, then set to Cached.'),
325
-
326
- self::MLA_MLA_GALLERY_IN_TUNING =>
327
- array('tab' => 'general',
328
- 'name' => 'MLA Gallery in',
329
- 'type' => 'select',
330
- 'std' => 'cached',
331
- 'options' => array('dynamic', 'refresh', 'cached', 'disabled'),
332
- 'texts' => array('Dynamic', 'Refresh', 'Cached', 'Disabled'),
333
- 'help' => 'Search database posts and pages for [mla_gallery] shortcode results.<br>&nbsp;&nbsp;Dynamic = once every page load, Cached = once every login, Disabled = never.<br>&nbsp;&nbsp;Refresh = update references, then set to Cached.'),
334
-
335
- 'taxonomy_header' =>
336
- array('tab' => 'general',
337
- 'name' => 'Taxonomy Support',
338
- 'type' => 'header'),
339
-
340
- self::MLA_TAXONOMY_SUPPORT =>
341
- array('tab' => 'general',
342
- 'help' => 'Check the "Support" box to add the taxonomy to the Assistant and the Edit Media screen.<br>Check the "Inline Edit" box to display the taxonomy in the Quick Edit and Bulk Edit areas.<br>Use the "List Filter" option to select the taxonomy on which to filter the Assistant table listing.',
343
- 'std' => array (
344
- 'tax_support' => array (
345
- 'attachment_category' => 'checked',
346
- 'attachment_tag' => 'checked',
347
- ),
348
- 'tax_quick_edit' => array (
349
- 'attachment_category' => 'checked',
350
- 'attachment_tag' => 'checked',
351
- ),
352
- 'tax_filter' => 'attachment_category'
353
- ),
354
- 'type' => 'custom',
355
- 'render' => 'mla_taxonomy_option_handler',
356
- 'update' => 'mla_taxonomy_option_handler',
357
- 'delete' => 'mla_taxonomy_option_handler',
358
- 'reset' => 'mla_taxonomy_option_handler'),
359
-
360
- 'attachments_column' =>
361
- array('tab' => '',
362
- 'name' => 'Attachments Column',
363
- 'type' => 'hidden', // checkbox',
364
- 'std' => 'checked',
365
- 'help' => 'Check this option to replace the Posts column with the Attachments Column.'),
366
-
367
- 'media_assistant_header' =>
368
- array('tab' => 'general',
369
- 'name' => 'Media/Assistant Screen Options',
370
- 'type' => 'header'),
371
-
372
- 'admin_sidebar_subheader' =>
373
- array('tab' => 'general',
374
- 'name' => 'Admin Menu Options',
375
- 'type' => 'subheader'),
376
-
377
- self::MLA_SCREEN_PAGE_TITLE =>
378
- array('tab' => 'general',
379
- 'name' => 'Page Title',
380
- 'type' => 'text',
381
- 'std' => 'Media Library Assistant',
382
- 'size' => 40,
383
- 'help' => 'Enter the title for the Media/Assistant submenu page'),
384
-
385
- self::MLA_SCREEN_MENU_TITLE =>
386
- array('tab' => 'general',
387
- 'name' => 'Menu Title',
388
- 'type' => 'text',
389
- 'std' => 'Assistant',
390
- 'size' => 20,
391
- 'help' => 'Enter the title for the Media/Assistant submenu entry'),
392
-
393
- self::MLA_SCREEN_ORDER =>
394
- array('tab' => 'general',
395
- 'name' => 'Submenu Order',
396
- 'type' => 'text',
397
- 'std' => '0',
398
- 'size' => 2,
399
- 'help' => 'Enter the position of the Media/Assistant submenu entry.<br>&nbsp;&nbsp;0 = natural order (at bottom),&nbsp;&nbsp;&nbsp;&nbsp;1 - 4 = at top<br>&nbsp;&nbsp;6-9 = after "Library",&nbsp;&nbsp;&nbsp;&nbsp;11-16 = after "Add New"'),
400
-
401
- self::MLA_SCREEN_DISPLAY_LIBRARY =>
402
- array('tab' => 'general',
403
- 'name' => 'Display Media/Library',
404
- 'type' => 'checkbox',
405
- 'std' => 'checked',
406
- 'help' => 'Check/uncheck this option to display/remove the WordPress Media/Library submenu entry.'),
407
-
408
- 'table_defaults_subheader' =>
409
- array('tab' => 'general',
410
- 'name' => 'Table Defaults',
411
- 'type' => 'subheader'),
412
-
413
- self::MLA_DEFAULT_ORDERBY =>
414
- array('tab' => 'general',
415
- 'name' => 'Order By',
416
- 'type' => 'select',
417
- 'std' => 'title_name',
418
- 'options' => array('none', 'title_name'),
419
- 'texts' => array('None', 'Title/Name'),
420
- 'help' => 'Select the column for the sort order of the Assistant table listing.'),
421
-
422
- self::MLA_DEFAULT_ORDER =>
423
- array('tab' => 'general',
424
- 'name' => 'Order',
425
- 'type' => 'radio',
426
- 'std' => 'ASC',
427
- 'options' => array('ASC', 'DESC'),
428
- 'texts' => array('Ascending', 'Descending'),
429
- 'help' => 'Choose the sort order.'),
430
-
431
- self::MLA_TABLE_VIEWS_WIDTH =>
432
- array('tab' => 'general',
433
- 'name' => 'Views Width',
434
- 'type' => 'text',
435
- 'std' => '',
436
- 'size' => 10,
437
- 'help' => 'Enter the width for the views list, in pixels (px) or percent (%)'),
438
-
439
- 'taxonomy_filter_subheader' =>
440
- array('tab' => 'general',
441
- 'name' => 'Taxonomy Filter parameters',
442
- 'type' => 'subheader'),
443
-
444
- self::MLA_TAXONOMY_FILTER_DEPTH =>
445
- array('tab' => 'general',
446
- 'name' => 'Maximum Depth',
447
- 'type' => 'text',
448
- 'std' => '3',
449
- 'size' => 2,
450
- 'help' => 'Enter the number of levels displayed for hierarchial taxonomies; enter zero for no limit.'),
451
-
452
- self::MLA_TAXONOMY_FILTER_INCLUDE_CHILDREN =>
453
- array('tab' => 'general',
454
- 'name' => 'Include Children',
455
- 'type' => 'checkbox',
456
- 'std' => 'checked',
457
- 'help' => 'Check/uncheck this option to include/exclude children for hierarchical taxonomies.'),
458
-
459
- 'media_modal_header' =>
460
- array('tab' => 'general',
461
- 'name' => 'Media Manager Enhancements',
462
- 'type' => 'header'),
463
-
464
- self::MLA_MEDIA_MODAL_TOOLBAR =>
465
- array('tab' => 'general',
466
- 'name' => 'Enable Media Manager Enhancements',
467
- 'type' => 'checkbox',
468
- 'std' => 'checked',
469
- 'help' => 'Check/uncheck this option to enable/disable Media Manager Enhancements.'),
470
-
471
- self::MLA_MEDIA_MODAL_MIMETYPES =>
472
- array('tab' => 'general',
473
- 'name' => 'Media Manager Enhanced MIME Type filter',
474
- 'type' => 'checkbox',
475
- 'std' => 'checked',
476
- 'help' => 'Check this option to filter by more MIME Types, e.g., text, applications.'),
477
-
478
- self::MLA_MEDIA_MODAL_MONTHS =>
479
- array('tab' => 'general',
480
- 'name' => 'Media Manager Month and Year filter',
481
- 'type' => 'checkbox',
482
- 'std' => 'checked',
483
- 'help' => 'Check this option to filter by month and year uploaded.'),
484
-
485
- self::MLA_MEDIA_MODAL_TERMS =>
486
- array('tab' => 'general',
487
- 'name' => 'Media Manager Category/Tag filter',
488
- 'type' => 'checkbox',
489
- 'std' => 'checked',
490
- 'help' => 'Check this option to filter by taxonomy terms.'),
491
-
492
- self::MLA_MEDIA_MODAL_SEARCHBOX =>
493
- array('tab' => 'general',
494
- 'name' => 'Media Manager Enhanced Search Media box',
495
- 'type' => 'checkbox',
496
- 'std' => 'checked',
497
- 'help' => 'Check this option to enable search box enhancements.'),
498
-
499
- self::MLA_MEDIA_MODAL_DETAILS_CATEGORY_METABOX =>
500
- array('tab' => 'general',
501
- 'name' => 'Media Manager Searchable Categories metaboxes',
502
- 'type' => 'checkbox',
503
- 'std' => '',
504
- 'help' => 'Check this option to enable searchable metaboxes in the "ATTACHMENT DETAILS" pane.<br>&nbsp;&nbsp;This option is for <strong>hierarchical taxonomies, e.g., "Att. Categories".</strong><br>&nbsp;&nbsp;You must also install and activate the <strong>"Media Categories" plugin</strong> (by Eddie Moya) to implement this option.'),
505
-
506
- self::MLA_MEDIA_MODAL_DETAILS_TAG_METABOX =>
507
- array('tab' => 'general',
508
- 'name' => 'Media Manager Searchable Tags metaboxes',
509
- 'type' => 'checkbox',
510
- 'std' => '',
511
- 'help' => 'Check this option to enable searchable metaboxes in the "ATTACHMENT DETAILS" pane.<br>&nbsp;&nbsp;This option is for <strong>flat taxonomies, e.g., "Att. Tags".</strong><br>&nbsp;&nbsp;You must also install and activate the <strong>"Media Categories" plugin</strong> (by Eddie Moya) to implement this option.'),
512
-
513
- self::MLA_MEDIA_MODAL_ORDERBY =>
514
- array('tab' => '',
515
- 'name' => 'Media Manager Order By',
516
- 'type' => 'select',
517
- 'std' => 'default',
518
- 'options' => array('default', 'none', 'title_name'),
519
- 'texts' => array(' -- Media Manager Default -- ', 'None', 'Title/Name'),
520
- 'help' => 'If you want to override the Media Manager default,<br>&nbsp;&nbsp;select a column for the sort order of the Media Library listing.'),
521
-
522
- self::MLA_MEDIA_MODAL_ORDER =>
523
- array('tab' => '',
524
- 'name' => 'Media Manager Order',
525
- 'type' => 'radio',
526
- 'std' => 'default',
527
- 'options' => array('default', 'ASC', 'DESC'),
528
- 'texts' => array(' -- Media Manager Default -- ', 'Ascending', 'Descending'),
529
- 'help' => 'Choose the sort order.'),
530
-
531
- 'template_header' =>
532
- array('tab' => 'mla_gallery',
533
- 'name' => 'Default [mla_gallery] Templates and Settings',
534
- 'type' => 'header'),
535
-
536
- 'default_tag_cloud_style' =>
537
- array('tab' => '',
538
- 'name' => 'Style Template',
539
- 'type' => 'select',
540
- 'std' => 'tag-cloud',
541
- 'options' => array(),
542
- 'texts' => array(),
543
- 'help' => 'Select the default style template for your [mla_tag_cloud] shortcodes.'),
544
-
545
- 'default_tag_cloud_markup' =>
546
- array('tab' => '',
547
- 'name' => 'Markup Template',
548
- 'type' => 'select',
549
- 'std' => 'tag-cloud',
550
- 'options' => array(),
551
- 'texts' => array(),
552
- 'help' => 'Select the default markup template for your [mla_tag_cloud] shortcodes.'),
553
-
554
- 'mla_tag_cloud_columns' =>
555
- array('tab' => '',
556
- 'name' => 'Default columns',
557
- 'type' => 'text',
558
- 'std' => '3',
559
- 'size' => 3,
560
- 'help' => 'Enter the number of [mla_tag_cloud] columns; must be a positive integer.'),
561
-
562
- 'mla_tag_cloud_margin' =>
563
- array('tab' => '',
564
- 'name' => 'Default mla_margin',
565
- 'type' => 'text',
566
- 'std' => '1.5%',
567
- 'size' => 10,
568
- 'help' => 'Enter the CSS "margin" property value, in length (px, em, pt, etc.), percent (%), "auto" or "inherit".<br>&nbsp;&nbsp;Enter "none" to remove the property entirely.'),
569
-
570
- 'mla_tag_cloud_itemwidth' =>
571
- array('tab' => '',
572
- 'name' => 'Default mla_itemwidth',
573
- 'type' => 'text',
574
- 'std' => 'calculate',
575
- 'size' => 10,
576
- 'help' => 'Enter the CSS "width" property value, in length (px, em, pt, etc.), percent (%), "auto" or "inherit".<br>&nbsp;&nbsp;Enter "calculate" (the default) to calculate the value taking the "margin" value into account.<br>&nbsp;&nbsp;Enter "exact" to calculate the value without considering the "margin" value.<br>&nbsp;&nbsp;Enter "none" to remove the property entirely.'),
577
-
578
- 'default_style' =>
579
- array('tab' => 'mla_gallery',
580
- 'name' => 'Style Template',
581
- 'type' => 'select',
582
- 'std' => 'default',
583
- 'options' => array(),
584
- 'texts' => array(),
585
- 'help' => 'Select the default style template for your [mla_gallery] shortcodes.'),
586
-
587
- 'default_markup' =>
588
- array('tab' => 'mla_gallery',
589
- 'name' => 'Markup Template',
590
- 'type' => 'select',
591
- 'std' => 'default',
592
- 'options' => array(),
593
- 'texts' => array(),
594
- 'help' => 'Select the default markup template for your [mla_gallery] shortcodes.'),
595
-
596
- 'mla_gallery_columns' =>
597
- array('tab' => 'mla_gallery',
598
- 'name' => 'Default columns',
599
- 'type' => 'text',
600
- 'std' => '3',
601
- 'size' => 3,
602
- 'help' => 'Enter the number of [mla_gallery] columns; must be a positive integer.'),
603
-
604
- 'mla_gallery_margin' =>
605
- array('tab' => 'mla_gallery',
606
- 'name' => 'Default mla_margin',
607
- 'type' => 'text',
608
- 'std' => '1.5%',
609
- 'size' => 10,
610
- 'help' => 'Enter the CSS "margin" property value, in length (px, em, pt, etc.), percent (%), "auto" or "inherit".<br>&nbsp;&nbsp;Enter "none" to remove the property entirely.'),
611
-
612
- 'mla_gallery_itemwidth' =>
613
- array('tab' => 'mla_gallery',
614
- 'name' => 'Default mla_itemwidth',
615
- 'type' => 'text',
616
- 'std' => 'calculate',
617
- 'size' => 10,
618
- 'help' => 'Enter the CSS "width" property value, in length (px, em, pt, etc.), percent (%), "auto" or "inherit".<br>&nbsp;&nbsp;Enter "calculate" (the default) to calculate the value taking the "margin" value into account.<br>&nbsp;&nbsp;Enter "exact" to calculate the value without considering the "margin" value.<br>&nbsp;&nbsp;Enter "none" to remove the property entirely.'),
619
-
620
- /*
621
- * Managed by mla_get_style_templates and mla_put_style_templates
622
- */
623
- 'style_templates' =>
624
- array('tab' => '',
625
- 'type' => 'hidden',
626
- 'std' => array()),
627
-
628
- /*
629
- * Managed by mla_get_markup_templates and mla_put_markup_templates
630
- */
631
- 'markup_templates' =>
632
- array('tab' => '',
633
- 'type' => 'hidden',
634
- 'std' => array()),
635
-
636
- 'enable_custom_field_mapping' =>
637
- array('tab' => 'custom_field',
638
- 'name' => 'Enable custom field mapping when adding new media',
639
- 'type' => 'checkbox',
640
- 'std' => '',
641
- 'help' => 'Check this option to enable mapping when uploading new media (attachments).<br>&nbsp;&nbsp;Click Save Changes at the bottom of the screen if you change this option.<br>&nbsp;&nbsp;Does NOT affect the operation of the "Map" buttons on the bulk edit, single edit and settings screens.'),
642
-
643
- 'custom_field_mapping' =>
644
- array('tab' => '',
645
- 'help' => '&nbsp;<br>Update the custom field mapping values above, then click Save Changes to make the updates permanent.<br>You can also make temporary updates and click a Map All Attachments button to apply the rule(s) to all attachments without saving any rule changes.',
646
- 'std' => array(),
647
- 'type' => 'custom',
648
- 'render' => 'mla_custom_field_option_handler',
649
- 'update' => 'mla_custom_field_option_handler',
650
- 'delete' => 'mla_custom_field_option_handler',
651
- 'reset' => 'mla_custom_field_option_handler'),
652
-
653
- 'enable_iptc_exif_mapping' =>
654
- array('tab' => 'iptc_exif',
655
- 'name' => 'Enable IPTC/EXIF Mapping when adding new media',
656
- 'type' => 'checkbox',
657
- 'std' => '',
658
- 'help' => 'Check this option to enable mapping when uploading new media (attachments).<br>&nbsp;&nbsp;Does NOT affect the operation of the "Map" buttons on the bulk edit, single edit and settings screens.'),
659
-
660
- 'iptc_exif_standard_mapping' =>
661
- array('tab' => '',
662
- 'help' => 'Update the standard field mapping values above, then click <strong>Save Changes</strong> to make the updates permanent.<br>You can also make temporary updates and click <strong>Map All Attachments, Standard Fields Now</strong> to apply the updates to all attachments without saving the rule changes.',
663
- 'std' => NULL,
664
- 'type' => 'custom',
665
- 'render' => 'mla_iptc_exif_option_handler',
666
- 'update' => 'mla_iptc_exif_option_handler',
667
- 'delete' => 'mla_iptc_exif_option_handler',
668
- 'reset' => 'mla_iptc_exif_option_handler'),
669
-
670
- 'iptc_exif_taxonomy_mapping' =>
671
- array('tab' => '',
672
- 'help' => 'Update the taxonomy term mapping values above, then click <strong>Save Changes</strong> or <strong>Map All Attachments, Taxonomy Terms Now</strong>.',
673
- 'std' => NULL,
674
- 'type' => 'custom',
675
- 'render' => 'mla_iptc_exif_option_handler',
676
- 'update' => 'mla_iptc_exif_option_handler',
677
- 'delete' => 'mla_iptc_exif_option_handler',
678
- 'reset' => 'mla_iptc_exif_option_handler'),
679
-
680
- 'iptc_exif_custom_mapping' =>
681
- array('tab' => '',
682
- 'help' => '<strong>Update</strong> individual custom field mapping values above, or make several updates and click <strong>Save Changes</strong> below to apply them all at once.<br>You can also <strong>add a new rule</strong> for an existing field or <strong>add a new field</strong> and rule.<br>You can make temporary updates and click <strong>Map All Attachments, Custom Fields Now</strong> to apply the updates to all attachments without saving the rule changes.',
683
- 'std' => NULL,
684
- 'type' => 'custom',
685
- 'render' => 'mla_iptc_exif_option_handler',
686
- 'update' => 'mla_iptc_exif_option_handler',
687
- 'delete' => 'mla_iptc_exif_option_handler',
688
- 'reset' => 'mla_iptc_exif_option_handler'),
689
-
690
- 'iptc_exif_mapping' =>
691
- array('tab' => '',
692
- 'help' => 'IPTC/EXIF Mapping help',
693
- 'std' => array (
694
- 'standard' => array (
695
- 'post_title' => array (
696
- 'name' => 'Title',
697
- 'iptc_value' => 'none',
698
- 'exif_value' => '',
699
- 'iptc_first' => true,
700
- 'keep_existing' => true
701
- ),
702
- 'post_name' => array (
703
- 'name' => 'Name/Slug',
704
- 'iptc_value' => 'none',
705
- 'exif_value' => '',
706
- 'iptc_first' => true,
707
- 'keep_existing' => true
708
- ),
709
- 'image_alt' => array (
710
- 'name' => 'Alternate Text',
711
- 'iptc_value' => 'none',
712
- 'exif_value' => '',
713
- 'iptc_first' => true,
714
- 'keep_existing' => true
715
- ),
716
- 'post_excerpt' => array (
717
- 'name' => 'Caption',
718
- 'iptc_value' => 'none',
719
- 'exif_value' => '',
720
- 'iptc_first' => true,
721
- 'keep_existing' => true
722
- ),
723
- 'post_content' => array (
724
- 'name' => 'Description',
725
- 'iptc_value' => 'none',
726
- 'exif_value' => '',
727
- 'iptc_first' => true,
728
- 'keep_existing' => true
729
- ),
730
- ),
731
- 'taxonomy' => array (
732
- ),
733
- 'custom' => array (
734
- )
735
- ),
736
- 'type' => 'custom',
737
- 'render' => 'mla_iptc_exif_option_handler',
738
- 'update' => 'mla_iptc_exif_option_handler',
739
- 'delete' => 'mla_iptc_exif_option_handler',
740
- 'reset' => 'mla_iptc_exif_option_handler'),
741
-
742
- self::MLA_ENABLE_POST_MIME_TYPES =>
743
- array('tab' => 'view',
744
- 'name' => 'Enable View and Post MIME Type Support',
745
- 'type' => 'checkbox',
746
- 'std' => 'checked',
747
- 'help' => 'Check/uncheck this option to enable/disable Post MIME Type Support, then click <strong>Save Changes</strong> to record the new setting.'),
748
-
749
- self::MLA_POST_MIME_TYPES =>
750
- array('tab' => '',
751
- 'type' => 'custom',
752
- 'render' => 'mla_post_mime_types_option_handler',
753
- 'update' => 'mla_post_mime_types_option_handler',
754
- 'delete' => 'mla_post_mime_types_option_handler',
755
- 'reset' => 'mla_post_mime_types_option_handler',
756
- 'help' => 'Post MIME Types help.',
757
- 'std' => array(
758
- 'all' => array(
759
- 'singular' => 'All',
760
- 'plural' => 'All',
761
- 'specification' => '',
762
- 'post_mime_type' => false,
763
- 'table_view' => true,
764
- 'menu_order' => 0,
765
- 'description' => 'Built-in view'
766
- ),
767
- 'image' => array(
768
- 'singular' => 'Image',
769
- 'plural' => 'Images',
770
- 'specification' => '',
771
- 'post_mime_type' => true,
772
- 'table_view' => true,
773
- 'menu_order' => 0,
774
- 'description' => 'All image subtypes'
775
- ),
776
- 'audio' => array(
777
- 'singular' => 'Audio',
778
- 'plural' => 'Audio',
779
- 'specification' => '',
780
- 'post_mime_type' => true,
781
- 'table_view' => true,
782
- 'menu_order' => 0,
783
- 'description' => 'All audio subtypes'
784
- ),
785
- 'video' => array(
786
- 'singular' => 'Video',
787
- 'plural' => 'Video',
788
- 'specification' => '',
789
- 'post_mime_type' => true,
790
- 'table_view' => true,
791
- 'menu_order' => 0,
792
- 'description' => 'All video subtypes'
793
- ),
794
- 'text' => array(
795
- 'singular' => 'Text',
796
- 'plural' => 'Text',
797
- 'specification' => '',
798
- 'post_mime_type' => true,
799
- 'table_view' => true,
800
- 'menu_order' => 0,
801
- 'description' => 'All text subtypes'
802
- ),
803
- 'application' => array(
804
- 'singular' => 'Application',
805
- 'plural' => 'Applications',
806
- 'specification' => '',
807
- 'post_mime_type' => true,
808
- 'table_view' => true,
809
- 'menu_order' => 0,
810
- 'description' => 'All application subtypes'
811
- ),
812
- 'unattached' => array(
813
- 'singular' => 'Unattached',
814
- 'plural' => 'Unattached',
815
- 'specification' => '',
816
- 'post_mime_type' => false,
817
- 'table_view' => true,
818
- 'menu_order' => 0,
819
- 'description' => 'Built-in view'
820
- ),
821
- 'trash' => array(
822
- 'singular' => 'Trash',
823
- 'plural' => 'Trash',
824
- 'specification' => '',
825
- 'post_mime_type' => false,
826
- 'table_view' => true,
827
- 'menu_order' => 0,
828
- 'description' => 'Built-in view'
829
- )
830
- )),
831
-
832
- self::MLA_ENABLE_UPLOAD_MIMES =>
833
- array('tab' => 'upload',
834
- 'name' => 'Enable Upload MIME Type Support',
835
- 'type' => 'checkbox',
836
- 'std' => 'checked',
837
- 'help' => 'Check/uncheck this option to enable/disable Upload MIME Type Support, then click <strong>Save Changes</strong> to record the new setting.'),
838
-
839
- self::MLA_UPLOAD_MIMES =>
840
- array('tab' => '',
841
- 'type' => 'custom',
842
- 'render' => 'mla_upload_mimes_option_handler',
843
- 'update' => 'mla_upload_mimes_option_handler',
844
- 'delete' => 'mla_upload_mimes_option_handler',
845
- 'reset' => 'mla_upload_mimes_option_handler',
846
- 'help' => 'Upload MIME Types help.',
847
- 'std' => false), // false to detect first-time load; will become an array
848
-
849
- self::MLA_ENABLE_MLA_ICONS =>
850
- array('tab' => 'upload',
851
- 'name' => 'Enable MLA File Type Icons Support',
852
- 'type' => 'checkbox',
853
- 'std' => 'checked',
854
- 'help' => 'Check/uncheck this option to enable/disable MLA File Type Icons Support, then click <strong>Save Changes</strong> to record the new setting.'),
855
-
856
- /* Here are examples of the other option types
857
- 'textarea' =>
858
- array('tab' => '',
859
- 'name' => 'Text Area',
860
- 'type' => 'textarea',
861
- 'std' => 'default text area',
862
- 'cols' => 60,
863
- 'rows' => 4,
864
- 'help' => 'Enter the text area...'),
865
- */
866
- );
867
-
868
  /**
869
  * Initialization function, similar to __construct()
870
  *
@@ -875,22 +269,34 @@ class MLAOptions {
875
  public static function initialize( ) {
876
  self::_load_option_templates();
877
 
878
- if ( 'disabled' == self::mla_get_option( self::MLA_FEATURED_IN_TUNING ) )
879
  self::$process_featured_in = false;
880
- if ( 'disabled' == self::mla_get_option( self::MLA_INSERTED_IN_TUNING ) )
 
 
881
  self::$process_inserted_in = false;
882
- if ( 'disabled' == self::mla_get_option( self::MLA_GALLERY_IN_TUNING ) )
 
 
883
  self::$process_gallery_in = false;
884
- if ( 'disabled' == self::mla_get_option( self::MLA_MLA_GALLERY_IN_TUNING ) )
 
 
885
  self::$process_mla_gallery_in = false;
886
-
887
- if ( 'checked' == MLAOptions::mla_get_option( 'enable_iptc_exif_mapping' ) )
888
- add_action( 'add_attachment', 'MLAOptions::mla_add_attachment_action' );
889
 
890
- if ( 'checked' == MLAOptions::mla_get_option( 'enable_custom_field_mapping' ) )
891
- add_filter( 'wp_update_attachment_metadata', 'MLAOptions::mla_update_attachment_metadata_filter', 10, 2 ); // $data, $post_id
 
 
 
 
 
 
 
 
892
  }
893
-
894
  /**
895
  * Style and Markup templates
896
  *
@@ -899,7 +305,7 @@ class MLAOptions {
899
  * @var array
900
  */
901
  private static $mla_option_templates = null;
902
-
903
  /**
904
  * Load style and markup templates to $mla_templates
905
  *
@@ -908,17 +314,16 @@ class MLAOptions {
908
  * @return void
909
  */
910
  private static function _load_option_templates() {
911
- self::$mla_option_templates = MLAData::mla_load_template( MLA_PLUGIN_PATH . 'tpls/mla-option-templates.tpl' );
912
 
913
  /*
914
  * Load the default templates
915
  */
916
- if( is_null( self::$mla_option_templates ) ) {
917
- MLAShortcodes::$mla_debug_messages .= '<p><strong>_load_option_templates()</strong> error loading tpls/mla-option-templates.tpl';
918
  return;
919
- }
920
- elseif( !self::$mla_option_templates ) {
921
- MLAShortcodes::$mla_debug_messages .= '<p><strong>_load_option_templates()</strong>tpls/mla-option-templates.tpl not found';
922
  $mla_option_templates = null;
923
  return;
924
  }
@@ -945,6 +350,649 @@ class MLAOptions {
945
  } // is_array
946
  }
947
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
948
  /**
949
  * Fetch style or markup template from $mla_templates
950
  *
@@ -957,16 +1005,15 @@ class MLAOptions {
957
  */
958
  public static function mla_fetch_gallery_template( $key, $type = 'style' ) {
959
  if ( ! is_array( self::$mla_option_templates ) ) {
960
- MLAShortcodes::$mla_debug_messages .= '<p><strong>_fetch_template()</strong> no templates exist';
961
  return null;
962
  }
963
-
964
  $array_key = $key . '-' . $type;
965
  if ( array_key_exists( $array_key, self::$mla_option_templates ) ) {
966
  return self::$mla_option_templates[ $array_key ];
967
- }
968
- else {
969
- MLAShortcodes::$mla_debug_messages .= "<p><strong>_fetch_template( {$key}, {$type} )</strong> not found";
970
  return false;
971
  }
972
  }
@@ -980,10 +1027,10 @@ class MLAOptions {
980
  */
981
  public static function mla_get_style_templates() {
982
  if ( ! is_array( self::$mla_option_templates ) ) {
983
- MLAShortcodes::$mla_debug_messages .= '<p><strong>_fetch_template()</strong> no templates exist';
984
  return null;
985
  }
986
-
987
  $templates = array();
988
  foreach ( self::$mla_option_templates as $key => $value ) {
989
  $tail = strrpos( $key, '-style' );
@@ -992,7 +1039,7 @@ class MLAOptions {
992
  $templates[ $name ] = $value;
993
  }
994
  } // foreach
995
-
996
  return $templates;
997
  }
998
 
@@ -1009,7 +1056,7 @@ class MLAOptions {
1009
  self::_load_option_templates();
1010
  return true;
1011
  }
1012
-
1013
  return false;
1014
  }
1015
 
@@ -1022,10 +1069,10 @@ class MLAOptions {
1022
  */
1023
  public static function mla_get_markup_templates() {
1024
  if ( ! is_array( self::$mla_option_templates ) ) {
1025
- MLAShortcodes::$mla_debug_messages .= '<p><strong>_fetch_template()</strong> no templates exist';
1026
  return null;
1027
  }
1028
-
1029
  $templates = array();
1030
  foreach ( self::$mla_option_templates as $key => $value ) {
1031
  // Note order: -row-open must precede -open!
@@ -1035,35 +1082,35 @@ class MLAOptions {
1035
  $templates[ $name ]['row-open'] = $value;
1036
  continue;
1037
  }
1038
-
1039
  $tail = strrpos( $key, '-open-markup' );
1040
  if ( ! ( false === $tail ) ) {
1041
  $name = substr( $key, 0, $tail );
1042
  $templates[ $name ]['open'] = $value;
1043
  continue;
1044
  }
1045
-
1046
  $tail = strrpos( $key, '-item-markup' );
1047
  if ( ! ( false === $tail ) ) {
1048
  $name = substr( $key, 0, $tail );
1049
  $templates[ $name ]['item'] = $value;
1050
  continue;
1051
  }
1052
-
1053
  $tail = strrpos( $key, '-row-close-markup' );
1054
  if ( ! ( false === $tail ) ) {
1055
  $name = substr( $key, 0, $tail );
1056
  $templates[ $name ]['row-close'] = $value;
1057
  continue;
1058
  }
1059
-
1060
  $tail = strrpos( $key, '-close-markup' );
1061
  if ( ! ( false === $tail ) ) {
1062
  $name = substr( $key, 0, $tail );
1063
  $templates[ $name ]['close'] = $value;
1064
  }
1065
  } // foreach
1066
-
1067
  return $templates;
1068
  }
1069
 
@@ -1080,7 +1127,7 @@ class MLAOptions {
1080
  self::_load_option_templates();
1081
  return true;
1082
  }
1083
-
1084
  return false;
1085
  }
1086
 
@@ -1096,22 +1143,25 @@ class MLAOptions {
1096
  * @return mixed Value(s) for the option or false if the option is not a defined MLA option
1097
  */
1098
  public static function mla_get_option( $option, $get_default = false, $get_stored = false ) {
1099
- if ( ! array_key_exists( $option, self::$mla_option_definitions ) )
1100
  return false;
1101
-
 
1102
  if ( $get_default ) {
1103
- if ( array_key_exists( 'std', self::$mla_option_definitions[ $option ] ) )
1104
  return self::$mla_option_definitions[ $option ]['std'];
1105
- else
1106
- return false;
 
1107
  } // $get_default
1108
-
1109
- if ( ! $get_stored && array_key_exists( 'std', self::$mla_option_definitions[ $option ] ) )
1110
  return get_option( MLA_OPTION_PREFIX . $option, self::$mla_option_definitions[ $option ]['std'] );
 
1111
 
1112
  return get_option( MLA_OPTION_PREFIX . $option, false );
1113
  }
1114
-
1115
  /**
1116
  * Add or update the stored value of a defined MLA option
1117
  *
@@ -1123,12 +1173,13 @@ class MLAOptions {
1123
  * @return boolean True if the value was changed or false if the update failed
1124
  */
1125
  public static function mla_update_option( $option, $newvalue ) {
1126
- if ( array_key_exists( $option, self::$mla_option_definitions ) )
1127
  return update_option( MLA_OPTION_PREFIX . $option, $newvalue );
1128
-
 
1129
  return false;
1130
  }
1131
-
1132
  /**
1133
  * Delete the stored value of a defined MLA option
1134
  *
@@ -1142,10 +1193,10 @@ class MLAOptions {
1142
  if ( array_key_exists( $option, self::$mla_option_definitions ) ) {
1143
  return delete_option( MLA_OPTION_PREFIX . $option );
1144
  }
1145
-
1146
  return false;
1147
  }
1148
-
1149
  /**
1150
  * Determine MLA support for a taxonomy, handling the special case where the
1151
  * settings are being updated or reset.
@@ -1161,12 +1212,11 @@ class MLAOptions {
1161
  */
1162
  public static function mla_taxonomy_support($tax_name, $support_type = 'support') {
1163
  $tax_options = MLAOptions::mla_get_option( self::MLA_TAXONOMY_SUPPORT );
1164
-
1165
  switch ( $support_type ) {
1166
  case 'support':
1167
  $tax_support = isset( $tax_options['tax_support'] ) ? $tax_options['tax_support'] : array();
1168
  $is_supported = array_key_exists( $tax_name, $tax_support );
1169
-
1170
  if ( !empty( $_REQUEST['mla-general-options-save'] ) ) {
1171
  $is_supported = isset( $_REQUEST['tax_support'][ $tax_name ] );
1172
  } elseif ( !empty( $_REQUEST['mla-general-options-reset'] ) ) {
@@ -1179,12 +1229,12 @@ class MLAOptions {
1179
  $is_supported = false;
1180
  }
1181
  }
1182
-
1183
  return $is_supported;
1184
  case 'quick-edit':
1185
  $tax_quick_edit = isset( $tax_options['tax_quick_edit'] ) ? $tax_options['tax_quick_edit'] : array();
1186
  $is_supported = array_key_exists( $tax_name, $tax_quick_edit );
1187
-
1188
  if ( !empty( $_REQUEST['mla-general-options-save'] ) ) {
1189
  $is_supported = isset( $_REQUEST['tax_quick_edit'][ $tax_name ] );
1190
  } elseif ( !empty( $_REQUEST['mla-general-options-reset'] ) ) {
@@ -1197,31 +1247,33 @@ class MLAOptions {
1197
  $is_supported = false;
1198
  }
1199
  }
1200
-
1201
  return $is_supported;
1202
  case 'filter':
1203
  $tax_filter = isset( $tax_options['tax_filter'] ) ? $tax_options['tax_filter'] : '';
1204
- if ( '' == $tax_name )
1205
  return $tax_filter;
1206
- else
1207
- $is_supported = ( $tax_name == $tax_filter );
1208
-
 
1209
  if ( !empty( $_REQUEST['mla-general-options-save'] ) ) {
1210
  $tax_filter = isset( $_REQUEST['tax_filter'] ) ? $_REQUEST['tax_filter'] : '';
1211
  $is_supported = ( $tax_name == $tax_filter );
1212
  } elseif ( !empty( $_REQUEST['mla-general-options-reset'] ) ) {
1213
- if ( 'attachment_category' == $tax_name )
1214
  $is_supported = true;
1215
- else
1216
  $is_supported = false;
 
1217
  }
1218
-
1219
  return $is_supported;
1220
  default:
1221
  return false;
1222
  } // $support_type
1223
  } // mla_taxonomy_support
1224
-
1225
  /**
1226
  * Render and manage taxonomy support options, e.g., Categories and Post Tags
1227
  *
@@ -1243,39 +1295,45 @@ class MLAOptions {
1243
  $tax_support = isset( $current_values['tax_support'] ) ? $current_values['tax_support'] : array();
1244
  $tax_quick_edit = isset( $current_values['tax_quick_edit'] ) ? $current_values['tax_quick_edit'] : array();
1245
  $tax_filter = isset( $current_values['tax_filter'] ) ? $current_values['tax_filter'] : '';
1246
-
1247
  /*
1248
  * Always display our own taxonomies, even if not registered.
1249
  * Otherwise there's no way to turn them back on.
1250
  */
1251
  if ( ! array_key_exists( 'attachment_category', $taxonomies ) ) {
1252
- $taxonomies['attachment_category'] = (object) array( 'labels' => (object) array( 'name' => 'Attachment Categories' ) );
1253
- if ( isset( $tax_support['attachment_category'] ) )
1254
  unset( $tax_support['attachment_category'] );
1255
-
1256
- if ( isset( $tax_quick_edit['attachment_category'] ) )
 
1257
  unset( $tax_quick_edit['attachment_category'] );
1258
-
1259
- if ( $tax_filter == 'attachment_category' )
 
1260
  $tax_filter = '';
 
1261
  }
1262
 
1263
  if ( ! array_key_exists( 'attachment_tag', $taxonomies ) ) {
1264
- $taxonomies['attachment_tag'] = (object) array( 'labels' => (object) array( 'name' => 'Attachment Tags' ) );
1265
 
1266
- if ( isset( $tax_support['attachment_tag'] ) )
1267
  unset( $tax_support['attachment_tag'] );
1268
-
1269
- if ( isset( $tax_quick_edit['attachment_tag'] ) )
 
1270
  unset( $tax_quick_edit['attachment_tag'] );
1271
-
1272
- if ( $tax_filter == 'attachment_tag' )
 
1273
  $tax_filter = '';
 
1274
  }
1275
 
1276
  $taxonomy_row = self::$mla_option_templates['taxonomy-row'];
1277
  $row = '';
1278
-
1279
  foreach ( $taxonomies as $tax_name => $tax_object ) {
1280
  $option_values = array (
1281
  'key' => $tax_name,
@@ -1284,15 +1342,19 @@ class MLAOptions {
1284
  'quick_edit_checked' => array_key_exists( $tax_name, $tax_quick_edit ) ? 'checked=checked' : '',
1285
  'filter_checked' => ( $tax_name == $tax_filter ) ? 'checked=checked' : ''
1286
  );
1287
-
1288
  $row .= MLAData::mla_parse_template( $taxonomy_row, $option_values );
1289
  }
1290
 
1291
  $option_values = array (
 
 
 
 
1292
  'taxonomy_rows' => $row,
1293
  'help' => $value['help']
1294
  );
1295
-
1296
  return MLAData::mla_parse_template( self::$mla_option_templates['taxonomy-table'], $option_values );
1297
  case 'update':
1298
  case 'delete':
@@ -1301,61 +1363,149 @@ class MLAOptions {
1301
  $tax_filter = isset( $args['tax_filter'] ) ? $args['tax_filter'] : '';
1302
 
1303
  $msg = '';
1304
-
1305
  if ( !empty($tax_filter) && !array_key_exists( $tax_filter, $tax_support ) ) {
1306
- $msg .= "<br>List Filter ignored; {$tax_filter} not supported.\r\n";
 
1307
  $tax_filter = '';
1308
  }
1309
 
1310
  foreach ( $tax_quick_edit as $tax_name => $tax_value ) {
1311
  if ( !array_key_exists( $tax_name, $tax_support ) ) {
1312
- $msg .= "<br>Quick Edit ignored; {$tax_name} not supported.\r\n";
 
1313
  unset( $tax_quick_edit[ $tax_name ] );
1314
  }
1315
  }
1316
-
1317
  $value = array (
1318
  'tax_support' => $tax_support,
1319
  'tax_quick_edit' => $tax_quick_edit,
1320
  'tax_filter' => $tax_filter
1321
  );
1322
-
1323
  self::mla_update_option( $key, $value );
1324
-
1325
- if ( empty( $msg ) )
1326
- $msg = "<br>Update custom {$key}\r\n";
 
 
1327
 
1328
  return $msg;
1329
  case 'reset':
1330
  self::mla_delete_option( $key );
1331
- return "<br>Reset custom {$key}\r\n";
 
1332
  default:
1333
- return "<br>ERROR: custom {$key} unknown action: {$action}\r\n";
 
1334
  }
1335
  } // mla_taxonomy_option_handler
1336
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1337
  /**
1338
- * Perform ITC/EXIF mapping on just-inserted attachment
1339
  *
 
 
1340
  * @since 1.00
1341
  *
1342
  * @param integer ID of just-inserted attachment
1343
  *
1344
  * @return void
1345
  */
1346
- public static function mla_add_attachment_action( $post_id ) {
1347
- if ( 'checked' == MLAOptions::mla_get_option( 'enable_iptc_exif_mapping' ) ) {
1348
- $item = get_post( $post_id );
1349
- $updates = MLAOptions::mla_evaluate_iptc_exif_mapping( $item, 'iptc_exif_mapping' );
1350
-
1351
- if ( !empty( $updates ) )
1352
- $item_content = MLAData::mla_update_single_item( $post_id, $updates );
1353
- }
1354
  } // mla_add_attachment_action
1355
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1356
  /**
1357
- * Perform Custom Field mapping on just-inserted or updated attachment
1358
  *
 
 
 
1359
  * @since 1.10
1360
  *
1361
  * @param array Attachment metadata for just-inserted attachment
@@ -1364,16 +1514,62 @@ class MLAOptions {
1364
  * @return void
1365
  */
1366
  public static function mla_update_attachment_metadata_filter( $data, $post_id ) {
1367
- if ( 'checked' == MLAOptions::mla_get_option( 'enable_custom_field_mapping' ) ) {
1368
- $updates = MLAOptions::mla_evaluate_custom_field_mapping( $post_id, 'single_attachment_mapping', NULL, $data );
1369
-
1370
- if ( !empty( $updates ) )
1371
- $item_content = MLAData::mla_update_single_item( $post_id, $updates );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1372
  }
1373
-
 
1374
  return $data;
1375
  } // mla_update_attachment_metadata_filter
1376
-
1377
  /**
1378
  * Fetch custom field option value given a slug
1379
  *
@@ -1387,13 +1583,14 @@ class MLAOptions {
1387
  $option_values = self::mla_get_option( 'custom_field_mapping' );
1388
 
1389
  foreach ( $option_values as $key => $value ) {
1390
- if ( $slug == 'c_' . sanitize_title( $key ) )
1391
  return $value;
 
1392
  }
1393
 
1394
  return array();
1395
  } // mla_custom_field_option_value
1396
-
1397
  /**
1398
  * Evaluate file information for custom field mapping
1399
  *
@@ -1412,31 +1609,36 @@ class MLAOptions {
1412
 
1413
  switch( $support_type ) {
1414
  case 'default_columns':
1415
- if ( $value['mla_column'] )
1416
  $results[ $slug ] = $value['name'];
 
1417
  break;
1418
  case 'default_hidden_columns':
1419
- if ( $value['mla_column'] )
1420
  $results[ ] = $slug;
 
1421
  break;
1422
  case 'default_sortable_columns':
1423
- if ( $value['mla_column'] )
1424
  $results[ $slug ] = array( $slug, false );
 
1425
  break;
1426
  case 'quick_edit':
1427
- if ( $value['quick_edit'] )
1428
  $results[ $slug ] = $value['name'];
 
1429
  break;
1430
  case 'bulk_edit':
1431
- if ( $value['bulk_edit'] )
1432
  $results[ $slug ] = $value['name'];
 
1433
  break;
1434
  } // switch support_type
1435
  } // foreach option_value
1436
-
1437
  return $results;
1438
  } // mla_custom_field_support
1439
-
1440
  /**
1441
  * Evaluate file information for custom field mapping
1442
  *
@@ -1469,28 +1671,29 @@ class MLAOptions {
1469
 
1470
  $base_file = isset( $wp_attached_files[ $post_id ]->meta_value ) ? $wp_attached_files[ $post_id ]->meta_value : '';
1471
  $sizes = array();
1472
-
1473
  $attachment_metadata = isset( $wp_attachment_metadata[ $post_id ]->meta_value ) ? unserialize( $wp_attachment_metadata[ $post_id ]->meta_value ) : array();
1474
  if ( !empty( $attachment_metadata ) ) {
1475
  $sizes = isset( $attachment_metadata['sizes'] ) ? $attachment_metadata['sizes'] : array();
1476
-
1477
  if ( isset( $attachment_metadata['width'] ) ) {
1478
  $results['width'] = $attachment_metadata['width'];
1479
  $width = absint( $results['width'] );
1480
- }
1481
- else
1482
  $width = 0;
1483
-
 
1484
  if ( isset( $attachment_metadata['height'] ) ) {
1485
  $results['height'] = $attachment_metadata['height'];
1486
  $height = absint( $results['height'] );
1487
- }
1488
- else
1489
  $height = 0;
1490
-
1491
- if ( $width && $height )
 
1492
  $results['orientation'] = ( $height > $width ) ? 'portrait' : 'landscape';
1493
-
 
1494
  $results['hwstring_small'] = isset( $attachment_metadata['hwstring_small'] ) ? $attachment_metadata['hwstring_small'] : '';
1495
 
1496
  if ( isset( $attachment_metadata['image_meta'] ) ) {
@@ -1506,8 +1709,7 @@ class MLAOptions {
1506
  $results['absolute_path_raw'] = $upload_dir;
1507
  $results['absolute_path'] = wptexturize( str_replace( '\\', '/', $upload_dir ) );
1508
  $results['path'] = '';
1509
- }
1510
- else {
1511
  $results['absolute_path_raw'] = $upload_dir . $pathinfo['dirname'] . '/';
1512
  $results['absolute_path'] = wptexturize( str_replace( '\\', '/', $results['absolute_path_raw'] ) );
1513
  $results['path'] = wptexturize( $pathinfo['dirname'] . '/' );
@@ -1523,7 +1725,7 @@ class MLAOptions {
1523
  $results['sizes'] = $sizes;
1524
  return $results;
1525
  } // _evaluate_file_information
1526
-
1527
  /**
1528
  * Evaluate post information for custom field mapping
1529
  *
@@ -1538,16 +1740,15 @@ class MLAOptions {
1538
  private static function _evaluate_post_information( $post_id, $category, $data_source ) {
1539
  global $wpdb;
1540
  static $post_info = NULL;
1541
-
1542
  if ( NULL == $post_info ) {
1543
  if ( 'custom_field_mapping' == $category ) {
1544
  $post_info = $wpdb->get_results( "SELECT ID, post_date, post_parent, post_mime_type FROM {$wpdb->posts} WHERE post_type = 'attachment'", OBJECT_K );
1545
- }
1546
- else {
1547
  $post_info = $wpdb->get_results( "SELECT ID, post_date, post_parent, post_mime_type FROM {$wpdb->posts} WHERE ID = '{$post_id}'", OBJECT_K );
1548
  }
1549
  }
1550
-
1551
  switch ( $data_source ) {
1552
  case 'post_date':
1553
  return isset( $post_info[ $post_id ]->post_date ) ? $post_info[ $post_id ]->post_date : '';
@@ -1559,7 +1760,7 @@ class MLAOptions {
1559
  return false;
1560
  }
1561
  } // _evaluate_post_information
1562
-
1563
  /**
1564
  * Evaluate post information for custom field mapping
1565
  *
@@ -1572,17 +1773,18 @@ class MLAOptions {
1572
  * @return mixed array for option = array|multi else string
1573
  */
1574
  private static function _evaluate_array_result( $value, $option, $keep_existing ) {
1575
- if ( empty( $value ) )
1576
  return '';
1577
-
 
1578
  if ( is_array( $value ) ) {
1579
- if ( 'single' == $option || 1 == count( $value ) )
1580
  return current( $value );
1581
- elseif ( 'export' == $option )
1582
  return var_export( $value, true );
1583
- elseif ( 'text' == $option )
1584
  return implode( ',', $value );
1585
- elseif ( 'multi' == $option ) {
1586
  $value[0x80000000] = $option;
1587
  $value[0x80000001] = $keep_existing;
1588
  return $value;
@@ -1594,28 +1796,57 @@ class MLAOptions {
1594
  */
1595
  return $value;
1596
  } // _evaluate_array_result
1597
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1598
  /**
1599
  * Evaluate custom field mapping data source
1600
- *
1601
  * @since 1.10
1602
  *
1603
  * @param integer post->ID of attachment
1604
  * @param string category/scope to evaluate against: custom_field_mapping or single_attachment_mapping
1605
- * @param array data source specification ( name, data_source, keep_existing, format, mla_column, quick_edit, bulk_edit, meta_name, no_null, option )
1606
- * @param array (optional) attachment_metadata, default NULL (use current postmeta database value)
1607
  *
1608
- * @return string data source value
1609
  */
1610
  private static function _evaluate_data_source( $post_id, $category, $data_value, $attachment_metadata = NULL ) {
1611
  global $wpdb;
1612
  static $upload_dir, $intermediate_sizes = NULL, $wp_attached_files = NULL, $wp_attachment_metadata = NULL;
1613
  static $current_id = 0, $file_info = NULL, $parent_info = NULL, $references = NULL;
1614
- if ( 'none' == $data_value['data_source'] )
1615
  return '';
 
1616
 
1617
  $data_source = $data_value['data_source'];
1618
-
1619
  /*
1620
  * Do this once per page load; cache attachment metadata if mapping all attachments
1621
  */
@@ -1623,13 +1854,12 @@ class MLAOptions {
1623
  $upload_dir = wp_upload_dir();
1624
  $upload_dir = $upload_dir['basedir'] . '/';
1625
  $intermediate_sizes = get_intermediate_image_sizes();
1626
-
1627
  if ( 'custom_field_mapping' == $category ) {
1628
  if ( ! $table = _get_meta_table('post') ) {
1629
  $wp_attached_files = array();
1630
  $wp_attachment_metadata = array();
1631
- }
1632
- else {
1633
  $wp_attachment_metadata = $wpdb->get_results( "SELECT post_id, meta_value FROM {$table} WHERE meta_key = '_wp_attachment_metadata'", OBJECT_K );
1634
  $wp_attached_files = $wpdb->get_results( "SELECT post_id, meta_value FROM {$table} WHERE meta_key = '_wp_attached_file'", OBJECT_K );
1635
  }
@@ -1643,47 +1873,51 @@ class MLAOptions {
1643
  $current_id = $post_id;
1644
  $parent_info = NULL;
1645
  $references = NULL;
1646
-
1647
  if ( 'single_attachment_mapping' == $category ) {
1648
  $meta_value = get_metadata( 'post', $post_id, '_wp_attached_file' );
1649
  $wp_attached_files = array( $post_id => (object) array( 'post_id' => $post_id, 'meta_value' => $meta_value[0] ) );
1650
-
1651
  if ( NULL == $attachment_metadata ) {
1652
  $metadata = get_metadata( 'post', $post_id, '_wp_attachment_metadata' );
1653
- if ( isset( $metadata[0] ) )
1654
  $attachment_metadata = $metadata[0];
 
1655
  }
1656
 
1657
- if ( empty( $attachment_metadata ) )
1658
  $attachment_metadata = array();
1659
-
 
1660
  $wp_attachment_metadata = array( $post_id => (object) array( 'post_id' => $post_id, 'meta_value' => serialize( $attachment_metadata ) ) );
1661
  }
1662
-
1663
  $file_info = self::_evaluate_file_information( $upload_dir, $wp_attached_files, $wp_attachment_metadata, $post_id );
1664
  }
1665
-
1666
  $size_info = array( 'file' => '', 'width' => '', 'height' => '' );
1667
  $match_count = preg_match( '/(.+)\[(.+)\]/', $data_source, $matches );
1668
  if ( 1 == $match_count ) {
1669
  $data_source = $matches[1] . '[size]';
1670
- if ( isset( $file_info['sizes'][ $matches[2] ] ) )
1671
  $size_info = $file_info['sizes'][ $matches[2] ];
 
1672
  }
1673
 
1674
  $result = '';
1675
-
1676
  switch( $data_source ) {
1677
  case 'meta':
1678
- $attachment_metadata = isset( $wp_attachment_metadata[ $post_id ]->meta_value ) ? unserialize( $wp_attachment_metadata[ $post_id ]->meta_value ) : array();
1679
  $result = MLAData::mla_find_array_element( $data_value['meta_name'], $attachment_metadata, $data_value['option'], $data_value['keep_existing'] );
1680
  break;
1681
  case 'template':
1682
- if ( in_array( $data_value['option'], array ( 'export', 'array', 'multi' ) ) )
1683
  $default_option = 'array';
1684
- else
1685
  $default_option = 'text';
1686
-
 
1687
  $item_values = array();
1688
  $placeholders = MLAData::mla_get_template_placeholders( $data_value['meta_name'], $default_option );
1689
  foreach ( $placeholders as $key => $placeholder ) {
@@ -1701,10 +1935,10 @@ class MLAOptions {
1701
  if ( 'array' == $default_option ) {
1702
  $result = MLAData::mla_parse_array_template( $template, $item_values );
1703
  $result = self::_evaluate_array_result( $result, $data_value['option'], $data_value['keep_existing'] );
1704
- }
1705
- else
1706
  $result = MLAData::mla_parse_template( $template, $item_values );
1707
-
 
1708
  break;
1709
  case 'absolute_path':
1710
  case 'absolute_file_name':
@@ -1727,13 +1961,15 @@ class MLAOptions {
1727
  case 'iso':
1728
  case 'shutter_speed':
1729
  case 'title':
1730
- if ( isset( $file_info[ $data_source ] ) )
1731
  $result = $file_info[ $data_source ];
 
1732
  break;
1733
  case 'file_size':
1734
  $filesize = @ filesize( $file_info['absolute_file_name_raw'] );
1735
- if ( ! (false === $filesize ) )
1736
  $result = $filesize;
 
1737
  break;
1738
  case 'upload_date':
1739
  $result = self::_evaluate_post_information( $post_id, $category, 'post_date' );
@@ -1743,15 +1979,17 @@ class MLAOptions {
1743
  break;
1744
  case 'dimensions':
1745
  $result = $file_info['width'] . 'x' . $file_info['height'];
1746
- if ( 'x' == $result )
1747
  $result = '';
 
1748
  break;
1749
  case 'pixels':
1750
  $result = absint( (int) $file_info['width'] * (int) $file_info['height'] );
1751
- if ( 0 == $result )
1752
  $result = '';
1753
- else
1754
  $result = (string) $result;
 
1755
  break;
1756
  case 'size_keys':
1757
  $result = array();
@@ -1771,13 +2009,14 @@ class MLAOptions {
1771
  $result = array();
1772
  foreach ( $file_info['sizes'] as $key => $value ) {
1773
  $filesize = @ filesize( $file_info['absolute_path_raw'] . $value['file'] );
1774
- if ( false === $filesize )
1775
  $result[] = '?';
1776
- else {
1777
  switch( $data_value['format'] ) {
1778
  case 'commas':
1779
- if ( is_numeric( $filesize ) )
1780
  $filesize = number_format( (float)$filesize );
 
1781
  break;
1782
  default:
1783
  // no change
@@ -1795,8 +2034,9 @@ class MLAOptions {
1795
 
1796
  switch( $data_value['format'] ) {
1797
  case 'commas':
1798
- if ( is_numeric( $pixels ) )
1799
  $pixels = number_format( (float)$pixels );
 
1800
  break;
1801
  default:
1802
  // no change
@@ -1819,16 +2059,18 @@ class MLAOptions {
1819
  break;
1820
  case 'size_bytes[size]':
1821
  $result = @ filesize( $file_info['absolute_path_raw'] . $size_info['file'] );
1822
- if ( false === $result )
1823
  $result = '?';
 
1824
  break;
1825
  case 'size_pixels[size]':
1826
  $result = absint( (int) $size_info['width'] * (int) $size_info['height'] );
1827
  break;
1828
  case 'size_dimensions[size]':
1829
  $result = $size_info['width'] . 'x' . $size_info['height'];
1830
- if ( 'x' == $result )
1831
  $result = '';
 
1832
  break;
1833
  case 'parent':
1834
  $result = absint( self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
@@ -1839,114 +2081,132 @@ class MLAOptions {
1839
  if ( is_null( $parent_info ) ) {
1840
  $parent_info = MLAData::mla_fetch_attachment_parent_data( self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
1841
  }
1842
-
1843
- if ( isset( $parent_info[ $data_source ] ) )
1844
  $result = $parent_info[ $data_source ];
 
1845
  break;
1846
  case 'parent_issues':
1847
- if ( is_null( $references ) )
1848
  $references = MLAData::mla_fetch_attachment_references( $post_id, self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
 
1849
 
1850
  if ( !empty( $references['parent_errors'] ) ) {
1851
  $result = $references['parent_errors'];
1852
  /*
1853
  * Remove (ORPHAN...
1854
  */
1855
- if ( false !== strpos( $result, '(ORPHAN)' ) )
1856
- $result = trim( substr( $result, 8) );
1857
- elseif ( false !== strpos( $result, '(ORPHAN?)' ) )
1858
- $result = trim( substr( $result, 9) );
 
 
 
 
1859
  }
1860
  break;
1861
  case 'reference_issues':
1862
- if ( is_null( $references ) )
1863
  $references = MLAData::mla_fetch_attachment_references( $post_id, self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
 
1864
 
1865
- if ( !empty( $references['parent_errors'] ) )
1866
  $result = $references['parent_errors'];
 
1867
  break;
1868
  case 'featured_in':
1869
  case 'featured_in_title':
1870
- if ( is_null( $references ) )
1871
  $references = MLAData::mla_fetch_attachment_references( $post_id, self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
 
1872
 
1873
  if ( !empty( $references['features'] ) ) {
1874
  $result = array();
1875
  foreach ( $references['features'] as $ID => $value )
1876
- if ( 'featured_in' == $data_source )
1877
- $result[] = sprintf( '%1$s (%2$s %3$d)', $value->post_title, $value->post_type, $ID );
1878
- else
1879
- $result[] = $value->post_title;
 
1880
 
1881
  $result = self::_evaluate_array_result( $result, $data_value['option'], $data_value['keep_existing'] );
1882
- }
1883
- else
1884
  $result = '';
 
1885
  break;
1886
  case 'inserted_in':
1887
  case 'inserted_in_title':
1888
- if ( is_null( $references ) )
1889
  $references = MLAData::mla_fetch_attachment_references( $post_id, self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
 
1890
 
1891
  if ( !empty( $references['inserts'] ) ) {
1892
  $result = array();
1893
  foreach ( $references['inserts'] as $base_file => $inserts )
1894
  foreach ( $inserts as $value )
1895
- if ( 'inserted_in' == $data_source )
1896
- $result[] = sprintf( '%1$s (%2$s %3$d)', $value->post_title, $value->post_type, $value->ID );
1897
- else
1898
- $result[] = $value->post_title;
 
 
1899
  ksort( $result );
1900
 
1901
  $result = self::_evaluate_array_result( $result, $data_value['option'], $data_value['keep_existing'] );
1902
- }
1903
- else
1904
  $result = '';
 
1905
  break;
1906
  case 'gallery_in':
1907
  case 'gallery_in_title':
1908
- if ( is_null( $references ) )
1909
  $references = MLAData::mla_fetch_attachment_references( $post_id, self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
 
1910
 
1911
  if ( !empty( $references['galleries'] ) ) {
1912
  $result = array();
1913
  foreach ( $references['galleries'] as $ID => $value )
1914
- if ( 'gallery_in' == $data_source )
1915
- $result[] = sprintf( '%1$s (%2$s %3$d)', $value['post_title'], $value['post_type'], $ID );
1916
- else
1917
- $result[] = $value['post_title'];
 
1918
 
1919
  $result = self::_evaluate_array_result( $result, $data_value['option'], $data_value['keep_existing'] );
1920
- }
1921
- else
1922
  $result = '';
 
1923
  break;
1924
  case 'mla_gallery_in':
1925
  case 'mla_gallery_in_title':
1926
- if ( is_null( $references ) )
1927
  $references = MLAData::mla_fetch_attachment_references( $post_id, self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
 
1928
 
1929
  if ( !empty( $references['mla_galleries'] ) ) {
1930
  $result = array();
1931
  foreach ( $references['mla_galleries'] as $ID => $value )
1932
- if ( 'mla_gallery_in' == $data_source )
1933
- $result[] = sprintf( '%1$s (%2$s %3$d)', $value['post_title'], $value['post_type'], $ID );
1934
- else
1935
- $result[] = $value['post_title'];
 
1936
 
1937
  $result = self::_evaluate_array_result( $result, $data_value['option'], $data_value['keep_existing'] );
1938
- }
1939
- else
1940
  $result = '';
 
1941
  break;
1942
  default:
1943
  return '';
1944
  } // switch $data_source
1945
-
1946
  switch( $data_value['format'] ) {
1947
  case 'commas':
1948
- if ( is_numeric( $result ) )
1949
  $result = str_pad( number_format( (float)$result ), 15, ' ', STR_PAD_LEFT );
 
1950
  break;
1951
  default:
1952
  // no change
@@ -1955,14 +2215,15 @@ class MLAOptions {
1955
  /*
1956
  * Make numeric values sortable as strings, make all value non-empty
1957
  */
1958
- if ( in_array( $data_source, array( 'file_size', 'pixels', 'width', 'height' ) ) )
1959
  $result = str_pad( $result, 15, ' ', STR_PAD_LEFT );
1960
- elseif ( empty( $result ) )
1961
  $result = ' ';
1962
-
 
1963
  return $result;
1964
  } // _evaluate_data_source
1965
-
1966
  /**
1967
  * Evaluate custom field mapping updates for a post
1968
  *
@@ -1976,73 +2237,93 @@ class MLAOptions {
1976
  * @return array Updates suitable for MLAData::mla_update_single_item, if any
1977
  */
1978
  public static function mla_evaluate_custom_field_mapping( $post_id, $category, $settings = NULL, $attachment_metadata = NULL ) {
1979
- if ( NULL == $settings )
1980
  $settings = self::mla_get_option( 'custom_field_mapping' );
1981
- $updates = array();
1982
- $custom_updates = array();
1983
-
1984
- foreach ( $settings as $new_key => $new_value ) {
1985
- if ( 'none' == $new_value['data_source'] )
1986
- continue;
1987
 
 
 
 
 
1988
  /*
1989
  * Convert checkbox value(s)
1990
  */
1991
- $new_value['no_null'] = isset( $new_value['no_null'] );
1992
-
1993
- $new_text = self::_evaluate_data_source( $post_id, $category, $new_value, $attachment_metadata );
1994
- if ( 'multi' == $new_value['option'] ) {
 
 
 
 
 
 
 
 
 
 
 
1995
  if ( ' ' == $new_text ) {
1996
  $new_text = array(
1997
- 0x80000000 => $new_value['option'],
1998
- 0x80000001 => $new_value['keep_existing'],
1999
- 0x80000002 => $new_value['no_null']
2000
  );
2001
-
2002
- if ( ! $new_value['no_null'] )
2003
  $new_text [0x00000000] = ' ';
2004
- }
2005
- elseif ( is_string( $new_text ) )
2006
  $new_text = array(
2007
  0x00000000 => $new_text,
2008
- 0x80000000 => $new_value['option'],
2009
- 0x80000001 => $new_value['keep_existing']
2010
  );
 
2011
 
2012
- $custom_updates[ $new_value['name'] ] = $new_text;
2013
- }
2014
- else {
2015
- if ( $new_value['keep_existing'] ) {
2016
- if ( 'meta:' == substr( $new_value['name'], 0, 5 ) ) {
2017
- $meta_key = substr( $new_value['name'], 5 );
2018
- $attachment_metadata = maybe_unserialize( get_metadata( 'post', $post_id, '_wp_attachment_metadata', true ) );
2019
- if ( array( $attachment_metadata ) )
 
 
 
2020
  $old_text = MLAData::mla_find_array_element( $meta_key, $attachment_metadata, 'array' );
2021
- else
2022
  $old_text = '';
2023
- }
2024
- else {
2025
- if ( is_string( $old_text = get_metadata( 'post', $post_id, $new_value['name'], true ) ) )
2026
  $old_text = trim( $old_text );
 
2027
  }
2028
-
2029
- if ( ( ' ' != $new_text ) && empty( $old_text ) )
2030
- $custom_updates[ $new_value['name'] ] = $new_text;
2031
- }
2032
- else {
2033
- if ( ' ' == $new_text && $new_value['no_null'] )
2034
  $new_text = NULL;
2035
-
2036
- $custom_updates[ $new_value['name'] ] = $new_text;
 
2037
  }
2038
  } // ! multi
2039
  } // foreach new setting
2040
- if ( ! empty( $custom_updates ) )
 
 
2041
  $updates['custom_updates'] = $custom_updates;
 
2042
 
 
2043
  return $updates;
2044
  } // mla_evaluate_custom_field_mapping
2045
-
2046
  /**
2047
  * Compose a Custom Field Options list with current selection
2048
  *
@@ -2059,27 +2340,28 @@ class MLAOptions {
2059
  $option_values = array (
2060
  'selected' => ( 'none' == $selection ) ? 'selected="selected"' : '',
2061
  'value' => 'none',
2062
- 'text' => ' -- None (select a value) -- '
2063
  );
2064
-
2065
  $custom_field_options = MLAData::mla_parse_template( $option_template, $option_values );
2066
  $custom_field_names = self::_get_custom_field_names();
2067
  foreach ( $custom_field_names as $value ) {
2068
- if ( array_key_exists( $value, $blacklist ) )
2069
  continue;
2070
-
 
2071
  $option_values = array (
2072
  'selected' => ( $value == $selection ) ? 'selected="selected"' : '',
2073
  'value' => $value,
2074
  'text' => $value
2075
  );
2076
-
2077
  $custom_field_options .= MLAData::mla_parse_template( $option_template, $option_values );
2078
  } // foreach custom_field_name
2079
-
2080
  return $custom_field_options;
2081
  } // _compose_custom_field_option_list
2082
-
2083
  /**
2084
  * Array of Data Source names for custom field mapping
2085
  *
@@ -2138,7 +2420,7 @@ class MLAOptions {
2138
  'shutter_speed',
2139
  'title'
2140
  );
2141
-
2142
  /**
2143
  * Compose a (Custom Field) Data Source Options list with current selection
2144
  *
@@ -2155,24 +2437,24 @@ class MLAOptions {
2155
  $option_values = array (
2156
  'selected' => ( 'none' == $selection ) ? 'selected="selected"' : '',
2157
  'value' => 'none',
2158
- 'text' => ' -- None (select a value) -- '
2159
  );
2160
  $custom_field_options = MLAData::mla_parse_template( $option_template, $option_values );
2161
 
2162
  $option_values = array (
2163
  'selected' => ( 'meta' == $selection ) ? 'selected="selected"' : '',
2164
  'value' => 'meta',
2165
- 'text' => ' -- Metadata (see below) -- '
2166
  );
2167
  $custom_field_options .= MLAData::mla_parse_template( $option_template, $option_values );
2168
-
2169
  $option_values = array (
2170
  'selected' => ( 'template' == $selection ) ? 'selected="selected"' : '',
2171
  'value' => 'template',
2172
- 'text' => ' -- Template (see below) -- '
2173
  );
2174
  $custom_field_options .= MLAData::mla_parse_template( $option_template, $option_values );
2175
-
2176
  $intermediate_sizes = get_intermediate_image_sizes();
2177
  foreach ( self::$custom_field_data_sources as $value ) {
2178
  $size_pos = strpos( $value, '[size]' );
@@ -2185,25 +2467,24 @@ class MLAOptions {
2185
  'value' => $value,
2186
  'text' => $value
2187
  );
2188
-
2189
  $custom_field_options .= MLAData::mla_parse_template( $option_template, $option_values );
2190
  } // foreach size_name
2191
  continue;
2192
- }
2193
- else {
2194
  $option_values = array (
2195
  'selected' => ( $value == $selection ) ? 'selected="selected"' : '',
2196
  'value' => $value,
2197
  'text' => $value
2198
  );
2199
  }
2200
-
2201
  $custom_field_options .= MLAData::mla_parse_template( $option_template, $option_values );
2202
  } // foreach custom_field_name
2203
-
2204
  return $custom_field_options;
2205
  } // _compose_data_source_option_list
2206
-
2207
  /**
2208
  * Update custom field mappings
2209
  *
@@ -2222,45 +2503,47 @@ class MLAOptions {
2222
 
2223
  foreach ( $new_values as $new_key => $new_value ) {
2224
  $any_setting_changed = false;
2225
-
2226
  /*
2227
  * Check for the addition of a new rule or field
2228
  */
2229
  if ( self::MLA_NEW_CUSTOM_FIELD == $new_key ) {
2230
  $new_key = trim( $new_value['name'] );
2231
 
2232
- if ( empty( $new_key ) )
2233
  continue;
 
2234
 
2235
  if ( in_array( $new_key, $custom_field_names ) ) {
2236
- $error_list .= "<br>ERROR: new field {$new_key} already exists.\r\n";
 
2237
  continue;
2238
  }
2239
 
2240
- $message_list .= "<br>Adding new field {$new_key}.\r\n";
 
2241
  $any_setting_changed = true;
2242
- }
2243
- elseif ( self::MLA_NEW_CUSTOM_RULE == $new_key ) {
2244
  $new_key = trim( $new_value['name'] );
2245
 
2246
- if ( 'none' == $new_key )
2247
  continue;
 
2248
 
2249
- $message_list .= "<br>Adding new rule for {$new_key}.\r\n";
 
2250
  $any_setting_changed = true;
2251
- }
2252
- else {
2253
  /*
2254
  * Replace slug with field name
2255
  */
2256
  $new_key = trim( $new_value['name'] );
2257
  }
2258
-
2259
  if ( isset( $current_values[ $new_key ] ) ) {
2260
  $old_values = $current_values[ $new_key ];
2261
  $any_setting_changed = false;
2262
- }
2263
- else {
2264
  $old_values = array(
2265
  'name' => $new_key,
2266
  'data_source' => 'none',
@@ -2278,12 +2561,13 @@ class MLAOptions {
2278
  if ( isset( $new_value['action'] ) ) {
2279
  if ( array_key_exists( 'delete_rule', $new_value['action'] ) || array_key_exists( 'delete_field', $new_value['action'] ) ) {
2280
  $settings_changed = true;
2281
- $message_list .= "<br>deleting rule for {$old_values['name']}.\r\n";
 
2282
  unset( $current_values[ $new_key ] );
2283
  continue;
2284
  } // delete rule
2285
  } // isset action
2286
-
2287
  /*
2288
  * For "meta:" fields, the UI options are not appropriate
2289
  */
@@ -2292,113 +2576,117 @@ class MLAOptions {
2292
  unset( $new_value['quick_edit'] );
2293
  unset( $new_value['bulk_edit'] );
2294
  }
2295
-
2296
  if ( $old_values['data_source'] != $new_value['data_source'] ) {
2297
  $any_setting_changed = true;
2298
-
2299
  if ( in_array( $old_values['data_source'], array( 'meta', 'template' ) ) ) {
2300
  $new_value['meta_name'] = '';
2301
  }
2302
 
2303
- $message_list .= "<br>{$old_values['name']} changing Data Source from {$old_values['data_source']} to {$new_value['data_source']}.\r\n";
 
2304
  $old_values['data_source'] = $new_value['data_source'];
2305
  }
2306
 
2307
  if ( $new_value['keep_existing'] ) {
2308
  $boolean_value = true;
2309
- $boolean_text = 'Replace to Keep';
2310
- }
2311
- else {
2312
  $boolean_value = false;
2313
- $boolean_text = 'Keep to Replace';
2314
  }
2315
  if ( $old_values['keep_existing'] != $boolean_value ) {
2316
  $any_setting_changed = true;
2317
- $message_list .= "<br>{$old_values['name']} changing Existing Text value from {$boolean_text}.\r\n";
 
2318
  $old_values['keep_existing'] = $boolean_value;
2319
  }
2320
-
2321
  if ( $old_values['format'] != $new_value['format'] ) {
2322
  $any_setting_changed = true;
2323
- $message_list .= "<br>{$old_values['name']} changing Format from {$old_values['format']} to {$new_value['format']}.\r\n";
 
2324
  $old_values['format'] = $new_value['format'];
2325
  }
2326
 
2327
  if ( isset( $new_value['mla_column'] ) ) {
2328
  $boolean_value = true;
2329
- $boolean_text = 'unchecked to checked';
2330
- }
2331
- else {
2332
  $boolean_value = false;
2333
- $boolean_text = 'checked to unchecked';
2334
  }
2335
  if ( $old_values['mla_column'] != $boolean_value ) {
2336
  $any_setting_changed = true;
2337
- $message_list .= "<br>{$old_values['name']} changing MLA Column value from {$boolean_text}.\r\n";
 
2338
  $old_values['mla_column'] = $boolean_value;
2339
  }
2340
-
2341
  if ( isset( $new_value['quick_edit'] ) ) {
2342
  $boolean_value = true;
2343
- $boolean_text = 'unchecked to checked';
2344
- }
2345
- else {
2346
  $boolean_value = false;
2347
- $boolean_text = 'checked to unchecked';
2348
  }
2349
  if ( $old_values['quick_edit'] != $boolean_value ) {
2350
  $any_setting_changed = true;
2351
- $message_list .= "<br>{$old_values['name']} changing Quick Edit value from {$boolean_text}.\r\n";
 
2352
  $old_values['quick_edit'] = $boolean_value;
2353
  }
2354
-
2355
  if ( isset( $new_value['bulk_edit'] ) ) {
2356
  $boolean_value = true;
2357
- $boolean_text = 'unchecked to checked';
2358
- }
2359
- else {
2360
  $boolean_value = false;
2361
- $boolean_text = 'checked to unchecked';
2362
  }
2363
  if ( $old_values['bulk_edit'] != $boolean_value ) {
2364
  $any_setting_changed = true;
2365
- $message_list .= "<br>{$old_values['name']} changing Bulk Edit value from {$boolean_text}.\r\n";
 
2366
  $old_values['bulk_edit'] = $boolean_value;
2367
  }
2368
-
2369
  if ( $old_values['meta_name'] != $new_value['meta_name'] ) {
2370
  $any_setting_changed = true;
2371
-
2372
- $message_list .= "<br>{$old_values['name']} changing Metavalue name from {$old_values['meta_name']} to {$new_value['meta_name']}.\r\n";
 
2373
  $old_values['meta_name'] = $new_value['meta_name'];
2374
  }
2375
 
2376
  if ( $old_values['option'] != $new_value['option'] ) {
2377
  $any_setting_changed = true;
2378
- $message_list .= "<br>{$old_values['name']} changing Option from {$old_values['option']} to {$new_value['option']}.\r\n";
 
2379
  $old_values['option'] = $new_value['option'];
2380
  }
2381
 
2382
  if ( isset( $new_value['no_null'] ) ) {
2383
  $boolean_value = true;
2384
- $boolean_text = 'unchecked to checked';
2385
- }
2386
- else {
2387
  $boolean_value = false;
2388
- $boolean_text = 'checked to unchecked';
2389
  }
2390
  if ( $old_values['no_null'] != $boolean_value ) {
2391
  $any_setting_changed = true;
2392
- $message_list .= "<br>{$old_values['name']} changing Delete NULL value from {$boolean_text}.\r\n";
 
2393
  $old_values['no_null'] = $boolean_value;
2394
  }
2395
-
2396
  if ( $any_setting_changed ) {
2397
  $settings_changed = true;
2398
  $current_values[ $new_key ] = $old_values;
2399
  }
2400
  } // foreach new value
2401
-
2402
  /*
2403
  * Uncomment this for debugging.
2404
  */
@@ -2406,7 +2694,7 @@ class MLAOptions {
2406
 
2407
  return array( 'message' => $error_list, 'values' => $current_values, 'changed' => $settings_changed );
2408
  } // _update_custom_field_mapping
2409
-
2410
  /**
2411
  * Render and manage custom field mapping options
2412
  *
@@ -2426,13 +2714,15 @@ class MLAOptions {
2426
  switch ( $action ) {
2427
  case 'render':
2428
  if (empty( $current_values ) ) {
2429
- $table_rows = MLAData::mla_parse_template( self::$mla_option_templates['custom-field-empty-row'], array( 'column_count' => 7 ) );
2430
- }
2431
- else {
 
 
2432
  $row_template = self::$mla_option_templates['custom-field-rule-row'];
2433
  $table_rows = '';
2434
  }
2435
-
2436
  ksort( $current_values );
2437
  foreach ( $current_values as $row_name => $current_value ) {
2438
  $row_values = array (
@@ -2440,9 +2730,13 @@ class MLAOptions {
2440
  'name' => $row_name,
2441
  'data_source_options' => self::_compose_data_source_option_list( $current_value['data_source'] ),
2442
  'keep_selected' => '',
 
2443
  'replace_selected' => '',
 
2444
  'native_format' => '',
 
2445
  'commas_format' => '',
 
2446
  'mla_column_checked' => '',
2447
  'quick_edit_checked' => '',
2448
  'bulk_edit_checked' => '',
@@ -2450,18 +2744,30 @@ class MLAOptions {
2450
  'meta_name_size' => 30,
2451
  'meta_name' => $current_value['meta_name'],
2452
  'column_count_meta' => (7 - 2),
 
2453
  'text_option' => '',
 
2454
  'single_option' => '',
 
2455
  'export_option' => '',
 
2456
  'array_option' => '',
 
2457
  'multi_option' => '',
2458
- 'no_null_checked' => ''
 
 
 
 
 
 
2459
  );
2460
-
2461
- if ( $current_value['keep_existing'] )
2462
  $row_values['keep_selected'] = 'selected="selected"';
2463
- else
2464
  $row_values['replace_selected'] = 'selected="selected"';
 
2465
 
2466
  switch( $current_value['format'] ) {
2467
  case 'native':
@@ -2474,14 +2780,17 @@ class MLAOptions {
2474
  $row_values['native_format'] = 'selected="selected"';
2475
  } // format
2476
 
2477
- if ( $current_value['mla_column'] )
2478
  $row_values['mla_column_checked'] = 'checked="checked"';
 
2479
 
2480
- if ( $current_value['quick_edit'] )
2481
  $row_values['quick_edit_checked'] = 'checked="checked"';
 
2482
 
2483
- if ( $current_value['bulk_edit'] )
2484
  $row_values['bulk_edit_checked'] = 'checked="checked"';
 
2485
 
2486
  switch( $current_value['option'] ) {
2487
  case 'single':
@@ -2500,8 +2809,9 @@ class MLAOptions {
2500
  $row_values['text_option'] = 'selected="selected"';
2501
  } // option
2502
 
2503
- if ( $current_value['no_null'] )
2504
  $row_values['no_null_checked'] = 'checked="checked"';
 
2505
 
2506
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
2507
  } // foreach current_value
@@ -2511,93 +2821,131 @@ class MLAOptions {
2511
  */
2512
  $row_template = self::$mla_option_templates['custom-field-new-rule-row'];
2513
  $row_values = array (
 
 
2514
  'key' => self::MLA_NEW_CUSTOM_RULE,
2515
  'field_name_options' => self::_compose_custom_field_option_list( 'none', $current_values ),
2516
  'data_source_options' => self::_compose_data_source_option_list( 'none' ),
2517
  'keep_selected' => '',
 
2518
  'replace_selected' => 'selected="selected"',
 
2519
  'native_format' => 'selected="selected"',
 
2520
  'commas_format' => '',
 
2521
  'mla_column_checked' => '',
2522
  'quick_edit_checked' => '',
2523
  'bulk_edit_checked' => '',
2524
- 'column_count' => 7,
2525
  'meta_name_size' => 30,
2526
  'meta_name' => '',
2527
  'column_count_meta' => (7 - 2),
 
2528
  'text_option' => '',
 
2529
  'single_option' => '',
 
2530
  'export_option' => '',
 
2531
  'array_option' => '',
 
2532
  'multi_option' => '',
2533
- 'no_null_checked' => ''
 
 
 
 
2534
  );
2535
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
2536
-
2537
  /*
2538
  * Add a row for defining a new Custom Field
2539
  */
2540
  $row_template = self::$mla_option_templates['custom-field-new-field-row'];
2541
  $row_values = array (
 
 
2542
  'key' => self::MLA_NEW_CUSTOM_FIELD,
2543
  'field_name_size' => '24',
2544
  'data_source_options' => self::_compose_data_source_option_list( 'none' ),
2545
  'keep_selected' => '',
 
2546
  'replace_selected' => 'selected="selected"',
 
2547
  'native_format' => 'selected="selected"',
 
2548
  'commas_format' => '',
 
2549
  'mla_column_checked' => '',
2550
  'quick_edit_checked' => '',
2551
  'bulk_edit_checked' => '',
2552
- 'column_count' => 7,
2553
  'meta_name_size' => 30,
2554
  'meta_name' => '',
2555
  'column_count_meta' => (7 - 2),
 
2556
  'text_option' => '',
 
2557
  'single_option' => '',
 
2558
  'export_option' => '',
 
2559
  'array_option' => '',
 
2560
  'multi_option' => '',
2561
- 'no_null_checked' => ''
 
 
 
 
2562
  );
2563
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
2564
-
2565
  $option_values = array (
 
 
 
 
 
 
 
2566
  'table_rows' => $table_rows,
2567
  'help' => $value['help']
2568
  );
2569
-
2570
  return MLAData::mla_parse_template( self::$mla_option_templates['custom-field-table'], $option_values );
2571
  case 'update':
2572
  case 'delete':
2573
  $settings_changed = false;
2574
  $messages = '';
2575
-
2576
  $results = self::_update_custom_field_mapping( $current_values, $args );
2577
  $messages .= $results['message'];
2578
  $current_values = $results['values'];
2579
  $settings_changed = $results['changed'];
2580
-
2581
  if ( $settings_changed ) {
2582
  $settings_changed = MLAOptions::mla_update_option( 'custom_field_mapping', $current_values );
2583
- if ( $settings_changed )
2584
- $results = "Custom field mapping rules updated.\r\n";
2585
- else
2586
- $results = "ERROR: Custom field mapping rules update failed.\r\n";
 
 
 
2587
  }
2588
- else
2589
- $results = "Custom field no mapping rule changes detected.\r\n";
2590
-
2591
  return $results . $messages;
2592
  case 'reset':
2593
  $current_values = self::$mla_option_definitions['custom_field_mapping']['std'];
2594
  $settings_changed = MLAOptions::mla_update_option( 'custom_field_mapping', $current_values );
2595
- if ( $settings_changed )
2596
- return "Custom field mapping settings saved.\r\n";
2597
- else
2598
- return "ERROR: Custom field mapping settings reset failed.\r\n";
 
2599
  default:
2600
- return "<br>ERROR: Custom {$key} unknown action: {$action}\r\n";
 
2601
  } // switch $action
2602
  } // mla_custom_field_option_handler
2603
 
@@ -2609,249 +2957,311 @@ class MLAOptions {
2609
  * @param object post object with current values
2610
  * @param string category to evaluate against, e.g., iptc_exif_standard_mapping or iptc_exif_mapping
2611
  * @param array (optional) iptc_exif_mapping values, default - current option value
 
2612
  *
2613
  * @return array Updates suitable for MLAData::mla_update_single_item, if any
2614
  */
2615
- public static function mla_evaluate_iptc_exif_mapping( $post, $category, $settings = NULL ) {
2616
- $metadata = MLAData::mla_fetch_attachment_image_metadata( $post->ID );
2617
  $updates = array();
2618
  $update_all = ( 'iptc_exif_mapping' == $category );
2619
- if ( NULL == $settings )
2620
  $settings = self::mla_get_option( 'iptc_exif_mapping' );
 
2621
 
 
 
2622
  if ( $update_all || ( 'iptc_exif_standard_mapping' == $category ) ) {
2623
- foreach ( $settings['standard'] as $new_key => $new_value ) {
2624
- if ( 'none' == $new_value['iptc_value'] )
 
 
 
 
 
2625
  $iptc_value = '';
2626
- else
2627
- $iptc_value = MLAData::mla_iptc_metadata_value( $new_value['iptc_value'], $metadata );
2628
-
2629
- if ( 'template:' == substr( $new_value['exif_value'], 0, 9 ) ) {
 
 
 
2630
  $data_value = array(
2631
- 'name' => $new_key,
2632
  'data_source' => 'template',
2633
- 'meta_name' => substr( $new_value['exif_value'], 9 ),
2634
- 'keep_existing' => $new_value['keep_existing'],
2635
  'format' => 'native',
2636
  'option' => 'text' );
2637
-
2638
- $exif_value = self::_evaluate_data_source( $post->ID, 'single_attachment_mapping', $data_value, $metadata );
2639
- }
2640
- else
2641
- $exif_value = MLAData::mla_exif_metadata_value( $new_value['exif_value'], $metadata );
2642
-
2643
- $keep_existing = (boolean) $new_value['keep_existing'];
2644
-
2645
- if ( $new_value['iptc_first'] )
2646
- if ( ! empty( $iptc_value ) )
 
 
2647
  $new_text = $iptc_value;
2648
- else
2649
  $new_text = $exif_value;
2650
- else
2651
- if ( ! empty( $exif_value ) )
 
2652
  $new_text = $exif_value;
2653
- else
2654
  $new_text = $iptc_value;
 
 
2655
 
2656
  if ( is_array( $new_text ) ) {
2657
- $new_text = implode( ',', $new_text );
2658
  }
2659
-
2660
  $new_text = trim( convert_chars( $new_text ) );
2661
- if ( !empty( $new_text ) )
2662
- switch ( $new_key ) {
2663
  case 'post_title':
2664
  if ( ( empty( $post->post_title ) || !$keep_existing ) &&
2665
  ( trim( $new_text ) && ! is_numeric( sanitize_title( $new_text ) ) ) )
2666
- $updates[ $new_key ] = $new_text;
2667
  break;
2668
  case 'post_name':
2669
- $updates[ $new_key ] = wp_unique_post_slug( sanitize_title( $new_text ), $post->ID, $post->post_status, $post->post_type, $post->post_parent);
2670
  break;
2671
  case 'image_alt':
2672
  $old_text = get_metadata( 'post', $post->ID, '_wp_attachment_image_alt', true );
2673
  if ( empty( $old_text ) || !$keep_existing ) {
2674
- $updates[ $new_key ] = $new_text; }
2675
  break;
2676
  case 'post_excerpt':
2677
- if ( empty( $post->post_excerpt ) || !$keep_existing )
2678
- $updates[ $new_key ] = $new_text;
 
2679
  break;
2680
  case 'post_content':
2681
- if ( empty( $post->post_content ) || !$keep_existing )
2682
- $updates[ $new_key ] = $new_text;
 
2683
  break;
2684
  default:
2685
  // ignore anything else
2686
- } // $new_key
 
2687
  } // foreach new setting
2688
  } // update standard field mappings
2689
-
2690
  if ( $update_all || ( 'iptc_exif_taxonomy_mapping' == $category ) ) {
2691
  $tax_inputs = array();
2692
  $tax_actions = array();
2693
-
2694
- foreach ( $settings['taxonomy'] as $new_key => $new_value ) {
2695
- if ( 'none' == $new_value['iptc_value'] )
 
 
 
 
 
 
 
 
 
 
2696
  $iptc_value = '';
2697
- else
2698
- $iptc_value = MLAData::mla_iptc_metadata_value( $new_value['iptc_value'], $metadata );
2699
-
2700
- if ( 'template:' == substr( $new_value['exif_value'], 0, 9 ) ) {
 
 
 
2701
  $data_value = array(
2702
- 'name' => $new_key,
2703
  'data_source' => 'template',
2704
- 'meta_name' => substr( $new_value['exif_value'], 9 ),
2705
- 'keep_existing' => $new_value['keep_existing'],
2706
  'format' => 'native',
2707
  'option' => 'array' );
2708
-
2709
- $exif_value = self::_evaluate_data_source( $post->ID, 'single_attachment_mapping', $data_value, $metadata );
 
 
2710
  }
2711
- else
2712
- $exif_value = MLAData::mla_exif_metadata_value( $new_value['exif_value'], $metadata );
2713
-
2714
- $tax_action = ( $new_value['keep_existing'] ) ? 'add' : 'replace';
2715
- $tax_parent = ( isset( $new_value['parent'] ) && (0 != (integer) $new_value['parent'] ) ) ? (integer) $new_value['parent'] : 0;
2716
 
2717
- if ( $new_value['iptc_first'] )
2718
- if ( ! empty( $iptc_value ) )
 
 
 
 
 
2719
  $new_text = $iptc_value;
2720
- else
2721
  $new_text = $exif_value;
2722
- else
2723
- if ( ! empty( $exif_value ) )
 
2724
  $new_text = $exif_value;
2725
- else
2726
  $new_text = $iptc_value;
 
 
2727
 
2728
  /*
2729
  * Parse out individual terms if Delimiter(s) are present
2730
  */
2731
- if ( ! empty( $new_value['delimiters'] ) ) {
2732
- $text = $new_value['delimiters'];
2733
  $delimiters = array();
2734
  while ( ! empty( $text ) ) {
2735
  $delimiters[] = $text[0];
2736
  $text = substr($text, 1);
2737
  }
2738
-
2739
- if ( is_scalar( $new_text ) )
2740
  $new_text = array( $new_text );
2741
-
 
2742
  foreach( $delimiters as $delimiter ) {
2743
  $new_terms = array();
2744
  foreach ( $new_text as $text ) {
2745
  $fragments = explode( $delimiter, $text );
2746
  foreach( $fragments as $fragment ) {
2747
  $fragment = trim( $fragment );
2748
- if ( ! empty( $fragment ) )
2749
  $new_terms[] = $fragment;
 
2750
  } // foreach fragment
2751
  } // foreach $text
2752
  $new_text = array_unique( $new_terms );
2753
  } // foreach $delimiter
2754
  }
2755
-
2756
  if ( !empty( $new_text ) ) {
2757
- if ( $new_value['hierarchical'] ) {
2758
- if ( is_string( $new_text ) )
2759
  $new_text = array( $new_text );
2760
-
 
2761
  $new_terms = array();
2762
  foreach ( $new_text as $new_term ) {
2763
- $term_object = term_exists( $new_term, $new_key );
2764
- if ($term_object !== 0 && $term_object !== null)
2765
  $new_terms[] = $term_object['term_id'];
2766
- else {
2767
- $term_object = wp_insert_term( $new_term, $new_key, array( 'parent' => $tax_parent ) );
2768
- if ( isset( $term_object['term_id'] ) )
2769
  $new_terms[] = $term_object['term_id'];
 
2770
  }
2771
  } // foreach new_term
2772
-
2773
- $tax_inputs[ $new_key ] = $new_terms;
2774
  } // hierarchical
2775
  else {
2776
- $tax_inputs[ $new_key ] = $new_text;
2777
  }
2778
 
2779
- $tax_actions[ $new_key ] = $tax_action;
2780
  } // new_text
2781
  } // foreach new setting
2782
-
2783
- if ( ! empty( $tax_inputs ) )
2784
  $updates['taxonomy_updates'] = array ( 'inputs' => $tax_inputs, 'actions' => $tax_actions );
 
2785
  } // update taxonomy term mappings
2786
 
2787
  if ( $update_all || ( 'iptc_exif_custom_mapping' == $category ) ) {
2788
  $custom_updates = array();
2789
-
2790
- foreach ( $settings['custom'] as $new_key => $new_value ) {
2791
- if ( 'none' == $new_value['iptc_value'] )
 
 
 
 
2792
  $iptc_value = '';
2793
- else
2794
- $iptc_value = MLAData::mla_iptc_metadata_value( $new_value['iptc_value'], $metadata );
2795
-
2796
- if ( 'template:' == substr( $new_value['exif_value'], 0, 9 ) ) {
 
 
 
2797
  $data_value = array(
2798
- 'name' => $new_key,
2799
  'data_source' => 'template',
2800
- 'meta_name' => substr( $new_value['exif_value'], 9 ),
2801
- 'keep_existing' => $new_value['keep_existing'],
2802
  'format' => 'native',
2803
  'option' => 'text' );
2804
-
2805
- $exif_value = self::_evaluate_data_source( $post->ID, 'single_attachment_mapping', $data_value, $metadata );
 
 
2806
  }
2807
- else
2808
- $exif_value = MLAData::mla_exif_metadata_value( $new_value['exif_value'], $metadata );
2809
-
2810
- if ( $new_value['iptc_first'] )
2811
- if ( ! empty( $iptc_value ) )
2812
  $new_text = $iptc_value;
2813
- else
2814
  $new_text = $exif_value;
2815
- else
2816
- if ( ! empty( $exif_value ) )
 
2817
  $new_text = $exif_value;
2818
- else
2819
  $new_text = $iptc_value;
 
 
2820
 
2821
  if ( is_array( $new_text ) ) {
2822
  $new_text = implode( ',', $new_text );
2823
  }
2824
-
2825
- if ( $new_value['keep_existing'] ) {
2826
- if ( 'meta:' == substr( $new_key, 0, 5 ) ) {
2827
- $meta_key = substr( $new_key, 5 );
2828
- $attachment_metadata = maybe_unserialize( get_metadata( 'post', $post->ID, '_wp_attachment_metadata', true ) );
2829
- if ( array( $attachment_metadata ) )
 
 
 
 
2830
  $old_value = MLAData::mla_find_array_element( $meta_key, $attachment_metadata, 'array' );
2831
- else
2832
  $old_value = '';
2833
- }
2834
- else {
2835
- if ( is_string( $old_value = get_metadata( 'post', $post->ID, $new_key, true ) ) )
2836
  $old_value = trim( $old_value );
 
2837
  }
2838
-
2839
  if ( ( ! empty( $new_text ) ) && empty( $old_value ) ) {
2840
- $custom_updates[ $new_key ] = $new_text;
2841
  }
2842
  } // keep_existing
2843
  else {
2844
- $custom_updates[ $new_key ] = $new_text;
2845
  }
2846
  } // foreach new setting
2847
-
2848
- if ( ! empty( $custom_updates ) )
2849
  $updates['custom_updates'] = $custom_updates;
 
2850
  } // update custom field mappings
2851
 
 
2852
  return $updates;
2853
  } // mla_evaluate_iptc_exif_mapping
2854
-
2855
  /**
2856
  * Compose an IPTC Options list with current selection
2857
  *
@@ -2867,9 +3277,9 @@ class MLAOptions {
2867
  $option_values = array (
2868
  'selected' => ( 'none' == $selection ) ? 'selected="selected"' : '',
2869
  'value' => 'none',
2870
- 'text' => ' -- None (select a value) -- '
2871
  );
2872
-
2873
  $iptc_options = MLAData::mla_parse_template( $option_template, $option_values );
2874
  foreach ( MLAData::$mla_iptc_keys as $iptc_name => $iptc_code ) {
2875
  $option_values = array (
@@ -2877,13 +3287,13 @@ class MLAOptions {
2877
  'value' => $iptc_code,
2878
  'text' => $iptc_code . ' ' . $iptc_name
2879
  );
2880
-
2881
  $iptc_options .= MLAData::mla_parse_template( $option_template, $option_values );
2882
  } // foreach iptc_key
2883
-
2884
  return $iptc_options;
2885
  } // _compose_iptc_option_list
2886
-
2887
  /**
2888
  * Compose an hierarchical taxonomy Parent options list with current selection
2889
  *
@@ -2896,29 +3306,41 @@ class MLAOptions {
2896
  * @return string HTML markup with select field options
2897
  */
2898
  private static function _compose_parent_option_list( $taxonomy, $selection = 0 ) {
2899
- $option_template = self::$mla_option_templates['iptc-exif-select-option'];
2900
- $option_values = array (
2901
- 'selected' => ( 0 == $selection ) ? 'selected="selected"' : '',
2902
- 'value' => 0,
2903
- 'text' => ' -- None (select a value) -- '
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2904
  );
2905
-
2906
- $parent_options = MLAData::mla_parse_template( $option_template, $option_values );
2907
-
2908
- $terms = get_terms( $taxonomy, array( 'orderby' => 'name', 'get' => 'all' ) );
2909
- foreach ( $terms as $term ) {
2910
- $option_values = array (
2911
- 'selected' => ( $term->term_id == $selection ) ? 'selected="selected"' : '',
2912
- 'value' => $term->term_id,
2913
- 'text' => $term->name
2914
- );
2915
-
2916
- $parent_options .= MLAData::mla_parse_template( $option_template, $option_values );
2917
- } // foreach iptc_key
2918
-
2919
- return $parent_options;
2920
  } // _compose_parent_option_list
2921
-
2922
  /**
2923
  * Update Standard field portion of IPTC/EXIF mappings
2924
  *
@@ -2938,58 +3360,72 @@ class MLAOptions {
2938
  if ( isset( $current_values['standard'][ $new_key ] ) ) {
2939
  $old_values = $current_values['standard'][ $new_key ];
2940
  $any_setting_changed = false;
2941
- }
2942
- else {
2943
- $error_list .= "<br>ERROR: No old values for {$new_key}.\r\n";
2944
  continue;
2945
  }
 
 
 
 
 
2946
 
 
 
 
 
 
 
 
2947
  if ( $old_values['iptc_value'] != $new_value['iptc_value'] ) {
2948
  $any_setting_changed = true;
2949
- $message_list .= "<br>{$old_values['name']} changing IPTC Value from {$old_values['iptc_value']} to {$new_value['iptc_value']}.\r\n";
 
2950
  $old_values['iptc_value'] = $new_value['iptc_value'];
2951
  }
2952
 
2953
  if ( $old_values['exif_value'] != $new_value['exif_value'] ) {
2954
  $any_setting_changed = true;
2955
- $message_list .= "<br>{$old_values['name']} changing EXIF Value from {$old_values['exif_value']} to {$new_value['exif_value']}.\r\n";
 
2956
  $old_values['exif_value'] = $new_value['exif_value'];
2957
  }
2958
 
2959
  if ( $new_value['iptc_first'] ) {
2960
  $boolean_value = true;
2961
- $boolean_text = 'EXIF to IPTC';
2962
- }
2963
- else {
2964
  $boolean_value = false;
2965
- $boolean_text = 'IPTC to EXIF';
2966
  }
2967
  if ( $old_values['iptc_first'] != $boolean_value ) {
2968
  $any_setting_changed = true;
2969
- $message_list .= "<br>{$old_values['name']} changing Priority Value from {$boolean_text}.\r\n";
 
2970
  $old_values['iptc_first'] = $boolean_value;
2971
  }
2972
 
2973
  if ( $new_value['keep_existing'] ) {
2974
  $boolean_value = true;
2975
- $boolean_text = 'Replace to Keep';
2976
- }
2977
- else {
2978
  $boolean_value = false;
2979
- $boolean_text = 'Keep to Replace';
2980
  }
2981
  if ( $old_values['keep_existing'] != $boolean_value ) {
2982
  $any_setting_changed = true;
2983
- $message_list .= "<br>{$old_values['name']} changing Existing Text Value from {$boolean_text}.\r\n";
 
2984
  $old_values['keep_existing'] = $boolean_value;
2985
  }
2986
-
2987
  if ( $any_setting_changed ) {
2988
  $settings_changed = true;
2989
  $current_values['standard'][ $new_key ] = $old_values;
2990
  }
2991
  } // new standard value
2992
-
2993
  /*
2994
  * Uncomment this for debugging.
2995
  */
@@ -2997,7 +3433,7 @@ class MLAOptions {
2997
 
2998
  return array( 'message' => $error_list, 'values' => $current_values, 'changed' => $settings_changed );
2999
  } // _update_iptc_exif_standard_mapping
3000
-
3001
  /**
3002
  * Update Taxonomy term portion of IPTC/EXIF mappings
3003
  *
@@ -3016,8 +3452,7 @@ class MLAOptions {
3016
  foreach ( $new_values['taxonomy'] as $new_key => $new_value ) {
3017
  if ( isset( $current_values['taxonomy'][ $new_key ] ) ) {
3018
  $old_values = $current_values['taxonomy'][ $new_key ];
3019
- }
3020
- else {
3021
  $old_values = array(
3022
  'name' => $new_value['name'],
3023
  'hierarchical' => $new_value['hierarchical'],
@@ -3029,57 +3464,61 @@ class MLAOptions {
3029
  'parent' => 0
3030
  );
3031
  }
3032
-
3033
  $any_setting_changed = false;
3034
  if ( $old_values['iptc_value'] != $new_value['iptc_value'] ) {
3035
  $any_setting_changed = true;
3036
- $message_list .= "<br>{$old_values['name']} changing IPTC Value from {$old_values['iptc_value']} to {$new_value['iptc_value']}.\r\n";
 
3037
  $old_values['iptc_value'] = $new_value['iptc_value'];
3038
  }
3039
 
3040
  if ( $old_values['exif_value'] != $new_value['exif_value'] ) {
3041
  $any_setting_changed = true;
3042
- $message_list .= "<br>{$old_values['name']} changing EXIF Value from {$old_values['exif_value']} to {$new_value['exif_value']}.\r\n";
 
3043
  $old_values['exif_value'] = $new_value['exif_value'];
3044
  }
3045
 
3046
  if ( $new_value['iptc_first'] ) {
3047
  $boolean_value = true;
3048
- $boolean_text = 'EXIF to IPTC';
3049
- }
3050
- else {
3051
  $boolean_value = false;
3052
- $boolean_text = 'IPTC to EXIF';
3053
  }
3054
  if ( $old_values['iptc_first'] != $boolean_value ) {
3055
  $any_setting_changed = true;
3056
- $message_list .= "<br>{$old_values['name']} changing Priority Value from {$boolean_text}.\r\n";
 
3057
  $old_values['iptc_first'] = $boolean_value;
3058
  }
3059
 
3060
  if ( $new_value['keep_existing'] ) {
3061
  $boolean_value = true;
3062
- $boolean_text = 'Replace to Keep';
3063
- }
3064
- else {
3065
  $boolean_value = false;
3066
- $boolean_text = 'Keep to Replace';
3067
  }
3068
  if ( $old_values['keep_existing'] != $boolean_value ) {
3069
  $any_setting_changed = true;
3070
- $message_list .= "<br>{$old_values['name']} changing Existing Text Value from {$boolean_text}.\r\n";
 
3071
  $old_values['keep_existing'] = $boolean_value;
3072
  }
3073
-
3074
  if ( $old_values['delimiters'] != $new_value['delimiters'] ) {
3075
  $any_setting_changed = true;
3076
- $message_list .= "<br>{$old_values['name']} changing Delimiter(s) from '{$old_values['delimiters']}' to '{$new_value['delimiters']}'.\r\n";
 
3077
  $old_values['delimiters'] = $new_value['delimiters'];
3078
  }
3079
 
3080
  if ( isset( $new_value['parent'] ) && ( $old_values['parent'] != $new_value['parent'] ) ) {
3081
  $any_setting_changed = true;
3082
- $message_list .= "<br>{$old_values['name']} changing Parent from {$old_values['parent']} to {$new_value['parent']}.\r\n";
 
3083
  $old_values['parent'] = $new_value['parent'];
3084
  }
3085
 
@@ -3096,7 +3535,7 @@ class MLAOptions {
3096
 
3097
  return array( 'message' => $error_list, 'values' => $current_values, 'changed' => $settings_changed );
3098
  } // _update_iptc_exif_taxonomy_mapping
3099
-
3100
  /**
3101
  * Update Custom field portion of IPTC/EXIF mappings
3102
  *
@@ -3115,39 +3554,42 @@ class MLAOptions {
3115
 
3116
  foreach ( $new_values['custom'] as $new_key => $new_value ) {
3117
  $any_setting_changed = false;
3118
-
3119
  /*
3120
  * Check for the addition of a new field or new rule
3121
  */
3122
  if ( self::MLA_NEW_CUSTOM_FIELD == $new_key ) {
3123
  $new_key = trim( $new_value['name'] );
3124
 
3125
- if ( empty( $new_key ) )
3126
  continue;
3127
-
 
3128
  if ( in_array( $new_key, $custom_field_names ) ) {
3129
- $error_list .= "<br>ERROR: new field {$new_key} already exists.\r\n";
 
3130
  continue;
3131
  }
3132
 
3133
- $message_list .= "<br>Adding new field {$new_key}.\r\n";
 
3134
  $any_setting_changed = true;
3135
- }
3136
- elseif ( self::MLA_NEW_CUSTOM_RULE == $new_key ) {
3137
  $new_key = trim( $new_value['name'] );
3138
 
3139
- if ( 'none' == $new_key )
3140
  continue;
 
3141
 
3142
- $message_list .= "<br>Adding new rule for {$new_key}.\r\n";
 
3143
  $any_setting_changed = true;
3144
  }
3145
-
3146
  if ( isset( $current_values['custom'][ $new_key ] ) ) {
3147
  $old_values = $current_values['custom'][ $new_key ];
3148
  $any_setting_changed = false;
3149
- }
3150
- else {
3151
  $old_values = array(
3152
  'name' => $new_key,
3153
  'iptc_value' => 'none',
@@ -3156,11 +3598,12 @@ class MLAOptions {
3156
  'keep_existing' => true
3157
  );
3158
  }
3159
-
3160
  if ( isset( $new_value['action'] ) ) {
3161
  if ( array_key_exists( 'delete_rule', $new_value['action'] ) || array_key_exists( 'delete_field', $new_value['action'] ) ) {
3162
  $settings_changed = true;
3163
- $message_list .= "<br>deleting rule for {$old_values['name']}.\r\n";
 
3164
  unset( $current_values['custom'][ $new_key ] );
3165
  $settings_changed = true;
3166
  continue;
@@ -3169,50 +3612,52 @@ class MLAOptions {
3169
 
3170
  if ( $old_values['iptc_value'] != $new_value['iptc_value'] ) {
3171
  $any_setting_changed = true;
3172
- $message_list .= "<br>{$old_values['name']} changing IPTC Value from {$old_values['iptc_value']} to {$new_value['iptc_value']}.\r\n";
 
3173
  $old_values['iptc_value'] = $new_value['iptc_value'];
3174
  }
3175
 
3176
  if ( $old_values['exif_value'] != $new_value['exif_value'] ) {
3177
  $any_setting_changed = true;
3178
- $message_list .= "<br>{$old_values['name']} changing EXIF Value from {$old_values['exif_value']} to {$new_value['exif_value']}.\r\n";
 
3179
  $old_values['exif_value'] = $new_value['exif_value'];
3180
  }
3181
 
3182
  if ( $new_value['iptc_first'] ) {
3183
  $boolean_value = true;
3184
- $boolean_text = 'EXIF to IPTC';
3185
- }
3186
- else {
3187
  $boolean_value = false;
3188
- $boolean_text = 'IPTC to EXIF';
3189
  }
3190
  if ( $old_values['iptc_first'] != $boolean_value ) {
3191
  $any_setting_changed = true;
3192
- $message_list .= "<br>{$old_values['name']} changing Priority Value from {$boolean_text}.\r\n";
 
3193
  $old_values['iptc_first'] = $boolean_value;
3194
  }
3195
 
3196
  if ( $new_value['keep_existing'] ) {
3197
  $boolean_value = true;
3198
- $boolean_text = 'Replace to Keep';
3199
- }
3200
- else {
3201
  $boolean_value = false;
3202
- $boolean_text = 'Keep to Replace';
3203
  }
3204
  if ( $old_values['keep_existing'] != $boolean_value ) {
3205
  $any_setting_changed = true;
3206
- $message_list .= "<br>{$old_values['name']} changing Existing Text Value from {$boolean_text}.\r\n";
 
3207
  $old_values['keep_existing'] = $boolean_value;
3208
  }
3209
-
3210
  if ( $any_setting_changed ) {
3211
  $settings_changed = true;
3212
  $current_values['custom'][ $new_key ] = $old_values;
3213
  }
3214
  } // new standard value
3215
-
3216
  /*
3217
  * Uncomment this for debugging.
3218
  */
@@ -3220,7 +3665,7 @@ class MLAOptions {
3220
 
3221
  return array( 'message' => $error_list, 'values' => $current_values, 'changed' => $settings_changed );
3222
  } // _update_iptc_exif_custom_mapping
3223
-
3224
  /**
3225
  * Generate a list of all (post) Custom Field names
3226
  *
@@ -3233,7 +3678,7 @@ class MLAOptions {
3233
  */
3234
  private static function _get_custom_field_names( ) {
3235
  global $wpdb;
3236
-
3237
  $custom_field_mapping = array_keys( self::mla_get_option( 'custom_field_mapping' ) );
3238
  $iptc_exif_mapping = self::mla_get_option( 'iptc_exif_mapping' );
3239
  $iptc_exif_mapping = array_keys( $iptc_exif_mapping['custom'] );
@@ -3246,22 +3691,24 @@ class MLAOptions {
3246
  HAVING meta_key NOT LIKE '\_%'
3247
  ORDER BY meta_key
3248
  LIMIT $limit" );
3249
-
3250
  if ( $keys ) {
3251
  foreach ( $custom_field_mapping as $value )
3252
- if ( ! in_array( $value, $keys ) )
3253
  $keys[] = $value;
3254
-
 
3255
  foreach ( $iptc_exif_mapping as $value )
3256
- if ( ! in_array( $value, $keys ) )
3257
  $keys[] = $value;
3258
-
 
3259
  natcasesort($keys);
3260
  }
3261
-
3262
  return $keys;
3263
  } // _get_custom_field_names
3264
-
3265
  /**
3266
  * Render and manage iptc/exif support options
3267
  *
@@ -3280,12 +3727,12 @@ class MLAOptions {
3280
 
3281
  switch ( $action ) {
3282
  case 'render':
3283
-
3284
  switch ( $key ) {
3285
  case 'iptc_exif_standard_mapping':
3286
  $row_template = self::$mla_option_templates['iptc-exif-standard-row'];
3287
  $table_rows = '';
3288
-
3289
  foreach ( $current_values['standard'] as $row_name => $row_value ) {
3290
  $row_values = array (
3291
  'key' => $row_name,
@@ -3294,36 +3741,47 @@ class MLAOptions {
3294
  'exif_size' => self::MLA_EXIF_SIZE,
3295
  'exif_text' => $row_value['exif_value'],
3296
  'iptc_selected' => '',
 
3297
  'exif_selected' => '',
 
3298
  'keep_selected' => '',
3299
- 'replace_selected' => ''
 
 
3300
  );
3301
-
3302
- if ( $row_value['iptc_first'] )
3303
  $row_values['iptc_selected'] = 'selected="selected"';
3304
- else
3305
  $row_values['exif_selected'] = 'selected="selected"';
3306
-
3307
- if ( $row_value['keep_existing'] )
 
3308
  $row_values['keep_selected'] = 'selected="selected"';
3309
- else
3310
  $row_values['replace_selected'] = 'selected="selected"';
 
3311
 
3312
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
3313
  } // foreach row
3314
-
3315
  $option_values = array (
 
 
 
 
 
3316
  'table_rows' => $table_rows,
3317
  'help' => $value['help']
3318
  );
3319
-
3320
  return MLAData::mla_parse_template( self::$mla_option_templates['iptc-exif-standard-table'], $option_values );
3321
  case 'iptc_exif_taxonomy_mapping':
3322
  $row_template = self::$mla_option_templates['iptc-exif-taxonomy-row'];
3323
  $select_template = self::$mla_option_templates['iptc-exif-select'];
3324
  $table_rows = '';
3325
  $taxonomies = get_taxonomies( array ( 'show_ui' => true ), 'objects' );
3326
-
3327
  foreach ( $taxonomies as $row_name => $row_value ) {
3328
  $row_values = array (
3329
  'key' => $row_name,
@@ -3333,28 +3791,34 @@ class MLAOptions {
3333
  'exif_size' => self::MLA_EXIF_SIZE,
3334
  'exif_text' => '',
3335
  'iptc_selected' => '',
 
3336
  'exif_selected' => '',
 
3337
  'keep_selected' => '',
 
3338
  'replace_selected' => '',
 
3339
  'delimiters_size' => 4,
3340
  'delimiters_text' => '',
3341
  'parent_select' => ''
3342
  );
3343
-
3344
  if ( array_key_exists( $row_name, $current_values['taxonomy'] ) ) {
3345
  $current_value = $current_values['taxonomy'][ $row_name ];
3346
  $row_values['iptc_field_options'] = self::_compose_iptc_option_list( $current_value['iptc_value'] );
3347
  $row_values['exif_text'] = $current_value['exif_value'];
3348
-
3349
- if ( $current_value['iptc_first'] )
3350
  $row_values['iptc_selected'] = 'selected="selected"';
3351
- else
3352
  $row_values['exif_selected'] = 'selected="selected"';
3353
-
3354
- if ( $current_value['keep_existing'] )
 
3355
  $row_values['keep_selected'] = 'selected="selected"';
3356
- else
3357
  $row_values['replace_selected'] = 'selected="selected"';
 
3358
 
3359
  $row_values['delimiters_text'] = $current_value['delimiters'];
3360
 
@@ -3368,8 +3832,7 @@ class MLAOptions {
3368
  );
3369
  $row_values['parent_select'] = MLAData::mla_parse_template( $select_template, $select_values );
3370
  }
3371
- }
3372
- else {
3373
  $row_values['iptc_field_options'] = self::_compose_iptc_option_list( 'none' );
3374
  $row_values['iptc_selected'] = 'selected="selected"';
3375
  $row_values['keep_selected'] = 'selected="selected"';
@@ -3387,18 +3850,27 @@ class MLAOptions {
3387
 
3388
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
3389
  } // foreach row
3390
-
3391
  $option_values = array (
 
 
 
 
 
 
 
3392
  'table_rows' => $table_rows,
3393
  'help' => $value['help']
3394
  );
3395
-
3396
  return MLAData::mla_parse_template( self::$mla_option_templates['iptc-exif-taxonomy-table'], $option_values );
3397
  case 'iptc_exif_custom_mapping':
3398
  if ( empty( $current_values['custom'] ) ) {
3399
- $table_rows = MLAData::mla_parse_template( self::$mla_option_templates['iptc-exif-custom-empty-row'], array( 'column_count' => 5 ) );
3400
- }
3401
- else {
 
 
3402
  $row_template = self::$mla_option_templates['iptc-exif-custom-rule-row'];
3403
  $table_rows = '';
3404
  }
@@ -3416,23 +3888,33 @@ class MLAOptions {
3416
  'exif_size' => self::MLA_EXIF_SIZE,
3417
  'exif_text' => '',
3418
  'iptc_selected' => '',
 
3419
  'exif_selected' => '',
 
3420
  'keep_selected' => '',
3421
- 'replace_selected' => ''
 
 
 
 
 
 
3422
  );
3423
-
3424
  $row_values['iptc_field_options'] = self::_compose_iptc_option_list( $current_value['iptc_value'] );
3425
  $row_values['exif_text'] = $current_value['exif_value'];
3426
-
3427
- if ( $current_value['iptc_first'] )
3428
  $row_values['iptc_selected'] = 'selected="selected"';
3429
- else
3430
  $row_values['exif_selected'] = 'selected="selected"';
3431
-
3432
- if ( $current_value['keep_existing'] )
 
3433
  $row_values['keep_selected'] = 'selected="selected"';
3434
- else
3435
  $row_values['replace_selected'] = 'selected="selected"';
 
3436
 
3437
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
3438
  } // foreach existing rule
@@ -3443,50 +3925,70 @@ class MLAOptions {
3443
  $row_template = self::$mla_option_templates['iptc-exif-custom-new-rule-row'];
3444
  $row_values = array (
3445
  'column_count' => 5 ,
 
3446
  'key' => self::MLA_NEW_CUSTOM_RULE,
3447
  'field_name_options' => self::_compose_custom_field_option_list( 'none', $current_values['custom'] ),
3448
  'iptc_field_options' => self::_compose_iptc_option_list( 'none' ),
3449
  'exif_size' => self::MLA_EXIF_SIZE,
3450
  'exif_text' => '',
3451
  'iptc_selected' => 'selected="selected"',
 
3452
  'exif_selected' => '',
 
3453
  'keep_selected' => 'selected="selected"',
3454
- 'replace_selected' => ''
 
 
 
 
3455
  );
3456
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
3457
-
3458
  /*
3459
  * Add a row for defining a new rule, new Custom Field
3460
  */
3461
  $row_template = self::$mla_option_templates['iptc-exif-custom-new-field-row'];
3462
  $row_values = array (
3463
  'column_count' => 5 ,
 
3464
  'key' => self::MLA_NEW_CUSTOM_FIELD,
3465
  'field_name_size' => '24',
3466
  'iptc_field_options' => self::_compose_iptc_option_list( 'none' ),
3467
  'exif_size' => self::MLA_EXIF_SIZE,
3468
  'exif_text' => '',
3469
  'iptc_selected' => 'selected="selected"',
 
3470
  'exif_selected' => '',
 
3471
  'keep_selected' => 'selected="selected"',
3472
- 'replace_selected' => ''
 
 
 
 
3473
  );
3474
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
3475
-
3476
  $option_values = array (
 
 
 
 
 
3477
  'table_rows' => $table_rows,
3478
  'help' => $value['help']
3479
  );
3480
-
3481
  return MLAData::mla_parse_template( self::$mla_option_templates['iptc-exif-custom-table'], $option_values );
3482
  default:
3483
- return "<br>ERROR: Render unknown custom {$key}\r\n";
 
3484
  } // switch $key
3485
  case 'update':
3486
  case 'delete':
3487
  $settings_changed = false;
3488
  $messages = '';
3489
-
3490
  switch ( $key ) {
3491
  case 'iptc_exif_standard_mapping':
3492
  $results = self::_update_iptc_exif_standard_mapping( $current_values, $args );
@@ -3511,7 +4013,7 @@ class MLAOptions {
3511
  $messages .= $results['message'];
3512
  $current_values = $results['values'];
3513
  $settings_changed = $results['changed'];
3514
-
3515
  $results = self::_update_iptc_exif_taxonomy_mapping( $current_values, $args );
3516
  $messages .= $results['message'];
3517
  $current_values = $results['values'];
@@ -3523,18 +4025,20 @@ class MLAOptions {
3523
  $settings_changed |= $results['changed'];
3524
  break;
3525
  default:
3526
- return "<br>ERROR: Update/delete unknown custom {$key}\r\n";
 
3527
  } // switch $key
3528
-
3529
  if ( $settings_changed ) {
3530
  $settings_changed = MLAOptions::mla_update_option( 'iptc_exif_mapping', $current_values );
3531
- if ( $settings_changed )
3532
- $results = "IPTC/EXIF mapping settings updated.\r\n";
3533
- else
3534
- $results = "ERROR: IPTC/EXIF settings update failed.\r\n";
 
 
 
3535
  }
3536
- else
3537
- $results = "IPTC/EXIF no mapping changes detected.\r\n";
3538
 
3539
  return $results . $messages;
3540
  case 'reset':
@@ -3542,32 +4046,44 @@ class MLAOptions {
3542
  case 'iptc_exif_standard_mapping':
3543
  $current_values['standard'] = self::$mla_option_definitions['iptc_exif_mapping']['std']['standard'];
3544
  $settings_changed = MLAOptions::mla_update_option( 'iptc_exif_mapping', $current_values );
3545
- if ( $settings_changed )
3546
- return "IPTC/EXIF Standard field settings saved.\r\n";
3547
- else
3548
- return "ERROR: IPTC/EXIF Standard field settings update failed.\r\n";
 
 
 
3549
  case 'iptc_exif_taxonomy_mapping':
3550
  $current_values['taxonomy'] = self::$mla_option_definitions['iptc_exif_mapping']['std']['taxonomy'];
3551
  $settings_changed = MLAOptions::mla_update_option( 'iptc_exif_mapping', $current_values );
3552
- if ( $settings_changed )
3553
- return "IPTC/EXIF Taxonomy term settings saved.\r\n";
3554
- else
3555
- return "ERROR: IPTC/EXIF Taxonomy term settings update failed.\r\n";
 
 
 
3556
  case 'iptc_exif_custom_mapping':
3557
  $current_values['custom'] = self::$mla_option_definitions['iptc_exif_mapping']['std']['custom'];
3558
  $settings_changed = MLAOptions::mla_update_option( 'iptc_exif_mapping', $current_values );
3559
- if ( $settings_changed )
3560
- return "IPTC/EXIF Custom field settings saved.\r\n";
3561
- else
3562
- return "ERROR: IPTC/EXIF Custom field settings reset failed.\r\n";
 
 
 
3563
  case 'iptc_exif_mapping':
3564
  self::mla_delete_option( $key );
3565
- return "<br>Reset custom {$key}\r\n";
 
3566
  default:
3567
- return "<br>ERROR: Reset unknown custom {$key}\r\n";
 
3568
  } // switch $key
3569
  default:
3570
- return "<br>ERROR: Custom {$key} unknown action: {$action}\r\n";
 
3571
  } // switch $action
3572
  } // mla_iptc_exif_option_handler
3573
  } // class MLAOptions
20
  * Provides a unique name for the current version option
21
  */
22
  const MLA_VERSION_OPTION = 'current_version';
23
+
24
  /**
25
  * Provides a unique name for the exclude revisions option
26
  */
45
  * Provides a unique name for a database tuning option
46
  */
47
  const MLA_MLA_GALLERY_IN_TUNING = 'mla_gallery_in_tuning';
48
+
49
  /**
50
  * Provides a unique name for the taxonomy support option
51
  */
52
  const MLA_TAXONOMY_SUPPORT = 'taxonomy_support';
53
+
54
  /**
55
  * Provides a unique name for the admin screen page title option
56
  */
57
  const MLA_SCREEN_PAGE_TITLE = 'admin_screen_page_title';
58
+
59
  /**
60
  * Provides a unique name for the admin screen menu title option
61
  */
62
  const MLA_SCREEN_MENU_TITLE = 'admin_screen_menu_title';
63
+
64
  /**
65
  * Provides a unique name for the admin screen menu order option
66
  */
67
  const MLA_SCREEN_ORDER = 'admin_screen_menu_order';
68
+
69
  /**
70
  * Provides a unique name for the admin screen remove Media/Library option
71
  */
72
  const MLA_SCREEN_DISPLAY_LIBRARY = 'admin_screen_display_default';
73
+
74
  /**
75
  * Provides a unique name for the default orderby option
76
  */
77
  const MLA_DEFAULT_ORDERBY = 'default_orderby';
78
+
79
  /**
80
  * Provides a unique name for the default order option
81
  */
82
  const MLA_DEFAULT_ORDER = 'default_order';
83
+
84
  /**
85
  * Provides a unique name for the default table views width option
86
  */
87
  const MLA_TABLE_VIEWS_WIDTH = 'table_views_width';
88
+
89
  /**
90
  * Provides a unique name for the taxonomy filter maximum depth option
91
  */
92
  const MLA_TAXONOMY_FILTER_DEPTH = 'taxonomy_filter_depth';
93
+
94
  /**
95
  * Provides a unique name for the taxonomy filter maximum depth option
96
  */
97
  const MLA_TAXONOMY_FILTER_INCLUDE_CHILDREN = 'taxonomy_filter_include_children';
98
+
99
  /**
100
  * Provides a "size" attribute value for the EXIF/Template Value field
101
  */
102
  const MLA_EXIF_SIZE = 30;
103
+
104
  /**
105
  * Provides a unique name for the Custom Field "new rule" key
106
  */
107
  const MLA_NEW_CUSTOM_RULE = '__NEW RULE__';
108
+
109
  /**
110
  * Provides a unique name for the Custom Field "new field" key
111
  */
112
  const MLA_NEW_CUSTOM_FIELD = '__NEW FIELD__';
113
+
114
  /**
115
  * Provides a unique name for the Media Manager toolbar option
116
  */
117
  const MLA_MEDIA_MODAL_TOOLBAR = 'media_modal_toolbar';
118
+
119
  /**
120
  * Provides a unique name for the Media Manager toolbar MIME Types option
121
  */
122
  const MLA_MEDIA_MODAL_MIMETYPES = 'media_modal_mimetypes';
123
+
124
  /**
125
  * Provides a unique name for the Media Manager toolbar Month and Year option
126
  */
127
  const MLA_MEDIA_MODAL_MONTHS = 'media_modal_months';
128
+
129
  /**
130
  * Provides a unique name for the Media Manager toolbar Taxonomy Terms option
131
  */
132
  const MLA_MEDIA_MODAL_TERMS = 'media_modal_terms';
133
+
134
  /**
135
  * Provides a unique name for the Media Manager toolbar Search Box option
136
  */
137
  const MLA_MEDIA_MODAL_SEARCHBOX = 'media_modal_searchbox';
138
+
139
  /**
140
  * Provides a unique name for the Media Manager Attachment Details searchable taxonomy option
141
  * This option is for hierarchical taxonomies, e.g., "Att. Categories".
142
  */
143
  const MLA_MEDIA_MODAL_DETAILS_CATEGORY_METABOX = 'media_modal_details_category_metabox';
144
+
145
  /**
146
  * Provides a unique name for the Media Manager Attachment Details searchable taxonomy option
147
  * This option is for flat taxonomies, e.g., "Att. Tags".
148
  */
149
  const MLA_MEDIA_MODAL_DETAILS_TAG_METABOX = 'media_modal_details_tag_metabox';
150
+
151
  /**
152
  * Provides a unique name for the Media Manager orderby option
153
  */
154
  const MLA_MEDIA_MODAL_ORDERBY = 'media_modal_orderby';
155
+
156
  /**
157
  * Provides a unique name for the Media Manager order option
158
  */
159
  const MLA_MEDIA_MODAL_ORDER = 'media_modal_order';
160
+
161
  /**
162
  * Provides a unique name for the Post MIME Types option
163
  */
164
  const MLA_POST_MIME_TYPES = 'post_mime_types';
165
+
166
  /**
167
  * Provides a unique name for the Enable Post MIME Types option
168
  */
169
  const MLA_ENABLE_POST_MIME_TYPES = 'enable_post_mime_types';
170
+
171
  /**
172
  * Provides a unique name for the Upload MIME Types option
173
  */
174
  const MLA_UPLOAD_MIMES = 'upload_mimes';
175
+
176
  /**
177
  * Provides a unique name for the Enable Upload MIME Types option
178
  */
179
  const MLA_ENABLE_UPLOAD_MIMES = 'enable_upload_mimes';
180
+
181
  /**
182
  * Provides a unique name for the Enable MLA Icons option
183
  */
184
  const MLA_ENABLE_MLA_ICONS = 'enable_mla_icons';
185
+
186
  /**
187
  * Option setting for "Featured in" reporting
188
  *
228
  public static $process_mla_gallery_in = true;
229
 
230
  /**
231
+ * $mla_option_definitions defines the database options and admin page areas for setting/updating them
232
+ *
233
+ * The array must be populated at runtime in MLAOptions::mla_localize_option_definitions_array(),
234
+ * because Localization calls cannot be placed in the "public static" array definition itself.
235
+ *
236
  * Each option is defined by an array with the following elements:
237
  *
238
  * array key => HTML id/name attribute and option database key (OMIT MLA_OPTION_PREFIX)
256
  * reset => reset function for 'custom' options; returns nothing. Usage:
257
  * $message = ['reset']( 'reset', $key, $value, $_REQUEST );
258
  */
259
+
260
+ public static $mla_option_definitions = array ();
261
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  /**
263
  * Initialization function, similar to __construct()
264
  *
269
  public static function initialize( ) {
270
  self::_load_option_templates();
271
 
272
+ if ( 'disabled' == self::mla_get_option( self::MLA_FEATURED_IN_TUNING ) ) {
273
  self::$process_featured_in = false;
274
+ }
275
+
276
+ if ( 'disabled' == self::mla_get_option( self::MLA_INSERTED_IN_TUNING ) ) {
277
  self::$process_inserted_in = false;
278
+ }
279
+
280
+ if ( 'disabled' == self::mla_get_option( self::MLA_GALLERY_IN_TUNING ) ) {
281
  self::$process_gallery_in = false;
282
+ }
283
+
284
+ if ( 'disabled' == self::mla_get_option( self::MLA_MLA_GALLERY_IN_TUNING ) ) {
285
  self::$process_mla_gallery_in = false;
286
+ }
 
 
287
 
288
+ if ( ( 'checked' == MLAOptions::mla_get_option( 'enable_iptc_exif_mapping' ) ) ||
289
+ ( 'checked' == MLAOptions::mla_get_option( 'enable_custom_field_mapping' ) ) ||
290
+ ( 'checked' == MLAOptions::mla_get_option( 'enable_iptc_exif_update' ) ) ||
291
+ ( 'checked' == MLAOptions::mla_get_option( 'enable_custom_field_update' ) ) ) {
292
+ add_filter( 'wp_handle_upload_prefilter', 'MLAOptions::mla_wp_handle_upload_prefilter_filter', 1, 1 );
293
+ add_filter( 'wp_handle_upload', 'MLAOptions::mla_wp_handle_upload_filter', 1, 1 );
294
+
295
+ add_action( 'add_attachment', 'MLAOptions::mla_add_attachment_action', 0x7FFFFFFF, 1 );
296
+ add_filter( 'wp_update_attachment_metadata', 'MLAOptions::mla_update_attachment_metadata_filter', 0x7FFFFFFF, 2 );
297
+ }
298
  }
299
+
300
  /**
301
  * Style and Markup templates
302
  *
305
  * @var array
306
  */
307
  private static $mla_option_templates = null;
308
+
309
  /**
310
  * Load style and markup templates to $mla_templates
311
  *
314
  * @return void
315
  */
316
  private static function _load_option_templates() {
317
+ self::$mla_option_templates = MLAData::mla_load_template( 'mla-option-templates.tpl' );
318
 
319
  /*
320
  * Load the default templates
321
  */
322
+ if ( is_null( self::$mla_option_templates ) ) {
323
+ MLAShortcodes::$mla_debug_messages .= '<p><strong>mla_debug _load_option_templates()</strong> ' . __( 'error loading tpls/mla-option-templates.tpl', 'media-library-assistant' );
324
  return;
325
+ } elseif ( !self::$mla_option_templates ) {
326
+ MLAShortcodes::$mla_debug_messages .= '<p><strong>mla_debug _load_option_templates()</strong> ' . __( 'tpls/mla-option-templates.tpl not found', 'media-library-assistant' );
 
327
  $mla_option_templates = null;
328
  return;
329
  }
350
  } // is_array
351
  }
352
 
353
+ /**
354
+ * Localize $mla_option_definitions array
355
+ *
356
+ * Localization must be done at runtime, and these calls cannot be placed
357
+ * in the "public static" array definition itself.
358
+ *
359
+ * @since 1.6x
360
+ *
361
+ * @return void
362
+ */
363
+ public static function mla_localize_option_definitions_array() {
364
+ self::$mla_option_definitions = array (
365
+ /*
366
+ * This option records the highest MLA version so-far installed
367
+ */
368
+ self::MLA_VERSION_OPTION =>
369
+ array('tab' => '',
370
+ 'type' => 'hidden',
371
+ 'std' => '0'),
372
+
373
+ /*
374
+ * These checkboxes are no longer used;
375
+ * they are retained for the database version/update check
376
+ */
377
+ 'attachment_category' =>
378
+ array('tab' => '',
379
+ 'name' => __( 'Attachment Categories', 'media-library-assistant' ),
380
+ 'type' => 'hidden', // checkbox',
381
+ 'std' => 'checked',
382
+ 'help' => __( 'Check this option to add support for Attachment Categories.', 'media-library-assistant' )),
383
+
384
+ 'attachment_tag' =>
385
+ array('tab' => '',
386
+ 'name' => __( 'Attachment Tags', 'media-library-assistant' ),
387
+ 'type' => 'hidden', // checkbox',
388
+ 'std' => 'checked',
389
+ 'help' => __( 'Check this option to add support for Attachment Tags.'), 'media-library-assistant' ),
390
+
391
+ 'where_used_header' =>
392
+ array('tab' => 'general',
393
+ 'name' => __( 'Where-used Reporting', 'media-library-assistant' ),
394
+ 'type' => 'header'),
395
+
396
+ self::MLA_EXCLUDE_REVISIONS =>
397
+ array('tab' => 'general',
398
+ 'name' => __( 'Exclude Revisions', 'media-library-assistant' ),
399
+ 'type' => 'checkbox',
400
+ 'std' => 'checked',
401
+ 'help' => __( 'Check this option to exclude revisions from where-used reporting.', 'media-library-assistant' )),
402
+
403
+ 'where_used_subheader' =>
404
+ array('tab' => 'general',
405
+ 'name' => __( 'Where-used database access tuning', 'media-library-assistant' ),
406
+ 'type' => 'subheader'),
407
+
408
+ self::MLA_FEATURED_IN_TUNING =>
409
+ array('tab' => 'general',
410
+ 'name' => __( 'Featured in', 'media-library-assistant' ),
411
+ 'type' => 'select',
412
+ 'std' => 'enabled',
413
+ 'options' => array('enabled', 'disabled'),
414
+ 'texts' => array( __( 'Enabled', 'media-library-assistant' ), __( 'Disabled', 'media-library-assistant' ) ),
415
+ 'help' => __( 'Search database posts and pages for Featured Image attachments.', 'media-library-assistant' )),
416
+
417
+ self::MLA_INSERTED_IN_TUNING =>
418
+ array('tab' => 'general',
419
+ 'name' => __( 'Inserted in', 'media-library-assistant' ),
420
+ 'type' => 'select',
421
+ 'std' => 'base',
422
+ 'options' => array('enabled', 'base', 'disabled'),
423
+ 'texts' => array( __( 'Enabled', 'media-library-assistant' ), __( 'Base', 'media-library-assistant' ), __( 'Disabled', 'media-library-assistant' ) ),
424
+ 'help' => __( 'Search database posts and pages for attachments embedded in content.<br>&nbsp;&nbsp;Base = ignore intermediate size suffixes; use path, base name and extension only.', 'media-library-assistant' )),
425
+
426
+ self::MLA_GALLERY_IN_TUNING =>
427
+ array('tab' => 'general',
428
+ 'name' => __( 'Gallery in', 'media-library-assistant' ),
429
+ 'type' => 'select',
430
+ 'std' => 'cached',
431
+ 'options' => array('dynamic', 'refresh', 'cached', 'disabled'),
432
+ 'texts' => array( __( 'Dynamic', 'media-library-assistant' ), __( 'Refresh', 'media-library-assistant' ), __( 'Cached', 'media-library-assistant' ), __( 'Disabled', 'media-library-assistant' ) ),
433
+ 'help' => __( 'Search database posts and pages for [gallery] shortcode results.<br>&nbsp;&nbsp;Dynamic = once every page load, Cached = once every login, Disabled = never.<br>&nbsp;&nbsp;Refresh = update references, then set to Cached.', 'media-library-assistant' )),
434
+
435
+ self::MLA_MLA_GALLERY_IN_TUNING =>
436
+ array('tab' => 'general',
437
+ 'name' => __( 'MLA Gallery in', 'media-library-assistant' ),
438
+ 'type' => 'select',
439
+ 'std' => 'cached',
440
+ 'options' => array('dynamic', 'refresh', 'cached', 'disabled'),
441
+ 'texts' => array( __( 'Dynamic', 'media-library-assistant' ), __( 'Refresh', 'media-library-assistant' ), __( 'Cached', 'media-library-assistant' ), __( 'Disabled', 'media-library-assistant' ) ),
442
+ 'help' => __( 'Search database posts and pages for [mla_gallery] shortcode results.<br>&nbsp;&nbsp;Dynamic = once every page load, Cached = once every login, Disabled = never.<br>&nbsp;&nbsp;Refresh = update references, then set to Cached.', 'media-library-assistant' )),
443
+
444
+ 'taxonomy_header' =>
445
+ array('tab' => 'general',
446
+ 'name' => __( 'Taxonomy Support', 'media-library-assistant' ),
447
+ 'type' => 'header'),
448
+
449
+ self::MLA_TAXONOMY_SUPPORT =>
450
+ array('tab' => 'general',
451
+ 'help' => __( 'Check the "Support" box to add the taxonomy to the Assistant and the Edit Media screen.<br>Check the "Inline Edit" box to display the taxonomy in the Quick Edit and Bulk Edit areas.<br>Use the "List Filter" option to select the taxonomy on which to filter the Assistant table listing.', 'media-library-assistant' ),
452
+ 'std' => array (
453
+ 'tax_support' => array (
454
+ 'attachment_category' => 'checked',
455
+ 'attachment_tag' => 'checked',
456
+ ),
457
+ 'tax_quick_edit' => array (
458
+ 'attachment_category' => 'checked',
459
+ 'attachment_tag' => 'checked',
460
+ ),
461
+ 'tax_filter' => 'attachment_category'
462
+ ),
463
+ 'type' => 'custom',
464
+ 'render' => 'mla_taxonomy_option_handler',
465
+ 'update' => 'mla_taxonomy_option_handler',
466
+ 'delete' => 'mla_taxonomy_option_handler',
467
+ 'reset' => 'mla_taxonomy_option_handler'),
468
+
469
+ 'attachments_column' =>
470
+ array('tab' => '',
471
+ 'name' => __( 'Attachments Column', 'media-library-assistant' ),
472
+ 'type' => 'hidden', // checkbox',
473
+ 'std' => 'checked',
474
+ 'help' => __( 'Check this option to replace the Posts column with the Attachments Column.', 'media-library-assistant' )),
475
+
476
+ 'media_assistant_header' =>
477
+ array('tab' => 'general',
478
+ 'name' => __( 'Media/Assistant Screen Options', 'media-library-assistant' ),
479
+ 'type' => 'header'),
480
+
481
+ 'admin_sidebar_subheader' =>
482
+ array('tab' => 'general',
483
+ 'name' => __( 'Admin Menu Options', 'media-library-assistant' ),
484
+ 'type' => 'subheader'),
485
+
486
+ self::MLA_SCREEN_PAGE_TITLE =>
487
+ array('tab' => 'general',
488
+ 'name' => __( 'Page Title', 'media-library-assistant' ),
489
+ 'type' => 'text',
490
+ 'std' => __( 'Media Library Assistant', 'media-library-assistant' ),
491
+ 'size' => 40,
492
+ 'help' => __( 'Enter the title for the Media/Assistant submenu page', 'media-library-assistant' )),
493
+
494
+ self::MLA_SCREEN_MENU_TITLE =>
495
+ array('tab' => 'general',
496
+ 'name' => __( 'Menu Title', 'media-library-assistant' ),
497
+ 'type' => 'text',
498
+ 'std' => __( 'Assistant', 'media-library-assistant' ),
499
+ 'size' => 20,
500
+ 'help' => __( 'Enter the title for the Media/Assistant submenu entry', 'media-library-assistant' )),
501
+
502
+ self::MLA_SCREEN_ORDER =>
503
+ array('tab' => 'general',
504
+ 'name' => __( 'Submenu Order', 'media-library-assistant' ),
505
+ 'type' => 'text',
506
+ 'std' => '0',
507
+ 'size' => 2,
508
+ 'help' => __( 'Enter the position of the Media/Assistant submenu entry.<br>&nbsp;&nbsp;0 = natural order (at bottom),&nbsp;&nbsp;&nbsp;&nbsp;1 - 4 = at top<br>&nbsp;&nbsp;6-9 = after "Library",&nbsp;&nbsp;&nbsp;&nbsp;11-16 = after "Add New"', 'media-library-assistant' )),
509
+
510
+ self::MLA_SCREEN_DISPLAY_LIBRARY =>
511
+ array('tab' => 'general',
512
+ 'name' => __( 'Display Media/Library', 'media-library-assistant' ),
513
+ 'type' => 'checkbox',
514
+ 'std' => 'checked',
515
+ 'help' => __( 'Check/uncheck this option to display/remove the WordPress Media/Library submenu entry.', 'media-library-assistant' )),
516
+
517
+ 'table_defaults_subheader' =>
518
+ array('tab' => 'general',
519
+ 'name' => __( 'Table Defaults', 'media-library-assistant' ),
520
+ 'type' => 'subheader'),
521
+
522
+ self::MLA_DEFAULT_ORDERBY =>
523
+ array('tab' => 'general',
524
+ 'name' => __( 'Order By', 'media-library-assistant' ),
525
+ 'type' => 'select',
526
+ 'std' => 'title_name',
527
+ 'options' => array('none', 'title_name'),
528
+ 'texts' => array( __( 'None', 'media-library-assistant' ), __( 'Title/Name', 'media-library-assistant' ) ),
529
+ 'help' => __( 'Select the column for the sort order of the Assistant table listing.', 'media-library-assistant' )),
530
+
531
+ self::MLA_DEFAULT_ORDER =>
532
+ array('tab' => 'general',
533
+ 'name' => __( 'Order', 'media-library-assistant' ),
534
+ 'type' => 'radio',
535
+ 'std' => 'ASC',
536
+ 'options' => array('ASC', 'DESC'),
537
+ 'texts' => array( __( 'Ascending', 'media-library-assistant' ), __( 'Descending', 'media-library-assistant' ) ),
538
+ 'help' => __( 'Choose the sort order.', 'media-library-assistant' )),
539
+
540
+ self::MLA_TABLE_VIEWS_WIDTH =>
541
+ array('tab' => 'general',
542
+ 'name' => __( 'Views Width', 'media-library-assistant' ),
543
+ 'type' => 'text',
544
+ 'std' => '',
545
+ 'size' => 10,
546
+ 'help' => __( 'Enter the width for the views list, in pixels (px) or percent (%)', 'media-library-assistant' )),
547
+
548
+ 'taxonomy_filter_subheader' =>
549
+ array('tab' => 'general',
550
+ 'name' => __( 'Taxonomy Filter parameters', 'media-library-assistant' ),
551
+ 'type' => 'subheader'),
552
+
553
+ self::MLA_TAXONOMY_FILTER_DEPTH =>
554
+ array('tab' => 'general',
555
+ 'name' => __( 'Maximum Depth', 'media-library-assistant' ),
556
+ 'type' => 'text',
557
+ 'std' => '3',
558
+ 'size' => 2,
559
+ 'help' => __( 'Enter the number of levels displayed for hierarchial taxonomies; enter zero for no limit.', 'media-library-assistant' )),
560
+
561
+ self::MLA_TAXONOMY_FILTER_INCLUDE_CHILDREN =>
562
+ array('tab' => 'general',
563
+ 'name' => __( 'Include Children', 'media-library-assistant' ),
564
+ 'type' => 'checkbox',
565
+ 'std' => 'checked',
566
+ 'help' => __( 'Check/uncheck this option to include/exclude children for hierarchical taxonomies.', 'media-library-assistant' )),
567
+
568
+ 'media_modal_header' =>
569
+ array('tab' => 'general',
570
+ 'name' => __( 'Media Manager Enhancements', 'media-library-assistant' ),
571
+ 'type' => 'header'),
572
+
573
+ self::MLA_MEDIA_MODAL_TOOLBAR =>
574
+ array('tab' => 'general',
575
+ 'name' => __( 'Enable Media Manager Enhancements', 'media-library-assistant' ),
576
+ 'type' => 'checkbox',
577
+ 'std' => 'checked',
578
+ 'help' => __( 'Check/uncheck this option to enable/disable Media Manager Enhancements.', 'media-library-assistant' )),
579
+
580
+ self::MLA_MEDIA_MODAL_MIMETYPES =>
581
+ array('tab' => 'general',
582
+ 'name' => __( 'Media Manager Enhanced MIME Type filter', 'media-library-assistant' ),
583
+ 'type' => 'checkbox',
584
+ 'std' => 'checked',
585
+ 'help' => __( 'Check this option to filter by more MIME Types, e.g., text, applications.', 'media-library-assistant' )),
586
+
587
+ self::MLA_MEDIA_MODAL_MONTHS =>
588
+ array('tab' => 'general',
589
+ 'name' => __( 'Media Manager Month and Year filter', 'media-library-assistant' ),
590
+ 'type' => 'checkbox',
591
+ 'std' => 'checked',
592
+ 'help' => __( 'Check this option to filter by month and year uploaded.', 'media-library-assistant' )),
593
+
594
+ self::MLA_MEDIA_MODAL_TERMS =>
595
+ array('tab' => 'general',
596
+ 'name' => __( 'Media Manager Category/Tag filter', 'media-library-assistant' ),
597
+ 'type' => 'checkbox',
598
+ 'std' => 'checked',
599
+ 'help' => __( 'Check this option to filter by taxonomy terms.', 'media-library-assistant' )),
600
+
601
+ self::MLA_MEDIA_MODAL_SEARCHBOX =>
602
+ array('tab' => 'general',
603
+ 'name' => __( 'Media Manager Enhanced Search Media box', 'media-library-assistant' ),
604
+ 'type' => 'checkbox',
605
+ 'std' => 'checked',
606
+ 'help' => __( 'Check this option to enable search box enhancements.', 'media-library-assistant' )),
607
+
608
+ self::MLA_MEDIA_MODAL_DETAILS_CATEGORY_METABOX =>
609
+ array('tab' => 'general',
610
+ 'name' => __( 'Media Manager Searchable Categories metaboxes', 'media-library-assistant' ),
611
+ 'type' => 'checkbox',
612
+ 'std' => '',
613
+ 'help' => __( 'Check this option to enable searchable metaboxes in the "ATTACHMENT DETAILS" pane.<br>&nbsp;&nbsp;This option is for <strong>hierarchical taxonomies, e.g., "Att. Categories".</strong><br>&nbsp;&nbsp;You must also install and activate the <strong>"Media Categories" plugin</strong> (by Eddie Moya) to implement this option.', 'media-library-assistant' )),
614
+
615
+ self::MLA_MEDIA_MODAL_DETAILS_TAG_METABOX =>
616
+ array('tab' => 'general',
617
+ 'name' => __( 'Media Manager Searchable Tags metaboxes', 'media-library-assistant' ),
618
+ 'type' => 'checkbox',
619
+ 'std' => '',
620
+ 'help' => __( 'Check this option to enable searchable metaboxes in the "ATTACHMENT DETAILS" pane.<br>&nbsp;&nbsp;This option is for <strong>flat taxonomies, e.g., "Att. Tags".</strong><br>&nbsp;&nbsp;You must also install and activate the <strong>"Media Categories" plugin</strong> (by Eddie Moya) to implement this option.', 'media-library-assistant' )),
621
+
622
+ self::MLA_MEDIA_MODAL_ORDERBY =>
623
+ array('tab' => '',
624
+ 'name' => __( 'Media Manager Order By', 'media-library-assistant' ),
625
+ 'type' => 'select',
626
+ 'std' => 'default',
627
+ 'options' => array('default', 'none', 'title_name'),
628
+ 'texts' => array('&mdash; ' . __( 'Media Manager Default', 'media-library-assistant' ) . ' &mdash;', __( 'None', 'media-library-assistant' ), __( 'Title/Name', 'media-library-assistant' )),
629
+ 'help' => __( 'If you want to override the Media Manager default,<br>&nbsp;&nbsp;select a column for the sort order of the Media Library listing.', 'media-library-assistant' )),
630
+
631
+ self::MLA_MEDIA_MODAL_ORDER =>
632
+ array('tab' => '',
633
+ 'name' => __( 'Media Manager Order', 'media-library-assistant' ),
634
+ 'type' => 'radio',
635
+ 'std' => 'default',
636
+ 'options' => array('default', 'ASC', 'DESC'),
637
+ 'texts' => array( '&mdash; ' . __( 'Media Manager Default', 'media-library-assistant' ) . ' &mdash;', 'Ascending', 'Descending' ),
638
+ 'help' => __( 'Choose the sort order.', 'media-library-assistant' )),
639
+
640
+ 'template_header' =>
641
+ array('tab' => 'mla_gallery',
642
+ 'name' => __( 'Default [mla_gallery] Templates and Settings', 'media-library-assistant' ),
643
+ 'type' => 'header'),
644
+
645
+ 'default_tag_cloud_style' =>
646
+ array('tab' => '',
647
+ 'name' => __( 'Style Template', 'media-library-assistant' ),
648
+ 'type' => 'select',
649
+ 'std' => 'tag-cloud',
650
+ 'options' => array(),
651
+ 'texts' => array(),
652
+ /* translators: 1: template type 2: shortcode */
653
+ 'help' => sprintf( __( 'Select the default %1$s for your %2$s shortcodes.', 'media-library-assistant' ), __( 'style template', 'media-library-assistant' ), '[mla_tag_cloud]' ) ),
654
+
655
+ 'default_tag_cloud_markup' =>
656
+ array('tab' => '',
657
+ 'name' => __( 'Markup Template', 'media-library-assistant' ),
658
+ 'type' => 'select',
659
+ 'std' => 'tag-cloud',
660
+ 'options' => array(),
661
+ 'texts' => array(),
662
+ /* translators: 1: template type 2: shortcode */
663
+ 'help' => sprintf( __( 'Select the default %1$s for your %2$s shortcodes.', 'media-library-assistant' ), __( 'markup template', 'media-library-assistant' ), '[mla_tag_cloud]' ) ),
664
+
665
+ 'mla_tag_cloud_columns' =>
666
+ array('tab' => '',
667
+ 'name' => __( 'Default columns', 'media-library-assistant' ),
668
+ 'type' => 'text',
669
+ 'std' => '3',
670
+ 'size' => 3,
671
+ 'help' => __( 'Enter the number of [mla_tag_cloud] columns; must be a positive integer.', 'media-library-assistant' )),
672
+
673
+ 'mla_tag_cloud_margin' =>
674
+ array('tab' => '',
675
+ 'name' => __( 'Default mla_margin', 'media-library-assistant' ),
676
+ 'type' => 'text',
677
+ 'std' => '1.5%',
678
+ 'size' => 10,
679
+ 'help' => __( 'Enter the CSS "margin" property value, in length (px, em, pt, etc.), percent (%), "auto" or "inherit".<br>&nbsp;&nbsp;Enter "none" to remove the property entirely.', 'media-library-assistant' )),
680
+
681
+ 'mla_tag_cloud_itemwidth' =>
682
+ array('tab' => '',
683
+ 'name' => __( 'Default mla_itemwidth', 'media-library-assistant' ),
684
+ 'type' => 'text',
685
+ 'std' => 'calculate',
686
+ 'size' => 10,
687
+ 'help' => __( 'Enter the CSS "width" property value, in length (px, em, pt, etc.), percent (%), "auto" or "inherit".<br>&nbsp;&nbsp;Enter "calculate" (the default) to calculate the value taking the "margin" value into account.<br>&nbsp;&nbsp;Enter "exact" to calculate the value without considering the "margin" value.<br>&nbsp;&nbsp;Enter "none" to remove the property entirely.', 'media-library-assistant' )),
688
+
689
+ 'default_style' =>
690
+ array('tab' => 'mla_gallery',
691
+ 'name' => __( 'Style Template', 'media-library-assistant' ),
692
+ 'type' => 'select',
693
+ 'std' => 'default',
694
+ 'options' => array(),
695
+ 'texts' => array(),
696
+ /* translators: 1: template type 2: shortcode */
697
+ 'help' => sprintf( __( 'Select the default %1$s for your %2$s shortcodes.', 'media-library-assistant' ), __( 'style template', 'media-library-assistant' ), '[mla_gallery]' ) ),
698
+
699
+ 'default_markup' =>
700
+ array('tab' => 'mla_gallery',
701
+ 'name' => __( 'Markup Template', 'media-library-assistant' ),
702
+ 'type' => 'select',
703
+ 'std' => 'default',
704
+ 'options' => array(),
705
+ 'texts' => array(),
706
+ /* translators: 1: template type 2: shortcode */
707
+ 'help' => sprintf( __( 'Select the default %1$s for your %2$s shortcodes.', 'media-library-assistant' ), __( 'markup template', 'media-library-assistant' ), '[mla_gallery]' ) ),
708
+
709
+ 'mla_gallery_columns' =>
710
+ array('tab' => 'mla_gallery',
711
+ 'name' => __( 'Default columns', 'media-library-assistant' ),
712
+ 'type' => 'text',
713
+ 'std' => '3',
714
+ 'size' => 3,
715
+ 'help' => __( 'Enter the number of [mla_gallery] columns; must be a positive integer.', 'media-library-assistant' )),
716
+
717
+ 'mla_gallery_margin' =>
718
+ array('tab' => 'mla_gallery',
719
+ 'name' => __( 'Default mla_margin', 'media-library-assistant' ),
720
+ 'type' => 'text',
721
+ 'std' => '1.5%',
722
+ 'size' => 10,
723
+ 'help' => __( 'Enter the CSS "margin" property value, in length (px, em, pt, etc.), percent (%), "auto" or "inherit".<br>&nbsp;&nbsp;Enter "none" to remove the property entirely.', 'media-library-assistant' )),
724
+
725
+ 'mla_gallery_itemwidth' =>
726
+ array('tab' => 'mla_gallery',
727
+ 'name' => __( 'Default mla_itemwidth', 'media-library-assistant' ),
728
+ 'type' => 'text',
729
+ 'std' => 'calculate',
730
+ 'size' => 10,
731
+ 'help' => __( 'Enter the CSS "width" property value, in length (px, em, pt, etc.), percent (%), "auto" or "inherit".<br>&nbsp;&nbsp;Enter "calculate" (the default) to calculate the value taking the "margin" value into account.<br>&nbsp;&nbsp;Enter "exact" to calculate the value without considering the "margin" value.<br>&nbsp;&nbsp;Enter "none" to remove the property entirely.', 'media-library-assistant' )),
732
+
733
+ /*
734
+ * Managed by mla_get_style_templates and mla_put_style_templates
735
+ */
736
+ 'style_templates' =>
737
+ array('tab' => '',
738
+ 'type' => 'hidden',
739
+ 'std' => array()),
740
+
741
+ /*
742
+ * Managed by mla_get_markup_templates and mla_put_markup_templates
743
+ */
744
+ 'markup_templates' =>
745
+ array('tab' => '',
746
+ 'type' => 'hidden',
747
+ 'std' => array()),
748
+
749
+ 'enable_custom_field_mapping' =>
750
+ array('tab' => 'custom_field',
751
+ 'name' => __( 'Enable custom field mapping when adding new media', 'media-library-assistant' ),
752
+ 'type' => 'checkbox',
753
+ 'std' => '',
754
+ 'help' => __( 'Check this option to enable mapping when uploading new media (attachments).<br>&nbsp;&nbsp;Click Save Changes at the bottom of the screen if you change this option.<br>&nbsp;&nbsp;Does NOT affect the operation of the "Map" buttons on the bulk edit, single edit and settings screens.', 'media-library-assistant' )),
755
+
756
+ 'enable_custom_field_update' =>
757
+ array('tab' => 'custom_field',
758
+ 'name' => __( 'Enable custom field mapping when updating media metadata', 'media-library-assistant' ),
759
+ 'type' => 'checkbox',
760
+ 'std' => '',
761
+ 'help' => __( 'Check this option to enable mapping when media (attachments) metadata is regenerated,<br>&nbsp;&nbsp;e.g., when the Media/Edit Media "Edit Image" functions are used.', 'media-library-assistant' )),
762
+
763
+ 'custom_field_mapping' =>
764
+ array('tab' => '',
765
+ 'help' => __( 'Update the custom field mapping values above, then click Save Changes to make the updates permanent.<br>You can also make temporary updates and click a Map All Attachments button to apply the rule(s) to all attachments without saving any rule changes.', 'media-library-assistant' ),
766
+ 'std' => array(),
767
+ 'type' => 'custom',
768
+ 'render' => 'mla_custom_field_option_handler',
769
+ 'update' => 'mla_custom_field_option_handler',
770
+ 'delete' => 'mla_custom_field_option_handler',
771
+ 'reset' => 'mla_custom_field_option_handler'),
772
+
773
+ 'enable_iptc_exif_mapping' =>
774
+ array('tab' => 'iptc_exif',
775
+ 'name' => __( 'Enable IPTC/EXIF Mapping when adding new media', 'media-library-assistant' ),
776
+ 'type' => 'checkbox',
777
+ 'std' => '',
778
+ 'help' => __( 'Check this option to enable mapping when uploading new media (attachments).<br>&nbsp;&nbsp;Does NOT affect the operation of the "Map" buttons on the bulk edit, single edit and settings screens.', 'media-library-assistant' )),
779
+
780
+ 'enable_iptc_exif_update' =>
781
+ array('tab' => 'iptc_exif',
782
+ 'name' => __( 'Enable IPTC/EXIF Mapping when updating media metadata', 'media-library-assistant' ),
783
+ 'type' => 'checkbox',
784
+ 'std' => '',
785
+ 'help' => __( 'Check this option to enable mapping when media (attachments) metadata is regenerated,<br>&nbsp;&nbsp;e.g., when the Media/Edit Media "Edit Image" functions are used.', 'media-library-assistant' )),
786
+
787
+ 'iptc_exif_standard_mapping' =>
788
+ array('tab' => '',
789
+ 'help' => __( 'Update the standard field mapping values above, then click <strong>Save Changes</strong> to make the updates permanent.<br>You can also make temporary updates and click <strong>Map All Attachments, Standard Fields Now</strong> to apply the updates to all attachments without saving the rule changes.', 'media-library-assistant' ),
790
+ 'std' => NULL,
791
+ 'type' => 'custom',
792
+ 'render' => 'mla_iptc_exif_option_handler',
793
+ 'update' => 'mla_iptc_exif_option_handler',
794
+ 'delete' => 'mla_iptc_exif_option_handler',
795
+ 'reset' => 'mla_iptc_exif_option_handler'),
796
+
797
+ 'iptc_exif_taxonomy_mapping' =>
798
+ array('tab' => '',
799
+ 'help' => __( 'Update the taxonomy term mapping values above, then click <strong>Save Changes</strong> or <strong>Map All Attachments, Taxonomy Terms Now</strong>.', 'media-library-assistant' ),
800
+ 'std' => NULL,
801
+ 'type' => 'custom',
802
+ 'render' => 'mla_iptc_exif_option_handler',
803
+ 'update' => 'mla_iptc_exif_option_handler',
804
+ 'delete' => 'mla_iptc_exif_option_handler',
805
+ 'reset' => 'mla_iptc_exif_option_handler'),
806
+
807
+ 'iptc_exif_custom_mapping' =>
808
+ array('tab' => '',
809
+ 'help' => __( '<strong>Update</strong> individual custom field mapping values above, or make several updates and click <strong>Save Changes</strong> below to apply them all at once.<br>You can also <strong>add a new rule</strong> for an existing field or <strong>add a new field</strong> and rule.<br>You can make temporary updates and click <strong>Map All Attachments, Custom Fields Now</strong> to apply the updates to all attachments without saving the rule changes.', 'media-library-assistant' ),
810
+ 'std' => NULL,
811
+ 'type' => 'custom',
812
+ 'render' => 'mla_iptc_exif_option_handler',
813
+ 'update' => 'mla_iptc_exif_option_handler',
814
+ 'delete' => 'mla_iptc_exif_option_handler',
815
+ 'reset' => 'mla_iptc_exif_option_handler'),
816
+
817
+ 'iptc_exif_mapping' =>
818
+ array('tab' => '',
819
+ 'help' => __( 'IPTC/EXIF Mapping help', 'media-library-assistant' ),
820
+ 'std' => array (
821
+ 'standard' => array (
822
+ 'post_title' => array (
823
+ 'name' => __( 'Title', 'media-library-assistant' ),
824
+ 'iptc_value' => 'none',
825
+ 'exif_value' => '',
826
+ 'iptc_first' => true,
827
+ 'keep_existing' => true
828
+ ),
829
+ 'post_name' => array (
830
+ 'name' => __( 'Name/Slug', 'media-library-assistant' ),
831
+ 'iptc_value' => 'none',
832
+ 'exif_value' => '',
833
+ 'iptc_first' => true,
834
+ 'keep_existing' => true
835
+ ),
836
+ 'image_alt' => array (
837
+ 'name' => __( 'ALT Text', 'media-library-assistant' ),
838
+ 'iptc_value' => 'none',
839
+ 'exif_value' => '',
840
+ 'iptc_first' => true,
841
+ 'keep_existing' => true
842
+ ),
843
+ 'post_excerpt' => array (
844
+ 'name' => __( 'Caption', 'media-library-assistant' ),
845
+ 'iptc_value' => 'none',
846
+ 'exif_value' => '',
847
+ 'iptc_first' => true,
848
+ 'keep_existing' => true
849
+ ),
850
+ 'post_content' => array (
851
+ 'name' => __( 'Description', 'media-library-assistant' ),
852
+ 'iptc_value' => 'none',
853
+ 'exif_value' => '',
854
+ 'iptc_first' => true,
855
+ 'keep_existing' => true
856
+ ),
857
+ ),
858
+ 'taxonomy' => array (
859
+ ),
860
+ 'custom' => array (
861
+ )
862
+ ),
863
+ 'type' => 'custom',
864
+ 'render' => 'mla_iptc_exif_option_handler',
865
+ 'update' => 'mla_iptc_exif_option_handler',
866
+ 'delete' => 'mla_iptc_exif_option_handler',
867
+ 'reset' => 'mla_iptc_exif_option_handler'),
868
+
869
+ self::MLA_ENABLE_POST_MIME_TYPES =>
870
+ array('tab' => 'view',
871
+ 'name' => __( 'Enable View and Post MIME Type Support', 'media-library-assistant' ),
872
+ 'type' => 'checkbox',
873
+ 'std' => 'checked',
874
+ 'help' => __( 'Check/uncheck this option to enable/disable Post MIME Type Support, then click <strong>Save Changes</strong> to record the new setting.', 'media-library-assistant' )),
875
+
876
+ self::MLA_POST_MIME_TYPES =>
877
+ array('tab' => '',
878
+ 'type' => 'custom',
879
+ 'render' => 'mla_post_mime_types_option_handler',
880
+ 'update' => 'mla_post_mime_types_option_handler',
881
+ 'delete' => 'mla_post_mime_types_option_handler',
882
+ 'reset' => 'mla_post_mime_types_option_handler',
883
+ 'help' => __( 'Post MIME Types help.', 'media-library-assistant' ),
884
+ 'std' => array(
885
+ 'all' => array(
886
+ 'singular' => _x( 'All', 'post_mime_types_singular', 'media-library-assistant' ),
887
+ 'plural' => _x( 'All', 'post_mime_types_plural', 'media-library-assistant' ),
888
+ 'specification' => '',
889
+ 'post_mime_type' => false,
890
+ 'table_view' => true,
891
+ 'menu_order' => 0,
892
+ 'description' => _x( 'Built-in view', 'post_mime_types_description', 'media-library-assistant' )
893
+ ),
894
+ 'image' => array(
895
+ 'singular' => _x( 'Image', 'post_mime_types_singular', 'media-library-assistant' ),
896
+ 'plural' => _x( 'Images', 'post_mime_types_plural', 'media-library-assistant' ),
897
+ 'specification' => '',
898
+ 'post_mime_type' => true,
899
+ 'table_view' => true,
900
+ 'menu_order' => 0,
901
+ 'description' => _x( 'All image subtypes', 'post_mime_types_description', 'media-library-assistant' )
902
+ ),
903
+ 'audio' => array(
904
+ 'singular' => _x( 'Audio', 'post_mime_types_singular', 'media-library-assistant' ),
905
+ 'plural' => _x( 'Audio', 'post_mime_types_plural', 'media-library-assistant' ),
906
+ 'specification' => '',
907
+ 'post_mime_type' => true,
908
+ 'table_view' => true,
909
+ 'menu_order' => 0,
910
+ 'description' => _x( 'All audio subtypes', 'post_mime_types_description', 'media-library-assistant' )
911
+ ),
912
+ 'video' => array(
913
+ 'singular' => _x( 'Video', 'post_mime_types_singular', 'media-library-assistant' ),
914
+ 'plural' => _x( 'Video', 'post_mime_types_plural', 'media-library-assistant' ),
915
+ 'specification' => '',
916
+ 'post_mime_type' => true,
917
+ 'table_view' => true,
918
+ 'menu_order' => 0,
919
+ 'description' => _x( 'All video subtypes', 'post_mime_types_description', 'media-library-assistant' )
920
+ ),
921
+ 'text' => array(
922
+ 'singular' => _x( 'Text', 'post_mime_types_singular', 'media-library-assistant' ),
923
+ 'plural' => _x( 'Text', 'post_mime_types_plural', 'media-library-assistant' ),
924
+ 'specification' => '',
925
+ 'post_mime_type' => true,
926
+ 'table_view' => true,
927
+ 'menu_order' => 0,
928
+ 'description' => _x( 'All text subtypes', 'post_mime_types_description', 'media-library-assistant' )
929
+ ),
930
+ 'application' => array(
931
+ 'singular' => _x( 'Application', 'post_mime_types_singular', 'media-library-assistant' ),
932
+ 'plural' => _x( 'Applications', 'post_mime_types_plural', 'media-library-assistant' ),
933
+ 'specification' => '',
934
+ 'post_mime_type' => true,
935
+ 'table_view' => true,
936
+ 'menu_order' => 0,
937
+ 'description' => _x( 'All application subtypes', 'post_mime_types_description', 'media-library-assistant' )
938
+ ),
939
+ 'unattached' => array(
940
+ 'singular' => _x( 'Unattached', 'post_mime_types_singular', 'media-library-assistant' ),
941
+ 'plural' => _x( 'Unattached', 'post_mime_types_plural', 'media-library-assistant' ),
942
+ 'specification' => '',
943
+ 'post_mime_type' => false,
944
+ 'table_view' => true,
945
+ 'menu_order' => 0,
946
+ 'description' => _x( 'Built-in view', 'post_mime_types_description', 'media-library-assistant' )
947
+ ),
948
+ 'trash' => array(
949
+ 'singular' => _x( 'Trash', 'post_mime_types_singular', 'media-library-assistant' ),
950
+ 'plural' => _x( 'Trash', 'post_mime_types_plural', 'media-library-assistant' ),
951
+ 'specification' => '',
952
+ 'post_mime_type' => false,
953
+ 'table_view' => true,
954
+ 'menu_order' => 0,
955
+ 'description' => _x( 'Built-in view', 'post_mime_types_description', 'media-library-assistant' )
956
+ )
957
+ )),
958
+
959
+ self::MLA_ENABLE_UPLOAD_MIMES =>
960
+ array('tab' => 'upload',
961
+ 'name' => __( 'Enable Upload MIME Type Support', 'media-library-assistant' ),
962
+ 'type' => 'checkbox',
963
+ 'std' => 'checked',
964
+ 'help' => __( 'Check/uncheck this option to enable/disable Upload MIME Type Support, then click <strong>Save Changes</strong> to record the new setting.', 'media-library-assistant' )),
965
+
966
+ self::MLA_UPLOAD_MIMES =>
967
+ array('tab' => '',
968
+ 'type' => 'custom',
969
+ 'render' => 'mla_upload_mimes_option_handler',
970
+ 'update' => 'mla_upload_mimes_option_handler',
971
+ 'delete' => 'mla_upload_mimes_option_handler',
972
+ 'reset' => 'mla_upload_mimes_option_handler',
973
+ 'help' => __( 'Upload MIME Types help.', 'media-library-assistant' ),
974
+ 'std' => false), // false to detect first-time load; will become an array
975
+
976
+ self::MLA_ENABLE_MLA_ICONS =>
977
+ array('tab' => 'upload',
978
+ 'name' => __( 'Enable MLA File Type Icons Support', 'media-library-assistant' ),
979
+ 'type' => 'checkbox',
980
+ 'std' => 'checked',
981
+ 'help' => __( 'Check/uncheck this option to enable/disable MLA File Type Icons Support, then click <strong>Save Changes</strong> to record the new setting.', 'media-library-assistant' )),
982
+
983
+ /* Here are examples of the other option types
984
+ 'textarea' =>
985
+ array('tab' => '',
986
+ 'name' => 'Text Area',
987
+ 'type' => 'textarea',
988
+ 'std' => 'default text area',
989
+ 'cols' => 60,
990
+ 'rows' => 4,
991
+ 'help' => __( 'Enter the text area...'),
992
+ */
993
+ );
994
+ }
995
+
996
  /**
997
  * Fetch style or markup template from $mla_templates
998
  *
1005
  */
1006
  public static function mla_fetch_gallery_template( $key, $type = 'style' ) {
1007
  if ( ! is_array( self::$mla_option_templates ) ) {
1008
+ MLAShortcodes::$mla_debug_messages .= '<p><strong>mla_debug mla_fetch_gallery_template()</strong> ' . __( 'no templates exist', 'media-library-assistant' );
1009
  return null;
1010
  }
1011
+
1012
  $array_key = $key . '-' . $type;
1013
  if ( array_key_exists( $array_key, self::$mla_option_templates ) ) {
1014
  return self::$mla_option_templates[ $array_key ];
1015
+ } else {
1016
+ MLAShortcodes::$mla_debug_messages .= "<p><strong>mla_fetch_gallery_template( {$key}, {$type} )</strong> " . __( 'not found', 'media-library-assistant' );
 
1017
  return false;
1018
  }
1019
  }
1027
  */
1028
  public static function mla_get_style_templates() {
1029
  if ( ! is_array( self::$mla_option_templates ) ) {
1030
+ MLAShortcodes::$mla_debug_messages .= '<p><strong>mla_debug mla_get_style_templates()</strong> ' . __( 'no templates exist', 'media-library-assistant' );
1031
  return null;
1032
  }
1033
+
1034
  $templates = array();
1035
  foreach ( self::$mla_option_templates as $key => $value ) {
1036
  $tail = strrpos( $key, '-style' );
1039
  $templates[ $name ] = $value;
1040
  }
1041
  } // foreach
1042
+
1043
  return $templates;
1044
  }
1045
 
1056
  self::_load_option_templates();
1057
  return true;
1058
  }
1059
+
1060
  return false;
1061
  }
1062
 
1069
  */
1070
  public static function mla_get_markup_templates() {
1071
  if ( ! is_array( self::$mla_option_templates ) ) {
1072
+ MLAShortcodes::$mla_debug_messages .= '<p><strong>mla_debug mla_get_markup_templates()</strong> ' . __( 'no templates exist', 'media-library-assistant' );
1073
  return null;
1074
  }
1075
+
1076
  $templates = array();
1077
  foreach ( self::$mla_option_templates as $key => $value ) {
1078
  // Note order: -row-open must precede -open!
1082
  $templates[ $name ]['row-open'] = $value;
1083
  continue;
1084
  }
1085
+
1086
  $tail = strrpos( $key, '-open-markup' );
1087
  if ( ! ( false === $tail ) ) {
1088
  $name = substr( $key, 0, $tail );
1089
  $templates[ $name ]['open'] = $value;
1090
  continue;
1091
  }
1092
+
1093
  $tail = strrpos( $key, '-item-markup' );
1094
  if ( ! ( false === $tail ) ) {
1095
  $name = substr( $key, 0, $tail );
1096
  $templates[ $name ]['item'] = $value;
1097
  continue;
1098
  }
1099
+
1100
  $tail = strrpos( $key, '-row-close-markup' );
1101
  if ( ! ( false === $tail ) ) {
1102
  $name = substr( $key, 0, $tail );
1103
  $templates[ $name ]['row-close'] = $value;
1104
  continue;
1105
  }
1106
+
1107
  $tail = strrpos( $key, '-close-markup' );
1108
  if ( ! ( false === $tail ) ) {
1109
  $name = substr( $key, 0, $tail );
1110
  $templates[ $name ]['close'] = $value;
1111
  }
1112
  } // foreach
1113
+
1114
  return $templates;
1115
  }
1116
 
1127
  self::_load_option_templates();
1128
  return true;
1129
  }
1130
+
1131
  return false;
1132
  }
1133
 
1143
  * @return mixed Value(s) for the option or false if the option is not a defined MLA option
1144
  */
1145
  public static function mla_get_option( $option, $get_default = false, $get_stored = false ) {
1146
+ if ( ! array_key_exists( $option, self::$mla_option_definitions ) ) {
1147
  return false;
1148
+ }
1149
+
1150
  if ( $get_default ) {
1151
+ if ( array_key_exists( 'std', self::$mla_option_definitions[ $option ] ) ) {
1152
  return self::$mla_option_definitions[ $option ]['std'];
1153
+ }
1154
+
1155
+ return false;
1156
  } // $get_default
1157
+
1158
+ if ( ! $get_stored && array_key_exists( 'std', self::$mla_option_definitions[ $option ] ) ) {
1159
  return get_option( MLA_OPTION_PREFIX . $option, self::$mla_option_definitions[ $option ]['std'] );
1160
+ }
1161
 
1162
  return get_option( MLA_OPTION_PREFIX . $option, false );
1163
  }
1164
+
1165
  /**
1166
  * Add or update the stored value of a defined MLA option
1167
  *
1173
  * @return boolean True if the value was changed or false if the update failed
1174
  */
1175
  public static function mla_update_option( $option, $newvalue ) {
1176
+ if ( array_key_exists( $option, self::$mla_option_definitions ) ) {
1177
  return update_option( MLA_OPTION_PREFIX . $option, $newvalue );
1178
+ }
1179
+
1180
  return false;
1181
  }
1182
+
1183
  /**
1184
  * Delete the stored value of a defined MLA option
1185
  *
1193
  if ( array_key_exists( $option, self::$mla_option_definitions ) ) {
1194
  return delete_option( MLA_OPTION_PREFIX . $option );
1195
  }
1196
+
1197
  return false;
1198
  }
1199
+
1200
  /**
1201
  * Determine MLA support for a taxonomy, handling the special case where the
1202
  * settings are being updated or reset.
1212
  */
1213
  public static function mla_taxonomy_support($tax_name, $support_type = 'support') {
1214
  $tax_options = MLAOptions::mla_get_option( self::MLA_TAXONOMY_SUPPORT );
 
1215
  switch ( $support_type ) {
1216
  case 'support':
1217
  $tax_support = isset( $tax_options['tax_support'] ) ? $tax_options['tax_support'] : array();
1218
  $is_supported = array_key_exists( $tax_name, $tax_support );
1219
+
1220
  if ( !empty( $_REQUEST['mla-general-options-save'] ) ) {
1221
  $is_supported = isset( $_REQUEST['tax_support'][ $tax_name ] );
1222
  } elseif ( !empty( $_REQUEST['mla-general-options-reset'] ) ) {
1229
  $is_supported = false;
1230
  }
1231
  }
1232
+
1233
  return $is_supported;
1234
  case 'quick-edit':
1235
  $tax_quick_edit = isset( $tax_options['tax_quick_edit'] ) ? $tax_options['tax_quick_edit'] : array();
1236
  $is_supported = array_key_exists( $tax_name, $tax_quick_edit );
1237
+
1238
  if ( !empty( $_REQUEST['mla-general-options-save'] ) ) {
1239
  $is_supported = isset( $_REQUEST['tax_quick_edit'][ $tax_name ] );
1240
  } elseif ( !empty( $_REQUEST['mla-general-options-reset'] ) ) {
1247
  $is_supported = false;
1248
  }
1249
  }
1250
+
1251
  return $is_supported;
1252
  case 'filter':
1253
  $tax_filter = isset( $tax_options['tax_filter'] ) ? $tax_options['tax_filter'] : '';
1254
+ if ( '' == $tax_name ) {
1255
  return $tax_filter;
1256
+ }
1257
+
1258
+ $is_supported = ( $tax_name == $tax_filter );
1259
+
1260
  if ( !empty( $_REQUEST['mla-general-options-save'] ) ) {
1261
  $tax_filter = isset( $_REQUEST['tax_filter'] ) ? $_REQUEST['tax_filter'] : '';
1262
  $is_supported = ( $tax_name == $tax_filter );
1263
  } elseif ( !empty( $_REQUEST['mla-general-options-reset'] ) ) {
1264
+ if ( 'attachment_category' == $tax_name ) {
1265
  $is_supported = true;
1266
+ } else {
1267
  $is_supported = false;
1268
+ }
1269
  }
1270
+
1271
  return $is_supported;
1272
  default:
1273
  return false;
1274
  } // $support_type
1275
  } // mla_taxonomy_support
1276
+
1277
  /**
1278
  * Render and manage taxonomy support options, e.g., Categories and Post Tags
1279
  *
1295
  $tax_support = isset( $current_values['tax_support'] ) ? $current_values['tax_support'] : array();
1296
  $tax_quick_edit = isset( $current_values['tax_quick_edit'] ) ? $current_values['tax_quick_edit'] : array();
1297
  $tax_filter = isset( $current_values['tax_filter'] ) ? $current_values['tax_filter'] : '';
1298
+
1299
  /*
1300
  * Always display our own taxonomies, even if not registered.
1301
  * Otherwise there's no way to turn them back on.
1302
  */
1303
  if ( ! array_key_exists( 'attachment_category', $taxonomies ) ) {
1304
+ $taxonomies['attachment_category'] = (object) array( 'labels' => (object) array( 'name' => __( 'Attachment Categories', 'media-library-assistant' ) ) );
1305
+ if ( isset( $tax_support['attachment_category'] ) ) {
1306
  unset( $tax_support['attachment_category'] );
1307
+ }
1308
+
1309
+ if ( isset( $tax_quick_edit['attachment_category'] ) ) {
1310
  unset( $tax_quick_edit['attachment_category'] );
1311
+ }
1312
+
1313
+ if ( $tax_filter == 'attachment_category' ) {
1314
  $tax_filter = '';
1315
+ }
1316
  }
1317
 
1318
  if ( ! array_key_exists( 'attachment_tag', $taxonomies ) ) {
1319
+ $taxonomies['attachment_tag'] = (object) array( 'labels' => (object) array( 'name' => __( 'Attachment Tags', 'media-library-assistant' ) ) );
1320
 
1321
+ if ( isset( $tax_support['attachment_tag'] ) ) {
1322
  unset( $tax_support['attachment_tag'] );
1323
+ }
1324
+
1325
+ if ( isset( $tax_quick_edit['attachment_tag'] ) ) {
1326
  unset( $tax_quick_edit['attachment_tag'] );
1327
+ }
1328
+
1329
+ if ( $tax_filter == 'attachment_tag' ) {
1330
  $tax_filter = '';
1331
+ }
1332
  }
1333
 
1334
  $taxonomy_row = self::$mla_option_templates['taxonomy-row'];
1335
  $row = '';
1336
+
1337
  foreach ( $taxonomies as $tax_name => $tax_object ) {
1338
  $option_values = array (
1339
  'key' => $tax_name,
1342
  'quick_edit_checked' => array_key_exists( $tax_name, $tax_quick_edit ) ? 'checked=checked' : '',
1343
  'filter_checked' => ( $tax_name == $tax_filter ) ? 'checked=checked' : ''
1344
  );
1345
+
1346
  $row .= MLAData::mla_parse_template( $taxonomy_row, $option_values );
1347
  }
1348
 
1349
  $option_values = array (
1350
+ 'Support' => __( 'Support', 'media-library-assistant' ),
1351
+ 'Inline Edit' => __( 'Inline Edit', 'media-library-assistant' ),
1352
+ 'List Filter' => __( 'List Filter', 'media-library-assistant' ),
1353
+ 'Taxonomy' => __( 'Taxonomy', 'media-library-assistant' ),
1354
  'taxonomy_rows' => $row,
1355
  'help' => $value['help']
1356
  );
1357
+
1358
  return MLAData::mla_parse_template( self::$mla_option_templates['taxonomy-table'], $option_values );
1359
  case 'update':
1360
  case 'delete':
1363
  $tax_filter = isset( $args['tax_filter'] ) ? $args['tax_filter'] : '';
1364
 
1365
  $msg = '';
1366
+
1367
  if ( !empty($tax_filter) && !array_key_exists( $tax_filter, $tax_support ) ) {
1368
+ /* translators: 1: taxonomy name */
1369
+ $msg .= '<br>' . sprintf( __( 'List Filter ignored; %1$s not supported.', 'media-library-assistant' ), $tax_filter ) . "\r\n";
1370
  $tax_filter = '';
1371
  }
1372
 
1373
  foreach ( $tax_quick_edit as $tax_name => $tax_value ) {
1374
  if ( !array_key_exists( $tax_name, $tax_support ) ) {
1375
+ /* translators: 1: taxonomy name */
1376
+ $msg .= '<br>' . sprintf( __( 'Quick Edit ignored; %1$s not supported.', 'media-library-assistant' ), $tax_name ) . "\r\n";
1377
  unset( $tax_quick_edit[ $tax_name ] );
1378
  }
1379
  }
1380
+
1381
  $value = array (
1382
  'tax_support' => $tax_support,
1383
  'tax_quick_edit' => $tax_quick_edit,
1384
  'tax_filter' => $tax_filter
1385
  );
1386
+
1387
  self::mla_update_option( $key, $value );
1388
+
1389
+ if ( empty( $msg ) ) {
1390
+ /* translators: 1: option name, e.g., taxonomy_support */
1391
+ $msg .= '<br>' . sprintf( __( 'Update custom %1$s', 'media-library-assistant' ), $key ) . "\r\n";
1392
+ }
1393
 
1394
  return $msg;
1395
  case 'reset':
1396
  self::mla_delete_option( $key );
1397
+ /* translators: 1: option name, e.g., taxonomy_support */
1398
+ return '<br>' . sprintf( __( 'Reset custom %1$s', 'media-library-assistant' ), $key ) . "\r\n";
1399
  default:
1400
+ /* translators: 1: option name 2: action, e.g., update, delete, reset */
1401
+ return '<br>' . sprintf( __( 'ERROR: Custom %1$s unknown action "%2$s"', 'media-library-assistant' ), $key, $action ) . "\r\n";
1402
  }
1403
  } // mla_taxonomy_option_handler
1404
+
1405
+ /**
1406
+ * Examine or alter the filename before the file is made permanent
1407
+ *
1408
+ * @since 1.70
1409
+ *
1410
+ * @param array file parameters ( 'name' )
1411
+ *
1412
+ * @return array updated file parameters
1413
+ */
1414
+ public static function mla_wp_handle_upload_prefilter_filter( $file ) {
1415
+ $image_metadata = MLAData::mla_fetch_attachment_image_metadata( 0, $file['tmp_name'] );
1416
+ $image_metadata['mla_exif_metadata']['FileName'] = $file['name'];
1417
+ $image_metadata['wp_image_metadata'] = wp_read_image_metadata( $file['tmp_name'] );
1418
+ $file = apply_filters( 'mla_upload_prefilter', $file, $image_metadata );
1419
+ return $file;
1420
+ } // mla_wp_handle_upload_prefilter_filter
1421
+
1422
+ /**
1423
+ * Called once for each file uploaded
1424
+ *
1425
+ * @since 1.70
1426
+ *
1427
+ * @param array file parameters ( 'name' )
1428
+ *
1429
+ * @return array updated file parameters
1430
+ */
1431
+ public static function mla_wp_handle_upload_filter( $file ) {
1432
+ if ( ! class_exists( 'getID3' ) ) {
1433
+ require( ABSPATH . WPINC . '/ID3/getid3.php' );
1434
+ }
1435
+
1436
+ $id3 = new getID3();
1437
+ $id3_data = $id3->analyze( $file['file'] );
1438
+ $file = apply_filters( 'mla_upload_filter', $file, $id3_data );
1439
+ return $file;
1440
+ } // mla_wp_handle_upload_filter
1441
+
1442
+ /**
1443
+ * Attachment ID passed from mla_add_attachment_action to mla_update_attachment_metadata_filter
1444
+ *
1445
+ * Ensures that IPTC/EXIF and Custom Field mapping is only performed when the attachment is first
1446
+ * added to the Media Library.
1447
+ *
1448
+ * @since 1.70
1449
+ *
1450
+ * @var integer
1451
+ */
1452
+ private static $add_attachment_id = 0;
1453
+
1454
  /**
1455
+ * Set $add_attachment_id to just-inserted attachment
1456
  *
1457
+ * All of the actual processing is done later, in mla_update_attachment_metadata_filter.
1458
+ *
1459
  * @since 1.00
1460
  *
1461
  * @param integer ID of just-inserted attachment
1462
  *
1463
  * @return void
1464
  */
1465
+ public static function mla_add_attachment_action( $post_ID ) {
1466
+ self::$add_attachment_id = $post_ID;
1467
+ do_action('mla_add_attachment', $post_ID);
 
 
 
 
 
1468
  } // mla_add_attachment_action
1469
+
1470
+ /**
1471
+ * Update _wp_attachment_metadata for just-inserted attachment
1472
+ *
1473
+ * @since 1.70
1474
+ *
1475
+ * @param array Attachment metadata updates
1476
+ * @param array Attachment metadata, by reference; updated by this function
1477
+ *
1478
+ * @return array Attachment metadata updates, with "meta:" elements removed
1479
+ */
1480
+ private static function _update_attachment_metadata( $updates, &$data ) {
1481
+ if ( is_array( $updates ) and isset( $updates['custom_updates'] ) ) {
1482
+ $attachment_meta_values = array();
1483
+ foreach ( $updates['custom_updates'] as $key => $value ) {
1484
+ if ( 'meta:' == substr( $key, 0, 5 ) ) {
1485
+ $meta_key = substr( $key, 5 );
1486
+ $attachment_meta_values[ $meta_key ] = $value;
1487
+ unset( $updates['custom_updates'][ $key ] );
1488
+ }
1489
+ } // foreach $updates
1490
+
1491
+ if ( empty( $updates['custom_updates'] ) ) {
1492
+ unset( $updates['custom_updates'] );
1493
+ }
1494
+
1495
+ if ( ! empty( $attachment_meta_values ) ) {
1496
+ $results = MLAData::mla_update_wp_attachment_metadata( $data, $attachment_meta_values );
1497
+ }
1498
+ } // custom_updates
1499
+
1500
+ return $updates;
1501
+ } // _update_attachment_metadata
1502
+
1503
  /**
1504
+ * Perform IPTC/EXIF and Custom Field mapping on just-inserted attachment
1505
  *
1506
+ * This filter tests the $add_attachment_id variable set by the mla_add_attachment_action
1507
+ * to ensure that mapping is only performed for new additions, not metadata updates.
1508
+ *
1509
  * @since 1.10
1510
  *
1511
  * @param array Attachment metadata for just-inserted attachment
1514
  * @return void
1515
  */
1516
  public static function mla_update_attachment_metadata_filter( $data, $post_id ) {
1517
+ $options = array ();
1518
+ $options['is_upload'] = self::$add_attachment_id == $post_id;
1519
+ self::$add_attachment_id = 0;
1520
+
1521
+ $options['enable_iptc_exif_mapping'] = 'checked' == MLAOptions::mla_get_option( 'enable_iptc_exif_mapping' );
1522
+ $options['enable_custom_field_mapping'] = 'checked' == MLAOptions::mla_get_option( 'enable_custom_field_mapping' );
1523
+ $options['enable_iptc_exif_update'] = 'checked' == MLAOptions::mla_get_option( 'enable_iptc_exif_update' );
1524
+ $options['enable_custom_field_update'] = 'checked' == MLAOptions::mla_get_option( 'enable_custom_field_update' );
1525
+
1526
+ $options = apply_filters( 'mla_update_attachment_metadata_options', $options, $data, $post_id );
1527
+ $data = apply_filters( 'mla_update_attachment_metadata_prefilter', $data, $post_id, $options );
1528
+
1529
+ if ( $options['is_upload'] ) {
1530
+ if ( $options['enable_iptc_exif_mapping'] ) {
1531
+ $item = get_post( $post_id );
1532
+ $updates = MLAOptions::mla_evaluate_iptc_exif_mapping( $item, 'iptc_exif_mapping', NULL, $data );
1533
+ $updates = self::_update_attachment_metadata( $updates, $data );
1534
+
1535
+ if ( !empty( $updates ) ) {
1536
+ $item_content = MLAData::mla_update_single_item( $post_id, $updates );
1537
+ }
1538
+ }
1539
+
1540
+ if ( $options['enable_custom_field_mapping'] ) {
1541
+ $updates = MLAOptions::mla_evaluate_custom_field_mapping( $post_id, 'single_attachment_mapping', NULL, $data );
1542
+ $updates = self::_update_attachment_metadata( $updates, $data );
1543
+
1544
+ if ( !empty( $updates ) ) {
1545
+ $item_content = MLAData::mla_update_single_item( $post_id, $updates );
1546
+ }
1547
+ }
1548
+ } else {
1549
+ if ( $options['enable_iptc_exif_update'] ) {
1550
+ $item = get_post( $post_id );
1551
+ $updates = MLAOptions::mla_evaluate_iptc_exif_mapping( $item, 'iptc_exif_mapping', NULL, $data );
1552
+ $updates = self::_update_attachment_metadata( $updates, $data );
1553
+
1554
+ if ( !empty( $updates ) ) {
1555
+ $item_content = MLAData::mla_update_single_item( $post_id, $updates );
1556
+ }
1557
+ }
1558
+
1559
+ if ( $options['enable_custom_field_update'] ) {
1560
+ $updates = MLAOptions::mla_evaluate_custom_field_mapping( $post_id, 'single_attachment_mapping', NULL, $data );
1561
+ $updates = self::_update_attachment_metadata( $updates, $data );
1562
+
1563
+ if ( !empty( $updates ) ) {
1564
+ $item_content = MLAData::mla_update_single_item( $post_id, $updates );
1565
+ }
1566
+ }
1567
  }
1568
+
1569
+ $data = apply_filters( 'mla_update_attachment_metadata_postfilter', $data, $post_id, $options );
1570
  return $data;
1571
  } // mla_update_attachment_metadata_filter
1572
+
1573
  /**
1574
  * Fetch custom field option value given a slug
1575
  *
1583
  $option_values = self::mla_get_option( 'custom_field_mapping' );
1584
 
1585
  foreach ( $option_values as $key => $value ) {
1586
+ if ( $slug == 'c_' . sanitize_title( $key ) ) {
1587
  return $value;
1588
+ }
1589
  }
1590
 
1591
  return array();
1592
  } // mla_custom_field_option_value
1593
+
1594
  /**
1595
  * Evaluate file information for custom field mapping
1596
  *
1609
 
1610
  switch( $support_type ) {
1611
  case 'default_columns':
1612
+ if ( $value['mla_column'] ) {
1613
  $results[ $slug ] = $value['name'];
1614
+ }
1615
  break;
1616
  case 'default_hidden_columns':
1617
+ if ( $value['mla_column'] ) {
1618
  $results[ ] = $slug;
1619
+ }
1620
  break;
1621
  case 'default_sortable_columns':
1622
+ if ( $value['mla_column'] ) {
1623
  $results[ $slug ] = array( $slug, false );
1624
+ }
1625
  break;
1626
  case 'quick_edit':
1627
+ if ( $value['quick_edit'] ) {
1628
  $results[ $slug ] = $value['name'];
1629
+ }
1630
  break;
1631
  case 'bulk_edit':
1632
+ if ( $value['bulk_edit'] ) {
1633
  $results[ $slug ] = $value['name'];
1634
+ }
1635
  break;
1636
  } // switch support_type
1637
  } // foreach option_value
1638
+
1639
  return $results;
1640
  } // mla_custom_field_support
1641
+
1642
  /**
1643
  * Evaluate file information for custom field mapping
1644
  *
1671
 
1672
  $base_file = isset( $wp_attached_files[ $post_id ]->meta_value ) ? $wp_attached_files[ $post_id ]->meta_value : '';
1673
  $sizes = array();
1674
+
1675
  $attachment_metadata = isset( $wp_attachment_metadata[ $post_id ]->meta_value ) ? unserialize( $wp_attachment_metadata[ $post_id ]->meta_value ) : array();
1676
  if ( !empty( $attachment_metadata ) ) {
1677
  $sizes = isset( $attachment_metadata['sizes'] ) ? $attachment_metadata['sizes'] : array();
1678
+
1679
  if ( isset( $attachment_metadata['width'] ) ) {
1680
  $results['width'] = $attachment_metadata['width'];
1681
  $width = absint( $results['width'] );
1682
+ } else {
 
1683
  $width = 0;
1684
+ }
1685
+
1686
  if ( isset( $attachment_metadata['height'] ) ) {
1687
  $results['height'] = $attachment_metadata['height'];
1688
  $height = absint( $results['height'] );
1689
+ } else {
 
1690
  $height = 0;
1691
+ }
1692
+
1693
+ if ( $width && $height ) {
1694
  $results['orientation'] = ( $height > $width ) ? 'portrait' : 'landscape';
1695
+ }
1696
+
1697
  $results['hwstring_small'] = isset( $attachment_metadata['hwstring_small'] ) ? $attachment_metadata['hwstring_small'] : '';
1698
 
1699
  if ( isset( $attachment_metadata['image_meta'] ) ) {
1709
  $results['absolute_path_raw'] = $upload_dir;
1710
  $results['absolute_path'] = wptexturize( str_replace( '\\', '/', $upload_dir ) );
1711
  $results['path'] = '';
1712
+ } else {
 
1713
  $results['absolute_path_raw'] = $upload_dir . $pathinfo['dirname'] . '/';
1714
  $results['absolute_path'] = wptexturize( str_replace( '\\', '/', $results['absolute_path_raw'] ) );
1715
  $results['path'] = wptexturize( $pathinfo['dirname'] . '/' );
1725
  $results['sizes'] = $sizes;
1726
  return $results;
1727
  } // _evaluate_file_information
1728
+
1729
  /**
1730
  * Evaluate post information for custom field mapping
1731
  *
1740
  private static function _evaluate_post_information( $post_id, $category, $data_source ) {
1741
  global $wpdb;
1742
  static $post_info = NULL;
1743
+
1744
  if ( NULL == $post_info ) {
1745
  if ( 'custom_field_mapping' == $category ) {
1746
  $post_info = $wpdb->get_results( "SELECT ID, post_date, post_parent, post_mime_type FROM {$wpdb->posts} WHERE post_type = 'attachment'", OBJECT_K );
1747
+ } else {
 
1748
  $post_info = $wpdb->get_results( "SELECT ID, post_date, post_parent, post_mime_type FROM {$wpdb->posts} WHERE ID = '{$post_id}'", OBJECT_K );
1749
  }
1750
  }
1751
+
1752
  switch ( $data_source ) {
1753
  case 'post_date':
1754
  return isset( $post_info[ $post_id ]->post_date ) ? $post_info[ $post_id ]->post_date : '';
1760
  return false;
1761
  }
1762
  } // _evaluate_post_information
1763
+
1764
  /**
1765
  * Evaluate post information for custom field mapping
1766
  *
1773
  * @return mixed array for option = array|multi else string
1774
  */
1775
  private static function _evaluate_array_result( $value, $option, $keep_existing ) {
1776
+ if ( empty( $value ) ) {
1777
  return '';
1778
+ }
1779
+
1780
  if ( is_array( $value ) ) {
1781
+ if ( 'single' == $option || 1 == count( $value ) ) {
1782
  return current( $value );
1783
+ } elseif ( 'export' == $option ) {
1784
  return var_export( $value, true );
1785
+ } elseif ( 'text' == $option ) {
1786
  return implode( ',', $value );
1787
+ } elseif ( 'multi' == $option ) {
1788
  $value[0x80000000] = $option;
1789
  $value[0x80000001] = $keep_existing;
1790
  return $value;
1796
  */
1797
  return $value;
1798
  } // _evaluate_array_result
1799
+
1800
+ /**
1801
+ * Get IPTC/EXIF or custom field mapping data source
1802
+ *
1803
+ * Defined as public so MLA Mapping Hooks clients can call it.
1804
+ * Isolates clients from changes to _evaluate_data_source().
1805
+ *
1806
+ * @since 1.70
1807
+ *
1808
+ * @param integer post->ID of attachment
1809
+ * @param string category/scope to evaluate against: custom_field_mapping or single_attachment_mapping
1810
+ * @param array data source specification ( name, *data_source, *keep_existing, *format, mla_column, quick_edit, bulk_edit, *meta_name, *option, no_null )
1811
+ * @param array (optional) _wp_attachment_metadata, default NULL (use current postmeta database value)
1812
+ *
1813
+ * @return string|array data source value
1814
+ */
1815
+ public static function mla_get_data_source( $post_id, $category, $data_value, $attachment_metadata = NULL ) {
1816
+ $default_arguments = array(
1817
+ 'data_source' => 'none',
1818
+ 'keep_existing' => true,
1819
+ 'format' => 'native',
1820
+ 'meta_name' => '',
1821
+ 'option' => 'text',
1822
+ );
1823
+ $data_value = shortcode_atts( $default_arguments, $data_value );
1824
+
1825
+ return self::_evaluate_data_source( $post_id, $category, $data_value, $attachment_metadata = NULL );
1826
+ } // mla_get_data_source
1827
+
1828
  /**
1829
  * Evaluate custom field mapping data source
1830
+ *
1831
  * @since 1.10
1832
  *
1833
  * @param integer post->ID of attachment
1834
  * @param string category/scope to evaluate against: custom_field_mapping or single_attachment_mapping
1835
+ * @param array data source specification ( name, *data_source, *keep_existing, *format, mla_column, quick_edit, bulk_edit, *meta_name, *option, no_null )
1836
+ * @param array (optional) _wp_attachment_metadata, default NULL (use current postmeta database value)
1837
  *
1838
+ * @return string|array data source value
1839
  */
1840
  private static function _evaluate_data_source( $post_id, $category, $data_value, $attachment_metadata = NULL ) {
1841
  global $wpdb;
1842
  static $upload_dir, $intermediate_sizes = NULL, $wp_attached_files = NULL, $wp_attachment_metadata = NULL;
1843
  static $current_id = 0, $file_info = NULL, $parent_info = NULL, $references = NULL;
1844
+ if ( 'none' == $data_value['data_source'] ) {
1845
  return '';
1846
+ }
1847
 
1848
  $data_source = $data_value['data_source'];
1849
+
1850
  /*
1851
  * Do this once per page load; cache attachment metadata if mapping all attachments
1852
  */
1854
  $upload_dir = wp_upload_dir();
1855
  $upload_dir = $upload_dir['basedir'] . '/';
1856
  $intermediate_sizes = get_intermediate_image_sizes();
1857
+
1858
  if ( 'custom_field_mapping' == $category ) {
1859
  if ( ! $table = _get_meta_table('post') ) {
1860
  $wp_attached_files = array();
1861
  $wp_attachment_metadata = array();
1862
+ } else {
 
1863
  $wp_attachment_metadata = $wpdb->get_results( "SELECT post_id, meta_value FROM {$table} WHERE meta_key = '_wp_attachment_metadata'", OBJECT_K );
1864
  $wp_attached_files = $wpdb->get_results( "SELECT post_id, meta_value FROM {$table} WHERE meta_key = '_wp_attached_file'", OBJECT_K );
1865
  }
1873
  $current_id = $post_id;
1874
  $parent_info = NULL;
1875
  $references = NULL;
1876
+
1877
  if ( 'single_attachment_mapping' == $category ) {
1878
  $meta_value = get_metadata( 'post', $post_id, '_wp_attached_file' );
1879
  $wp_attached_files = array( $post_id => (object) array( 'post_id' => $post_id, 'meta_value' => $meta_value[0] ) );
1880
+
1881
  if ( NULL == $attachment_metadata ) {
1882
  $metadata = get_metadata( 'post', $post_id, '_wp_attachment_metadata' );
1883
+ if ( isset( $metadata[0] ) ) {
1884
  $attachment_metadata = $metadata[0];
1885
+ }
1886
  }
1887
 
1888
+ if ( empty( $attachment_metadata ) ) {
1889
  $attachment_metadata = array();
1890
+ }
1891
+
1892
  $wp_attachment_metadata = array( $post_id => (object) array( 'post_id' => $post_id, 'meta_value' => serialize( $attachment_metadata ) ) );
1893
  }
1894
+
1895
  $file_info = self::_evaluate_file_information( $upload_dir, $wp_attached_files, $wp_attachment_metadata, $post_id );
1896
  }
1897
+
1898
  $size_info = array( 'file' => '', 'width' => '', 'height' => '' );
1899
  $match_count = preg_match( '/(.+)\[(.+)\]/', $data_source, $matches );
1900
  if ( 1 == $match_count ) {
1901
  $data_source = $matches[1] . '[size]';
1902
+ if ( isset( $file_info['sizes'][ $matches[2] ] ) ) {
1903
  $size_info = $file_info['sizes'][ $matches[2] ];
1904
+ }
1905
  }
1906
 
1907
  $result = '';
1908
+
1909
  switch( $data_source ) {
1910
  case 'meta':
1911
+ $attachment_metadata = isset( $wp_attachment_metadata[ $post_id ]->meta_value ) ? maybe_unserialize( $wp_attachment_metadata[ $post_id ]->meta_value ) : array();
1912
  $result = MLAData::mla_find_array_element( $data_value['meta_name'], $attachment_metadata, $data_value['option'], $data_value['keep_existing'] );
1913
  break;
1914
  case 'template':
1915
+ if ( in_array( $data_value['option'], array ( 'export', 'array', 'multi' ) ) ) {
1916
  $default_option = 'array';
1917
+ } else {
1918
  $default_option = 'text';
1919
+ }
1920
+
1921
  $item_values = array();
1922
  $placeholders = MLAData::mla_get_template_placeholders( $data_value['meta_name'], $default_option );
1923
  foreach ( $placeholders as $key => $placeholder ) {
1935
  if ( 'array' == $default_option ) {
1936
  $result = MLAData::mla_parse_array_template( $template, $item_values );
1937
  $result = self::_evaluate_array_result( $result, $data_value['option'], $data_value['keep_existing'] );
1938
+ } else {
 
1939
  $result = MLAData::mla_parse_template( $template, $item_values );
1940
+ }
1941
+
1942
  break;
1943
  case 'absolute_path':
1944
  case 'absolute_file_name':
1961
  case 'iso':
1962
  case 'shutter_speed':
1963
  case 'title':
1964
+ if ( isset( $file_info[ $data_source ] ) ) {
1965
  $result = $file_info[ $data_source ];
1966
+ }
1967
  break;
1968
  case 'file_size':
1969
  $filesize = @ filesize( $file_info['absolute_file_name_raw'] );
1970
+ if ( ! (false === $filesize ) ) {
1971
  $result = $filesize;
1972
+ }
1973
  break;
1974
  case 'upload_date':
1975
  $result = self::_evaluate_post_information( $post_id, $category, 'post_date' );
1979
  break;
1980
  case 'dimensions':
1981
  $result = $file_info['width'] . 'x' . $file_info['height'];
1982
+ if ( 'x' == $result ) {
1983
  $result = '';
1984
+ }
1985
  break;
1986
  case 'pixels':
1987
  $result = absint( (int) $file_info['width'] * (int) $file_info['height'] );
1988
+ if ( 0 == $result ) {
1989
  $result = '';
1990
+ } else {
1991
  $result = (string) $result;
1992
+ }
1993
  break;
1994
  case 'size_keys':
1995
  $result = array();
2009
  $result = array();
2010
  foreach ( $file_info['sizes'] as $key => $value ) {
2011
  $filesize = @ filesize( $file_info['absolute_path_raw'] . $value['file'] );
2012
+ if ( false === $filesize ) {
2013
  $result[] = '?';
2014
+ } else {
2015
  switch( $data_value['format'] ) {
2016
  case 'commas':
2017
+ if ( is_numeric( $filesize ) ) {
2018
  $filesize = number_format( (float)$filesize );
2019
+ }
2020
  break;
2021
  default:
2022
  // no change
2034
 
2035
  switch( $data_value['format'] ) {
2036
  case 'commas':
2037
+ if ( is_numeric( $pixels ) ) {
2038
  $pixels = number_format( (float)$pixels );
2039
+ }
2040
  break;
2041
  default:
2042
  // no change
2059
  break;
2060
  case 'size_bytes[size]':
2061
  $result = @ filesize( $file_info['absolute_path_raw'] . $size_info['file'] );
2062
+ if ( false === $result ) {
2063
  $result = '?';
2064
+ }
2065
  break;
2066
  case 'size_pixels[size]':
2067
  $result = absint( (int) $size_info['width'] * (int) $size_info['height'] );
2068
  break;
2069
  case 'size_dimensions[size]':
2070
  $result = $size_info['width'] . 'x' . $size_info['height'];
2071
+ if ( 'x' == $result ) {
2072
  $result = '';
2073
+ }
2074
  break;
2075
  case 'parent':
2076
  $result = absint( self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
2081
  if ( is_null( $parent_info ) ) {
2082
  $parent_info = MLAData::mla_fetch_attachment_parent_data( self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
2083
  }
2084
+
2085
+ if ( isset( $parent_info[ $data_source ] ) ) {
2086
  $result = $parent_info[ $data_source ];
2087
+ }
2088
  break;
2089
  case 'parent_issues':
2090
+ if ( is_null( $references ) ) {
2091
  $references = MLAData::mla_fetch_attachment_references( $post_id, self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
2092
+ }
2093
 
2094
  if ( !empty( $references['parent_errors'] ) ) {
2095
  $result = $references['parent_errors'];
2096
  /*
2097
  * Remove (ORPHAN...
2098
  */
2099
+ $orphan_certain = '(' . __( 'ORPHAN', 'media-library-assistant' ) . ')';
2100
+ $orphan_possible = '(' . __( 'ORPHAN', 'media-library-assistant' ) . '?)';
2101
+
2102
+ if ( false !== strpos( $result, $orphan_certain ) ) {
2103
+ $result = trim( substr( $result, strlen( $orphan_certain ) ) );
2104
+ } elseif ( false !== strpos( $result, $orphan_possible ) ) {
2105
+ $result = trim( substr( $result, strlen( $orphan_possible ) ) );
2106
+ }
2107
  }
2108
  break;
2109
  case 'reference_issues':
2110
+ if ( is_null( $references ) ) {
2111
  $references = MLAData::mla_fetch_attachment_references( $post_id, self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
2112
+ }
2113
 
2114
+ if ( !empty( $references['parent_errors'] ) ) {
2115
  $result = $references['parent_errors'];
2116
+ }
2117
  break;
2118
  case 'featured_in':
2119
  case 'featured_in_title':
2120
+ if ( is_null( $references ) ) {
2121
  $references = MLAData::mla_fetch_attachment_references( $post_id, self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
2122
+ }
2123
 
2124
  if ( !empty( $references['features'] ) ) {
2125
  $result = array();
2126
  foreach ( $references['features'] as $ID => $value )
2127
+ if ( 'featured_in' == $data_source ) {
2128
+ $result[] = sprintf( '%1$s (%2$s %3$d)', $value->post_title, $value->post_type, $ID );
2129
+ } else {
2130
+ $result[] = $value->post_title;
2131
+ }
2132
 
2133
  $result = self::_evaluate_array_result( $result, $data_value['option'], $data_value['keep_existing'] );
2134
+ } else {
 
2135
  $result = '';
2136
+ }
2137
  break;
2138
  case 'inserted_in':
2139
  case 'inserted_in_title':
2140
+ if ( is_null( $references ) ) {
2141
  $references = MLAData::mla_fetch_attachment_references( $post_id, self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
2142
+ }
2143
 
2144
  if ( !empty( $references['inserts'] ) ) {
2145
  $result = array();
2146
  foreach ( $references['inserts'] as $base_file => $inserts )
2147
  foreach ( $inserts as $value )
2148
+ if ( 'inserted_in' == $data_source ) {
2149
+ $result[] = sprintf( '%1$s (%2$s %3$d)', $value->post_title, $value->post_type, $value->ID );
2150
+ } else {
2151
+ $result[] = $value->post_title;
2152
+ }
2153
+
2154
  ksort( $result );
2155
 
2156
  $result = self::_evaluate_array_result( $result, $data_value['option'], $data_value['keep_existing'] );
2157
+ } else {
 
2158
  $result = '';
2159
+ }
2160
  break;
2161
  case 'gallery_in':
2162
  case 'gallery_in_title':
2163
+ if ( is_null( $references ) ) {
2164
  $references = MLAData::mla_fetch_attachment_references( $post_id, self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
2165
+ }
2166
 
2167
  if ( !empty( $references['galleries'] ) ) {
2168
  $result = array();
2169
  foreach ( $references['galleries'] as $ID => $value )
2170
+ if ( 'gallery_in' == $data_source ) {
2171
+ $result[] = sprintf( '%1$s (%2$s %3$d)', $value['post_title'], $value['post_type'], $ID );
2172
+ } else {
2173
+ $result[] = $value['post_title'];
2174
+ }
2175
 
2176
  $result = self::_evaluate_array_result( $result, $data_value['option'], $data_value['keep_existing'] );
2177
+ } else {
 
2178
  $result = '';
2179
+ }
2180
  break;
2181
  case 'mla_gallery_in':
2182
  case 'mla_gallery_in_title':
2183
+ if ( is_null( $references ) ) {
2184
  $references = MLAData::mla_fetch_attachment_references( $post_id, self::_evaluate_post_information( $post_id, $category, 'post_parent' ) );
2185
+ }
2186
 
2187
  if ( !empty( $references['mla_galleries'] ) ) {
2188
  $result = array();
2189
  foreach ( $references['mla_galleries'] as $ID => $value )
2190
+ if ( 'mla_gallery_in' == $data_source ) {
2191
+ $result[] = sprintf( '%1$s (%2$s %3$d)', $value['post_title'], $value['post_type'], $ID );
2192
+ } else {
2193
+ $result[] = $value['post_title'];
2194
+ }
2195
 
2196
  $result = self::_evaluate_array_result( $result, $data_value['option'], $data_value['keep_existing'] );
2197
+ } else {
 
2198
  $result = '';
2199
+ }
2200
  break;
2201
  default:
2202
  return '';
2203
  } // switch $data_source
2204
+
2205
  switch( $data_value['format'] ) {
2206
  case 'commas':
2207
+ if ( is_numeric( $result ) ) {
2208
  $result = str_pad( number_format( (float)$result ), 15, ' ', STR_PAD_LEFT );
2209
+ }
2210
  break;
2211
  default:
2212
  // no change
2215
  /*
2216
  * Make numeric values sortable as strings, make all value non-empty
2217
  */
2218
+ if ( in_array( $data_source, array( 'file_size', 'pixels', 'width', 'height' ) ) ) {
2219
  $result = str_pad( $result, 15, ' ', STR_PAD_LEFT );
2220
+ } elseif ( empty( $result ) ) {
2221
  $result = ' ';
2222
+ }
2223
+
2224
  return $result;
2225
  } // _evaluate_data_source
2226
+
2227
  /**
2228
  * Evaluate custom field mapping updates for a post
2229
  *
2237
  * @return array Updates suitable for MLAData::mla_update_single_item, if any
2238
  */
2239
  public static function mla_evaluate_custom_field_mapping( $post_id, $category, $settings = NULL, $attachment_metadata = NULL ) {
2240
+ if ( NULL == $settings ) {
2241
  $settings = self::mla_get_option( 'custom_field_mapping' );
2242
+ }
 
 
 
 
 
2243
 
2244
+ $settings = apply_filters( 'mla_mapping_settings', $settings, $post_id, $category, $attachment_metadata );
2245
+
2246
+ $custom_updates = array();
2247
+ foreach ( $settings as $setting_key => $setting_value ) {
2248
  /*
2249
  * Convert checkbox value(s)
2250
  */
2251
+ $setting_value['no_null'] = isset( $setting_value['no_null'] );
2252
+
2253
+ $setting_value = apply_filters( 'mla_mapping_rule', $setting_value, $post_id, $category, $attachment_metadata );
2254
+ if ( NULL === $setting_value ) {
2255
+ continue;
2256
+ }
2257
+
2258
+ if ( 'none' == $setting_value['data_source'] ) {
2259
+ continue;
2260
+ }
2261
+
2262
+ $new_text = self::_evaluate_data_source( $post_id, $category, $setting_value, $attachment_metadata );
2263
+ $new_text = apply_filters( 'mla_mapping_custom_value', $new_text, $setting_key, $post_id, $category, $attachment_metadata );
2264
+
2265
+ if ( 'multi' == $setting_value['option'] ) {
2266
  if ( ' ' == $new_text ) {
2267
  $new_text = array(
2268
+ 0x80000000 => $setting_value['option'],
2269
+ 0x80000001 => $setting_value['keep_existing'],
2270
+ 0x80000002 => $setting_value['no_null']
2271
  );
2272
+
2273
+ if ( ! $setting_value['no_null'] ) {
2274
  $new_text [0x00000000] = ' ';
2275
+ }
2276
+ } elseif ( is_string( $new_text ) ) {
2277
  $new_text = array(
2278
  0x00000000 => $new_text,
2279
+ 0x80000000 => $setting_value['option'],
2280
+ 0x80000001 => $setting_value['keep_existing']
2281
  );
2282
+ }
2283
 
2284
+ $custom_updates[ $setting_value['name'] ] = $new_text;
2285
+ } else {
2286
+ if ( $setting_value['keep_existing'] ) {
2287
+ if ( 'meta:' == substr( $setting_value['name'], 0, 5 ) ) {
2288
+ $meta_key = substr( $setting_value['name'], 5 );
2289
+
2290
+ if ( NULL === $attachment_metadata ) {
2291
+ $attachment_metadata = maybe_unserialize( get_metadata( 'post', $post->ID, '_wp_attachment_metadata', true ) );
2292
+ }
2293
+
2294
+ if ( array( $attachment_metadata ) ) {
2295
  $old_text = MLAData::mla_find_array_element( $meta_key, $attachment_metadata, 'array' );
2296
+ } else {
2297
  $old_text = '';
2298
+ }
2299
+ } else {
2300
+ if ( is_string( $old_text = get_metadata( 'post', $post_id, $setting_value['name'], true ) ) ) {
2301
  $old_text = trim( $old_text );
2302
+ }
2303
  }
2304
+
2305
+ if ( ( ' ' != $new_text ) && empty( $old_text ) ) {
2306
+ $custom_updates[ $setting_value['name'] ] = $new_text;
2307
+ }
2308
+ } else {
2309
+ if ( ' ' == $new_text && $setting_value['no_null'] ) {
2310
  $new_text = NULL;
2311
+ }
2312
+
2313
+ $custom_updates[ $setting_value['name'] ] = $new_text;
2314
  }
2315
  } // ! multi
2316
  } // foreach new setting
2317
+
2318
+ $updates = array();
2319
+ if ( ! empty( $custom_updates ) ) {
2320
  $updates['custom_updates'] = $custom_updates;
2321
+ }
2322
 
2323
+ $updates = apply_filters( 'mla_mapping_updates', $updates, $post_id, $category, $settings, $attachment_metadata );
2324
  return $updates;
2325
  } // mla_evaluate_custom_field_mapping
2326
+
2327
  /**
2328
  * Compose a Custom Field Options list with current selection
2329
  *
2340
  $option_values = array (
2341
  'selected' => ( 'none' == $selection ) ? 'selected="selected"' : '',
2342
  'value' => 'none',
2343
+ 'text' => '&mdash; ' . __( 'None (select a value)', 'media-library-assistant' ) . ' &mdash;'
2344
  );
2345
+
2346
  $custom_field_options = MLAData::mla_parse_template( $option_template, $option_values );
2347
  $custom_field_names = self::_get_custom_field_names();
2348
  foreach ( $custom_field_names as $value ) {
2349
+ if ( array_key_exists( $value, $blacklist ) ) {
2350
  continue;
2351
+ }
2352
+
2353
  $option_values = array (
2354
  'selected' => ( $value == $selection ) ? 'selected="selected"' : '',
2355
  'value' => $value,
2356
  'text' => $value
2357
  );
2358
+
2359
  $custom_field_options .= MLAData::mla_parse_template( $option_template, $option_values );
2360
  } // foreach custom_field_name
2361
+
2362
  return $custom_field_options;
2363
  } // _compose_custom_field_option_list
2364
+
2365
  /**
2366
  * Array of Data Source names for custom field mapping
2367
  *
2420
  'shutter_speed',
2421
  'title'
2422
  );
2423
+
2424
  /**
2425
  * Compose a (Custom Field) Data Source Options list with current selection
2426
  *
2437
  $option_values = array (
2438
  'selected' => ( 'none' == $selection ) ? 'selected="selected"' : '',
2439
  'value' => 'none',
2440
+ 'text' => '&mdash; ' . __( 'None (select a value)', 'media-library-assistant' ) . ' &mdash;'
2441
  );
2442
  $custom_field_options = MLAData::mla_parse_template( $option_template, $option_values );
2443
 
2444
  $option_values = array (
2445
  'selected' => ( 'meta' == $selection ) ? 'selected="selected"' : '',
2446
  'value' => 'meta',
2447
+ 'text' => '&mdash; ' . __( 'Metadata (see below)', 'media-library-assistant' ) . ' &mdash;'
2448
  );
2449
  $custom_field_options .= MLAData::mla_parse_template( $option_template, $option_values );
2450
+
2451
  $option_values = array (
2452
  'selected' => ( 'template' == $selection ) ? 'selected="selected"' : '',
2453
  'value' => 'template',
2454
+ 'text' => '&mdash; ' . __( 'Template (see below)', 'media-library-assistant' ) . ' &mdash;'
2455
  );
2456
  $custom_field_options .= MLAData::mla_parse_template( $option_template, $option_values );
2457
+
2458
  $intermediate_sizes = get_intermediate_image_sizes();
2459
  foreach ( self::$custom_field_data_sources as $value ) {
2460
  $size_pos = strpos( $value, '[size]' );
2467
  'value' => $value,
2468
  'text' => $value
2469
  );
2470
+
2471
  $custom_field_options .= MLAData::mla_parse_template( $option_template, $option_values );
2472
  } // foreach size_name
2473
  continue;
2474
+ } else {
 
2475
  $option_values = array (
2476
  'selected' => ( $value == $selection ) ? 'selected="selected"' : '',
2477
  'value' => $value,
2478
  'text' => $value
2479
  );
2480
  }
2481
+
2482
  $custom_field_options .= MLAData::mla_parse_template( $option_template, $option_values );
2483
  } // foreach custom_field_name
2484
+
2485
  return $custom_field_options;
2486
  } // _compose_data_source_option_list
2487
+
2488
  /**
2489
  * Update custom field mappings
2490
  *
2503
 
2504
  foreach ( $new_values as $new_key => $new_value ) {
2505
  $any_setting_changed = false;
2506
+
2507
  /*
2508
  * Check for the addition of a new rule or field
2509
  */
2510
  if ( self::MLA_NEW_CUSTOM_FIELD == $new_key ) {
2511
  $new_key = trim( $new_value['name'] );
2512
 
2513
+ if ( empty( $new_key ) ) {
2514
  continue;
2515
+ }
2516
 
2517
  if ( in_array( $new_key, $custom_field_names ) ) {
2518
+ /* translators: 1: custom field name */
2519
+ $error_list .= '<br>' . sprintf( __( 'ERROR: New field %1$s already exists.', 'media-library-assistant' ), $new_key ) . "\r\n";
2520
  continue;
2521
  }
2522
 
2523
+ /* translators: 1: custom field name */
2524
+ $message_list .= '<br>' . sprintf( __( 'Adding new field %1$s.', 'media-library-assistant' ), $new_key ) . "\r\n";
2525
  $any_setting_changed = true;
2526
+ } elseif ( self::MLA_NEW_CUSTOM_RULE == $new_key ) {
 
2527
  $new_key = trim( $new_value['name'] );
2528
 
2529
+ if ( 'none' == $new_key ) {
2530
  continue;
2531
+ }
2532
 
2533
+ /* translators: 1: custom field name */
2534
+ $message_list .= '<br>' . sprintf( __( 'Adding new rule for %1$s.', 'media-library-assistant' ), $new_key ) . "\r\n";
2535
  $any_setting_changed = true;
2536
+ } else {
 
2537
  /*
2538
  * Replace slug with field name
2539
  */
2540
  $new_key = trim( $new_value['name'] );
2541
  }
2542
+
2543
  if ( isset( $current_values[ $new_key ] ) ) {
2544
  $old_values = $current_values[ $new_key ];
2545
  $any_setting_changed = false;
2546
+ } else {
 
2547
  $old_values = array(
2548
  'name' => $new_key,
2549
  'data_source' => 'none',
2561
  if ( isset( $new_value['action'] ) ) {
2562
  if ( array_key_exists( 'delete_rule', $new_value['action'] ) || array_key_exists( 'delete_field', $new_value['action'] ) ) {
2563
  $settings_changed = true;
2564
+ /* translators: 1: custom field name */
2565
+ $message_list .= '<br>' . sprintf( __( 'Deleting rule for %1$s.', 'media-library-assistant' ), $old_values['name'] ) . "\r\n";
2566
  unset( $current_values[ $new_key ] );
2567
  continue;
2568
  } // delete rule
2569
  } // isset action
2570
+
2571
  /*
2572
  * For "meta:" fields, the UI options are not appropriate
2573
  */
2576
  unset( $new_value['quick_edit'] );
2577
  unset( $new_value['bulk_edit'] );
2578
  }
2579
+
2580
  if ( $old_values['data_source'] != $new_value['data_source'] ) {
2581
  $any_setting_changed = true;
2582
+
2583
  if ( in_array( $old_values['data_source'], array( 'meta', 'template' ) ) ) {
2584
  $new_value['meta_name'] = '';
2585
  }
2586
 
2587
+ /* translators: 1: custom field name 2: attribute 3: old value 4: new value */
2588
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s from %3$s to %4$s.', 'media-library-assistant' ), $old_values['name'], __( 'Data Source', 'media-library-assistant' ), $old_values['data_source'], $new_value['data_source'] ) . "\r\n";
2589
  $old_values['data_source'] = $new_value['data_source'];
2590
  }
2591
 
2592
  if ( $new_value['keep_existing'] ) {
2593
  $boolean_value = true;
2594
+ $boolean_text = __( 'Replace to Keep', 'media-library-assistant' );
2595
+ } else {
 
2596
  $boolean_value = false;
2597
+ $boolean_text = __( 'Keep to Replace', 'media-library-assistant' );
2598
  }
2599
  if ( $old_values['keep_existing'] != $boolean_value ) {
2600
  $any_setting_changed = true;
2601
+ /* translators: 1: custom field name 2: attribute 3: old value 'to' new value */
2602
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s value from %3$s.', 'media-library-assistant' ), $old_values['name'], __( 'Existing Text', 'media-library-assistant' ), $boolean_text ) . "\r\n";
2603
  $old_values['keep_existing'] = $boolean_value;
2604
  }
2605
+
2606
  if ( $old_values['format'] != $new_value['format'] ) {
2607
  $any_setting_changed = true;
2608
+ /* translators: 1: custom field name 2: attribute 3: old value 4: new value */
2609
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s from %3$s to %4$s.', 'media-library-assistant' ), $old_values['name'], __( 'Format', 'media-library-assistant' ), $old_values['format'], $new_value['format'] ) . "\r\n";
2610
  $old_values['format'] = $new_value['format'];
2611
  }
2612
 
2613
  if ( isset( $new_value['mla_column'] ) ) {
2614
  $boolean_value = true;
2615
+ $boolean_text = __( 'unchecked to checked', 'media-library-assistant' );
2616
+ } else {
 
2617
  $boolean_value = false;
2618
+ $boolean_text = __( 'checked to unchecked', 'media-library-assistant' );
2619
  }
2620
  if ( $old_values['mla_column'] != $boolean_value ) {
2621
  $any_setting_changed = true;
2622
+ /* translators: 1: custom field name 2: attribute 3: old value 'to' new value */
2623
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s value from %3$s.', 'media-library-assistant' ), $old_values['name'], __( 'MLA Column', 'media-library-assistant' ), $boolean_text ) . "\r\n";
2624
  $old_values['mla_column'] = $boolean_value;
2625
  }
2626
+
2627
  if ( isset( $new_value['quick_edit'] ) ) {
2628
  $boolean_value = true;
2629
+ $boolean_text = __( 'unchecked to checked', 'media-library-assistant' );
2630
+ } else {
 
2631
  $boolean_value = false;
2632
+ $boolean_text = __( 'checked to unchecked', 'media-library-assistant' );
2633
  }
2634
  if ( $old_values['quick_edit'] != $boolean_value ) {
2635
  $any_setting_changed = true;
2636
+ /* translators: 1: custom field name 2: attribute 3: old value 'to' new value */
2637
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s value from %3$s.', 'media-library-assistant' ), $old_values['name'], __( 'Quick Edit', 'media-library-assistant' ), $boolean_text ) . "\r\n";
2638
  $old_values['quick_edit'] = $boolean_value;
2639
  }
2640
+
2641
  if ( isset( $new_value['bulk_edit'] ) ) {
2642
  $boolean_value = true;
2643
+ $boolean_text = __( 'unchecked to checked', 'media-library-assistant' );
2644
+ } else {
 
2645
  $boolean_value = false;
2646
+ $boolean_text = __( 'checked to unchecked', 'media-library-assistant' );
2647
  }
2648
  if ( $old_values['bulk_edit'] != $boolean_value ) {
2649
  $any_setting_changed = true;
2650
+ /* translators: 1: custom field name 2: attribute 3: old value 'to' new value */
2651
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s value from %3$s.', 'media-library-assistant' ), $old_values['name'], __( 'Bulk Edit', 'media-library-assistant' ), $boolean_text ) . "\r\n";
2652
  $old_values['bulk_edit'] = $boolean_value;
2653
  }
2654
+
2655
  if ( $old_values['meta_name'] != $new_value['meta_name'] ) {
2656
  $any_setting_changed = true;
2657
+
2658
+ /* translators: 1: custom field name 2: attribute 3: old value 4: new value */
2659
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s from %3$s to %4$s.', 'media-library-assistant' ), $old_values['name'], __( 'Metavalue name', 'media-library-assistant' ), $old_values['meta_name'], $new_value['meta_name'] ) . "\r\n";
2660
  $old_values['meta_name'] = $new_value['meta_name'];
2661
  }
2662
 
2663
  if ( $old_values['option'] != $new_value['option'] ) {
2664
  $any_setting_changed = true;
2665
+ /* translators: 1: custom field name 2: attribute 3: old value 4: new value */
2666
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s from %3$s to %4$s.', 'media-library-assistant' ), $old_values['name'], __( 'Option', 'media-library-assistant' ), $old_values['option'], $new_value['option'] ) . "\r\n";
2667
  $old_values['option'] = $new_value['option'];
2668
  }
2669
 
2670
  if ( isset( $new_value['no_null'] ) ) {
2671
  $boolean_value = true;
2672
+ $boolean_text = __( 'unchecked to checked', 'media-library-assistant' );
2673
+ } else {
 
2674
  $boolean_value = false;
2675
+ $boolean_text = __( 'checked to unchecked', 'media-library-assistant' );
2676
  }
2677
  if ( $old_values['no_null'] != $boolean_value ) {
2678
  $any_setting_changed = true;
2679
+ /* translators: 1: custom field name 2: attribute 3: old value 'to' new value */
2680
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s value from %3$s.', 'media-library-assistant' ), $old_values['name'], __( 'Delete NULL', 'media-library-assistant' ), $boolean_text ) . "\r\n";
2681
  $old_values['no_null'] = $boolean_value;
2682
  }
2683
+
2684
  if ( $any_setting_changed ) {
2685
  $settings_changed = true;
2686
  $current_values[ $new_key ] = $old_values;
2687
  }
2688
  } // foreach new value
2689
+
2690
  /*
2691
  * Uncomment this for debugging.
2692
  */
2694
 
2695
  return array( 'message' => $error_list, 'values' => $current_values, 'changed' => $settings_changed );
2696
  } // _update_custom_field_mapping
2697
+
2698
  /**
2699
  * Render and manage custom field mapping options
2700
  *
2714
  switch ( $action ) {
2715
  case 'render':
2716
  if (empty( $current_values ) ) {
2717
+ $table_rows = MLAData::mla_parse_template( self::$mla_option_templates['custom-field-empty-row'],
2718
+ array(
2719
+ 'No Mapping Rules' => __( 'No Custom Field Mapping Rules Defined', 'media-library-assistant' ),
2720
+ 'column_count' => 7 ) );
2721
+ } else {
2722
  $row_template = self::$mla_option_templates['custom-field-rule-row'];
2723
  $table_rows = '';
2724
  }
2725
+
2726
  ksort( $current_values );
2727
  foreach ( $current_values as $row_name => $current_value ) {
2728
  $row_values = array (
2730
  'name' => $row_name,
2731
  'data_source_options' => self::_compose_data_source_option_list( $current_value['data_source'] ),
2732
  'keep_selected' => '',
2733
+ 'Keep' => __( 'Keep', 'media-library-assistant' ),
2734
  'replace_selected' => '',
2735
+ 'Replace' => __( 'Replace', 'media-library-assistant' ),
2736
  'native_format' => '',
2737
+ 'Native' => __( 'Native', 'media-library-assistant' ),
2738
  'commas_format' => '',
2739
+ 'Commas' => __( 'Commas', 'media-library-assistant' ),
2740
  'mla_column_checked' => '',
2741
  'quick_edit_checked' => '',
2742
  'bulk_edit_checked' => '',
2744
  'meta_name_size' => 30,
2745
  'meta_name' => $current_value['meta_name'],
2746
  'column_count_meta' => (7 - 2),
2747
+ 'Option' => __( 'Option', 'media-library-assistant' ),
2748
  'text_option' => '',
2749
+ 'Text' => __( 'Text', 'media-library-assistant' ),
2750
  'single_option' => '',
2751
+ 'Single' => __( 'Single', 'media-library-assistant' ),
2752
  'export_option' => '',
2753
+ 'Export' => __( 'Export', 'media-library-assistant' ),
2754
  'array_option' => '',
2755
+ 'Array' => __( 'Array', 'media-library-assistant' ),
2756
  'multi_option' => '',
2757
+ 'Multi' => __( 'Multi', 'media-library-assistant' ),
2758
+ 'no_null_checked' => '',
2759
+ 'Delete NULL values' => __( 'Delete NULL values', 'media-library-assistant' ),
2760
+ 'Delete Rule' => __( 'Delete Rule', 'media-library-assistant' ),
2761
+ 'Delete Field' => __( 'Delete Rule AND Field', 'media-library-assistant' ),
2762
+ 'Update Rule' => __( 'Update Rule', 'media-library-assistant' ),
2763
+ 'Map All Attachments' => __( 'Map All Attachments', 'media-library-assistant' ),
2764
  );
2765
+
2766
+ if ( $current_value['keep_existing'] ) {
2767
  $row_values['keep_selected'] = 'selected="selected"';
2768
+ } else {
2769
  $row_values['replace_selected'] = 'selected="selected"';
2770
+ }
2771
 
2772
  switch( $current_value['format'] ) {
2773
  case 'native':
2780
  $row_values['native_format'] = 'selected="selected"';
2781
  } // format
2782
 
2783
+ if ( $current_value['mla_column'] ) {
2784
  $row_values['mla_column_checked'] = 'checked="checked"';
2785
+ }
2786
 
2787
+ if ( $current_value['quick_edit'] ) {
2788
  $row_values['quick_edit_checked'] = 'checked="checked"';
2789
+ }
2790
 
2791
+ if ( $current_value['bulk_edit'] ) {
2792
  $row_values['bulk_edit_checked'] = 'checked="checked"';
2793
+ }
2794
 
2795
  switch( $current_value['option'] ) {
2796
  case 'single':
2809
  $row_values['text_option'] = 'selected="selected"';
2810
  } // option
2811
 
2812
+ if ( $current_value['no_null'] ) {
2813
  $row_values['no_null_checked'] = 'checked="checked"';
2814
+ }
2815
 
2816
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
2817
  } // foreach current_value
2821
  */
2822
  $row_template = self::$mla_option_templates['custom-field-new-rule-row'];
2823
  $row_values = array (
2824
+ 'column_count' => 7,
2825
+ 'Add new Rule' => __( 'Add a new Mapping Rule', 'media-library-assistant' ),
2826
  'key' => self::MLA_NEW_CUSTOM_RULE,
2827
  'field_name_options' => self::_compose_custom_field_option_list( 'none', $current_values ),
2828
  'data_source_options' => self::_compose_data_source_option_list( 'none' ),
2829
  'keep_selected' => '',
2830
+ 'Keep' => __( 'Keep', 'media-library-assistant' ),
2831
  'replace_selected' => 'selected="selected"',
2832
+ 'Replace' => __( 'Replace', 'media-library-assistant' ),
2833
  'native_format' => 'selected="selected"',
2834
+ 'Native' => __( 'Native', 'media-library-assistant' ),
2835
  'commas_format' => '',
2836
+ 'Commas' => __( 'Commas', 'media-library-assistant' ),
2837
  'mla_column_checked' => '',
2838
  'quick_edit_checked' => '',
2839
  'bulk_edit_checked' => '',
 
2840
  'meta_name_size' => 30,
2841
  'meta_name' => '',
2842
  'column_count_meta' => (7 - 2),
2843
+ 'Option' => __( 'Option', 'media-library-assistant' ),
2844
  'text_option' => '',
2845
+ 'Text' => __( 'Text', 'media-library-assistant' ),
2846
  'single_option' => '',
2847
+ 'Single' => __( 'Single', 'media-library-assistant' ),
2848
  'export_option' => '',
2849
+ 'Export' => __( 'Export', 'media-library-assistant' ),
2850
  'array_option' => '',
2851
+ 'Array' => __( 'Array', 'media-library-assistant' ),
2852
  'multi_option' => '',
2853
+ 'Multi' => __( 'Multi', 'media-library-assistant' ),
2854
+ 'no_null_checked' => '',
2855
+ 'Delete NULL values' => __( 'Delete NULL values', 'media-library-assistant' ),
2856
+ 'Add Rule' => __( 'Add Rule', 'media-library-assistant' ),
2857
+ 'Map All Attachments' => __( 'Add Rule and Map All Attachments', 'media-library-assistant' ),
2858
  );
2859
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
2860
+
2861
  /*
2862
  * Add a row for defining a new Custom Field
2863
  */
2864
  $row_template = self::$mla_option_templates['custom-field-new-field-row'];
2865
  $row_values = array (
2866
+ 'column_count' => 7,
2867
+ 'Add new Field' => __( 'Add a new Field and Mapping Rule', 'media-library-assistant' ),
2868
  'key' => self::MLA_NEW_CUSTOM_FIELD,
2869
  'field_name_size' => '24',
2870
  'data_source_options' => self::_compose_data_source_option_list( 'none' ),
2871
  'keep_selected' => '',
2872
+ 'Keep' => __( 'Keep', 'media-library-assistant' ),
2873
  'replace_selected' => 'selected="selected"',
2874
+ 'Replace' => __( 'Replace', 'media-library-assistant' ),
2875
  'native_format' => 'selected="selected"',
2876
+ 'Native' => __( 'Native', 'media-library-assistant' ),
2877
  'commas_format' => '',
2878
+ 'Commas' => __( 'Commas', 'media-library-assistant' ),
2879
  'mla_column_checked' => '',
2880
  'quick_edit_checked' => '',
2881
  'bulk_edit_checked' => '',
 
2882
  'meta_name_size' => 30,
2883
  'meta_name' => '',
2884
  'column_count_meta' => (7 - 2),
2885
+ 'Option' => __( 'Option', 'media-library-assistant' ),
2886
  'text_option' => '',
2887
+ 'Text' => __( 'Text', 'media-library-assistant' ),
2888
  'single_option' => '',
2889
+ 'Single' => __( 'Single', 'media-library-assistant' ),
2890
  'export_option' => '',
2891
+ 'Export' => __( 'Export', 'media-library-assistant' ),
2892
  'array_option' => '',
2893
+ 'Array' => __( 'Array', 'media-library-assistant' ),
2894
  'multi_option' => '',
2895
+ 'Multi' => __( 'Multi', 'media-library-assistant' ),
2896
+ 'no_null_checked' => '',
2897
+ 'Delete NULL values' => __( 'Delete NULL values', 'media-library-assistant' ),
2898
+ 'Add Field' => __( 'Add Field', 'media-library-assistant' ),
2899
+ 'Map All Attachments' => __( 'Add Field and Map All Attachments', 'media-library-assistant' ),
2900
  );
2901
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
2902
+
2903
  $option_values = array (
2904
+ 'Field Title' => __( 'Field Title', 'media-library-assistant' ),
2905
+ 'Data Source' => __( 'Data Source', 'media-library-assistant' ),
2906
+ 'Existing Text' => __( 'Existing Text', 'media-library-assistant' ),
2907
+ 'Format' => __( 'Format', 'media-library-assistant' ),
2908
+ 'MLA Column' => __( 'MLA Column', 'media-library-assistant' ),
2909
+ 'Quick Edit' => __( 'Quick Edit', 'media-library-assistant' ),
2910
+ 'Bulk Edit' => __( 'Bulk Edit', 'media-library-assistant' ),
2911
  'table_rows' => $table_rows,
2912
  'help' => $value['help']
2913
  );
2914
+
2915
  return MLAData::mla_parse_template( self::$mla_option_templates['custom-field-table'], $option_values );
2916
  case 'update':
2917
  case 'delete':
2918
  $settings_changed = false;
2919
  $messages = '';
2920
+
2921
  $results = self::_update_custom_field_mapping( $current_values, $args );
2922
  $messages .= $results['message'];
2923
  $current_values = $results['values'];
2924
  $settings_changed = $results['changed'];
2925
+
2926
  if ( $settings_changed ) {
2927
  $settings_changed = MLAOptions::mla_update_option( 'custom_field_mapping', $current_values );
2928
+ if ( $settings_changed ) {
2929
+ $results = __( 'Custom field mapping rules updated.', 'media-library-assistant' ) . "\r\n";
2930
+ } else {
2931
+ $results = __( 'ERROR: Custom field mapping rules update failed.', 'media-library-assistant' ) . "\r\n";
2932
+ }
2933
+ } else {
2934
+ $results = __( 'Custom field no mapping rule changes detected.', 'media-library-assistant' ) . "\r\n";
2935
  }
2936
+
 
 
2937
  return $results . $messages;
2938
  case 'reset':
2939
  $current_values = self::$mla_option_definitions['custom_field_mapping']['std'];
2940
  $settings_changed = MLAOptions::mla_update_option( 'custom_field_mapping', $current_values );
2941
+ if ( $settings_changed ) {
2942
+ return __( 'Custom field mapping settings saved.', 'media-library-assistant' ) . "\r\n";
2943
+ } else {
2944
+ return __( 'ERROR: Custom field mapping settings reset failed.', 'media-library-assistant' ) . "\r\n";
2945
+ }
2946
  default:
2947
+ /* translators: 1: option name 2: action, e.g., update, delete, reset */
2948
+ return '<br>' . sprintf( __( 'ERROR: Custom %1$s unknown action "%2$s"', 'media-library-assistant' ), $key, $action ) . "\r\n";
2949
  } // switch $action
2950
  } // mla_custom_field_option_handler
2951
 
2957
  * @param object post object with current values
2958
  * @param string category to evaluate against, e.g., iptc_exif_standard_mapping or iptc_exif_mapping
2959
  * @param array (optional) iptc_exif_mapping values, default - current option value
2960
+ * @param array (optional) _wp_attachment_metadata, for MLAOptions::mla_update_attachment_metadata_filter
2961
  *
2962
  * @return array Updates suitable for MLAData::mla_update_single_item, if any
2963
  */
2964
+ public static function mla_evaluate_iptc_exif_mapping( $post, $category, $settings = NULL, $attachment_metadata = NULL ) {
2965
+ $image_metadata = MLAData::mla_fetch_attachment_image_metadata( $post->ID );
2966
  $updates = array();
2967
  $update_all = ( 'iptc_exif_mapping' == $category );
2968
+ if ( NULL == $settings ) {
2969
  $settings = self::mla_get_option( 'iptc_exif_mapping' );
2970
+ }
2971
 
2972
+ $settings = apply_filters( 'mla_mapping_settings', $settings, $post->ID, $category, $attachment_metadata );
2973
+
2974
  if ( $update_all || ( 'iptc_exif_standard_mapping' == $category ) ) {
2975
+ foreach ( $settings['standard'] as $setting_key => $setting_value ) {
2976
+ $setting_value = apply_filters( 'mla_mapping_rule', $setting_value, $post->ID, 'iptc_exif_standard_mapping', $attachment_metadata );
2977
+ if ( NULL === $setting_value ) {
2978
+ continue;
2979
+ }
2980
+
2981
+ if ( 'none' == $setting_value['iptc_value'] ) {
2982
  $iptc_value = '';
2983
+ } else {
2984
+ $iptc_value = MLAData::mla_iptc_metadata_value( $setting_value['iptc_value'], $image_metadata );
2985
+ }
2986
+
2987
+ $iptc_value = apply_filters( 'mla_mapping_iptc_value', $iptc_value, $setting_key, $post->ID, 'iptc_exif_standard_mapping', $attachment_metadata );
2988
+
2989
+ if ( 'template:' == substr( $setting_value['exif_value'], 0, 9 ) ) {
2990
  $data_value = array(
2991
+ 'name' => $setting_key,
2992
  'data_source' => 'template',
2993
+ 'meta_name' => substr( $setting_value['exif_value'], 9 ),
2994
+ 'keep_existing' => $setting_value['keep_existing'],
2995
  'format' => 'native',
2996
  'option' => 'text' );
2997
+
2998
+ $exif_value = self::_evaluate_data_source( $post->ID, 'single_attachment_mapping', $data_value, $attachment_metadata );
2999
+ } else {
3000
+ $exif_value = MLAData::mla_exif_metadata_value( $setting_value['exif_value'], $image_metadata );
3001
+ }
3002
+
3003
+ $exif_value = apply_filters( 'mla_mapping_exif_value', $exif_value, $setting_key, $post->ID, 'iptc_exif_standard_mapping', $attachment_metadata );
3004
+
3005
+ $keep_existing = (boolean) $setting_value['keep_existing'];
3006
+
3007
+ if ( $setting_value['iptc_first'] ) {
3008
+ if ( ! empty( $iptc_value ) ) {
3009
  $new_text = $iptc_value;
3010
+ } else {
3011
  $new_text = $exif_value;
3012
+ }
3013
+ } else {
3014
+ if ( ! empty( $exif_value ) ) {
3015
  $new_text = $exif_value;
3016
+ } else {
3017
  $new_text = $iptc_value;
3018
+ }
3019
+ }
3020
 
3021
  if ( is_array( $new_text ) ) {
3022
+ $new_text = implode( ',', $new_text );
3023
  }
3024
+
3025
  $new_text = trim( convert_chars( $new_text ) );
3026
+ if ( !empty( $new_text ) ) {
3027
+ switch ( $setting_key ) {
3028
  case 'post_title':
3029
  if ( ( empty( $post->post_title ) || !$keep_existing ) &&
3030
  ( trim( $new_text ) && ! is_numeric( sanitize_title( $new_text ) ) ) )
3031
+ $updates[ $setting_key ] = $new_text;
3032
  break;
3033
  case 'post_name':
3034
+ $updates[ $setting_key ] = wp_unique_post_slug( sanitize_title( $new_text ), $post->ID, $post->post_status, $post->post_type, $post->post_parent);
3035
  break;
3036
  case 'image_alt':
3037
  $old_text = get_metadata( 'post', $post->ID, '_wp_attachment_image_alt', true );
3038
  if ( empty( $old_text ) || !$keep_existing ) {
3039
+ $updates[ $setting_key ] = $new_text; }
3040
  break;
3041
  case 'post_excerpt':
3042
+ if ( empty( $post->post_excerpt ) || !$keep_existing ) {
3043
+ $updates[ $setting_key ] = $new_text;
3044
+ }
3045
  break;
3046
  case 'post_content':
3047
+ if ( empty( $post->post_content ) || !$keep_existing ) {
3048
+ $updates[ $setting_key ] = $new_text;
3049
+ }
3050
  break;
3051
  default:
3052
  // ignore anything else
3053
+ } // $setting_key
3054
+ }
3055
  } // foreach new setting
3056
  } // update standard field mappings
3057
+
3058
  if ( $update_all || ( 'iptc_exif_taxonomy_mapping' == $category ) ) {
3059
  $tax_inputs = array();
3060
  $tax_actions = array();
3061
+
3062
+ foreach ( $settings['taxonomy'] as $setting_key => $setting_value ) {
3063
+ /*
3064
+ * Convert checkbox value(s)
3065
+ */
3066
+ $setting_value['hierarchical'] = (boolean) $setting_value['hierarchical'];
3067
+
3068
+ $setting_value = apply_filters( 'mla_mapping_rule', $setting_value, $post->ID, 'iptc_exif_taxonomy_mapping', $attachment_metadata );
3069
+ if ( NULL === $setting_value ) {
3070
+ continue;
3071
+ }
3072
+
3073
+ if ( 'none' == $setting_value['iptc_value'] ) {
3074
  $iptc_value = '';
3075
+ } else {
3076
+ $iptc_value = MLAData::mla_iptc_metadata_value( $setting_value['iptc_value'], $image_metadata );
3077
+ }
3078
+
3079
+ $iptc_value = apply_filters( 'mla_mapping_iptc_value', $iptc_value, $setting_key, $post->ID, 'iptc_exif_taxonomy_mapping', $attachment_metadata );
3080
+
3081
+ if ( 'template:' == substr( $setting_value['exif_value'], 0, 9 ) ) {
3082
  $data_value = array(
3083
+ 'name' => $setting_key,
3084
  'data_source' => 'template',
3085
+ 'meta_name' => substr( $setting_value['exif_value'], 9 ),
3086
+ 'keep_existing' => $setting_value['keep_existing'],
3087
  'format' => 'native',
3088
  'option' => 'array' );
3089
+
3090
+ $exif_value = trim( self::_evaluate_data_source( $post->ID, 'single_attachment_mapping', $data_value, $attachment_metadata ) );
3091
+ } else {
3092
+ $exif_value = MLAData::mla_exif_metadata_value( $setting_value['exif_value'], $image_metadata );
3093
  }
 
 
 
 
 
3094
 
3095
+ $exif_value = apply_filters( 'mla_mapping_exif_value', $exif_value, $setting_key, $post->ID, 'iptc_exif_taxonomy_mapping', $attachment_metadata );
3096
+
3097
+ $tax_action = ( $setting_value['keep_existing'] ) ? 'add' : 'replace';
3098
+ $tax_parent = ( isset( $setting_value['parent'] ) && (0 != (integer) $setting_value['parent'] ) ) ? (integer) $setting_value['parent'] : 0;
3099
+
3100
+ if ( $setting_value['iptc_first'] ) {
3101
+ if ( ! empty( $iptc_value ) ) {
3102
  $new_text = $iptc_value;
3103
+ } else {
3104
  $new_text = $exif_value;
3105
+ }
3106
+ } else {
3107
+ if ( ! empty( $exif_value ) ) {
3108
  $new_text = $exif_value;
3109
+ } else {
3110
  $new_text = $iptc_value;
3111
+ }
3112
+ }
3113
 
3114
  /*
3115
  * Parse out individual terms if Delimiter(s) are present
3116
  */
3117
+ if ( ! empty( $setting_value['delimiters'] ) ) {
3118
+ $text = $setting_value['delimiters'];
3119
  $delimiters = array();
3120
  while ( ! empty( $text ) ) {
3121
  $delimiters[] = $text[0];
3122
  $text = substr($text, 1);
3123
  }
3124
+
3125
+ if ( is_scalar( $new_text ) ) {
3126
  $new_text = array( $new_text );
3127
+ }
3128
+
3129
  foreach( $delimiters as $delimiter ) {
3130
  $new_terms = array();
3131
  foreach ( $new_text as $text ) {
3132
  $fragments = explode( $delimiter, $text );
3133
  foreach( $fragments as $fragment ) {
3134
  $fragment = trim( $fragment );
3135
+ if ( ! empty( $fragment ) ) {
3136
  $new_terms[] = $fragment;
3137
+ }
3138
  } // foreach fragment
3139
  } // foreach $text
3140
  $new_text = array_unique( $new_terms );
3141
  } // foreach $delimiter
3142
  }
3143
+
3144
  if ( !empty( $new_text ) ) {
3145
+ if ( $setting_value['hierarchical'] ) {
3146
+ if ( is_string( $new_text ) ) {
3147
  $new_text = array( $new_text );
3148
+ }
3149
+
3150
  $new_terms = array();
3151
  foreach ( $new_text as $new_term ) {
3152
+ $term_object = term_exists( $new_term, $setting_key );
3153
+ if ($term_object !== 0 && $term_object !== null) {
3154
  $new_terms[] = $term_object['term_id'];
3155
+ } else {
3156
+ $term_object = wp_insert_term( $new_term, $setting_key, array( 'parent' => $tax_parent ) );
3157
+ if ( isset( $term_object['term_id'] ) ) {
3158
  $new_terms[] = $term_object['term_id'];
3159
+ }
3160
  }
3161
  } // foreach new_term
3162
+
3163
+ $tax_inputs[ $setting_key ] = $new_terms;
3164
  } // hierarchical
3165
  else {
3166
+ $tax_inputs[ $setting_key ] = $new_text;
3167
  }
3168
 
3169
+ $tax_actions[ $setting_key ] = $tax_action;
3170
  } // new_text
3171
  } // foreach new setting
3172
+
3173
+ if ( ! empty( $tax_inputs ) ) {
3174
  $updates['taxonomy_updates'] = array ( 'inputs' => $tax_inputs, 'actions' => $tax_actions );
3175
+ }
3176
  } // update taxonomy term mappings
3177
 
3178
  if ( $update_all || ( 'iptc_exif_custom_mapping' == $category ) ) {
3179
  $custom_updates = array();
3180
+ foreach ( $settings['custom'] as $setting_key => $setting_value ) {
3181
+ $setting_value = apply_filters( 'mla_mapping_rule', $setting_value, $post->ID, 'iptc_exif_custom_mapping', $attachment_metadata );
3182
+ if ( NULL === $setting_value ) {
3183
+ continue;
3184
+ }
3185
+
3186
+ if ( 'none' == $setting_value['iptc_value'] ) {
3187
  $iptc_value = '';
3188
+ } else {
3189
+ $iptc_value = MLAData::mla_iptc_metadata_value( $setting_value['iptc_value'], $image_metadata );
3190
+ }
3191
+
3192
+ $iptc_value = apply_filters( 'mla_mapping_iptc_value', $iptc_value, $setting_key, $post->ID, 'iptc_exif_custom_mapping', $attachment_metadata );
3193
+
3194
+ if ( 'template:' == substr( $setting_value['exif_value'], 0, 9 ) ) {
3195
  $data_value = array(
3196
+ 'name' => $setting_key,
3197
  'data_source' => 'template',
3198
+ 'meta_name' => substr( $setting_value['exif_value'], 9 ),
3199
+ 'keep_existing' => $setting_value['keep_existing'],
3200
  'format' => 'native',
3201
  'option' => 'text' );
3202
+
3203
+ $exif_value = self::_evaluate_data_source( $post->ID, 'single_attachment_mapping', $data_value, $attachment_metadata );
3204
+ } else {
3205
+ $exif_value = MLAData::mla_exif_metadata_value( $setting_value['exif_value'], $image_metadata );
3206
  }
3207
+
3208
+ $exif_value = apply_filters( 'mla_mapping_exif_value', $exif_value, $setting_key, $post->ID, 'iptc_exif_custom_mapping', $attachment_metadata );
3209
+
3210
+ if ( $setting_value['iptc_first'] ) {
3211
+ if ( ! empty( $iptc_value ) ) {
3212
  $new_text = $iptc_value;
3213
+ } else {
3214
  $new_text = $exif_value;
3215
+ }
3216
+ } else {
3217
+ if ( ! empty( $exif_value ) ) {
3218
  $new_text = $exif_value;
3219
+ } else {
3220
  $new_text = $iptc_value;
3221
+ }
3222
+ }
3223
 
3224
  if ( is_array( $new_text ) ) {
3225
  $new_text = implode( ',', $new_text );
3226
  }
3227
+
3228
+ if ( $setting_value['keep_existing'] ) {
3229
+ if ( 'meta:' == substr( $setting_key, 0, 5 ) ) {
3230
+ $meta_key = substr( $setting_key, 5 );
3231
+
3232
+ if ( NULL === $attachment_metadata ) {
3233
+ $attachment_metadata = maybe_unserialize( get_metadata( 'post', $post->ID, '_wp_attachment_metadata', true ) );
3234
+ }
3235
+
3236
+ if ( array( $attachment_metadata ) ) {
3237
  $old_value = MLAData::mla_find_array_element( $meta_key, $attachment_metadata, 'array' );
3238
+ } else {
3239
  $old_value = '';
3240
+ }
3241
+ } else {
3242
+ if ( is_string( $old_value = get_metadata( 'post', $post->ID, $setting_key, true ) ) ) {
3243
  $old_value = trim( $old_value );
3244
+ }
3245
  }
3246
+
3247
  if ( ( ! empty( $new_text ) ) && empty( $old_value ) ) {
3248
+ $custom_updates[ $setting_key ] = $new_text;
3249
  }
3250
  } // keep_existing
3251
  else {
3252
+ $custom_updates[ $setting_key ] = $new_text;
3253
  }
3254
  } // foreach new setting
3255
+
3256
+ if ( ! empty( $custom_updates ) ) {
3257
  $updates['custom_updates'] = $custom_updates;
3258
+ }
3259
  } // update custom field mappings
3260
 
3261
+ $updates = apply_filters( 'mla_mapping_updates', $updates, $post_id, $category, $settings, $attachment_metadata );
3262
  return $updates;
3263
  } // mla_evaluate_iptc_exif_mapping
3264
+
3265
  /**
3266
  * Compose an IPTC Options list with current selection
3267
  *
3277
  $option_values = array (
3278
  'selected' => ( 'none' == $selection ) ? 'selected="selected"' : '',
3279
  'value' => 'none',
3280
+ 'text' => '&mdash; ' . __( 'None (select a value)', 'media-library-assistant' ) . ' &mdash;'
3281
  );
3282
+
3283
  $iptc_options = MLAData::mla_parse_template( $option_template, $option_values );
3284
  foreach ( MLAData::$mla_iptc_keys as $iptc_name => $iptc_code ) {
3285
  $option_values = array (
3287
  'value' => $iptc_code,
3288
  'text' => $iptc_code . ' ' . $iptc_name
3289
  );
3290
+
3291
  $iptc_options .= MLAData::mla_parse_template( $option_template, $option_values );
3292
  } // foreach iptc_key
3293
+
3294
  return $iptc_options;
3295
  } // _compose_iptc_option_list
3296
+
3297
  /**
3298
  * Compose an hierarchical taxonomy Parent options list with current selection
3299
  *
3306
  * @return string HTML markup with select field options
3307
  */
3308
  private static function _compose_parent_option_list( $taxonomy, $selection = 0 ) {
3309
+ $dropdown_options = array(
3310
+ 'show_option_all' => '',
3311
+ 'show_option_none' => '&mdash; ' . __( 'None (select a value)', 'media-library-assistant' ) . ' &mdash;',
3312
+ 'orderby' => 'name',
3313
+ 'order' => 'ASC',
3314
+ 'show_count' => false,
3315
+ 'hide_empty' => false,
3316
+ 'child_of' => 0,
3317
+ 'exclude' => '',
3318
+ // 'exclude_tree => '',
3319
+ 'echo' => true,
3320
+ 'depth' => 0,
3321
+ 'tab_index' => 0,
3322
+ 'name' => 'mla_filter_term',
3323
+ 'id' => 'name',
3324
+ 'class' => 'postform',
3325
+ 'selected' => ( 0 == $selection) ? -1 : $selection,
3326
+ 'hierarchical' => true,
3327
+ 'pad_counts' => false,
3328
+ 'taxonomy' => $taxonomy,
3329
+ 'hide_if_empty' => false
3330
  );
3331
+
3332
+ ob_start();
3333
+ wp_dropdown_categories( $dropdown_options );
3334
+ $dropdown = ob_get_contents();
3335
+ ob_end_clean();
3336
+
3337
+ $dropdown_options = substr( $dropdown, strpos( $dropdown, ' >' ) + 2 );
3338
+ $dropdown_options = substr( $dropdown_options, 0, strpos( $dropdown_options, '</select>' ) );
3339
+ $dropdown_options = str_replace( "value='-1' ", 'value="0"', $dropdown_options );
3340
+
3341
+ return $dropdown_options;
 
 
 
 
3342
  } // _compose_parent_option_list
3343
+
3344
  /**
3345
  * Update Standard field portion of IPTC/EXIF mappings
3346
  *
3360
  if ( isset( $current_values['standard'][ $new_key ] ) ) {
3361
  $old_values = $current_values['standard'][ $new_key ];
3362
  $any_setting_changed = false;
3363
+ } else {
3364
+ /* translators: 1: custom field name */
3365
+ $error_list .= '<br>' . sprintf( __( 'ERROR: No old values for %1$s.', 'media-library-assistant' ), $new_key ) . "\r\n";
3366
  continue;
3367
  }
3368
+
3369
+ /*
3370
+ * Field Title can change as a result of localization
3371
+ */
3372
+ $new_value['name'] = self::$mla_option_definitions['iptc_exif_mapping']['std']['standard'][ $new_key ]['name'];
3373
 
3374
+ if ( $old_values['name'] != $new_value['name'] ) {
3375
+ $any_setting_changed = true;
3376
+ /* translators: 1: custom field name 2: attribute 3: old value 4: new value */
3377
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s from %3$s to %4$s.', 'media-library-assistant' ), $old_values['name'], __( 'Field Title', 'media-library-assistant' ), $old_values['name'], $new_value['name'] ) . "\r\n";
3378
+ $old_values['name'] = $new_value['name'];
3379
+ }
3380
+
3381
  if ( $old_values['iptc_value'] != $new_value['iptc_value'] ) {
3382
  $any_setting_changed = true;
3383
+ /* translators: 1: custom field name 2: attribute 3: old value 4: new value */
3384
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s from %3$s to %4$s.', 'media-library-assistant' ), $old_values['name'], __( 'IPTC Value', 'media-library-assistant' ), $old_values['iptc_value'], $new_value['iptc_value'] ) . "\r\n";
3385
  $old_values['iptc_value'] = $new_value['iptc_value'];
3386
  }
3387
 
3388
  if ( $old_values['exif_value'] != $new_value['exif_value'] ) {
3389
  $any_setting_changed = true;
3390
+ /* translators: 1: custom field name 2: attribute 3: old value 4: new value */
3391
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s from %3$s to %4$s.', 'media-library-assistant' ), $old_values['name'], __( 'EXIF Value', 'media-library-assistant' ), $old_values['exif_value'], $new_value['exif_value'] ) . "\r\n";
3392
  $old_values['exif_value'] = $new_value['exif_value'];
3393
  }
3394
 
3395
  if ( $new_value['iptc_first'] ) {
3396
  $boolean_value = true;
3397
+ $boolean_text = __( 'EXIF to IPTC', 'media-library-assistant' );
3398
+ } else {
 
3399
  $boolean_value = false;
3400
+ $boolean_text = __( 'IPTC to EXIF', 'media-library-assistant' );
3401
  }
3402
  if ( $old_values['iptc_first'] != $boolean_value ) {
3403
  $any_setting_changed = true;
3404
+ /* translators: 1: custom field name 2: attribute 3: old value 'to' new value */
3405
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s value from %3$s.', 'media-library-assistant' ), $old_values['name'], __( 'Priority', 'media-library-assistant' ), $boolean_text ) . "\r\n";
3406
  $old_values['iptc_first'] = $boolean_value;
3407
  }
3408
 
3409
  if ( $new_value['keep_existing'] ) {
3410
  $boolean_value = true;
3411
+ $boolean_text = __( 'Replace to Keep', 'media-library-assistant' );
3412
+ } else {
 
3413
  $boolean_value = false;
3414
+ $boolean_text = __( 'Keep to Replace', 'media-library-assistant' );
3415
  }
3416
  if ( $old_values['keep_existing'] != $boolean_value ) {
3417
  $any_setting_changed = true;
3418
+ /* translators: 1: custom field name 2: attribute 3: old value 'to' new value */
3419
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s value from %3$s.', 'media-library-assistant' ), $old_values['name'], __( 'Existing Text', 'media-library-assistant' ), $boolean_text ) . "\r\n";
3420
  $old_values['keep_existing'] = $boolean_value;
3421
  }
3422
+
3423
  if ( $any_setting_changed ) {
3424
  $settings_changed = true;
3425
  $current_values['standard'][ $new_key ] = $old_values;
3426
  }
3427
  } // new standard value
3428
+
3429
  /*
3430
  * Uncomment this for debugging.
3431
  */
3433
 
3434
  return array( 'message' => $error_list, 'values' => $current_values, 'changed' => $settings_changed );
3435
  } // _update_iptc_exif_standard_mapping
3436
+
3437
  /**
3438
  * Update Taxonomy term portion of IPTC/EXIF mappings
3439
  *
3452
  foreach ( $new_values['taxonomy'] as $new_key => $new_value ) {
3453
  if ( isset( $current_values['taxonomy'][ $new_key ] ) ) {
3454
  $old_values = $current_values['taxonomy'][ $new_key ];
3455
+ } else {
 
3456
  $old_values = array(
3457
  'name' => $new_value['name'],
3458
  'hierarchical' => $new_value['hierarchical'],
3464
  'parent' => 0
3465
  );
3466
  }
3467
+
3468
  $any_setting_changed = false;
3469
  if ( $old_values['iptc_value'] != $new_value['iptc_value'] ) {
3470
  $any_setting_changed = true;
3471
+ /* translators: 1: custom field name 2: attribute 3: old value 4: new value */
3472
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s from %3$s to %4$s.', 'media-library-assistant' ), $old_values['name'], __( 'IPTC Value', 'media-library-assistant' ), $old_values['iptc_value'], $new_value['iptc_value'] ) . "\r\n";
3473
  $old_values['iptc_value'] = $new_value['iptc_value'];
3474
  }
3475
 
3476
  if ( $old_values['exif_value'] != $new_value['exif_value'] ) {
3477
  $any_setting_changed = true;
3478
+ /* translators: 1: custom field name 2: attribute 3: old value 4: new value */
3479
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s from %3$s to %4$s.', 'media-library-assistant' ), $old_values['name'], __( 'EXIF Value', 'media-library-assistant' ), $old_values['exif_value'], $new_value['exif_value'] ) . "\r\n";
3480
  $old_values['exif_value'] = $new_value['exif_value'];
3481
  }
3482
 
3483
  if ( $new_value['iptc_first'] ) {
3484
  $boolean_value = true;
3485
+ $boolean_text = __( 'EXIF to IPTC', 'media-library-assistant' );
3486
+ } else {
 
3487
  $boolean_value = false;
3488
+ $boolean_text = __( 'IPTC to EXIF', 'media-library-assistant' );
3489
  }
3490
  if ( $old_values['iptc_first'] != $boolean_value ) {
3491
  $any_setting_changed = true;
3492
+ /* translators: 1: custom field name 2: attribute 3: old value 'to' new value */
3493
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s value from %3$s.', 'media-library-assistant' ), $old_values['name'], __( 'Priority', 'media-library-assistant' ), $boolean_text ) . "\r\n";
3494
  $old_values['iptc_first'] = $boolean_value;
3495
  }
3496
 
3497
  if ( $new_value['keep_existing'] ) {
3498
  $boolean_value = true;
3499
+ $boolean_text = __( 'Replace to Keep', 'media-library-assistant' );
3500
+ } else {
 
3501
  $boolean_value = false;
3502
+ $boolean_text = __( 'Keep to Replace', 'media-library-assistant' );
3503
  }
3504
  if ( $old_values['keep_existing'] != $boolean_value ) {
3505
  $any_setting_changed = true;
3506
+ /* translators: 1: custom field name 2: attribute 3: old value 'to' new value */
3507
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s value from %3$s.', 'media-library-assistant' ), $old_values['name'], __( 'Existing Text', 'media-library-assistant' ), $boolean_text ) . "\r\n";
3508
  $old_values['keep_existing'] = $boolean_value;
3509
  }
3510
+
3511
  if ( $old_values['delimiters'] != $new_value['delimiters'] ) {
3512
  $any_setting_changed = true;
3513
+ /* translators: 1: custom field name 2: attribute 3: old value 4: new value */
3514
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s from %3$s to %4$s.', 'media-library-assistant' ), $old_values['name'], __( 'Delimiter(s)', 'media-library-assistant' ), $old_values['delimiters'], $new_value['delimiters'] ) . "\r\n";
3515
  $old_values['delimiters'] = $new_value['delimiters'];
3516
  }
3517
 
3518
  if ( isset( $new_value['parent'] ) && ( $old_values['parent'] != $new_value['parent'] ) ) {
3519
  $any_setting_changed = true;
3520
+ /* translators: 1: custom field name 2: attribute 3: old value 4: new value */
3521
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s from %3$s to %4$s.', 'media-library-assistant' ), $old_values['name'], __( 'Parent', 'media-library-assistant' ), $old_values['parent'], $new_value['parent'] ) . "\r\n";
3522
  $old_values['parent'] = $new_value['parent'];
3523
  }
3524
 
3535
 
3536
  return array( 'message' => $error_list, 'values' => $current_values, 'changed' => $settings_changed );
3537
  } // _update_iptc_exif_taxonomy_mapping
3538
+
3539
  /**
3540
  * Update Custom field portion of IPTC/EXIF mappings
3541
  *
3554
 
3555
  foreach ( $new_values['custom'] as $new_key => $new_value ) {
3556
  $any_setting_changed = false;
3557
+
3558
  /*
3559
  * Check for the addition of a new field or new rule
3560
  */
3561
  if ( self::MLA_NEW_CUSTOM_FIELD == $new_key ) {
3562
  $new_key = trim( $new_value['name'] );
3563
 
3564
+ if ( empty( $new_key ) ) {
3565
  continue;
3566
+ }
3567
+
3568
  if ( in_array( $new_key, $custom_field_names ) ) {
3569
+ /* translators: 1: custom field name */
3570
+ $error_list .= '<br>' . sprintf( __( 'ERROR: New field %1$s already exists.', 'media-library-assistant' ), $new_key ) . "\r\n";
3571
  continue;
3572
  }
3573
 
3574
+ /* translators: 1: custom field name */
3575
+ $message_list .= '<br>' . sprintf( __( 'Adding new field %1$s.', 'media-library-assistant' ), $new_key ) . "\r\n";
3576
  $any_setting_changed = true;
3577
+ } elseif ( self::MLA_NEW_CUSTOM_RULE == $new_key ) {
 
3578
  $new_key = trim( $new_value['name'] );
3579
 
3580
+ if ( 'none' == $new_key ) {
3581
  continue;
3582
+ }
3583
 
3584
+ /* translators: 1: custom field name */
3585
+ $message_list .= '<br>' . sprintf( __( 'Adding new rule for %1$s.', 'media-library-assistant' ), $new_key ) . "\r\n";
3586
  $any_setting_changed = true;
3587
  }
3588
+
3589
  if ( isset( $current_values['custom'][ $new_key ] ) ) {
3590
  $old_values = $current_values['custom'][ $new_key ];
3591
  $any_setting_changed = false;
3592
+ } else {
 
3593
  $old_values = array(
3594
  'name' => $new_key,
3595
  'iptc_value' => 'none',
3598
  'keep_existing' => true
3599
  );
3600
  }
3601
+
3602
  if ( isset( $new_value['action'] ) ) {
3603
  if ( array_key_exists( 'delete_rule', $new_value['action'] ) || array_key_exists( 'delete_field', $new_value['action'] ) ) {
3604
  $settings_changed = true;
3605
+ /* translators: 1: custom field name */
3606
+ $message_list .= '<br>' . sprintf( __( 'Deleting rule for %1$s.', 'media-library-assistant' ), $old_values['name'] ) . "\r\n";
3607
  unset( $current_values['custom'][ $new_key ] );
3608
  $settings_changed = true;
3609
  continue;
3612
 
3613
  if ( $old_values['iptc_value'] != $new_value['iptc_value'] ) {
3614
  $any_setting_changed = true;
3615
+ /* translators: 1: custom field name 2: attribute 3: old value 4: new value */
3616
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s from %3$s to %4$s.', 'media-library-assistant' ), $old_values['name'], __( 'IPTC Value', 'media-library-assistant' ), $old_values['iptc_value'], $new_value['iptc_value'] ) . "\r\n";
3617
  $old_values['iptc_value'] = $new_value['iptc_value'];
3618
  }
3619
 
3620
  if ( $old_values['exif_value'] != $new_value['exif_value'] ) {
3621
  $any_setting_changed = true;
3622
+ /* translators: 1: custom field name 2: attribute 3: old value 4: new value */
3623
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s from %3$s to %4$s.', 'media-library-assistant' ), $old_values['name'], __( 'EXIF Value', 'media-library-assistant' ), $old_values['exif_value'], $new_value['exif_value'] ) . "\r\n";
3624
  $old_values['exif_value'] = $new_value['exif_value'];
3625
  }
3626
 
3627
  if ( $new_value['iptc_first'] ) {
3628
  $boolean_value = true;
3629
+ $boolean_text = __( 'EXIF to IPTC', 'media-library-assistant' );
3630
+ } else {
 
3631
  $boolean_value = false;
3632
+ $boolean_text = __( 'IPTC to EXIF', 'media-library-assistant' );
3633
  }
3634
  if ( $old_values['iptc_first'] != $boolean_value ) {
3635
  $any_setting_changed = true;
3636
+ /* translators: 1: custom field name 2: attribute 3: old value 'to' new value */
3637
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s value from %3$s.', 'media-library-assistant' ), $old_values['name'], __( 'Priority', 'media-library-assistant' ), $boolean_text ) . "\r\n";
3638
  $old_values['iptc_first'] = $boolean_value;
3639
  }
3640
 
3641
  if ( $new_value['keep_existing'] ) {
3642
  $boolean_value = true;
3643
+ $boolean_text = __( 'Replace to Keep', 'media-library-assistant' );
3644
+ } else {
 
3645
  $boolean_value = false;
3646
+ $boolean_text = __( 'Keep to Replace', 'media-library-assistant' );
3647
  }
3648
  if ( $old_values['keep_existing'] != $boolean_value ) {
3649
  $any_setting_changed = true;
3650
+ /* translators: 1: custom field name 2: attribute 3: old value 'to' new value */
3651
+ $message_list .= '<br>' . sprintf( __( '%1$s changing %2$s value from %3$s.', 'media-library-assistant' ), $old_values['name'], __( 'Existing Text', 'media-library-assistant' ), $boolean_text ) . "\r\n";
3652
  $old_values['keep_existing'] = $boolean_value;
3653
  }
3654
+
3655
  if ( $any_setting_changed ) {
3656
  $settings_changed = true;
3657
  $current_values['custom'][ $new_key ] = $old_values;
3658
  }
3659
  } // new standard value
3660
+
3661
  /*
3662
  * Uncomment this for debugging.
3663
  */
3665
 
3666
  return array( 'message' => $error_list, 'values' => $current_values, 'changed' => $settings_changed );
3667
  } // _update_iptc_exif_custom_mapping
3668
+
3669
  /**
3670
  * Generate a list of all (post) Custom Field names
3671
  *
3678
  */
3679
  private static function _get_custom_field_names( ) {
3680
  global $wpdb;
3681
+
3682
  $custom_field_mapping = array_keys( self::mla_get_option( 'custom_field_mapping' ) );
3683
  $iptc_exif_mapping = self::mla_get_option( 'iptc_exif_mapping' );
3684
  $iptc_exif_mapping = array_keys( $iptc_exif_mapping['custom'] );
3691
  HAVING meta_key NOT LIKE '\_%'
3692
  ORDER BY meta_key
3693
  LIMIT $limit" );
3694
+
3695
  if ( $keys ) {
3696
  foreach ( $custom_field_mapping as $value )
3697
+ if ( ! in_array( $value, $keys ) ) {
3698
  $keys[] = $value;
3699
+ }
3700
+
3701
  foreach ( $iptc_exif_mapping as $value )
3702
+ if ( ! in_array( $value, $keys ) ) {
3703
  $keys[] = $value;
3704
+ }
3705
+
3706
  natcasesort($keys);
3707
  }
3708
+
3709
  return $keys;
3710
  } // _get_custom_field_names
3711
+
3712
  /**
3713
  * Render and manage iptc/exif support options
3714
  *
3727
 
3728
  switch ( $action ) {
3729
  case 'render':
3730
+
3731
  switch ( $key ) {
3732
  case 'iptc_exif_standard_mapping':
3733
  $row_template = self::$mla_option_templates['iptc-exif-standard-row'];
3734
  $table_rows = '';
3735
+
3736
  foreach ( $current_values['standard'] as $row_name => $row_value ) {
3737
  $row_values = array (
3738
  'key' => $row_name,
3741
  'exif_size' => self::MLA_EXIF_SIZE,
3742
  'exif_text' => $row_value['exif_value'],
3743
  'iptc_selected' => '',
3744
+ 'IPTC' => __( 'IPTC', 'media-library-assistant' ),
3745
  'exif_selected' => '',
3746
+ 'EXIF' => __( 'EXIF', 'media-library-assistant' ),
3747
  'keep_selected' => '',
3748
+ 'Keep' => __( 'Keep', 'media-library-assistant' ),
3749
+ 'replace_selected' => '',
3750
+ 'Replace' => __( 'Replace', 'media-library-assistant' ),
3751
  );
3752
+
3753
+ if ( $row_value['iptc_first'] ) {
3754
  $row_values['iptc_selected'] = 'selected="selected"';
3755
+ } else {
3756
  $row_values['exif_selected'] = 'selected="selected"';
3757
+ }
3758
+
3759
+ if ( $row_value['keep_existing'] ) {
3760
  $row_values['keep_selected'] = 'selected="selected"';
3761
+ } else {
3762
  $row_values['replace_selected'] = 'selected="selected"';
3763
+ }
3764
 
3765
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
3766
  } // foreach row
3767
+
3768
  $option_values = array (
3769
+ 'Field Title' => __( 'Field Title', 'media-library-assistant' ),
3770
+ 'IPTC Value' => __( 'IPTC Value', 'media-library-assistant' ),
3771
+ 'EXIF/Template Value' => __( 'EXIF/Template Value', 'media-library-assistant' ),
3772
+ 'Priority' => __( 'Priority', 'media-library-assistant' ),
3773
+ 'Existing Text' => __( 'Existing Text', 'media-library-assistant' ),
3774
  'table_rows' => $table_rows,
3775
  'help' => $value['help']
3776
  );
3777
+
3778
  return MLAData::mla_parse_template( self::$mla_option_templates['iptc-exif-standard-table'], $option_values );
3779
  case 'iptc_exif_taxonomy_mapping':
3780
  $row_template = self::$mla_option_templates['iptc-exif-taxonomy-row'];
3781
  $select_template = self::$mla_option_templates['iptc-exif-select'];
3782
  $table_rows = '';
3783
  $taxonomies = get_taxonomies( array ( 'show_ui' => true ), 'objects' );
3784
+
3785
  foreach ( $taxonomies as $row_name => $row_value ) {
3786
  $row_values = array (
3787
  'key' => $row_name,
3791
  'exif_size' => self::MLA_EXIF_SIZE,
3792
  'exif_text' => '',
3793
  'iptc_selected' => '',
3794
+ 'IPTC' => __( 'IPTC', 'media-library-assistant' ),
3795
  'exif_selected' => '',
3796
+ 'EXIF' => __( 'EXIF', 'media-library-assistant' ),
3797
  'keep_selected' => '',
3798
+ 'Keep' => __( 'Keep', 'media-library-assistant' ),
3799
  'replace_selected' => '',
3800
+ 'Replace' => __( 'Replace', 'media-library-assistant' ),
3801
  'delimiters_size' => 4,
3802
  'delimiters_text' => '',
3803
  'parent_select' => ''
3804
  );
3805
+
3806
  if ( array_key_exists( $row_name, $current_values['taxonomy'] ) ) {
3807
  $current_value = $current_values['taxonomy'][ $row_name ];
3808
  $row_values['iptc_field_options'] = self::_compose_iptc_option_list( $current_value['iptc_value'] );
3809
  $row_values['exif_text'] = $current_value['exif_value'];
3810
+
3811
+ if ( $current_value['iptc_first'] ) {
3812
  $row_values['iptc_selected'] = 'selected="selected"';
3813
+ } else {
3814
  $row_values['exif_selected'] = 'selected="selected"';
3815
+ }
3816
+
3817
+ if ( $current_value['keep_existing'] ) {
3818
  $row_values['keep_selected'] = 'selected="selected"';
3819
+ } else {
3820
  $row_values['replace_selected'] = 'selected="selected"';
3821
+ }
3822
 
3823
  $row_values['delimiters_text'] = $current_value['delimiters'];
3824
 
3832
  );
3833
  $row_values['parent_select'] = MLAData::mla_parse_template( $select_template, $select_values );
3834
  }
3835
+ } else {
 
3836
  $row_values['iptc_field_options'] = self::_compose_iptc_option_list( 'none' );
3837
  $row_values['iptc_selected'] = 'selected="selected"';
3838
  $row_values['keep_selected'] = 'selected="selected"';
3850
 
3851
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
3852
  } // foreach row
3853
+
3854
  $option_values = array (
3855
+ 'Field Title' => __( 'Field Title', 'media-library-assistant' ),
3856
+ 'IPTC Value' => __( 'IPTC Value', 'media-library-assistant' ),
3857
+ 'EXIF/Template Value' => __( 'EXIF/Template Value', 'media-library-assistant' ),
3858
+ 'Priority' => __( 'Priority', 'media-library-assistant' ),
3859
+ 'Existing Text' => __( 'Existing Text', 'media-library-assistant' ),
3860
+ 'Delimiter(s)' => __( 'Delimiter(s)', 'media-library-assistant' ),
3861
+ 'Parent' => __( 'Parent', 'media-library-assistant' ),
3862
  'table_rows' => $table_rows,
3863
  'help' => $value['help']
3864
  );
3865
+
3866
  return MLAData::mla_parse_template( self::$mla_option_templates['iptc-exif-taxonomy-table'], $option_values );
3867
  case 'iptc_exif_custom_mapping':
3868
  if ( empty( $current_values['custom'] ) ) {
3869
+ $table_rows = MLAData::mla_parse_template( self::$mla_option_templates['iptc-exif-custom-empty-row'],
3870
+ array(
3871
+ 'No Mapping Rules' => __( 'No Custom Field Mapping Rules Defined', 'media-library-assistant' ),
3872
+ 'column_count' => 5 ) );
3873
+ } else {
3874
  $row_template = self::$mla_option_templates['iptc-exif-custom-rule-row'];
3875
  $table_rows = '';
3876
  }
3888
  'exif_size' => self::MLA_EXIF_SIZE,
3889
  'exif_text' => '',
3890
  'iptc_selected' => '',
3891
+ 'IPTC' => __( 'IPTC', 'media-library-assistant' ),
3892
  'exif_selected' => '',
3893
+ 'EXIF' => __( 'EXIF', 'media-library-assistant' ),
3894
  'keep_selected' => '',
3895
+ 'Keep' => __( 'Keep', 'media-library-assistant' ),
3896
+ 'replace_selected' => '',
3897
+ 'Replace' => __( 'Replace', 'media-library-assistant' ),
3898
+ 'Delete Rule' => __( 'Delete Rule', 'media-library-assistant' ),
3899
+ 'Delete Field' => __( 'Delete Rule AND Field', 'media-library-assistant' ),
3900
+ 'Update Rule' => __( 'Update Rule', 'media-library-assistant' ),
3901
+ 'Map All Attachments' => __( 'Map All Attachments', 'media-library-assistant' ),
3902
  );
3903
+
3904
  $row_values['iptc_field_options'] = self::_compose_iptc_option_list( $current_value['iptc_value'] );
3905
  $row_values['exif_text'] = $current_value['exif_value'];
3906
+
3907
+ if ( $current_value['iptc_first'] ) {
3908
  $row_values['iptc_selected'] = 'selected="selected"';
3909
+ } else {
3910
  $row_values['exif_selected'] = 'selected="selected"';
3911
+ }
3912
+
3913
+ if ( $current_value['keep_existing'] ) {
3914
  $row_values['keep_selected'] = 'selected="selected"';
3915
+ } else {
3916
  $row_values['replace_selected'] = 'selected="selected"';
3917
+ }
3918
 
3919
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
3920
  } // foreach existing rule
3925
  $row_template = self::$mla_option_templates['iptc-exif-custom-new-rule-row'];
3926
  $row_values = array (
3927
  'column_count' => 5 ,
3928
+ 'Add new Rule' => __( 'Add a new Mapping Rule', 'media-library-assistant' ),
3929
  'key' => self::MLA_NEW_CUSTOM_RULE,
3930
  'field_name_options' => self::_compose_custom_field_option_list( 'none', $current_values['custom'] ),
3931
  'iptc_field_options' => self::_compose_iptc_option_list( 'none' ),
3932
  'exif_size' => self::MLA_EXIF_SIZE,
3933
  'exif_text' => '',
3934
  'iptc_selected' => 'selected="selected"',
3935
+ 'IPTC' => __( 'IPTC', 'media-library-assistant' ),
3936
  'exif_selected' => '',
3937
+ 'EXIF' => __( 'EXIF', 'media-library-assistant' ),
3938
  'keep_selected' => 'selected="selected"',
3939
+ 'Keep' => __( 'Keep', 'media-library-assistant' ),
3940
+ 'replace_selected' => '',
3941
+ 'Replace' => __( 'Replace', 'media-library-assistant' ),
3942
+ 'Add Rule' => __( 'Add Rule', 'media-library-assistant' ),
3943
+ 'Map All Attachments' => __( 'Add Rule and Map All Attachments', 'media-library-assistant' ),
3944
  );
3945
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
3946
+
3947
  /*
3948
  * Add a row for defining a new rule, new Custom Field
3949
  */
3950
  $row_template = self::$mla_option_templates['iptc-exif-custom-new-field-row'];
3951
  $row_values = array (
3952
  'column_count' => 5 ,
3953
+ 'Add new Field' => __( 'Add a new Field and Mapping Rule', 'media-library-assistant' ),
3954
  'key' => self::MLA_NEW_CUSTOM_FIELD,
3955
  'field_name_size' => '24',
3956
  'iptc_field_options' => self::_compose_iptc_option_list( 'none' ),
3957
  'exif_size' => self::MLA_EXIF_SIZE,
3958
  'exif_text' => '',
3959
  'iptc_selected' => 'selected="selected"',
3960
+ 'IPTC' => __( 'IPTC', 'media-library-assistant' ),
3961
  'exif_selected' => '',
3962
+ 'EXIF' => __( 'EXIF', 'media-library-assistant' ),
3963
  'keep_selected' => 'selected="selected"',
3964
+ 'Keep' => __( 'Keep', 'media-library-assistant' ),
3965
+ 'replace_selected' => '',
3966
+ 'Replace' => __( 'Replace', 'media-library-assistant' ),
3967
+ 'Add Field' => __( 'Add Field', 'media-library-assistant' ),
3968
+ 'Map All Attachments' => __( 'Add Field and Map All Attachments', 'media-library-assistant' ),
3969
  );
3970
  $table_rows .= MLAData::mla_parse_template( $row_template, $row_values );
3971
+
3972
  $option_values = array (
3973
+ 'Field Title' => __( 'Field Title', 'media-library-assistant' ),
3974
+ 'IPTC Value' => __( 'IPTC Value', 'media-library-assistant' ),
3975
+ 'EXIF/Template Value' => __( 'EXIF/Template Value', 'media-library-assistant' ),
3976
+ 'Priority' => __( 'Priority', 'media-library-assistant' ),
3977
+ 'Existing Text' => __( 'Existing Text', 'media-library-assistant' ),
3978
  'table_rows' => $table_rows,
3979
  'help' => $value['help']
3980
  );
3981
+
3982
  return MLAData::mla_parse_template( self::$mla_option_templates['iptc-exif-custom-table'], $option_values );
3983
  default:
3984
+ /* translators: 1: option name */
3985
+ return '<br>' . sprintf( __( 'ERROR: Render unknown custom %1$s.', 'media-library-assistant' ), $key ) . "\r\n";
3986
  } // switch $key
3987
  case 'update':
3988
  case 'delete':
3989
  $settings_changed = false;
3990
  $messages = '';
3991
+
3992
  switch ( $key ) {
3993
  case 'iptc_exif_standard_mapping':
3994
  $results = self::_update_iptc_exif_standard_mapping( $current_values, $args );
4013
  $messages .= $results['message'];
4014
  $current_values = $results['values'];
4015
  $settings_changed = $results['changed'];
4016
+
4017
  $results = self::_update_iptc_exif_taxonomy_mapping( $current_values, $args );
4018
  $messages .= $results['message'];
4019
  $current_values = $results['values'];
4025
  $settings_changed |= $results['changed'];
4026
  break;
4027
  default:
4028
+ /* translators: 1: option name */
4029
+ return '<br>' . sprintf( __( 'ERROR: Update/delete unknown custom %1$s.', 'media-library-assistant' ), $key ) . "\r\n";
4030
  } // switch $key
4031
+
4032
  if ( $settings_changed ) {
4033
  $settings_changed = MLAOptions::mla_update_option( 'iptc_exif_mapping', $current_values );
4034
+ if ( $settings_changed ) {
4035
+ $results = __( 'IPTC/EXIF mapping settings updated.', 'media-library-assistant' ) . "\r\n";
4036
+ } else {
4037
+ $results = __( 'ERROR: IPTC/EXIF settings update failed.', 'media-library-assistant' ) . "\r\n";
4038
+ }
4039
+ } else {
4040
+ $results = __( 'IPTC/EXIF no mapping changes detected.', 'media-library-assistant' ) . "\r\n";
4041
  }
 
 
4042
 
4043
  return $results . $messages;
4044
  case 'reset':
4046
  case 'iptc_exif_standard_mapping':
4047
  $current_values['standard'] = self::$mla_option_definitions['iptc_exif_mapping']['std']['standard'];
4048
  $settings_changed = MLAOptions::mla_update_option( 'iptc_exif_mapping', $current_values );
4049
+ if ( $settings_changed ) {
4050
+ /* translators: 1: field type */
4051
+ return sprintf( __( '%1$s settings saved.', 'media-library-assistant' ), 'IPTC/EXIF ' . __( 'Standard field', 'media-library-assistant' ) ) . "\r\n";
4052
+ } else {
4053
+ /* translators: 1: field type */
4054
+ return sprintf( __( 'ERROR: IPTC/EXIF %1$s settings update failed.', 'media-library-assistant' ), __( 'Standard field', 'media-library-assistant' ) ) . "\r\n";
4055
+ }
4056
  case 'iptc_exif_taxonomy_mapping':
4057
  $current_values['taxonomy'] = self::$mla_option_definitions['iptc_exif_mapping']['std']['taxonomy'];
4058
  $settings_changed = MLAOptions::mla_update_option( 'iptc_exif_mapping', $current_values );
4059
+ if ( $settings_changed ) {
4060
+ /* translators: 1: field type */
4061
+ return sprintf( __( '%1$s settings saved.', 'media-library-assistant' ), 'IPTC/EXIF ' . __( 'Taxonomy term', 'media-library-assistant' ) ) . "\r\n";
4062
+ } else {
4063
+ /* translators: 1: field type */
4064
+ return sprintf( __( 'ERROR: IPTC/EXIF %1$s settings update failed.', 'media-library-assistant' ), __( 'Taxonomy term', 'media-library-assistant' ) ) . "\r\n";
4065
+ }
4066
  case 'iptc_exif_custom_mapping':
4067
  $current_values['custom'] = self::$mla_option_definitions['iptc_exif_mapping']['std']['custom'];
4068
  $settings_changed = MLAOptions::mla_update_option( 'iptc_exif_mapping', $current_values );
4069
+ if ( $settings_changed ) {
4070
+ /* translators: 1: field type */
4071
+ return sprintf( __( '%1$s settings saved.', 'media-library-assistant' ), 'IPTC/EXIF ' . __( 'Custom field', 'media-library-assistant' ) ) . "\r\n";
4072
+ } else {
4073
+ /* translators: 1: field type */
4074
+ return sprintf( __( 'ERROR: IPTC/EXIF %1$s settings update failed.', 'media-library-assistant' ), __( 'Custom field', 'media-library-assistant' ) ) . "\r\n";
4075
+ }
4076
  case 'iptc_exif_mapping':
4077
  self::mla_delete_option( $key );
4078
+ /* translators: 1: option name, e.g., taxonomy_support */
4079
+ return '<br>' . sprintf( __( 'Reset custom %1$s', 'media-library-assistant' ), $key ) . "\r\n";
4080
  default:
4081
+ /* translators: 1: option name, e.g., taxonomy_support */
4082
+ return '<br>' . sprintf( __( 'ERROR: Reset unknown custom %1$s', 'media-library-assistant' ), $key ) . "\r\n";
4083
  } // switch $key
4084
  default:
4085
+ /* translators: 1: option name 2: action, e.g., update, delete, reset */
4086
+ return '<br>' . sprintf( __( 'ERROR: Custom %1$s unknown action "%2$s"', 'media-library-assistant' ), $key, $action ) . "\r\n";
4087
  } // switch $action
4088
  } // mla_iptc_exif_option_handler
4089
  } // class MLAOptions
includes/class-mla-settings.php CHANGED
@@ -53,7 +53,7 @@ class MLASettings {
53
  * Provides a unique name for the settings page
54
  */
55
  const MLA_SETTINGS_SLUG = 'mla-settings-menu';
56
-
57
  /**
58
  * Holds screen id to match help text to corresponding screen
59
  *
@@ -62,7 +62,7 @@ class MLASettings {
62
  * @var array
63
  */
64
  private static $current_page_hook = '';
65
-
66
  /**
67
  * Initialization function, similar to __construct()
68
  *
@@ -79,7 +79,7 @@ class MLASettings {
79
  add_filter( 'screen_options_show_screen', 'MLASettings::mla_screen_options_show_screen_filter', 10, 2 ); // $show_screen, $this
80
  self::_version_upgrade();
81
  }
82
-
83
  /**
84
  * Database and option update check, for installing new versions
85
  *
@@ -89,7 +89,7 @@ class MLASettings {
89
  */
90
  private static function _version_upgrade( ) {
91
  $current_version = MLAOptions::mla_get_option( MLAOptions::MLA_VERSION_OPTION );
92
-
93
  if ( ((float)'.30') > ((float)$current_version) ) {
94
  /*
95
  * Convert attachment_category and _tag to taxonomy_support;
@@ -100,13 +100,15 @@ class MLASettings {
100
  if ( ! ( ( 'checked' == $category_option ) && ( 'checked' == $tag_option ) ) ) {
101
  $tax_option = MLAOptions::mla_get_option( MLAOptions::MLA_TAXONOMY_SUPPORT );
102
  if ( 'checked' != $category_option ) {
103
- if ( isset( $tax_option['tax_support']['attachment_category'] ) )
104
  unset( $tax_option['tax_support']['attachment_category'] );
 
105
  }
106
 
107
  if ( 'checked' != $tag_option ) {
108
- if ( isset( $tax_option['tax_support']['attachment_tag'] ) )
109
  unset( $tax_option['tax_support']['attachment_tag'] );
 
110
  }
111
 
112
  MLAOptions::mla_taxonomy_option_handler( 'update', 'taxonomy_support', MLAOptions::$mla_option_definitions['taxonomy_support'], $tax_option );
@@ -115,13 +117,13 @@ class MLASettings {
115
  MLAOptions::mla_delete_option( 'attachment_category' );
116
  MLAOptions::mla_delete_option( 'attachment_tag' );
117
  } // version is less than .30
118
-
119
  if ( ((float)'1.13') > ((float)$current_version) ) {
120
  /*
121
  * Add quick_edit and bulk_edit values to custom field mapping rules
122
  */
123
  $new_values = array();
124
-
125
  foreach ( MLAOptions::mla_get_option( 'custom_field_mapping' ) as $key => $value ) {
126
  $value['quick_edit'] = ( isset( $value['quick_edit'] ) && $value['quick_edit'] ) ? true : false;
127
  $value['bulk_edit'] = ( isset( $value['bulk_edit'] ) && $value['bulk_edit'] ) ? true : false;
@@ -130,13 +132,13 @@ class MLASettings {
130
 
131
  MLAOptions::mla_update_option( 'custom_field_mapping', $new_values );
132
  } // version is less than 1.13
133
-
134
  if ( ((float)'1.30') > ((float)$current_version) ) {
135
  /*
136
  * Add metadata values to custom field mapping rules
137
  */
138
  $new_values = array();
139
-
140
  foreach ( MLAOptions::mla_get_option( 'custom_field_mapping' ) as $key => $value ) {
141
  $value['meta_name'] = isset( $value['meta_name'] ) ? $value['meta_name'] : '';
142
  $value['meta_single'] = ( isset( $value['meta_single'] ) && $value['meta_single'] ) ? true : false;
@@ -146,39 +148,40 @@ class MLASettings {
146
 
147
  MLAOptions::mla_update_option( 'custom_field_mapping', $new_values );
148
  } // version is less than 1.30
149
-
150
  if ( ((float)'1.40') > ((float)$current_version) ) {
151
  /*
152
  * Add metadata values to custom field mapping rules
153
  */
154
  $new_values = array();
155
-
156
  foreach ( MLAOptions::mla_get_option( 'custom_field_mapping' ) as $key => $value ) {
157
  $value['no_null'] = ( isset( $value['no_null'] ) && $value['no_null'] ) ? true : false;
158
-
159
- if ( isset( $value['meta_single'] ) && $value['meta_single'] )
160
  $value['option'] = 'single';
161
- elseif ( isset( $value['meta_export'] ) && $value['meta_export'] )
162
  $value['option'] = 'export';
163
- else
164
  $value['option'] = 'text';
165
-
 
166
  unset( $value['meta_single'] );
167
  unset( $value['meta_export'] );
168
-
169
  $new_values[ $key ] = $value;
170
  }
171
 
172
  MLAOptions::mla_update_option( 'custom_field_mapping', $new_values );
173
  } // version is less than 1.40
174
-
175
  if ( ((float)'1.60') > ((float)$current_version) ) {
176
  /*
177
  * Add delimiters values to taxonomy mapping rules
178
  */
179
  $option_value = MLAOptions::mla_get_option( 'iptc_exif_mapping' );
180
  $new_values = array();
181
-
182
  foreach ( $option_value['taxonomy'] as $key => $value ) {
183
  $value['delimiters'] = isset( $value['delimiters'] ) ? $value['delimiters'] : '';
184
  $new_values[ $key ] = $value;
@@ -187,10 +190,10 @@ class MLASettings {
187
  $option_value['taxonomy'] = $new_values;
188
  MLAOptions::mla_update_option( 'iptc_exif_mapping', $option_value );
189
  } // version is less than 1.60
190
-
191
  MLAOptions::mla_update_option( MLAOptions::MLA_VERSION_OPTION, MLA::CURRENT_MLA_VERSION );
192
  }
193
-
194
  /**
195
  * Perform one-time actions on plugin activation
196
  *
@@ -203,7 +206,7 @@ class MLASettings {
203
  public static function mla_activation_hook( ) {
204
  // self::_create_alt_text_view(); DELETED v1.10, NO LONGER REQUIRED
205
  }
206
-
207
  /**
208
  * Perform one-time actions on plugin deactivation
209
  *
@@ -215,7 +218,7 @@ class MLASettings {
215
  */
216
  public static function mla_deactivation_hook( ) {
217
  global $wpdb, $table_prefix;
218
-
219
  $view_name = $table_prefix . MLA_OPTION_PREFIX . MLAData::MLA_ALT_TEXT_VIEW_SUFFIX;
220
  $result = $wpdb->query( "SHOW TABLES LIKE '{$view_name}'" );
221
 
@@ -223,7 +226,7 @@ class MLASettings {
223
  $result = $wpdb->query( "DROP VIEW {$view_name}" );
224
  }
225
  }
226
-
227
  /**
228
  * Debug logging for "You do not have sufficient permissions to access this page."
229
  *
@@ -239,7 +242,7 @@ class MLASettings {
239
  global $_wp_submenu_nopriv;
240
  global $plugin_page;
241
  global $_registered_pages;
242
-
243
  error_log( 'DEBUG: mla_admin_page_access_denied_action $_SERVER[REQUEST_URI] = ' . var_export( $_SERVER['REQUEST_URI'], true), 0 );
244
  error_log( 'DEBUG: mla_admin_page_access_denied_action $_REQUEST = ' . var_export( $_REQUEST, true), 0 );
245
  error_log( 'DEBUG: mla_admin_page_access_denied_action $pagenow = ' . var_export( $pagenow, true), 0 );
@@ -252,7 +255,7 @@ class MLASettings {
252
  error_log( 'DEBUG: mla_admin_page_access_denied_action $_registered_pages = ' . var_export( $_registered_pages, true), 0 );
253
  }
254
  // */
255
-
256
  /**
257
  * Load the plugin's Ajax handler
258
  *
@@ -264,7 +267,7 @@ class MLASettings {
264
  add_action( 'wp_ajax_' . self::JAVASCRIPT_INLINE_EDIT_VIEW_SLUG, 'MLASettings::mla_inline_edit_view_action' );
265
  add_action( 'wp_ajax_' . self::JAVASCRIPT_INLINE_EDIT_UPLOAD_SLUG, 'MLASettings::mla_inline_edit_upload_action' );
266
  }
267
-
268
  /**
269
  * Load the plugin's Style Sheet and Javascript files
270
  *
@@ -276,24 +279,25 @@ class MLASettings {
276
  */
277
  public static function mla_admin_enqueue_scripts_action( $page_hook ) {
278
  $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
279
-
280
- if ( self::$current_page_hook != $page_hook )
281
  return;
 
282
 
283
  wp_register_style( MLA::STYLESHEET_SLUG, MLA_PLUGIN_URL . 'css/mla-style.css', false, MLA::CURRENT_MLA_VERSION );
284
  wp_enqueue_style( MLA::STYLESHEET_SLUG );
285
-
286
  if ( isset( $_REQUEST['mla_tab'] ) && ( $_REQUEST['mla_tab'] == 'view' ) ) {
287
  wp_enqueue_script( self::JAVASCRIPT_INLINE_EDIT_VIEW_SLUG, MLA_PLUGIN_URL . "js/mla-inline-edit-view-scripts{$suffix}.js",
288
  array( 'wp-lists', 'suggest', 'jquery' ), MLA::CURRENT_MLA_VERSION, false );
289
-
290
  $script_variables = array(
291
  'fields' => array( 'original_slug', 'slug', 'singular', 'plural', 'specification', 'menu_order' ),
292
  'checkboxes' => array( 'post_mime_type', 'table_view' ),
293
- 'error' => 'Error while saving the changes.',
294
- 'ntdeltitle' => 'Remove From Bulk Edit',
295
- 'notitle' => '(no slug)',
296
- 'comma' => _x( ',', 'tag delimiter' ),
297
  'ajax_action' => self::JAVASCRIPT_INLINE_EDIT_VIEW_SLUG,
298
  'ajax_nonce' => wp_create_nonce( MLA::MLA_ADMIN_NONCE )
299
  );
@@ -308,10 +312,10 @@ class MLASettings {
308
  $script_variables = array(
309
  'fields' => array( 'original_slug', 'slug', 'mime_type', 'icon_type', 'core_type', 'mla_type', 'source', 'standard_source' ),
310
  'checkboxes' => array( 'disabled' ),
311
- 'error' => 'Error while saving the changes.',
312
- 'ntdeltitle' => 'Remove From Bulk Edit',
313
- 'notitle' => '(no slug)',
314
- 'comma' => _x( ',', 'tag delimiter' ),
315
  'ajax_action' => self::JAVASCRIPT_INLINE_EDIT_UPLOAD_SLUG,
316
  'ajax_nonce' => wp_create_nonce( MLA::MLA_ADMIN_NONCE )
317
  );
@@ -319,7 +323,7 @@ class MLASettings {
319
  return;
320
  }
321
  }
322
-
323
  /**
324
  * Add settings page in the "Settings" section,
325
  * add screen options and help tabs,
@@ -335,18 +339,19 @@ class MLASettings {
335
  * Use the URL suffix, if present. If the URL doesn't have a tab suffix, use '-general'.
336
  * This hack is required to pass the WordPress "referer" validation.
337
  */
338
- if ( isset( $_REQUEST['page'] ) && is_string( $_REQUEST['page'] ) && ( 'mla-settings-menu-' == substr( $_REQUEST['page'], 0, 18 ) ) )
339
  $tab = substr( $_REQUEST['page'], 18 );
340
- else
341
  $tab = 'general';
342
-
 
343
  $tab = isset ( self::$mla_tablist[ $tab ] ) ? '-' . $tab : '-general';
344
- self::$current_page_hook = add_submenu_page( 'options-general.php', 'Media Library Assistant Settings', 'Media Library Assistant', 'manage_options', self::MLA_SETTINGS_SLUG . $tab, 'MLASettings::mla_render_settings_page' );
345
  add_action( 'load-' . self::$current_page_hook, 'MLASettings::mla_add_menu_options_action' );
346
  add_action( 'load-' . self::$current_page_hook, 'MLASettings::mla_add_help_tab_action' );
347
  add_filter( 'plugin_action_links', 'MLASettings::mla_add_plugin_settings_link_filter', 10, 2 );
348
  }
349
-
350
  /**
351
  * Add the "XX Entries per page" filter to the Screen Options tab
352
  *
@@ -358,40 +363,40 @@ class MLASettings {
358
  if ( isset( $_REQUEST['mla_tab'] ) ) {
359
  if ( 'view' == $_REQUEST['mla_tab'] ) {
360
  $option = 'per_page';
361
-
362
  $args = array(
363
- 'label' => 'Views per page',
364
  'default' => 10,
365
  'option' => 'mla_views_per_page'
366
  );
367
-
368
  add_screen_option( $option, $args );
369
  } // view
370
  elseif ( isset( $_REQUEST['mla-optional-uploads-display'] ) || isset( $_REQUEST['mla-optional-uploads-search'] ) ) {
371
  $option = 'per_page';
372
-
373
  $args = array(
374
- 'label' => 'Types per page',
375
  'default' => 10,
376
  'option' => 'mla_types_per_page'
377
  );
378
-
379
  add_screen_option( $option, $args );
380
  } // optional upload
381
  elseif ( 'upload' == $_REQUEST['mla_tab'] ) {
382
  $option = 'per_page';
383
-
384
  $args = array(
385
- 'label' => 'Upload types per page',
386
  'default' => 10,
387
  'option' => 'mla_uploads_per_page'
388
  );
389
-
390
  add_screen_option( $option, $args );
391
  } // upload
392
  } // isset mla_tab
393
  }
394
-
395
  /**
396
  * Add contextual help tabs to all the MLA pages
397
  *
@@ -402,49 +407,49 @@ class MLASettings {
402
  public static function mla_add_help_tab_action( )
403
  {
404
  $screen = get_current_screen();
405
-
406
  /*
407
  * Is this our page and the Views or Uploads tab?
408
  */
409
- if ( ! in_array( $screen->id, array( 'settings_page_' . self::MLA_SETTINGS_SLUG . '-view', 'settings_page_' . self::MLA_SETTINGS_SLUG . '-upload' ) ) )
410
  return;
411
-
 
412
  $file_suffix = self::$current_page_hook;
413
-
414
  /*
415
  * Override the screen suffix if we are going to display something other than the attachment table
416
  */
417
  if ( isset( $_REQUEST['mla-optional-uploads-display'] ) || isset( $_REQUEST['mla-optional-uploads-search'] ) ) {
418
  $file_suffix .= '-optional';
419
- }
420
- elseif ( isset( $_REQUEST['mla_admin_action'] ) ) {
421
  switch ( $_REQUEST['mla_admin_action'] ) {
422
  case MLA::MLA_ADMIN_SINGLE_EDIT_DISPLAY:
423
  $file_suffix .= '-edit';
424
  break;
425
  } // switch
426
  } // isset( $_REQUEST['mla_admin_action'] )
427
-
428
- $template_array = MLAData::mla_load_template( MLA_PLUGIN_PATH . 'tpls/help-for-' . $file_suffix . '.tpl' );
429
  if ( empty( $template_array ) ) {
430
  return;
431
  }
432
-
433
  if ( !empty( $template_array['sidebar'] ) ) {
434
  $page_values = array( 'settingsURL' => admin_url('options-general.php') );
435
  $content = MLAData::mla_parse_template( $template_array['sidebar'], $page_values );
436
  $screen->set_help_sidebar( $content );
437
  unset( $template_array['sidebar'] );
438
  }
439
-
440
  /*
441
  * Provide explicit control over tab order
442
  */
443
  $tab_array = array();
444
-
445
  foreach ( $template_array as $id => $content ) {
446
  $match_count = preg_match( '#\<!-- title="(.+)" order="(.+)" --\>#', $content, $matches, PREG_OFFSET_CAPTURE );
447
-
448
  if ( $match_count > 0 ) {
449
  $page_values = array( 'settingsURL' => admin_url('options-general.php') );
450
  $content = MLAData::mla_parse_template( $content, $page_values );
@@ -454,16 +459,17 @@ class MLASettings {
454
  'content' => $content
455
  );
456
  } else {
457
- error_log( 'ERROR: mla_add_help_tab_action discarding '.var_export( $id, true ), 0 );
 
458
  }
459
  }
460
-
461
  ksort( $tab_array, SORT_NUMERIC );
462
  foreach ( $tab_array as $indx => $value ) {
463
  $screen->add_help_tab( $value );
464
  }
465
  }
466
-
467
  /**
468
  * Only show screen options on the View and Upload tabs
469
  *
@@ -476,13 +482,14 @@ class MLASettings {
476
  */
477
  public static function mla_screen_options_show_screen_filter( $show_screen, $this_screen ) {
478
  if ( self::$current_page_hook == $this_screen->base ) {
479
- if ( isset( $_REQUEST['mla_tab'] ) && in_array( $_REQUEST['mla_tab'], array( 'view', 'upload' ) ) )
480
  return true;
 
481
  }
482
-
483
  return $show_screen;
484
  }
485
-
486
  /**
487
  * Save the "Views/Uploads per page" option set by this user
488
  *
@@ -495,12 +502,13 @@ class MLASettings {
495
  * @return string|void New value if this is our option, otherwise nothing
496
  */
497
  public static function mla_set_screen_option_filter( $status, $option, $value ) {
498
- if ( 'mla_views_per_page' == $option || 'mla_uploads_per_page' == $option || 'mla_types_per_page' == $option )
499
  return $value;
500
- elseif ( $status )
501
  return $status;
 
502
  }
503
-
504
  /**
505
  * Ajax handler for Post MIME Types inline editing (quick and bulk edit)
506
  *
@@ -514,9 +522,9 @@ class MLASettings {
514
  set_current_screen( $_REQUEST['screen'] );
515
 
516
  check_ajax_referer( MLA::MLA_ADMIN_NONCE, 'nonce' );
517
-
518
  if ( empty( $_REQUEST['original_slug'] ) ) {
519
- echo 'Error: no view slug found';
520
  die();
521
  }
522
 
@@ -530,11 +538,12 @@ class MLASettings {
530
  $request['menu_order'] = $_REQUEST['menu_order'];
531
  $results = MLAMime::mla_update_post_mime_type( $request );
532
 
533
- if ( false === strpos( $results['message'], 'ERROR:' ) )
534
  $new_item = (object) MLAMime::mla_get_post_mime_type( $_REQUEST['slug'] );
535
- else
536
  $new_item = (object) MLAMime::mla_get_post_mime_type( $_REQUEST['original_slug'] );
537
-
 
538
  $new_item->post_ID = $_REQUEST['post_ID'];
539
 
540
  // Create an instance of our package class and echo the new HTML
@@ -542,7 +551,7 @@ class MLASettings {
542
  $MLAListViewTable->single_row( $new_item );
543
  die(); // this is required to return a proper result
544
  }
545
-
546
  /**
547
  * Ajax handler for Upload MIME Types inline editing (quick and bulk edit)
548
  *
@@ -556,9 +565,9 @@ class MLASettings {
556
  set_current_screen( $_REQUEST['screen'] );
557
 
558
  check_ajax_referer( MLA::MLA_ADMIN_NONCE, 'nonce' );
559
-
560
  if ( empty( $_REQUEST['original_slug'] ) ) {
561
- echo 'Error: no upload slug found';
562
  die();
563
  }
564
 
@@ -569,10 +578,11 @@ class MLASettings {
569
  $request['disabled'] = isset( $_REQUEST['disabled'] ) && ( '1' == $_REQUEST['disabled'] );
570
  $results = MLAMime::mla_update_upload_mime( $request );
571
 
572
- if ( false === strpos( $results['message'], 'ERROR:' ) )
573
  $new_item = (object) MLAMime::mla_get_upload_mime( $_REQUEST['slug'] );
574
- else
575
  $new_item = (object) MLAMime::mla_get_upload_mime( $_REQUEST['original_slug'] );
 
576
  $new_item->post_ID = $_REQUEST['post_ID'];
577
 
578
  // Create an instance of our package class and echo the new HTML
@@ -580,7 +590,7 @@ class MLASettings {
580
  $MLAListUploadTable->single_row( $new_item );
581
  die(); // this is required to return a proper result
582
  }
583
-
584
  /**
585
  * Add the "Settings" link to the MLA entry in the Plugins section
586
  *
@@ -593,13 +603,13 @@ class MLASettings {
593
  */
594
  public static function mla_add_plugin_settings_link_filter( $links, $file ) {
595
  if ( $file == 'media-library-assistant/index.php' ) {
596
- $settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'options-general.php?page=' . self::MLA_SETTINGS_SLUG . '-general' ), 'Settings' );
597
  array_unshift( $links, $settings_link );
598
  }
599
-
600
  return $links;
601
  }
602
-
603
  /**
604
  * Update or delete a single MLA option value
605
  *
@@ -640,7 +650,8 @@ class MLASettings {
640
  case 'hidden':
641
  break;
642
  default:
643
- error_log( 'ERROR: _save_settings unknown type(1): ' . var_export( $value, true ), 0 );
 
644
  } // $value['type']
645
  } // isset $key
646
  else {
@@ -671,13 +682,14 @@ class MLASettings {
671
  case 'hidden':
672
  break;
673
  default:
674
- error_log( 'ERROR: _save_settings unknown type(2): ' . var_export( $value, true ), 0 );
 
675
  } // $value['type']
676
  } // ! isset $key
677
-
678
  return $message;
679
  }
680
-
681
  /**
682
  * Compose the table row for a single MLA option
683
  *
@@ -698,18 +710,20 @@ class MLASettings {
698
  'value' => $value['name'],
699
  'help' => $value['help']
700
  );
701
-
702
- if ( 'checked' == MLAOptions::mla_get_option( $key ) )
703
  $option_values['checked'] = 'checked="checked"';
704
-
 
705
  return MLAData::mla_parse_template( self::$page_template_array['checkbox'], $option_values );
706
  case 'header':
707
  case 'subheader':
708
  $option_values = array(
 
709
  'key' => MLA_OPTION_PREFIX . $key,
710
  'value' => $value['name']
711
  );
712
-
713
  return MLAData::mla_parse_template( self::$page_template_array[ $value['type'] ], $option_values );
714
  case 'radio':
715
  $radio_options = '';
@@ -720,19 +734,20 @@ class MLASettings {
720
  'checked' => '',
721
  'value' => $value['texts'][$optid]
722
  );
723
-
724
- if ( $option == MLAOptions::mla_get_option( $key ) )
725
  $option_values['checked'] = 'checked="checked"';
726
-
 
727
  $radio_options .= MLAData::mla_parse_template( self::$page_template_array['radio-option'], $option_values );
728
  }
729
-
730
  $option_values = array(
731
  'value' => $value['name'],
732
  'options' => $radio_options,
733
  'help' => $value['help']
734
  );
735
-
736
  return MLAData::mla_parse_template( self::$page_template_array['radio'], $option_values );
737
  case 'select':
738
  $select_options = '';
@@ -742,20 +757,21 @@ class MLASettings {
742
  'value' => $option,
743
  'text' => $value['texts'][$optid]
744
  );
745
-
746
- if ( $option == MLAOptions::mla_get_option( $key ) )
747
  $option_values['selected'] = 'selected="selected"';
748
-
 
749
  $select_options .= MLAData::mla_parse_template( self::$page_template_array['select-option'], $option_values );
750
  }
751
-
752
  $option_values = array(
753
  'key' => MLA_OPTION_PREFIX . $key,
754
  'value' => $value['name'],
755
  'options' => $select_options,
756
  'help' => $value['help']
757
  );
758
-
759
  return MLAData::mla_parse_template( self::$page_template_array['select'], $option_values );
760
  case 'text':
761
  $option_values = array(
@@ -765,12 +781,13 @@ class MLASettings {
765
  'size' => '40',
766
  'text' => ''
767
  );
768
-
769
- if ( !empty( $value['size'] ) )
770
  $option_values['size'] = $value['size'];
771
-
 
772
  $option_values['text'] = MLAOptions::mla_get_option( $key );
773
-
774
  return MLAData::mla_parse_template( self::$page_template_array['text'], $option_values );
775
  case 'textarea':
776
  $option_values = array(
@@ -782,30 +799,34 @@ class MLASettings {
782
  'rows' => '5',
783
  'text' => ''
784
  );
785
-
786
- if ( !empty( $value['cols'] ) )
787
  $option_values['cols'] = $value['cols'];
788
-
789
- if ( !empty( $value['rows'] ) )
 
790
  $option_values['rows'] = $value['rows'];
791
-
 
792
  $option_values['text'] = stripslashes( MLAOptions::mla_get_option( $key ) );
793
-
794
  return MLAData::mla_parse_template( self::$page_template_array['textarea'], $option_values );
795
  case 'custom':
796
- if ( isset( $value['render'] ) )
797
  return MLAOptions::$value['render']( 'render', $key, $value );
 
798
 
799
  break;
800
  case 'hidden':
801
  break;
802
  default:
803
- error_log( 'ERROR: mla_render_settings_page unknown type: ' . var_export( $value, true ), 0 );
 
804
  } //switch
805
-
806
  return '';
807
  }
808
-
809
  /**
810
  * Template file for the Settings page(s) and parts
811
  *
@@ -822,6 +843,9 @@ class MLASettings {
822
  * Definitions for Settings page tab ids, titles and handlers
823
  * Each tab is defined by an array with the following elements:
824
  *
 
 
 
825
  * array key => HTML id/name attribute and option database key (OMIT MLA_OPTION_PREFIX)
826
  *
827
  * title => tab label / heading text
@@ -832,15 +856,29 @@ class MLASettings {
832
  *
833
  * @var array
834
  */
835
- private static $mla_tablist = array(
836
- 'general' => array( 'title' => 'General', 'render' => '_compose_general_tab' ),
837
- 'view' => array( 'title' => 'Views', 'render' => '_compose_view_tab' ),
838
- 'upload' => array( 'title' => 'Uploads', 'render' => '_compose_upload_tab' ),
839
- 'mla_gallery' => array( 'title' => 'MLA Gallery', 'render' => '_compose_mla_gallery_tab' ),
840
- 'custom_field' => array( 'title' => 'Custom Fields', 'render' => '_compose_custom_field_tab' ),
841
- 'iptc_exif' => array( 'title' => 'IPTC/EXIF', 'render' => '_compose_iptc_exif_tab' ),
842
- 'documentation' => array( 'title' => 'Documentation', 'render' => '_compose_documentation_tab' )
843
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
844
 
845
  /**
846
  * Compose the navigation tabs for the Settings subpage
@@ -862,14 +900,14 @@ class MLASettings {
862
  'settings-page' => self::MLA_SETTINGS_SLUG . '-' . $key,
863
  'title' => $item['title']
864
  );
865
-
866
  $tabs .= MLAData::mla_parse_template( $tablist_item, $item_values );
867
  } // foreach $item
868
-
869
  $tablist_values = array( 'tablist' => $tabs );
870
  return MLAData::mla_parse_template( self::$page_template_array['tablist'], $tablist_values );
871
  }
872
-
873
  /**
874
  * Compose the General tab content for the Settings subpage
875
  *
@@ -901,47 +939,64 @@ class MLASettings {
901
  'body' => ''
902
  );
903
  }
904
-
905
  if ( !empty( $page_content['body'] ) ) {
906
  return $page_content;
907
  }
908
-
909
  $page_values = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
910
  'shortcode_list' => '',
 
911
  'options_list' => '',
 
912
  'donateURL' => MLA_PLUGIN_URL . 'images/DonateButton.jpg',
913
- 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-general&mla_tab=general',
914
- '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
915
- '_wp_http_referer' => wp_referer_field( false )
916
  );
917
-
918
  /*
919
  * $custom_fields documents the name and description of custom fields
920
  */
921
  $custom_fields = array(
922
  // array("name" => "field_name", "description" => "field description.")
923
  );
924
-
925
  /*
926
  * $shortcodes documents the name and description of plugin shortcodes
927
  */
928
  $shortcodes = array(
929
  // array("name" => "shortcode", "description" => "This shortcode...")
930
- array( 'name' => 'mla_attachment_list', 'description' => 'renders a complete list of all attachments and references to them.' ),
931
- array( 'name' => 'mla_gallery', 'description' => 'enhanced version of the WordPress [gallery] shortcode. For complete documentation <a href="' . admin_url( 'options-general.php?page=' . self::MLA_SETTINGS_SLUG . '-documentation&amp;mla_tab=documentation' ) . '">click here</a>.' )
 
932
  );
933
-
934
  $shortcode_list = '';
935
  foreach ( $shortcodes as $shortcode ) {
936
  $shortcode_values = array ( 'name' => $shortcode['name'], 'description' => $shortcode['description'] );
937
  $shortcode_list .= MLAData::mla_parse_template( self::$page_template_array['shortcode-item'], $shortcode_values );
938
  }
939
-
940
  if ( ! empty( $shortcode_list ) ) {
941
- $shortcode_values = array ( 'shortcode_list' => $shortcode_list );
 
 
 
942
  $page_values['shortcode_list'] = MLAData::mla_parse_template( self::$page_template_array['shortcode-list'], $shortcode_values );
943
  }
944
-
945
  /*
946
  * Fill in the current list of Media/Assistant table sortable columns, sorted by their labels.
947
  * Make sure the current choice still exists or revert to default.
@@ -952,7 +1007,7 @@ class MLASettings {
952
  $columns[ $value[1] ] = $value[0];
953
  }
954
  }
955
-
956
  uksort( $columns, 'strnatcasecmp' );
957
  $options = array_merge( array('None' => 'none'), $columns );
958
  $current = MLAOptions::mla_get_option( MLAOptions::MLA_DEFAULT_ORDERBY );
@@ -962,8 +1017,9 @@ class MLASettings {
962
  foreach ($options as $key => $value ) {
963
  MLAOptions::$mla_option_definitions[MLAOptions::MLA_DEFAULT_ORDERBY]['options'][] = $value;
964
  MLAOptions::$mla_option_definitions[MLAOptions::MLA_DEFAULT_ORDERBY]['texts'][] = $key;
965
- if ( $current == $value )
966
  $found_current = true;
 
967
  }
968
 
969
  if ( ! $found_current ) {
@@ -973,7 +1029,7 @@ class MLASettings {
973
  /*
974
  * Validate the Media Manager sort order or revert to default
975
  */
976
- $options = array_merge( array(' -- Media Manager Default -- ' => 'default', 'None' => 'none'), $columns );
977
  $current = MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_ORDERBY );
978
  MLAOptions::$mla_option_definitions[MLAOptions::MLA_MEDIA_MODAL_ORDERBY]['options'] = array();
979
  MLAOptions::$mla_option_definitions[MLAOptions::MLA_MEDIA_MODAL_ORDERBY]['texts'] = array();
@@ -981,8 +1037,9 @@ class MLASettings {
981
  foreach ($options as $key => $value ) {
982
  MLAOptions::$mla_option_definitions[MLAOptions::MLA_MEDIA_MODAL_ORDERBY]['options'][] = $value;
983
  MLAOptions::$mla_option_definitions[MLAOptions::MLA_MEDIA_MODAL_ORDERBY]['texts'][] = $key;
984
- if ( $current == $value )
985
  $found_current = true;
 
986
  }
987
 
988
  if ( ! $found_current ) {
@@ -991,16 +1048,17 @@ class MLASettings {
991
 
992
  $options_list = '';
993
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
994
- if ( 'general' == $value['tab'] )
995
  $options_list .= self::_compose_option_row( $key, $value );
 
996
  }
997
-
998
  $page_values['options_list'] = $options_list;
999
  $page_values['import_settings'] = self::_compose_import_settings();
1000
  $page_content['body'] = MLAData::mla_parse_template( self::$page_template_array['general-tab'], $page_values );
1001
  return $page_content;
1002
  }
1003
-
1004
  /**
1005
  * Get the current action selected from the bulk actions dropdown
1006
  *
@@ -1010,24 +1068,26 @@ class MLASettings {
1010
  */
1011
  private static function _current_bulk_action( ) {
1012
  $action = false;
1013
-
1014
  if ( isset( $_REQUEST['action'] ) ) {
1015
- if ( -1 != $_REQUEST['action'] )
1016
  return $_REQUEST['action'];
1017
- else
1018
- $action = 'none';
 
1019
  } // isset action
1020
-
1021
  if ( isset( $_REQUEST['action2'] ) ) {
1022
- if ( -1 != $_REQUEST['action2'] )
1023
  return $_REQUEST['action2'];
1024
- else
1025
- $action = 'none';
 
1026
  } // isset action2
1027
-
1028
  return $action;
1029
  }
1030
-
1031
  /**
1032
  * Compose the Edit View tab content for the Settings subpage
1033
  *
@@ -1040,13 +1100,31 @@ class MLASettings {
1040
  */
1041
  private static function _compose_edit_view_tab( $view, $template ) {
1042
  $page_values = array(
1043
- 'settingsURL' => admin_url('options-general.php'),
1044
- 'action' => MLA::MLA_ADMIN_SINGLE_EDIT_UPDATE,
1045
  'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-view&mla_tab=view',
 
 
1046
  '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1047
- 'original_slug' => $view['slug']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1048
  );
1049
-
1050
  foreach ( $view as $key => $value ) {
1051
  switch ( $key ) {
1052
  case 'post_mime_type':
@@ -1063,7 +1141,7 @@ class MLASettings {
1063
  'body' => MLAData::mla_parse_template( $template, $page_values )
1064
  );
1065
  }
1066
-
1067
  /**
1068
  * Compose the Post MIME Type Views tab content for the Settings subpage
1069
  *
@@ -1072,12 +1150,13 @@ class MLASettings {
1072
  * @return array 'message' => status/error messages, 'body' => tab content
1073
  */
1074
  private static function _compose_view_tab( ) {
1075
- $page_template_array = MLAData::mla_load_template( MLA_PLUGIN_PATH . 'tpls/admin-display-settings-view-tab.tpl' );
1076
  if ( ! array( $page_template_array ) ) {
1077
- error_log( 'ERROR: MLASettings::_compose_view_tab $page_template_array = ' . var_export( $page_template_array, true ), 0 );
 
1078
  return '';
1079
  }
1080
-
1081
  /*
1082
  * Convert checkbox values, if present
1083
  */
@@ -1099,26 +1178,25 @@ class MLASettings {
1099
  'menu_order' => '',
1100
  'description' => ''
1101
  );
1102
-
1103
  if ( !empty( $_REQUEST['mla-view-options-save'] ) ) {
1104
  check_admin_referer( MLA::MLA_ADMIN_NONCE, '_wpnonce' );
1105
  $page_content = self::_save_view_settings( );
1106
- }
1107
- elseif ( !empty( $_REQUEST['mla-add-view-submit'] ) ) {
1108
  check_admin_referer( MLA::MLA_ADMIN_NONCE, '_wpnonce' );
1109
  $page_content = MLAMime::mla_add_post_mime_type( $_REQUEST['mla_view_item'] );
1110
- if ( false !== strpos( $page_content['message'], 'ERROR:' ) ) {
1111
  $add_form_values = $_REQUEST['mla_view_item'];
1112
  $add_form_values['post_mime_type'] = $add_form_values['post_mime_type'] ? 'checked="checked"' : '';
1113
  $add_form_values['table_view'] = $add_form_values['table_view'] ? 'checked="checked"' : '';
1114
  }
1115
  } else {
1116
  $page_content = array(
1117
- 'message' => '',
1118
  'body' => ''
1119
  );
1120
  }
1121
-
1122
  /*
1123
  * Process bulk actions that affect an array of items
1124
  */
@@ -1131,7 +1209,7 @@ class MLASettings {
1131
  $slugs = array();
1132
  foreach ( $_REQUEST['cb_mla_item_ID'] as $post_ID )
1133
  $slugs[] = MLAMime::mla_get_post_mime_type_slug( $post_ID );
1134
-
1135
  foreach ( $slugs as $slug ) {
1136
  switch ( $bulk_action ) {
1137
  case 'delete':
@@ -1139,35 +1217,40 @@ class MLASettings {
1139
  break;
1140
  case 'edit':
1141
  $request = array( 'slug' => $slug );
1142
- if ( '-1' != $_REQUEST['post_mime_type'] )
1143
  $request['post_mime_type'] = '1' == $_REQUEST['post_mime_type'];
1144
- if ( '-1' != $_REQUEST['table_view'] )
 
1145
  $request['table_view'] = '1' == $_REQUEST['table_view'];
1146
- if ( !empty( $_REQUEST['menu_order'] ) )
 
1147
  $request['menu_order'] = $_REQUEST['menu_order'];
 
1148
  $item_content = MLAMime::mla_update_post_mime_type( $request );
1149
  break;
1150
  default:
1151
  $item_content = array(
1152
- 'message' => sprintf( 'Unknown bulk action %s', $bulk_action ),
 
1153
  'body' => ''
1154
  );
1155
  } // switch $bulk_action
1156
-
1157
  $page_content['message'] .= $item_content['message'] . '<br>';
1158
  } // foreach cb_attachment
1159
  } // isset cb_attachment
1160
  else {
1161
- $page_content['message'] = 'Bulk Action ' . $bulk_action . ' - no items selected.';
 
1162
  }
1163
  } // $bulk_action
1164
-
1165
  /*
1166
  * Process row-level actions that affect a single item
1167
  */
1168
  if ( !empty( $_REQUEST['mla_admin_action'] ) ) {
1169
  check_admin_referer( MLA::MLA_ADMIN_NONCE );
1170
-
1171
  switch ( $_REQUEST['mla_admin_action'] ) {
1172
  case MLA::MLA_ADMIN_SINGLE_DELETE:
1173
  $page_content = MLAMime::mla_delete_post_mime_type( $_REQUEST['mla_item_slug'] );
@@ -1179,21 +1262,23 @@ class MLASettings {
1179
  case MLA::MLA_ADMIN_SINGLE_EDIT_UPDATE:
1180
  if ( !empty( $_REQUEST['update'] ) ) {
1181
  $page_content = MLAMime::mla_update_post_mime_type( $_REQUEST['mla_view_item'] );
1182
- if ( false !== strpos( $page_content['message'], 'ERROR:' ) ) {
1183
  $message = $page_content['message'];
1184
  $page_content = self::_compose_edit_view_tab( $_REQUEST['mla_view_item'], $page_template_array['single-item-edit'] );
1185
  $page_content['message'] = $message;
1186
  }
1187
  } else {
1188
  $page_content = array(
1189
- 'message' => 'Edit view "' . $_REQUEST['mla_view_item']['original_slug'] . '" cancelled.',
 
1190
  'body' => ''
1191
  );
1192
  }
1193
  break;
1194
  default:
1195
  $page_content = array(
1196
- 'message' => sprintf( 'Unknown mla_admin_action - "%1$s"', $_REQUEST['mla_admin_action'] ),
 
1197
  'body' => ''
1198
  );
1199
  break;
@@ -1203,7 +1288,7 @@ class MLASettings {
1203
  if ( !empty( $page_content['body'] ) ) {
1204
  return $page_content;
1205
  }
1206
-
1207
  /*
1208
  * Check for disabled status
1209
  */
@@ -1213,17 +1298,20 @@ class MLASettings {
1213
  */
1214
  $options_list = '';
1215
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
1216
- if ( 'view' == $value['tab'] )
1217
  $options_list .= self::_compose_option_row( $key, $value );
 
1218
  }
1219
-
1220
  $page_values = array(
1221
- 'settingsURL' => admin_url('options-general.php'),
 
 
1222
  'options_list' => $options_list,
 
1223
  '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1224
- 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-view&mla_tab=view',
1225
  );
1226
-
1227
  $page_content['body'] .= MLAData::mla_parse_template( $page_template_array['view-disabled'], $page_values );
1228
  return $page_content;
1229
  }
@@ -1243,49 +1331,80 @@ class MLASettings {
1243
  'mla-optional-uploads-search',
1244
  'mla-optional-uploads-display'
1245
  ), $_SERVER['REQUEST_URI'] );
1246
-
1247
  // Create an instance of our package class
1248
  $MLAListViewTable = new MLA_View_List_Table();
1249
-
1250
  // Fetch, prepare, sort, and filter our data
1251
  $MLAListViewTable->prepare_items();
1252
  $MLAListViewTable->views();
1253
-
1254
  /*
1255
  * Start with any page-level options
1256
  */
1257
  $options_list = '';
1258
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
1259
- if ( 'view' == $value['tab'] )
1260
  $options_list .= self::_compose_option_row( $key, $value );
 
1261
  }
1262
-
1263
  $page_values = array(
 
 
 
 
1264
  'settingsURL' => admin_url('options-general.php'),
 
 
 
 
 
1265
  'options_list' => $options_list,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1266
  'colspan' => count( $MLAListViewTable->get_columns() ),
1267
- '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1268
- 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-view&mla_tab=view',
1269
- 'results' => ! empty( $_REQUEST['s'] ) ? '<h3 style="float:left">Displaying search results for: "' . $_REQUEST['s'] . '"</h3>' : '',
1270
- 's' => isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''
 
 
 
1271
  );
1272
-
1273
  foreach ( $add_form_values as $key => $value ) {
1274
  $page_values[ $key ] = $value;
1275
  }
1276
  $page_content['body'] = MLAData::mla_parse_template( $page_template_array['before-table'], $page_values );
1277
-
1278
  // Now we can render the completed list table
1279
  ob_start();
1280
  $MLAListViewTable->display();
1281
  $page_content['body'] .= ob_get_contents();
1282
  ob_end_clean();
1283
-
1284
  $page_content['body'] .= MLAData::mla_parse_template( $page_template_array['after-table'], $page_values );
1285
 
1286
  return $page_content;
1287
  }
1288
-
1289
  /**
1290
  * Get an HTML select element representing a list of icon types
1291
  *
@@ -1299,21 +1418,22 @@ class MLASettings {
1299
  */
1300
  public static function mla_get_icon_type_dropdown( $templates, $name, $selection = '.none.' ) {
1301
  $option_template = $templates['icon-type-select-option'];
1302
- if ( '.nochange.' == $selection )
1303
  $option_values = array (
1304
  'selected' => 'selected="selected"',
1305
  'value' => '.none.',
1306
- 'text' => '&mdash; No Change &mdash;'
1307
  );
1308
- else
1309
  $option_values = array (
1310
  'selected' => ( '.none.' == $selection ) ? 'selected="selected"' : '',
1311
  'value' => '.none.',
1312
- 'text' => ' &mdash; None (select a value) &mdash; '
1313
  );
1314
-
 
1315
  $options = MLAData::mla_parse_template( $option_template, $option_values );
1316
-
1317
  $icon_types = MLAMime::mla_get_current_icon_types();
1318
  foreach ( $icon_types as $icon_type ) {
1319
  $option_values = array (
@@ -1321,10 +1441,10 @@ class MLASettings {
1321
  'value' => $icon_type,
1322
  'text' => $icon_type
1323
  );
1324
-
1325
  $options .= MLAData::mla_parse_template( $option_template, $option_values );
1326
  } // foreach icon_type
1327
-
1328
  return MLAData::mla_parse_template( $templates['icon-type-select'], array( 'name' => $name, 'options' => $options ) );
1329
  }
1330
 
@@ -1340,14 +1460,27 @@ class MLASettings {
1340
  */
1341
  private static function _compose_edit_upload_tab( $item, &$templates ) {
1342
  $page_values = array(
1343
- 'settingsURL' => admin_url('options-general.php'),
1344
- 'action' => MLA::MLA_ADMIN_SINGLE_EDIT_UPDATE,
1345
  'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-upload&mla_tab=upload',
1346
- '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1347
  'original_slug' => $item['slug'],
1348
- 'icon_types' => self::mla_get_icon_type_dropdown( $templates, 'mla_upload_item[icon_type]', $item['icon_type'] )
 
 
 
 
 
 
 
 
 
 
 
 
 
1349
  );
1350
-
1351
  foreach ( $item as $key => $value ) {
1352
  switch ( $key ) {
1353
  case 'disabled':
@@ -1363,7 +1496,7 @@ class MLASettings {
1363
  'body' => MLAData::mla_parse_template( $templates['single-item-edit'], $page_values )
1364
  );
1365
  }
1366
-
1367
  /**
1368
  * Compose the Optional File Upload MIME Types tab content for the Settings subpage
1369
  *
@@ -1388,7 +1521,7 @@ class MLASettings {
1388
  'cb_attachment',
1389
  'mla-optional-uploads-search'
1390
  ), $_SERVER['REQUEST_URI'] ) );
1391
-
1392
  /*
1393
  * Suppress display of the hidden columns selection list
1394
  */
@@ -1400,7 +1533,7 @@ class MLASettings {
1400
 
1401
  // Create an instance of our package class
1402
  $MLAListUploadTable = new MLA_Upload_Optional_List_Table();
1403
-
1404
  // Fetch, prepare, sort, and filter our data
1405
  $MLAListUploadTable->prepare_items();
1406
 
@@ -1408,28 +1541,32 @@ class MLASettings {
1408
  'message' => '',
1409
  'body' => ''
1410
  );
1411
-
1412
  $page_values = array(
1413
- '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1414
  'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-upload&mla_tab=upload',
1415
- 'results' => ! empty( $_REQUEST['s'] ) ? '<br>&nbsp;<br>Displaying search results for: "' . $_REQUEST['s'] . '"' : '',
1416
- 's' => isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''
 
 
 
 
 
1417
  );
1418
 
1419
  $page_content['body'] = MLAData::mla_parse_template( $page_template_array['before-optional-uploads-table'], $page_values );
1420
-
1421
  // Now we can render the completed list table
1422
  ob_start();
1423
  // $MLAListUploadTable->views();
1424
  $MLAListUploadTable->display();
1425
  $page_content['body'] .= ob_get_contents();
1426
  ob_end_clean();
1427
-
1428
  $page_content['body'] .= MLAData::mla_parse_template( $page_template_array['after-optional-uploads-table'], $page_values );
1429
 
1430
  return $page_content;
1431
  }
1432
-
1433
  /**
1434
  * Process an Optional Upload MIME Type selection
1435
  *
@@ -1451,7 +1588,7 @@ class MLASettings {
1451
  $optional_type['original_slug'] = $optional_type['slug'];
1452
  return MLAMime::mla_update_upload_mime( $optional_type );
1453
  }
1454
-
1455
  /**
1456
  * Compose the File Upload MIME Types tab content for the Settings subpage
1457
  *
@@ -1460,12 +1597,13 @@ class MLASettings {
1460
  * @return array 'message' => status/error messages, 'body' => tab content
1461
  */
1462
  private static function _compose_upload_tab( ) {
1463
- $page_template_array = MLAData::mla_load_template( MLA_PLUGIN_PATH . 'tpls/admin-display-settings-upload-tab.tpl' );
1464
  if ( ! array( $page_template_array ) ) {
1465
- error_log( 'ERROR: MLASettings::_compose_upload_tab $page_template_array = ' . var_export( $page_template_array, true ), 0 );
 
1466
  return '';
1467
  }
1468
-
1469
  /*
1470
  * Untangle confusion between searching, canceling and selecting on the Optional Uploads screen
1471
  */
@@ -1474,7 +1612,7 @@ class MLASettings {
1474
  unset( $_REQUEST['mla-optional-uploads-search'] );
1475
  unset( $_REQUEST['s'] );
1476
  }
1477
-
1478
  /*
1479
  * Convert checkbox values, if present
1480
  */
@@ -1483,7 +1621,7 @@ class MLASettings {
1483
  }
1484
 
1485
  /*
1486
- * Set default values, check for Add New Post MIME Type View button
1487
  */
1488
  $add_form_values = array (
1489
  'slug' => '',
@@ -1492,32 +1630,28 @@ class MLASettings {
1492
  'disabled' => '',
1493
  'description' => ''
1494
  );
1495
-
1496
  if ( !empty( $_REQUEST['mla-upload-options-save'] ) ) {
1497
  check_admin_referer( MLA::MLA_ADMIN_NONCE, '_wpnonce' );
1498
  $page_content = self::_save_upload_settings( );
1499
- }
1500
- elseif ( !empty( $_REQUEST['mla-optional-uploads-search'] ) ) {
1501
  check_admin_referer( MLA::MLA_ADMIN_NONCE, '_wpnonce' );
1502
  $page_content = self::_compose_optional_upload_tab( $page_template_array );
1503
- }
1504
- elseif ( !empty( $_REQUEST['mla-optional-uploads-cancel'] ) ) {
1505
  $page_content = array(
1506
  'message' => '',
1507
  'body' => ''
1508
  );
1509
- }
1510
- elseif ( !empty( $_REQUEST['mla-optional-uploads-display'] ) ) {
1511
  if ( 'true' != $_REQUEST['mla-optional-uploads-display'] ) {
1512
  check_admin_referer( MLA::MLA_ADMIN_NONCE, '_wpnonce' );
1513
  unset( $_REQUEST['s'] );
1514
  }
1515
  $page_content = self::_compose_optional_upload_tab( $page_template_array );
1516
- }
1517
- elseif ( !empty( $_REQUEST['mla-add-upload-submit'] ) ) {
1518
  check_admin_referer( MLA::MLA_ADMIN_NONCE, '_wpnonce' );
1519
  $page_content = MLAMime::mla_add_upload_mime( $_REQUEST['mla_upload_item'] );
1520
- if ( false !== strpos( $page_content['message'], 'ERROR:' ) ) {
1521
  $add_form_values = $_REQUEST['mla_upload_item'];
1522
  $add_form_values['disabled'] = $add_form_values['disabled'] ? 'checked="checked"' : '';
1523
  }
@@ -1527,7 +1661,7 @@ class MLASettings {
1527
  'body' => ''
1528
  );
1529
  }
1530
-
1531
  /*
1532
  * Process bulk actions that affect an array of items
1533
  */
@@ -1538,15 +1672,14 @@ class MLASettings {
1538
  $item_content = MLASettings::_process_optional_upload_mime( $ID );
1539
  $page_content['message'] .= $item_content['message'] . '<br>';
1540
  }
1541
- }
1542
- else {
1543
  /*
1544
  * Convert post-ID to slug; separate loop required because delete changes post_IDs
1545
  */
1546
  $slugs = array();
1547
  foreach ( $_REQUEST['cb_mla_item_ID'] as $post_ID )
1548
  $slugs[] = MLAMime::mla_get_upload_mime_slug( $post_ID );
1549
-
1550
  foreach ( $slugs as $slug ) {
1551
  switch ( $bulk_action ) {
1552
  case 'delete':
@@ -1554,34 +1687,38 @@ class MLASettings {
1554
  break;
1555
  case 'edit':
1556
  $request = array( 'slug' => $slug );
1557
- if ( '-1' != $_REQUEST['disabled'] )
1558
  $request['disabled'] = '1' == $_REQUEST['disabled'];
1559
- if ( '.none.' != $_REQUEST['icon_type'] )
 
1560
  $request['icon_type'] = $_REQUEST['icon_type'];
 
1561
  $item_content = MLAMime::mla_update_upload_mime( $request );
1562
  break;
1563
  default:
1564
  $item_content = array(
1565
- 'message' => sprintf( 'Unknown bulk action %s', $bulk_action ),
 
1566
  'body' => ''
1567
  );
1568
  } // switch $bulk_action
1569
-
1570
  $page_content['message'] .= $item_content['message'] . '<br>';
1571
  } // foreach cb_attachment
1572
  } // != select
1573
  } // isset cb_attachment
1574
  else {
1575
- $page_content['message'] = 'Bulk Action ' . $bulk_action . ' - no items selected.';
 
1576
  }
1577
  } // $bulk_action
1578
-
1579
  /*
1580
  * Process row-level actions that affect a single item
1581
  */
1582
  if ( !empty( $_REQUEST['mla_admin_action'] ) ) {
1583
  check_admin_referer( MLA::MLA_ADMIN_NONCE );
1584
-
1585
  switch ( $_REQUEST['mla_admin_action'] ) {
1586
  case MLA::MLA_ADMIN_SINGLE_DELETE:
1587
  $page_content = MLAMime::mla_delete_upload_mime( $_REQUEST['mla_item_slug'] );
@@ -1593,24 +1730,25 @@ class MLASettings {
1593
  case MLA::MLA_ADMIN_SINGLE_EDIT_UPDATE:
1594
  if ( !empty( $_REQUEST['update'] ) ) {
1595
  $page_content = MLAMime::mla_update_upload_mime( $_REQUEST['mla_upload_item'] );
1596
- if ( false !== strpos( $page_content['message'], 'ERROR:' ) ) {
1597
  $message = $page_content['message'];
1598
  $page_content = self::_compose_edit_upload_tab( $_REQUEST['mla_upload_item'], $page_template_array );
1599
  $page_content['message'] = $message;
1600
  }
1601
- }
1602
- elseif ( !empty( $_REQUEST['mla_item_ID'] ) ) {
1603
  $page_content = self::_process_optional_upload_mime( $_REQUEST['mla_item_ID'] );
1604
  } else {
1605
  $page_content = array(
1606
- 'message' => 'Edit view "' . $_REQUEST['mla_upload_item']['original_slug'] . '" cancelled.',
 
1607
  'body' => ''
1608
  );
1609
  }
1610
  break;
1611
  default:
1612
  $page_content = array(
1613
- 'message' => sprintf( 'Unknown mla_admin_action - "%1$s"', $_REQUEST['mla_admin_action'] ),
 
1614
  'body' => ''
1615
  );
1616
  break;
@@ -1620,7 +1758,7 @@ class MLASettings {
1620
  if ( !empty( $page_content['body'] ) ) {
1621
  return $page_content;
1622
  }
1623
-
1624
  /*
1625
  * Check for disabled status
1626
  */
@@ -1630,17 +1768,20 @@ class MLASettings {
1630
  */
1631
  $options_list = '';
1632
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
1633
- if ( 'upload' == $value['tab'] )
1634
  $options_list .= self::_compose_option_row( $key, $value );
 
1635
  }
1636
-
1637
  $page_values = array(
1638
- 'settingsURL' => admin_url('options-general.php'),
 
 
1639
  'options_list' => $options_list,
 
1640
  '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1641
- 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-upload&mla_tab=upload',
1642
  );
1643
-
1644
  $page_content['body'] .= MLAData::mla_parse_template( $page_template_array['upload-disabled'], $page_values );
1645
  return $page_content;
1646
  }
@@ -1659,53 +1800,82 @@ class MLASettings {
1659
  'cb_mla_item_ID',
1660
  'mla-optional-uploads-search',
1661
  ), $_SERVER['REQUEST_URI'] );
1662
-
1663
  // Create an instance of our package class
1664
  $MLAListUploadTable = new MLA_Upload_List_Table();
1665
-
1666
  // Fetch, prepare, sort, and filter our data
1667
  $MLAListUploadTable->prepare_items();
1668
-
1669
  /*
1670
  * Start with any page-level options
1671
  */
1672
  $options_list = '';
1673
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
1674
- if ( 'upload' == $value['tab'] )
1675
  $options_list .= self::_compose_option_row( $key, $value );
 
1676
  }
1677
-
1678
  $page_values = array(
 
 
 
 
1679
  'settingsURL' => admin_url('options-general.php'),
 
 
 
 
1680
  'options_list' => $options_list,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1681
  'colspan' => count( $MLAListUploadTable->get_columns() ),
1682
- '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1683
- 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-upload&mla_tab=upload',
1684
- 'results' => ! empty( $_REQUEST['s'] ) ? '<h3 style="float:left">Displaying search results for: "' . $_REQUEST['s'] . '"</h3>' : '',
 
 
 
 
 
1685
  's' => isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '',
1686
  'icon_types' => self::mla_get_icon_type_dropdown( $page_template_array, 'mla_upload_item[icon_type]' ),
1687
  'inline_icon_types' => self::mla_get_icon_type_dropdown( $page_template_array, 'icon_type' ),
1688
  'bulk_icon_types' => self::mla_get_icon_type_dropdown( $page_template_array, 'icon_type', '.nochange.' ),
1689
- 'search_url' => wp_nonce_url( '?page=mla-settings-menu-upload&mla_tab=upload&mla-optional-uploads-search=Search', MLA::MLA_ADMIN_NONCE )
1690
  );
1691
-
1692
  foreach ( $add_form_values as $key => $value ) {
1693
  $page_values[ $key ] = $value;
1694
  }
1695
  $page_content['body'] = MLAData::mla_parse_template( $page_template_array['before-table'], $page_values );
1696
-
1697
  // Now we can render the completed list table
1698
  ob_start();
1699
  $MLAListUploadTable->views();
1700
  $MLAListUploadTable->display();
1701
  $page_content['body'] .= ob_get_contents();
1702
  ob_end_clean();
1703
-
1704
  $page_content['body'] .= MLAData::mla_parse_template( $page_template_array['after-table'], $page_values );
1705
 
1706
  return $page_content;
1707
  }
1708
-
1709
  /**
1710
  * Compose the MLA Gallery tab content for the Settings subpage
1711
  *
@@ -1728,26 +1898,32 @@ class MLASettings {
1728
  'body' => ''
1729
  );
1730
  }
1731
-
1732
  if ( !empty( $page_content['body'] ) ) {
1733
  return $page_content;
1734
  }
1735
-
1736
  $page_values = array(
1737
- 'settingsURL' => admin_url('options-general.php'),
 
 
 
1738
  'options_list' => '',
 
 
1739
  'style_options_list' => '',
 
1740
  'markup_options_list' => '',
1741
- 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-mla_gallery&mla_tab=mla_gallery',
1742
  '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1743
  '_wp_http_referer' => wp_referer_field( false )
1744
  );
1745
-
1746
  /*
1747
  * Build default template selection lists
1748
  */
1749
  MLAOptions::$mla_option_definitions['default_style']['options'][] = 'none';
1750
- MLAOptions::$mla_option_definitions['default_style']['texts'][] = '-- none --';
1751
 
1752
  $templates = MLAOptions::mla_get_style_templates();
1753
  ksort($templates);
@@ -1762,16 +1938,17 @@ class MLASettings {
1762
  MLAOptions::$mla_option_definitions['default_markup']['options'][] = $key;
1763
  MLAOptions::$mla_option_definitions['default_markup']['texts'][] = $key;
1764
  }
1765
-
1766
  /*
1767
  * Start with any page-level options
1768
  */
1769
  $options_list = '';
1770
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
1771
- if ( 'mla_gallery' == $value['tab'] )
1772
  $options_list .= self::_compose_option_row( $key, $value );
 
1773
  }
1774
-
1775
  $page_values['options_list'] = $options_list;
1776
 
1777
  /*
@@ -1780,242 +1957,265 @@ class MLASettings {
1780
  $default_styles = array( 'default', 'tag-cloud' );
1781
  $style_options_list = '';
1782
  $templates = MLAOptions::mla_get_style_templates();
1783
-
1784
  foreach ( $default_styles as $default ) {
1785
  $name = $default;
1786
  $value =$templates[$default];
1787
  if ( ! empty( $value ) ) {
1788
  $template_values = array (
1789
- 'help' => 'This default template cannot be altered or deleted, but you can copy the styles.'
1790
  );
1791
  $control_cells = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-default'], $template_values );
1792
-
1793
  $template_values = array (
1794
- 'readonly' => 'readonly="readonly"',
1795
  'name_name' => "mla_style_templates_name[{$default}]",
1796
  'name_id' => "mla_style_templates_name_{$default}",
 
1797
  'name_text' => $default,
1798
  'control_cells' => $control_cells,
 
1799
  'value_name' => "mla_style_templates_value[{$default}]",
1800
  'value_id' => "mla_style_templates_value_{$default}",
1801
  'value_text' => esc_textarea( $value ),
1802
- 'value_help' => 'List of substitution parameters, e.g., [+selector+], on Documentation tab.'
1803
  );
1804
-
1805
  $style_options_list .= MLAData::mla_parse_template( self::$page_template_array['mla-gallery-style'], $template_values );
1806
  } // $value
1807
  } // foreach default
1808
-
1809
  foreach ( $templates as $name => $value ) {
1810
  $slug = sanitize_title( $name );
1811
 
1812
- if ( in_array( $name, $default_styles ) )
1813
  continue; // already handled above
1814
-
 
1815
  $template_values = array (
1816
  'name' => 'mla_style_templates_delete[' . $slug . ']',
1817
  'id' => 'mla_style_templates_delete_' . $slug,
1818
- 'value' => 'Delete this template',
1819
- 'help' => 'Check the box to delete this template when you press Update at the bottom of the page.'
1820
  );
1821
  $control_cells = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-delete'], $template_values );
1822
-
1823
  $template_values = array (
1824
- 'readonly' => '',
1825
  'name_name' => 'mla_style_templates_name[' . $slug . ']',
1826
  'name_id' => 'mla_style_templates_name_' . $slug,
 
1827
  'name_text' => $slug,
1828
  'control_cells' => $control_cells,
 
1829
  'value_name' => 'mla_style_templates_value[' . $slug . ']',
1830
  'value_id' => 'mla_style_templates_value_' . $slug,
1831
  'value_text' => esc_textarea( $value ),
1832
- 'value_help' => 'List of substitution parameters, e.g., [+selector+], on Documentation tab.'
1833
  );
1834
 
1835
  $style_options_list .= MLAData::mla_parse_template( self::$page_template_array['mla-gallery-style'], $template_values );
1836
  } // foreach $templates
1837
-
1838
  /*
1839
  * Add blank style template for additions
1840
  */
1841
  if ( ! empty( $value ) ) {
1842
  $template_values = array (
1843
- 'help' => 'Fill in a name and styles to add a new template.'
1844
  );
1845
  $control_cells = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-default'], $template_values );
1846
-
1847
  $template_values = array (
1848
- 'readonly' => '',
1849
  'name_name' => 'mla_style_templates_name[blank]',
1850
  'name_id' => 'mla_style_templates_name_blank',
 
1851
  'name_text' => '',
1852
  'control_cells' => $control_cells,
 
1853
  'value_name' => 'mla_style_templates_value[blank]',
1854
  'value_id' => 'mla_style_templates_value_blank',
1855
  'value_text' => '',
1856
- 'value_help' => 'List of substitution parameters, e.g., [+selector+], on Documentation tab.'
1857
  );
1858
 
1859
  $style_options_list .= MLAData::mla_parse_template( self::$page_template_array['mla-gallery-style'], $template_values );
1860
  } // $value
1861
-
1862
  $page_values['style_options_list'] = $style_options_list;
1863
-
1864
  /*
1865
  * Add markup templates; defaults go first
1866
  */
1867
  $default_markups = array( 'default', 'tag-cloud', 'tag-cloud-ul', 'tag-cloud-dl' );
1868
  $markup_options_list = '';
1869
  $templates = MLAOptions::mla_get_markup_templates();
1870
-
1871
  foreach ( $default_markups as $default ) {
1872
  $name = $default;
1873
  $value =$templates[$default];
1874
  if ( ! empty( $value ) ) {
1875
  $template_values = array (
1876
- 'help' => 'This default template cannot be altered or deleted, but you can copy the markup.'
1877
  );
1878
  $control_cells = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-default'], $template_values );
1879
-
1880
  $template_values = array (
1881
- 'readonly' => 'readonly="readonly"',
1882
  'name_name' => "mla_markup_templates_name[{$default}]",
1883
  'name_id' => "mla_markup_templates_name_{$default}",
 
1884
  'name_text' => $default,
1885
  'control_cells' => $control_cells,
1886
-
 
1887
  'open_name' => "mla_markup_templates_open[{$default}]",
1888
  'open_id' => "mla_markup_templates_open_{$default}",
1889
  'open_text' => isset( $value['open'] ) ? esc_textarea( $value['open'] ) : '',
1890
- 'open_help' => 'Markup for the beginning of the gallery. List of parameters, e.g., [+selector+], on Documentation tab.',
1891
-
 
1892
  'row_open_name' => "mla_markup_templates_row_open[{$default}]",
1893
  'row_open_id' => "mla_markup_templates_row_open_{$default}",
1894
  'row_open_text' => isset( $value['row-open'] ) ? esc_textarea( $value['row-open'] ) : '',
1895
- 'row_open_help' => 'Markup for the beginning of each row in the gallery.',
1896
-
 
1897
  'item_name' => "mla_markup_templates_item[{$default}]",
1898
  'item_id' => "mla_markup_templates_item_{$default}",
1899
  'item_text' => isset( $value['item'] ) ? esc_textarea( $value['item'] ) : '',
1900
- 'item_help' => 'Markup for each item/cell of the gallery.',
1901
-
 
1902
  'row_close_name' => "mla_markup_templates_row_close[{$default}]",
1903
  'row_close_id' => "mla_markup_templates_row_close_{$default}",
1904
  'row_close_text' => isset( $value['row-close'] ) ? esc_textarea( $value['row-close'] ) : '',
1905
- 'row_close_help' => 'Markup for the end of each row in the gallery.',
1906
-
1907
  'close_name' => "mla_markup_templates_close[{$default}]",
1908
  'close_id' => "mla_markup_templates_close_{$default}",
1909
  'close_text' => isset( $value['close'] ) ? esc_textarea( $value['close'] ) : '',
1910
- 'close_help' => 'Markup for the end of the gallery.'
1911
  );
1912
-
1913
  $markup_options_list .= MLAData::mla_parse_template( self::$page_template_array['mla-gallery-markup'], $template_values );
1914
  } // $value
1915
  } // foreach default
1916
-
1917
  foreach ( $templates as $name => $value ) {
1918
  $slug = sanitize_title( $name );
1919
 
1920
- if ( in_array( $name, $default_markups ) )
1921
  continue; // already handled above
1922
-
 
1923
  $template_values = array (
1924
  'name' => 'mla_markup_templates_delete[' . $slug . ']',
1925
  'id' => 'mla_markup_templates_delete_' . $slug,
1926
- 'value' => 'Delete this template',
1927
- 'help' => 'Check the box to delete this template when you press Update at the bottom of the page.'
1928
  );
1929
  $control_cells = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-delete'], $template_values );
1930
-
1931
  $template_values = array (
1932
- 'readonly' => '',
1933
  'name_name' => 'mla_markup_templates_name[' . $slug . ']',
1934
  'name_id' => 'mla_markup_templates_name_' . $slug,
 
1935
  'name_text' => $slug,
1936
  'control_cells' => $control_cells,
1937
 
 
1938
  'open_name' => 'mla_markup_templates_open[' . $slug . ']',
1939
  'open_id' => 'mla_markup_templates_open_' . $slug,
1940
  'open_text' => esc_textarea( $value['open'] ),
1941
- 'open_help' => 'Markup for the beginning of the gallery. List of parameters, e.g., [+selector+], on Documentation tab.',
1942
 
 
1943
  'row_open_name' => 'mla_markup_templates_row_open[' . $slug . ']',
1944
  'row_open_id' => 'mla_markup_templates_row_open_' . $slug,
1945
  'row_open_text' => esc_textarea( $value['row-open'] ),
1946
- 'row_open_help' => 'Markup for the beginning of each row.',
1947
 
 
1948
  'item_name' => 'mla_markup_templates_item[' . $slug . ']',
1949
  'item_id' => 'mla_markup_templates_item_' . $slug,
1950
  'item_text' => esc_textarea( $value['item'] ),
1951
- 'item_help' => 'Markup for each item/cell.',
1952
 
 
1953
  'row_close_name' => 'mla_markup_templates_row_close[' . $slug . ']',
1954
  'row_close_id' => 'mla_markup_templates_row_close_' . $slug,
1955
  'row_close_text' => esc_textarea( $value['row-close'] ),
1956
- 'row_close_help' => 'Markup for the end of each row.',
1957
 
1958
  'close_name' => 'mla_markup_templates_close[' . $slug . ']',
1959
  'close_id' => 'mla_markup_templates_close_' . $slug,
1960
  'close_text' => esc_textarea( $value['close'] ),
1961
- 'close_help' => 'Markup for the end of the gallery.'
1962
  );
1963
 
1964
  $markup_options_list .= MLAData::mla_parse_template( self::$page_template_array['mla-gallery-markup'], $template_values );
1965
  } // foreach $templates
1966
-
1967
  /*
1968
  * Add blank markup template for additions
1969
  */
1970
  if ( ! empty( $value ) ) {
1971
  $template_values = array (
1972
- 'help' => 'Fill in a name and markup to add a new template.'
1973
  );
1974
  $control_cells = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-default'], $template_values );
1975
-
1976
  $template_values = array (
1977
- 'readonly' => '',
1978
  'name_name' => 'mla_markup_templates_name[blank]',
1979
  'name_id' => 'mla_markup_templates_name_blank',
 
1980
  'name_text' => '',
1981
  'control_cells' => $control_cells,
1982
 
 
1983
  'open_name' => 'mla_markup_templates_open[blank]',
1984
  'open_id' => 'mla_markup_templates_open_blank',
1985
  'open_text' => '',
1986
- 'open_help' => 'Markup for the beginning of the gallery. List of parameters, e.g., [+selector+], on Documentation tab.',
1987
 
 
1988
  'row_open_name' => 'mla_markup_templates_row_open[blank]',
1989
  'row_open_id' => 'mla_markup_templates_row_open_blank',
1990
  'row_open_text' => '',
1991
- 'row_open_help' => 'Markup for the beginning of each row in the gallery.',
1992
 
 
1993
  'item_name' => 'mla_markup_templates_item[blank]',
1994
  'item_id' => 'mla_markup_templates_item_blank',
1995
  'item_text' => '',
1996
- 'item_help' => 'Markup for each item/cell of the gallery.',
1997
 
 
1998
  'row_close_name' => 'mla_markup_templates_row_close[blank]',
1999
  'row_close_id' => 'mla_markup_templates_row_close_blank',
2000
  'row_close_text' => '',
2001
- 'row_close_help' => 'Markup for the end of each row in the gallery.',
2002
 
2003
  'close_name' => 'mla_markup_templates_close[blank]',
2004
  'close_id' => 'mla_markup_templates_close_blank',
2005
  'close_text' => '',
2006
- 'close_help' => 'Markup for the end of the gallery.'
2007
-
2008
  );
2009
 
2010
  $markup_options_list .= MLAData::mla_parse_template( self::$page_template_array['mla-gallery-markup'], $template_values );
2011
  } // $value
2012
-
2013
  $page_values['markup_options_list'] = $markup_options_list;
2014
-
2015
  $page_content['body'] = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-tab'], $page_values );
2016
  return $page_content;
2017
  }
2018
-
2019
  /**
2020
  * Compose the Custom Field tab content for the Settings subpage
2021
  *
@@ -2038,11 +2238,9 @@ class MLASettings {
2038
  */
2039
  if ( !empty( $_REQUEST['custom-field-options-save'] ) ) {
2040
  $page_content = self::_save_custom_field_settings( );
2041
- }
2042
- elseif ( !empty( $_REQUEST['custom-field-options-map'] ) ) {
2043
  $page_content = self::_process_custom_field_mapping( );
2044
- }
2045
- else {
2046
  $page_content = array(
2047
  'message' => '',
2048
  'body' => ''
@@ -2063,8 +2261,9 @@ class MLASettings {
2063
  case 'add_field':
2064
  case 'update_rule':
2065
  $page_content = self::_save_custom_field_settings( $settings );
2066
- if ( isset( $delete_result ) )
2067
  $page_content['message'] = $delete_result . $page_content['message'];
 
2068
  break;
2069
  case 'map_now':
2070
  $page_content = self::_process_custom_field_mapping( $settings );
@@ -2072,7 +2271,7 @@ class MLASettings {
2072
  case 'add_rule_map':
2073
  case 'add_field_map':
2074
  $page_content = self::_save_custom_field_settings( $settings );
2075
- if ( false === strpos( $page_content['message'], 'ERROR:' ) ) {
2076
  $current_values = MLAOptions::mla_get_option( 'custom_field_mapping' );
2077
  $settings = array( $value['name'] => $current_values[$value['name']] );
2078
  $map_content = self::_process_custom_field_mapping( $settings );
@@ -2093,40 +2292,53 @@ class MLASettings {
2093
  'body' => ''
2094
  );
2095
  }
2096
-
2097
  if ( !empty( $page_content['body'] ) ) {
2098
  return $page_content;
2099
  }
2100
-
2101
  $page_values = array(
 
 
 
 
 
2102
  'settingsURL' => admin_url('options-general.php'),
 
2103
  'options_list' => '',
 
2104
  'custom_options_list' => '',
2105
- 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-custom_field&mla_tab=custom_field',
 
 
 
 
 
2106
  '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
2107
  '_wp_http_referer' => wp_referer_field( false )
2108
  );
2109
-
2110
  /*
2111
  * Start with any page-level options
2112
  */
2113
  $options_list = '';
2114
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
2115
- if ( 'custom_field' == $value['tab'] )
2116
  $options_list .= self::_compose_option_row( $key, $value );
 
2117
  }
2118
-
2119
  $page_values['options_list'] = $options_list;
2120
-
2121
  /*
2122
  * Add mapping options
2123
  */
2124
  $page_values['custom_options_list'] = MLAOptions::mla_custom_field_option_handler( 'render', 'custom_field_mapping', MLAOptions::$mla_option_definitions['custom_field_mapping'] );
2125
-
2126
  $page_content['body'] = MLAData::mla_parse_template( self::$page_template_array['custom-field-tab'], $page_values );
2127
  return $page_content;
2128
  }
2129
-
2130
  /**
2131
  * Compose the IPTC/EXIF tab content for the Settings subpage
2132
  *
@@ -2150,17 +2362,13 @@ class MLASettings {
2150
 
2151
  if ( !empty( $_REQUEST['iptc-exif-options-save'] ) ) {
2152
  $page_content = self::_save_iptc_exif_settings( );
2153
- }
2154
- elseif ( !empty( $_REQUEST['iptc-exif-options-process-standard'] ) ) {
2155
  $page_content = self::_process_iptc_exif_standard( );
2156
- }
2157
- elseif ( !empty( $_REQUEST['iptc-exif-options-process-taxonomy'] ) ) {
2158
  $page_content = self::_process_iptc_exif_taxonomy( );
2159
- }
2160
- elseif ( !empty( $_REQUEST['iptc-exif-options-process-custom'] ) ) {
2161
  $page_content = self::_process_iptc_exif_custom( );
2162
- }
2163
- else {
2164
  /*
2165
  * Check for single-rule action buttons
2166
  */
@@ -2176,8 +2384,9 @@ class MLASettings {
2176
  case 'add_field':
2177
  case 'update_rule':
2178
  $page_content = self::_save_iptc_exif_custom_settings( $settings );
2179
- if ( isset( $delete_result ) )
2180
  $page_content['message'] = $delete_result . $page_content['message'];
 
2181
  break;
2182
  case 'map_now':
2183
  $page_content = self::_process_iptc_exif_custom( $settings );
@@ -2185,7 +2394,7 @@ class MLASettings {
2185
  case 'add_rule_map':
2186
  case 'add_field_map':
2187
  $page_content = self::_save_iptc_exif_custom_settings( $settings );
2188
- if ( false === strpos( $page_content['message'], 'ERROR:' ) ) {
2189
  $current_values = MLAOptions::mla_get_option( 'iptc_exif_mapping' );
2190
  $settings = array( 'custom' => array( $value['name'] => $current_values['custom'][$value['name']] ) );
2191
  $map_content = self::_process_iptc_exif_custom( $settings );
@@ -2199,47 +2408,61 @@ class MLASettings {
2199
  } /// isset action
2200
  } // foreach rule
2201
  }
2202
-
2203
  if ( !empty( $page_content['body'] ) ) {
2204
  return $page_content;
2205
  }
2206
  }
2207
-
2208
  $page_values = array(
 
 
 
 
2209
  'settingsURL' => admin_url('options-general.php'),
 
2210
  'options_list' => '',
 
 
2211
  'standard_options_list' => '',
 
 
2212
  'taxonomy_options_list' => '',
 
 
2213
  'custom_options_list' => '',
2214
- 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-iptc_exif&mla_tab=iptc_exif',
 
 
2215
  '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
2216
  '_wp_http_referer' => wp_referer_field( false )
2217
  );
2218
-
2219
  /*
2220
  * Start with any page-level options
2221
  */
2222
  $options_list = '';
2223
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
2224
- if ( 'iptc_exif' == $value['tab'] )
2225
  $options_list .= self::_compose_option_row( $key, $value );
 
2226
  }
2227
-
2228
  $page_values['options_list'] = $options_list;
2229
-
2230
  /*
2231
  * Add mapping options
2232
  */
2233
  $page_values['standard_options_list'] = MLAOptions::mla_iptc_exif_option_handler( 'render', 'iptc_exif_standard_mapping', MLAOptions::$mla_option_definitions['iptc_exif_standard_mapping'] );
2234
-
2235
  $page_values['taxonomy_options_list'] = MLAOptions::mla_iptc_exif_option_handler( 'render', 'iptc_exif_taxonomy_mapping', MLAOptions::$mla_option_definitions['iptc_exif_taxonomy_mapping'] );
2236
-
2237
  $page_values['custom_options_list'] = MLAOptions::mla_iptc_exif_option_handler( 'render', 'iptc_exif_custom_mapping', MLAOptions::$mla_option_definitions['iptc_exif_custom_mapping'] );
2238
-
2239
  $page_content['body'] = MLAData::mla_parse_template( self::$page_template_array['iptc-exif-tab'], $page_values );
2240
  return $page_content;
2241
  }
2242
-
2243
  /**
2244
  * Compose the Documentation tab content for the Settings subpage
2245
  *
@@ -2249,18 +2472,18 @@ class MLASettings {
2249
  * @return array 'message' => status/error messages, 'body' => tab content
2250
  */
2251
  private static function _compose_documentation_tab( ) {
2252
- $page_template = MLAData::mla_load_template( MLA_PLUGIN_PATH . 'tpls/documentation-settings-tab.tpl' );
2253
  $page_values = array(
2254
  'phpDocs_url' => MLA_PLUGIN_URL . 'phpDocs/index.html',
2255
  'examples_url' => MLA_PLUGIN_URL . 'examples/'
2256
  );
2257
-
2258
  return array(
2259
  'message' => '',
2260
  'body' => MLAData::mla_parse_template( $page_template['documentation-tab'], $page_values )
2261
  );
2262
  }
2263
-
2264
  /**
2265
  * Render (echo) the "Media Library Assistant" subpage in the Settings section
2266
  *
@@ -2270,24 +2493,26 @@ class MLASettings {
2270
  */
2271
  public static function mla_render_settings_page( ) {
2272
  if ( !current_user_can( 'manage_options' ) ) {
2273
- echo "Media Library Assistant - Error</h2>\r\n";
2274
- wp_die( __( 'You do not have permission to manage plugin settings.' ) );
2275
  }
2276
-
2277
  /*
2278
  * Load template array and initialize page-level values.
2279
  */
2280
- self::$page_template_array = MLAData::mla_load_template( MLA_PLUGIN_PATH . 'tpls/admin-display-settings-page.tpl' );
2281
  $current_tab = isset( $_REQUEST['mla_tab'] ) ? $_REQUEST['mla_tab']: 'general';
2282
  $page_values = array(
2283
- 'settingsURL' => admin_url('options-general.php'),
2284
- 'version' => 'v' . MLA::CURRENT_MLA_VERSION,
2285
  'donateURL' => MLA_PLUGIN_URL . 'images/DonateButton.jpg',
 
2286
  'messages' => '',
2287
  'tablist' => self::_compose_settings_tabs( $current_tab ),
2288
- 'tab_content' => ''
 
 
2289
  );
2290
-
2291
  /*
2292
  * Compose tab content
2293
  */
@@ -2296,17 +2521,18 @@ class MLASettings {
2296
  $handler = self::$mla_tablist[ $current_tab ]['render'];
2297
  $page_content = self::$handler( );
2298
  } else {
2299
- $page_content = array( 'message' => 'ERROR: cannot render content tab', 'body' => '' );
2300
  }
2301
  } else {
2302
- $page_content = array( 'message' => 'ERROR: unknown content tab', 'body' => '' );
2303
  }
2304
 
2305
  if ( ! empty( $page_content['message'] ) ) {
2306
- if ( false !== strpos( $page_content['message'], 'ERROR:' ) )
2307
  $messages_class = 'mla_errors';
2308
- else
2309
  $messages_class = 'mla_messages';
 
2310
 
2311
  $page_values['messages'] = MLAData::mla_parse_template( self::$page_template_array['messages'], array(
2312
  'messages' => $page_content['message'],
@@ -2317,7 +2543,7 @@ class MLASettings {
2317
  $page_values['tab_content'] = $page_content['body'];
2318
  echo MLAData::mla_parse_template( self::$page_template_array['page'], $page_values );
2319
  } // mla_render_settings_page
2320
-
2321
  /**
2322
  * Save MLA Gallery settings to the options table
2323
  *
@@ -2331,7 +2557,7 @@ class MLASettings {
2331
  $settings_changed = false;
2332
  $message_list = '';
2333
  $error_list = '';
2334
-
2335
  /*
2336
  * Start with any page-level options
2337
  */
@@ -2343,11 +2569,11 @@ class MLASettings {
2343
  $settings_changed = true;
2344
  $message_list .= self::_update_option_row( $key, $value );
2345
  }
2346
- }
2347
- elseif ( 'text' == $value['type'] ) {
2348
- if ( '' == $_REQUEST[ MLA_OPTION_PREFIX . $key ] )
2349
  $_REQUEST[ MLA_OPTION_PREFIX . $key ] = $value['std'];
2350
-
 
2351
  $old_value = MLAOptions::mla_get_option( $key );
2352
  if ( $old_value != $_REQUEST[ MLA_OPTION_PREFIX . $key ] ) {
2353
  $settings_changed = true;
@@ -2356,7 +2582,7 @@ class MLASettings {
2356
  } // text
2357
  } // mla_gallery
2358
  } // foreach mla_options
2359
-
2360
  /*
2361
  * Get the current style contents for comparison
2362
  */
@@ -2365,74 +2591,84 @@ class MLASettings {
2365
  $new_names = $_REQUEST['mla_style_templates_name'];
2366
  $new_values = stripslashes_deep( $_REQUEST['mla_style_templates_value'] );
2367
  $new_deletes = isset( $_REQUEST['mla_style_templates_delete'] ) ? $_REQUEST['mla_style_templates_delete']: array();
2368
-
2369
  /*
2370
  * Build new style template array, noting changes
2371
  */
2372
  $default_styles = array( 'default', 'tag-cloud' );
2373
  $templates_changed = false;
2374
  foreach ( $new_names as $name => $new_name ) {
2375
- if ( in_array( $name, $default_styles ) )
2376
  continue;
 
2377
 
2378
- if( array_key_exists( $name, $new_deletes ) ) {
2379
- $message_list .= "<br>Deleting style template '{$name}'.";
 
2380
  $templates_changed = true;
2381
  continue;
2382
  }
2383
 
2384
  $new_slug = sanitize_title( $new_name );
2385
  if ( 'blank' == $name ) {
2386
- if ( '' == $new_slug )
2387
  continue;
2388
- elseif ( 'blank' == $new_slug ) {
2389
- $error_list .= "<br>ERROR: reserved name '{$new_slug}', new style template discarded.";
 
2390
  continue;
2391
  }
2392
-
2393
- if( array_key_exists( $new_slug, $old_templates ) ) {
2394
- $error_list .= "<br>ERROR: duplicate name '{$new_slug}', new style template discarded.";
 
2395
  continue;
2396
- }
2397
- else {
2398
- $message_list .= "<br>Adding new style template '{$new_slug}'.";
2399
  $templates_changed = true;
2400
  }
2401
  } // 'blank' - reserved name
2402
-
2403
  /*
2404
  * Handle name changes, check for duplicates
2405
  */
2406
  if ( '' == $new_slug ) {
2407
- $error_list .= "<br>ERROR: blank style template name value, reverting to '{$name}'.";
 
 
2408
  $new_slug = $name;
2409
  }
2410
-
2411
  if ( $new_slug != $name ) {
2412
- if( array_key_exists( $new_slug, $old_templates ) ) {
2413
- $error_list .= "<br>ERROR: duplicate new style template name '{$new_slug}', reverting to '{$name}'.";
 
2414
  $new_slug = $name;
2415
- }
2416
- elseif ( 'blank' != $name ) {
2417
- $message_list .= "<br>Changing style template name from '{$name}' to '{$new_slug}'.";
2418
  $templates_changed = true;
2419
  }
2420
  } // name changed
2421
-
2422
  if ( ( 'blank' != $name ) && ( $new_values[ $name ] != $old_templates[ $name ] ) ) {
2423
- $message_list .= "<br>Updating contents of style template '{$new_slug}'.";
 
2424
  $templates_changed = true;
2425
  }
2426
-
2427
  $new_templates[ $new_slug ] = $new_values[ $name ];
2428
  } // foreach $name
2429
-
2430
  if ( $templates_changed ) {
2431
  $settings_changed = true;
2432
- if ( false == MLAOptions::mla_put_style_templates( $new_templates ) )
2433
- $error_list .= "<br>ERROR: update of style templates failed.";
 
 
2434
  }
2435
-
2436
  /*
2437
  * Get the current markup contents for comparison
2438
  */
@@ -2445,111 +2681,128 @@ class MLASettings {
2445
  $new_values['row-close'] = stripslashes_deep( $_REQUEST['mla_markup_templates_row_close'] );
2446
  $new_values['close'] = stripslashes_deep( $_REQUEST['mla_markup_templates_close'] );
2447
  $new_deletes = isset( $_REQUEST['mla_markup_templates_delete'] ) ? $_REQUEST['mla_markup_templates_delete']: array();
2448
-
2449
  /*
2450
  * Build new markup template array, noting changes
2451
  */
2452
  $default_markups = array( 'default', 'tag-cloud', 'tag-cloud-ul', 'tag-cloud-dl' );
2453
  $templates_changed = false;
2454
  foreach ( $new_names as $name => $new_name ) {
2455
- if ( in_array( $name, $default_markups ) )
2456
  continue;
 
2457
 
2458
- if( array_key_exists( $name, $new_deletes ) ) {
2459
- $message_list .= "<br>Deleting markup template '{$name}'.";
 
2460
  $templates_changed = true;
2461
  continue;
2462
  }
2463
 
2464
  $new_slug = sanitize_title( $new_name );
2465
  if ( 'blank' == $name ) {
2466
- if ( '' == $new_slug )
2467
  continue;
2468
-
 
2469
  if ( 'blank' == $new_slug ) {
2470
- $error_list .= "<br>ERROR: reserved name '{$new_slug}', new markup template discarded.";
 
2471
  continue;
2472
  }
2473
-
2474
- if( array_key_exists( $new_slug, $old_templates ) ) {
2475
- $error_list .= "<br>ERROR: duplicate name '{$new_slug}', new markup template discarded.";
 
2476
  continue;
2477
- }
2478
- else {
2479
- $message_list .= "<br>Adding new markup template '{$new_slug}'.";
2480
  $templates_changed = true;
2481
  }
2482
  } // 'blank' - reserved name
2483
-
2484
  /*
2485
  * Handle name changes, check for duplicates
2486
  */
2487
  if ( '' == $new_slug ) {
2488
- $error_list .= "<br>ERROR: blank markup template name value, reverting to '{$name}'.";
 
2489
  $new_slug = $name;
2490
  }
2491
-
2492
  if ( $new_slug != $name ) {
2493
- if( array_key_exists( $new_slug, $old_templates ) ) {
2494
- $error_list .= "<br>ERROR: duplicate new markup template name '{$new_slug}', reverting to '{$name}'.";
 
2495
  $new_slug = $name;
2496
- }
2497
- elseif ( 'blank' != $name ) {
2498
- $message_list .= "<br>Changing markup template name from '{$name}' to '{$new_slug}'.";
2499
  $templates_changed = true;
2500
  }
2501
  } // name changed
2502
-
2503
  if ( 'blank' != $name ) {
2504
  if ( $new_values['open'][ $name ] != $old_templates[ $name ]['open'] ) {
2505
- $message_list .= "<br>Updating open markup for '{$new_slug}'.";
 
2506
  $templates_changed = true;
2507
  }
2508
-
2509
  if ( $new_values['row-open'][ $name ] != $old_templates[ $name ]['row-open'] ) {
2510
- $message_list .= "<br>Updating row open markup for '{$new_slug}'.";
 
2511
  $templates_changed = true;
2512
  }
2513
-
2514
  if ( $new_values['item'][ $name ] != $old_templates[ $name ]['item'] ) {
2515
- $message_list .= "<br>Updating item markup for '{$new_slug}'.";
 
2516
  $templates_changed = true;
2517
  }
2518
-
2519
  if ( $new_values['row-close'][ $name ] != $old_templates[ $name ]['row-close'] ) {
2520
- $message_list .= "<br>Updating row close markup for '{$new_slug}'.";
 
2521
  $templates_changed = true;
2522
  }
2523
-
2524
  if ( $new_values['close'][ $name ] != $old_templates[ $name ]['close'] ) {
2525
- $message_list .= "<br>Updating close markup for '{$new_slug}'.";
 
2526
  $templates_changed = true;
2527
  }
2528
  } // ! 'blank'
2529
-
2530
  $new_templates[ $new_slug ]['open'] = $new_values['open'][ $name ];
2531
  $new_templates[ $new_slug ]['row-open'] = $new_values['row-open'][ $name ];
2532
  $new_templates[ $new_slug ]['item'] = $new_values['item'][ $name ];
2533
  $new_templates[ $new_slug ]['row-close'] = $new_values['row-close'][ $name ];
2534
  $new_templates[ $new_slug ]['close'] = $new_values['close'][ $name ];
2535
  } // foreach $name
2536
-
2537
  if ( $templates_changed ) {
2538
  $settings_changed = true;
2539
- if ( false == MLAOptions::mla_put_markup_templates( $new_templates ) )
2540
- $error_list .= "<br>ERROR: update of markup templates failed.";
2541
- }
2542
-
2543
- if ( $settings_changed )
2544
- $message = "MLA Gallery settings saved.\r\n";
2545
- else
2546
- $message = "MLA Gallery no changes detected.\r\n";
2547
-
 
 
 
 
 
2548
  $page_content = array(
2549
  'message' => $message . $error_list,
2550
  'body' => ''
2551
  );
2552
-
2553
  /*
2554
  * Uncomment this for debugging.
2555
  */
@@ -2557,7 +2810,7 @@ class MLASettings {
2557
 
2558
  return $page_content;
2559
  } // _save_gallery_settings
2560
-
2561
  /**
2562
  * Save View settings to the options table
2563
  *
@@ -2569,18 +2822,18 @@ class MLASettings {
2569
  */
2570
  private static function _save_view_settings( ) {
2571
  $message_list = '';
2572
-
2573
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
2574
  if ( 'view' == $value['tab'] ) {
2575
  $message_list .= self::_update_option_row( $key, $value );
2576
  } // view option
2577
  } // foreach mla_options
2578
-
2579
  $page_content = array(
2580
- 'message' => "View settings saved.\r\n",
2581
  'body' => ''
2582
  );
2583
-
2584
  /*
2585
  * Uncomment this for debugging.
2586
  */
@@ -2588,7 +2841,7 @@ class MLASettings {
2588
 
2589
  return $page_content;
2590
  } // _save_view_settings
2591
-
2592
  /**
2593
  * Save Upload settings to the options table
2594
  *
@@ -2600,21 +2853,21 @@ class MLASettings {
2600
  */
2601
  private static function _save_upload_settings( ) {
2602
  $message_list = '';
2603
-
2604
  if ( ! isset( $_REQUEST[ MLA_OPTION_PREFIX . MLAOptions::MLA_ENABLE_UPLOAD_MIMES ] ) )
2605
  unset( $_REQUEST[ MLA_OPTION_PREFIX . MLAOptions::MLA_ENABLE_MLA_ICONS ] );
2606
-
2607
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
2608
  if ( 'upload' == $value['tab'] ) {
2609
  $message_list .= self::_update_option_row( $key, $value );
2610
  } // upload option
2611
  } // foreach mla_options
2612
-
2613
  $page_content = array(
2614
- 'message' => "Upload MIME Type settings saved.\r\n",
2615
  'body' => ''
2616
  );
2617
-
2618
  /*
2619
  * Uncomment this for debugging.
2620
  */
@@ -2622,7 +2875,7 @@ class MLASettings {
2622
 
2623
  return $page_content;
2624
  } // _save_upload_settings
2625
-
2626
  /**
2627
  * Process custom field settings against all image attachments
2628
  * without saving the settings to the mla_option
@@ -2636,20 +2889,23 @@ class MLASettings {
2636
  */
2637
  private static function _process_custom_field_mapping( $settings = NULL ) {
2638
  global $wpdb;
2639
-
2640
  if ( NULL == $settings ) {
2641
  $settings = ( isset( $_REQUEST['custom_field_mapping'] ) ) ? $_REQUEST['custom_field_mapping'] : array();
2642
- if ( isset( $settings[ MLAOptions::MLA_NEW_CUSTOM_FIELD ] ) )
2643
  unset( $settings[ MLAOptions::MLA_NEW_CUSTOM_FIELD ] );
2644
- if ( isset( $settings[ MLAOptions::MLA_NEW_CUSTOM_RULE ] ) )
 
2645
  unset( $settings[ MLAOptions::MLA_NEW_CUSTOM_RULE ] );
 
2646
  }
2647
-
2648
- if ( empty( $settings ) )
2649
  return array(
2650
- 'message' => 'ERROR: No custom field mapping rules to process.',
2651
  'body' => ''
2652
  );
 
2653
 
2654
  $examine_count = 0;
2655
  $update_count = 0;
@@ -2661,22 +2917,26 @@ class MLASettings {
2661
  $examine_count += 1;
2662
  if ( ! empty( $updates ) ) {
2663
  $results = MLAData::mla_update_item_postmeta( (integer) $post_id, $updates['custom_updates'] );
2664
- if ( ! empty( $results ) )
2665
  $update_count += 1;
 
2666
  }
2667
  } // foreach post
2668
-
2669
- if ( $update_count )
2670
- $message = "Custom field mapping completed; {$examine_count} attachment(s) examined, {$update_count} updated.\r\n";
2671
- else
2672
- $message = "Custom field mapping completed; {$examine_count} attachment(s) examined, no changes detected.\r\n";
2673
-
 
 
 
2674
  return array(
2675
  'message' => $message,
2676
  'body' => ''
2677
  );
2678
  } // _process_custom_field_mapping
2679
-
2680
  /**
2681
  * Delete a custom field from the wp_postmeta table
2682
  *
@@ -2694,12 +2954,14 @@ class MLASettings {
2694
  delete_metadata_by_mid( 'post', $mid );
2695
 
2696
  $count = count( $post_meta_ids );
2697
- if ( $count )
2698
- return sprintf( 'Deleted custom field value from ' . _n('%s attachment.<br>', '%s attachments.<br>', $count), $count);
2699
- else
2700
- return 'No attachments contained this custom field.<br>';
 
 
2701
  } // _delete_custom_field
2702
-
2703
  /**
2704
  * Save custom field settings to the options table
2705
  *
@@ -2719,10 +2981,11 @@ class MLASettings {
2719
  * Start with any page-level options
2720
  */
2721
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
2722
- if ( 'custom_field' == $value['tab'] )
2723
  $option_messages .= self::_update_option_row( $key, $value );
 
2724
  }
2725
-
2726
  /*
2727
  * Add mapping options
2728
  */
@@ -2733,13 +2996,13 @@ class MLASettings {
2733
  * Uncomment this for debugging.
2734
  */
2735
  // $message_list = $option_messages . '<br>';
2736
-
2737
  return array(
2738
  'message' => $message_list . MLAOptions::mla_custom_field_option_handler( 'update', 'custom_field_mapping', MLAOptions::$mla_option_definitions['custom_field_mapping'], $new_values ),
2739
  'body' => ''
2740
  );
2741
  } // _save_custom_field_settings
2742
-
2743
  /**
2744
  * Process IPTC/EXIF standard field settings against all image attachments
2745
  * without saving the settings to the mla_option
@@ -2751,47 +3014,53 @@ class MLASettings {
2751
  * @return array Message(s) reflecting the results of the operation
2752
  */
2753
  private static function _process_iptc_exif_standard( ) {
2754
- if ( ! isset( $_REQUEST['iptc_exif_mapping']['standard'] ) )
2755
  return array(
2756
- 'message' => 'ERROR: No standard field settings to process.',
 
2757
  'body' => ''
2758
  );
 
2759
 
2760
  $examine_count = 0;
2761
  $update_count = 0;
2762
-
2763
- // $query = array( 'orderby' => 'none', 'post_parent' => 'all' ); // , 'post_mime_type' => 'image' );
2764
- // $query = array( 'orderby' => 'none', 'post_parent' => 'all', 'post_mime_type' => 'application/*pdf*' );
2765
  $query = array( 'orderby' => 'none', 'post_parent' => 'all', 'post_mime_type' => 'image,application/*pdf*' );
2766
  $posts = MLAShortcodes::mla_get_shortcode_attachments( 0, $query );
2767
-
2768
- if ( is_string( $posts ) )
2769
  return array(
2770
  'message' => $posts,
2771
  'body' => ''
2772
  );
 
2773
 
2774
  foreach ( $posts as $key => $post ) {
2775
  $updates = MLAOptions::mla_evaluate_iptc_exif_mapping( $post, 'iptc_exif_standard_mapping', $_REQUEST['iptc_exif_mapping'] );
2776
 
2777
  $examine_count += 1;
2778
  if ( ! empty( $updates ) ) {
2779
- MLAData::mla_update_single_item( $post->ID, $updates );
2780
- $update_count += 1;
 
 
2781
  }
2782
  } // foreach post
2783
-
2784
- if ( $update_count )
2785
- $message = "IPTC/EXIF Standard field mapping completed; {$examine_count} attachment(s) examined, {$update_count} updated.\r\n";
2786
- else
2787
- $message = "IPTC/EXIF Standard field mapping completed; {$examine_count} attachment(s) examined, no changes detected.\r\n";
2788
-
 
 
 
2789
  return array(
2790
  'message' => $message,
2791
  'body' => ''
2792
  );
2793
  } // _process_iptc_exif_standard
2794
-
2795
  /**
2796
  * Process IPTC/EXIF taxonomy term settings against all image attachments
2797
  * without saving the settings to the mla_option
@@ -2803,25 +3072,26 @@ class MLASettings {
2803
  * @return array Message(s) reflecting the results of the operation
2804
  */
2805
  private static function _process_iptc_exif_taxonomy( ) {
2806
- if ( ! isset( $_REQUEST['iptc_exif_mapping']['taxonomy'] ) )
2807
  return array(
2808
- 'message' => 'ERROR: No taxonomy term settings to process.',
 
2809
  'body' => ''
2810
  );
 
2811
 
2812
  $examine_count = 0;
2813
  $update_count = 0;
2814
-
2815
- // $query = array( 'orderby' => 'none', 'post_parent' => 'all' ); // , 'post_mime_type' => 'image' );
2816
- // $query = array( 'orderby' => 'none', 'post_parent' => 'all', 'post_mime_type' => 'application/*pdf*' );
2817
  $query = array( 'orderby' => 'none', 'post_parent' => 'all', 'post_mime_type' => 'image,application/*pdf*' );
2818
  $posts = MLAShortcodes::mla_get_shortcode_attachments( 0, $query );
2819
-
2820
- if ( is_string( $posts ) )
2821
  return array(
2822
  'message' => $posts,
2823
  'body' => ''
2824
  );
 
2825
 
2826
  foreach ( $posts as $key => $post ) {
2827
  $updates = MLAOptions::mla_evaluate_iptc_exif_mapping( $post, 'iptc_exif_taxonomy_mapping', $_REQUEST['iptc_exif_mapping'] );
@@ -2829,22 +3099,26 @@ class MLASettings {
2829
  $examine_count += 1;
2830
  if ( ! empty( $updates ) ) {
2831
  $results = MLAData::mla_update_single_item( $post->ID, array(), $updates['taxonomy_updates']['inputs'], $updates['taxonomy_updates']['actions'] );
2832
- if ( stripos( $results['message'], 'updated.' ) )
2833
  $update_count += 1;
 
2834
  }
2835
  } // foreach post
2836
-
2837
- if ( $update_count )
2838
- $message = "IPTC/EXIF Taxonomy term mapping completed; {$examine_count} attachment(s) examined, {$update_count} updated.\r\n";
2839
- else
2840
- $message = "IPTC/EXIF Taxonomy term mapping completed; {$examine_count} attachment(s) examined, no changes detected.\r\n";
2841
-
 
 
 
2842
  return array(
2843
  'message' => $message,
2844
  'body' => ''
2845
  );
2846
  } // _process_iptc_exif_taxonomy
2847
-
2848
  /**
2849
  * Process IPTC/EXIF custom field settings against all image attachments
2850
  * without saving the settings to the mla_option
@@ -2860,31 +3134,34 @@ class MLASettings {
2860
  private static function _process_iptc_exif_custom( $settings = NULL ) {
2861
  if ( NULL == $settings ) {
2862
  $settings = ( isset( $_REQUEST['iptc_exif_mapping'] ) ) ? $_REQUEST['iptc_exif_mapping'] : array();
2863
- if ( isset( $settings['custom'][ MLAOptions::MLA_NEW_CUSTOM_FIELD ] ) )
2864
  unset( $settings['custom'][ MLAOptions::MLA_NEW_CUSTOM_FIELD ] );
2865
- if ( isset( $settings['custom'][ MLAOptions::MLA_NEW_CUSTOM_RULE ] ) )
 
2866
  unset( $settings['custom'][ MLAOptions::MLA_NEW_CUSTOM_RULE ] );
 
2867
  }
2868
-
2869
- if ( empty( $settings['custom'] ) )
2870
  return array(
2871
- 'message' => 'ERROR: No custom field settings to process.',
 
2872
  'body' => ''
2873
  );
 
2874
 
2875
  $examine_count = 0;
2876
  $update_count = 0;
2877
-
2878
- // $query = array( 'orderby' => 'none', 'post_parent' => 'all' ); // , 'post_mime_type' => 'image' );
2879
- // $query = array( 'orderby' => 'none', 'post_parent' => 'all', 'post_mime_type' => 'application/*pdf*' );
2880
  $query = array( 'orderby' => 'none', 'post_parent' => 'all', 'post_mime_type' => 'image,application/*pdf*' );
2881
  $posts = MLAShortcodes::mla_get_shortcode_attachments( 0, $query );
2882
-
2883
- if ( is_string( $posts ) )
2884
  return array(
2885
  'message' => $posts,
2886
  'body' => ''
2887
  );
 
2888
 
2889
  foreach ( $posts as $key => $post ) {
2890
  $updates = MLAOptions::mla_evaluate_iptc_exif_mapping( $post, 'iptc_exif_custom_mapping', $settings );
@@ -2892,22 +3169,26 @@ class MLASettings {
2892
  $examine_count += 1;
2893
  if ( ! empty( $updates ) ) {
2894
  $results = MLAData::mla_update_single_item( $post->ID, $updates );
2895
- if ( stripos( $results['message'], 'updated.' ) )
2896
  $update_count += 1;
 
2897
  }
2898
  } // foreach post
2899
-
2900
- if ( $update_count )
2901
- $message = "IPTC/EXIF custom field mapping completed; {$examine_count} attachment(s) examined, {$update_count} updated.\r\n";
2902
- else
2903
- $message = "IPTC/EXIF custom field mapping completed; {$examine_count} attachment(s) examined, no changes detected.\r\n";
2904
-
 
 
 
2905
  return array(
2906
  'message' => $message,
2907
  'body' => ''
2908
  );
2909
  } // _process_iptc_exif_custom
2910
-
2911
  /**
2912
  * Save IPTC/EXIF custom field settings to the options table
2913
  *
@@ -2923,7 +3204,7 @@ class MLASettings {
2923
  'body' => ''
2924
  );
2925
  } // _save_iptc_exif_custom_settings
2926
-
2927
  /**
2928
  * Save IPTC/EXIF settings to the options table
2929
  *
@@ -2941,15 +3222,16 @@ class MLASettings {
2941
  * Start with any page-level options
2942
  */
2943
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
2944
- if ( 'iptc_exif' == $value['tab'] )
2945
  $option_messages .= self::_update_option_row( $key, $value );
 
2946
  }
2947
 
2948
  /*
2949
  * Uncomment this for debugging.
2950
  */
2951
  // $message_list = $option_messages . '<br>';
2952
-
2953
  /*
2954
  * Add mapping options
2955
  */
@@ -2960,7 +3242,7 @@ class MLASettings {
2960
  'body' => ''
2961
  );
2962
  } // _save_iptc_exif_settings
2963
-
2964
  /**
2965
  * Save General settings to the options table
2966
  *
@@ -2972,7 +3254,7 @@ class MLASettings {
2972
  */
2973
  private static function _save_general_settings( ) {
2974
  $message_list = '';
2975
-
2976
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
2977
  if ( 'general' == $value['tab'] ) {
2978
  switch ( $key ) {
@@ -2984,19 +3266,21 @@ class MLASettings {
2984
  break;
2985
  case MLAOptions::MLA_GALLERY_IN_TUNING:
2986
  MLAOptions::$process_gallery_in = ( 'disabled' != $_REQUEST[ MLA_OPTION_PREFIX . $key ] );
2987
-
2988
  if ( 'refresh' == $_REQUEST[ MLA_OPTION_PREFIX . $key ] ) {
2989
  MLAData::mla_flush_mla_galleries( MLAOptions::MLA_GALLERY_IN_TUNING );
2990
- $message_list .= "<br>Gallery in - references updated.\r\n";
 
2991
  $_REQUEST[ MLA_OPTION_PREFIX . $key ] = 'cached';
2992
  }
2993
  break;
2994
  case MLAOptions::MLA_MLA_GALLERY_IN_TUNING:
2995
  MLAOptions::$process_mla_gallery_in = ( 'disabled' != $_REQUEST[ MLA_OPTION_PREFIX . $key ] );
2996
-
2997
  if ( 'refresh' == $_REQUEST[ MLA_OPTION_PREFIX . $key ] ) {
2998
  MLAData::mla_flush_mla_galleries( MLAOptions::MLA_MLA_GALLERY_IN_TUNING );
2999
- $message_list .= "<br>MLA Gallery in - references updated.\r\n";
 
3000
  $_REQUEST[ MLA_OPTION_PREFIX . $key ] = 'cached';
3001
  }
3002
  break;
@@ -3007,12 +3291,12 @@ class MLASettings {
3007
  $message_list .= self::_update_option_row( $key, $value );
3008
  } // general option
3009
  } // foreach mla_options
3010
-
3011
  $page_content = array(
3012
- 'message' => "General settings saved.\r\n",
3013
  'body' => ''
3014
  );
3015
-
3016
  /*
3017
  * Uncomment this for debugging.
3018
  */
@@ -3020,7 +3304,7 @@ class MLASettings {
3020
 
3021
  return $page_content;
3022
  } // _save_general_settings
3023
-
3024
  /**
3025
  * Delete saved settings, restoring default values
3026
  *
@@ -3030,26 +3314,25 @@ class MLASettings {
3030
  */
3031
  private static function _reset_general_settings( ) {
3032
  $message_list = '';
3033
-
3034
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
3035
  if ( 'general' == $value['tab'] ) {
3036
  if ( 'custom' == $value['type'] && isset( $value['reset'] ) ) {
3037
  $message = MLAOptions::$value['reset']( 'reset', $key, $value, $_REQUEST );
3038
- }
3039
- elseif ( ('header' == $value['type']) || ('hidden' == $value['type']) ) {
3040
  $message = '';
3041
- }
3042
- else {
3043
  MLAOptions::mla_delete_option( $key );
3044
- $message = '<br>delete_option(' . $key . ')';
 
3045
  }
3046
-
3047
  $message_list .= $message;
3048
  }
3049
  }
3050
-
3051
  $page_content = array(
3052
- 'message' => 'General tab settings reset to default values.',
3053
  'body' => ''
3054
  );
3055
 
@@ -3057,10 +3340,10 @@ class MLASettings {
3057
  * Uncomment this for debugging.
3058
  */
3059
  // $page_content['message'] .= $message_list;
3060
-
3061
  return $page_content;
3062
  } // _reset_general_settings
3063
-
3064
  /**
3065
  * Compose HTML markup for the import settings if any settings files exist
3066
  *
@@ -3069,9 +3352,10 @@ class MLASettings {
3069
  * @return string HTML markup for the Import All Settings button and dropdown list, if any
3070
  */
3071
  private static function _compose_import_settings( ) {
3072
- if ( ! file_exists( MLA_BACKUP_DIR ) )
3073
  return '';
3074
-
 
3075
  $prefix = ( ( defined( MLA_OPTION_PREFIX ) ) ? MLA_OPTION_PREFIX : 'mla_' ) . '_options_';
3076
  $prefix_length = strlen( $prefix );
3077
  $backup_files = array();
@@ -3083,16 +3367,17 @@ class MLASettings {
3083
  $backup_files [ $text ] = $file;
3084
  }
3085
  }
3086
-
3087
- if ( empty( $backup_files ) )
3088
  return '';
 
3089
 
3090
  $option_values = array(
3091
  'value' => 'none',
3092
- 'text' => '-- select settings --',
3093
  'selected' => 'selected="selected"'
3094
  );
3095
-
3096
  $select_options = MLAData::mla_parse_template( self::$page_template_array['select-option'], $option_values );
3097
  foreach ( $backup_files as $text => $file ) {
3098
  $option_values = array(
@@ -3100,18 +3385,18 @@ class MLASettings {
3100
  'text' => esc_html( $text ),
3101
  'selected' => ''
3102
  );
3103
-
3104
  $select_options .= MLAData::mla_parse_template( self::$page_template_array['select-option'], $option_values );
3105
  }
3106
-
3107
  $option_values = array(
3108
  'key' => 'mla-import-settings-file',
3109
  'options' => $select_options
3110
  );
3111
-
3112
- return '<input name="mla-general-options-import" type="submit" class="button-primary" value="Import ALL Settings" />' . MLAData::mla_parse_template( self::$page_template_array['select-only'], $option_values );
3113
  } // _compose_import_settings
3114
-
3115
  /**
3116
  * Serialize option settings and write them to a file
3117
  *
@@ -3134,58 +3419,65 @@ class MLASettings {
3134
  if ( false !== $stored_value ) {
3135
  $settings[ $key ] = $stored_value;
3136
  $stored_count++;
3137
- $message = "<br>{$key} exported";
 
 
3138
  }
3139
- else
3140
- $message = "<br>{$key} skipped";
3141
-
3142
  $message_list .= $message;
3143
  }
3144
-
3145
  $settings = serialize( $settings );
3146
- $page_content = array( 'message' => 'ALL settings exported.', 'body' => '' );
3147
-
3148
  /*
3149
  * Make sure the directory exists and is writable, then create the file
3150
  */
3151
  $prefix = ( defined( MLA_OPTION_PREFIX ) ) ? MLA_OPTION_PREFIX : 'mla_';
3152
  $date = date("Ymd_B");
3153
  $filename = MLA_BACKUP_DIR . "{$prefix}_options_{$date}.txt";
3154
-
3155
  if ( ! file_exists( MLA_BACKUP_DIR ) && ! @mkdir( MLA_BACKUP_DIR ) ) {
3156
- $page_content['message'] = 'ERROR: The settings directory ( ' . MLA_BACKUP_DIR . ' ) cannot be created.';
 
3157
  return $page_content;
3158
- }
3159
- elseif ( ! is_writable( MLA_BACKUP_DIR ) && ! @chmod( MLA_BACKUP_DIR , '0777') ) {
3160
- $page_content['message'] = 'ERROR: The settings directory ( ' . MLA_BACKUP_DIR . ' ) is not writable.';
3161
  return $page_content;
3162
  }
3163
-
3164
- if ( ! file_exists( MLA_BACKUP_DIR . 'index.php') )
3165
  @ touch( MLA_BACKUP_DIR . 'index.php');
 
3166
 
3167
  $file_pointer = @fopen( $filename, 'w' );
3168
- if( ! $file_pointer ) {
3169
- $page_content['message'] = "ERROR: The settings file ( {$filename} ) could not be opened.";
 
3170
  return $page_content;
3171
  }
3172
-
3173
- if(false === @fwrite($file_pointer, $settings)) {
3174
  $error_info = error_get_last();
3175
- error_log( 'ERROR: _export_settings $error_info = ' . var_export( $error_info, true ), 0 );
 
3176
 
3177
- if ( false !== ( $tail = strpos( $error_info['message'], '</a>]: ' ) ) )
3178
  $php_errormsg = ':<br>' . substr( $error_info['message'], $tail + 7 );
3179
- else
3180
  $php_errormsg = '.';
3181
-
3182
- $page_content['message'] = "ERROR: writing the settings file ( {$filename} ){$php_errormsg}";
 
 
3183
  }
3184
 
3185
  fclose($file_pointer);
3186
 
3187
- $page_content['message'] = "Settings exported; {$stored_count} settings recorded.";
3188
-
 
3189
  /*
3190
  * Uncomment this for debugging.
3191
  */
@@ -3193,7 +3485,7 @@ class MLASettings {
3193
 
3194
  return $page_content;
3195
  } // _export_settings
3196
-
3197
  /**
3198
  * Read a serialized file of option settings and write them to the database
3199
  *
@@ -3202,35 +3494,37 @@ class MLASettings {
3202
  * @return array Message(s) reflecting the results of the operation
3203
  */
3204
  private static function _import_settings( ) {
3205
- $page_content = array( 'message' => 'No settings imported.', 'body' => '' );
3206
  $message_list = '';
3207
 
3208
  if ( isset( $_REQUEST['mla-import-settings-file'] ) ) {
3209
  $filename = $_REQUEST['mla-import-settings-file'];
3210
-
3211
- if ( 'none' != $filename )
3212
  $filename = MLA_BACKUP_DIR . $filename;
3213
- else {
3214
- $page_content['message'] = 'Please select an import settings file from the dropdown list.';
3215
  return $page_content;
3216
  }
3217
- }
3218
- else {
3219
- $page_content['message'] = "ERROR: The import settings dropdown selection is missing.";
3220
  return $page_content;
3221
  }
3222
-
3223
  $settings = @file_get_contents( $filename, false );
3224
- if( false === $settings ) {
3225
  $error_info = error_get_last();
3226
- error_log( 'ERROR: _import_settings $error_info = ' . var_export( $error_info, true ), 0 );
 
3227
 
3228
- if ( false !== ( $tail = strpos( $error_info['message'], '</a>]: ' ) ) )
3229
  $php_errormsg = ':<br>' . substr( $error_info['message'], $tail + 7 );
3230
- else
3231
  $php_errormsg = '.';
3232
-
3233
- $page_content['message'] = "ERROR: reading the settings file ( {$filename} ){$php_errormsg}";
 
 
3234
  return $page_content;
3235
  }
3236
 
@@ -3240,21 +3534,21 @@ class MLASettings {
3240
  foreach ( $settings as $key => $value ) {
3241
  if ( MLAOptions::mla_update_option( $key, $value ) ) {
3242
  $updated_count++;
3243
- $message_list .= "<br>{$key} updated";
3244
- }
3245
- else {
3246
  $unchanged_count++;
3247
- $message_list .= "<br>{$key} unchanged";
3248
  }
3249
  }
3250
-
3251
- $page_content['message'] = "Settings imported; {$updated_count} updated, {$unchanged_count} unchanged.";
3252
-
 
3253
  /*
3254
  * Uncomment this for debugging.
3255
  */
3256
  //$page_content['message'] .= $message_list;
3257
-
3258
  return $page_content;
3259
  } // _import_settings
3260
  } // class MLASettings
53
  * Provides a unique name for the settings page
54
  */
55
  const MLA_SETTINGS_SLUG = 'mla-settings-menu';
56
+
57
  /**
58
  * Holds screen id to match help text to corresponding screen
59
  *
62
  * @var array
63
  */
64
  private static $current_page_hook = '';
65
+
66
  /**
67
  * Initialization function, similar to __construct()
68
  *
79
  add_filter( 'screen_options_show_screen', 'MLASettings::mla_screen_options_show_screen_filter', 10, 2 ); // $show_screen, $this
80
  self::_version_upgrade();
81
  }
82
+
83
  /**
84
  * Database and option update check, for installing new versions
85
  *
89
  */
90
  private static function _version_upgrade( ) {
91
  $current_version = MLAOptions::mla_get_option( MLAOptions::MLA_VERSION_OPTION );
92
+
93
  if ( ((float)'.30') > ((float)$current_version) ) {
94
  /*
95
  * Convert attachment_category and _tag to taxonomy_support;
100
  if ( ! ( ( 'checked' == $category_option ) && ( 'checked' == $tag_option ) ) ) {
101
  $tax_option = MLAOptions::mla_get_option( MLAOptions::MLA_TAXONOMY_SUPPORT );
102
  if ( 'checked' != $category_option ) {
103
+ if ( isset( $tax_option['tax_support']['attachment_category'] ) ) {
104
  unset( $tax_option['tax_support']['attachment_category'] );
105
+ }
106
  }
107
 
108
  if ( 'checked' != $tag_option ) {
109
+ if ( isset( $tax_option['tax_support']['attachment_tag'] ) ) {
110
  unset( $tax_option['tax_support']['attachment_tag'] );
111
+ }
112
  }
113
 
114
  MLAOptions::mla_taxonomy_option_handler( 'update', 'taxonomy_support', MLAOptions::$mla_option_definitions['taxonomy_support'], $tax_option );
117
  MLAOptions::mla_delete_option( 'attachment_category' );
118
  MLAOptions::mla_delete_option( 'attachment_tag' );
119
  } // version is less than .30
120
+
121
  if ( ((float)'1.13') > ((float)$current_version) ) {
122
  /*
123
  * Add quick_edit and bulk_edit values to custom field mapping rules
124
  */
125
  $new_values = array();
126
+
127
  foreach ( MLAOptions::mla_get_option( 'custom_field_mapping' ) as $key => $value ) {
128
  $value['quick_edit'] = ( isset( $value['quick_edit'] ) && $value['quick_edit'] ) ? true : false;
129
  $value['bulk_edit'] = ( isset( $value['bulk_edit'] ) && $value['bulk_edit'] ) ? true : false;
132
 
133
  MLAOptions::mla_update_option( 'custom_field_mapping', $new_values );
134
  } // version is less than 1.13
135
+
136
  if ( ((float)'1.30') > ((float)$current_version) ) {
137
  /*
138
  * Add metadata values to custom field mapping rules
139
  */
140
  $new_values = array();
141
+
142
  foreach ( MLAOptions::mla_get_option( 'custom_field_mapping' ) as $key => $value ) {
143
  $value['meta_name'] = isset( $value['meta_name'] ) ? $value['meta_name'] : '';
144
  $value['meta_single'] = ( isset( $value['meta_single'] ) && $value['meta_single'] ) ? true : false;
148
 
149
  MLAOptions::mla_update_option( 'custom_field_mapping', $new_values );
150
  } // version is less than 1.30
151
+
152
  if ( ((float)'1.40') > ((float)$current_version) ) {
153
  /*
154
  * Add metadata values to custom field mapping rules
155
  */
156
  $new_values = array();
157
+
158
  foreach ( MLAOptions::mla_get_option( 'custom_field_mapping' ) as $key => $value ) {
159
  $value['no_null'] = ( isset( $value['no_null'] ) && $value['no_null'] ) ? true : false;
160
+
161
+ if ( isset( $value['meta_single'] ) && $value['meta_single'] ) {
162
  $value['option'] = 'single';
163
+ } elseif ( isset( $value['meta_export'] ) && $value['meta_export'] ) {
164
  $value['option'] = 'export';
165
+ } else {
166
  $value['option'] = 'text';
167
+ }
168
+
169
  unset( $value['meta_single'] );
170
  unset( $value['meta_export'] );
171
+
172
  $new_values[ $key ] = $value;
173
  }
174
 
175
  MLAOptions::mla_update_option( 'custom_field_mapping', $new_values );
176
  } // version is less than 1.40
177
+
178
  if ( ((float)'1.60') > ((float)$current_version) ) {
179
  /*
180
  * Add delimiters values to taxonomy mapping rules
181
  */
182
  $option_value = MLAOptions::mla_get_option( 'iptc_exif_mapping' );
183
  $new_values = array();
184
+
185
  foreach ( $option_value['taxonomy'] as $key => $value ) {
186
  $value['delimiters'] = isset( $value['delimiters'] ) ? $value['delimiters'] : '';
187
  $new_values[ $key ] = $value;
190
  $option_value['taxonomy'] = $new_values;
191
  MLAOptions::mla_update_option( 'iptc_exif_mapping', $option_value );
192
  } // version is less than 1.60
193
+
194
  MLAOptions::mla_update_option( MLAOptions::MLA_VERSION_OPTION, MLA::CURRENT_MLA_VERSION );
195
  }
196
+
197
  /**
198
  * Perform one-time actions on plugin activation
199
  *
206
  public static function mla_activation_hook( ) {
207
  // self::_create_alt_text_view(); DELETED v1.10, NO LONGER REQUIRED
208
  }
209
+
210
  /**
211
  * Perform one-time actions on plugin deactivation
212
  *
218
  */
219
  public static function mla_deactivation_hook( ) {
220
  global $wpdb, $table_prefix;
221
+
222
  $view_name = $table_prefix . MLA_OPTION_PREFIX . MLAData::MLA_ALT_TEXT_VIEW_SUFFIX;
223
  $result = $wpdb->query( "SHOW TABLES LIKE '{$view_name}'" );
224
 
226
  $result = $wpdb->query( "DROP VIEW {$view_name}" );
227
  }
228
  }
229
+
230
  /**
231
  * Debug logging for "You do not have sufficient permissions to access this page."
232
  *
242
  global $_wp_submenu_nopriv;
243
  global $plugin_page;
244
  global $_registered_pages;
245
+
246
  error_log( 'DEBUG: mla_admin_page_access_denied_action $_SERVER[REQUEST_URI] = ' . var_export( $_SERVER['REQUEST_URI'], true), 0 );
247
  error_log( 'DEBUG: mla_admin_page_access_denied_action $_REQUEST = ' . var_export( $_REQUEST, true), 0 );
248
  error_log( 'DEBUG: mla_admin_page_access_denied_action $pagenow = ' . var_export( $pagenow, true), 0 );
255
  error_log( 'DEBUG: mla_admin_page_access_denied_action $_registered_pages = ' . var_export( $_registered_pages, true), 0 );
256
  }
257
  // */
258
+
259
  /**
260
  * Load the plugin's Ajax handler
261
  *
267
  add_action( 'wp_ajax_' . self::JAVASCRIPT_INLINE_EDIT_VIEW_SLUG, 'MLASettings::mla_inline_edit_view_action' );
268
  add_action( 'wp_ajax_' . self::JAVASCRIPT_INLINE_EDIT_UPLOAD_SLUG, 'MLASettings::mla_inline_edit_upload_action' );
269
  }
270
+
271
  /**
272
  * Load the plugin's Style Sheet and Javascript files
273
  *
279
  */
280
  public static function mla_admin_enqueue_scripts_action( $page_hook ) {
281
  $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
282
+
283
+ if ( self::$current_page_hook != $page_hook ) {
284
  return;
285
+ }
286
 
287
  wp_register_style( MLA::STYLESHEET_SLUG, MLA_PLUGIN_URL . 'css/mla-style.css', false, MLA::CURRENT_MLA_VERSION );
288
  wp_enqueue_style( MLA::STYLESHEET_SLUG );
289
+
290
  if ( isset( $_REQUEST['mla_tab'] ) && ( $_REQUEST['mla_tab'] == 'view' ) ) {
291
  wp_enqueue_script( self::JAVASCRIPT_INLINE_EDIT_VIEW_SLUG, MLA_PLUGIN_URL . "js/mla-inline-edit-view-scripts{$suffix}.js",
292
  array( 'wp-lists', 'suggest', 'jquery' ), MLA::CURRENT_MLA_VERSION, false );
293
+
294
  $script_variables = array(
295
  'fields' => array( 'original_slug', 'slug', 'singular', 'plural', 'specification', 'menu_order' ),
296
  'checkboxes' => array( 'post_mime_type', 'table_view' ),
297
+ 'error' => __( 'Error while saving the changes.', 'media-library-assistant' ),
298
+ 'ntdeltitle' => __( 'Remove From Bulk Edit', 'media-library-assistant' ),
299
+ 'notitle' => '(' . __( 'no slug', 'media-library-assistant' ) . ')',
300
+ 'comma' => _x( ',', 'tag_delimiter', 'media-library-assistant' ),
301
  'ajax_action' => self::JAVASCRIPT_INLINE_EDIT_VIEW_SLUG,
302
  'ajax_nonce' => wp_create_nonce( MLA::MLA_ADMIN_NONCE )
303
  );
312
  $script_variables = array(
313
  'fields' => array( 'original_slug', 'slug', 'mime_type', 'icon_type', 'core_type', 'mla_type', 'source', 'standard_source' ),
314
  'checkboxes' => array( 'disabled' ),
315
+ 'error' => __( 'Error while saving the changes.', 'media-library-assistant' ),
316
+ 'ntdeltitle' => __( 'Remove From Bulk Edit', 'media-library-assistant' ),
317
+ 'notitle' => '(' . __( 'no slug', 'media-library-assistant' ) . ')',
318
+ 'comma' => _x( ',', 'tag_delimiter', 'media-library-assistant' ),
319
  'ajax_action' => self::JAVASCRIPT_INLINE_EDIT_UPLOAD_SLUG,
320
  'ajax_nonce' => wp_create_nonce( MLA::MLA_ADMIN_NONCE )
321
  );
323
  return;
324
  }
325
  }
326
+
327
  /**
328
  * Add settings page in the "Settings" section,
329
  * add screen options and help tabs,
339
  * Use the URL suffix, if present. If the URL doesn't have a tab suffix, use '-general'.
340
  * This hack is required to pass the WordPress "referer" validation.
341
  */
342
+ if ( isset( $_REQUEST['page'] ) && is_string( $_REQUEST['page'] ) && ( 'mla-settings-menu-' == substr( $_REQUEST['page'], 0, 18 ) ) ) {
343
  $tab = substr( $_REQUEST['page'], 18 );
344
+ } else {
345
  $tab = 'general';
346
+ }
347
+
348
  $tab = isset ( self::$mla_tablist[ $tab ] ) ? '-' . $tab : '-general';
349
+ self::$current_page_hook = add_submenu_page( 'options-general.php', __( 'Media Library Assistant Settings', 'media-library-assistant' ), __( 'Media Library Assistant', 'media-library-assistant' ), 'manage_options', self::MLA_SETTINGS_SLUG . $tab, 'MLASettings::mla_render_settings_page' );
350
  add_action( 'load-' . self::$current_page_hook, 'MLASettings::mla_add_menu_options_action' );
351
  add_action( 'load-' . self::$current_page_hook, 'MLASettings::mla_add_help_tab_action' );
352
  add_filter( 'plugin_action_links', 'MLASettings::mla_add_plugin_settings_link_filter', 10, 2 );
353
  }
354
+
355
  /**
356
  * Add the "XX Entries per page" filter to the Screen Options tab
357
  *
363
  if ( isset( $_REQUEST['mla_tab'] ) ) {
364
  if ( 'view' == $_REQUEST['mla_tab'] ) {
365
  $option = 'per_page';
366
+
367
  $args = array(
368
+ 'label' => __( 'Views per page', 'media-library-assistant' ),
369
  'default' => 10,
370
  'option' => 'mla_views_per_page'
371
  );
372
+
373
  add_screen_option( $option, $args );
374
  } // view
375
  elseif ( isset( $_REQUEST['mla-optional-uploads-display'] ) || isset( $_REQUEST['mla-optional-uploads-search'] ) ) {
376
  $option = 'per_page';
377
+
378
  $args = array(
379
+ 'label' => __( 'Types per page', 'media-library-assistant' ),
380
  'default' => 10,
381
  'option' => 'mla_types_per_page'
382
  );
383
+
384
  add_screen_option( $option, $args );
385
  } // optional upload
386
  elseif ( 'upload' == $_REQUEST['mla_tab'] ) {
387
  $option = 'per_page';
388
+
389
  $args = array(
390
+ 'label' => __( 'Upload types per page', 'media-library-assistant' ),
391
  'default' => 10,
392
  'option' => 'mla_uploads_per_page'
393
  );
394
+
395
  add_screen_option( $option, $args );
396
  } // upload
397
  } // isset mla_tab
398
  }
399
+
400
  /**
401
  * Add contextual help tabs to all the MLA pages
402
  *
407
  public static function mla_add_help_tab_action( )
408
  {
409
  $screen = get_current_screen();
410
+
411
  /*
412
  * Is this our page and the Views or Uploads tab?
413
  */
414
+ if ( ! in_array( $screen->id, array( 'settings_page_' . self::MLA_SETTINGS_SLUG . '-view', 'settings_page_' . self::MLA_SETTINGS_SLUG . '-upload' ) ) ) {
415
  return;
416
+ }
417
+
418
  $file_suffix = self::$current_page_hook;
419
+
420
  /*
421
  * Override the screen suffix if we are going to display something other than the attachment table
422
  */
423
  if ( isset( $_REQUEST['mla-optional-uploads-display'] ) || isset( $_REQUEST['mla-optional-uploads-search'] ) ) {
424
  $file_suffix .= '-optional';
425
+ } elseif ( isset( $_REQUEST['mla_admin_action'] ) ) {
 
426
  switch ( $_REQUEST['mla_admin_action'] ) {
427
  case MLA::MLA_ADMIN_SINGLE_EDIT_DISPLAY:
428
  $file_suffix .= '-edit';
429
  break;
430
  } // switch
431
  } // isset( $_REQUEST['mla_admin_action'] )
432
+
433
+ $template_array = MLAData::mla_load_template( 'help-for-' . $file_suffix . '.tpl' );
434
  if ( empty( $template_array ) ) {
435
  return;
436
  }
437
+
438
  if ( !empty( $template_array['sidebar'] ) ) {
439
  $page_values = array( 'settingsURL' => admin_url('options-general.php') );
440
  $content = MLAData::mla_parse_template( $template_array['sidebar'], $page_values );
441
  $screen->set_help_sidebar( $content );
442
  unset( $template_array['sidebar'] );
443
  }
444
+
445
  /*
446
  * Provide explicit control over tab order
447
  */
448
  $tab_array = array();
449
+
450
  foreach ( $template_array as $id => $content ) {
451
  $match_count = preg_match( '#\<!-- title="(.+)" order="(.+)" --\>#', $content, $matches, PREG_OFFSET_CAPTURE );
452
+
453
  if ( $match_count > 0 ) {
454
  $page_values = array( 'settingsURL' => admin_url('options-general.php') );
455
  $content = MLAData::mla_parse_template( $content, $page_values );
459
  'content' => $content
460
  );
461
  } else {
462
+ /* translators: 1: function name 2: template key */
463
+ error_log( sprintf( _x( 'ERROR: %1$s discarding "%2$s"; no title/order', 'error_log', 'media-library-assistant' ), 'mla_add_help_tab_action', $id ), 0 );
464
  }
465
  }
466
+
467
  ksort( $tab_array, SORT_NUMERIC );
468
  foreach ( $tab_array as $indx => $value ) {
469
  $screen->add_help_tab( $value );
470
  }
471
  }
472
+
473
  /**
474
  * Only show screen options on the View and Upload tabs
475
  *
482
  */
483
  public static function mla_screen_options_show_screen_filter( $show_screen, $this_screen ) {
484
  if ( self::$current_page_hook == $this_screen->base ) {
485
+ if ( isset( $_REQUEST['mla_tab'] ) && in_array( $_REQUEST['mla_tab'], array( 'view', 'upload' ) ) ) {
486
  return true;
487
+ }
488
  }
489
+
490
  return $show_screen;
491
  }
492
+
493
  /**
494
  * Save the "Views/Uploads per page" option set by this user
495
  *
502
  * @return string|void New value if this is our option, otherwise nothing
503
  */
504
  public static function mla_set_screen_option_filter( $status, $option, $value ) {
505
+ if ( 'mla_views_per_page' == $option || 'mla_uploads_per_page' == $option || 'mla_types_per_page' == $option ) {
506
  return $value;
507
+ } elseif ( $status ) {
508
  return $status;
509
+ }
510
  }
511
+
512
  /**
513
  * Ajax handler for Post MIME Types inline editing (quick and bulk edit)
514
  *
522
  set_current_screen( $_REQUEST['screen'] );
523
 
524
  check_ajax_referer( MLA::MLA_ADMIN_NONCE, 'nonce' );
525
+
526
  if ( empty( $_REQUEST['original_slug'] ) ) {
527
+ echo __( 'ERROR: No view slug found', 'media-library-assistant' );
528
  die();
529
  }
530
 
538
  $request['menu_order'] = $_REQUEST['menu_order'];
539
  $results = MLAMime::mla_update_post_mime_type( $request );
540
 
541
+ if ( false === strpos( $results['message'], __( 'ERROR:', 'media-library-assistant' ) ) ) {
542
  $new_item = (object) MLAMime::mla_get_post_mime_type( $_REQUEST['slug'] );
543
+ } else {
544
  $new_item = (object) MLAMime::mla_get_post_mime_type( $_REQUEST['original_slug'] );
545
+ }
546
+
547
  $new_item->post_ID = $_REQUEST['post_ID'];
548
 
549
  // Create an instance of our package class and echo the new HTML
551
  $MLAListViewTable->single_row( $new_item );
552
  die(); // this is required to return a proper result
553
  }
554
+
555
  /**
556
  * Ajax handler for Upload MIME Types inline editing (quick and bulk edit)
557
  *
565
  set_current_screen( $_REQUEST['screen'] );
566
 
567
  check_ajax_referer( MLA::MLA_ADMIN_NONCE, 'nonce' );
568
+
569
  if ( empty( $_REQUEST['original_slug'] ) ) {
570
+ echo __( 'ERROR: No upload slug found', 'media-library-assistant' );
571
  die();
572
  }
573
 
578
  $request['disabled'] = isset( $_REQUEST['disabled'] ) && ( '1' == $_REQUEST['disabled'] );
579
  $results = MLAMime::mla_update_upload_mime( $request );
580
 
581
+ if ( false === strpos( $results['message'], __( 'ERROR:', 'media-library-assistant' ) ) ) {
582
  $new_item = (object) MLAMime::mla_get_upload_mime( $_REQUEST['slug'] );
583
+ } else {
584
  $new_item = (object) MLAMime::mla_get_upload_mime( $_REQUEST['original_slug'] );
585
+ }
586
  $new_item->post_ID = $_REQUEST['post_ID'];
587
 
588
  // Create an instance of our package class and echo the new HTML
590
  $MLAListUploadTable->single_row( $new_item );
591
  die(); // this is required to return a proper result
592
  }
593
+
594
  /**
595
  * Add the "Settings" link to the MLA entry in the Plugins section
596
  *
603
  */
604
  public static function mla_add_plugin_settings_link_filter( $links, $file ) {
605
  if ( $file == 'media-library-assistant/index.php' ) {
606
+ $settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'options-general.php?page=' . self::MLA_SETTINGS_SLUG . '-general' ), __( 'Settings', 'media-library-assistant' ) );
607
  array_unshift( $links, $settings_link );
608
  }
609
+
610
  return $links;
611
  }
612
+
613
  /**
614
  * Update or delete a single MLA option value
615
  *
650
  case 'hidden':
651
  break;
652
  default:
653
+ /* translators: 1: function name 2: option type, e.g., radio, select, text */
654
+ error_log( sprintf( _x( 'ERROR: %1$s unknown type = "%2$s"', 'error_log', 'media-library-assistant' ), '_save_settings(1)', var_export( $value, true ) ), 0 );
655
  } // $value['type']
656
  } // isset $key
657
  else {
682
  case 'hidden':
683
  break;
684
  default:
685
+ /* translators: 1: function name 2: option type, e.g., radio, select, text */
686
+ error_log( sprintf( _x( 'ERROR: %1$s unknown type = "%2$s"', 'error_log', 'media-library-assistant' ), '_save_settings(2)', var_export( $value, true ) ), 0 );
687
  } // $value['type']
688
  } // ! isset $key
689
+
690
  return $message;
691
  }
692
+
693
  /**
694
  * Compose the table row for a single MLA option
695
  *
710
  'value' => $value['name'],
711
  'help' => $value['help']
712
  );
713
+
714
+ if ( 'checked' == MLAOptions::mla_get_option( $key ) ) {
715
  $option_values['checked'] = 'checked="checked"';
716
+ }
717
+
718
  return MLAData::mla_parse_template( self::$page_template_array['checkbox'], $option_values );
719
  case 'header':
720
  case 'subheader':
721
  $option_values = array(
722
+ 'Go to Top' => __( 'Go to Top', 'media-library-assistant' ),
723
  'key' => MLA_OPTION_PREFIX . $key,
724
  'value' => $value['name']
725
  );
726
+
727
  return MLAData::mla_parse_template( self::$page_template_array[ $value['type'] ], $option_values );
728
  case 'radio':
729
  $radio_options = '';
734
  'checked' => '',
735
  'value' => $value['texts'][$optid]
736
  );
737
+
738
+ if ( $option == MLAOptions::mla_get_option( $key ) ) {
739
  $option_values['checked'] = 'checked="checked"';
740
+ }
741
+
742
  $radio_options .= MLAData::mla_parse_template( self::$page_template_array['radio-option'], $option_values );
743
  }
744
+
745
  $option_values = array(
746
  'value' => $value['name'],
747
  'options' => $radio_options,
748
  'help' => $value['help']
749
  );
750
+
751
  return MLAData::mla_parse_template( self::$page_template_array['radio'], $option_values );
752
  case 'select':
753
  $select_options = '';
757
  'value' => $option,
758
  'text' => $value['texts'][$optid]
759
  );
760
+
761
+ if ( $option == MLAOptions::mla_get_option( $key ) ) {
762
  $option_values['selected'] = 'selected="selected"';
763
+ }
764
+
765
  $select_options .= MLAData::mla_parse_template( self::$page_template_array['select-option'], $option_values );
766
  }
767
+
768
  $option_values = array(
769
  'key' => MLA_OPTION_PREFIX . $key,
770
  'value' => $value['name'],
771
  'options' => $select_options,
772
  'help' => $value['help']
773
  );
774
+
775
  return MLAData::mla_parse_template( self::$page_template_array['select'], $option_values );
776
  case 'text':
777
  $option_values = array(
781
  'size' => '40',
782
  'text' => ''
783
  );
784
+
785
+ if ( !empty( $value['size'] ) ) {
786
  $option_values['size'] = $value['size'];
787
+ }
788
+
789
  $option_values['text'] = MLAOptions::mla_get_option( $key );
790
+
791
  return MLAData::mla_parse_template( self::$page_template_array['text'], $option_values );
792
  case 'textarea':
793
  $option_values = array(
799
  'rows' => '5',
800
  'text' => ''
801
  );
802
+
803
+ if ( !empty( $value['cols'] ) ) {
804
  $option_values['cols'] = $value['cols'];
805
+ }
806
+
807
+ if ( !empty( $value['rows'] ) ) {
808
  $option_values['rows'] = $value['rows'];
809
+ }
810
+
811
  $option_values['text'] = stripslashes( MLAOptions::mla_get_option( $key ) );
812
+
813
  return MLAData::mla_parse_template( self::$page_template_array['textarea'], $option_values );
814
  case 'custom':
815
+ if ( isset( $value['render'] ) ) {
816
  return MLAOptions::$value['render']( 'render', $key, $value );
817
+ }
818
 
819
  break;
820
  case 'hidden':
821
  break;
822
  default:
823
+ /* translators: 1: function name 2: option type, e.g., radio, select, text */
824
+ error_log( sprintf( _x( 'ERROR: %1$s unknown type = "%2$s"', 'error_log', 'media-library-assistant' ), 'mla_render_settings_page', var_export( $value, true ) ), 0 );
825
  } //switch
826
+
827
  return '';
828
  }
829
+
830
  /**
831
  * Template file for the Settings page(s) and parts
832
  *
843
  * Definitions for Settings page tab ids, titles and handlers
844
  * Each tab is defined by an array with the following elements:
845
  *
846
+ * The array must be populated at runtime in MLASettings::mla_localize_tablist(),
847
+ * because Localization calls cannot be placed in the "public static" array definition itself.
848
+ *
849
  * array key => HTML id/name attribute and option database key (OMIT MLA_OPTION_PREFIX)
850
  *
851
  * title => tab label / heading text
856
  *
857
  * @var array
858
  */
859
+ private static $mla_tablist = array();
860
+
861
+ /**
862
+ * Localize $mla_option_definitions array
863
+ *
864
+ * Localization must be done at runtime, and these calls cannot be placed
865
+ * in the "public static" array definition itself.
866
+ *
867
+ * @since 1.6x
868
+ *
869
+ * @return void
870
+ */
871
+ public static function mla_localize_tablist() {
872
+ self::$mla_tablist = array(
873
+ 'general' => array( 'title' => __ ( 'General', 'media-library-assistant' ), 'render' => '_compose_general_tab' ),
874
+ 'view' => array( 'title' => __ ( 'Views', 'media-library-assistant' ), 'render' => '_compose_view_tab' ),
875
+ 'upload' => array( 'title' => __ ( 'Uploads', 'media-library-assistant' ), 'render' => '_compose_upload_tab' ),
876
+ 'mla_gallery' => array( 'title' => __ ( 'MLA Gallery', 'media-library-assistant' ), 'render' => '_compose_mla_gallery_tab' ),
877
+ 'custom_field' => array( 'title' => __ ( 'Custom Fields', 'media-library-assistant' ), 'render' => '_compose_custom_field_tab' ),
878
+ 'iptc_exif' => array( 'title' => 'IPTC/EXIF', 'render' => '_compose_iptc_exif_tab' ),
879
+ 'documentation' => array( 'title' => __ ( 'Documentation', 'media-library-assistant' ), 'render' => '_compose_documentation_tab' )
880
+ );
881
+ }
882
 
883
  /**
884
  * Compose the navigation tabs for the Settings subpage
900
  'settings-page' => self::MLA_SETTINGS_SLUG . '-' . $key,
901
  'title' => $item['title']
902
  );
903
+
904
  $tabs .= MLAData::mla_parse_template( $tablist_item, $item_values );
905
  } // foreach $item
906
+
907
  $tablist_values = array( 'tablist' => $tabs );
908
  return MLAData::mla_parse_template( self::$page_template_array['tablist'], $tablist_values );
909
  }
910
+
911
  /**
912
  * Compose the General tab content for the Settings subpage
913
  *
939
  'body' => ''
940
  );
941
  }
942
+
943
  if ( !empty( $page_content['body'] ) ) {
944
  return $page_content;
945
  }
946
+
947
  $page_values = array(
948
+ 'General Processing Options' => __( 'General Processing Options', 'media-library-assistant' ),
949
+ /* translators: 1: - 4: page subheader values */
950
+ 'In this tab' => sprintf( __( 'In this tab you can find a number of options for controlling the plugin&rsquo;s operation. Scroll down to find options for %1$s, %2$s, %3$s and %4$s. Be sure to click "Save Changes" at the bottom of the tab to save any changes you make.', 'media-library-assistant' ), '<strong>' . __( 'Where-used Reporting', 'media-library-assistant' ) . '</strong>', '<strong>' . __( 'Taxonomy Support', 'media-library-assistant' ) . '</strong>', '<strong>' . __( 'Media/Assistant Table Defaults', 'media-library-assistant' ) . '</strong>', '<strong>' . __( 'Media Manager Enhancements', 'media-library-assistant' ) . '</strong>' ),
951
+ 'Save Changes' => __( 'Save Changes', 'media-library-assistant' ),
952
+ 'Export ALL Settings' => __( 'Export ALL Settings', 'media-library-assistant' ),
953
+ 'Delete General options' => __( 'Delete General options and restore default settings', 'media-library-assistant' ),
954
+ '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
955
+ '_wp_http_referer' => wp_referer_field( false ),
956
+ 'Go to Top' => __( 'Go to Top', 'media-library-assistant' ),
957
+ 'Support Our Work' => __( 'Support Our Work', 'media-library-assistant' ),
958
+ 'Donate to FTJ' => __( 'Donate to FTJ', 'media-library-assistant' ),
959
+ 'Donate' => __( 'Donate', 'media-library-assistant' ),
960
+ /* translators: 1: donation hyperlink */
961
+ 'This plugin was' => sprintf( __( 'This plugin was inspired by my work on the WordPress web site for our nonprofit, Fair Trade Judaica. If you find the Media Library Assistant plugin useful and would like to support a great cause, consider a %1$s to our work. Thank you!', 'media-library-assistant' ), '<a href="http://fairtradejudaica.org/make-a-difference/donate/" title="' . __( 'Donate to FTJ', 'media-library-assistant' ) . '" target="_blank" style="font-weight:bold">' . __( 'tax-deductible donation', 'media-library-assistant' ) . '</a>' ),
962
  'shortcode_list' => '',
963
+ 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-general&mla_tab=general',
964
  'options_list' => '',
965
+ 'import_settings' => '',
966
  'donateURL' => MLA_PLUGIN_URL . 'images/DonateButton.jpg',
 
 
 
967
  );
968
+
969
  /*
970
  * $custom_fields documents the name and description of custom fields
971
  */
972
  $custom_fields = array(
973
  // array("name" => "field_name", "description" => "field description.")
974
  );
975
+
976
  /*
977
  * $shortcodes documents the name and description of plugin shortcodes
978
  */
979
  $shortcodes = array(
980
  // array("name" => "shortcode", "description" => "This shortcode...")
981
+ array( 'name' => 'mla_attachment_list', 'description' => __( 'renders a complete list of all attachments and references to them.', 'media-library-assistant' ) ),
982
+ array( 'name' => 'mla_gallery', 'description' => __( 'enhanced version of the WordPress [gallery] shortcode.', 'media-library-assistant' ) . sprintf( ' %1$s <a href="%2$s">%3$s</a>.', __( 'For complete documentation', 'media-library-assistant' ), admin_url( 'options-general.php?page=' . self::MLA_SETTINGS_SLUG . '-documentation&amp;mla_tab=documentation' ), __( 'click here', 'media-library-assistant' ) ) ),
983
+ array( 'name' => 'mla_tag_cloud', 'description' => __( 'enhanced version of the WordPress Tag Cloud.', 'media-library-assistant' ) . sprintf( ' %1$s <a href="%2$s">%3$s</a>.', __( 'For complete documentation', 'media-library-assistant' ), admin_url( 'options-general.php?page=' . self::MLA_SETTINGS_SLUG . '-documentation&amp;mla_tab=documentation' ), __( 'click here', 'media-library-assistant' ) ) )
984
  );
985
+
986
  $shortcode_list = '';
987
  foreach ( $shortcodes as $shortcode ) {
988
  $shortcode_values = array ( 'name' => $shortcode['name'], 'description' => $shortcode['description'] );
989
  $shortcode_list .= MLAData::mla_parse_template( self::$page_template_array['shortcode-item'], $shortcode_values );
990
  }
991
+
992
  if ( ! empty( $shortcode_list ) ) {
993
+ $shortcode_values = array (
994
+ 'shortcode_list' => $shortcode_list,
995
+ 'Shortcodes made available' => __( 'Shortcodes made available by this plugin', 'media-library-assistant' )
996
+ );
997
  $page_values['shortcode_list'] = MLAData::mla_parse_template( self::$page_template_array['shortcode-list'], $shortcode_values );
998
  }
999
+
1000
  /*
1001
  * Fill in the current list of Media/Assistant table sortable columns, sorted by their labels.
1002
  * Make sure the current choice still exists or revert to default.
1007
  $columns[ $value[1] ] = $value[0];
1008
  }
1009
  }
1010
+
1011
  uksort( $columns, 'strnatcasecmp' );
1012
  $options = array_merge( array('None' => 'none'), $columns );
1013
  $current = MLAOptions::mla_get_option( MLAOptions::MLA_DEFAULT_ORDERBY );
1017
  foreach ($options as $key => $value ) {
1018
  MLAOptions::$mla_option_definitions[MLAOptions::MLA_DEFAULT_ORDERBY]['options'][] = $value;
1019
  MLAOptions::$mla_option_definitions[MLAOptions::MLA_DEFAULT_ORDERBY]['texts'][] = $key;
1020
+ if ( $current == $value ) {
1021
  $found_current = true;
1022
+ }
1023
  }
1024
 
1025
  if ( ! $found_current ) {
1029
  /*
1030
  * Validate the Media Manager sort order or revert to default
1031
  */
1032
+ $options = array_merge( array('&mdash; ' . __( 'Media Manager Default', 'media-library-assistant' ) . ' &mdash;' => 'default', 'None' => 'none'), $columns );
1033
  $current = MLAOptions::mla_get_option( MLAOptions::MLA_MEDIA_MODAL_ORDERBY );
1034
  MLAOptions::$mla_option_definitions[MLAOptions::MLA_MEDIA_MODAL_ORDERBY]['options'] = array();
1035
  MLAOptions::$mla_option_definitions[MLAOptions::MLA_MEDIA_MODAL_ORDERBY]['texts'] = array();
1037
  foreach ($options as $key => $value ) {
1038
  MLAOptions::$mla_option_definitions[MLAOptions::MLA_MEDIA_MODAL_ORDERBY]['options'][] = $value;
1039
  MLAOptions::$mla_option_definitions[MLAOptions::MLA_MEDIA_MODAL_ORDERBY]['texts'][] = $key;
1040
+ if ( $current == $value ) {
1041
  $found_current = true;
1042
+ }
1043
  }
1044
 
1045
  if ( ! $found_current ) {
1048
 
1049
  $options_list = '';
1050
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
1051
+ if ( 'general' == $value['tab'] ) {
1052
  $options_list .= self::_compose_option_row( $key, $value );
1053
+ }
1054
  }
1055
+
1056
  $page_values['options_list'] = $options_list;
1057
  $page_values['import_settings'] = self::_compose_import_settings();
1058
  $page_content['body'] = MLAData::mla_parse_template( self::$page_template_array['general-tab'], $page_values );
1059
  return $page_content;
1060
  }
1061
+
1062
  /**
1063
  * Get the current action selected from the bulk actions dropdown
1064
  *
1068
  */
1069
  private static function _current_bulk_action( ) {
1070
  $action = false;
1071
+
1072
  if ( isset( $_REQUEST['action'] ) ) {
1073
+ if ( -1 != $_REQUEST['action'] ) {
1074
  return $_REQUEST['action'];
1075
+ }
1076
+
1077
+ $action = 'none';
1078
  } // isset action
1079
+
1080
  if ( isset( $_REQUEST['action2'] ) ) {
1081
+ if ( -1 != $_REQUEST['action2'] ) {
1082
  return $_REQUEST['action2'];
1083
+ }
1084
+
1085
+ $action = 'none';
1086
  } // isset action2
1087
+
1088
  return $action;
1089
  }
1090
+
1091
  /**
1092
  * Compose the Edit View tab content for the Settings subpage
1093
  *
1100
  */
1101
  private static function _compose_edit_view_tab( $view, $template ) {
1102
  $page_values = array(
1103
+ // 'settingsURL' => admin_url('options-general.php'),
1104
+ 'Edit View' => __( 'Edit View', 'media-library-assistant' ),
1105
  'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-view&mla_tab=view',
1106
+ 'action' => MLA::MLA_ADMIN_SINGLE_EDIT_UPDATE,
1107
+ 'original_slug' => $view['slug'],
1108
  '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1109
+ 'Slug' => __( 'Slug', 'media-library-assistant' ),
1110
+ 'The slug is' => __( 'The &#8220;slug&#8221; is the URL-friendly, unique key for the view. It must be all lowercase and contain only letters, numbers, periods (.), slashes (/) and hyphens (-). For &#8220;<strong>Post MIME Type</strong>&#8221; views, the slug is also the MIME type specification and <strong>must be a valid MIME</strong> type, e.g., &#8220;image&#8221; or &#8220;image/jpeg&#8221;.', 'media-library-assistant' ),
1111
+ 'Singular Label' => __( 'Singular Label', 'media-library-assistant' ),
1112
+ 'Plural Label' => __( 'Plural Label', 'media-library-assistant' ),
1113
+ 'The labels' => __( 'The labels, e.g., &#8220;Image&#8221; and &#8220;Images&#8221; are used for column headers and other display purposes.', 'media-library-assistant' ),
1114
+ 'Specification' => __( 'Specification', 'media-library-assistant' ),
1115
+ 'If the specification' => __( 'If the MIME type specification differs from the slug, enter it here. You may include multiple MIME types, e.g., &#8220;audio,video&#8221; and/or wildcard specs, e.g., &#8220;*/*ms*&#8221;. This field will be ignored if the Post MIME Type box is checked.', 'media-library-assistant' ),
1116
+ 'Post MIME Type' => __( 'Post MIME Type', 'media-library-assistant' ),
1117
+ 'Check Post MIME' => __( 'Check this box if you want to add this entry to the list of MIME types returned by wp_get_mime_types().', 'media-library-assistant' ),
1118
+ 'Table View' => __( 'Table View', 'media-library-assistant' ),
1119
+ 'Check Table View' => __( 'Check this box if you want to add this entry to the list of Media/Assistant table views.', 'media-library-assistant' ),
1120
+ 'Menu Order' => __( 'Menu Order', 'media-library-assistant' ),
1121
+ 'You can choose' => __( 'You can choose your own table view order by entering a number (1 for first, etc.) in this field.', 'media-library-assistant' ),
1122
+ 'Description' => __( 'Description', 'media-library-assistant' ),
1123
+ 'The description can' => __( 'The description can contain any documentation or notes you need to understand or use the item.', 'media-library-assistant' ),
1124
+ 'Update' => __( 'Update', 'media-library-assistant' ),
1125
+ 'Cancel' => __( 'Cancel', 'media-library-assistant' ),
1126
  );
1127
+
1128
  foreach ( $view as $key => $value ) {
1129
  switch ( $key ) {
1130
  case 'post_mime_type':
1141
  'body' => MLAData::mla_parse_template( $template, $page_values )
1142
  );
1143
  }
1144
+
1145
  /**
1146
  * Compose the Post MIME Type Views tab content for the Settings subpage
1147
  *
1150
  * @return array 'message' => status/error messages, 'body' => tab content
1151
  */
1152
  private static function _compose_view_tab( ) {
1153
+ $page_template_array = MLAData::mla_load_template( 'admin-display-settings-view-tab.tpl' );
1154
  if ( ! array( $page_template_array ) ) {
1155
+ /* translators: 1: function name 2: non-array value */
1156
+ error_log( sprintf( _x( 'ERROR: %1$s non-array "%2$s"', 'error_log', 'media-library-assistant' ), 'MLASettings::_compose_view_tab', var_export( $page_template_array, true ) ), 0 );
1157
  return '';
1158
  }
1159
+
1160
  /*
1161
  * Convert checkbox values, if present
1162
  */
1178
  'menu_order' => '',
1179
  'description' => ''
1180
  );
1181
+
1182
  if ( !empty( $_REQUEST['mla-view-options-save'] ) ) {
1183
  check_admin_referer( MLA::MLA_ADMIN_NONCE, '_wpnonce' );
1184
  $page_content = self::_save_view_settings( );
1185
+ } elseif ( !empty( $_REQUEST['mla-add-view-submit'] ) ) {
 
1186
  check_admin_referer( MLA::MLA_ADMIN_NONCE, '_wpnonce' );
1187
  $page_content = MLAMime::mla_add_post_mime_type( $_REQUEST['mla_view_item'] );
1188
+ if ( false !== strpos( $page_content['message'], __( 'ERROR:', 'media-library-assistant' ) ) ) {
1189
  $add_form_values = $_REQUEST['mla_view_item'];
1190
  $add_form_values['post_mime_type'] = $add_form_values['post_mime_type'] ? 'checked="checked"' : '';
1191
  $add_form_values['table_view'] = $add_form_values['table_view'] ? 'checked="checked"' : '';
1192
  }
1193
  } else {
1194
  $page_content = array(
1195
+ 'message' => '',
1196
  'body' => ''
1197
  );
1198
  }
1199
+
1200
  /*
1201
  * Process bulk actions that affect an array of items
1202
  */
1209
  $slugs = array();
1210
  foreach ( $_REQUEST['cb_mla_item_ID'] as $post_ID )
1211
  $slugs[] = MLAMime::mla_get_post_mime_type_slug( $post_ID );
1212
+
1213
  foreach ( $slugs as $slug ) {
1214
  switch ( $bulk_action ) {
1215
  case 'delete':
1217
  break;
1218
  case 'edit':
1219
  $request = array( 'slug' => $slug );
1220
+ if ( '-1' != $_REQUEST['post_mime_type'] ) {
1221
  $request['post_mime_type'] = '1' == $_REQUEST['post_mime_type'];
1222
+ }
1223
+ if ( '-1' != $_REQUEST['table_view'] ) {
1224
  $request['table_view'] = '1' == $_REQUEST['table_view'];
1225
+ }
1226
+ if ( !empty( $_REQUEST['menu_order'] ) ) {
1227
  $request['menu_order'] = $_REQUEST['menu_order'];
1228
+ }
1229
  $item_content = MLAMime::mla_update_post_mime_type( $request );
1230
  break;
1231
  default:
1232
  $item_content = array(
1233
+ /* translators: 1: bulk_action, e.g., delete, edit, restore, trash */
1234
+ 'message' => sprintf( __( 'Unknown bulk action %1$s', 'media-library-assistant' ), $bulk_action ),
1235
  'body' => ''
1236
  );
1237
  } // switch $bulk_action
1238
+
1239
  $page_content['message'] .= $item_content['message'] . '<br>';
1240
  } // foreach cb_attachment
1241
  } // isset cb_attachment
1242
  else {
1243
+ /* translators: 1: action name, e.g., edit */
1244
+ $page_content['message'] = sprintf( __( 'Bulk Action %1$s - no items selected.', 'media-library-assistant' ), $bulk_action );
1245
  }
1246
  } // $bulk_action
1247
+
1248
  /*
1249
  * Process row-level actions that affect a single item
1250
  */
1251
  if ( !empty( $_REQUEST['mla_admin_action'] ) ) {
1252
  check_admin_referer( MLA::MLA_ADMIN_NONCE );
1253
+
1254
  switch ( $_REQUEST['mla_admin_action'] ) {
1255
  case MLA::MLA_ADMIN_SINGLE_DELETE:
1256
  $page_content = MLAMime::mla_delete_post_mime_type( $_REQUEST['mla_item_slug'] );
1262
  case MLA::MLA_ADMIN_SINGLE_EDIT_UPDATE:
1263
  if ( !empty( $_REQUEST['update'] ) ) {
1264
  $page_content = MLAMime::mla_update_post_mime_type( $_REQUEST['mla_view_item'] );
1265
+ if ( false !== strpos( $page_content['message'], __( 'ERROR:', 'media-library-assistant' ) ) ) {
1266
  $message = $page_content['message'];
1267
  $page_content = self::_compose_edit_view_tab( $_REQUEST['mla_view_item'], $page_template_array['single-item-edit'] );
1268
  $page_content['message'] = $message;
1269
  }
1270
  } else {
1271
  $page_content = array(
1272
+ /* translators: 1: view name/slug */
1273
+ 'message' => sprintf( __( 'Edit view "%1$s" cancelled.', 'media-library-assistant' ), $_REQUEST['mla_view_item']['original_slug'] ),
1274
  'body' => ''
1275
  );
1276
  }
1277
  break;
1278
  default:
1279
  $page_content = array(
1280
+ /* translators: 1: bulk_action, e.g., single_item_delete, single_item_edit */
1281
+ 'message' => sprintf( __( 'Unknown mla_admin_action - "%1$s"', 'media-library-assistant' ), $_REQUEST['mla_admin_action'] ),
1282
  'body' => ''
1283
  );
1284
  break;
1288
  if ( !empty( $page_content['body'] ) ) {
1289
  return $page_content;
1290
  }
1291
+
1292
  /*
1293
  * Check for disabled status
1294
  */
1298
  */
1299
  $options_list = '';
1300
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
1301
+ if ( 'view' == $value['tab'] ) {
1302
  $options_list .= self::_compose_option_row( $key, $value );
1303
+ }
1304
  }
1305
+
1306
  $page_values = array(
1307
+ // 'settingsURL' => admin_url('options-general.php'),
1308
+ 'Support is disabled' => __( 'View and Post MIME Type Support is disabled', 'media-library-assistant' ),
1309
+ 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-view&mla_tab=view',
1310
  'options_list' => $options_list,
1311
+ 'Save Changes' => __( 'Save Changes', 'media-library-assistant' ),
1312
  '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
 
1313
  );
1314
+
1315
  $page_content['body'] .= MLAData::mla_parse_template( $page_template_array['view-disabled'], $page_values );
1316
  return $page_content;
1317
  }
1331
  'mla-optional-uploads-search',
1332
  'mla-optional-uploads-display'
1333
  ), $_SERVER['REQUEST_URI'] );
1334
+
1335
  // Create an instance of our package class
1336
  $MLAListViewTable = new MLA_View_List_Table();
1337
+
1338
  // Fetch, prepare, sort, and filter our data
1339
  $MLAListViewTable->prepare_items();
1340
  $MLAListViewTable->views();
1341
+
1342
  /*
1343
  * Start with any page-level options
1344
  */
1345
  $options_list = '';
1346
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
1347
+ if ( 'view' == $value['tab'] ) {
1348
  $options_list .= self::_compose_option_row( $key, $value );
1349
+ }
1350
  }
1351
+
1352
  $page_values = array(
1353
+ 'Library Views Processing' => __( 'Library Views/Post MIME Type Processing', 'media-library-assistant' ),
1354
+ 'In this tab' => __( 'In this tab you can manage the list of "Post MIME Types", which are used by WordPress to define the views for the <em><strong>Media/Library</strong></em> screen and the <em><strong>Media Manager/Add Media</strong></em> "media items" drop down list. MLA&rsquo;s <em><strong>Media/Assistant</strong></em> screen uses an enhanced version of the list, <em>Table Views</em>, to support views with multiple MIME Types (e.g., "audio,video") and wildcard specifications (e.g. "*/*ms*").', 'media-library-assistant' ),
1355
+ /* translators: 1: Documentation hyperlink */
1356
+ 'You can find' => sprintf( __( 'You can find more information about library views, Post MIME types and how MLA and WordPress use them in the %1$s section of the Documentation or by clicking the <strong>"Help"</strong> tab in the upper-right corner of this screen.', 'media-library-assistant' ), '<a href="[+settingsURL+]?page=mla-settings-menu-documentation&amp;mla_tab=documentation#mla_views" title="' . __( 'Library View Processing documentation', 'media-library-assistant' ) . '">' . __( 'Library Views/Post MIME Type Processing', 'media-library-assistant' ) . '</a>' ),
1357
  'settingsURL' => admin_url('options-general.php'),
1358
+ 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-view&mla_tab=view',
1359
+ '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1360
+ 'results' => ! empty( $_REQUEST['s'] ) ? '<h3 style="float:left">' . __( 'Displaying search results for', 'media-library-assistant' ) . ': "' . $_REQUEST['s'] . '"</h3>' : '',
1361
+ 'Search Views' => __( 'Search Views', 'media-library-assistant' ),
1362
+ 's' => isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '',
1363
  'options_list' => $options_list,
1364
+ 'Save Changes' => __( 'Save Changes', 'media-library-assistant' ),
1365
+ 'Add New View' => __( 'Add New View', 'media-library-assistant' ),
1366
+ 'Slug' => __( 'Slug', 'media-library-assistant' ),
1367
+ 'The slug is' => __( 'The &#8220;slug&#8221; is the URL-friendly, unique key for the view. It must be all lowercase and contain only letters, numbers, periods (.), slashes (/) and hyphens (-). For &#8220;<strong>Post MIME Type</strong>&#8221; views, the slug is also the MIME type specification and <strong>must be a valid MIME</strong> type, e.g., &#8220;image&#8221; or &#8220;image/jpeg&#8221;.', 'media-library-assistant' ),
1368
+ 'Singular Label' => __( 'Singular Label', 'media-library-assistant' ),
1369
+ 'Plural Label' => __( 'Plural Label', 'media-library-assistant' ),
1370
+ 'The labels' => __( 'The labels, e.g., &#8220;Image&#8221; and &#8220;Images&#8221; are used for column headers and other display purposes.', 'media-library-assistant' ),
1371
+ 'Specification' => __( 'Specification', 'media-library-assistant' ),
1372
+ 'If the specification' => __( 'If the MIME type specification differs from the slug, enter it here. You may include multiple MIME types, e.g., &#8220;audio,video&#8221; and/or wildcard specs, e.g., &#8220;*/*ms*&#8221;. This field will be ignored if the Post MIME Type box is checked.', 'media-library-assistant' ),
1373
+ 'Post MIME Type' => __( 'Post MIME Type', 'media-library-assistant' ),
1374
+ 'Check Post MIME' => __( 'Check this box if you want to add this entry to the list of MIME types returned by wp_get_mime_types().', 'media-library-assistant' ),
1375
+ 'Table View' => __( 'Table View', 'media-library-assistant' ),
1376
+ 'Check Table View' => __( 'Check this box if you want to add this entry to the list of Media/Assistant table views.', 'media-library-assistant' ),
1377
+ 'Menu Order' => __( 'Menu Order', 'media-library-assistant' ),
1378
+ 'You can choose' => __( 'You can choose your own table view order by entering a number (1 for first, etc.) in this field.', 'media-library-assistant' ),
1379
+ 'Description' => __( 'Description', 'media-library-assistant' ),
1380
+ 'The description can' => __( 'The description can contain any documentation or notes you need to understand or use the item.', 'media-library-assistant' ),
1381
+ 'Add View' => __( 'Add View', 'media-library-assistant' ),
1382
  'colspan' => count( $MLAListViewTable->get_columns() ),
1383
+ 'Quick Edit' => __( '<strong>Quick Edit</strong>', 'media-library-assistant' ),
1384
+ 'Cancel' => __( 'Cancel', 'media-library-assistant' ),
1385
+ 'Update' => __( 'Update', 'media-library-assistant' ),
1386
+ 'Bulk Edit' => __( 'Bulk Edit', 'media-library-assistant' ),
1387
+ 'No Change' => __( 'No Change', 'media-library-assistant' ),
1388
+ 'No' => __( 'No', 'media-library-assistant' ),
1389
+ 'Yes' => __( 'Yes', 'media-library-assistant' ),
1390
  );
1391
+
1392
  foreach ( $add_form_values as $key => $value ) {
1393
  $page_values[ $key ] = $value;
1394
  }
1395
  $page_content['body'] = MLAData::mla_parse_template( $page_template_array['before-table'], $page_values );
1396
+
1397
  // Now we can render the completed list table
1398
  ob_start();
1399
  $MLAListViewTable->display();
1400
  $page_content['body'] .= ob_get_contents();
1401
  ob_end_clean();
1402
+
1403
  $page_content['body'] .= MLAData::mla_parse_template( $page_template_array['after-table'], $page_values );
1404
 
1405
  return $page_content;
1406
  }
1407
+
1408
  /**
1409
  * Get an HTML select element representing a list of icon types
1410
  *
1418
  */
1419
  public static function mla_get_icon_type_dropdown( $templates, $name, $selection = '.none.' ) {
1420
  $option_template = $templates['icon-type-select-option'];
1421
+ if ( '.nochange.' == $selection ) {
1422
  $option_values = array (
1423
  'selected' => 'selected="selected"',
1424
  'value' => '.none.',
1425
+ 'text' => '&mdash; ' . __( 'No Change', 'media-library-assistant' ) . ' &mdash;'
1426
  );
1427
+ } else {
1428
  $option_values = array (
1429
  'selected' => ( '.none.' == $selection ) ? 'selected="selected"' : '',
1430
  'value' => '.none.',
1431
+ 'text' => '&mdash; ' . __( 'None (select a value)', 'media-library-assistant' ) . ' &mdash;'
1432
  );
1433
+ }
1434
+
1435
  $options = MLAData::mla_parse_template( $option_template, $option_values );
1436
+
1437
  $icon_types = MLAMime::mla_get_current_icon_types();
1438
  foreach ( $icon_types as $icon_type ) {
1439
  $option_values = array (
1441
  'value' => $icon_type,
1442
  'text' => $icon_type
1443
  );
1444
+
1445
  $options .= MLAData::mla_parse_template( $option_template, $option_values );
1446
  } // foreach icon_type
1447
+
1448
  return MLAData::mla_parse_template( $templates['icon-type-select'], array( 'name' => $name, 'options' => $options ) );
1449
  }
1450
 
1460
  */
1461
  private static function _compose_edit_upload_tab( $item, &$templates ) {
1462
  $page_values = array(
1463
+ // 'settingsURL' => admin_url('options-general.php'),
1464
+ 'Edit Upload MIME' => __( 'Edit Upload MIME Type', 'media-library-assistant' ),
1465
  'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-upload&mla_tab=upload',
1466
+ 'action' => MLA::MLA_ADMIN_SINGLE_EDIT_UPDATE,
1467
  'original_slug' => $item['slug'],
1468
+ '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1469
+ 'Extension' => __( 'Extension', 'media-library-assistant' ),
1470
+ 'The extension is' => __( 'The &#8220;extension&#8221; is the file extension for this type, and a unique key for the item. It must be all lowercase and contain only letters and numbers.', 'media-library-assistant' ),
1471
+ 'MIME Type' => __( 'MIME Type', 'media-library-assistant' ),
1472
+ 'The MIME Type' => __( 'The MIME Type must be all lowercase and contain only letters, numbers, periods (.), slashes (/) and hyphens (-). It <strong>must be a valid MIME</strong> type, e.g., &#8220;image&#8221; or &#8220;image/jpeg&#8221;.', 'media-library-assistant' ),
1473
+ 'Icon Type' => __( 'Icon Type', 'media-library-assistant' ),
1474
+ 'icon_types' => self::mla_get_icon_type_dropdown( $templates, 'mla_upload_item[icon_type]', $item['icon_type'] ),
1475
+ 'The Icon Type' => __( 'The Icon Type selects a thumbnail image displayed for non-image file types, such as PDF documents.', 'media-library-assistant' ),
1476
+ 'Inactive' => __( 'Inactive', 'media-library-assistant' ),
1477
+ 'Check this box' => __( 'Check this box if you want to remove this entry from the list of Upload MIME Types returned by get_allowed_mime_types().', 'media-library-assistant' ),
1478
+ 'Description' => __( 'Description', 'media-library-assistant' ),
1479
+ 'The description can' => __( 'The description can contain any documentation or notes you need to understand or use the item.', 'media-library-assistant' ),
1480
+ 'Update' => __( 'Update', 'media-library-assistant' ),
1481
+ 'Cancel' => __( 'Cancel', 'media-library-assistant' ),
1482
  );
1483
+
1484
  foreach ( $item as $key => $value ) {
1485
  switch ( $key ) {
1486
  case 'disabled':
1496
  'body' => MLAData::mla_parse_template( $templates['single-item-edit'], $page_values )
1497
  );
1498
  }
1499
+
1500
  /**
1501
  * Compose the Optional File Upload MIME Types tab content for the Settings subpage
1502
  *
1521
  'cb_attachment',
1522
  'mla-optional-uploads-search'
1523
  ), $_SERVER['REQUEST_URI'] ) );
1524
+
1525
  /*
1526
  * Suppress display of the hidden columns selection list
1527
  */
1533
 
1534
  // Create an instance of our package class
1535
  $MLAListUploadTable = new MLA_Upload_Optional_List_Table();
1536
+
1537
  // Fetch, prepare, sort, and filter our data
1538
  $MLAListUploadTable->prepare_items();
1539
 
1541
  'message' => '',
1542
  'body' => ''
1543
  );
1544
+
1545
  $page_values = array(
 
1546
  'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-upload&mla_tab=upload',
1547
+ '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1548
+ 'Known File Extension' => __( 'Known File Extension/MIME Type Associations', 'media-library-assistant' ),
1549
+ 'results' => ! empty( $_REQUEST['s'] ) ? '<br>&nbsp;<br>' . __( 'Displaying search results for', 'media-library-assistant' ) . ': "' . $_REQUEST['s'] . '"' : '',
1550
+ 'Search Known MIME' => __( 'Search Known MIME Types', 'media-library-assistant' ),
1551
+ 's' => isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '',
1552
+ 'To search by' => __( 'To search by extension, use ".", e.g., ".doc"', 'media-library-assistant' ),
1553
+ 'Cancel' => __( 'Cancel', 'media-library-assistant' ),
1554
  );
1555
 
1556
  $page_content['body'] = MLAData::mla_parse_template( $page_template_array['before-optional-uploads-table'], $page_values );
1557
+
1558
  // Now we can render the completed list table
1559
  ob_start();
1560
  // $MLAListUploadTable->views();
1561
  $MLAListUploadTable->display();
1562
  $page_content['body'] .= ob_get_contents();
1563
  ob_end_clean();
1564
+
1565
  $page_content['body'] .= MLAData::mla_parse_template( $page_template_array['after-optional-uploads-table'], $page_values );
1566
 
1567
  return $page_content;
1568
  }
1569
+
1570
  /**
1571
  * Process an Optional Upload MIME Type selection
1572
  *
1588
  $optional_type['original_slug'] = $optional_type['slug'];
1589
  return MLAMime::mla_update_upload_mime( $optional_type );
1590
  }
1591
+
1592
  /**
1593
  * Compose the File Upload MIME Types tab content for the Settings subpage
1594
  *
1597
  * @return array 'message' => status/error messages, 'body' => tab content
1598
  */
1599
  private static function _compose_upload_tab( ) {
1600
+ $page_template_array = MLAData::mla_load_template( 'admin-display-settings-upload-tab.tpl' );
1601
  if ( ! array( $page_template_array ) ) {
1602
+ /* translators: 1: function name 2: non-array value */
1603
+ error_log( sprintf( _x( 'ERROR: %1$s non-array "%2$s"', 'error_log', 'media-library-assistant' ), 'MLASettings::_compose_upload_tab', var_export( $page_template_array, true ) ), 0 );
1604
  return '';
1605
  }
1606
+
1607
  /*
1608
  * Untangle confusion between searching, canceling and selecting on the Optional Uploads screen
1609
  */
1612
  unset( $_REQUEST['mla-optional-uploads-search'] );
1613
  unset( $_REQUEST['s'] );
1614
  }
1615
+
1616
  /*
1617
  * Convert checkbox values, if present
1618
  */
1621
  }
1622
 
1623
  /*
1624
+ * Set default values, check for Add New Upload MIME Type button
1625
  */
1626
  $add_form_values = array (
1627
  'slug' => '',
1630
  'disabled' => '',
1631
  'description' => ''
1632
  );
1633
+
1634
  if ( !empty( $_REQUEST['mla-upload-options-save'] ) ) {
1635
  check_admin_referer( MLA::MLA_ADMIN_NONCE, '_wpnonce' );
1636
  $page_content = self::_save_upload_settings( );
1637
+ } elseif ( !empty( $_REQUEST['mla-optional-uploads-search'] ) ) {
 
1638
  check_admin_referer( MLA::MLA_ADMIN_NONCE, '_wpnonce' );
1639
  $page_content = self::_compose_optional_upload_tab( $page_template_array );
1640
+ } elseif ( !empty( $_REQUEST['mla-optional-uploads-cancel'] ) ) {
 
1641
  $page_content = array(
1642
  'message' => '',
1643
  'body' => ''
1644
  );
1645
+ } elseif ( !empty( $_REQUEST['mla-optional-uploads-display'] ) ) {
 
1646
  if ( 'true' != $_REQUEST['mla-optional-uploads-display'] ) {
1647
  check_admin_referer( MLA::MLA_ADMIN_NONCE, '_wpnonce' );
1648
  unset( $_REQUEST['s'] );
1649
  }
1650
  $page_content = self::_compose_optional_upload_tab( $page_template_array );
1651
+ } elseif ( !empty( $_REQUEST['mla-add-upload-submit'] ) ) {
 
1652
  check_admin_referer( MLA::MLA_ADMIN_NONCE, '_wpnonce' );
1653
  $page_content = MLAMime::mla_add_upload_mime( $_REQUEST['mla_upload_item'] );
1654
+ if ( false !== strpos( $page_content['message'], __( 'ERROR:', 'media-library-assistant' ) ) ) {
1655
  $add_form_values = $_REQUEST['mla_upload_item'];
1656
  $add_form_values['disabled'] = $add_form_values['disabled'] ? 'checked="checked"' : '';
1657
  }
1661
  'body' => ''
1662
  );
1663
  }
1664
+
1665
  /*
1666
  * Process bulk actions that affect an array of items
1667
  */
1672
  $item_content = MLASettings::_process_optional_upload_mime( $ID );
1673
  $page_content['message'] .= $item_content['message'] . '<br>';
1674
  }
1675
+ } else {
 
1676
  /*
1677
  * Convert post-ID to slug; separate loop required because delete changes post_IDs
1678
  */
1679
  $slugs = array();
1680
  foreach ( $_REQUEST['cb_mla_item_ID'] as $post_ID )
1681
  $slugs[] = MLAMime::mla_get_upload_mime_slug( $post_ID );
1682
+
1683
  foreach ( $slugs as $slug ) {
1684
  switch ( $bulk_action ) {
1685
  case 'delete':
1687
  break;
1688
  case 'edit':
1689
  $request = array( 'slug' => $slug );
1690
+ if ( '-1' != $_REQUEST['disabled'] ) {
1691
  $request['disabled'] = '1' == $_REQUEST['disabled'];
1692
+ }
1693
+ if ( '.none.' != $_REQUEST['icon_type'] ) {
1694
  $request['icon_type'] = $_REQUEST['icon_type'];
1695
+ }
1696
  $item_content = MLAMime::mla_update_upload_mime( $request );
1697
  break;
1698
  default:
1699
  $item_content = array(
1700
+ /* translators: 1: bulk_action, e.g., delete, edit, restore, trash */
1701
+ 'message' => sprintf( __( 'Unknown bulk action %1$s', 'media-library-assistant' ), $bulk_action ),
1702
  'body' => ''
1703
  );
1704
  } // switch $bulk_action
1705
+
1706
  $page_content['message'] .= $item_content['message'] . '<br>';
1707
  } // foreach cb_attachment
1708
  } // != select
1709
  } // isset cb_attachment
1710
  else {
1711
+ /* translators: 1: action name, e.g., edit */
1712
+ $page_content['message'] = sprintf( __( 'Bulk Action %1$s - no items selected.', 'media-library-assistant' ), $bulk_action );
1713
  }
1714
  } // $bulk_action
1715
+
1716
  /*
1717
  * Process row-level actions that affect a single item
1718
  */
1719
  if ( !empty( $_REQUEST['mla_admin_action'] ) ) {
1720
  check_admin_referer( MLA::MLA_ADMIN_NONCE );
1721
+
1722
  switch ( $_REQUEST['mla_admin_action'] ) {
1723
  case MLA::MLA_ADMIN_SINGLE_DELETE:
1724
  $page_content = MLAMime::mla_delete_upload_mime( $_REQUEST['mla_item_slug'] );
1730
  case MLA::MLA_ADMIN_SINGLE_EDIT_UPDATE:
1731
  if ( !empty( $_REQUEST['update'] ) ) {
1732
  $page_content = MLAMime::mla_update_upload_mime( $_REQUEST['mla_upload_item'] );
1733
+ if ( false !== strpos( $page_content['message'], __( 'ERROR:', 'media-library-assistant' ) ) ) {
1734
  $message = $page_content['message'];
1735
  $page_content = self::_compose_edit_upload_tab( $_REQUEST['mla_upload_item'], $page_template_array );
1736
  $page_content['message'] = $message;
1737
  }
1738
+ } elseif ( !empty( $_REQUEST['mla_item_ID'] ) ) {
 
1739
  $page_content = self::_process_optional_upload_mime( $_REQUEST['mla_item_ID'] );
1740
  } else {
1741
  $page_content = array(
1742
+ /* translators: 1: view name/slug */
1743
+ 'message' => sprintf( __( 'Edit view "%1$s" cancelled.', 'media-library-assistant' ), $_REQUEST['mla_upload_item']['original_slug'] ),
1744
  'body' => ''
1745
  );
1746
  }
1747
  break;
1748
  default:
1749
  $page_content = array(
1750
+ /* translators: 1: bulk_action, e.g., single_item_delete, single_item_edit */
1751
+ 'message' => sprintf( __( 'Unknown mla_admin_action - "%1$s"', 'media-library-assistant' ), $_REQUEST['mla_admin_action'] ),
1752
  'body' => ''
1753
  );
1754
  break;
1758
  if ( !empty( $page_content['body'] ) ) {
1759
  return $page_content;
1760
  }
1761
+
1762
  /*
1763
  * Check for disabled status
1764
  */
1768
  */
1769
  $options_list = '';
1770
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
1771
+ if ( 'upload' == $value['tab'] ) {
1772
  $options_list .= self::_compose_option_row( $key, $value );
1773
+ }
1774
  }
1775
+
1776
  $page_values = array(
1777
+ // 'settingsURL' => admin_url('options-general.php'),
1778
+ 'Support is disabled' => __( 'Upload MIME Type Support is disabled', 'media-library-assistant' ),
1779
+ 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-upload&mla_tab=upload',
1780
  'options_list' => $options_list,
1781
+ 'Save Changes' => __( 'Save Changes', 'media-library-assistant' ),
1782
  '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
 
1783
  );
1784
+
1785
  $page_content['body'] .= MLAData::mla_parse_template( $page_template_array['upload-disabled'], $page_values );
1786
  return $page_content;
1787
  }
1800
  'cb_mla_item_ID',
1801
  'mla-optional-uploads-search',
1802
  ), $_SERVER['REQUEST_URI'] );
1803
+
1804
  // Create an instance of our package class
1805
  $MLAListUploadTable = new MLA_Upload_List_Table();
1806
+
1807
  // Fetch, prepare, sort, and filter our data
1808
  $MLAListUploadTable->prepare_items();
1809
+
1810
  /*
1811
  * Start with any page-level options
1812
  */
1813
  $options_list = '';
1814
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
1815
+ if ( 'upload' == $value['tab'] ) {
1816
  $options_list .= self::_compose_option_row( $key, $value );
1817
+ }
1818
  }
1819
+
1820
  $page_values = array(
1821
+ 'File Extension Processing' => __( 'File Extension and MIME Type Processing', 'media-library-assistant' ),
1822
+ 'In this tab' => __( 'In this tab you can manage the list of file extension/MIME Type associations, which are used by WordPress to decide what kind of files can be uploaded to the Media Library and to fill in the <strong><em>post_mime_type</em></strong> value. To upload a file, the file extension must be in this list and be active.', 'media-library-assistant' ),
1823
+ /* translators: 1: Documentation hyperlink */
1824
+ 'You can find' => sprintf( __( 'You can find more information about file extensions, MIME types and how WordPress uses them in the %1$s section of the Documentation or by clicking the <strong>"Help"</strong> tab in the upper-right corner of this screen.', 'media-library-assistant' ), '<a href="[+settingsURL+]?page=mla-settings-menu-documentation&amp;mla_tab=documentation#mla_uploads" title="' . __( 'File Extension Processing documentation', 'media-library-assistant' ) . '">' . __( 'File Extension and MIME Type Processing', 'media-library-assistant' ) . '</a>' ),
1825
  'settingsURL' => admin_url('options-general.php'),
1826
+ 'Search Uploads' => __( 'Search Uploads', 'media-library-assistant' ),
1827
+ 'To search by' => __( 'To search by extension, use ".", e.g., ".doc"', 'media-library-assistant' ),
1828
+ 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-upload&mla_tab=upload',
1829
+ '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1830
  'options_list' => $options_list,
1831
+ 'Save Changes' => __( 'Save Changes', 'media-library-assistant' ),
1832
+ 'Add New Upload' => __( 'Add New Upload MIME Type', 'media-library-assistant' ),
1833
+ 'To search database' => __( 'To search the database of over 1,500 known extension/type associations, click "Search Known Types" below the form.', 'media-library-assistant' ),
1834
+ 'Extension' => __( 'Extension', 'media-library-assistant' ),
1835
+ 'The extension is' => __( 'The &#8220;extension&#8221; is the file extension for this type, and unique key for the item. It must be all lowercase and contain only letters and numbers.', 'media-library-assistant' ),
1836
+ 'MIME Type' => __( 'MIME Type', 'media-library-assistant' ),
1837
+ 'The MIME Type' => __( 'The MIME Type must be all lowercase and contain only letters, numbers, periods (.), slashes (/) and hyphens (-). It <strong>must be a valid MIME</strong> type, e.g., &#8220;image&#8221; or &#8220;image/jpeg&#8221;.', 'media-library-assistant' ),
1838
+ 'Icon Type' => __( 'Icon Type', 'media-library-assistant' ),
1839
+ 'The Icon Type' => __( 'The Icon Type selects a thumbnail image displayed for non-image file types, such as PDF documents.', 'media-library-assistant' ),
1840
+ 'Inactive' => __( 'Inactive', 'media-library-assistant' ),
1841
+ 'Check this box' => __( 'Check this box if you want to remove this entry from the list of Upload MIME Types returned by get_allowed_mime_types().', 'media-library-assistant' ),
1842
+ 'Description' => __( 'Description', 'media-library-assistant' ),
1843
+ 'The description can' => __( 'The description can contain any documentation or notes you need to understand or use the item.', 'media-library-assistant' ),
1844
+ 'Add Upload MIME' => __( 'Add Upload MIME Type', 'media-library-assistant' ),
1845
+ 'search_url' => wp_nonce_url( '?page=mla-settings-menu-upload&mla_tab=upload&mla-optional-uploads-search=Search', MLA::MLA_ADMIN_NONCE ),
1846
+ 'Search Known Types' => __( 'Search Known Types', 'media-library-assistant' ),
1847
  'colspan' => count( $MLAListUploadTable->get_columns() ),
1848
+ 'Quick Edit' => __( '<strong>Quick Edit</strong>', 'media-library-assistant' ),
1849
+ 'Cancel' => __( 'Cancel', 'media-library-assistant' ),
1850
+ 'Update' => __( 'Update', 'media-library-assistant' ),
1851
+ 'Bulk Edit' => __( 'Bulk Edit', 'media-library-assistant' ),
1852
+ 'Status' => __( 'Status', 'media-library-assistant' ),
1853
+ 'No Change' => __( 'No Change', 'media-library-assistant' ),
1854
+ 'Active' => __( 'Active', 'media-library-assistant' ),
1855
+ 'results' => ! empty( $_REQUEST['s'] ) ? '<h3 style="float:left">' . __( 'Displaying search results for', 'media-library-assistant' ) . ': "' . $_REQUEST['s'] . '"</h3>' : '',
1856
  's' => isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '',
1857
  'icon_types' => self::mla_get_icon_type_dropdown( $page_template_array, 'mla_upload_item[icon_type]' ),
1858
  'inline_icon_types' => self::mla_get_icon_type_dropdown( $page_template_array, 'icon_type' ),
1859
  'bulk_icon_types' => self::mla_get_icon_type_dropdown( $page_template_array, 'icon_type', '.nochange.' ),
 
1860
  );
1861
+
1862
  foreach ( $add_form_values as $key => $value ) {
1863
  $page_values[ $key ] = $value;
1864
  }
1865
  $page_content['body'] = MLAData::mla_parse_template( $page_template_array['before-table'], $page_values );
1866
+
1867
  // Now we can render the completed list table
1868
  ob_start();
1869
  $MLAListUploadTable->views();
1870
  $MLAListUploadTable->display();
1871
  $page_content['body'] .= ob_get_contents();
1872
  ob_end_clean();
1873
+
1874
  $page_content['body'] .= MLAData::mla_parse_template( $page_template_array['after-table'], $page_values );
1875
 
1876
  return $page_content;
1877
  }
1878
+
1879
  /**
1880
  * Compose the MLA Gallery tab content for the Settings subpage
1881
  *
1898
  'body' => ''
1899
  );
1900
  }
1901
+
1902
  if ( !empty( $page_content['body'] ) ) {
1903
  return $page_content;
1904
  }
1905
+
1906
  $page_values = array(
1907
+ 'MLA Gallery Options' => __( 'MLA Gallery Options', 'media-library-assistant' ),
1908
+ 'Go to Markup Templates' => __( 'Go to Markup Templates', 'media-library-assistant' ),
1909
+ 'In this tab' => __( 'In this tab you can view the default style and markup templates. You can also define additional templates and use the <code>mla_style</code> and <code>mla_markup</code> parameters to apply them in your <code>[mla_gallery]</code> shortcodes. <strong>NOTE:</strong> template additions and changes will not be made permanent until you click "Save Changes" at the bottom of this page.', 'media-library-assistant' ),
1910
+ 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-mla_gallery&mla_tab=mla_gallery',
1911
  'options_list' => '',
1912
+ 'Style Templates' => __( 'Style Templates', 'media-library-assistant' ),
1913
+ // 'settingsURL' => admin_url('options-general.php'),
1914
  'style_options_list' => '',
1915
+ 'Markup Templates' => __( 'Markup Templates', 'media-library-assistant' ),
1916
  'markup_options_list' => '',
1917
+ 'Save Changes' => __( 'Save Changes', 'media-library-assistant' ),
1918
  '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
1919
  '_wp_http_referer' => wp_referer_field( false )
1920
  );
1921
+
1922
  /*
1923
  * Build default template selection lists
1924
  */
1925
  MLAOptions::$mla_option_definitions['default_style']['options'][] = 'none';
1926
+ MLAOptions::$mla_option_definitions['default_style']['texts'][] = '&mdash; ' . __( 'None', 'media-library-assistant' ) . ' &mdash;';
1927
 
1928
  $templates = MLAOptions::mla_get_style_templates();
1929
  ksort($templates);
1938
  MLAOptions::$mla_option_definitions['default_markup']['options'][] = $key;
1939
  MLAOptions::$mla_option_definitions['default_markup']['texts'][] = $key;
1940
  }
1941
+
1942
  /*
1943
  * Start with any page-level options
1944
  */
1945
  $options_list = '';
1946
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
1947
+ if ( 'mla_gallery' == $value['tab'] ) {
1948
  $options_list .= self::_compose_option_row( $key, $value );
1949
+ }
1950
  }
1951
+
1952
  $page_values['options_list'] = $options_list;
1953
 
1954
  /*
1957
  $default_styles = array( 'default', 'tag-cloud' );
1958
  $style_options_list = '';
1959
  $templates = MLAOptions::mla_get_style_templates();
1960
+
1961
  foreach ( $default_styles as $default ) {
1962
  $name = $default;
1963
  $value =$templates[$default];
1964
  if ( ! empty( $value ) ) {
1965
  $template_values = array (
1966
+ 'help' => __( 'This default template cannot be altered or deleted, but you can copy the styles.', 'media-library-assistant' )
1967
  );
1968
  $control_cells = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-default'], $template_values );
1969
+
1970
  $template_values = array (
1971
+ 'Name' => __( 'Name', 'media-library-assistant' ),
1972
  'name_name' => "mla_style_templates_name[{$default}]",
1973
  'name_id' => "mla_style_templates_name_{$default}",
1974
+ 'readonly' => 'readonly="readonly"',
1975
  'name_text' => $default,
1976
  'control_cells' => $control_cells,
1977
+ 'Styles' => __( 'Styles', 'media-library-assistant' ),
1978
  'value_name' => "mla_style_templates_value[{$default}]",
1979
  'value_id' => "mla_style_templates_value_{$default}",
1980
  'value_text' => esc_textarea( $value ),
1981
+ 'value_help' => __( 'List of substitution parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant' )
1982
  );
1983
+
1984
  $style_options_list .= MLAData::mla_parse_template( self::$page_template_array['mla-gallery-style'], $template_values );
1985
  } // $value
1986
  } // foreach default
1987
+
1988
  foreach ( $templates as $name => $value ) {
1989
  $slug = sanitize_title( $name );
1990
 
1991
+ if ( in_array( $name, $default_styles ) ) {
1992
  continue; // already handled above
1993
+ }
1994
+
1995
  $template_values = array (
1996
  'name' => 'mla_style_templates_delete[' . $slug . ']',
1997
  'id' => 'mla_style_templates_delete_' . $slug,
1998
+ 'value' => __( 'Delete this template', 'media-library-assistant' ),
1999
+ 'help' => __( 'Check the box to delete this template when you press Update at the bottom of the page.', 'media-library-assistant' )
2000
  );
2001
  $control_cells = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-delete'], $template_values );
2002
+
2003
  $template_values = array (
2004
+ 'Name' => __( 'Name', 'media-library-assistant' ),
2005
  'name_name' => 'mla_style_templates_name[' . $slug . ']',
2006
  'name_id' => 'mla_style_templates_name_' . $slug,
2007
+ 'readonly' => '',
2008
  'name_text' => $slug,
2009
  'control_cells' => $control_cells,
2010
+ 'Styles' => __( 'Styles', 'media-library-assistant' ),
2011
  'value_name' => 'mla_style_templates_value[' . $slug . ']',
2012
  'value_id' => 'mla_style_templates_value_' . $slug,
2013
  'value_text' => esc_textarea( $value ),
2014
+ 'value_help' => __( 'List of substitution parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant' )
2015
  );
2016
 
2017
  $style_options_list .= MLAData::mla_parse_template( self::$page_template_array['mla-gallery-style'], $template_values );
2018
  } // foreach $templates
2019
+
2020
  /*
2021
  * Add blank style template for additions
2022
  */
2023
  if ( ! empty( $value ) ) {
2024
  $template_values = array (
2025
+ 'help' => __( 'Fill in a name and styles to add a new template.', 'media-library-assistant' )
2026
  );
2027
  $control_cells = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-default'], $template_values );
2028
+
2029
  $template_values = array (
2030
+ 'Name' => __( 'Name', 'media-library-assistant' ),
2031
  'name_name' => 'mla_style_templates_name[blank]',
2032
  'name_id' => 'mla_style_templates_name_blank',
2033
+ 'readonly' => '',
2034
  'name_text' => '',
2035
  'control_cells' => $control_cells,
2036
+ 'Styles' => __( 'Styles', 'media-library-assistant' ),
2037
  'value_name' => 'mla_style_templates_value[blank]',
2038
  'value_id' => 'mla_style_templates_value_blank',
2039
  'value_text' => '',
2040
+ 'value_help' => __( 'List of substitution parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant' )
2041
  );
2042
 
2043
  $style_options_list .= MLAData::mla_parse_template( self::$page_template_array['mla-gallery-style'], $template_values );
2044
  } // $value
2045
+
2046
  $page_values['style_options_list'] = $style_options_list;
2047
+
2048
  /*
2049
  * Add markup templates; defaults go first
2050
  */
2051
  $default_markups = array( 'default', 'tag-cloud', 'tag-cloud-ul', 'tag-cloud-dl' );
2052
  $markup_options_list = '';
2053
  $templates = MLAOptions::mla_get_markup_templates();
2054
+
2055
  foreach ( $default_markups as $default ) {
2056
  $name = $default;
2057
  $value =$templates[$default];
2058
  if ( ! empty( $value ) ) {
2059
  $template_values = array (
2060
+ 'help' => __( 'This default template cannot be altered or deleted, but you can copy the markup.', 'media-library-assistant' )
2061
  );
2062
  $control_cells = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-default'], $template_values );
2063
+
2064
  $template_values = array (
2065
+ 'Name' => __( 'Name', 'media-library-assistant' ),
2066
  'name_name' => "mla_markup_templates_name[{$default}]",
2067
  'name_id' => "mla_markup_templates_name_{$default}",
2068
+ 'readonly' => 'readonly="readonly"',
2069
  'name_text' => $default,
2070
  'control_cells' => $control_cells,
2071
+
2072
+ 'Open' => __( 'Open', 'media-library-assistant' ),
2073
  'open_name' => "mla_markup_templates_open[{$default}]",
2074
  'open_id' => "mla_markup_templates_open_{$default}",
2075
  'open_text' => isset( $value['open'] ) ? esc_textarea( $value['open'] ) : '',
2076
+ 'open_help' => __( 'Markup for the beginning of the gallery. List of parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant' ),
2077
+
2078
+ 'Row' => __( 'Row', 'media-library-assistant' ),
2079
  'row_open_name' => "mla_markup_templates_row_open[{$default}]",
2080
  'row_open_id' => "mla_markup_templates_row_open_{$default}",
2081
  'row_open_text' => isset( $value['row-open'] ) ? esc_textarea( $value['row-open'] ) : '',
2082
+ 'row_open_help' => __( 'Markup for the beginning of each row in the gallery.', 'media-library-assistant' ),
2083
+
2084
+ 'Item' => __( 'Item', 'media-library-assistant' ),
2085
  'item_name' => "mla_markup_templates_item[{$default}]",
2086
  'item_id' => "mla_markup_templates_item_{$default}",
2087
  'item_text' => isset( $value['item'] ) ? esc_textarea( $value['item'] ) : '',
2088
+ 'item_help' => __( 'Markup for each item/cell of the gallery.', 'media-library-assistant' ),
2089
+
2090
+ 'Close' => __( 'Close', 'media-library-assistant' ),
2091
  'row_close_name' => "mla_markup_templates_row_close[{$default}]",
2092
  'row_close_id' => "mla_markup_templates_row_close_{$default}",
2093
  'row_close_text' => isset( $value['row-close'] ) ? esc_textarea( $value['row-close'] ) : '',
2094
+ 'row_close_help' => __( 'Markup for the end of each row in the gallery.', 'media-library-assistant' ),
2095
+
2096
  'close_name' => "mla_markup_templates_close[{$default}]",
2097
  'close_id' => "mla_markup_templates_close_{$default}",
2098
  'close_text' => isset( $value['close'] ) ? esc_textarea( $value['close'] ) : '',
2099
+ 'close_help' => __( 'Markup for the end of the gallery.', 'media-library-assistant' )
2100
  );
2101
+
2102
  $markup_options_list .= MLAData::mla_parse_template( self::$page_template_array['mla-gallery-markup'], $template_values );
2103
  } // $value
2104
  } // foreach default
2105
+
2106
  foreach ( $templates as $name => $value ) {
2107
  $slug = sanitize_title( $name );
2108
 
2109
+ if ( in_array( $name, $default_markups ) ) {
2110
  continue; // already handled above
2111
+ }
2112
+
2113
  $template_values = array (
2114
  'name' => 'mla_markup_templates_delete[' . $slug . ']',
2115
  'id' => 'mla_markup_templates_delete_' . $slug,
2116
+ 'value' => __( 'Delete this template', 'media-library-assistant' ),
2117
+ 'help' => __( 'Check the box to delete this template when you press Update at the bottom of the page.', 'media-library-assistant' )
2118
  );
2119
  $control_cells = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-delete'], $template_values );
2120
+
2121
  $template_values = array (
2122
+ 'Name' => __( 'Name', 'media-library-assistant' ),
2123
  'name_name' => 'mla_markup_templates_name[' . $slug . ']',
2124
  'name_id' => 'mla_markup_templates_name_' . $slug,
2125
+ 'readonly' => '',
2126
  'name_text' => $slug,
2127
  'control_cells' => $control_cells,
2128
 
2129
+ 'Open' => __( 'Open', 'media-library-assistant' ),
2130
  'open_name' => 'mla_markup_templates_open[' . $slug . ']',
2131
  'open_id' => 'mla_markup_templates_open_' . $slug,
2132
  'open_text' => esc_textarea( $value['open'] ),
2133
+ 'open_help' => __( 'Markup for the beginning of the gallery. List of parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant' ),
2134
 
2135
+ 'Row' => __( 'Row', 'media-library-assistant' ),
2136
  'row_open_name' => 'mla_markup_templates_row_open[' . $slug . ']',
2137
  'row_open_id' => 'mla_markup_templates_row_open_' . $slug,
2138
  'row_open_text' => esc_textarea( $value['row-open'] ),
2139
+ 'row_open_help' => __( 'Markup for the beginning of each row.', 'media-library-assistant' ),
2140
 
2141
+ 'Item' => __( 'Item', 'media-library-assistant' ),
2142
  'item_name' => 'mla_markup_templates_item[' . $slug . ']',
2143
  'item_id' => 'mla_markup_templates_item_' . $slug,
2144
  'item_text' => esc_textarea( $value['item'] ),
2145
+ 'item_help' => __( 'Markup for each item/cell.', 'media-library-assistant' ),
2146
 
2147
+ 'Close' => __( 'Close', 'media-library-assistant' ),
2148
  'row_close_name' => 'mla_markup_templates_row_close[' . $slug . ']',
2149
  'row_close_id' => 'mla_markup_templates_row_close_' . $slug,
2150
  'row_close_text' => esc_textarea( $value['row-close'] ),
2151
+ 'row_close_help' => __( 'Markup for the end of each row.', 'media-library-assistant' ),
2152
 
2153
  'close_name' => 'mla_markup_templates_close[' . $slug . ']',
2154
  'close_id' => 'mla_markup_templates_close_' . $slug,
2155
  'close_text' => esc_textarea( $value['close'] ),
2156
+ 'close_help' => __( 'Markup for the end of the gallery.', 'media-library-assistant' )
2157
  );
2158
 
2159
  $markup_options_list .= MLAData::mla_parse_template( self::$page_template_array['mla-gallery-markup'], $template_values );
2160
  } // foreach $templates
2161
+
2162
  /*
2163
  * Add blank markup template for additions
2164
  */
2165
  if ( ! empty( $value ) ) {
2166
  $template_values = array (
2167
+ 'help' => __( 'Fill in a name and markup to add a new template.', 'media-library-assistant' )
2168
  );
2169
  $control_cells = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-default'], $template_values );
2170
+
2171
  $template_values = array (
2172
+ 'Name' => __( 'Name', 'media-library-assistant' ),
2173
  'name_name' => 'mla_markup_templates_name[blank]',
2174
  'name_id' => 'mla_markup_templates_name_blank',
2175
+ 'readonly' => '',
2176
  'name_text' => '',
2177
  'control_cells' => $control_cells,
2178
 
2179
+ 'Open' => __( 'Open', 'media-library-assistant' ),
2180
  'open_name' => 'mla_markup_templates_open[blank]',
2181
  'open_id' => 'mla_markup_templates_open_blank',
2182
  'open_text' => '',
2183
+ 'open_help' => __( 'Markup for the beginning of the gallery. List of parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant' ),
2184
 
2185
+ 'Row' => __( 'Row', 'media-library-assistant' ),
2186
  'row_open_name' => 'mla_markup_templates_row_open[blank]',
2187
  'row_open_id' => 'mla_markup_templates_row_open_blank',
2188
  'row_open_text' => '',
2189
+ 'row_open_help' => __( 'Markup for the beginning of each row in the gallery.', 'media-library-assistant' ),
2190
 
2191
+ 'Item' => __( 'Item', 'media-library-assistant' ),
2192
  'item_name' => 'mla_markup_templates_item[blank]',
2193
  'item_id' => 'mla_markup_templates_item_blank',
2194
  'item_text' => '',
2195
+ 'item_help' => __( 'Markup for each item/cell of the gallery.', 'media-library-assistant' ),
2196
 
2197
+ 'Close' => __( 'Close', 'media-library-assistant' ),
2198
  'row_close_name' => 'mla_markup_templates_row_close[blank]',
2199
  'row_close_id' => 'mla_markup_templates_row_close_blank',
2200
  'row_close_text' => '',
2201
+ 'row_close_help' => __( 'Markup for the end of each row in the gallery.', 'media-library-assistant' ),
2202
 
2203
  'close_name' => 'mla_markup_templates_close[blank]',
2204
  'close_id' => 'mla_markup_templates_close_blank',
2205
  'close_text' => '',
2206
+ 'close_help' => __( 'Markup for the end of the gallery.', 'media-library-assistant' )
2207
+
2208
  );
2209
 
2210
  $markup_options_list .= MLAData::mla_parse_template( self::$page_template_array['mla-gallery-markup'], $template_values );
2211
  } // $value
2212
+
2213
  $page_values['markup_options_list'] = $markup_options_list;
2214
+
2215
  $page_content['body'] = MLAData::mla_parse_template( self::$page_template_array['mla-gallery-tab'], $page_values );
2216
  return $page_content;
2217
  }
2218
+
2219
  /**
2220
  * Compose the Custom Field tab content for the Settings subpage
2221
  *
2238
  */
2239
  if ( !empty( $_REQUEST['custom-field-options-save'] ) ) {
2240
  $page_content = self::_save_custom_field_settings( );
2241
+ } elseif ( !empty( $_REQUEST['custom-field-options-map'] ) ) {
 
2242
  $page_content = self::_process_custom_field_mapping( );
2243
+ } else {
 
2244
  $page_content = array(
2245
  'message' => '',
2246
  'body' => ''
2261
  case 'add_field':
2262
  case 'update_rule':
2263
  $page_content = self::_save_custom_field_settings( $settings );
2264
+ if ( isset( $delete_result ) ) {
2265
  $page_content['message'] = $delete_result . $page_content['message'];
2266
+ }
2267
  break;
2268
  case 'map_now':
2269
  $page_content = self::_process_custom_field_mapping( $settings );
2271
  case 'add_rule_map':
2272
  case 'add_field_map':
2273
  $page_content = self::_save_custom_field_settings( $settings );
2274
+ if ( false === strpos( $page_content['message'], __( 'ERROR:', 'media-library-assistant' ) ) ) {
2275
  $current_values = MLAOptions::mla_get_option( 'custom_field_mapping' );
2276
  $settings = array( $value['name'] => $current_values[$value['name']] );
2277
  $map_content = self::_process_custom_field_mapping( $settings );
2292
  'body' => ''
2293
  );
2294
  }
2295
+
2296
  if ( !empty( $page_content['body'] ) ) {
2297
  return $page_content;
2298
  }
2299
+
2300
  $page_values = array(
2301
+ 'Custom Field Options' => __( 'Custom Field and Attachment Metadata Processing Options', 'media-library-assistant' ),
2302
+ /* translators: 1: Documentation hyperlink */
2303
+ 'In this tab' => sprintf( __( 'In this tab you can define the rules for mapping several types of image metadata to WordPress custom fields. You can also use this screen to define rules for adding or updating fields within the WordPress-supplied "Attachment Metadata", stored in the "_wp_attachment_metadata" custom field. See the %1$s section of the Documentation for details.', 'media-library-assistant' ), '<a href="[+settingsURL+]?page=mla-settings-menu-documentation&amp;mla_tab=documentation#attachment_metadata_mapping" title="' . __( 'Updating Attachment Metadata Documentation', 'media-library-assistant' ) . '">' . __( 'Adding or changing Attachment Metadata', 'media-library-assistant' ) . '</a>' ),
2304
+ /* translators: 1: Documentation hyperlink */
2305
+ 'You can find' => sprintf( __( 'You can find more information about using the controls in this tab to define mapping rules and apply them in the %1$s section of the Documentation.', 'media-library-assistant' ), '<a href="[+settingsURL+]?page=mla-settings-menu-documentation&amp;mla_tab=documentation#mla_custom_field_mapping" title="' . __( 'Custom Field Options documentation', 'media-library-assistant' ) . '">' . __( 'Custom Field and Attachment Metadata Processing Options', 'media-library-assistant' ) . '</a>' ),
2306
  'settingsURL' => admin_url('options-general.php'),
2307
+ 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-custom_field&mla_tab=custom_field',
2308
  'options_list' => '',
2309
+ 'Custom field mapping' => __( 'Custom field mapping', 'media-library-assistant' ),
2310
  'custom_options_list' => '',
2311
+ 'Save Changes' => __( 'Save Changes', 'media-library-assistant' ),
2312
+ 'Map All Rules' => __( 'Map All Rules, All Attachments Now', 'media-library-assistant' ),
2313
+ /* translators: 1: "Save Changes" */
2314
+ 'Click Save Changes' => sprintf( __( 'Click %1$s to update the "Enable custom field mapping..." checkbox and/or all rule changes and additions at once. <strong>No rule mapping will be performed.</strong>', 'media-library-assistant' ), '<strong>' . __( 'Save Changes', 'media-library-assistant' ) . '</strong>' ),
2315
+ /* translators: 1: "Map All Rules..." */
2316
+ 'Click Map All' => sprintf( __( 'Click %1$s to apply all the rules at once (rule changes will be applied but not saved).', 'media-library-assistant' ), '<strong>' . __( 'Map All Rules, All Attachments Now', 'media-library-assistant' ) . '</strong>' ),
2317
  '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
2318
  '_wp_http_referer' => wp_referer_field( false )
2319
  );
2320
+
2321
  /*
2322
  * Start with any page-level options
2323
  */
2324
  $options_list = '';
2325
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
2326
+ if ( 'custom_field' == $value['tab'] ) {
2327
  $options_list .= self::_compose_option_row( $key, $value );
2328
+ }
2329
  }
2330
+
2331
  $page_values['options_list'] = $options_list;
2332
+
2333
  /*
2334
  * Add mapping options
2335
  */
2336
  $page_values['custom_options_list'] = MLAOptions::mla_custom_field_option_handler( 'render', 'custom_field_mapping', MLAOptions::$mla_option_definitions['custom_field_mapping'] );
2337
+
2338
  $page_content['body'] = MLAData::mla_parse_template( self::$page_template_array['custom-field-tab'], $page_values );
2339
  return $page_content;
2340
  }
2341
+
2342
  /**
2343
  * Compose the IPTC/EXIF tab content for the Settings subpage
2344
  *
2362
 
2363
  if ( !empty( $_REQUEST['iptc-exif-options-save'] ) ) {
2364
  $page_content = self::_save_iptc_exif_settings( );
2365
+ } elseif ( !empty( $_REQUEST['iptc-exif-options-process-standard'] ) ) {
 
2366
  $page_content = self::_process_iptc_exif_standard( );
2367
+ } elseif ( !empty( $_REQUEST['iptc-exif-options-process-taxonomy'] ) ) {
 
2368
  $page_content = self::_process_iptc_exif_taxonomy( );
2369
+ } elseif ( !empty( $_REQUEST['iptc-exif-options-process-custom'] ) ) {
 
2370
  $page_content = self::_process_iptc_exif_custom( );
2371
+ } else {
 
2372
  /*
2373
  * Check for single-rule action buttons
2374
  */
2384
  case 'add_field':
2385
  case 'update_rule':
2386
  $page_content = self::_save_iptc_exif_custom_settings( $settings );
2387
+ if ( isset( $delete_result ) ) {
2388
  $page_content['message'] = $delete_result . $page_content['message'];
2389
+ }
2390
  break;
2391
  case 'map_now':
2392
  $page_content = self::_process_iptc_exif_custom( $settings );
2394
  case 'add_rule_map':
2395
  case 'add_field_map':
2396
  $page_content = self::_save_iptc_exif_custom_settings( $settings );
2397
+ if ( false === strpos( $page_content['message'], __( 'ERROR:', 'media-library-assistant' ) ) ) {
2398
  $current_values = MLAOptions::mla_get_option( 'iptc_exif_mapping' );
2399
  $settings = array( 'custom' => array( $value['name'] => $current_values['custom'][$value['name']] ) );
2400
  $map_content = self::_process_iptc_exif_custom( $settings );
2408
  } /// isset action
2409
  } // foreach rule
2410
  }
2411
+
2412
  if ( !empty( $page_content['body'] ) ) {
2413
  return $page_content;
2414
  }
2415
  }
2416
+
2417
  $page_values = array(
2418
+ 'IPTX/EXIF Options' => __( 'IPTC &amp; EXIF Processing Options', 'media-library-assistant' ),
2419
+ 'In this tab' => __( 'In this tab you can define the rules for mapping IPTC (International Press Telecommunications Council) and EXIF (EXchangeable Image File) metadata to WordPress standard attachment fields, taxonomy terms and custom fields. <strong>NOTE:</strong> settings changes will not be made permanent until you click "Save Changes" at the bottom of this page.', 'media-library-assistant' ),
2420
+ /* translators: 1: Documentation hyperlink */
2421
+ 'You can find' => sprintf( __( 'You can find more information about using the controls in this tab to define mapping rules and apply them in the %1$s section of the Documentation.', 'media-library-assistant' ), '<a href="[+settingsURL+]?page=mla-settings-menu-documentation&amp;mla_tab=documentation#mla_iptc_exif_mapping" title="' . __( 'IPTC/EXIF Options documentation', 'media-library-assistant' ) . '">' . __( 'IPTC &amp; EXIF Processing Options', 'media-library-assistant' ) . '</a>' ),
2422
  'settingsURL' => admin_url('options-general.php'),
2423
+ 'form_url' => admin_url( 'options-general.php' ) . '?page=mla-settings-menu-iptc_exif&mla_tab=iptc_exif',
2424
  'options_list' => '',
2425
+ 'Standard field mapping' => __( 'Standard field mapping', 'media-library-assistant' ),
2426
+ 'Map Standard Fields' => __( 'Map All Attachments, Standard Fields Now', 'media-library-assistant' ),
2427
  'standard_options_list' => '',
2428
+ 'Taxonomy term mapping' => __( 'Taxonomy term mapping', 'media-library-assistant' ),
2429
+ 'Map Taxonomy Terms' => __( 'Map All Attachments, Taxonomy Terms Now', 'media-library-assistant' ),
2430
  'taxonomy_options_list' => '',
2431
+ 'Custom field mapping' => __( 'Custom field mapping', 'media-library-assistant' ),
2432
+ 'Map Custom Fields' => __( 'Map All Attachments, Custom Fields Now', 'media-library-assistant' ),
2433
  'custom_options_list' => '',
2434
+ 'Save Changes' => __( 'Save Changes', 'media-library-assistant' ),
2435
+ /* translators: 1: "Save Changes" */
2436
+ 'Click Save Changes' => sprintf( __( 'Click %1$s to update the "Enable IPTC/EXIF mapping..." checkbox and/or all rule changes and additions at once. <strong>No rule mapping will be performed.</strong>', 'media-library-assistant' ), '<strong>' . __( 'Save Changes', 'media-library-assistant' ) . '</strong>' ),
2437
  '_wpnonce' => wp_nonce_field( MLA::MLA_ADMIN_NONCE, '_wpnonce', true, false ),
2438
  '_wp_http_referer' => wp_referer_field( false )
2439
  );
2440
+
2441
  /*
2442
  * Start with any page-level options
2443
  */
2444
  $options_list = '';
2445
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
2446
+ if ( 'iptc_exif' == $value['tab'] ) {
2447
  $options_list .= self::_compose_option_row( $key, $value );
2448
+ }
2449
  }
2450
+
2451
  $page_values['options_list'] = $options_list;
2452
+
2453
  /*
2454
  * Add mapping options
2455
  */
2456
  $page_values['standard_options_list'] = MLAOptions::mla_iptc_exif_option_handler( 'render', 'iptc_exif_standard_mapping', MLAOptions::$mla_option_definitions['iptc_exif_standard_mapping'] );
2457
+
2458
  $page_values['taxonomy_options_list'] = MLAOptions::mla_iptc_exif_option_handler( 'render', 'iptc_exif_taxonomy_mapping', MLAOptions::$mla_option_definitions['iptc_exif_taxonomy_mapping'] );
2459
+
2460
  $page_values['custom_options_list'] = MLAOptions::mla_iptc_exif_option_handler( 'render', 'iptc_exif_custom_mapping', MLAOptions::$mla_option_definitions['iptc_exif_custom_mapping'] );
2461
+
2462
  $page_content['body'] = MLAData::mla_parse_template( self::$page_template_array['iptc-exif-tab'], $page_values );
2463
  return $page_content;
2464
  }
2465
+
2466
  /**
2467
  * Compose the Documentation tab content for the Settings subpage
2468
  *
2472
  * @return array 'message' => status/error messages, 'body' => tab content
2473
  */
2474
  private static function _compose_documentation_tab( ) {
2475
+ $page_template = MLAData::mla_load_template( 'documentation-settings-tab.tpl' );
2476
  $page_values = array(
2477
  'phpDocs_url' => MLA_PLUGIN_URL . 'phpDocs/index.html',
2478
  'examples_url' => MLA_PLUGIN_URL . 'examples/'
2479
  );
2480
+
2481
  return array(
2482
  'message' => '',
2483
  'body' => MLAData::mla_parse_template( $page_template['documentation-tab'], $page_values )
2484
  );
2485
  }
2486
+
2487
  /**
2488
  * Render (echo) the "Media Library Assistant" subpage in the Settings section
2489
  *
2493
  */
2494
  public static function mla_render_settings_page( ) {
2495
  if ( !current_user_can( 'manage_options' ) ) {
2496
+ echo __( 'Media Library Assistant - Error', 'media-library-assistant' ) . "</h2>\r\n";
2497
+ wp_die( __( 'You do not have permission to manage plugin settings.', 'media-library-assistant' ) );
2498
  }
2499
+
2500
  /*
2501
  * Load template array and initialize page-level values.
2502
  */
2503
+ self::$page_template_array = MLAData::mla_load_template( 'admin-display-settings-page.tpl' );
2504
  $current_tab = isset( $_REQUEST['mla_tab'] ) ? $_REQUEST['mla_tab']: 'general';
2505
  $page_values = array(
2506
+ // 'settingsURL' => admin_url('options-general.php'),
 
2507
  'donateURL' => MLA_PLUGIN_URL . 'images/DonateButton.jpg',
2508
+ 'version' => 'v' . MLA::CURRENT_MLA_VERSION,
2509
  'messages' => '',
2510
  'tablist' => self::_compose_settings_tabs( $current_tab ),
2511
+ 'tab_content' => '',
2512
+ 'Media Library Assistant' => __( 'Media Library Assistant', 'media-library-assistant' ),
2513
+ 'Settings' => __( 'Settings', 'media-library-assistant' )
2514
  );
2515
+
2516
  /*
2517
  * Compose tab content
2518
  */
2521
  $handler = self::$mla_tablist[ $current_tab ]['render'];
2522
  $page_content = self::$handler( );
2523
  } else {
2524
+ $page_content = array( 'message' => __( 'ERROR: Cannot render content tab', 'media-library-assistant' ), 'body' => '' );
2525
  }
2526
  } else {
2527
+ $page_content = array( 'message' => __( 'ERROR: Unknown content tab', 'media-library-assistant' ), 'body' => '' );
2528
  }
2529
 
2530
  if ( ! empty( $page_content['message'] ) ) {
2531
+ if ( false !== strpos( $page_content['message'], __( 'ERROR:', 'media-library-assistant' ) ) ) {
2532
  $messages_class = 'mla_errors';
2533
+ } else {
2534
  $messages_class = 'mla_messages';
2535
+ }
2536
 
2537
  $page_values['messages'] = MLAData::mla_parse_template( self::$page_template_array['messages'], array(
2538
  'messages' => $page_content['message'],
2543
  $page_values['tab_content'] = $page_content['body'];
2544
  echo MLAData::mla_parse_template( self::$page_template_array['page'], $page_values );
2545
  } // mla_render_settings_page
2546
+
2547
  /**
2548
  * Save MLA Gallery settings to the options table
2549
  *
2557
  $settings_changed = false;
2558
  $message_list = '';
2559
  $error_list = '';
2560
+
2561
  /*
2562
  * Start with any page-level options
2563
  */
2569
  $settings_changed = true;
2570
  $message_list .= self::_update_option_row( $key, $value );
2571
  }
2572
+ } elseif ( 'text' == $value['type'] ) {
2573
+ if ( '' == $_REQUEST[ MLA_OPTION_PREFIX . $key ] ) {
 
2574
  $_REQUEST[ MLA_OPTION_PREFIX . $key ] = $value['std'];
2575
+ }
2576
+
2577
  $old_value = MLAOptions::mla_get_option( $key );
2578
  if ( $old_value != $_REQUEST[ MLA_OPTION_PREFIX . $key ] ) {
2579
  $settings_changed = true;
2582
  } // text
2583
  } // mla_gallery
2584
  } // foreach mla_options
2585
+
2586
  /*
2587
  * Get the current style contents for comparison
2588
  */
2591
  $new_names = $_REQUEST['mla_style_templates_name'];
2592
  $new_values = stripslashes_deep( $_REQUEST['mla_style_templates_value'] );
2593
  $new_deletes = isset( $_REQUEST['mla_style_templates_delete'] ) ? $_REQUEST['mla_style_templates_delete']: array();
2594
+
2595
  /*
2596
  * Build new style template array, noting changes
2597
  */
2598
  $default_styles = array( 'default', 'tag-cloud' );
2599
  $templates_changed = false;
2600
  foreach ( $new_names as $name => $new_name ) {
2601
+ if ( in_array( $name, $default_styles ) ) {
2602
  continue;
2603
+ }
2604
 
2605
+ if ( array_key_exists( $name, $new_deletes ) ) {
2606
+ /* translators: 1: template type 2: template name */
2607
+ $message_list .= '<br>' . sprintf( _x( 'Deleting %1$s "%2$s".', 'message_list', 'media-library-assistant' ), __( 'style template', 'media-library-assistant' ), $name );
2608
  $templates_changed = true;
2609
  continue;
2610
  }
2611
 
2612
  $new_slug = sanitize_title( $new_name );
2613
  if ( 'blank' == $name ) {
2614
+ if ( '' == $new_slug ) {
2615
  continue;
2616
+ } elseif ( 'blank' == $new_slug ) {
2617
+ /* translators: 1: template name 2: template type */
2618
+ $error_list .= '<br>' . sprintf( __( 'ERROR: Reserved name "%1$s", new %2$s discarded.', $new_slug, 'media-library-assistant' ), __( 'style template', 'media-library-assistant' ) );
2619
  continue;
2620
  }
2621
+
2622
+ if ( array_key_exists( $new_slug, $old_templates ) ) {
2623
+ /* translators: 1: template name 2: template type */
2624
+ $error_list .= '<br>' . sprintf( __( 'ERROR: Duplicate name "%1$s", new %2$s discarded.', $new_slug, 'media-library-assistant' ), __( 'style template', 'media-library-assistant' ) );
2625
  continue;
2626
+ } else {
2627
+ /* translators: 1: template type 2: template name */
2628
+ $message_list .= '<br>' . sprintf( _x( 'Adding new %1$s "%2$s".', 'message_list', 'media-library-assistant' ), __( 'style template', 'media-library-assistant' ), $new_slug );
2629
  $templates_changed = true;
2630
  }
2631
  } // 'blank' - reserved name
2632
+
2633
  /*
2634
  * Handle name changes, check for duplicates
2635
  */
2636
  if ( '' == $new_slug ) {
2637
+ /* translators: 1: element name 3: old value */
2638
+ $error_list .= '<br>' . sprintf( __( 'ERROR: Blank %1$s, reverting to "%3$s".', 'media-library-assistant' ), __( 'style template name', 'media-library-assistant' ), $name );
2639
+ /* translators: 1: template name */
2640
  $new_slug = $name;
2641
  }
2642
+
2643
  if ( $new_slug != $name ) {
2644
+ if ( array_key_exists( $new_slug, $old_templates ) ) {
2645
+ /* translators: 1: element name 2: new value 3: old value */
2646
+ $error_list .= '<br>' . sprintf( __( 'ERROR: Duplicate new %1$s "%2$s", reverting to "%3$s".', 'media-library-assistant' ), __( 'style template name', 'media-library-assistant' ), $new_slug, $name );
2647
  $new_slug = $name;
2648
+ } elseif ( 'blank' != $name ) {
2649
+ /* translators: 1: element name 2: old_value 3: new_value */
2650
+ $message_list .= '<br>' . sprintf( _x( 'Changing %1$s from "%2$s" to "%3$s"', 'message_list', 'media-library-assistant' ), __( 'style template name', 'media-library-assistant' ), $name, $new_slug );
2651
  $templates_changed = true;
2652
  }
2653
  } // name changed
2654
+
2655
  if ( ( 'blank' != $name ) && ( $new_values[ $name ] != $old_templates[ $name ] ) ) {
2656
+ /* translators: 1: template type 2: template name */
2657
+ $message_list .= '<br>' . sprintf( _x( 'Updating contents of %1$s "%2$s".', 'message_list', 'media-library-assistant' ), __( 'style template', 'media-library-assistant' ), $new_slug );
2658
  $templates_changed = true;
2659
  }
2660
+
2661
  $new_templates[ $new_slug ] = $new_values[ $name ];
2662
  } // foreach $name
2663
+
2664
  if ( $templates_changed ) {
2665
  $settings_changed = true;
2666
+ if ( false == MLAOptions::mla_put_style_templates( $new_templates ) ) {
2667
+ /* translators: 1: template type */
2668
+ $error_list .= '<br>' . sprintf( __( 'ERROR: Update of %1$s failed.', 'media-library-assistant' ), __( 'style template', 'media-library-assistant' ) );
2669
+ }
2670
  }
2671
+
2672
  /*
2673
  * Get the current markup contents for comparison
2674
  */
2681
  $new_values['row-close'] = stripslashes_deep( $_REQUEST['mla_markup_templates_row_close'] );
2682
  $new_values['close'] = stripslashes_deep( $_REQUEST['mla_markup_templates_close'] );
2683
  $new_deletes = isset( $_REQUEST['mla_markup_templates_delete'] ) ? $_REQUEST['mla_markup_templates_delete']: array();
2684
+
2685
  /*
2686
  * Build new markup template array, noting changes
2687
  */
2688
  $default_markups = array( 'default', 'tag-cloud', 'tag-cloud-ul', 'tag-cloud-dl' );
2689
  $templates_changed = false;
2690
  foreach ( $new_names as $name => $new_name ) {
2691
+ if ( in_array( $name, $default_markups ) ) {
2692
  continue;
2693
+ }
2694
 
2695
+ if ( array_key_exists( $name, $new_deletes ) ) {
2696
+ /* translators: 1: template type 2: template name */
2697
+ $message_list .= '<br>' . sprintf( _x( 'Deleting %1$s "%2$s".', 'message_list', 'media-library-assistant' ), __( 'markup template', 'media-library-assistant' ), $name );
2698
  $templates_changed = true;
2699
  continue;
2700
  }
2701
 
2702
  $new_slug = sanitize_title( $new_name );
2703
  if ( 'blank' == $name ) {
2704
+ if ( '' == $new_slug ) {
2705
  continue;
2706
+ }
2707
+
2708
  if ( 'blank' == $new_slug ) {
2709
+ /* translators: 1: template name 2: template type */
2710
+ $error_list .= '<br>' . sprintf( __( 'ERROR: Reserved name "%1$s", new %2$s discarded.', $new_slug, 'media-library-assistant' ), __( 'markup template', 'media-library-assistant' ) );
2711
  continue;
2712
  }
2713
+
2714
+ if ( array_key_exists( $new_slug, $old_templates ) ) {
2715
+ /* translators: 1: template name 2: template type */
2716
+ $error_list .= '<br>' . sprintf( __( 'ERROR: Duplicate name "%1$s", new %2$s discarded.', $new_slug, 'media-library-assistant' ), __( 'markup template', 'media-library-assistant' ) );
2717
  continue;
2718
+ } else {
2719
+ /* translators: 1: template type 2: template name */
2720
+ $message_list .= '<br>' . sprintf( _x( 'Adding new %1$s "%2$s".', 'message_list', 'media-library-assistant' ), __( 'markup template', 'media-library-assistant' ), $new_slug );
2721
  $templates_changed = true;
2722
  }
2723
  } // 'blank' - reserved name
2724
+
2725
  /*
2726
  * Handle name changes, check for duplicates
2727
  */
2728
  if ( '' == $new_slug ) {
2729
+ /* translators: 1: element name 3: old value */
2730
+ $error_list .= '<br>' . sprintf( __( 'ERROR: Blank %1$s, reverting to "%3$s".', 'media-library-assistant' ), __( 'markup template name', 'media-library-assistant' ), $name );
2731
  $new_slug = $name;
2732
  }
2733
+
2734
  if ( $new_slug != $name ) {
2735
+ if ( array_key_exists( $new_slug, $old_templates ) ) {
2736
+ /* translators: 1: element name 2: new value 3: old value */
2737
+ $error_list .= '<br>' . sprintf( __( 'ERROR: Duplicate new %1$s "%2$s", reverting to "%3$s".', 'media-library-assistant' ), __( 'markup template name', 'media-library-assistant' ), $new_slug, $name );
2738
  $new_slug = $name;
2739
+ } elseif ( 'blank' != $name ) {
2740
+ /* translators: 1: element name 2: old_value 3: new_value */
2741
+ $message_list .= '<br>' . sprintf( _x( 'Changing %1$s from "%2$s" to "%3$s"', 'message_list', 'media-library-assistant' ), __( 'markup template name', 'media-library-assistant' ), $name, $new_slug );
2742
  $templates_changed = true;
2743
  }
2744
  } // name changed
2745
+
2746
  if ( 'blank' != $name ) {
2747
  if ( $new_values['open'][ $name ] != $old_templates[ $name ]['open'] ) {
2748
+ /* translators: 1: template name */
2749
+ $message_list .= '<br>' . sprintf( _x( 'Updating open markup for "%1$s".', 'message_list', 'media-library-assistant' ), $new_slug );
2750
  $templates_changed = true;
2751
  }
2752
+
2753
  if ( $new_values['row-open'][ $name ] != $old_templates[ $name ]['row-open'] ) {
2754
+ /* translators: 1: template name */
2755
+ $message_list .= '<br>' . sprintf( _x( 'Updating row open markup for "%1$s".', 'message_list', 'media-library-assistant' ), $new_slug );
2756
  $templates_changed = true;
2757
  }
2758
+
2759
  if ( $new_values['item'][ $name ] != $old_templates[ $name ]['item'] ) {
2760
+ /* translators: 1: template name */
2761
+ $message_list .= '<br>' . sprintf( _x( 'Updating item markup for "%1$s".', 'message_list', 'media-library-assistant' ), $new_slug );
2762
  $templates_changed = true;
2763
  }
2764
+
2765
  if ( $new_values['row-close'][ $name ] != $old_templates[ $name ]['row-close'] ) {
2766
+ /* translators: 1: template name */
2767
+ $message_list .= '<br>' . sprintf( _x( 'Updating row close markup for "%1$s".', 'message_list', 'media-library-assistant' ), $new_slug );
2768
  $templates_changed = true;
2769
  }
2770
+
2771
  if ( $new_values['close'][ $name ] != $old_templates[ $name ]['close'] ) {
2772
+ /* translators: 1: template name */
2773
+ $message_list .= '<br>' . sprintf( _x( 'Updating close markup for "%1$s".', 'message_list', 'media-library-assistant' ), $new_slug );
2774
  $templates_changed = true;
2775
  }
2776
  } // ! 'blank'
2777
+
2778
  $new_templates[ $new_slug ]['open'] = $new_values['open'][ $name ];
2779
  $new_templates[ $new_slug ]['row-open'] = $new_values['row-open'][ $name ];
2780
  $new_templates[ $new_slug ]['item'] = $new_values['item'][ $name ];
2781
  $new_templates[ $new_slug ]['row-close'] = $new_values['row-close'][ $name ];
2782
  $new_templates[ $new_slug ]['close'] = $new_values['close'][ $name ];
2783
  } // foreach $name
2784
+
2785
  if ( $templates_changed ) {
2786
  $settings_changed = true;
2787
+ if ( false == MLAOptions::mla_put_markup_templates( $new_templates ) ) {
2788
+ /* translators: 1: template type */
2789
+ $error_list .= '<br>' . sprintf( __( 'ERROR: Update of %1$s failed.', 'media-library-assistant' ), __( 'markup template', 'media-library-assistant' ) );
2790
+ }
2791
+ }
2792
+
2793
+ if ( $settings_changed ) {
2794
+ /* translators: 1: field type */
2795
+ $message = sprintf( __( '%1$s settings saved.', 'media-library-assistant' ), __( 'MLA Gallery', 'media-library-assistant' ) ) . "\r\n";
2796
+ } else {
2797
+ /* translators: 1: field type */
2798
+ $message = sprintf( __( '%1$s no changes detected.', 'media-library-assistant' ), __( 'MLA Gallery', 'media-library-assistant' ) ) . "\r\n";
2799
+ }
2800
+
2801
  $page_content = array(
2802
  'message' => $message . $error_list,
2803
  'body' => ''
2804
  );
2805
+
2806
  /*
2807
  * Uncomment this for debugging.
2808
  */
2810
 
2811
  return $page_content;
2812
  } // _save_gallery_settings
2813
+
2814
  /**
2815
  * Save View settings to the options table
2816
  *
2822
  */
2823
  private static function _save_view_settings( ) {
2824
  $message_list = '';
2825
+
2826
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
2827
  if ( 'view' == $value['tab'] ) {
2828
  $message_list .= self::_update_option_row( $key, $value );
2829
  } // view option
2830
  } // foreach mla_options
2831
+
2832
  $page_content = array(
2833
+ 'message' => __( 'View settings saved.', 'media-library-assistant' ) . "\r\n",
2834
  'body' => ''
2835
  );
2836
+
2837
  /*
2838
  * Uncomment this for debugging.
2839
  */
2841
 
2842
  return $page_content;
2843
  } // _save_view_settings
2844
+
2845
  /**
2846
  * Save Upload settings to the options table
2847
  *
2853
  */
2854
  private static function _save_upload_settings( ) {
2855
  $message_list = '';
2856
+
2857
  if ( ! isset( $_REQUEST[ MLA_OPTION_PREFIX . MLAOptions::MLA_ENABLE_UPLOAD_MIMES ] ) )
2858
  unset( $_REQUEST[ MLA_OPTION_PREFIX . MLAOptions::MLA_ENABLE_MLA_ICONS ] );
2859
+
2860
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
2861
  if ( 'upload' == $value['tab'] ) {
2862
  $message_list .= self::_update_option_row( $key, $value );
2863
  } // upload option
2864
  } // foreach mla_options
2865
+
2866
  $page_content = array(
2867
+ 'message' => __( 'Upload MIME Type settings saved.', 'media-library-assistant' ) . "\r\n",
2868
  'body' => ''
2869
  );
2870
+
2871
  /*
2872
  * Uncomment this for debugging.
2873
  */
2875
 
2876
  return $page_content;
2877
  } // _save_upload_settings
2878
+
2879
  /**
2880
  * Process custom field settings against all image attachments
2881
  * without saving the settings to the mla_option
2889
  */
2890
  private static function _process_custom_field_mapping( $settings = NULL ) {
2891
  global $wpdb;
2892
+
2893
  if ( NULL == $settings ) {
2894
  $settings = ( isset( $_REQUEST['custom_field_mapping'] ) ) ? $_REQUEST['custom_field_mapping'] : array();
2895
+ if ( isset( $settings[ MLAOptions::MLA_NEW_CUSTOM_FIELD ] ) ) {
2896
  unset( $settings[ MLAOptions::MLA_NEW_CUSTOM_FIELD ] );
2897
+ }
2898
+ if ( isset( $settings[ MLAOptions::MLA_NEW_CUSTOM_RULE ] ) ) {
2899
  unset( $settings[ MLAOptions::MLA_NEW_CUSTOM_RULE ] );
2900
+ }
2901
  }
2902
+
2903
+ if ( empty( $settings ) ) {
2904
  return array(
2905
+ 'message' => __( 'ERROR: No custom field mapping rules to process.', 'media-library-assistant' ),
2906
  'body' => ''
2907
  );
2908
+ }
2909
 
2910
  $examine_count = 0;
2911
  $update_count = 0;
2917
  $examine_count += 1;
2918
  if ( ! empty( $updates ) ) {
2919
  $results = MLAData::mla_update_item_postmeta( (integer) $post_id, $updates['custom_updates'] );
2920
+ if ( ! empty( $results ) ) {
2921
  $update_count += 1;
2922
+ }
2923
  }
2924
  } // foreach post
2925
+
2926
+ if ( $update_count ) {
2927
+ /* translators: 1: field type 2: examined count 3: updated count */
2928
+ $message = sprintf( __( '%1$s mapping completed; %2$d attachment(s) examined, %3$d updated.' ), __( 'Custom field', 'media-library-assistant' ), $examine_count, $update_count ) . "\r\n";
2929
+ } else {
2930
+ /* translators: 1: field type 2: examined count */
2931
+ $message = sprintf( __( '%1$s mapping completed; %2$d attachment(s) examined, no changes detected.' ), __( 'Custom field', 'media-library-assistant' ), $examine_count ) . "\r\n";
2932
+ }
2933
+
2934
  return array(
2935
  'message' => $message,
2936
  'body' => ''
2937
  );
2938
  } // _process_custom_field_mapping
2939
+
2940
  /**
2941
  * Delete a custom field from the wp_postmeta table
2942
  *
2954
  delete_metadata_by_mid( 'post', $mid );
2955
 
2956
  $count = count( $post_meta_ids );
2957
+ if ( $count ) {
2958
+ /* translators: 1: number of attachments */
2959
+ return sprintf( __( 'Deleted custom field value from %1$s.', 'media-library-assistant' ) . '<br>', _n( '%s attachment', '%s attachments', $count, 'media-library-assistant' ) );
2960
+ }
2961
+
2962
+ return __( 'No attachments contained this custom field.', 'media-library-assistant' ) . '<br>';
2963
  } // _delete_custom_field
2964
+
2965
  /**
2966
  * Save custom field settings to the options table
2967
  *
2981
  * Start with any page-level options
2982
  */
2983
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
2984
+ if ( 'custom_field' == $value['tab'] ) {
2985
  $option_messages .= self::_update_option_row( $key, $value );
2986
+ }
2987
  }
2988
+
2989
  /*
2990
  * Add mapping options
2991
  */
2996
  * Uncomment this for debugging.
2997
  */
2998
  // $message_list = $option_messages . '<br>';
2999
+
3000
  return array(
3001
  'message' => $message_list . MLAOptions::mla_custom_field_option_handler( 'update', 'custom_field_mapping', MLAOptions::$mla_option_definitions['custom_field_mapping'], $new_values ),
3002
  'body' => ''
3003
  );
3004
  } // _save_custom_field_settings
3005
+
3006
  /**
3007
  * Process IPTC/EXIF standard field settings against all image attachments
3008
  * without saving the settings to the mla_option
3014
  * @return array Message(s) reflecting the results of the operation
3015
  */
3016
  private static function _process_iptc_exif_standard( ) {
3017
+ if ( ! isset( $_REQUEST['iptc_exif_mapping']['standard'] ) ) {
3018
  return array(
3019
+ /* translators: 1: field type */
3020
+ 'message' => sprintf( __( 'ERROR: No %1$s settings to process.', 'media-library-assistant' ), __( 'Standard field', 'media-library-assistant' ) ),
3021
  'body' => ''
3022
  );
3023
+ }
3024
 
3025
  $examine_count = 0;
3026
  $update_count = 0;
3027
+
 
 
3028
  $query = array( 'orderby' => 'none', 'post_parent' => 'all', 'post_mime_type' => 'image,application/*pdf*' );
3029
  $posts = MLAShortcodes::mla_get_shortcode_attachments( 0, $query );
3030
+
3031
+ if ( is_string( $posts ) ) {
3032
  return array(
3033
  'message' => $posts,
3034
  'body' => ''
3035
  );
3036
+ }
3037
 
3038
  foreach ( $posts as $key => $post ) {
3039
  $updates = MLAOptions::mla_evaluate_iptc_exif_mapping( $post, 'iptc_exif_standard_mapping', $_REQUEST['iptc_exif_mapping'] );
3040
 
3041
  $examine_count += 1;
3042
  if ( ! empty( $updates ) ) {
3043
+ $results = MLAData::mla_update_single_item( $post->ID, $updates );
3044
+ if ( stripos( $results['message'], __( 'updated.', 'media-library-assistant' ) ) ) {
3045
+ $update_count += 1;
3046
+ }
3047
  }
3048
  } // foreach post
3049
+
3050
+ if ( $update_count ) {
3051
+ /* translators: 1: field type 2: examined count 3: updated count */
3052
+ $message = sprintf( __( '%1$s mapping completed; %2$d attachment(s) examined, %3$d updated.' ), 'IPTC/EXIF ' . __( 'Standard field', 'media-library-assistant' ), $examine_count, $update_count ) . "\r\n";
3053
+ } else {
3054
+ /* translators: 1: field type 2: examined count */
3055
+ $message = sprintf( __( '%1$s mapping completed; %2$d attachment(s) examined, no changes detected.' ), 'IPTC/EXIF ' . __( 'Standard field', 'media-library-assistant' ), $examine_count ) . "\r\n";
3056
+ }
3057
+
3058
  return array(
3059
  'message' => $message,
3060
  'body' => ''
3061
  );
3062
  } // _process_iptc_exif_standard
3063
+
3064
  /**
3065
  * Process IPTC/EXIF taxonomy term settings against all image attachments
3066
  * without saving the settings to the mla_option
3072
  * @return array Message(s) reflecting the results of the operation
3073
  */
3074
  private static function _process_iptc_exif_taxonomy( ) {
3075
+ if ( ! isset( $_REQUEST['iptc_exif_mapping']['taxonomy'] ) ) {
3076
  return array(
3077
+ /* translators: 1: field type */
3078
+ 'message' => sprintf( __( 'ERROR: No %1$s settings to process.', 'media-library-assistant' ), __( 'Taxonomy term', 'media-library-assistant' ) ),
3079
  'body' => ''
3080
  );
3081
+ }
3082
 
3083
  $examine_count = 0;
3084
  $update_count = 0;
3085
+
 
 
3086
  $query = array( 'orderby' => 'none', 'post_parent' => 'all', 'post_mime_type' => 'image,application/*pdf*' );
3087
  $posts = MLAShortcodes::mla_get_shortcode_attachments( 0, $query );
3088
+
3089
+ if ( is_string( $posts ) ) {
3090
  return array(
3091
  'message' => $posts,
3092
  'body' => ''
3093
  );
3094
+ }
3095
 
3096
  foreach ( $posts as $key => $post ) {
3097
  $updates = MLAOptions::mla_evaluate_iptc_exif_mapping( $post, 'iptc_exif_taxonomy_mapping', $_REQUEST['iptc_exif_mapping'] );
3099
  $examine_count += 1;
3100
  if ( ! empty( $updates ) ) {
3101
  $results = MLAData::mla_update_single_item( $post->ID, array(), $updates['taxonomy_updates']['inputs'], $updates['taxonomy_updates']['actions'] );
3102
+ if ( stripos( $results['message'], __( 'updated.', 'media-library-assistant' ) ) ) {
3103
  $update_count += 1;
3104
+ }
3105
  }
3106
  } // foreach post
3107
+
3108
+ if ( $update_count ) {
3109
+ /* translators: 1: field type 2: examined count 3: updated count */
3110
+ $message = sprintf( __( '%1$s mapping completed; %2$d attachment(s) examined, %3$d updated.' ), 'IPTC/EXIF ' . __( 'Taxonomy term', 'media-library-assistant' ), $examine_count, $update_count ) . "\r\n";
3111
+ } else {
3112
+ /* translators: 1: field type 2: examined count */
3113
+ $message = sprintf( __( '%1$s mapping completed; %2$d attachment(s) examined, no changes detected.' ), 'IPTC/EXIF ' . __( 'Taxonomy term', 'media-library-assistant' ), $examine_count ) . "\r\n";
3114
+ }
3115
+
3116
  return array(
3117
  'message' => $message,
3118
  'body' => ''
3119
  );
3120
  } // _process_iptc_exif_taxonomy
3121
+
3122
  /**
3123
  * Process IPTC/EXIF custom field settings against all image attachments
3124
  * without saving the settings to the mla_option
3134
  private static function _process_iptc_exif_custom( $settings = NULL ) {
3135
  if ( NULL == $settings ) {
3136
  $settings = ( isset( $_REQUEST['iptc_exif_mapping'] ) ) ? $_REQUEST['iptc_exif_mapping'] : array();
3137
+ if ( isset( $settings['custom'][ MLAOptions::MLA_NEW_CUSTOM_FIELD ] ) ) {
3138
  unset( $settings['custom'][ MLAOptions::MLA_NEW_CUSTOM_FIELD ] );
3139
+ }
3140
+ if ( isset( $settings['custom'][ MLAOptions::MLA_NEW_CUSTOM_RULE ] ) ) {
3141
  unset( $settings['custom'][ MLAOptions::MLA_NEW_CUSTOM_RULE ] );
3142
+ }
3143
  }
3144
+
3145
+ if ( empty( $settings['custom'] ) ) {
3146
  return array(
3147
+ /* translators: 1: field type */
3148
+ 'message' => sprintf( __( 'ERROR: No %1$s settings to process.', 'media-library-assistant' ), __( 'Custom field', 'media-library-assistant' ) ),
3149
  'body' => ''
3150
  );
3151
+ }
3152
 
3153
  $examine_count = 0;
3154
  $update_count = 0;
3155
+
 
 
3156
  $query = array( 'orderby' => 'none', 'post_parent' => 'all', 'post_mime_type' => 'image,application/*pdf*' );
3157
  $posts = MLAShortcodes::mla_get_shortcode_attachments( 0, $query );
3158
+
3159
+ if ( is_string( $posts ) ) {
3160
  return array(
3161
  'message' => $posts,
3162
  'body' => ''
3163
  );
3164
+ }
3165
 
3166
  foreach ( $posts as $key => $post ) {
3167
  $updates = MLAOptions::mla_evaluate_iptc_exif_mapping( $post, 'iptc_exif_custom_mapping', $settings );
3169
  $examine_count += 1;
3170
  if ( ! empty( $updates ) ) {
3171
  $results = MLAData::mla_update_single_item( $post->ID, $updates );
3172
+ if ( stripos( $results['message'], __( 'updated.', 'media-library-assistant' ) ) ) {
3173
  $update_count += 1;
3174
+ }
3175
  }
3176
  } // foreach post
3177
+
3178
+ if ( $update_count ) {
3179
+ /* translators: 1: field type 2: examined count 3: updated count */
3180
+ $message = sprintf( __( '%1$s mapping completed; %2$d attachment(s) examined, %3$d updated.' ), 'IPTC/EXIF ' . __( 'Custom field', 'media-library-assistant' ), $examine_count, $update_count ) . "\r\n";
3181
+ } else {
3182
+ /* translators: 1: field type 2: examined count */
3183
+ $message = sprintf( __( '%1$s mapping completed; %2$d attachment(s) examined, no changes detected.' ), 'IPTC/EXIF ' . __( 'Custom field', 'media-library-assistant' ), $examine_count ) . "\r\n";
3184
+ }
3185
+
3186
  return array(
3187
  'message' => $message,
3188
  'body' => ''
3189
  );
3190
  } // _process_iptc_exif_custom
3191
+
3192
  /**
3193
  * Save IPTC/EXIF custom field settings to the options table
3194
  *
3204
  'body' => ''
3205
  );
3206
  } // _save_iptc_exif_custom_settings
3207
+
3208
  /**
3209
  * Save IPTC/EXIF settings to the options table
3210
  *
3222
  * Start with any page-level options
3223
  */
3224
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
3225
+ if ( 'iptc_exif' == $value['tab'] ) {
3226
  $option_messages .= self::_update_option_row( $key, $value );
3227
+ }
3228
  }
3229
 
3230
  /*
3231
  * Uncomment this for debugging.
3232
  */
3233
  // $message_list = $option_messages . '<br>';
3234
+
3235
  /*
3236
  * Add mapping options
3237
  */
3242
  'body' => ''
3243
  );
3244
  } // _save_iptc_exif_settings
3245
+
3246
  /**
3247
  * Save General settings to the options table
3248
  *
3254
  */
3255
  private static function _save_general_settings( ) {
3256
  $message_list = '';
3257
+
3258
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
3259
  if ( 'general' == $value['tab'] ) {
3260
  switch ( $key ) {
3266
  break;
3267
  case MLAOptions::MLA_GALLERY_IN_TUNING:
3268
  MLAOptions::$process_gallery_in = ( 'disabled' != $_REQUEST[ MLA_OPTION_PREFIX . $key ] );
3269
+
3270
  if ( 'refresh' == $_REQUEST[ MLA_OPTION_PREFIX . $key ] ) {
3271
  MLAData::mla_flush_mla_galleries( MLAOptions::MLA_GALLERY_IN_TUNING );
3272
+ /* translators: 1: reference type, e.g., Gallery in */
3273
+ $message_list .= "<br>" . sprintf( _x( '%1$s - references updated.', 'message_list', 'media-library-assistant' ), __( 'Gallery in', 'media-library-assistant' ) ) . "\r\n";
3274
  $_REQUEST[ MLA_OPTION_PREFIX . $key ] = 'cached';
3275
  }
3276
  break;
3277
  case MLAOptions::MLA_MLA_GALLERY_IN_TUNING:
3278
  MLAOptions::$process_mla_gallery_in = ( 'disabled' != $_REQUEST[ MLA_OPTION_PREFIX . $key ] );
3279
+
3280
  if ( 'refresh' == $_REQUEST[ MLA_OPTION_PREFIX . $key ] ) {
3281
  MLAData::mla_flush_mla_galleries( MLAOptions::MLA_MLA_GALLERY_IN_TUNING );
3282
+ /* translators: 1: reference type, e.g., Gallery in */
3283
+ $message_list .= "<br>" . sprintf( _x( '%1$s - references updated.', 'message_list', 'media-library-assistant' ), __( 'MLA Gallery in', 'media-library-assistant' ) ) . "\r\n";
3284
  $_REQUEST[ MLA_OPTION_PREFIX . $key ] = 'cached';
3285
  }
3286
  break;
3291
  $message_list .= self::_update_option_row( $key, $value );
3292
  } // general option
3293
  } // foreach mla_options
3294
+
3295
  $page_content = array(
3296
+ 'message' => __( 'General settings saved.', 'media-library-assistant' ) . "\r\n",
3297
  'body' => ''
3298
  );
3299
+
3300
  /*
3301
  * Uncomment this for debugging.
3302
  */
3304
 
3305
  return $page_content;
3306
  } // _save_general_settings
3307
+
3308
  /**
3309
  * Delete saved settings, restoring default values
3310
  *
3314
  */
3315
  private static function _reset_general_settings( ) {
3316
  $message_list = '';
3317
+
3318
  foreach ( MLAOptions::$mla_option_definitions as $key => $value ) {
3319
  if ( 'general' == $value['tab'] ) {
3320
  if ( 'custom' == $value['type'] && isset( $value['reset'] ) ) {
3321
  $message = MLAOptions::$value['reset']( 'reset', $key, $value, $_REQUEST );
3322
+ } elseif ( ('header' == $value['type']) || ('hidden' == $value['type']) ) {
 
3323
  $message = '';
3324
+ } else {
 
3325
  MLAOptions::mla_delete_option( $key );
3326
+ /* translators: 1: option name */
3327
+ $message = '<br>' . sprintf( _x( 'delete_option "%1$s"', 'message_list', 'media-library-assistant'), $key );
3328
  }
3329
+
3330
  $message_list .= $message;
3331
  }
3332
  }
3333
+
3334
  $page_content = array(
3335
+ 'message' => __( 'General settings reset to default values.', 'media-library-assistant' ) . "\r\n",
3336
  'body' => ''
3337
  );
3338
 
3340
  * Uncomment this for debugging.
3341
  */
3342
  // $page_content['message'] .= $message_list;
3343
+
3344
  return $page_content;
3345
  } // _reset_general_settings
3346
+
3347
  /**
3348
  * Compose HTML markup for the import settings if any settings files exist
3349
  *
3352
  * @return string HTML markup for the Import All Settings button and dropdown list, if any
3353
  */
3354
  private static function _compose_import_settings( ) {
3355
+ if ( ! file_exists( MLA_BACKUP_DIR ) ) {
3356
  return '';
3357
+ }
3358
+
3359
  $prefix = ( ( defined( MLA_OPTION_PREFIX ) ) ? MLA_OPTION_PREFIX : 'mla_' ) . '_options_';
3360
  $prefix_length = strlen( $prefix );
3361
  $backup_files = array();
3367
  $backup_files [ $text ] = $file;
3368
  }
3369
  }
3370
+
3371
+ if ( empty( $backup_files ) ) {
3372
  return '';
3373
+ }
3374
 
3375
  $option_values = array(
3376
  'value' => 'none',
3377
+ 'text' => '&mdash; ' . __( 'select settings', 'media-library-assistant' ) . ' &mdash;',
3378
  'selected' => 'selected="selected"'
3379
  );
3380
+
3381
  $select_options = MLAData::mla_parse_template( self::$page_template_array['select-option'], $option_values );
3382
  foreach ( $backup_files as $text => $file ) {
3383
  $option_values = array(
3385
  'text' => esc_html( $text ),
3386
  'selected' => ''
3387
  );
3388
+
3389
  $select_options .= MLAData::mla_parse_template( self::$page_template_array['select-option'], $option_values );
3390
  }
3391
+
3392
  $option_values = array(
3393
  'key' => 'mla-import-settings-file',
3394
  'options' => $select_options
3395
  );
3396
+
3397
+ return '<input name="mla-general-options-import" type="submit" class="button-primary" value="' . __( 'Import ALL Settings', 'media-library-assistant' ) . '" />' . MLAData::mla_parse_template( self::$page_template_array['select-only'], $option_values );
3398
  } // _compose_import_settings
3399
+
3400
  /**
3401
  * Serialize option settings and write them to a file
3402
  *
3419
  if ( false !== $stored_value ) {
3420
  $settings[ $key ] = $stored_value;
3421
  $stored_count++;
3422
+ $message = "<br>{$key} " . _x( 'exported', 'message_list', 'media-library-assistant' );
3423
+ } else {
3424
+ $message = "<br>{$key} " . _x( 'skipped', 'message_list', 'media-library-assistant' );
3425
  }
3426
+
 
 
3427
  $message_list .= $message;
3428
  }
3429
+
3430
  $settings = serialize( $settings );
3431
+ $page_content = array( 'message' => __( 'ALL settings exported.', 'media-library-assistant' ), 'body' => '' );
3432
+
3433
  /*
3434
  * Make sure the directory exists and is writable, then create the file
3435
  */
3436
  $prefix = ( defined( MLA_OPTION_PREFIX ) ) ? MLA_OPTION_PREFIX : 'mla_';
3437
  $date = date("Ymd_B");
3438
  $filename = MLA_BACKUP_DIR . "{$prefix}_options_{$date}.txt";
3439
+
3440
  if ( ! file_exists( MLA_BACKUP_DIR ) && ! @mkdir( MLA_BACKUP_DIR ) ) {
3441
+ /* translators: 1: backup directory name */
3442
+ $page_content['message'] = sprintf( __( 'ERROR: The settings directory ( %1$s ) cannot be created.', 'media-library-assistant' ), MLA_BACKUP_DIR );
3443
  return $page_content;
3444
+ } elseif ( ! is_writable( MLA_BACKUP_DIR ) && ! @chmod( MLA_BACKUP_DIR , '0777') ) {
3445
+ /* translators: 1: backup directory name */
3446
+ $page_content['message'] = sprintf( __( 'ERROR: The settings directory ( %1$s ) is not writable.', 'media-library-assistant' ), MLA_BACKUP_DIR );
3447
  return $page_content;
3448
  }
3449
+
3450
+ if ( ! file_exists( MLA_BACKUP_DIR . 'index.php') ) {
3451
  @ touch( MLA_BACKUP_DIR . 'index.php');
3452
+ }
3453
 
3454
  $file_pointer = @fopen( $filename, 'w' );
3455
+ if ( ! $file_pointer ) {
3456
+ /* translators: 1: backup file name */
3457
+ $page_content['message'] = sprintf( __( 'ERROR: The settings file ( %1$s ) could not be opened.', 'media-library-assistant' ), $filename );
3458
  return $page_content;
3459
  }
3460
+
3461
+ if (false === @fwrite($file_pointer, $settings)) {
3462
  $error_info = error_get_last();
3463
+ /* translators: 1: PHP error information */
3464
+ error_log( sprintf( _x( 'ERROR: _export_settings $error_info = "%1$s".', 'error_log', 'media-library-assistant' ), var_export( $error_info, true ) ), 0 );
3465
 
3466
+ if ( false !== ( $tail = strpos( $error_info['message'], '</a>]: ' ) ) ) {
3467
  $php_errormsg = ':<br>' . substr( $error_info['message'], $tail + 7 );
3468
+ } else {
3469
  $php_errormsg = '.';
3470
+ }
3471
+
3472
+ /* translators: 1: backup file name 2: error message*/
3473
+ $page_content['message'] = sprintf( __( 'ERROR: Writing the settings file ( %1$s ) "%2$s".', 'media-library-assistant' ), $filename, $php_errormsg );
3474
  }
3475
 
3476
  fclose($file_pointer);
3477
 
3478
+ /* translators: 1: number of option settings */
3479
+ $page_content['message'] = sprintf( __( 'Settings exported; %1$s settings recorded.', 'media-library-assistant' ), $stored_count );
3480
+
3481
  /*
3482
  * Uncomment this for debugging.
3483
  */
3485
 
3486
  return $page_content;
3487
  } // _export_settings
3488
+
3489
  /**
3490
  * Read a serialized file of option settings and write them to the database
3491
  *
3494
  * @return array Message(s) reflecting the results of the operation
3495
  */
3496
  private static function _import_settings( ) {
3497
+ $page_content = array( 'message' => __( 'No settings imported.', 'media-library-assistant' ), 'body' => '' );
3498
  $message_list = '';
3499
 
3500
  if ( isset( $_REQUEST['mla-import-settings-file'] ) ) {
3501
  $filename = $_REQUEST['mla-import-settings-file'];
3502
+
3503
+ if ( 'none' != $filename ) {
3504
  $filename = MLA_BACKUP_DIR . $filename;
3505
+ } else {
3506
+ $page_content['message'] = __( 'Please select an import settings file from the dropdown list.', 'media-library-assistant' );
3507
  return $page_content;
3508
  }
3509
+ } else {
3510
+ $page_content['message'] = __( 'ERROR: The import settings dropdown selection is missing.', 'media-library-assistant' );
 
3511
  return $page_content;
3512
  }
3513
+
3514
  $settings = @file_get_contents( $filename, false );
3515
+ if ( false === $settings ) {
3516
  $error_info = error_get_last();
3517
+ /* translators: 1: PHP error information */
3518
+ error_log( sprintf( _x( 'ERROR: _import_settings $error_info = "%1$s".', 'error_log', 'media-library-assistant' ), var_export( $error_info, true ) ), 0 );
3519
 
3520
+ if ( false !== ( $tail = strpos( $error_info['message'], '</a>]: ' ) ) ) {
3521
  $php_errormsg = ':<br>' . substr( $error_info['message'], $tail + 7 );
3522
+ } else {
3523
  $php_errormsg = '.';
3524
+ }
3525
+
3526
+ /* translators: 1: backup file name 2: error message*/
3527
+ $page_content['message'] = sprintf( __( 'ERROR: Reading the settings file ( %1$s ) "%2$s".', 'media-library-assistant' ), $filename, $php_errormsg );
3528
  return $page_content;
3529
  }
3530
 
3534
  foreach ( $settings as $key => $value ) {
3535
  if ( MLAOptions::mla_update_option( $key, $value ) ) {
3536
  $updated_count++;
3537
+ $message_list .= "<br>{$key} " . _x( 'updated', 'message_list', 'media-library-assistant' );
3538
+ } else {
 
3539
  $unchanged_count++;
3540
+ $message_list .= "<br>{$key} " . _x( 'unchanged', 'message_list', 'media-library-assistant' );
3541
  }
3542
  }
3543
+
3544
+ /* translators: 1: number of option settings updated 2: number of option settings unchanged */
3545
+ $page_content['message'] = sprintf( __( 'Settings imported; %1$s updated, %2$s unchanged.', 'media-library-assistant' ), $updated_count, $unchanged_count );
3546
+
3547
  /*
3548
  * Uncomment this for debugging.
3549
  */
3550
  //$page_content['message'] .= $message_list;
3551
+
3552
  return $page_content;
3553
  } // _import_settings
3554
  } // class MLASettings
includes/class-mla-shortcodes.php CHANGED
@@ -35,20 +35,21 @@ class MLAShortcodes {
35
  */
36
  public static function mla_attachment_list_shortcode( /* $atts */ ) {
37
  global $wpdb;
38
-
39
  /* extract(shortcode_atts(array(
40
  'item_type'=>'attachment',
41
  'organize_by'=>'title',
42
  ), $atts)); */
43
-
44
  /*
45
  * Process the where-used settings option
46
  */
47
- if ('checked' == MLAOptions::mla_get_option( MLAOptions::MLA_EXCLUDE_REVISIONS ) )
48
  $exclude_revisions = "(post_type <> 'revision') AND ";
49
- else
50
  $exclude_revisions = '';
51
-
 
52
  $attachments = $wpdb->get_results(
53
  "
54
  SELECT ID, post_title, post_name, post_parent
@@ -56,12 +57,12 @@ class MLAShortcodes {
56
  WHERE {$exclude_revisions}post_type = 'attachment'
57
  "
58
  );
59
-
60
  foreach ( $attachments as $attachment ) {
61
  $references = MLAData::mla_fetch_attachment_references( $attachment->ID, $attachment->post_parent );
62
-
63
  echo '&nbsp;<br><h3>' . $attachment->ID . ', ' . esc_attr( $attachment->post_title ) . ', Parent: ' . $attachment->post_parent . '<br>' . esc_attr( $attachment->post_name ) . '<br>' . esc_html( $references['base_file'] ) . "</h3>\r\n";
64
-
65
  /*
66
  * Look for the "Featured Image(s)"
67
  */
@@ -71,16 +72,16 @@ class MLAShortcodes {
71
  echo "&nbsp;&nbsp;&nbsp;&nbsp;Featured in<br>\r\n";
72
  foreach ( $references['features'] as $feature_id => $feature ) {
73
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
74
-
75
  if ( $feature_id == $attachment->post_parent ) {
76
  echo 'PARENT ';
77
  $found_parent = true;
78
  }
79
-
80
  echo $feature_id . ' (' . $feature->post_type . '), ' . esc_attr( $feature->post_title ) . "<br>\r\n";
81
  }
82
  }
83
-
84
  /*
85
  * Look for item(s) inserted in post_content
86
  */
@@ -91,40 +92,43 @@ class MLAShortcodes {
91
  echo '&nbsp;&nbsp;&nbsp;&nbsp;' . $file . " inserted in<br>\r\n";
92
  foreach ( $inserts as $insert ) {
93
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
94
-
95
  if ( $insert->ID == $attachment->post_parent ) {
96
  echo 'PARENT ';
97
  $found_parent = true;
98
  }
99
-
100
  echo $insert->ID . ' (' . $insert->post_type . '), ' . esc_attr( $insert->post_title ) . "<br>\r\n";
101
  } // foreach $insert
102
  } // foreach $file
103
  }
104
-
105
  $errors = '';
106
-
107
- if ( !$references['found_reference'] )
108
  $errors .= '(ORPHAN) ';
109
-
110
- if ( $references['is_unattached'] )
 
111
  $errors .= '(UNATTACHED) ';
112
- else {
113
  if ( !$references['found_parent'] ) {
114
- if ( isset( $references['parent_title'] ) )
115
  $errors .= '(BAD PARENT) ';
116
- else
117
  $errors .= '(INVALID PARENT) ';
 
118
  }
119
  }
120
-
121
- if ( !empty( $errors ) )
122
  echo '&nbsp;&nbsp;&nbsp;&nbsp;' . $errors . "<br>\r\n";
 
123
  } // foreach attachment
124
-
125
  echo "<br>----- End of Report -----\r\n";
126
  }
127
-
128
  /**
129
  * Accumulates debug messages
130
  *
@@ -133,7 +137,7 @@ class MLAShortcodes {
133
  * @var string
134
  */
135
  public static $mla_debug_messages = '';
136
-
137
  /**
138
  * Turn debug collection and display on or off
139
  *
@@ -142,7 +146,7 @@ class MLAShortcodes {
142
  * @var boolean
143
  */
144
  private static $mla_debug = false;
145
-
146
  /**
147
  * The MLA Gallery shortcode.
148
  *
@@ -163,23 +167,26 @@ class MLAShortcodes {
163
  /*
164
  * Some do_shortcode callers may not have a specific post in mind
165
  */
166
- if ( ! is_object( $post ) )
167
  $post = (object) array( 'ID' => 0 );
168
-
 
169
  /*
170
  * Make sure $attr is an array, even if it's empty
171
  */
172
- if ( empty( $attr ) )
173
  $attr = array();
174
- elseif ( is_string( $attr ) )
175
  $attr = shortcode_parse_atts( $attr );
 
176
 
177
  /*
178
  * The mla_paginate_current parameter can be changed to support multiple galleries per page.
179
  */
180
- if ( ! isset( $attr['mla_page_parameter'] ) )
181
  $attr['mla_page_parameter'] = self::$mla_get_shortcode_attachments_parameters['mla_page_parameter'];
182
-
 
183
  $mla_page_parameter = $attr['mla_page_parameter'];
184
 
185
  /*
@@ -187,9 +194,11 @@ class MLAShortcodes {
187
  * "MLA pagination" easier. Look for this parameter in $_REQUEST
188
  * if it's not present in the shortcode itself.
189
  */
190
- if ( ! isset( $attr[ $mla_page_parameter ] ) )
191
- if ( isset( $_REQUEST[ $mla_page_parameter ] ) )
192
  $attr[ $mla_page_parameter ] = $_REQUEST[ $mla_page_parameter ];
 
 
193
 
194
  /*
195
  * These are the parameters for gallery display
@@ -206,7 +215,7 @@ class MLAShortcodes {
206
  'mla_image_attributes' => '',
207
  'mla_caption' => ''
208
  );
209
-
210
  $mla_arguments = array_merge( array(
211
  'mla_output' => 'gallery',
212
  'mla_style' => MLAOptions::mla_get_option('default_style'),
@@ -222,7 +231,7 @@ class MLAShortcodes {
222
  'mla_viewer_width' => '150',
223
  'mla_alt_shortcode' => NULL,
224
  'mla_alt_ids_name' => 'ids',
225
-
226
  // paginatation arguments defined in $mla_get_shortcode_attachments_parameters
227
  // 'mla_page_parameter' => 'mla_paginate_current', handled in code with $mla_page_parameter
228
  // 'mla_paginate_current' => NULL,
@@ -231,12 +240,12 @@ class MLAShortcodes {
231
 
232
  'mla_end_size'=> 1,
233
  'mla_mid_size' => 2,
234
- 'mla_prev_text' => '&laquo; Previous',
235
- 'mla_next_text' => 'Next &raquo;',
236
  'mla_paginate_type' => 'plain'),
237
  $mla_item_specific_arguments
238
  );
239
-
240
  $default_arguments = array_merge( array(
241
  'size' => 'thumbnail', // or 'medium', 'large', 'full' or registered size
242
  'itemtag' => 'dl',
@@ -259,7 +268,7 @@ class MLAShortcodes {
259
  'pause' => NULL),
260
  $mla_arguments
261
  );
262
-
263
  /*
264
  * Look for 'request' substitution parameters,
265
  * which can be added to any input parameter
@@ -269,16 +278,18 @@ class MLAShortcodes {
269
  * attachment-specific Gallery Display Content parameters must be evaluated
270
  * later, when all of the information is available.
271
  */
272
- if ( array_key_exists( $attr_key, $mla_item_specific_arguments ) )
273
  continue;
274
-
 
275
  $attr_value = str_replace( '{+', '[+', str_replace( '+}', '+]', $attr_value ) );
276
  $replacement_values = MLAData::mla_expand_field_level_parameters( $attr_value );
277
 
278
- if ( ! empty( $replacement_values ) )
279
  $attr[ $attr_key ] = MLAData::mla_parse_template( $attr_value, $replacement_values );
 
280
  }
281
-
282
  /*
283
  * Merge gallery arguments with defaults, pass the query arguments on to mla_get_shortcode_attachments.
284
  */
@@ -287,7 +298,7 @@ class MLAShortcodes {
287
  $content = apply_filters( 'mla_gallery_initial_content', $content, $attr );
288
  $arguments = shortcode_atts( $default_arguments, $attr );
289
  $arguments = apply_filters( 'mla_gallery_arguments', $arguments );
290
-
291
  self::$mla_debug = !empty( $arguments['mla_debug'] ) && ( 'true' == strtolower( $arguments['mla_debug'] ) );
292
 
293
  /*
@@ -296,26 +307,26 @@ class MLAShortcodes {
296
  $output_parameters = array_map( 'strtolower', array_map( 'trim', explode( ',', $arguments['mla_output'] ) ) );
297
  $is_gallery = 'gallery' == $output_parameters[0];
298
  $is_pagination = in_array( $output_parameters[0], array( 'previous_page', 'next_page', 'paginate_links' ) );
299
-
300
  $attachments = self::mla_get_shortcode_attachments( $post->ID, $attr, $is_pagination );
301
-
302
- if ( is_string( $attachments ) )
303
  return $attachments;
304
-
 
305
  if ( empty($attachments) ) {
306
  if ( self::$mla_debug ) {
307
- $output = '<p><strong>mla_debug empty gallery</strong>, query = ' . var_export( $attr, true ) . '</p>';
308
  $output .= self::$mla_debug_messages;
309
  self::$mla_debug_messages = '';
310
- }
311
- else {
312
  $output = '';
313
  }
314
-
315
  $output .= $arguments['mla_nolink_text'];
316
  return $output;
317
  } // empty $attachments
318
-
319
  /*
320
  * Look for user-specified alternate gallery shortcode
321
  */
@@ -329,28 +340,28 @@ class MLAShortcodes {
329
  if ( array_key_exists( $key, $blacklist ) ) {
330
  continue;
331
  }
332
-
333
  $slashed = addcslashes( $value, chr(0).chr(7).chr(8)."\f\n\r\t\v\"\\\$" );
334
  if ( ( false !== strpos( $value, ' ' ) ) || ( false !== strpos( $value, '\'' ) ) || ( $slashed != $value ) ) {
335
  $value = '"' . $slashed . '"';
336
  }
337
-
338
  $new_args .= empty( $new_args ) ? $key . '=' . $value : ' ' . $key . '=' . $value;
339
  } // foreach $attr
340
-
341
  $new_ids = '';
342
  foreach ( $attachments as $value ) {
343
  $new_ids .= empty( $new_ids ) ? (string) $value->ID : ',' . $value->ID;
344
  } // foreach $attachments
345
 
346
  $new_ids = $arguments['mla_alt_ids_name'] . '="' . $new_ids . '"';
347
-
348
  if ( self::$mla_debug ) {
349
  $output = self::$mla_debug_messages;
350
  self::$mla_debug_messages = '';
351
- }
352
- else
353
  $output = '';
 
354
  /*
355
  * Execute the alternate gallery shortcode with the new parameters
356
  */
@@ -366,35 +377,38 @@ class MLAShortcodes {
366
  * Look for Photonic-enhanced gallery
367
  */
368
  global $photonic;
369
-
370
  if ( is_object( $photonic ) && ! empty( $arguments['style'] ) ) {
371
- if ( 'default' != strtolower( $arguments['type'] ) )
372
- return '<p><strong>Photonic-enhanced [mla_gallery]</strong> type must be <strong>default</strong>, query = ' . var_export( $attr, true ) . '</p>';
 
373
 
374
  $images = array();
375
  foreach ($attachments as $key => $val) {
376
  $images[$val->ID] = $attachments[$key];
377
  }
378
-
379
- if ( isset( $arguments['pause'] ) && ( 'false' == $arguments['pause'] ) )
380
  $arguments['pause'] = NULL;
 
381
 
382
  $output = $photonic->build_gallery( $images, $arguments['style'], $arguments );
383
  return $output;
384
  }
385
-
386
  $size = $size_class = $arguments['size'];
387
  if ( 'icon' == strtolower( $size) ) {
388
- if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) )
389
  $size = array( 64, 64 );
390
- else
391
  $size = array( 60, 60 );
392
-
 
393
  $show_icon = true;
394
- }
395
- else
396
  $show_icon = false;
397
-
 
398
  /*
399
  * Feeds such as RSS, Atom or RDF do not require styled and formatted output
400
  */
@@ -414,7 +428,7 @@ class MLAShortcodes {
414
  $arguments['mla_viewer_page'] = absint( $arguments['mla_viewer_page'] );
415
  $arguments['mla_viewer_width'] = absint( $arguments['mla_viewer_width'] );
416
  }
417
-
418
  // $instance supports multiple galleries in one page/post
419
  static $instance = 0;
420
  $instance++;
@@ -428,34 +442,38 @@ class MLAShortcodes {
428
 
429
  $columns = absint( $arguments['columns'] );
430
  $margin_string = strtolower( trim( $arguments['mla_margin'] ) );
431
-
432
- if ( is_numeric( $margin_string ) && ( 0 != $margin_string) )
433
  $margin_string .= '%'; // Legacy values are always in percent
434
-
435
- if ( '%' == substr( $margin_string, -1 ) )
 
436
  $margin_percent = (float) substr( $margin_string, 0, strlen( $margin_string ) - 1 );
437
- else
438
  $margin_percent = 0;
439
-
 
440
  $width_string = strtolower( trim( $arguments['mla_itemwidth'] ) );
441
  if ( 'none' != $width_string ) {
442
  switch ( $width_string ) {
443
  case 'exact':
444
  $margin_percent = 0;
445
- /* fallthru */
446
  case 'calculate':
447
  $width_string = $columns > 0 ? (floor(1000/$columns)/10) - ( 2.0 * $margin_percent ) : 100 - ( 2.0 * $margin_percent );
448
- /* fallthru */
449
  default:
450
- if ( is_numeric( $width_string ) && ( 0 != $width_string) )
451
  $width_string .= '%'; // Legacy values are always in percent
 
452
  }
453
  } // $use_width
454
-
455
  $float = strtolower( $arguments['mla_float'] );
456
- if ( ! in_array( $float, array( 'left', 'none', 'right' ) ) )
457
  $float = is_rtl() ? 'right' : 'left';
458
-
 
459
  $style_values = array(
460
  'mla_style' => $arguments['mla_style'],
461
  'mla_markup' => $arguments['mla_markup'],
@@ -484,7 +502,7 @@ class MLAShortcodes {
484
  $style_template = MLAOptions::mla_fetch_gallery_template( 'default', 'style' );
485
  }
486
  }
487
-
488
  if ( ! empty ( $style_template ) ) {
489
  /*
490
  * Look for 'query' and 'request' substitution parameters
@@ -503,12 +521,12 @@ class MLAShortcodes {
503
  $style_values['itemwidth'] = 'auto';
504
  $style_template = preg_replace( '/width:[\s]*\[\+itemwidth\+\][\%]*[\;]*/', '', $style_template );
505
  }
506
-
507
  $style_values = apply_filters( 'mla_gallery_style_values', $style_values );
508
  $style_template = apply_filters( 'mla_gallery_style_template', $style_template );
509
  $gallery_style = MLAData::mla_parse_template( $style_template, $style_values );
510
  $gallery_style = apply_filters( 'mla_gallery_style_parse', $gallery_style, $style_template, $style_values );
511
-
512
  /*
513
  * Clean up the styles to resolve extra "%" suffixes on width or margin (pre v1.42 values)
514
  */
@@ -517,7 +535,7 @@ class MLAShortcodes {
517
  $gallery_style = preg_replace( $preg_pattern, $preg_replacement, $gallery_style );
518
  } // !empty template
519
  } // use_mla_gallery_style
520
-
521
  $upload_dir = wp_upload_dir();
522
  $markup_values = $style_values;
523
  $markup_values['site_url'] = site_url();
@@ -535,82 +553,91 @@ class MLAShortcodes {
535
  $open_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-open', 'markup' );
536
  }
537
  }
538
- if ( empty( $open_template ) )
539
  $open_template = '';
 
540
 
541
  $row_open_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-row-open', 'markup' );
542
- if ( empty( $row_open_template ) )
543
  $row_open_template = '';
544
-
 
545
  $item_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-item', 'markup' );
546
- if ( empty( $item_template ) )
547
  $item_template = '';
 
548
 
549
  $row_close_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-row-close', 'markup' );
550
- if ( empty( $row_close_template ) )
551
  $row_close_template = '';
552
-
 
553
  $close_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-close', 'markup' );
554
- if ( empty( $close_template ) )
555
  $close_template = '';
 
556
 
557
  /*
558
  * Look for gallery-level markup substitution parameters
559
  */
560
  $new_text = $open_template . $row_open_template . $row_close_template . $close_template;
561
-
562
  $markup_values = MLAData::mla_expand_field_level_parameters( $new_text, $attr, $markup_values );
563
 
564
  if ( self::$mla_debug ) {
565
  $output = self::$mla_debug_messages;
566
  self::$mla_debug_messages = '';
567
- }
568
- else
569
  $output = '';
 
570
 
571
  if ($is_gallery ) {
572
  $markup_values = apply_filters( 'mla_gallery_open_values', $markup_values );
573
 
574
  $open_template = apply_filters( 'mla_gallery_open_template', $open_template );
575
- if ( empty( $open_template ) )
576
  $gallery_open = '';
577
- else
578
  $gallery_open = MLAData::mla_parse_template( $open_template, $markup_values );
 
579
 
580
  $gallery_open = apply_filters( 'mla_gallery_open_parse', $gallery_open, $open_template, $markup_values );
581
  $output .= apply_filters( 'mla_gallery_style', $gallery_style . $gallery_open, $style_values, $markup_values, $style_template, $open_template );
582
- }
583
- else {
584
- if ( ! isset( $attachments['found_rows'] ) )
585
  $attachments['found_rows'] = 0;
586
-
 
587
  /*
588
  * Handle 'previous_page', 'next_page', and 'paginate_links'
589
  */
590
  $pagination_result = self::_process_pagination_output_types( $output_parameters, $markup_values, $arguments, $attr, $attachments['found_rows'], $output );
591
- if ( false !== $pagination_result )
592
  return $pagination_result;
593
-
 
594
  unset( $attachments['found_rows'] );
595
  }
596
-
597
  /*
598
  * For "previous_link", "current_link" and "next_link", discard all of the $attachments except the appropriate choice
599
  */
600
  if ( ! $is_gallery ) {
601
  $link_type = $output_parameters[0];
602
-
603
- if ( ! in_array( $link_type, array ( 'previous_link', 'current_link', 'next_link' ) ) )
604
- return ''; // unknown outtput type
605
-
 
606
  $is_wrap = isset( $output_parameters[1] ) && 'wrap' == $output_parameters[1];
607
  $current_id = empty( $arguments['id'] ) ? $markup_values['id'] : $arguments['id'];
608
-
609
  foreach ( $attachments as $id => $attachment ) {
610
- if ( $attachment->ID == $current_id )
611
  break;
 
612
  }
613
-
614
  switch ( $link_type ) {
615
  case 'previous_link':
616
  $target_id = $id - 1;
@@ -622,12 +649,11 @@ class MLAShortcodes {
622
  default:
623
  $target_id = $id;
624
  } // link_type
625
-
626
  $target = NULL;
627
  if ( isset( $attachments[ $target_id ] ) ) {
628
  $target = $attachments[ $target_id ];
629
- }
630
- elseif ( $is_wrap ) {
631
  switch ( $link_type ) {
632
  case 'previous_link':
633
  $target = array_pop( $attachments );
@@ -637,20 +663,21 @@ class MLAShortcodes {
637
  } // link_type
638
  } // is_wrap
639
 
640
- if ( isset( $target ) )
641
  $attachments = array( $target );
642
- elseif ( ! empty( $arguments['mla_nolink_text'] ) )
643
  return self::_process_shortcode_parameter( $arguments['mla_nolink_text'], $markup_values ) . '</a>';
644
- else
645
  return '';
646
- } // ! is_gallery
647
- else
648
  $link_type= '';
649
-
 
650
  $column_index = 0;
651
  foreach ( $attachments as $id => $attachment ) {
652
  $item_values = $markup_values;
653
-
654
  /*
655
  * fill in item-specific elements
656
  */
@@ -663,7 +690,7 @@ class MLAShortcodes {
663
  $item_values['date'] = $attachment->post_date;
664
  $item_values['modified'] = $attachment->post_modified;
665
  $item_values['parent'] = $attachment->post_parent;
666
- $item_values['parent_title'] = '(unattached)';
667
  $item_values['parent_type'] = '';
668
  $item_values['parent_date'] = '';
669
  $item_values['title'] = wptexturize( $attachment->post_title );
@@ -679,12 +706,13 @@ class MLAShortcodes {
679
  $item_values['description'] = wptexturize( $attachment->post_content );
680
  $item_values['file_url'] = wptexturize( $attachment->guid );
681
  $item_values['author_id'] = $attachment->post_author;
682
-
683
  $user = get_user_by( 'id', $attachment->post_author );
684
- if ( isset( $user->data->display_name ) )
685
  $item_values['author'] = wptexturize( $user->data->display_name );
686
- else
687
- $item_values['author'] = 'unknown';
 
688
 
689
  $post_meta = MLAData::mla_fetch_attachment_metadata( $attachment->ID );
690
  $base_file = $post_meta['mla_wp_attached_file'];
@@ -693,24 +721,28 @@ class MLAShortcodes {
693
  if ( !empty( $post_meta['mla_wp_attachment_metadata']['width'] ) ) {
694
  $item_values['width'] = $post_meta['mla_wp_attachment_metadata']['width'];
695
  $width = absint( $item_values['width'] );
696
- }
697
- else
698
  $width = 0;
699
-
 
700
  if ( !empty( $post_meta['mla_wp_attachment_metadata']['height'] ) ) {
701
  $item_values['height'] = $post_meta['mla_wp_attachment_metadata']['height'];
702
  $height = absint( $item_values['height'] );
703
- }
704
- else
705
  $height = 0;
706
-
707
- if ( $width && $height )
 
708
  $item_values['orientation'] = ( $height > $width ) ? 'portrait' : 'landscape';
 
709
 
710
- if ( !empty( $post_meta['mla_wp_attachment_metadata']['image_meta'] ) )
711
  $item_values['image_meta'] = wptexturize( var_export( $post_meta['mla_wp_attachment_metadata']['image_meta'], true ) );
712
- if ( !empty( $post_meta['mla_wp_attachment_image_alt'] ) )
 
 
713
  $item_values['image_alt'] = wptexturize( $post_meta['mla_wp_attachment_image_alt'] );
 
714
 
715
  if ( ! empty( $base_file ) ) {
716
  $last_slash = strrpos( $base_file, '/' );
@@ -718,27 +750,29 @@ class MLAShortcodes {
718
  $file_name = $base_file;
719
  $item_values['base_file'] = wptexturize( $base_file );
720
  $item_values['file'] = wptexturize( $base_file );
721
- }
722
- else {
723
  $file_name = substr( $base_file, $last_slash + 1 );
724
  $item_values['base_file'] = wptexturize( $base_file );
725
  $item_values['path'] = wptexturize( substr( $base_file, 0, $last_slash + 1 ) );
726
  $item_values['file'] = wptexturize( $file_name );
727
  }
728
- }
729
- else
730
  $file_name = '';
 
731
 
732
  $parent_info = MLAData::mla_fetch_attachment_parent_data( $attachment->post_parent );
733
- if ( isset( $parent_info['parent_title'] ) )
734
  $item_values['parent_title'] = wptexturize( $parent_info['parent_title'] );
735
-
736
- if ( isset( $parent_info['parent_date'] ) )
 
737
  $item_values['parent_date'] = wptexturize( $parent_info['parent_date'] );
738
-
739
- if ( isset( $parent_info['parent_type'] ) )
 
740
  $item_values['parent_type'] = wptexturize( $parent_info['parent_type'] );
741
-
 
742
  /*
743
  * Add attachment-specific field-level substitution parameters
744
  */
@@ -746,21 +780,23 @@ class MLAShortcodes {
746
  foreach( $mla_item_specific_arguments as $index => $value ) {
747
  $new_text .= str_replace( '{+', '[+', str_replace( '+}', '+]', $arguments[ $index ] ) );
748
  }
749
-
750
  $item_values = MLAData::mla_expand_field_level_parameters( $new_text, $attr, $item_values, $attachment->ID );
751
 
752
  if ( $item_values['captiontag'] ) {
753
  $item_values['caption'] = wptexturize( $attachment->post_excerpt );
754
- if ( ! empty( $arguments['mla_caption'] ) )
755
  $item_values['caption'] = wptexturize( self::_process_shortcode_parameter( $arguments['mla_caption'], $item_values ) );
756
- }
757
- else
758
  $item_values['caption'] = '';
759
-
760
- if ( ! empty( $arguments['mla_link_text'] ) )
 
761
  $link_text = self::_process_shortcode_parameter( $arguments['mla_link_text'], $item_values );
762
- else
763
  $link_text = false;
 
764
 
765
  $item_values['pagelink'] = wp_get_attachment_link($attachment->ID, $size, true, $show_icon, $link_text);
766
  $item_values['filelink'] = wp_get_attachment_link($attachment->ID, $size, false, $show_icon, $link_text);
@@ -770,25 +806,28 @@ class MLAShortcodes {
770
  * Note that $link_attributes and $rollover_text
771
  * are used in the Google Viewer code below
772
  */
773
- if ( ! empty( $arguments['mla_target'] ) )
774
  $link_attributes = 'target="' . $arguments['mla_target'] . '" ';
775
- else
776
  $link_attributes = '';
777
-
778
- if ( ! empty( $arguments['mla_link_attributes'] ) )
 
779
  $link_attributes .= self::_process_shortcode_parameter( $arguments['mla_link_attributes'], $item_values ) . ' ';
 
780
 
781
- if ( ! empty( $arguments['mla_link_class'] ) )
782
  $link_attributes .= 'class="' . self::_process_shortcode_parameter( $arguments['mla_link_class'], $item_values ) . '" ';
 
783
 
784
  if ( ! empty( $link_attributes ) ) {
785
  $item_values['pagelink'] = str_replace( '<a href=', '<a ' . $link_attributes . 'href=', $item_values['pagelink'] );
786
  $item_values['filelink'] = str_replace( '<a href=', '<a ' . $link_attributes . 'href=', $item_values['filelink'] );
787
  }
788
-
789
  if ( ! empty( $arguments['mla_rollover_text'] ) ) {
790
  $rollover_text = esc_attr( self::_process_shortcode_parameter( $arguments['mla_rollover_text'], $item_values ) );
791
-
792
  /*
793
  * Replace single- and double-quote delimited values
794
  */
@@ -796,36 +835,39 @@ class MLAShortcodes {
796
  $item_values['pagelink'] = preg_replace('# title=\"([^\"]*)\"#', " title=\"{$rollover_text}\"", $item_values['pagelink'] );
797
  $item_values['filelink'] = preg_replace('# title=\'([^\']*)\'#', " title='{$rollover_text}'", $item_values['filelink'] );
798
  $item_values['filelink'] = preg_replace('# title=\"([^\"]*)\"#', " title=\"{$rollover_text}\"", $item_values['filelink'] );
799
- }
800
- else
801
  $rollover_text = $item_values['title'];
 
802
 
803
  /*
804
  * Process the <img> tag, if present
805
  * Note that $image_attributes, $image_class and $image_alt
806
  * are used in the Google Viewer code below
807
  */
808
- if ( ! empty( $arguments['mla_image_attributes'] ) )
809
  $image_attributes = self::_process_shortcode_parameter( $arguments['mla_image_attributes'], $item_values ) . ' ';
810
- else
811
  $image_attributes = '';
812
-
813
- if ( ! empty( $arguments['mla_image_class'] ) )
 
814
  $image_class = esc_attr( self::_process_shortcode_parameter( $arguments['mla_image_class'], $item_values ) );
815
- else
816
  $image_class = '';
 
817
 
818
- if ( ! empty( $arguments['mla_image_alt'] ) )
819
- $image_alt = esc_attr( self::_process_shortcode_parameter( $arguments['mla_image_alt'], $item_values ) );
820
- else
821
- $image_alt = '';
 
822
 
823
  if ( false !== strpos( $item_values['pagelink'], '<img ' ) ) {
824
  if ( ! empty( $image_attributes ) ) {
825
  $item_values['pagelink'] = str_replace( '<img ', '<img ' . $image_attributes, $item_values['pagelink'] );
826
  $item_values['filelink'] = str_replace( '<img ', '<img ' . $image_attributes, $item_values['filelink'] );
827
  }
828
-
829
  /*
830
  * Extract existing class values and add to them
831
  */
@@ -833,20 +875,20 @@ class MLAShortcodes {
833
  $match_count = preg_match_all( '# class=\"([^\"]+)\" #', $item_values['pagelink'], $matches, PREG_OFFSET_CAPTURE );
834
  if ( ! ( ( $match_count == false ) || ( $match_count == 0 ) ) ) {
835
  $class = $matches[1][0][0] . ' ' . $image_class;
836
- }
837
- else
838
  $class = $image_class;
839
-
 
840
  $item_values['pagelink'] = preg_replace('# class=\"([^\"]*)\"#', " class=\"{$class}\"", $item_values['pagelink'] );
841
  $item_values['filelink'] = preg_replace('# class=\"([^\"]*)\"#', " class=\"{$class}\"", $item_values['filelink'] );
842
  }
843
-
844
  if ( ! empty( $image_alt ) ) {
845
  $item_values['pagelink'] = preg_replace('# alt=\"([^\"]*)\"#', " alt=\"{$image_alt}\"", $item_values['pagelink'] );
846
  $item_values['filelink'] = preg_replace('# alt=\"([^\"]*)\"#', " alt=\"{$image_alt}\"", $item_values['filelink'] );
847
  }
848
  } // process <img> tag
849
-
850
  switch ( $arguments['link'] ) {
851
  case 'permalink':
852
  case 'post':
@@ -867,30 +909,30 @@ class MLAShortcodes {
867
  $item_values['link'] = str_replace( $file_name, $target_file, $item_values['filelink'] );
868
  }
869
  } // switch 'link'
870
-
871
  /*
872
  * Extract target and thumbnail fields
873
  */
874
  $match_count = preg_match_all( '#href=\'([^\']+)\'#', $item_values['pagelink'], $matches, PREG_OFFSET_CAPTURE );
875
  if ( ! ( ( $match_count == false ) || ( $match_count == 0 ) ) ) {
876
  $item_values['pagelink_url'] = $matches[1][0][0];
877
- }
878
- else
879
  $item_values['pagelink_url'] = '';
 
880
 
881
  $match_count = preg_match_all( '#href=\'([^\']+)\'#', $item_values['filelink'], $matches, PREG_OFFSET_CAPTURE );
882
  if ( ! ( ( $match_count == false ) || ( $match_count == 0 ) ) ) {
883
  $item_values['filelink_url'] = $matches[1][0][0];
884
- }
885
- else
886
  $item_values['filelink_url'] = '';
 
887
 
888
  $match_count = preg_match_all( '#href=\'([^\']+)\'#', $item_values['link'], $matches, PREG_OFFSET_CAPTURE );
889
  if ( ! ( ( $match_count == false ) || ( $match_count == 0 ) ) ) {
890
  $item_values['link_url'] = $matches[1][0][0];
891
- }
892
- else
893
  $item_values['link_url'] = '';
 
894
 
895
  /*
896
  * Override the link value; leave filelink and pagelink unchanged
@@ -904,24 +946,23 @@ class MLAShortcodes {
904
  */
905
  $item_values['link'] = preg_replace('# href=\'([^\']*)\'#', " href='{$link_href}'", $item_values['link'] );
906
  $item_values['link'] = preg_replace('# href=\"([^\"]*)\"#', " href=\"{$link_href}\"", $item_values['link'] );
907
- }
908
- else
909
  $link_href = '';
910
-
 
911
  $match_count = preg_match_all( '#\<a [^\>]+\>(.*)\</a\>#', $item_values['link'], $matches, PREG_OFFSET_CAPTURE );
912
  if ( ! ( ( $match_count == false ) || ( $match_count == 0 ) ) ) {
913
  $item_values['thumbnail_content'] = $matches[1][0][0];
914
- }
915
- else
916
  $item_values['thumbnail_content'] = '';
 
917
 
918
  $match_count = preg_match_all( '# width=\"([^\"]+)\" height=\"([^\"]+)\" src=\"([^\"]+)\" #', $item_values['link'], $matches, PREG_OFFSET_CAPTURE );
919
  if ( ! ( ( $match_count == false ) || ( $match_count == 0 ) ) ) {
920
  $item_values['thumbnail_width'] = $matches[1][0][0];
921
  $item_values['thumbnail_height'] = $matches[2][0][0];
922
  $item_values['thumbnail_url'] = $matches[3][0][0];
923
- }
924
- else {
925
  $item_values['thumbnail_width'] = '';
926
  $item_values['thumbnail_height'] = '';
927
  $item_values['thumbnail_url'] = '';
@@ -930,11 +971,12 @@ class MLAShortcodes {
930
  /*
931
  * Now that we have thumbnail_content we can check for 'span' and 'none'
932
  */
933
- if ( 'none' == $arguments['link'] )
934
  $item_values['link'] = $item_values['thumbnail_content'];
935
- elseif ( 'span' == $arguments['link'] )
936
  $item_values['link'] = sprintf( '<span %1$s>%2$s</span>', $link_attributes, $item_values['thumbnail_content'] );
937
-
 
938
  /*
939
  * Check for Google file viewer substitution, uses above-defined
940
  * $link_attributes (includes target), $rollover_text, $link_href (link only),
@@ -948,36 +990,39 @@ class MLAShortcodes {
948
  /*
949
  * <img> tag (thumbnail_text)
950
  */
951
- if ( ! empty( $image_class ) )
952
  $image_class = ' class="' . $image_class . '"';
953
-
954
- if ( ! empty( $image_alt ) )
 
955
  $image_alt = ' alt="' . $image_alt . '"';
956
- elseif ( ! empty( $item_values['caption'] ) )
957
  $image_alt = ' alt="' . $item_values['caption'] . '"';
 
958
 
959
  $item_values['thumbnail_content'] = sprintf( '<img %1$ssrc="http://docs.google.com/viewer?url=%2$s&a=bi&pagenumber=%3$d&w=%4$d"%5$s%6$s>', $image_attributes, $item_values['filelink_url'], $arguments['mla_viewer_page'], $arguments['mla_viewer_width'], $image_class, $image_alt );
960
-
961
  /*
962
  * Filelink, pagelink and link
963
  */
964
  $item_values['pagelink'] = sprintf( '<a %1$shref="%2$s" title="%3$s">%4$s</a>', $link_attributes, $item_values['pagelink_url'], $rollover_text, $item_values['thumbnail_content'] );
965
  $item_values['filelink'] = sprintf( '<a %1$shref="%2$s" title="%3$s">%4$s</a>', $link_attributes, $item_values['filelink_url'], $rollover_text, $item_values['thumbnail_content'] );
966
 
967
- if ( ! empty( $link_href ) )
968
  $item_values['link'] = sprintf( '<a %1$shref="%2$s" title="%3$s">%4$s</a>', $link_attributes, $link_href, $rollover_text, $item_values['thumbnail_content'] );
969
- elseif ( 'permalink' == $arguments['link'] )
970
  $item_values['link'] = $item_values['pagelink'];
971
- elseif ( 'file' == $arguments['link'] )
972
  $item_values['link'] = $item_values['filelink'];
973
- elseif ( 'span' == $arguments['link'] )
974
  $item_values['link'] = sprintf( '<a %1$s>%2$s</a>', $link_attributes, $item_values['thumbnail_content'] );
975
- else
976
  $item_values['link'] = $item_values['thumbnail_content'];
 
977
  } // viewer extension
978
  } // has extension
979
  } // mla_viewer
980
-
981
  if ($is_gallery ) {
982
  /*
983
  * Start of row markup
@@ -988,21 +1033,22 @@ class MLAShortcodes {
988
  $parse_value = MLAData::mla_parse_template( $row_open_template, $markup_values );
989
  $output .= apply_filters( 'mla_gallery_row_open_parse', $parse_value, $row_open_template, $markup_values );
990
  }
991
-
992
  /*
993
  * item markup
994
  */
995
  $column_index++;
996
- if ( $item_values['columns'] > 0 && $column_index % $item_values['columns'] == 0 )
997
  $item_values['last_in_row'] = 'last_in_row';
998
- else
999
  $item_values['last_in_row'] = '';
1000
-
 
1001
  $item_values = apply_filters( 'mla_gallery_item_values', $item_values );
1002
  $item_template = apply_filters( 'mla_gallery_item_template', $item_template );
1003
  $parse_value = MLAData::mla_parse_template( $item_template, $item_values );
1004
  $output .= apply_filters( 'mla_gallery_item_parse', $parse_value, $item_template, $item_values );
1005
-
1006
  /*
1007
  * End of row markup
1008
  */
@@ -1013,10 +1059,11 @@ class MLAShortcodes {
1013
  $output .= apply_filters( 'mla_gallery_row_close_parse', $parse_value, $row_close_template, $markup_values );
1014
  }
1015
  } // is_gallery
1016
- elseif ( ! empty( $link_type ) )
1017
  return $item_values['link'];
 
1018
  } // foreach attachment
1019
-
1020
  if ($is_gallery ) {
1021
  /*
1022
  * Close out partial row
@@ -1027,13 +1074,13 @@ class MLAShortcodes {
1027
  $parse_value = MLAData::mla_parse_template( $row_close_template, $markup_values );
1028
  $output .= apply_filters( 'mla_gallery_row_close_parse', $parse_value, $row_close_template, $markup_values );
1029
  }
1030
-
1031
  $markup_values = apply_filters( 'mla_gallery_close_values', $markup_values );
1032
  $close_template = apply_filters( 'mla_gallery_close_template', $close_template );
1033
  $parse_value = MLAData::mla_parse_template( $close_template, $markup_values );
1034
  $output .= apply_filters( 'mla_gallery_close_parse', $parse_value, $close_template, $markup_values );
1035
  } // is_gallery
1036
-
1037
  return $output;
1038
  }
1039
 
@@ -1063,7 +1110,7 @@ class MLAShortcodes {
1063
  'mla_rollover_text' => '',
1064
  'mla_caption' => ''
1065
  );
1066
-
1067
  $mla_arguments = array_merge( array(
1068
  'mla_output' => 'flat',
1069
  'mla_style' => NULL,
@@ -1078,15 +1125,15 @@ class MLAShortcodes {
1078
  'term_id' => NULL,
1079
  'mla_end_size'=> 1,
1080
  'mla_mid_size' => 2,
1081
- 'mla_prev_text' => '&laquo; Previous',
1082
- 'mla_next_text' => 'Next &raquo;',
1083
  'mla_page_parameter' => 'mla_cloud_current',
1084
  'mla_cloud_current' => NULL,
1085
  'mla_paginate_total' => NULL,
1086
  'mla_paginate_type' => 'plain'),
1087
  $mla_item_specific_arguments
1088
  );
1089
-
1090
  $defaults = array_merge(
1091
  self::$mla_get_terms_parameters,
1092
  array(
@@ -1099,7 +1146,7 @@ class MLAShortcodes {
1099
 
1100
  'echo' => false,
1101
  'link' => 'view',
1102
-
1103
  'itemtag' => 'ul',
1104
  'termtag' => 'li',
1105
  'captiontag' => '',
@@ -1107,13 +1154,14 @@ class MLAShortcodes {
1107
  ),
1108
  $mla_arguments
1109
  );
1110
-
1111
  /*
1112
  * The mla_paginate_current parameter can be changed to support multiple galleries per page.
1113
  */
1114
- if ( ! isset( $attr['mla_page_parameter'] ) )
1115
  $attr['mla_page_parameter'] = $defaults['mla_page_parameter'];
1116
-
 
1117
  $mla_page_parameter = $attr['mla_page_parameter'];
1118
 
1119
  /*
@@ -1121,9 +1169,11 @@ class MLAShortcodes {
1121
  * "MLA pagination" easier. Look for this parameter in $_REQUEST
1122
  * if it's not present in the shortcode itself.
1123
  */
1124
- if ( ! isset( $attr[ $mla_page_parameter ] ) )
1125
- if ( isset( $_REQUEST[ $mla_page_parameter ] ) )
1126
  $attr[ $mla_page_parameter ] = $_REQUEST[ $mla_page_parameter ];
 
 
1127
 
1128
  /*
1129
  * Look for 'request' substitution parameters,
@@ -1134,16 +1184,18 @@ class MLAShortcodes {
1134
  * item-specific Display Content parameters must be evaluated
1135
  * later, when all of the information is available.
1136
  */
1137
- if ( array_key_exists( $attr_key, $mla_item_specific_arguments ) )
1138
  continue;
1139
-
 
1140
  $attr_value = str_replace( '{+', '[+', str_replace( '+}', '+]', $attr_value ) );
1141
  $replacement_values = MLAData::mla_expand_field_level_parameters( $attr_value );
1142
 
1143
- if ( ! empty( $replacement_values ) )
1144
  $attr[ $attr_key ] = MLAData::mla_parse_template( $attr_value, $replacement_values );
 
1145
  }
1146
-
1147
  $attr = apply_filters( 'mla_tag_cloud_attributes', $attr );
1148
  $arguments = shortcode_atts( $defaults, $attr );
1149
 
@@ -1151,12 +1203,15 @@ class MLAShortcodes {
1151
  * $mla_page_parameter, if non-default, doesn't make it through the shortcode_atts filter,
1152
  * so we handle it separately
1153
  */
1154
- if ( ! isset( $arguments[ $mla_page_parameter ] ) )
1155
- if ( isset( $attr[ $mla_page_parameter ] ) )
1156
  $arguments[ $mla_page_parameter ] = $attr[ $mla_page_parameter ];
1157
- else
1158
  $arguments[ $mla_page_parameter ] = $defaults['mla_cloud_current'];
1159
 
 
 
 
1160
  /*
1161
  * Process the pagination parameter, if present
1162
  */
@@ -1168,22 +1223,23 @@ class MLAShortcodes {
1168
 
1169
  self::$mla_debug = !empty( $arguments['mla_debug'] ) && ( 'true' == strtolower( $arguments['mla_debug'] ) );
1170
  if ( self::$mla_debug ) {
1171
- self::$mla_debug_messages .= '<p><strong>mla_debug attributes</strong> = ' . var_export( $attr, true ) . '</p>';
1172
- self::$mla_debug_messages .= '<p><strong>mla_debug arguments</strong> = ' . var_export( $arguments, true ) . '</p>';
1173
  }
1174
 
1175
  /*
1176
  * Determine output type and templates
1177
  */
1178
  $output_parameters = array_map( 'strtolower', array_map( 'trim', explode( ',', $arguments['mla_output'] ) ) );
1179
-
1180
  if ( $is_grid = 'grid' == $output_parameters[0] ) {
1181
  $default_style = MLAOptions::mla_get_option('default_tag_cloud_style');
1182
  $default_markup = MLAOptions::mla_get_option('default_tag_cloud_markup');
1183
-
1184
- if ( NULL == $arguments['mla_style'] )
1185
  $arguments['mla_style'] = $default_style;
1186
-
 
1187
  if ( NULL == $arguments['mla_markup'] ) {
1188
  $arguments['mla_markup'] = $default_markup;
1189
  $arguments['itemtag'] = 'dl';
@@ -1191,102 +1247,116 @@ class MLAShortcodes {
1191
  $arguments['captiontag'] = 'dd';
1192
  }
1193
  }
1194
-
1195
  if ( $is_list = 'list' == $output_parameters[0] ) {
1196
  $default_style = 'none';
1197
  if ( empty( $arguments['captiontag'] ) ) {
1198
  $default_markup = 'tag-cloud-ul';
1199
  } else {
1200
  $default_markup = 'tag-cloud-dl';
1201
-
1202
  if ( 'dd' == $arguments['captiontag'] ) {
1203
  $arguments['itemtag'] = 'dl';
1204
  $arguments['termtag'] = 'dt';
1205
  }
1206
  }
1207
-
1208
- if ( NULL == $arguments['mla_style'] )
1209
  $arguments['mla_style'] = $default_style;
1210
-
1211
- if ( NULL == $arguments['mla_markup'] )
 
1212
  $arguments['mla_markup'] = $default_markup;
 
1213
  }
1214
-
1215
  $is_pagination = in_array( $output_parameters[0], array( 'previous_link', 'current_link', 'next_link', 'previous_page', 'next_page', 'paginate_links' ) );
1216
-
1217
  /*
1218
  * Convert taxonomy list to an array
1219
  */
1220
- if ( is_string( $arguments['taxonomy'] ) )
1221
  $arguments['taxonomy'] = explode( ',', $arguments['taxonomy'] );
 
1222
 
1223
  $tags = self::mla_get_terms( $arguments );
1224
-
1225
  if ( self::$mla_debug ) {
1226
  $cloud = self::$mla_debug_messages;
1227
  self::$mla_debug_messages = '';
1228
- }
1229
- else
1230
  $cloud = '';
 
1231
 
1232
  /*
1233
  * Invalid taxonomy names return WP_Error
1234
  */
1235
  if ( is_wp_error( $tags ) ) {
1236
- $cloud .= '<strong>ERROR: ' . $tags->get_error_message() . '</strong>, ' . $tags->get_error_data( $tags->get_error_code() );
1237
 
1238
- if ( 'array' == $arguments['mla_output'] )
1239
  return array( $cloud );
1240
-
1241
- if ( empty($arguments['echo']) )
 
1242
  return $cloud;
1243
-
 
1244
  echo $cloud;
1245
  return;
1246
  }
1247
-
1248
  if ( empty( $tags ) ) {
1249
  if ( self::$mla_debug ) {
1250
- $cloud .= '<p><strong>mla_debug empty cloud</strong>, query = ' . var_export( $arguments, true ) . '</p>';
1251
  }
1252
-
1253
  $cloud .= $arguments['mla_nolink_text'];
1254
- if ( 'array' == $arguments['mla_output'] )
1255
  return array( $cloud );
1256
-
1257
- if ( empty($arguments['echo']) )
 
1258
  return $cloud;
1259
-
 
1260
  echo $cloud;
1261
  return;
1262
  }
1263
-
1264
  /*
1265
  * Fill in the item_specific link properties, calculate cloud parameters
1266
  */
1267
- if( isset( $tags['found_rows'] ) ) {
1268
  $found_rows = $tags['found_rows'];
1269
  unset( $tags['found_rows'] );
1270
- } else
1271
  $found_rows = count( $tags );
1272
-
 
1273
  $min_count = 0x7FFFFFFF;
1274
  $max_count = 0;
1275
  $min_scaled_count = 0x7FFFFFFF;
1276
  $max_scaled_count = 0;
1277
  foreach ( $tags as $key => $tag ) {
1278
  $tag->scaled_count = apply_filters( 'mla_tag_cloud_scale', round(log10($tag->count + 1) * 100), $attr, $arguments, $tag );
1279
-
1280
- if ( $tag->count < $min_count )
1281
  $min_count = $tag->count;
1282
- if ( $tag->count > $max_count )
 
 
1283
  $max_count = $tag->count;
1284
-
1285
- if ( $tag->scaled_count < $min_scaled_count )
 
1286
  $min_scaled_count = $tag->scaled_count;
1287
- if ( $tag->scaled_count > $max_scaled_count )
 
 
1288
  $max_scaled_count = $tag->scaled_count;
1289
-
 
1290
  $link = get_edit_tag_link( $tag->term_id, $tag->taxonomy );
1291
  if ( ! is_wp_error( $link ) ) {
1292
  $tags[ $key ]->edit_link = $link;
@@ -1295,22 +1365,25 @@ class MLAShortcodes {
1295
  }
1296
 
1297
  if ( is_wp_error( $link ) ) {
1298
- $cloud = '<strong>ERROR: ' . $link->get_error_message() . '</strong>, ' . $link->get_error_data( $link->get_error_code() );
1299
-
1300
- if ( 'array' == $arguments['mla_output'] )
1301
  return array( $cloud );
1302
-
1303
- if ( empty($arguments['echo']) )
 
1304
  return $cloud;
1305
-
 
1306
  echo $cloud;
1307
  return;
1308
  }
1309
 
1310
- if ( 'edit' == $arguments['link'] )
1311
  $tags[ $key ]->link = $tags[ $key ]->edit_link;
1312
- else
1313
  $tags[ $key ]->link = $tags[ $key ]->term_link;
 
1314
  } // foreach tag
1315
 
1316
  // $instance supports multiple clouds in one page/post
@@ -1326,43 +1399,51 @@ class MLAShortcodes {
1326
 
1327
  $columns = absint( $arguments['columns'] );
1328
  $margin_string = strtolower( trim( $arguments['mla_margin'] ) );
1329
-
1330
- if ( is_numeric( $margin_string ) && ( 0 != $margin_string) )
1331
  $margin_string .= '%'; // Legacy values are always in percent
1332
-
1333
- if ( '%' == substr( $margin_string, -1 ) )
 
1334
  $margin_percent = (float) substr( $margin_string, 0, strlen( $margin_string ) - 1 );
1335
- else
1336
  $margin_percent = 0;
1337
-
 
1338
  $width_string = strtolower( trim( $arguments['mla_itemwidth'] ) );
1339
  if ( 'none' != $width_string ) {
1340
  switch ( $width_string ) {
1341
  case 'exact':
1342
  $margin_percent = 0;
1343
- /* fallthru */
1344
  case 'calculate':
1345
  $width_string = $columns > 0 ? (floor(1000/$columns)/10) - ( 2.0 * $margin_percent ) : 100 - ( 2.0 * $margin_percent );
1346
- /* fallthru */
1347
  default:
1348
- if ( is_numeric( $width_string ) && ( 0 != $width_string) )
1349
  $width_string .= '%'; // Legacy values are always in percent
 
1350
  }
1351
  } // $use_width
1352
-
1353
  $float = strtolower( $arguments['mla_float'] );
1354
- if ( ! in_array( $float, array( 'left', 'none', 'right' ) ) )
1355
  $float = is_rtl() ? 'right' : 'left';
 
1356
 
1357
  /*
1358
  * Calculate cloud parameters
1359
  */
1360
  $spread = $max_scaled_count - $min_scaled_count;
1361
- if ( $spread <= 0 )
1362
  $spread = 1;
 
 
1363
  $font_spread = $arguments['largest'] - $arguments['smallest'];
1364
- if ( $font_spread < 0 )
1365
  $font_spread = 1;
 
 
1366
  $font_step = $font_spread / $spread;
1367
 
1368
  $style_values = array(
@@ -1405,7 +1486,7 @@ class MLAShortcodes {
1405
  $style_values['mla_style'] = $default_style;
1406
  $style_template = MLAOptions::mla_fetch_gallery_template( $default_style, 'style' );
1407
  }
1408
-
1409
  if ( ! empty ( $style_template ) ) {
1410
  /*
1411
  * Look for 'query' and 'request' substitution parameters
@@ -1424,14 +1505,14 @@ class MLAShortcodes {
1424
  $style_values['itemwidth'] = 'auto';
1425
  $style_template = preg_replace( '/width:[\s]*\[\+itemwidth\+\][\%]*[\;]*/', '', $style_template );
1426
  }
1427
-
1428
  $style_values = apply_filters( 'mla_tag_cloud_style_values', $style_values );
1429
  $style_template = apply_filters( 'mla_tag_cloud_style_template', $style_template );
1430
  $gallery_style = MLAData::mla_parse_template( $style_template, $style_values );
1431
  $gallery_style = apply_filters( 'mla_tag_cloud_style_parse', $gallery_style, $style_template, $style_values );
1432
  } // !empty template
1433
  } // use_mla_tag_cloud_style
1434
-
1435
  $upload_dir = wp_upload_dir();
1436
  $markup_values = $style_values;
1437
  $markup_values['site_url'] = site_url();
@@ -1444,33 +1525,39 @@ class MLAShortcodes {
1444
  $markup_values['mla_markup'] = $default_markup;
1445
  $open_template = MLAOptions::mla_fetch_gallery_template( $default_markup, 'markup' );
1446
  }
1447
- if ( empty( $open_template ) )
 
1448
  $open_template = '';
1449
-
 
1450
  if ( $is_grid ) {
1451
  $row_open_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-row-open', 'markup' );
1452
- if ( empty( $row_open_template ) )
1453
  $row_open_template = '';
1454
- }
1455
- else
1456
  $row_open_template = '';
1457
-
 
1458
  $item_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-item', 'markup' );
1459
- if ( empty( $item_template ) )
1460
  $item_template = '';
1461
-
 
1462
  if ( $is_grid ) {
1463
  $row_close_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-row-close', 'markup' );
1464
- if ( empty( $row_close_template ) )
1465
  $row_close_template = '';
1466
- }
1467
- else
1468
  $row_close_template = '';
1469
-
 
1470
  $close_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-close', 'markup' );
1471
- if ( empty( $close_template ) )
1472
  $close_template = '';
1473
-
 
1474
  /*
1475
  * Look for gallery-level markup substitution parameters
1476
  */
@@ -1479,10 +1566,11 @@ class MLAShortcodes {
1479
 
1480
  $markup_values = apply_filters( 'mla_tag_cloud_open_values', $markup_values );
1481
  $open_template = apply_filters( 'mla_tag_cloud_open_template', $open_template );
1482
- if ( empty( $open_template ) )
1483
  $gallery_open = '';
1484
- else
1485
  $gallery_open = MLAData::mla_parse_template( $open_template, $markup_values );
 
1486
 
1487
  $gallery_open = apply_filters( 'mla_tag_cloud_open_parse', $gallery_open, $open_template, $markup_values );
1488
  $cloud .= $gallery_style . $gallery_open;
@@ -1491,33 +1579,36 @@ class MLAShortcodes {
1491
  /*
1492
  * Handle 'previous_page', 'next_page', and 'paginate_links'
1493
  */
1494
- if ( isset( $attr['limit'] ) )
1495
  $attr['posts_per_page'] = $attr['limit'];
1496
-
 
1497
  $pagination_result = self::_process_pagination_output_types( $output_parameters, $markup_values, $arguments, $attr, $found_rows, $output );
1498
- if ( false !== $pagination_result )
1499
  return $pagination_result;
 
1500
 
1501
  /*
1502
  * For "previous_link", "current_link" and "next_link", discard all of the $tags except the appropriate choice
1503
  */
1504
  $link_type = $output_parameters[0];
1505
-
1506
- if ( ! in_array( $link_type, array ( 'previous_link', 'current_link', 'next_link' ) ) )
1507
- return ''; // unknown outtput type
1508
-
 
1509
  $is_wrap = isset( $output_parameters[1] ) && 'wrap' == $output_parameters[1];
1510
  if ( empty( $arguments['term_id'] ) ) {
1511
  $target_id = -2; // won't match anything
1512
- }
1513
- else {
1514
  $current_id = $arguments['term_id'];
1515
-
1516
  foreach ( $tags as $id => $tag ) {
1517
- if ( $tag->term_id == $current_id )
1518
  break;
 
1519
  }
1520
-
1521
  switch ( $link_type ) {
1522
  case 'previous_link':
1523
  $target_id = $id - 1;
@@ -1530,12 +1621,11 @@ class MLAShortcodes {
1530
  $target_id = $id;
1531
  } // link_type
1532
  }
1533
-
1534
  $target = NULL;
1535
  if ( isset( $tags[ $target_id ] ) ) {
1536
  $target = $tags[ $target_id ];
1537
- }
1538
- elseif ( $is_wrap ) {
1539
  switch ( $link_type ) {
1540
  case 'previous_link':
1541
  $target = array_pop( $tags );
@@ -1544,15 +1634,16 @@ class MLAShortcodes {
1544
  $target = array_shift( $tags );
1545
  } // link_type
1546
  } // is_wrap
1547
-
1548
- if ( isset( $target ) )
1549
  $tags = array( $target );
1550
- elseif ( ! empty( $arguments['mla_nolink_text'] ) )
1551
  return self::_process_shortcode_parameter( $arguments['mla_nolink_text'], $markup_values ) . '</a>';
1552
- else
1553
  return '';
 
1554
  } // is_pagination
1555
-
1556
  /*
1557
  * Accumulate links for flat and array output
1558
  */
@@ -1561,15 +1652,16 @@ class MLAShortcodes {
1561
  $column_index = 0;
1562
  foreach ( $tags as $key => $tag ) {
1563
  $item_values = $markup_values;
1564
-
1565
  /*
1566
  * fill in item-specific elements
1567
  */
1568
  $item_values['index'] = (string) 1 + $column_index;
1569
- if ( $item_values['columns'] > 0 && ( 1 + $column_index ) % $item_values['columns'] == 0 )
1570
  $item_values['last_in_row'] = 'last_in_row';
1571
- else
1572
  $item_values['last_in_row'] = '';
 
1573
 
1574
  $item_values['key'] = $key;
1575
  $item_values['term_id'] = $tag->term_id;
@@ -1588,7 +1680,7 @@ class MLAShortcodes {
1588
  $item_values['termlink_url'] = $tag->term_link;
1589
  // Added in the code below:
1590
  // 'caption', 'link_attributes', 'rollover_text', 'link_style', 'link_text', 'editlink', 'termlink', 'thelink'
1591
-
1592
  /*
1593
  * Add item_specific field-level substitution parameters
1594
  */
@@ -1596,39 +1688,44 @@ class MLAShortcodes {
1596
  foreach( $mla_item_specific_arguments as $index => $value ) {
1597
  $new_text .= str_replace( '{+', '[+', str_replace( '+}', '+]', $arguments[ $index ] ) );
1598
  }
1599
-
1600
  $item_values = MLAData::mla_expand_field_level_parameters( $new_text, $attr, $item_values );
1601
 
1602
  if ( $item_values['captiontag'] ) {
1603
  $item_values['caption'] = wptexturize( $tag->description );
1604
- if ( ! empty( $arguments['mla_caption'] ) )
1605
  $item_values['caption'] = wptexturize( self::_process_shortcode_parameter( $arguments['mla_caption'], $item_values ) );
1606
- }
1607
- else
1608
  $item_values['caption'] = '';
1609
-
1610
- if ( ! empty( $arguments['mla_link_text'] ) )
 
1611
  $link_text = self::_process_shortcode_parameter( $arguments['mla_link_text'], $item_values );
1612
- else
1613
  $link_text = false;
 
1614
 
1615
  /*
1616
  * Apply the Display Content parameters.
1617
  */
1618
- if ( ! empty( $arguments['mla_target'] ) )
1619
  $link_attributes = 'target="' . $arguments['mla_target'] . '" ';
1620
- else
1621
  $link_attributes = '';
1622
-
1623
- if ( ! empty( $arguments['mla_link_attributes'] ) )
 
1624
  $link_attributes .= self::_process_shortcode_parameter( $arguments['mla_link_attributes'], $item_values ) . ' ';
 
1625
 
1626
- if ( ! empty( $arguments['mla_link_class'] ) )
1627
  $link_attributes .= 'class="' . self::_process_shortcode_parameter( $arguments['mla_link_class'], $item_values ) . '" ';
 
1628
 
1629
  $item_values['link_attributes'] = $link_attributes;
1630
-
1631
- $item_values['rollover_text'] = sprintf( _n( $item_values['single_text'], $item_values['multiple_text'], $item_values['count'] ), number_format_i18n( $item_values['count'] ) );
1632
  if ( ! empty( $arguments['mla_rollover_text'] ) ) {
1633
  $item_values['rollover_text'] = esc_attr( self::_process_shortcode_parameter( $arguments['mla_rollover_text'], $item_values ) );
1634
  }
@@ -1636,21 +1733,21 @@ class MLAShortcodes {
1636
  if ( ! empty( $arguments['mla_link_href'] ) ) {
1637
  $link_href = self::_process_shortcode_parameter( $arguments['mla_link_href'], $item_values );
1638
  $item_values['link_url'] = $link_href;
1639
- }
1640
- else
1641
  $link_href = '';
 
1642
 
1643
  if ( ! empty( $arguments['mla_link_style'] ) ) {
1644
  $item_values['link_style'] = esc_attr( self::_process_shortcode_parameter( $arguments['mla_link_style'], $item_values ) );
1645
- }
1646
- else
1647
  $item_values['link_style'] = 'font-size: ' . $item_values['font_size'] . $item_values['unit'];
 
1648
 
1649
  if ( ! empty( $arguments['mla_link_text'] ) ) {
1650
  $item_values['link_text'] = esc_attr( self::_process_shortcode_parameter( $arguments['mla_link_text'], $item_values ) );
1651
- }
1652
- else
1653
  $item_values['link_text'] = $item_values['name'];
 
1654
 
1655
  /*
1656
  * Editlink, termlink and thelink
@@ -1658,16 +1755,17 @@ class MLAShortcodes {
1658
  $item_values['editlink'] = sprintf( '<a %1$shref="%2$s" title="%3$s" style="%4$s">%5$s</a>', $link_attributes, $item_values['editlink_url'], $item_values['rollover_text'], $item_values['link_style'], $item_values['link_text'] );
1659
  $item_values['termlink'] = sprintf( '<a %1$shref="%2$s" title="%3$s" style="%4$s">%5$s</a>', $link_attributes, $item_values['termlink_url'], $item_values['rollover_text'], $item_values['link_style'], $item_values['link_text'] );
1660
 
1661
- if ( ! empty( $link_href ) )
1662
  $item_values['thelink'] = sprintf( '<a %1$shref="%2$s" title="%3$s" style="%4$s">%5$s</a>', $link_attributes, $link_href, $item_values['rollover_text'], $item_values['link_style'], $item_values['link_text'] );
1663
- elseif ( 'edit' == $arguments['link'] )
1664
  $item_values['thelink'] = $item_values['editlink'];
1665
- elseif ( 'view' == $arguments['link'] )
1666
  $item_values['thelink'] = $item_values['termlink'];
1667
- elseif ( 'span' == $arguments['link'] )
1668
  $item_values['thelink'] = sprintf( '<span %1$sstyle="%2$s">%3$s</a>', $link_attributes, $item_values['link_style'], $item_values['link_text'] );
1669
- else
1670
  $item_values['thelink'] = $item_values['link_text'];
 
1671
 
1672
  if ( $is_grid || $is_list ) {
1673
  /*
@@ -1679,7 +1777,7 @@ class MLAShortcodes {
1679
  $parse_value = MLAData::mla_parse_template( $row_open_template, $markup_values );
1680
  $cloud .= apply_filters( 'mla_tag_cloud_row_open_parse', $parse_value, $row_open_template, $markup_values );
1681
  }
1682
-
1683
  /*
1684
  * item markup
1685
  */
@@ -1688,7 +1786,7 @@ class MLAShortcodes {
1688
  $item_template = apply_filters( 'mla_tag_cloud_item_template', $item_template );
1689
  $parse_value = MLAData::mla_parse_template( $item_template, $item_values );
1690
  $cloud .= apply_filters( 'mla_tag_cloud_item_parse', $parse_value, $item_template, $item_values );
1691
-
1692
  /*
1693
  * End of row markup
1694
  */
@@ -1699,15 +1797,15 @@ class MLAShortcodes {
1699
  $cloud .= apply_filters( 'mla_tag_cloud_row_close_parse', $parse_value, $row_close_template, $markup_values );
1700
  }
1701
  } // is_grid || is_list
1702
- elseif ( $is_pagination )
1703
  return $item_values['thelink'];
1704
- else {
1705
  $column_index++;
1706
  $item_values = apply_filters( 'mla_tag_cloud_item_values', $item_values );
1707
  $tag_links[] = apply_filters( 'mla_tag_cloud_item_parse', $item_values['thelink'], NULL, $item_values );
1708
  }
1709
  } // foreach tag
1710
-
1711
  if ($is_grid || $is_list ) {
1712
  /*
1713
  * Close out partial row
@@ -1718,7 +1816,7 @@ class MLAShortcodes {
1718
  $parse_value = MLAData::mla_parse_template( $row_close_template, $markup_values );
1719
  $cloud .= apply_filters( 'mla_tag_cloud_row_close_parse', $parse_value, $row_close_template, $markup_values );
1720
  }
1721
-
1722
  $markup_values = apply_filters( 'mla_tag_cloud_close_values', $markup_values );
1723
  $close_template = apply_filters( 'mla_tag_cloud_close_template', $close_template );
1724
  $parse_value = MLAData::mla_parse_template( $close_template, $markup_values );
@@ -1735,15 +1833,16 @@ class MLAShortcodes {
1735
  break;
1736
  } // switch format
1737
  }
1738
-
1739
  //$cloud = wp_generate_tag_cloud( $tags, $arguments );
1740
-
1741
- if ( 'array' == $arguments['mla_output'] || empty($arguments['echo']) )
1742
  return $cloud;
1743
-
 
1744
  echo $cloud;
1745
  }
1746
-
1747
  /**
1748
  * The MLA Tag Cloud shortcode.
1749
  *
@@ -1759,16 +1858,18 @@ class MLAShortcodes {
1759
  /*
1760
  * Make sure $attr is an array, even if it's empty
1761
  */
1762
- if ( empty( $attr ) )
1763
  $attr = array();
1764
- elseif ( is_string( $attr ) )
1765
  $attr = shortcode_parse_atts( $attr );
 
1766
 
1767
  /*
1768
  * The 'array' format makes no sense in a shortcode
1769
  */
1770
- if ( isset( $attr['mla_output'] ) && 'array' == $attr['mla_output'] )
1771
  $attr['mla_output'] = 'flat';
 
1772
 
1773
  /*
1774
  * A shortcode must return its content to the caller, so "echo" makes no sense
@@ -1777,7 +1878,7 @@ class MLAShortcodes {
1777
 
1778
  return self::mla_tag_cloud( $attr );
1779
  }
1780
-
1781
  /**
1782
  * Handles brace/bracket escaping and parses template for a shortcode parameter
1783
  *
@@ -1793,7 +1894,7 @@ class MLAShortcodes {
1793
  $new_text = str_replace( '\[', '{', str_replace( '\]', '}', $new_text ) );
1794
  return MLAData::mla_parse_template( $new_text, $markup_values );
1795
  }
1796
-
1797
  /**
1798
  * Handles pagnation output types 'previous_page', 'next_page', and 'paginate_links'
1799
  *
@@ -1808,12 +1909,13 @@ class MLAShortcodes {
1808
  * @return mixed false or string with HTML for pagination output types
1809
  */
1810
  private static function _paginate_links( $output_parameters, $markup_values, $arguments, $found_rows, $output = '' ) {
1811
- if ( 2 > $markup_values['last_page'] )
1812
  return '';
1813
-
 
1814
  $show_all = $prev_next = false;
1815
-
1816
- if ( isset ( $output_parameters[1] ) )
1817
  switch ( $output_parameters[1] ) {
1818
  case 'show_all':
1819
  $show_all = true;
@@ -1821,6 +1923,7 @@ class MLAShortcodes {
1821
  case 'prev_next':
1822
  $prev_next = true;
1823
  }
 
1824
 
1825
  $mla_page_parameter = $arguments['mla_page_parameter'];
1826
  $current_page = $markup_values['current_page'];
@@ -1828,9 +1931,9 @@ class MLAShortcodes {
1828
  $end_size = absint( $arguments['mla_end_size'] );
1829
  $mid_size = absint( $arguments['mla_mid_size'] );
1830
  $posts_per_page = $markup_values['posts_per_page'];
1831
-
1832
  $new_target = ( ! empty( $arguments['mla_target'] ) ) ? 'target="' . $arguments['mla_target'] . '" ' : '';
1833
-
1834
  /*
1835
  * these will add to the default classes
1836
  */
@@ -1845,12 +1948,12 @@ class MLAShortcodes {
1845
  */
1846
  $page_links = array();
1847
  $dots = false;
1848
-
1849
  if ( $prev_next && $current_page && 1 < $current_page ) {
1850
  $markup_values['new_page'] = $current_page - 1;
1851
  $new_title = ( ! empty( $arguments['mla_rollover_text'] ) ) ? 'title="' . esc_attr( self::_process_shortcode_parameter( $arguments['mla_rollover_text'], $markup_values ) ) . '" ' : '';
1852
  $new_url = add_query_arg( array( $mla_page_parameter => $current_page - 1 ), $new_base );
1853
- $prev_text = ( ! empty( $arguments['mla_prev_text'] ) ) ? esc_attr( self::_process_shortcode_parameter( $arguments['mla_prev_text'], $markup_values ) ) : '&laquo; Previous';
1854
  $page_links[] = sprintf( '<a %1$sclass="prev page-numbers%2$s" %3$s%4$shref="%5$s">%6$s</a>',
1855
  /* %1$s */ $new_target,
1856
  /* %2$s */ $new_class,
@@ -1859,20 +1962,19 @@ class MLAShortcodes {
1859
  /* %5$s */ $new_url,
1860
  /* %6$s */ $prev_text );
1861
  }
1862
-
1863
  for ( $new_page = 1; $new_page <= $last_page; $new_page++ ) {
1864
  $new_page_display = number_format_i18n( $new_page );
1865
  $markup_values['new_page'] = $new_page;
1866
  $new_title = ( ! empty( $arguments['mla_rollover_text'] ) ) ? 'title="' . esc_attr( self::_process_shortcode_parameter( $arguments['mla_rollover_text'], $markup_values ) ) . '" ' : '';
1867
-
1868
  if ( $new_page == $current_page ) {
1869
  // build current page span
1870
  $page_links[] = sprintf( '<span class="page-numbers current%1$s">%2$s</span>',
1871
  /* %1$s */ $new_class,
1872
  /* %2$s */ $new_page_display );
1873
  $dots = true;
1874
- }
1875
- else {
1876
  if ( $show_all || ( $new_page <= $end_size || ( $current_page && $new_page >= $current_page - $mid_size && $new_page <= $current_page + $mid_size ) || $new_page > $last_page - $end_size ) ) {
1877
  // build link
1878
  $new_url = add_query_arg( array( $mla_page_parameter => $new_page ), $new_base );
@@ -1884,8 +1986,7 @@ class MLAShortcodes {
1884
  /* %5$s */ $new_url,
1885
  /* %6$s */ $new_page_display );
1886
  $dots = true;
1887
- }
1888
- elseif ( $dots && ! $show_all ) {
1889
  // build link
1890
  $page_links[] = sprintf( '<span class="page-numbers dots%1$s">&hellip;</span>',
1891
  /* %1$s */ $new_class );
@@ -1893,13 +1994,13 @@ class MLAShortcodes {
1893
  }
1894
  } // ! current
1895
  } // for $new_page
1896
-
1897
  if ( $prev_next && $current_page && ( $current_page < $last_page || -1 == $last_page ) ) {
1898
  // build next link
1899
  $markup_values['new_page'] = $current_page + 1;
1900
  $new_title = ( ! empty( $arguments['mla_rollover_text'] ) ) ? 'title="' . esc_attr( self::_process_shortcode_parameter( $arguments['mla_rollover_text'], $markup_values ) ) . '" ' : '';
1901
  $new_url = add_query_arg( array( $mla_page_parameter => $current_page + 1 ), $new_base );
1902
- $next_text = ( ! empty( $arguments['mla_next_text'] ) ) ? esc_attr( self::_process_shortcode_parameter( $arguments['mla_next_text'], $markup_values ) ) : 'Next &raquo;';
1903
  $page_links[] = sprintf( '<a %1$sclass="next page-numbers%2$s" %3$s%4$shref="%5$s">%6$s</a>',
1904
  /* %1$s */ $new_target,
1905
  /* %2$s */ $new_class,
@@ -1919,10 +2020,10 @@ class MLAShortcodes {
1919
  default:
1920
  $results = join("\n", $page_links);
1921
  } // mla_paginate_type
1922
-
1923
  return $output . $results;
1924
  }
1925
-
1926
  /**
1927
  * Handles pagnation output types 'previous_page', 'next_page', and 'paginate_links'
1928
  *
@@ -1938,62 +2039,72 @@ class MLAShortcodes {
1938
  * @return mixed false or string with HTML for pagination output types
1939
  */
1940
  private static function _process_pagination_output_types( $output_parameters, $markup_values, $arguments, $attr, $found_rows, $output = '' ) {
1941
- if ( ! in_array( $output_parameters[0], array( 'previous_page', 'next_page', 'paginate_links' ) ) )
1942
  return false;
1943
-
 
1944
  /*
1945
  * Add data selection parameters to gallery-specific and mla_gallery-specific parameters
1946
  */
1947
  $arguments = array_merge( $arguments, shortcode_atts( self::$mla_get_shortcode_attachments_parameters, $attr ) );
1948
  $posts_per_page = absint( $arguments['posts_per_page'] );
1949
  $mla_page_parameter = $arguments['mla_page_parameter'];
1950
-
1951
  /*
1952
  * $mla_page_parameter, if set, doesn't make it through the shortcode_atts filter,
1953
  * so we handle it separately
1954
  */
1955
- if ( ! isset( $arguments[ $mla_page_parameter ] ) )
1956
- if ( isset( $attr[ $mla_page_parameter ] ) )
1957
  $arguments[ $mla_page_parameter ] = $attr[ $mla_page_parameter ];
1958
- else
1959
  $arguments[ $mla_page_parameter ] = '';
1960
-
1961
- if ( 0 == $posts_per_page )
 
 
1962
  $posts_per_page = absint( $arguments['numberposts'] );
1963
-
1964
- if ( 0 == $posts_per_page )
 
1965
  $posts_per_page = absint( get_option('posts_per_page') );
 
1966
 
1967
  if ( 0 < $posts_per_page ) {
1968
  $max_page = floor( $found_rows / $posts_per_page );
1969
- if ( $max_page < ( $found_rows / $posts_per_page ) )
1970
  $max_page++;
1971
- }
1972
- else
1973
  $max_page = 1;
 
1974
 
1975
- if ( isset( $arguments['mla_paginate_total'] ) && $max_page > absint( $arguments['mla_paginate_total'] ) )
1976
  $max_page = absint( $arguments['mla_paginate_total'] );
1977
-
1978
- if ( isset( $arguments[ $mla_page_parameter ] ) )
 
1979
  $paged = absint( $arguments[ $mla_page_parameter ] );
1980
- else
1981
  $paged = absint( $arguments['paged'] );
1982
-
1983
- if ( 0 == $paged )
 
1984
  $paged = 1;
 
1985
 
1986
- if ( $max_page < $paged )
1987
  $paged = $max_page;
 
1988
 
1989
  switch ( $output_parameters[0] ) {
1990
  case 'previous_page':
1991
- if ( 1 < $paged )
1992
  $new_page = $paged - 1;
1993
- else {
1994
  $new_page = 0;
1995
 
1996
- if ( isset ( $output_parameters[1] ) )
1997
  switch ( $output_parameters[1] ) {
1998
  case 'wrap':
1999
  $new_page = $max_page;
@@ -2001,16 +2112,17 @@ class MLAShortcodes {
2001
  case 'first':
2002
  $new_page = 1;
2003
  }
 
2004
  }
2005
-
2006
  break;
2007
  case 'next_page':
2008
- if ( $paged < $max_page )
2009
  $new_page = $paged + 1;
2010
- else {
2011
  $new_page = 0;
2012
 
2013
- if ( isset ( $output_parameters[1] ) )
2014
  switch ( $output_parameters[1] ) {
2015
  case 'last':
2016
  $new_page = $max_page;
@@ -2018,40 +2130,44 @@ class MLAShortcodes {
2018
  case 'wrap':
2019
  $new_page = 1;
2020
  }
 
2021
  }
2022
-
2023
  break;
2024
  case 'paginate_links':
2025
  $new_page = 0;
2026
  $new_text = '';
2027
  }
2028
-
2029
  $markup_values['current_page'] = $paged;
2030
  $markup_values['new_page'] = $new_page;
2031
  $markup_values['last_page'] = $max_page;
2032
  $markup_values['posts_per_page'] = $posts_per_page;
2033
  $markup_values['found_rows'] = $found_rows;
2034
 
2035
- if ( $paged )
2036
  $markup_values['current_offset'] = ( $paged - 1 ) * $posts_per_page;
2037
- else
2038
  $markup_values['current_offset'] = 0;
2039
-
2040
- if ( $new_page )
 
2041
  $markup_values['new_offset'] = ( $new_page - 1 ) * $posts_per_page;
2042
- else
2043
  $markup_values['new_offset'] = 0;
2044
-
 
2045
  $markup_values['current_page_text'] = 'mla_paginate_current="[+current_page+]"';
2046
  $markup_values['new_page_text'] = 'mla_paginate_current="[+new_page+]"';
2047
  $markup_values['last_page_text'] = 'mla_paginate_total="[+last_page+]"';
2048
  $markup_values['posts_per_page_text'] = 'posts_per_page="[+posts_per_page+]"';
2049
-
2050
- if ( 'HTTPS' == substr( $_SERVER["SERVER_PROTOCOL"], 0, 5 ) )
2051
  $markup_values['scheme'] = 'https://';
2052
- else
2053
  $markup_values['scheme'] = 'http://';
2054
-
 
2055
  $markup_values['http_host'] = $_SERVER['HTTP_HOST'];
2056
  $markup_values['request_uri'] = add_query_arg( array( $mla_page_parameter => $new_page ), $_SERVER['REQUEST_URI'] );
2057
  $markup_values['new_url'] = set_url_scheme( $markup_values['scheme'] . $markup_values['http_host'] . $markup_values['request_uri'] );
@@ -2059,57 +2175,65 @@ class MLAShortcodes {
2059
  /*
2060
  * Build the new link, applying Gallery Display Content parameters
2061
  */
2062
- if ( 'paginate_links' == $output_parameters[0] )
2063
  return self::_paginate_links( $output_parameters, $markup_values, $arguments, $found_rows, $output );
2064
-
 
2065
  if ( 0 == $new_page ) {
2066
- if ( ! empty( $arguments['mla_nolink_text'] ) )
2067
  return self::_process_shortcode_parameter( $arguments['mla_nolink_text'], $markup_values );
2068
- else
2069
  return '';
 
2070
  }
2071
-
2072
  $new_link = '<a ';
2073
-
2074
- if ( ! empty( $arguments['mla_target'] ) )
2075
  $new_link .= 'target="' . $arguments['mla_target'] . '" ';
2076
-
2077
- if ( ! empty( $arguments['mla_link_class'] ) )
 
2078
  $new_link .= 'class="' . esc_attr( self::_process_shortcode_parameter( $arguments['mla_link_class'], $markup_values ) ) . '" ';
 
2079
 
2080
- if ( ! empty( $arguments['mla_rollover_text'] ) )
2081
  $new_link .= 'title="' . esc_attr( self::_process_shortcode_parameter( $arguments['mla_rollover_text'], $markup_values ) ) . '" ';
 
2082
 
2083
- if ( ! empty( $arguments['mla_link_attributes'] ) )
2084
  $new_link .= esc_attr( self::_process_shortcode_parameter( $arguments['mla_link_attributes'], $markup_values ) ) . ' ';
 
2085
 
2086
- if ( ! empty( $arguments['mla_link_href'] ) )
2087
  $new_link .= 'href="' . esc_attr( self::_process_shortcode_parameter( $arguments['mla_link_href'], $markup_values ) ) . '" >';
2088
- else
2089
  $new_link .= 'href="' . $markup_values['new_url'] . '" >';
2090
-
2091
- if ( ! empty( $arguments['mla_link_text'] ) )
 
2092
  $new_link .= self::_process_shortcode_parameter( $arguments['mla_link_text'], $markup_values ) . '</a>';
2093
- else {
2094
  if ( 'previous_page' == $output_parameters[0] ) {
2095
- if ( isset( $arguments['mla_prev_text'] ) )
2096
  $new_text = esc_attr( self::_process_shortcode_parameter( $arguments['mla_prev_text'], $markup_values ) );
2097
- else
2098
- $new_text = '&laquo; Previous';
2099
- }
2100
- else {
2101
- if ( isset( $arguments['mla_next_text'] ) )
2102
  $new_text = esc_attr( self::_process_shortcode_parameter( $arguments['mla_next_text'], $markup_values ) );
2103
- else
2104
- $new_text = 'Next &raquo;';
 
2105
  }
2106
-
2107
  $new_link .= $new_text . '</a>';
2108
  }
2109
-
2110
  return $new_link;
2111
  }
2112
-
2113
  /**
2114
  * WP_Query filter "parameters"
2115
  *
@@ -2140,7 +2264,7 @@ class MLAShortcodes {
2140
  $specification = str_replace( array( '<br />', '<p>', '</p>', "\r", "\n" ), ' ', $specification );
2141
  return $specification;
2142
  }
2143
-
2144
  /**
2145
  * Translates query parameters to a valid SQL order by clause.
2146
  *
@@ -2174,15 +2298,15 @@ class MLAShortcodes {
2174
  $allowed_keys[] = 'meta_value';
2175
  $allowed_keys[] = 'meta_value_num';
2176
  }
2177
-
2178
  $obmatches = preg_split('/\s*,\s*/', trim($query_parameters['orderby']));
2179
  foreach ( $obmatches as $index => $value ) {
2180
  $count = preg_match('/([a-z0-9_]+)(\s+(ASC|DESC))?/i', $value, $matches);
2181
 
2182
  if ( $count && ( $value == $matches[0] ) && in_array( $matches[1], $allowed_keys ) ) {
2183
- if ( 'rand' == $matches[1] )
2184
  $results[] = 'RAND()';
2185
- else {
2186
  switch ( $matches[1] ) {
2187
  case 'ID':
2188
  $matches[1] = "$wpdb->posts.ID";
@@ -2212,15 +2336,16 @@ class MLAShortcodes {
2212
  default:
2213
  $matches[1] = "$wpdb->posts.post_" . $matches[1];
2214
  } // switch $matches[1]
2215
-
2216
  $results[] = isset( $matches[2] ) ? $matches[1] . $matches[2] : $matches[1] . $order;
2217
  } // not 'rand'
2218
  } // valid column specification
2219
  } // foreach $obmatches
2220
 
2221
  $orderby = implode( ', ', $results );
2222
- if ( empty( $orderby ) )
2223
  return false;
 
2224
  } // else filter by allowed keys, etc.
2225
 
2226
  return $orderby;
@@ -2287,7 +2412,9 @@ class MLAShortcodes {
2287
  'meta_compare' => '',
2288
  'meta_query' => '',
2289
  // Search
2290
- 's' => ''
 
 
2291
  );
2292
 
2293
  /**
@@ -2301,7 +2428,7 @@ class MLAShortcodes {
2301
  * @var object
2302
  */
2303
  public static $mla_gallery_wp_query_object = NULL;
2304
-
2305
  /**
2306
  * Parses shortcode parameters and returns the gallery objects
2307
  *
@@ -2324,10 +2451,11 @@ class MLAShortcodes {
2324
  /*
2325
  * Make sure $attr is an array, even if it's empty
2326
  */
2327
- if ( empty( $attr ) )
2328
  $attr = array();
2329
- elseif ( is_string( $attr ) )
2330
  $attr = shortcode_parse_atts( $attr );
 
2331
 
2332
  /*
2333
  * The "where used" queries have no $_REQUEST context available to them,
@@ -2337,9 +2465,9 @@ class MLAShortcodes {
2337
  if ( isset( $attr['where_used_query'] ) && ( 'this-is-a-where-used-query' == $attr['where_used_query'] ) ) {
2338
  $where_used_query = true;
2339
  unset( $attr['where_used_query'] );
2340
- }
2341
- else
2342
  $where_used_query = false;
 
2343
 
2344
  /*
2345
  * Merge input arguments with defaults, then extract the query arguments.
@@ -2347,22 +2475,25 @@ class MLAShortcodes {
2347
  * $return_found_rows is used to indicate that the call comes from gallery_shortcode(),
2348
  * which is the only call that supplies it.
2349
  */
2350
- if ( ! is_null( $return_found_rows ) )
2351
  $attr = apply_filters( 'mla_gallery_query_attributes', $attr );
 
2352
 
2353
  $arguments = shortcode_atts( self::$mla_get_shortcode_attachments_parameters, $attr );
2354
  $mla_page_parameter = $arguments['mla_page_parameter'];
2355
  unset( $arguments['mla_page_parameter'] );
2356
-
2357
  /*
2358
  * $mla_page_parameter, if set, doesn't make it through the shortcode_atts filter,
2359
  * so we handle it separately
2360
  */
2361
- if ( ! isset( $arguments[ $mla_page_parameter ] ) )
2362
- if ( isset( $attr[ $mla_page_parameter ] ) )
2363
  $arguments[ $mla_page_parameter ] = $attr[ $mla_page_parameter ];
2364
- else
2365
  $arguments[ $mla_page_parameter ] = NULL;
 
 
2366
 
2367
  /*
2368
  * 'RAND' is not documented in the codex, but is present in the code.
@@ -2374,16 +2505,18 @@ class MLAShortcodes {
2374
 
2375
  if ( !empty( $arguments['ids'] ) ) {
2376
  // 'ids' is explicitly ordered, unless you specify otherwise.
2377
- if ( empty( $attr['orderby'] ) )
2378
  $arguments['orderby'] = 'post__in';
 
2379
 
2380
  $arguments['include'] = $arguments['ids'];
2381
  }
2382
  unset( $arguments['ids'] );
2383
 
2384
- if ( ! is_null( $return_found_rows ) )
2385
  $arguments = apply_filters( 'mla_gallery_query_arguments', $arguments );
2386
-
 
2387
  /*
2388
  * Extract taxonomy arguments
2389
  */
@@ -2392,41 +2525,44 @@ class MLAShortcodes {
2392
  if ( ! empty( $attr ) ) {
2393
  foreach ( $attr as $key => $value ) {
2394
  if ( 'tax_query' == $key ) {
2395
- if ( is_array( $value ) )
2396
  $query_arguments[ $key ] = $value;
2397
- else {
2398
  $tax_query = NULL;
2399
  $value = self::_sanitize_query_specification( $value );
2400
 
2401
  /*
2402
  * Replace invalid queries from "where-used" callers with a harmless equivalent
2403
  */
2404
- if ( $where_used_query && ( false !== strpos( $value, '{+' ) ) )
2405
  $value = "array( array( 'taxonomy' => 'none', 'field' => 'slug', 'terms' => 'none' ) )";
 
2406
 
2407
  $function = @create_function('', 'return ' . $value . ';' );
2408
- if ( is_callable( $function ) )
2409
  $tax_query = $function();
 
2410
 
2411
- if ( is_array( $tax_query ) )
2412
  $query_arguments[ $key ] = $tax_query;
2413
- else {
2414
- return '<p>ERROR: invalid mla_gallery tax_query = ' . var_export( $value, true ) . '</p>';
2415
  }
2416
  } // not array
2417
  } // tax_query
2418
  elseif ( array_key_exists( $key, $taxonomies ) ) {
2419
  $query_arguments[ $key ] = implode(',', array_filter( array_map( 'trim', explode( ',', $value ) ) ) );
2420
-
2421
  if ( 'false' == strtolower( trim( $arguments['tax_include_children'] ) ) ) {
2422
  $arguments['tax_include_children'] = false;
2423
-
2424
- if ( '' == $arguments['tax_operator'] )
2425
- $arguments['tax_operator'] = 'OR';
2426
- }
2427
- else
2428
  $arguments['tax_include_children'] = true;
2429
-
 
2430
  if ( in_array( strtoupper( $arguments['tax_operator'] ), array( 'OR', 'IN', 'NOT IN', 'AND' ) ) ) {
2431
  $query_arguments['tax_query'] = array( array( 'taxonomy' => $key, 'field' => 'slug', 'terms' => explode( ',', $query_arguments[ $key ] ), 'operator' => strtoupper( $arguments['tax_operator'] ), 'include_children' => $arguments['tax_include_children'] ) );
2432
  unset( $query_arguments[ $key ] );
@@ -2436,7 +2572,7 @@ class MLAShortcodes {
2436
  } // ! empty
2437
  unset( $arguments['tax_operator'] );
2438
  unset( $arguments['tax_include_children'] );
2439
-
2440
  /*
2441
  * $query_arguments has been initialized in the taxonomy code above.
2442
  */
@@ -2472,8 +2608,9 @@ class MLAShortcodes {
2472
  case 'id':
2473
  if ( is_numeric( $value ) ) {
2474
  $query_arguments[ $key ] = intval( $value );
2475
- if ( ! $children_ok )
2476
  $use_children = false;
 
2477
  }
2478
  unset( $arguments[ $key ] );
2479
  break;
@@ -2494,8 +2631,9 @@ class MLAShortcodes {
2494
  case 'offset':
2495
  if ( is_numeric( $value ) ) {
2496
  $query_arguments[ $key ] = intval( $value );
2497
- if ( ! $children_ok )
2498
  $use_children = false;
 
2499
  }
2500
  unset( $arguments[ $key ] );
2501
  break;
@@ -2505,38 +2643,44 @@ class MLAShortcodes {
2505
  * Note: The query variable 'page' holds the pagenumber for a single paginated
2506
  * Post or Page that includes the <!--nextpage--> Quicktag in the post content.
2507
  */
2508
- if ( get_query_var('page') )
2509
  $query_arguments[ $key ] = get_query_var('page');
2510
- else
2511
  $query_arguments[ $key ] = (get_query_var('paged')) ? get_query_var('paged') : 1;
2512
- }
2513
- elseif ( is_numeric( $value ) )
2514
  $query_arguments[ $key ] = intval( $value );
2515
- elseif ( '' === $value )
2516
  $query_arguments[ $key ] = 1;
 
 
2517
  unset( $arguments[ $key ] );
2518
  break;
2519
  case $mla_page_parameter :
2520
  case 'mla_paginate_total':
2521
- if ( is_numeric( $value ) )
2522
  $query_arguments[ $key ] = intval( $value );
2523
- elseif ( '' === $value )
2524
  $query_arguments[ $key ] = 1;
 
 
2525
  unset( $arguments[ $key ] );
2526
  break;
2527
  case 'author':
2528
  case 'cat':
2529
  case 'tag_id':
2530
  if ( ! empty( $value ) ) {
2531
- if ( is_array( $value ) )
2532
  $query_arguments[ $key ] = array_filter( $value );
2533
- else
2534
  $query_arguments[ $key ] = array_filter( array_map( 'intval', explode( ",", $value ) ) );
2535
-
2536
- if ( 1 == count( $query_arguments[ $key ] ) )
 
2537
  $query_arguments[ $key ] = $query_arguments[ $key ][0];
2538
- else
2539
  $query_arguments[ $key ] = implode(',', $query_arguments[ $key ] );
 
2540
 
2541
  $use_children = false;
2542
  }
@@ -2553,31 +2697,36 @@ class MLAShortcodes {
2553
  // fallthru
2554
  case 'exclude':
2555
  if ( ! empty( $value ) ) {
2556
- if ( is_array( $value ) )
2557
  $query_arguments[ $key ] = array_filter( $value );
2558
- else
2559
  $query_arguments[ $key ] = array_filter( array_map( 'intval', explode( ",", $value ) ) );
2560
-
2561
- if ( ! $children_ok )
 
2562
  $use_children = false;
 
2563
  }
2564
  unset( $arguments[ $key ] );
2565
  break;
2566
  case 'tag_slug__and':
2567
  case 'tag_slug__in':
2568
  if ( ! empty( $value ) ) {
2569
- if ( is_array( $value ) )
2570
  $query_arguments[ $key ] = $value;
2571
- else
2572
  $query_arguments[ $key ] = array_filter( array_map( 'trim', explode( ",", $value ) ) );
 
2573
 
2574
  $use_children = false;
2575
  }
2576
  unset( $arguments[ $key ] );
2577
  break;
2578
  case 'nopaging': // boolean
2579
- if ( ! empty( $value ) && ( 'false' != strtolower( $value ) ) )
2580
  $query_arguments[ $key ] = true;
 
 
2581
  unset( $arguments[ $key ] );
2582
  break;
2583
  case 'author_name':
@@ -2595,46 +2744,63 @@ class MLAShortcodes {
2595
  case 'orderby':
2596
  if ( ! empty( $value ) ) {
2597
  $query_arguments[ $key ] = $value;
2598
-
2599
- if ( ! $children_ok )
2600
  $use_children = false;
 
2601
  }
 
2602
  unset( $arguments[ $key ] );
2603
  break;
2604
  case 'order':
2605
  if ( ! empty( $value ) ) {
2606
  $value = strtoupper( $value );
2607
- if ( in_array( $value, array( 'ASC', 'DESC' ) ) )
2608
  $query_arguments[ $key ] = $value;
 
2609
  }
 
2610
  unset( $arguments[ $key ] );
2611
  break;
2612
  case 'meta_query':
2613
  if ( ! empty( $value ) ) {
2614
- if ( is_array( $value ) )
2615
  $query_arguments[ $key ] = $value;
2616
- else {
2617
  $meta_query = NULL;
2618
  $value = self::_sanitize_query_specification( $value );
2619
 
2620
  /*
2621
  * Replace invalid queries from "where-used" callers with a harmless equivalent
2622
  */
2623
- if ( $where_used_query && ( false !== strpos( $value, '{+' ) ) )
2624
  $value = "array( array( 'key' => 'unlikely', 'value' => 'none or otherwise unlikely' ) )";
 
2625
 
2626
  $function = @create_function('', 'return ' . $value . ';' );
2627
- if ( is_callable( $function ) )
2628
  $meta_query = $function();
2629
-
2630
- if ( is_array( $meta_query ) )
 
2631
  $query_arguments[ $key ] = $meta_query;
2632
- else
2633
- return '<p>ERROR: invalid mla_gallery meta_query = ' . var_export( $value, true ) . '</p>';
 
2634
  } // not array
2635
 
2636
  $use_children = false;
2637
  }
 
 
 
 
 
 
 
 
 
 
2638
  unset( $arguments[ $key ] );
2639
  break;
2640
  default:
@@ -2646,10 +2812,11 @@ class MLAShortcodes {
2646
  * Decide whether to use a "get_children" style query
2647
  */
2648
  if ( $use_children && ! isset( $query_arguments['post_parent'] ) ) {
2649
- if ( ! isset( $query_arguments['id'] ) )
2650
  $query_arguments['post_parent'] = $post_parent;
2651
- else
2652
  $query_arguments['post_parent'] = $query_arguments['id'];
 
2653
 
2654
  unset( $query_arguments['id'] );
2655
  }
@@ -2666,13 +2833,13 @@ class MLAShortcodes {
2666
  unset( $query_arguments['nopaging'] );
2667
  unset( $query_arguments['offset'] );
2668
  unset( $query_arguments['paged'] );
2669
-
2670
- if ( isset( $query_arguments['mla_paginate_total'] ) && ( $query_arguments[ $mla_page_parameter ] > $query_arguments['mla_paginate_total'] ) )
2671
  $query_arguments['offset'] = 0x7FFFFFFF; // suppress further output
2672
- else
2673
  $query_arguments['paged'] = $query_arguments[ $mla_page_parameter ];
2674
- }
2675
- else {
2676
  if ( isset( $query_arguments['posts_per_page'] ) || isset( $query_arguments['posts_per_archive_page'] ) ||
2677
  isset( $query_arguments['paged'] ) || isset( $query_arguments['offset'] ) ) {
2678
  unset( $query_arguments['nopaging'] );
@@ -2681,34 +2848,37 @@ class MLAShortcodes {
2681
  unset( $query_arguments[ $mla_page_parameter ] );
2682
  unset( $query_arguments['mla_paginate_total'] );
2683
 
2684
- if ( isset( $query_arguments['post_mime_type'] ) && ('all' == strtolower( $query_arguments['post_mime_type'] ) ) )
2685
  unset( $query_arguments['post_mime_type'] );
 
2686
 
2687
  if ( ! empty($query_arguments['include']) ) {
2688
  $incposts = wp_parse_id_list( $query_arguments['include'] );
2689
  $query_arguments['posts_per_page'] = count($incposts); // only the number of posts included
2690
  $query_arguments['post__in'] = $incposts;
2691
- } elseif ( ! empty($query_arguments['exclude']) )
2692
  $query_arguments['post__not_in'] = wp_parse_id_list( $query_arguments['exclude'] );
2693
-
 
2694
  $query_arguments['ignore_sticky_posts'] = true;
2695
  $query_arguments['no_found_rows'] = is_null( $return_found_rows ) ? true : ! $return_found_rows;
2696
-
2697
  /*
2698
  * We will always handle "orderby" in our filter
2699
  */
2700
  self::$query_parameters['orderby'] = self::_validate_sql_orderby( $query_arguments );
2701
- if ( false === self::$query_parameters['orderby'] )
2702
  unset( self::$query_parameters['orderby'] );
2703
-
 
2704
  unset( $query_arguments['orderby'] );
2705
  unset( $query_arguments['order'] );
2706
-
2707
  if ( self::$mla_debug ) {
2708
  add_filter( 'posts_clauses', 'MLAShortcodes::mla_shortcode_query_posts_clauses_filter', 0x7FFFFFFF, 1 );
2709
  add_filter( 'posts_clauses_request', 'MLAShortcodes::mla_shortcode_query_posts_clauses_request_filter', 0x7FFFFFFF, 1 );
2710
  }
2711
-
2712
  add_filter( 'posts_orderby', 'MLAShortcodes::mla_shortcode_query_posts_orderby_filter', 0x7FFFFFFF, 1 );
2713
  add_filter( 'posts_where', 'MLAShortcodes::mla_shortcode_query_posts_where_filter', 0x7FFFFFFF, 1 );
2714
 
@@ -2717,36 +2887,37 @@ class MLAShortcodes {
2717
  self::$mla_debug_messages .= '<p><strong>mla_debug $wp_filter[posts_where]</strong> = ' . var_export( $wp_filter['posts_where'], true ) . '</p>';
2718
  self::$mla_debug_messages .= '<p><strong>mla_debug $wp_filter[posts_orderby]</strong> = ' . var_export( $wp_filter['posts_orderby'], true ) . '</p>';
2719
  }
2720
-
2721
  self::$mla_gallery_wp_query_object = new WP_Query;
2722
  $attachments = self::$mla_gallery_wp_query_object->query($query_arguments);
2723
-
2724
  /*
2725
  * $return_found_rows is used to indicate that the call comes from gallery_shortcode(),
2726
  * which is the only call that supplies it.
2727
  */
2728
- if ( is_null( $return_found_rows ) )
2729
  $return_found_rows = false;
2730
- else
2731
  do_action( 'mla_gallery_wp_query_object', $query_arguments );
2732
-
 
2733
  if ( $return_found_rows ) {
2734
  $attachments['found_rows'] = self::$mla_gallery_wp_query_object->found_posts;
2735
  }
2736
-
2737
  remove_filter( 'posts_where', 'MLAShortcodes::mla_shortcode_query_posts_where_filter', 0x7FFFFFFF, 1 );
2738
  remove_filter( 'posts_orderby', 'MLAShortcodes::mla_shortcode_query_posts_orderby_filter', 0x7FFFFFFF, 1 );
2739
-
2740
  if ( self::$mla_debug ) {
2741
  remove_filter( 'posts_clauses', 'MLAShortcodes::mla_shortcode_query_posts_clauses_filter', 0x7FFFFFFF, 1 );
2742
  remove_filter( 'posts_clauses_request', 'MLAShortcodes::mla_shortcode_query_posts_clauses_request_filter', 0x7FFFFFFF, 1 );
2743
 
2744
- self::$mla_debug_messages .= '<p><strong>mla_debug query</strong> = ' . var_export( $query_arguments, true ) . '</p>';
2745
- self::$mla_debug_messages .= '<p><strong>mla_debug request</strong> = ' . var_export( self::$mla_gallery_wp_query_object->request, true ) . '</p>';
2746
- self::$mla_debug_messages .= '<p><strong>mla_debug query_vars</strong> = ' . var_export( self::$mla_gallery_wp_query_object->query_vars, true ) . '</p>';
2747
- self::$mla_debug_messages .= '<p><strong>mla_debug post_count</strong> = ' . var_export( self::$mla_gallery_wp_query_object->post_count, true ) . '</p>';
2748
  }
2749
-
2750
  self::$mla_gallery_wp_query_object = NULL;
2751
  return $attachments;
2752
  }
@@ -2770,9 +2941,9 @@ class MLAShortcodes {
2770
 
2771
  if ( self::$mla_debug ) {
2772
  $old_clause = $where_clause;
2773
- self::$mla_debug_messages .= '<p><strong>mla_debug WHERE filter</strong> = ' . var_export( $where_clause, true ) . '</p>';
2774
  }
2775
-
2776
  if ( strpos( $where_clause, "post_type = 'attachment'" ) ) {
2777
  $where_clause = str_replace( "post_type = 'attachment'", "post_type = 'attachment'", $where_clause );
2778
  }
@@ -2788,8 +2959,9 @@ class MLAShortcodes {
2788
  }
2789
  }
2790
 
2791
- if ( self::$mla_debug && ( $old_clause != $where_clause ) )
2792
- self::$mla_debug_messages .= '<p><strong>mla_debug modified WHERE filter</strong> = ' . var_export( $where_clause, true ) . '</p>';
 
2793
 
2794
  return $where_clause;
2795
  }
@@ -2810,13 +2982,14 @@ class MLAShortcodes {
2810
  global $wpdb;
2811
 
2812
  if ( self::$mla_debug ) {
2813
- self::$mla_debug_messages .= '<p><strong>mla_debug ORDER BY filter, incoming</strong> = ' . var_export( $orderby_clause, true ) . '<br>Replacement ORDER BY clause = ' . var_export( self::$query_parameters['orderby'], true ) . '</p>';
2814
  }
2815
 
2816
- if ( isset( self::$query_parameters['orderby'] ) )
2817
  return self::$query_parameters['orderby'];
2818
- else
2819
- return $orderby_clause;
 
2820
  }
2821
 
2822
  /**
@@ -2832,7 +3005,7 @@ class MLAShortcodes {
2832
  * @return array query clauses after modification (none)
2833
  */
2834
  public static function mla_shortcode_query_posts_clauses_filter( $pieces ) {
2835
- self::$mla_debug_messages .= '<p><strong>mla_debug posts_clauses filter</strong> = ' . var_export( $pieces, true ) . '</p>';
2836
 
2837
  return $pieces;
2838
  }
@@ -2850,7 +3023,7 @@ class MLAShortcodes {
2850
  * @return array query clauses after modification (none)
2851
  */
2852
  public static function mla_shortcode_query_posts_clauses_request_filter( $pieces ) {
2853
- self::$mla_debug_messages .= '<p><strong>mla_debug posts_clauses_request filter</strong> = ' . var_export( $pieces, true ) . '</p>';
2854
 
2855
  return $pieces;
2856
  }
@@ -2921,10 +3094,11 @@ class MLAShortcodes {
2921
  /*
2922
  * Make sure $attr is an array, even if it's empty
2923
  */
2924
- if ( empty( $attr ) )
2925
  $attr = array();
2926
- elseif ( is_string( $attr ) )
2927
  $attr = shortcode_parse_atts( $attr );
 
2928
 
2929
  /*
2930
  * Merge input arguments with defaults
@@ -2932,7 +3106,7 @@ class MLAShortcodes {
2932
  $attr = apply_filters( 'mla_get_terms_query_attributes', $attr );
2933
  $arguments = shortcode_atts( self::$mla_get_terms_parameters, $attr );
2934
  $arguments = apply_filters( 'mla_get_terms_query_arguments', $arguments );
2935
-
2936
  $query = array();
2937
  $query_parameters = array();
2938
 
@@ -2946,18 +3120,19 @@ class MLAShortcodes {
2946
  /*
2947
  * Add taxonomy constraint
2948
  */
2949
- if ( is_array( $arguments['taxonomy'] ) )
2950
  $taxonomies = $arguments['taxonomy'];
2951
- else
2952
  $taxonomies = array( $arguments['taxonomy'] );
 
2953
 
2954
  foreach ( $taxonomies as $taxonomy ) {
2955
  if ( ! taxonomy_exists( $taxonomy ) ) {
2956
- $error = new WP_Error( 'invalid_taxonomy', __('Invalid taxonomy'), $taxonomy );
2957
  return $error;
2958
  }
2959
  }
2960
-
2961
  $placeholders = array();
2962
  foreach ($taxonomies as $taxonomy) {
2963
  $placeholders[] = '%s';
@@ -2965,15 +3140,14 @@ class MLAShortcodes {
2965
  }
2966
 
2967
  $query[] = 'WHERE ( tt.taxonomy IN (' . join( ',', $placeholders ) . ')';
2968
-
2969
  /*
2970
  * Add include/exclude and parent constraints to WHERE cluse
2971
  */
2972
  if ( ! empty( $arguments['include'] ) ) {
2973
  $placeholders = implode( "','", wp_parse_id_list( $arguments['include'] ) );
2974
  $query[] = "AND t.term_id IN ( '{$placeholders}' )";
2975
- }
2976
- elseif ( ! empty( $arguments['exclude'] ) ) {
2977
  $placeholders = implode( "','", wp_parse_id_list( $arguments['exclude'] ) );
2978
  $query[] = "AND t.term_id NOT IN ( '{$placeholders}' )";
2979
  }
@@ -2989,7 +3163,7 @@ class MLAShortcodes {
2989
  $query[] = 'HAVING count >= %d';
2990
  $query_parameters[] = absint( $arguments['minimum'] );
2991
  }
2992
-
2993
  /*
2994
  * For now, always select the most popular terms
2995
  */
@@ -3008,15 +3182,16 @@ class MLAShortcodes {
3008
  * $final_parameters, if present, require an SQL subquery
3009
  */
3010
  $final_parameters = array();
3011
-
3012
  /*
3013
  * Add sort order
3014
  */
3015
  $orderby = strtolower( $arguments['orderby'] );
3016
  $order = strtoupper( $arguments['order'] );
3017
- if ( 'DESC' != $order )
3018
  $order = 'ASC';
3019
-
 
3020
  /*
3021
  * Count, Descending, is the default order so no further work
3022
  * is needed unless a different order is specified
@@ -3044,7 +3219,7 @@ class MLAShortcodes {
3044
  break;
3045
  }
3046
  }
3047
-
3048
  /*
3049
  * Add pagination
3050
  */
@@ -3054,17 +3229,15 @@ class MLAShortcodes {
3054
  $final_parameters[] = 'LIMIT %d, %d';
3055
  $query_parameters[] = $offset;
3056
  $query_parameters[] = $limit;
3057
- }
3058
- elseif ( 0 < $limit ) {
3059
  $final_parameters[] = 'LIMIT %d';
3060
  $query_parameters[] = $limit;
3061
- }
3062
- elseif ( 0 < $offset ) {
3063
  $final_parameters[] = 'LIMIT %d, %d';
3064
  $query_parameters[] = $offset;
3065
  $query_parameters[] = 0x7FFFFFFF; // big number!
3066
  }
3067
-
3068
  /*
3069
  * If we're limiting the final results, we need to get an accurate total count first
3070
  */
@@ -3073,27 +3246,28 @@ class MLAShortcodes {
3073
  $count = $wpdb->get_results( $wpdb->prepare( $count_query, $query_parameters ) );
3074
  $found_rows = $count[0]->count;
3075
  }
3076
-
3077
  if ( ! empty( $final_parameters ) ) {
3078
  array_unshift($query, 'SELECT * FROM (');
3079
  $query[] = ') AS subQuery';
3080
  $query = array_merge( $query, $final_parameters );
3081
  }
3082
-
3083
  $query = join(' ', $query);
3084
-
3085
  $tags = $wpdb->get_results( $wpdb->prepare( $query, $query_parameters ) );
3086
- if ( ! isset( $found_rows ) )
3087
  $found_rows = $wpdb->num_rows;
 
3088
 
3089
  if ( self::$mla_debug ) {
3090
- self::$mla_debug_messages .= '<p><strong>mla_debug query arguments</strong> = ' . var_export( $arguments, true ) . '</p>';
3091
- self::$mla_debug_messages .= '<p><strong>mla_debug last_query</strong> = ' . var_export( $wpdb->last_query, true ) . '</p>';
3092
- self::$mla_debug_messages .= '<p><strong>mla_debug last_error</strong> = ' . var_export( $wpdb->last_error, true ) . '</p>';
3093
- self::$mla_debug_messages .= '<p><strong>mla_debug num_rows</strong> = ' . var_export( $wpdb->num_rows, true ) . '</p>';
3094
- self::$mla_debug_messages .= '<p><strong>mla_debug found_rows</strong> = ' . var_export( $found_rows, true ) . '</p>';
3095
  }
3096
-
3097
  $tags['found_rows'] = $found_rows;
3098
  $tags = apply_filters( 'mla_get_terms_query_results', $tags );
3099
 
35
  */
36
  public static function mla_attachment_list_shortcode( /* $atts */ ) {
37
  global $wpdb;
38
+
39
  /* extract(shortcode_atts(array(
40
  'item_type'=>'attachment',
41
  'organize_by'=>'title',
42
  ), $atts)); */
43
+
44
  /*
45
  * Process the where-used settings option
46
  */
47
+ if ('checked' == MLAOptions::mla_get_option( MLAOptions::MLA_EXCLUDE_REVISIONS ) ) {
48
  $exclude_revisions = "(post_type <> 'revision') AND ";
49
+ } else {
50
  $exclude_revisions = '';
51
+ }
52
+
53
  $attachments = $wpdb->get_results(
54
  "
55
  SELECT ID, post_title, post_name, post_parent
57
  WHERE {$exclude_revisions}post_type = 'attachment'
58
  "
59
  );
60
+
61
  foreach ( $attachments as $attachment ) {
62
  $references = MLAData::mla_fetch_attachment_references( $attachment->ID, $attachment->post_parent );
63
+
64
  echo '&nbsp;<br><h3>' . $attachment->ID . ', ' . esc_attr( $attachment->post_title ) . ', Parent: ' . $attachment->post_parent . '<br>' . esc_attr( $attachment->post_name ) . '<br>' . esc_html( $references['base_file'] ) . "</h3>\r\n";
65
+
66
  /*
67
  * Look for the "Featured Image(s)"
68
  */
72
  echo "&nbsp;&nbsp;&nbsp;&nbsp;Featured in<br>\r\n";
73
  foreach ( $references['features'] as $feature_id => $feature ) {
74
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
75
+
76
  if ( $feature_id == $attachment->post_parent ) {
77
  echo 'PARENT ';
78
  $found_parent = true;
79
  }
80
+
81
  echo $feature_id . ' (' . $feature->post_type . '), ' . esc_attr( $feature->post_title ) . "<br>\r\n";
82
  }
83
  }
84
+
85
  /*
86
  * Look for item(s) inserted in post_content
87
  */
92
  echo '&nbsp;&nbsp;&nbsp;&nbsp;' . $file . " inserted in<br>\r\n";
93
  foreach ( $inserts as $insert ) {
94
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
95
+
96
  if ( $insert->ID == $attachment->post_parent ) {
97
  echo 'PARENT ';
98
  $found_parent = true;
99
  }
100
+
101
  echo $insert->ID . ' (' . $insert->post_type . '), ' . esc_attr( $insert->post_title ) . "<br>\r\n";
102
  } // foreach $insert
103
  } // foreach $file
104
  }
105
+
106
  $errors = '';
107
+
108
+ if ( !$references['found_reference'] ) {
109
  $errors .= '(ORPHAN) ';
110
+ }
111
+
112
+ if ( $references['is_unattached'] ) {
113
  $errors .= '(UNATTACHED) ';
114
+ } else {
115
  if ( !$references['found_parent'] ) {
116
+ if ( isset( $references['parent_title'] ) ) {
117
  $errors .= '(BAD PARENT) ';
118
+ } else {
119
  $errors .= '(INVALID PARENT) ';
120
+ }
121
  }
122
  }
123
+
124
+ if ( !empty( $errors ) ) {
125
  echo '&nbsp;&nbsp;&nbsp;&nbsp;' . $errors . "<br>\r\n";
126
+ }
127
  } // foreach attachment
128
+
129
  echo "<br>----- End of Report -----\r\n";
130
  }
131
+
132
  /**
133
  * Accumulates debug messages
134
  *
137
  * @var string
138
  */
139
  public static $mla_debug_messages = '';
140
+
141
  /**
142
  * Turn debug collection and display on or off
143
  *
146
  * @var boolean
147
  */
148
  private static $mla_debug = false;
149
+
150
  /**
151
  * The MLA Gallery shortcode.
152
  *
167
  /*
168
  * Some do_shortcode callers may not have a specific post in mind
169
  */
170
+ if ( ! is_object( $post ) ) {
171
  $post = (object) array( 'ID' => 0 );
172
+ }
173
+
174
  /*
175
  * Make sure $attr is an array, even if it's empty
176
  */
177
+ if ( empty( $attr ) ) {
178
  $attr = array();
179
+ } elseif ( is_string( $attr ) ) {
180
  $attr = shortcode_parse_atts( $attr );
181
+ }
182
 
183
  /*
184
  * The mla_paginate_current parameter can be changed to support multiple galleries per page.
185
  */
186
+ if ( ! isset( $attr['mla_page_parameter'] ) ) {
187
  $attr['mla_page_parameter'] = self::$mla_get_shortcode_attachments_parameters['mla_page_parameter'];
188
+ }
189
+
190
  $mla_page_parameter = $attr['mla_page_parameter'];
191
 
192
  /*
194
  * "MLA pagination" easier. Look for this parameter in $_REQUEST
195
  * if it's not present in the shortcode itself.
196
  */
197
+ if ( ! isset( $attr[ $mla_page_parameter ] ) ) {
198
+ if ( isset( $_REQUEST[ $mla_page_parameter ] ) ) {
199
  $attr[ $mla_page_parameter ] = $_REQUEST[ $mla_page_parameter ];
200
+ }
201
+ }
202
 
203
  /*
204
  * These are the parameters for gallery display
215
  'mla_image_attributes' => '',
216
  'mla_caption' => ''
217
  );
218
+
219
  $mla_arguments = array_merge( array(
220
  'mla_output' => 'gallery',
221
  'mla_style' => MLAOptions::mla_get_option('default_style'),
231
  'mla_viewer_width' => '150',
232
  'mla_alt_shortcode' => NULL,
233
  'mla_alt_ids_name' => 'ids',
234
+
235
  // paginatation arguments defined in $mla_get_shortcode_attachments_parameters
236
  // 'mla_page_parameter' => 'mla_paginate_current', handled in code with $mla_page_parameter
237
  // 'mla_paginate_current' => NULL,
240
 
241
  'mla_end_size'=> 1,
242
  'mla_mid_size' => 2,
243
+ 'mla_prev_text' => '&laquo; ' . __( 'Previous', 'media-library-assistant' ),
244
+ 'mla_next_text' => __( 'Next', 'media-library-assistant' ) . ' &raquo;',
245
  'mla_paginate_type' => 'plain'),
246
  $mla_item_specific_arguments
247
  );
248
+
249
  $default_arguments = array_merge( array(
250
  'size' => 'thumbnail', // or 'medium', 'large', 'full' or registered size
251
  'itemtag' => 'dl',
268
  'pause' => NULL),
269
  $mla_arguments
270
  );
271
+
272
  /*
273
  * Look for 'request' substitution parameters,
274
  * which can be added to any input parameter
278
  * attachment-specific Gallery Display Content parameters must be evaluated
279
  * later, when all of the information is available.
280
  */
281
+ if ( array_key_exists( $attr_key, $mla_item_specific_arguments ) ) {
282
  continue;
283
+ }
284
+
285
  $attr_value = str_replace( '{+', '[+', str_replace( '+}', '+]', $attr_value ) );
286
  $replacement_values = MLAData::mla_expand_field_level_parameters( $attr_value );
287
 
288
+ if ( ! empty( $replacement_values ) ) {
289
  $attr[ $attr_key ] = MLAData::mla_parse_template( $attr_value, $replacement_values );
290
+ }
291
  }
292
+
293
  /*
294
  * Merge gallery arguments with defaults, pass the query arguments on to mla_get_shortcode_attachments.
295
  */
298
  $content = apply_filters( 'mla_gallery_initial_content', $content, $attr );
299
  $arguments = shortcode_atts( $default_arguments, $attr );
300
  $arguments = apply_filters( 'mla_gallery_arguments', $arguments );
301
+
302
  self::$mla_debug = !empty( $arguments['mla_debug'] ) && ( 'true' == strtolower( $arguments['mla_debug'] ) );
303
 
304
  /*
307
  $output_parameters = array_map( 'strtolower', array_map( 'trim', explode( ',', $arguments['mla_output'] ) ) );
308
  $is_gallery = 'gallery' == $output_parameters[0];
309
  $is_pagination = in_array( $output_parameters[0], array( 'previous_page', 'next_page', 'paginate_links' ) );
310
+
311
  $attachments = self::mla_get_shortcode_attachments( $post->ID, $attr, $is_pagination );
312
+
313
+ if ( is_string( $attachments ) ) {
314
  return $attachments;
315
+ }
316
+
317
  if ( empty($attachments) ) {
318
  if ( self::$mla_debug ) {
319
+ $output = '<p><strong>' . __( 'mla_debug empty gallery', 'media-library-assistant' ) . '</strong>, query = ' . var_export( $attr, true ) . '</p>';
320
  $output .= self::$mla_debug_messages;
321
  self::$mla_debug_messages = '';
322
+ } else {
 
323
  $output = '';
324
  }
325
+
326
  $output .= $arguments['mla_nolink_text'];
327
  return $output;
328
  } // empty $attachments
329
+
330
  /*
331
  * Look for user-specified alternate gallery shortcode
332
  */
340
  if ( array_key_exists( $key, $blacklist ) ) {
341
  continue;
342
  }
343
+
344
  $slashed = addcslashes( $value, chr(0).chr(7).chr(8)."\f\n\r\t\v\"\\\$" );
345
  if ( ( false !== strpos( $value, ' ' ) ) || ( false !== strpos( $value, '\'' ) ) || ( $slashed != $value ) ) {
346
  $value = '"' . $slashed . '"';
347
  }
348
+
349
  $new_args .= empty( $new_args ) ? $key . '=' . $value : ' ' . $key . '=' . $value;
350
  } // foreach $attr
351
+
352
  $new_ids = '';
353
  foreach ( $attachments as $value ) {
354
  $new_ids .= empty( $new_ids ) ? (string) $value->ID : ',' . $value->ID;
355
  } // foreach $attachments
356
 
357
  $new_ids = $arguments['mla_alt_ids_name'] . '="' . $new_ids . '"';
358
+
359
  if ( self::$mla_debug ) {
360
  $output = self::$mla_debug_messages;
361
  self::$mla_debug_messages = '';
362
+ } else {
 
363
  $output = '';
364
+ }
365
  /*
366
  * Execute the alternate gallery shortcode with the new parameters
367
  */
377
  * Look for Photonic-enhanced gallery
378
  */
379
  global $photonic;
380
+
381
  if ( is_object( $photonic ) && ! empty( $arguments['style'] ) ) {
382
+ if ( 'default' != strtolower( $arguments['type'] ) ) {
383
+ return '<p>' . __( '<strong>Photonic-enhanced [mla_gallery]</strong> type must be <strong>default</strong>, query = ', 'media-library-assistant' ) . var_export( $attr, true ) . '</p>';
384
+ }
385
 
386
  $images = array();
387
  foreach ($attachments as $key => $val) {
388
  $images[$val->ID] = $attachments[$key];
389
  }
390
+
391
+ if ( isset( $arguments['pause'] ) && ( 'false' == $arguments['pause'] ) ) {
392
  $arguments['pause'] = NULL;
393
+ }
394
 
395
  $output = $photonic->build_gallery( $images, $arguments['style'], $arguments );
396
  return $output;
397
  }
398
+
399
  $size = $size_class = $arguments['size'];
400
  if ( 'icon' == strtolower( $size) ) {
401
+ if ( 'checked' == MLAOptions::mla_get_option( MLAOptions::MLA_ENABLE_MLA_ICONS ) ) {
402
  $size = array( 64, 64 );
403
+ } else {
404
  $size = array( 60, 60 );
405
+ }
406
+
407
  $show_icon = true;
408
+ } else {
 
409
  $show_icon = false;
410
+ }
411
+
412
  /*
413
  * Feeds such as RSS, Atom or RDF do not require styled and formatted output
414
  */
428
  $arguments['mla_viewer_page'] = absint( $arguments['mla_viewer_page'] );
429
  $arguments['mla_viewer_width'] = absint( $arguments['mla_viewer_width'] );
430
  }
431
+
432
  // $instance supports multiple galleries in one page/post
433
  static $instance = 0;
434
  $instance++;
442
 
443
  $columns = absint( $arguments['columns'] );
444
  $margin_string = strtolower( trim( $arguments['mla_margin'] ) );
445
+
446
+ if ( is_numeric( $margin_string ) && ( 0 != $margin_string) ) {
447
  $margin_string .= '%'; // Legacy values are always in percent
448
+ }
449
+
450
+ if ( '%' == substr( $margin_string, -1 ) ) {
451
  $margin_percent = (float) substr( $margin_string, 0, strlen( $margin_string ) - 1 );
452
+ } else {
453
  $margin_percent = 0;
454
+ }
455
+
456
  $width_string = strtolower( trim( $arguments['mla_itemwidth'] ) );
457
  if ( 'none' != $width_string ) {
458
  switch ( $width_string ) {
459
  case 'exact':
460
  $margin_percent = 0;
461
+ // fallthru
462
  case 'calculate':
463
  $width_string = $columns > 0 ? (floor(1000/$columns)/10) - ( 2.0 * $margin_percent ) : 100 - ( 2.0 * $margin_percent );
464
+ // fallthru
465
  default:
466
+ if ( is_numeric( $width_string ) && ( 0 != $width_string) ) {
467
  $width_string .= '%'; // Legacy values are always in percent
468
+ }
469
  }
470
  } // $use_width
471
+
472
  $float = strtolower( $arguments['mla_float'] );
473
+ if ( ! in_array( $float, array( 'left', 'none', 'right' ) ) ) {
474
  $float = is_rtl() ? 'right' : 'left';
475
+ }
476
+
477
  $style_values = array(
478
  'mla_style' => $arguments['mla_style'],
479
  'mla_markup' => $arguments['mla_markup'],
502
  $style_template = MLAOptions::mla_fetch_gallery_template( 'default', 'style' );
503
  }
504
  }
505
+
506
  if ( ! empty ( $style_template ) ) {
507
  /*
508
  * Look for 'query' and 'request' substitution parameters
521
  $style_values['itemwidth'] = 'auto';
522
  $style_template = preg_replace( '/width:[\s]*\[\+itemwidth\+\][\%]*[\;]*/', '', $style_template );
523
  }
524
+
525
  $style_values = apply_filters( 'mla_gallery_style_values', $style_values );
526
  $style_template = apply_filters( 'mla_gallery_style_template', $style_template );
527
  $gallery_style = MLAData::mla_parse_template( $style_template, $style_values );
528
  $gallery_style = apply_filters( 'mla_gallery_style_parse', $gallery_style, $style_template, $style_values );
529
+
530
  /*
531
  * Clean up the styles to resolve extra "%" suffixes on width or margin (pre v1.42 values)
532
  */
535
  $gallery_style = preg_replace( $preg_pattern, $preg_replacement, $gallery_style );
536
  } // !empty template
537
  } // use_mla_gallery_style
538
+
539
  $upload_dir = wp_upload_dir();
540
  $markup_values = $style_values;
541
  $markup_values['site_url'] = site_url();
553
  $open_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-open', 'markup' );
554
  }
555
  }
556
+ if ( empty( $open_template ) ) {
557
  $open_template = '';
558
+ }
559
 
560
  $row_open_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-row-open', 'markup' );
561
+ if ( empty( $row_open_template ) ) {
562
  $row_open_template = '';
563
+ }
564
+
565
  $item_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-item', 'markup' );
566
+ if ( empty( $item_template ) ) {
567
  $item_template = '';
568
+ }
569
 
570
  $row_close_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-row-close', 'markup' );
571
+ if ( empty( $row_close_template ) ) {
572
  $row_close_template = '';
573
+ }
574
+
575
  $close_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-close', 'markup' );
576
+ if ( empty( $close_template ) ) {
577
  $close_template = '';
578
+ }
579
 
580
  /*
581
  * Look for gallery-level markup substitution parameters
582
  */
583
  $new_text = $open_template . $row_open_template . $row_close_template . $close_template;
584
+
585
  $markup_values = MLAData::mla_expand_field_level_parameters( $new_text, $attr, $markup_values );
586
 
587
  if ( self::$mla_debug ) {
588
  $output = self::$mla_debug_messages;
589
  self::$mla_debug_messages = '';
590
+ } else {
 
591
  $output = '';
592
+ }
593
 
594
  if ($is_gallery ) {
595
  $markup_values = apply_filters( 'mla_gallery_open_values', $markup_values );
596
 
597
  $open_template = apply_filters( 'mla_gallery_open_template', $open_template );
598
+ if ( empty( $open_template ) ) {
599
  $gallery_open = '';
600
+ } else {
601
  $gallery_open = MLAData::mla_parse_template( $open_template, $markup_values );
602
+ }
603
 
604
  $gallery_open = apply_filters( 'mla_gallery_open_parse', $gallery_open, $open_template, $markup_values );
605
  $output .= apply_filters( 'mla_gallery_style', $gallery_style . $gallery_open, $style_values, $markup_values, $style_template, $open_template );
606
+ } else {
607
+ if ( ! isset( $attachments['found_rows'] ) ) {
 
608
  $attachments['found_rows'] = 0;
609
+ }
610
+
611
  /*
612
  * Handle 'previous_page', 'next_page', and 'paginate_links'
613
  */
614
  $pagination_result = self::_process_pagination_output_types( $output_parameters, $markup_values, $arguments, $attr, $attachments['found_rows'], $output );
615
+ if ( false !== $pagination_result ) {
616
  return $pagination_result;
617
+ }
618
+
619
  unset( $attachments['found_rows'] );
620
  }
621
+
622
  /*
623
  * For "previous_link", "current_link" and "next_link", discard all of the $attachments except the appropriate choice
624
  */
625
  if ( ! $is_gallery ) {
626
  $link_type = $output_parameters[0];
627
+
628
+ if ( ! in_array( $link_type, array ( 'previous_link', 'current_link', 'next_link' ) ) ) {
629
+ return ''; // unknown output type
630
+ }
631
+
632
  $is_wrap = isset( $output_parameters[1] ) && 'wrap' == $output_parameters[1];
633
  $current_id = empty( $arguments['id'] ) ? $markup_values['id'] : $arguments['id'];
634
+
635
  foreach ( $attachments as $id => $attachment ) {
636
+ if ( $attachment->ID == $current_id ) {
637
  break;
638
+ }
639
  }
640
+
641
  switch ( $link_type ) {
642
  case 'previous_link':
643
  $target_id = $id - 1;
649
  default:
650
  $target_id = $id;
651
  } // link_type
652
+
653
  $target = NULL;
654
  if ( isset( $attachments[ $target_id ] ) ) {
655
  $target = $attachments[ $target_id ];
656
+ } elseif ( $is_wrap ) {
 
657
  switch ( $link_type ) {
658
  case 'previous_link':
659
  $target = array_pop( $attachments );
663
  } // link_type
664
  } // is_wrap
665
 
666
+ if ( isset( $target ) ) {
667
  $attachments = array( $target );
668
+ } elseif ( ! empty( $arguments['mla_nolink_text'] ) ) {
669
  return self::_process_shortcode_parameter( $arguments['mla_nolink_text'], $markup_values ) . '</a>';
670
+ } else {
671
  return '';
672
+ }
673
+ } else { // ! is_gallery
674
  $link_type= '';
675
+ }
676
+
677
  $column_index = 0;
678
  foreach ( $attachments as $id => $attachment ) {
679
  $item_values = $markup_values;
680
+
681
  /*
682
  * fill in item-specific elements
683
  */
690
  $item_values['date'] = $attachment->post_date;
691
  $item_values['modified'] = $attachment->post_modified;
692
  $item_values['parent'] = $attachment->post_parent;
693
+ $item_values['parent_title'] = '(' . __( 'unattached', 'media-library-assistant' ) . ')';
694
  $item_values['parent_type'] = '';
695
  $item_values['parent_date'] = '';
696
  $item_values['title'] = wptexturize( $attachment->post_title );
706
  $item_values['description'] = wptexturize( $attachment->post_content );
707
  $item_values['file_url'] = wptexturize( $attachment->guid );
708
  $item_values['author_id'] = $attachment->post_author;
709
+
710
  $user = get_user_by( 'id', $attachment->post_author );
711
+ if ( isset( $user->data->display_name ) ) {
712
  $item_values['author'] = wptexturize( $user->data->display_name );
713
+ } else {
714
+ $item_values['author'] = __( 'unknown', 'media-library-assistant' );
715
+ }
716
 
717
  $post_meta = MLAData::mla_fetch_attachment_metadata( $attachment->ID );
718
  $base_file = $post_meta['mla_wp_attached_file'];
721
  if ( !empty( $post_meta['mla_wp_attachment_metadata']['width'] ) ) {
722
  $item_values['width'] = $post_meta['mla_wp_attachment_metadata']['width'];
723
  $width = absint( $item_values['width'] );
724
+ } else {
 
725
  $width = 0;
726
+ }
727
+
728
  if ( !empty( $post_meta['mla_wp_attachment_metadata']['height'] ) ) {
729
  $item_values['height'] = $post_meta['mla_wp_attachment_metadata']['height'];
730
  $height = absint( $item_values['height'] );
731
+ } else {
 
732
  $height = 0;
733
+ }
734
+
735
+ if ( $width && $height ) {
736
  $item_values['orientation'] = ( $height > $width ) ? 'portrait' : 'landscape';
737
+ }
738
 
739
+ if ( !empty( $post_meta['mla_wp_attachment_metadata']['image_meta'] ) ) {
740
  $item_values['image_meta'] = wptexturize( var_export( $post_meta['mla_wp_attachment_metadata']['image_meta'], true ) );
741
+ }
742
+
743
+ if ( !empty( $post_meta['mla_wp_attachment_image_alt'] ) ) {
744
  $item_values['image_alt'] = wptexturize( $post_meta['mla_wp_attachment_image_alt'] );
745
+ }
746
 
747
  if ( ! empty( $base_file ) ) {
748
  $last_slash = strrpos( $base_file, '/' );
750
  $file_name = $base_file;
751
  $item_values['base_file'] = wptexturize( $base_file );
752
  $item_values['file'] = wptexturize( $base_file );
753
+ } else {
 
754
  $file_name = substr( $base_file, $last_slash + 1 );
755
  $item_values['base_file'] = wptexturize( $base_file );
756
  $item_values['path'] = wptexturize( substr( $base_file, 0, $last_slash + 1 ) );
757
  $item_values['file'] = wptexturize( $file_name );
758
  }
759
+ } else {
 
760
  $file_name = '';
761
+ }
762
 
763
  $parent_info = MLAData::mla_fetch_attachment_parent_data( $attachment->post_parent );
764
+ if ( isset( $parent_info['parent_title'] ) ) {
765
  $item_values['parent_title'] = wptexturize( $parent_info['parent_title'] );
766
+ }
767
+
768
+ if ( isset( $parent_info['parent_date'] ) ) {
769
  $item_values['parent_date'] = wptexturize( $parent_info['parent_date'] );
770
+ }
771
+
772
+ if ( isset( $parent_info['parent_type'] ) ) {
773
  $item_values['parent_type'] = wptexturize( $parent_info['parent_type'] );
774
+ }
775
+
776
  /*
777
  * Add attachment-specific field-level substitution parameters
778
  */
780
  foreach( $mla_item_specific_arguments as $index => $value ) {
781
  $new_text .= str_replace( '{+', '[+', str_replace( '+}', '+]', $arguments[ $index ] ) );
782
  }
783
+
784
  $item_values = MLAData::mla_expand_field_level_parameters( $new_text, $attr, $item_values, $attachment->ID );
785
 
786
  if ( $item_values['captiontag'] ) {
787
  $item_values['caption'] = wptexturize( $attachment->post_excerpt );
788
+ if ( ! empty( $arguments['mla_caption'] ) ) {
789
  $item_values['caption'] = wptexturize( self::_process_shortcode_parameter( $arguments['mla_caption'], $item_values ) );
790
+ }
791
+ } else {
792
  $item_values['caption'] = '';
793
+ }
794
+
795
+ if ( ! empty( $arguments['mla_link_text'] ) ) {
796
  $link_text = self::_process_shortcode_parameter( $arguments['mla_link_text'], $item_values );
797
+ } else {
798
  $link_text = false;
799
+ }
800
 
801
  $item_values['pagelink'] = wp_get_attachment_link($attachment->ID, $size, true, $show_icon, $link_text);
802
  $item_values['filelink'] = wp_get_attachment_link($attachment->ID, $size, false, $show_icon, $link_text);
806
  * Note that $link_attributes and $rollover_text
807
  * are used in the Google Viewer code below
808
  */
809
+ if ( ! empty( $arguments['mla_target'] ) ) {
810
  $link_attributes = 'target="' . $arguments['mla_target'] . '" ';
811
+ } else {
812
  $link_attributes = '';
813
+ }
814
+
815
+ if ( ! empty( $arguments['mla_link_attributes'] ) ) {
816
  $link_attributes .= self::_process_shortcode_parameter( $arguments['mla_link_attributes'], $item_values ) . ' ';
817
+ }
818
 
819
+ if ( ! empty( $arguments['mla_link_class'] ) ) {
820
  $link_attributes .= 'class="' . self::_process_shortcode_parameter( $arguments['mla_link_class'], $item_values ) . '" ';
821
+ }
822
 
823
  if ( ! empty( $link_attributes ) ) {
824
  $item_values['pagelink'] = str_replace( '<a href=', '<a ' . $link_attributes . 'href=', $item_values['pagelink'] );
825
  $item_values['filelink'] = str_replace( '<a href=', '<a ' . $link_attributes . 'href=', $item_values['filelink'] );
826
  }
827
+
828
  if ( ! empty( $arguments['mla_rollover_text'] ) ) {
829
  $rollover_text = esc_attr( self::_process_shortcode_parameter( $arguments['mla_rollover_text'], $item_values ) );
830
+
831
  /*
832
  * Replace single- and double-quote delimited values
833
  */
835
  $item_values['pagelink'] = preg_replace('# title=\"([^\"]*)\"#', " title=\"{$rollover_text}\"", $item_values['pagelink'] );
836
  $item_values['filelink'] = preg_replace('# title=\'([^\']*)\'#', " title='{$rollover_text}'", $item_values['filelink'] );
837
  $item_values['filelink'] = preg_replace('# title=\"([^\"]*)\"#', " title=\"{$rollover_text}\"", $item_values['filelink'] );
838
+ } else {
 
839
  $rollover_text = $item_values['title'];
840
+ }
841
 
842
  /*
843
  * Process the <img> tag, if present
844
  * Note that $image_attributes, $image_class and $image_alt
845
  * are used in the Google Viewer code below
846
  */
847
+ if ( ! empty( $arguments['mla_image_attributes'] ) ) {
848
  $image_attributes = self::_process_shortcode_parameter( $arguments['mla_image_attributes'], $item_values ) . ' ';
849
+ } else {
850
  $image_attributes = '';
851
+ }
852
+
853
+ if ( ! empty( $arguments['mla_image_class'] ) ) {
854
  $image_class = esc_attr( self::_process_shortcode_parameter( $arguments['mla_image_class'], $item_values ) );
855
+ } else {
856
  $image_class = '';
857
+ }
858
 
859
+ if ( ! empty( $arguments['mla_image_alt'] ) ) {
860
+ $image_alt = esc_attr( self::_process_shortcode_parameter( $arguments['mla_image_alt'], $item_values ) );
861
+ } else {
862
+ $image_alt = '';
863
+ }
864
 
865
  if ( false !== strpos( $item_values['pagelink'], '<img ' ) ) {
866
  if ( ! empty( $image_attributes ) ) {
867
  $item_values['pagelink'] = str_replace( '<img ', '<img ' . $image_attributes, $item_values['pagelink'] );
868
  $item_values['filelink'] = str_replace( '<img ', '<img ' . $image_attributes, $item_values['filelink'] );
869
  }
870
+
871
  /*
872
  * Extract existing class values and add to them
873
  */
875
  $match_count = preg_match_all( '# class=\"([^\"]+)\" #', $item_values['pagelink'], $matches, PREG_OFFSET_CAPTURE );
876
  if ( ! ( ( $match_count == false ) || ( $match_count == 0 ) ) ) {
877
  $class = $matches[1][0][0] . ' ' . $image_class;
878
+ } else {
 
879
  $class = $image_class;
880
+ }
881
+
882
  $item_values['pagelink'] = preg_replace('# class=\"([^\"]*)\"#', " class=\"{$class}\"", $item_values['pagelink'] );
883
  $item_values['filelink'] = preg_replace('# class=\"([^\"]*)\"#', " class=\"{$class}\"", $item_values['filelink'] );
884
  }
885
+
886
  if ( ! empty( $image_alt ) ) {
887
  $item_values['pagelink'] = preg_replace('# alt=\"([^\"]*)\"#', " alt=\"{$image_alt}\"", $item_values['pagelink'] );
888
  $item_values['filelink'] = preg_replace('# alt=\"([^\"]*)\"#', " alt=\"{$image_alt}\"", $item_values['filelink'] );
889
  }
890
  } // process <img> tag
891
+
892
  switch ( $arguments['link'] ) {
893
  case 'permalink':
894
  case 'post':
909
  $item_values['link'] = str_replace( $file_name, $target_file, $item_values['filelink'] );
910
  }
911
  } // switch 'link'
912
+
913
  /*
914
  * Extract target and thumbnail fields
915
  */
916
  $match_count = preg_match_all( '#href=\'([^\']+)\'#', $item_values['pagelink'], $matches, PREG_OFFSET_CAPTURE );
917
  if ( ! ( ( $match_count == false ) || ( $match_count == 0 ) ) ) {
918
  $item_values['pagelink_url'] = $matches[1][0][0];
919
+ } else {
 
920
  $item_values['pagelink_url'] = '';
921
+ }
922
 
923
  $match_count = preg_match_all( '#href=\'([^\']+)\'#', $item_values['filelink'], $matches, PREG_OFFSET_CAPTURE );
924
  if ( ! ( ( $match_count == false ) || ( $match_count == 0 ) ) ) {
925
  $item_values['filelink_url'] = $matches[1][0][0];
926
+ } else {
 
927
  $item_values['filelink_url'] = '';
928
+ }
929
 
930
  $match_count = preg_match_all( '#href=\'([^\']+)\'#', $item_values['link'], $matches, PREG_OFFSET_CAPTURE );
931
  if ( ! ( ( $match_count == false ) || ( $match_count == 0 ) ) ) {
932
  $item_values['link_url'] = $matches[1][0][0];
933
+ } else {
 
934
  $item_values['link_url'] = '';
935
+ }
936
 
937
  /*
938
  * Override the link value; leave filelink and pagelink unchanged
946
  */
947
  $item_values['link'] = preg_replace('# href=\'([^\']*)\'#', " href='{$link_href}'", $item_values['link'] );
948
  $item_values['link'] = preg_replace('# href=\"([^\"]*)\"#', " href=\"{$link_href}\"", $item_values['link'] );
949
+ } else {
 
950
  $link_href = '';
951
+ }
952
+
953
  $match_count = preg_match_all( '#\<a [^\>]+\>(.*)\</a\>#', $item_values['link'], $matches, PREG_OFFSET_CAPTURE );
954
  if ( ! ( ( $match_count == false ) || ( $match_count == 0 ) ) ) {
955
  $item_values['thumbnail_content'] = $matches[1][0][0];
956
+ } else {
 
957
  $item_values['thumbnail_content'] = '';
958
+ }
959
 
960
  $match_count = preg_match_all( '# width=\"([^\"]+)\" height=\"([^\"]+)\" src=\"([^\"]+)\" #', $item_values['link'], $matches, PREG_OFFSET_CAPTURE );
961
  if ( ! ( ( $match_count == false ) || ( $match_count == 0 ) ) ) {
962
  $item_values['thumbnail_width'] = $matches[1][0][0];
963
  $item_values['thumbnail_height'] = $matches[2][0][0];
964
  $item_values['thumbnail_url'] = $matches[3][0][0];
965
+ } else {
 
966
  $item_values['thumbnail_width'] = '';
967
  $item_values['thumbnail_height'] = '';
968
  $item_values['thumbnail_url'] = '';
971
  /*
972
  * Now that we have thumbnail_content we can check for 'span' and 'none'
973
  */
974
+ if ( 'none' == $arguments['link'] ) {
975
  $item_values['link'] = $item_values['thumbnail_content'];
976
+ } elseif ( 'span' == $arguments['link'] ) {
977
  $item_values['link'] = sprintf( '<span %1$s>%2$s</span>', $link_attributes, $item_values['thumbnail_content'] );
978
+ }
979
+
980
  /*
981
  * Check for Google file viewer substitution, uses above-defined
982
  * $link_attributes (includes target), $rollover_text, $link_href (link only),
990
  /*
991
  * <img> tag (thumbnail_text)
992
  */
993
+ if ( ! empty( $image_class ) ) {
994
  $image_class = ' class="' . $image_class . '"';
995
+ }
996
+
997
+ if ( ! empty( $image_alt ) ) {
998
  $image_alt = ' alt="' . $image_alt . '"';
999
+ } elseif ( ! empty( $item_values['caption'] ) ) {
1000
  $image_alt = ' alt="' . $item_values['caption'] . '"';
1001
+ }
1002
 
1003
  $item_values['thumbnail_content'] = sprintf( '<img %1$ssrc="http://docs.google.com/viewer?url=%2$s&a=bi&pagenumber=%3$d&w=%4$d"%5$s%6$s>', $image_attributes, $item_values['filelink_url'], $arguments['mla_viewer_page'], $arguments['mla_viewer_width'], $image_class, $image_alt );
1004
+
1005
  /*
1006
  * Filelink, pagelink and link
1007
  */
1008
  $item_values['pagelink'] = sprintf( '<a %1$shref="%2$s" title="%3$s">%4$s</a>', $link_attributes, $item_values['pagelink_url'], $rollover_text, $item_values['thumbnail_content'] );
1009
  $item_values['filelink'] = sprintf( '<a %1$shref="%2$s" title="%3$s">%4$s</a>', $link_attributes, $item_values['filelink_url'], $rollover_text, $item_values['thumbnail_content'] );
1010
 
1011
+ if ( ! empty( $link_href ) ) {
1012
  $item_values['link'] = sprintf( '<a %1$shref="%2$s" title="%3$s">%4$s</a>', $link_attributes, $link_href, $rollover_text, $item_values['thumbnail_content'] );
1013
+ } elseif ( 'permalink' == $arguments['link'] ) {
1014
  $item_values['link'] = $item_values['pagelink'];
1015
+ } elseif ( 'file' == $arguments['link'] ) {
1016
  $item_values['link'] = $item_values['filelink'];
1017
+ } elseif ( 'span' == $arguments['link'] ) {
1018
  $item_values['link'] = sprintf( '<a %1$s>%2$s</a>', $link_attributes, $item_values['thumbnail_content'] );
1019
+ } else {
1020
  $item_values['link'] = $item_values['thumbnail_content'];
1021
+ }
1022
  } // viewer extension
1023
  } // has extension
1024
  } // mla_viewer
1025
+
1026
  if ($is_gallery ) {
1027
  /*
1028
  * Start of row markup
1033
  $parse_value = MLAData::mla_parse_template( $row_open_template, $markup_values );
1034
  $output .= apply_filters( 'mla_gallery_row_open_parse', $parse_value, $row_open_template, $markup_values );
1035
  }
1036
+
1037
  /*
1038
  * item markup
1039
  */
1040
  $column_index++;
1041
+ if ( $item_values['columns'] > 0 && $column_index % $item_values['columns'] == 0 ) {
1042
  $item_values['last_in_row'] = 'last_in_row';
1043
+ } else {
1044
  $item_values['last_in_row'] = '';
1045
+ }
1046
+
1047
  $item_values = apply_filters( 'mla_gallery_item_values', $item_values );
1048
  $item_template = apply_filters( 'mla_gallery_item_template', $item_template );
1049
  $parse_value = MLAData::mla_parse_template( $item_template, $item_values );
1050
  $output .= apply_filters( 'mla_gallery_item_parse', $parse_value, $item_template, $item_values );
1051
+
1052
  /*
1053
  * End of row markup
1054
  */
1059
  $output .= apply_filters( 'mla_gallery_row_close_parse', $parse_value, $row_close_template, $markup_values );
1060
  }
1061
  } // is_gallery
1062
+ elseif ( ! empty( $link_type ) ) {
1063
  return $item_values['link'];
1064
+ }
1065
  } // foreach attachment
1066
+
1067
  if ($is_gallery ) {
1068
  /*
1069
  * Close out partial row
1074
  $parse_value = MLAData::mla_parse_template( $row_close_template, $markup_values );
1075
  $output .= apply_filters( 'mla_gallery_row_close_parse', $parse_value, $row_close_template, $markup_values );
1076
  }
1077
+
1078
  $markup_values = apply_filters( 'mla_gallery_close_values', $markup_values );
1079
  $close_template = apply_filters( 'mla_gallery_close_template', $close_template );
1080
  $parse_value = MLAData::mla_parse_template( $close_template, $markup_values );
1081
  $output .= apply_filters( 'mla_gallery_close_parse', $parse_value, $close_template, $markup_values );
1082
  } // is_gallery
1083
+
1084
  return $output;
1085
  }
1086
 
1110
  'mla_rollover_text' => '',
1111
  'mla_caption' => ''
1112
  );
1113
+
1114
  $mla_arguments = array_merge( array(
1115
  'mla_output' => 'flat',
1116
  'mla_style' => NULL,
1125
  'term_id' => NULL,
1126
  'mla_end_size'=> 1,
1127
  'mla_mid_size' => 2,
1128
+ 'mla_prev_text' => '&laquo; ' . __( 'Previous', 'media-library-assistant' ),
1129
+ 'mla_next_text' => __( 'Next', 'media-library-assistant' ) . ' &raquo;',
1130
  'mla_page_parameter' => 'mla_cloud_current',
1131
  'mla_cloud_current' => NULL,
1132
  'mla_paginate_total' => NULL,
1133
  'mla_paginate_type' => 'plain'),
1134
  $mla_item_specific_arguments
1135
  );
1136
+
1137
  $defaults = array_merge(
1138
  self::$mla_get_terms_parameters,
1139
  array(
1146
 
1147
  'echo' => false,
1148
  'link' => 'view',
1149
+
1150
  'itemtag' => 'ul',
1151
  'termtag' => 'li',
1152
  'captiontag' => '',
1154
  ),
1155
  $mla_arguments
1156
  );
1157
+
1158
  /*
1159
  * The mla_paginate_current parameter can be changed to support multiple galleries per page.
1160
  */
1161
+ if ( ! isset( $attr['mla_page_parameter'] ) ) {
1162
  $attr['mla_page_parameter'] = $defaults['mla_page_parameter'];
1163
+ }
1164
+
1165
  $mla_page_parameter = $attr['mla_page_parameter'];
1166
 
1167
  /*
1169
  * "MLA pagination" easier. Look for this parameter in $_REQUEST
1170
  * if it's not present in the shortcode itself.
1171
  */
1172
+ if ( ! isset( $attr[ $mla_page_parameter ] ) ) {
1173
+ if ( isset( $_REQUEST[ $mla_page_parameter ] ) ) {
1174
  $attr[ $mla_page_parameter ] = $_REQUEST[ $mla_page_parameter ];
1175
+ }
1176
+ }
1177
 
1178
  /*
1179
  * Look for 'request' substitution parameters,
1184
  * item-specific Display Content parameters must be evaluated
1185
  * later, when all of the information is available.
1186
  */
1187
+ if ( array_key_exists( $attr_key, $mla_item_specific_arguments ) ) {
1188
  continue;
1189
+ }
1190
+
1191
  $attr_value = str_replace( '{+', '[+', str_replace( '+}', '+]', $attr_value ) );
1192
  $replacement_values = MLAData::mla_expand_field_level_parameters( $attr_value );
1193
 
1194
+ if ( ! empty( $replacement_values ) ) {
1195
  $attr[ $attr_key ] = MLAData::mla_parse_template( $attr_value, $replacement_values );
1196
+ }
1197
  }
1198
+
1199
  $attr = apply_filters( 'mla_tag_cloud_attributes', $attr );
1200
  $arguments = shortcode_atts( $defaults, $attr );
1201
 
1203
  * $mla_page_parameter, if non-default, doesn't make it through the shortcode_atts filter,
1204
  * so we handle it separately
1205
  */
1206
+ if ( ! isset( $arguments[ $mla_page_parameter ] ) ) {
1207
+ if ( isset( $attr[ $mla_page_parameter ] ) ) {
1208
  $arguments[ $mla_page_parameter ] = $attr[ $mla_page_parameter ];
1209
+ } else {
1210
  $arguments[ $mla_page_parameter ] = $defaults['mla_cloud_current'];
1211
 
1212
+ }
1213
+ }
1214
+
1215
  /*
1216
  * Process the pagination parameter, if present
1217
  */
1223
 
1224
  self::$mla_debug = !empty( $arguments['mla_debug'] ) && ( 'true' == strtolower( $arguments['mla_debug'] ) );
1225
  if ( self::$mla_debug ) {
1226
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug attributes', 'media-library-assistant' ) . '</strong> = ' . var_export( $attr, true ) . '</p>';
1227
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug arguments', 'media-library-assistant' ) . '</strong> = ' . var_export( $arguments, true ) . '</p>';
1228
  }
1229
 
1230
  /*
1231
  * Determine output type and templates
1232
  */
1233
  $output_parameters = array_map( 'strtolower', array_map( 'trim', explode( ',', $arguments['mla_output'] ) ) );
1234
+
1235
  if ( $is_grid = 'grid' == $output_parameters[0] ) {
1236
  $default_style = MLAOptions::mla_get_option('default_tag_cloud_style');
1237
  $default_markup = MLAOptions::mla_get_option('default_tag_cloud_markup');
1238
+
1239
+ if ( NULL == $arguments['mla_style'] ) {
1240
  $arguments['mla_style'] = $default_style;
1241
+ }
1242
+
1243
  if ( NULL == $arguments['mla_markup'] ) {
1244
  $arguments['mla_markup'] = $default_markup;
1245
  $arguments['itemtag'] = 'dl';
1247
  $arguments['captiontag'] = 'dd';
1248
  }
1249
  }
1250
+
1251
  if ( $is_list = 'list' == $output_parameters[0] ) {
1252
  $default_style = 'none';
1253
  if ( empty( $arguments['captiontag'] ) ) {
1254
  $default_markup = 'tag-cloud-ul';
1255
  } else {
1256
  $default_markup = 'tag-cloud-dl';
1257
+
1258
  if ( 'dd' == $arguments['captiontag'] ) {
1259
  $arguments['itemtag'] = 'dl';
1260
  $arguments['termtag'] = 'dt';
1261
  }
1262
  }
1263
+
1264
+ if ( NULL == $arguments['mla_style'] ) {
1265
  $arguments['mla_style'] = $default_style;
1266
+ }
1267
+
1268
+ if ( NULL == $arguments['mla_markup'] ) {
1269
  $arguments['mla_markup'] = $default_markup;
1270
+ }
1271
  }
1272
+
1273
  $is_pagination = in_array( $output_parameters[0], array( 'previous_link', 'current_link', 'next_link', 'previous_page', 'next_page', 'paginate_links' ) );
1274
+
1275
  /*
1276
  * Convert taxonomy list to an array
1277
  */
1278
+ if ( is_string( $arguments['taxonomy'] ) ) {
1279
  $arguments['taxonomy'] = explode( ',', $arguments['taxonomy'] );
1280
+ }
1281
 
1282
  $tags = self::mla_get_terms( $arguments );
1283
+
1284
  if ( self::$mla_debug ) {
1285
  $cloud = self::$mla_debug_messages;
1286
  self::$mla_debug_messages = '';
1287
+ } else {
 
1288
  $cloud = '';
1289
+ }
1290
 
1291
  /*
1292
  * Invalid taxonomy names return WP_Error
1293
  */
1294
  if ( is_wp_error( $tags ) ) {
1295
+ $cloud .= '<strong>' . __( 'ERROR:', 'media-library-assistant' ) . ' ' . $tags->get_error_message() . '</strong>, ' . $tags->get_error_data( $tags->get_error_code() );
1296
 
1297
+ if ( 'array' == $arguments['mla_output'] ) {
1298
  return array( $cloud );
1299
+ }
1300
+
1301
+ if ( empty($arguments['echo']) ) {
1302
  return $cloud;
1303
+ }
1304
+
1305
  echo $cloud;
1306
  return;
1307
  }
1308
+
1309
  if ( empty( $tags ) ) {
1310
  if ( self::$mla_debug ) {
1311
+ $cloud .= '<p><strong>' . __( 'mla_debug empty cloud', 'media-library-assistant' ) . '</strong>, query = ' . var_export( $arguments, true ) . '</p>';
1312
  }
1313
+
1314
  $cloud .= $arguments['mla_nolink_text'];
1315
+ if ( 'array' == $arguments['mla_output'] ) {
1316
  return array( $cloud );
1317
+ }
1318
+
1319
+ if ( empty($arguments['echo']) ) {
1320
  return $cloud;
1321
+ }
1322
+
1323
  echo $cloud;
1324
  return;
1325
  }
1326
+
1327
  /*
1328
  * Fill in the item_specific link properties, calculate cloud parameters
1329
  */
1330
+ if ( isset( $tags['found_rows'] ) ) {
1331
  $found_rows = $tags['found_rows'];
1332
  unset( $tags['found_rows'] );
1333
+ } else {
1334
  $found_rows = count( $tags );
1335
+ }
1336
+
1337
  $min_count = 0x7FFFFFFF;
1338
  $max_count = 0;
1339
  $min_scaled_count = 0x7FFFFFFF;
1340
  $max_scaled_count = 0;
1341
  foreach ( $tags as $key => $tag ) {
1342
  $tag->scaled_count = apply_filters( 'mla_tag_cloud_scale', round(log10($tag->count + 1) * 100), $attr, $arguments, $tag );
1343
+
1344
+ if ( $tag->count < $min_count ) {
1345
  $min_count = $tag->count;
1346
+ }
1347
+
1348
+ if ( $tag->count > $max_count ) {
1349
  $max_count = $tag->count;
1350
+ }
1351
+
1352
+ if ( $tag->scaled_count < $min_scaled_count ) {
1353
  $min_scaled_count = $tag->scaled_count;
1354
+ }
1355
+
1356
+ if ( $tag->scaled_count > $max_scaled_count ) {
1357
  $max_scaled_count = $tag->scaled_count;
1358
+ }
1359
+
1360
  $link = get_edit_tag_link( $tag->term_id, $tag->taxonomy );
1361
  if ( ! is_wp_error( $link ) ) {
1362
  $tags[ $key ]->edit_link = $link;
1365
  }
1366
 
1367
  if ( is_wp_error( $link ) ) {
1368
+ $cloud = '<strong>' . __( 'ERROR:', 'media-library-assistant' ) . ' ' . $link->get_error_message() . '</strong>, ' . $link->get_error_data( $link->get_error_code() );
1369
+
1370
+ if ( 'array' == $arguments['mla_output'] ) {
1371
  return array( $cloud );
1372
+ }
1373
+
1374
+ if ( empty($arguments['echo']) ) {
1375
  return $cloud;
1376
+ }
1377
+
1378
  echo $cloud;
1379
  return;
1380
  }
1381
 
1382
+ if ( 'edit' == $arguments['link'] ) {
1383
  $tags[ $key ]->link = $tags[ $key ]->edit_link;
1384
+ } else {
1385
  $tags[ $key ]->link = $tags[ $key ]->term_link;
1386
+ }
1387
  } // foreach tag
1388
 
1389
  // $instance supports multiple clouds in one page/post
1399
 
1400
  $columns = absint( $arguments['columns'] );
1401
  $margin_string = strtolower( trim( $arguments['mla_margin'] ) );
1402
+
1403
+ if ( is_numeric( $margin_string ) && ( 0 != $margin_string) ) {
1404
  $margin_string .= '%'; // Legacy values are always in percent
1405
+ }
1406
+
1407
+ if ( '%' == substr( $margin_string, -1 ) ) {
1408
  $margin_percent = (float) substr( $margin_string, 0, strlen( $margin_string ) - 1 );
1409
+ } else {
1410
  $margin_percent = 0;
1411
+ }
1412
+
1413
  $width_string = strtolower( trim( $arguments['mla_itemwidth'] ) );
1414
  if ( 'none' != $width_string ) {
1415
  switch ( $width_string ) {
1416
  case 'exact':
1417
  $margin_percent = 0;
1418
+ // fallthru
1419
  case 'calculate':
1420
  $width_string = $columns > 0 ? (floor(1000/$columns)/10) - ( 2.0 * $margin_percent ) : 100 - ( 2.0 * $margin_percent );
1421
+ // fallthru
1422
  default:
1423
+ if ( is_numeric( $width_string ) && ( 0 != $width_string) ) {
1424
  $width_string .= '%'; // Legacy values are always in percent
1425
+ }
1426
  }
1427
  } // $use_width
1428
+
1429
  $float = strtolower( $arguments['mla_float'] );
1430
+ if ( ! in_array( $float, array( 'left', 'none', 'right' ) ) ) {
1431
  $float = is_rtl() ? 'right' : 'left';
1432
+ }
1433
 
1434
  /*
1435
  * Calculate cloud parameters
1436
  */
1437
  $spread = $max_scaled_count - $min_scaled_count;
1438
+ if ( $spread <= 0 ) {
1439
  $spread = 1;
1440
+ }
1441
+
1442
  $font_spread = $arguments['largest'] - $arguments['smallest'];
1443
+ if ( $font_spread < 0 ) {
1444
  $font_spread = 1;
1445
+ }
1446
+
1447
  $font_step = $font_spread / $spread;
1448
 
1449
  $style_values = array(
1486
  $style_values['mla_style'] = $default_style;
1487
  $style_template = MLAOptions::mla_fetch_gallery_template( $default_style, 'style' );
1488
  }
1489
+
1490
  if ( ! empty ( $style_template ) ) {
1491
  /*
1492
  * Look for 'query' and 'request' substitution parameters
1505
  $style_values['itemwidth'] = 'auto';
1506
  $style_template = preg_replace( '/width:[\s]*\[\+itemwidth\+\][\%]*[\;]*/', '', $style_template );
1507
  }
1508
+
1509
  $style_values = apply_filters( 'mla_tag_cloud_style_values', $style_values );
1510
  $style_template = apply_filters( 'mla_tag_cloud_style_template', $style_template );
1511
  $gallery_style = MLAData::mla_parse_template( $style_template, $style_values );
1512
  $gallery_style = apply_filters( 'mla_tag_cloud_style_parse', $gallery_style, $style_template, $style_values );
1513
  } // !empty template
1514
  } // use_mla_tag_cloud_style
1515
+
1516
  $upload_dir = wp_upload_dir();
1517
  $markup_values = $style_values;
1518
  $markup_values['site_url'] = site_url();
1525
  $markup_values['mla_markup'] = $default_markup;
1526
  $open_template = MLAOptions::mla_fetch_gallery_template( $default_markup, 'markup' );
1527
  }
1528
+
1529
+ if ( empty( $open_template ) ) {
1530
  $open_template = '';
1531
+ }
1532
+
1533
  if ( $is_grid ) {
1534
  $row_open_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-row-open', 'markup' );
1535
+ if ( empty( $row_open_template ) ) {
1536
  $row_open_template = '';
1537
+ }
1538
+ } else {
1539
  $row_open_template = '';
1540
+ }
1541
+
1542
  $item_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-item', 'markup' );
1543
+ if ( empty( $item_template ) ) {
1544
  $item_template = '';
1545
+ }
1546
+
1547
  if ( $is_grid ) {
1548
  $row_close_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-row-close', 'markup' );
1549
+ if ( empty( $row_close_template ) ) {
1550
  $row_close_template = '';
1551
+ }
1552
+ } else {
1553
  $row_close_template = '';
1554
+ }
1555
+
1556
  $close_template = MLAOptions::mla_fetch_gallery_template( $markup_values['mla_markup'] . '-close', 'markup' );
1557
+ if ( empty( $close_template ) ) {
1558
  $close_template = '';
1559
+ }
1560
+
1561
  /*
1562
  * Look for gallery-level markup substitution parameters
1563
  */
1566
 
1567
  $markup_values = apply_filters( 'mla_tag_cloud_open_values', $markup_values );
1568
  $open_template = apply_filters( 'mla_tag_cloud_open_template', $open_template );
1569
+ if ( empty( $open_template ) ) {
1570
  $gallery_open = '';
1571
+ } else {
1572
  $gallery_open = MLAData::mla_parse_template( $open_template, $markup_values );
1573
+ }
1574
 
1575
  $gallery_open = apply_filters( 'mla_tag_cloud_open_parse', $gallery_open, $open_template, $markup_values );
1576
  $cloud .= $gallery_style . $gallery_open;
1579
  /*
1580
  * Handle 'previous_page', 'next_page', and 'paginate_links'
1581
  */
1582
+ if ( isset( $attr['limit'] ) ) {
1583
  $attr['posts_per_page'] = $attr['limit'];
1584
+ }
1585
+
1586
  $pagination_result = self::_process_pagination_output_types( $output_parameters, $markup_values, $arguments, $attr, $found_rows, $output );
1587
+ if ( false !== $pagination_result ) {
1588
  return $pagination_result;
1589
+ }
1590
 
1591
  /*
1592
  * For "previous_link", "current_link" and "next_link", discard all of the $tags except the appropriate choice
1593
  */
1594
  $link_type = $output_parameters[0];
1595
+
1596
+ if ( ! in_array( $link_type, array ( 'previous_link', 'current_link', 'next_link' ) ) ) {
1597
+ return ''; // unknown output type
1598
+ }
1599
+
1600
  $is_wrap = isset( $output_parameters[1] ) && 'wrap' == $output_parameters[1];
1601
  if ( empty( $arguments['term_id'] ) ) {
1602
  $target_id = -2; // won't match anything
1603
+ } else {
 
1604
  $current_id = $arguments['term_id'];
1605
+
1606
  foreach ( $tags as $id => $tag ) {
1607
+ if ( $tag->term_id == $current_id ) {
1608
  break;
1609
+ }
1610
  }
1611
+
1612
  switch ( $link_type ) {
1613
  case 'previous_link':
1614
  $target_id = $id - 1;
1621
  $target_id = $id;
1622
  } // link_type
1623
  }
1624
+
1625
  $target = NULL;
1626
  if ( isset( $tags[ $target_id ] ) ) {
1627
  $target = $tags[ $target_id ];
1628
+ } elseif ( $is_wrap ) {
 
1629
  switch ( $link_type ) {
1630
  case 'previous_link':
1631
  $target = array_pop( $tags );
1634
  $target = array_shift( $tags );
1635
  } // link_type
1636
  } // is_wrap
1637
+
1638
+ if ( isset( $target ) ) {
1639
  $tags = array( $target );
1640
+ } elseif ( ! empty( $arguments['mla_nolink_text'] ) ) {
1641
  return self::_process_shortcode_parameter( $arguments['mla_nolink_text'], $markup_values ) . '</a>';
1642
+ } else {
1643
  return '';
1644
+ }
1645
  } // is_pagination
1646
+
1647
  /*
1648
  * Accumulate links for flat and array output
1649
  */
1652
  $column_index = 0;
1653
  foreach ( $tags as $key => $tag ) {
1654
  $item_values = $markup_values;
1655
+
1656
  /*
1657
  * fill in item-specific elements
1658
  */
1659
  $item_values['index'] = (string) 1 + $column_index;
1660
+ if ( $item_values['columns'] > 0 && ( 1 + $column_index ) % $item_values['columns'] == 0 ) {
1661
  $item_values['last_in_row'] = 'last_in_row';
1662
+ } else {
1663
  $item_values['last_in_row'] = '';
1664
+ }
1665
 
1666
  $item_values['key'] = $key;
1667
  $item_values['term_id'] = $tag->term_id;
1680
  $item_values['termlink_url'] = $tag->term_link;
1681
  // Added in the code below:
1682
  // 'caption', 'link_attributes', 'rollover_text', 'link_style', 'link_text', 'editlink', 'termlink', 'thelink'
1683
+
1684
  /*
1685
  * Add item_specific field-level substitution parameters
1686
  */
1688
  foreach( $mla_item_specific_arguments as $index => $value ) {
1689
  $new_text .= str_replace( '{+', '[+', str_replace( '+}', '+]', $arguments[ $index ] ) );
1690
  }
1691
+
1692
  $item_values = MLAData::mla_expand_field_level_parameters( $new_text, $attr, $item_values );
1693
 
1694
  if ( $item_values['captiontag'] ) {
1695
  $item_values['caption'] = wptexturize( $tag->description );
1696
+ if ( ! empty( $arguments['mla_caption'] ) ) {
1697
  $item_values['caption'] = wptexturize( self::_process_shortcode_parameter( $arguments['mla_caption'], $item_values ) );
1698
+ }
1699
+ } else {
1700
  $item_values['caption'] = '';
1701
+ }
1702
+
1703
+ if ( ! empty( $arguments['mla_link_text'] ) ) {
1704
  $link_text = self::_process_shortcode_parameter( $arguments['mla_link_text'], $item_values );
1705
+ } else {
1706
  $link_text = false;
1707
+ }
1708
 
1709
  /*
1710
  * Apply the Display Content parameters.
1711
  */
1712
+ if ( ! empty( $arguments['mla_target'] ) ) {
1713
  $link_attributes = 'target="' . $arguments['mla_target'] . '" ';
1714
+ } else {
1715
  $link_attributes = '';
1716
+ }
1717
+
1718
+ if ( ! empty( $arguments['mla_link_attributes'] ) ) {
1719
  $link_attributes .= self::_process_shortcode_parameter( $arguments['mla_link_attributes'], $item_values ) . ' ';
1720
+ }
1721
 
1722
+ if ( ! empty( $arguments['mla_link_class'] ) ) {
1723
  $link_attributes .= 'class="' . self::_process_shortcode_parameter( $arguments['mla_link_class'], $item_values ) . '" ';
1724
+ }
1725
 
1726
  $item_values['link_attributes'] = $link_attributes;
1727
+
1728
+ $item_values['rollover_text'] = sprintf( _n( $item_values['single_text'], $item_values['multiple_text'], $item_values['count'], 'media-library-assistant' ), number_format_i18n( $item_values['count'] ) );
1729
  if ( ! empty( $arguments['mla_rollover_text'] ) ) {
1730
  $item_values['rollover_text'] = esc_attr( self::_process_shortcode_parameter( $arguments['mla_rollover_text'], $item_values ) );
1731
  }
1733
  if ( ! empty( $arguments['mla_link_href'] ) ) {
1734
  $link_href = self::_process_shortcode_parameter( $arguments['mla_link_href'], $item_values );
1735
  $item_values['link_url'] = $link_href;
1736
+ } else {
 
1737
  $link_href = '';
1738
+ }
1739
 
1740
  if ( ! empty( $arguments['mla_link_style'] ) ) {
1741
  $item_values['link_style'] = esc_attr( self::_process_shortcode_parameter( $arguments['mla_link_style'], $item_values ) );
1742
+ } else {
 
1743
  $item_values['link_style'] = 'font-size: ' . $item_values['font_size'] . $item_values['unit'];
1744
+ }
1745
 
1746
  if ( ! empty( $arguments['mla_link_text'] ) ) {
1747
  $item_values['link_text'] = esc_attr( self::_process_shortcode_parameter( $arguments['mla_link_text'], $item_values ) );
1748
+ } else {
 
1749
  $item_values['link_text'] = $item_values['name'];
1750
+ }
1751
 
1752
  /*
1753
  * Editlink, termlink and thelink
1755
  $item_values['editlink'] = sprintf( '<a %1$shref="%2$s" title="%3$s" style="%4$s">%5$s</a>', $link_attributes, $item_values['editlink_url'], $item_values['rollover_text'], $item_values['link_style'], $item_values['link_text'] );
1756
  $item_values['termlink'] = sprintf( '<a %1$shref="%2$s" title="%3$s" style="%4$s">%5$s</a>', $link_attributes, $item_values['termlink_url'], $item_values['rollover_text'], $item_values['link_style'], $item_values['link_text'] );
1757
 
1758
+ if ( ! empty( $link_href ) ) {
1759
  $item_values['thelink'] = sprintf( '<a %1$shref="%2$s" title="%3$s" style="%4$s">%5$s</a>', $link_attributes, $link_href, $item_values['rollover_text'], $item_values['link_style'], $item_values['link_text'] );
1760
+ } elseif ( 'edit' == $arguments['link'] ) {
1761
  $item_values['thelink'] = $item_values['editlink'];
1762
+ } elseif ( 'view' == $arguments['link'] ) {
1763
  $item_values['thelink'] = $item_values['termlink'];
1764
+ } elseif ( 'span' == $arguments['link'] ) {
1765
  $item_values['thelink'] = sprintf( '<span %1$sstyle="%2$s">%3$s</a>', $link_attributes, $item_values['link_style'], $item_values['link_text'] );
1766
+ } else {
1767
  $item_values['thelink'] = $item_values['link_text'];
1768
+ }
1769
 
1770
  if ( $is_grid || $is_list ) {
1771
  /*
1777
  $parse_value = MLAData::mla_parse_template( $row_open_template, $markup_values );
1778
  $cloud .= apply_filters( 'mla_tag_cloud_row_open_parse', $parse_value, $row_open_template, $markup_values );
1779
  }
1780
+
1781
  /*
1782
  * item markup
1783
  */
1786
  $item_template = apply_filters( 'mla_tag_cloud_item_template', $item_template );
1787
  $parse_value = MLAData::mla_parse_template( $item_template, $item_values );
1788
  $cloud .= apply_filters( 'mla_tag_cloud_item_parse', $parse_value, $item_template, $item_values );
1789
+
1790
  /*
1791
  * End of row markup
1792
  */
1797
  $cloud .= apply_filters( 'mla_tag_cloud_row_close_parse', $parse_value, $row_close_template, $markup_values );
1798
  }
1799
  } // is_grid || is_list
1800
+ elseif ( $is_pagination ) {
1801
  return $item_values['thelink'];
1802
+ } else {
1803
  $column_index++;
1804
  $item_values = apply_filters( 'mla_tag_cloud_item_values', $item_values );
1805
  $tag_links[] = apply_filters( 'mla_tag_cloud_item_parse', $item_values['thelink'], NULL, $item_values );
1806
  }
1807
  } // foreach tag
1808
+
1809
  if ($is_grid || $is_list ) {
1810
  /*
1811
  * Close out partial row
1816
  $parse_value = MLAData::mla_parse_template( $row_close_template, $markup_values );
1817
  $cloud .= apply_filters( 'mla_tag_cloud_row_close_parse', $parse_value, $row_close_template, $markup_values );
1818
  }
1819
+
1820
  $markup_values = apply_filters( 'mla_tag_cloud_close_values', $markup_values );
1821
  $close_template = apply_filters( 'mla_tag_cloud_close_template', $close_template );
1822
  $parse_value = MLAData::mla_parse_template( $close_template, $markup_values );
1833
  break;
1834
  } // switch format
1835
  }
1836
+
1837
  //$cloud = wp_generate_tag_cloud( $tags, $arguments );
1838
+
1839
+ if ( 'array' == $arguments['mla_output'] || empty($arguments['echo']) ) {
1840
  return $cloud;
1841
+ }
1842
+
1843
  echo $cloud;
1844
  }
1845
+
1846
  /**
1847
  * The MLA Tag Cloud shortcode.
1848
  *
1858
  /*
1859
  * Make sure $attr is an array, even if it's empty
1860
  */
1861
+ if ( empty( $attr ) ) {
1862
  $attr = array();
1863
+ } elseif ( is_string( $attr ) ) {
1864
  $attr = shortcode_parse_atts( $attr );
1865
+ }
1866
 
1867
  /*
1868
  * The 'array' format makes no sense in a shortcode
1869
  */
1870
+ if ( isset( $attr['mla_output'] ) && 'array' == $attr['mla_output'] ) {
1871
  $attr['mla_output'] = 'flat';
1872
+ }
1873
 
1874
  /*
1875
  * A shortcode must return its content to the caller, so "echo" makes no sense
1878
 
1879
  return self::mla_tag_cloud( $attr );
1880
  }
1881
+
1882
  /**
1883
  * Handles brace/bracket escaping and parses template for a shortcode parameter
1884
  *
1894
  $new_text = str_replace( '\[', '{', str_replace( '\]', '}', $new_text ) );
1895
  return MLAData::mla_parse_template( $new_text, $markup_values );
1896
  }
1897
+
1898
  /**
1899
  * Handles pagnation output types 'previous_page', 'next_page', and 'paginate_links'
1900
  *
1909
  * @return mixed false or string with HTML for pagination output types
1910
  */
1911
  private static function _paginate_links( $output_parameters, $markup_values, $arguments, $found_rows, $output = '' ) {
1912
+ if ( 2 > $markup_values['last_page'] ) {
1913
  return '';
1914
+ }
1915
+
1916
  $show_all = $prev_next = false;
1917
+
1918
+ if ( isset ( $output_parameters[1] ) ) {
1919
  switch ( $output_parameters[1] ) {
1920
  case 'show_all':
1921
  $show_all = true;
1923
  case 'prev_next':
1924
  $prev_next = true;
1925
  }
1926
+ }
1927
 
1928
  $mla_page_parameter = $arguments['mla_page_parameter'];
1929
  $current_page = $markup_values['current_page'];
1931
  $end_size = absint( $arguments['mla_end_size'] );
1932
  $mid_size = absint( $arguments['mla_mid_size'] );
1933
  $posts_per_page = $markup_values['posts_per_page'];
1934
+
1935
  $new_target = ( ! empty( $arguments['mla_target'] ) ) ? 'target="' . $arguments['mla_target'] . '" ' : '';
1936
+
1937
  /*
1938
  * these will add to the default classes
1939
  */
1948
  */
1949
  $page_links = array();
1950
  $dots = false;
1951
+
1952
  if ( $prev_next && $current_page && 1 < $current_page ) {
1953
  $markup_values['new_page'] = $current_page - 1;
1954
  $new_title = ( ! empty( $arguments['mla_rollover_text'] ) ) ? 'title="' . esc_attr( self::_process_shortcode_parameter( $arguments['mla_rollover_text'], $markup_values ) ) . '" ' : '';
1955
  $new_url = add_query_arg( array( $mla_page_parameter => $current_page - 1 ), $new_base );
1956
+ $prev_text = ( ! empty( $arguments['mla_prev_text'] ) ) ? esc_attr( self::_process_shortcode_parameter( $arguments['mla_prev_text'], $markup_values ) ) : '&laquo; ' . __( 'Previous', 'media-library-assistant' );
1957
  $page_links[] = sprintf( '<a %1$sclass="prev page-numbers%2$s" %3$s%4$shref="%5$s">%6$s</a>',
1958
  /* %1$s */ $new_target,
1959
  /* %2$s */ $new_class,
1962
  /* %5$s */ $new_url,
1963
  /* %6$s */ $prev_text );
1964
  }
1965
+
1966
  for ( $new_page = 1; $new_page <= $last_page; $new_page++ ) {
1967
  $new_page_display = number_format_i18n( $new_page );
1968
  $markup_values['new_page'] = $new_page;
1969
  $new_title = ( ! empty( $arguments['mla_rollover_text'] ) ) ? 'title="' . esc_attr( self::_process_shortcode_parameter( $arguments['mla_rollover_text'], $markup_values ) ) . '" ' : '';
1970
+
1971
  if ( $new_page == $current_page ) {
1972
  // build current page span
1973
  $page_links[] = sprintf( '<span class="page-numbers current%1$s">%2$s</span>',
1974
  /* %1$s */ $new_class,
1975
  /* %2$s */ $new_page_display );
1976
  $dots = true;
1977
+ } else {
 
1978
  if ( $show_all || ( $new_page <= $end_size || ( $current_page && $new_page >= $current_page - $mid_size && $new_page <= $current_page + $mid_size ) || $new_page > $last_page - $end_size ) ) {
1979
  // build link
1980
  $new_url = add_query_arg( array( $mla_page_parameter => $new_page ), $new_base );
1986
  /* %5$s */ $new_url,
1987
  /* %6$s */ $new_page_display );
1988
  $dots = true;
1989
+ } elseif ( $dots && ! $show_all ) {
 
1990
  // build link
1991
  $page_links[] = sprintf( '<span class="page-numbers dots%1$s">&hellip;</span>',
1992
  /* %1$s */ $new_class );
1994
  }
1995
  } // ! current
1996
  } // for $new_page
1997
+
1998
  if ( $prev_next && $current_page && ( $current_page < $last_page || -1 == $last_page ) ) {
1999
  // build next link
2000
  $markup_values['new_page'] = $current_page + 1;
2001
  $new_title = ( ! empty( $arguments['mla_rollover_text'] ) ) ? 'title="' . esc_attr( self::_process_shortcode_parameter( $arguments['mla_rollover_text'], $markup_values ) ) . '" ' : '';
2002
  $new_url = add_query_arg( array( $mla_page_parameter => $current_page + 1 ), $new_base );
2003
+ $next_text = ( ! empty( $arguments['mla_next_text'] ) ) ? esc_attr( self::_process_shortcode_parameter( $arguments['mla_next_text'], $markup_values ) ) : __( 'Next', 'media-library-assistant' ) . ' &raquo;';
2004
  $page_links[] = sprintf( '<a %1$sclass="next page-numbers%2$s" %3$s%4$shref="%5$s">%6$s</a>',
2005
  /* %1$s */ $new_target,
2006
  /* %2$s */ $new_class,
2020
  default:
2021
  $results = join("\n", $page_links);
2022
  } // mla_paginate_type
2023
+
2024
  return $output . $results;
2025
  }
2026
+
2027
  /**
2028
  * Handles pagnation output types 'previous_page', 'next_page', and 'paginate_links'
2029
  *
2039
  * @return mixed false or string with HTML for pagination output types
2040
  */
2041
  private static function _process_pagination_output_types( $output_parameters, $markup_values, $arguments, $attr, $found_rows, $output = '' ) {
2042
+ if ( ! in_array( $output_parameters[0], array( 'previous_page', 'next_page', 'paginate_links' ) ) ) {
2043
  return false;
2044
+ }
2045
+
2046
  /*
2047
  * Add data selection parameters to gallery-specific and mla_gallery-specific parameters
2048
  */
2049
  $arguments = array_merge( $arguments, shortcode_atts( self::$mla_get_shortcode_attachments_parameters, $attr ) );
2050
  $posts_per_page = absint( $arguments['posts_per_page'] );
2051
  $mla_page_parameter = $arguments['mla_page_parameter'];
2052
+
2053
  /*
2054
  * $mla_page_parameter, if set, doesn't make it through the shortcode_atts filter,
2055
  * so we handle it separately
2056
  */
2057
+ if ( ! isset( $arguments[ $mla_page_parameter ] ) ) {
2058
+ if ( isset( $attr[ $mla_page_parameter ] ) ) {
2059
  $arguments[ $mla_page_parameter ] = $attr[ $mla_page_parameter ];
2060
+ } else {
2061
  $arguments[ $mla_page_parameter ] = '';
2062
+ }
2063
+ }
2064
+
2065
+ if ( 0 == $posts_per_page ) {
2066
  $posts_per_page = absint( $arguments['numberposts'] );
2067
+ }
2068
+
2069
+ if ( 0 == $posts_per_page ) {
2070
  $posts_per_page = absint( get_option('posts_per_page') );
2071
+ }
2072
 
2073
  if ( 0 < $posts_per_page ) {
2074
  $max_page = floor( $found_rows / $posts_per_page );
2075
+ if ( $max_page < ( $found_rows / $posts_per_page ) ) {
2076
  $max_page++;
2077
+ }
2078
+ } else {
2079
  $max_page = 1;
2080
+ }
2081
 
2082
+ if ( isset( $arguments['mla_paginate_total'] ) && $max_page > absint( $arguments['mla_paginate_total'] ) ) {
2083
  $max_page = absint( $arguments['mla_paginate_total'] );
2084
+ }
2085
+
2086
+ if ( isset( $arguments[ $mla_page_parameter ] ) ) {
2087
  $paged = absint( $arguments[ $mla_page_parameter ] );
2088
+ } else {
2089
  $paged = absint( $arguments['paged'] );
2090
+ }
2091
+
2092
+ if ( 0 == $paged ) {
2093
  $paged = 1;
2094
+ }
2095
 
2096
+ if ( $max_page < $paged ) {
2097
  $paged = $max_page;
2098
+ }
2099
 
2100
  switch ( $output_parameters[0] ) {
2101
  case 'previous_page':
2102
+ if ( 1 < $paged ) {
2103
  $new_page = $paged - 1;
2104
+ } else {
2105
  $new_page = 0;
2106
 
2107
+ if ( isset ( $output_parameters[1] ) ) {
2108
  switch ( $output_parameters[1] ) {
2109
  case 'wrap':
2110
  $new_page = $max_page;
2112
  case 'first':
2113
  $new_page = 1;
2114
  }
2115
+ }
2116
  }
2117
+
2118
  break;
2119
  case 'next_page':
2120
+ if ( $paged < $max_page ) {
2121
  $new_page = $paged + 1;
2122
+ } else {
2123
  $new_page = 0;
2124
 
2125
+ if ( isset ( $output_parameters[1] ) ) {
2126
  switch ( $output_parameters[1] ) {
2127
  case 'last':
2128
  $new_page = $max_page;
2130
  case 'wrap':
2131
  $new_page = 1;
2132
  }
2133
+ }
2134
  }
2135
+
2136
  break;
2137
  case 'paginate_links':
2138
  $new_page = 0;
2139
  $new_text = '';
2140
  }
2141
+
2142
  $markup_values['current_page'] = $paged;
2143
  $markup_values['new_page'] = $new_page;
2144
  $markup_values['last_page'] = $max_page;
2145
  $markup_values['posts_per_page'] = $posts_per_page;
2146
  $markup_values['found_rows'] = $found_rows;
2147
 
2148
+ if ( $paged ) {
2149
  $markup_values['current_offset'] = ( $paged - 1 ) * $posts_per_page;
2150
+ } else {
2151
  $markup_values['current_offset'] = 0;
2152
+ }
2153
+
2154
+ if ( $new_page ) {
2155
  $markup_values['new_offset'] = ( $new_page - 1 ) * $posts_per_page;
2156
+ } else {
2157
  $markup_values['new_offset'] = 0;
2158
+ }
2159
+
2160
  $markup_values['current_page_text'] = 'mla_paginate_current="[+current_page+]"';
2161
  $markup_values['new_page_text'] = 'mla_paginate_current="[+new_page+]"';
2162
  $markup_values['last_page_text'] = 'mla_paginate_total="[+last_page+]"';
2163
  $markup_values['posts_per_page_text'] = 'posts_per_page="[+posts_per_page+]"';
2164
+
2165
+ if ( 'HTTPS' == substr( $_SERVER["SERVER_PROTOCOL"], 0, 5 ) ) {
2166
  $markup_values['scheme'] = 'https://';
2167
+ } else {
2168
  $markup_values['scheme'] = 'http://';
2169
+ }
2170
+
2171
  $markup_values['http_host'] = $_SERVER['HTTP_HOST'];
2172
  $markup_values['request_uri'] = add_query_arg( array( $mla_page_parameter => $new_page ), $_SERVER['REQUEST_URI'] );
2173
  $markup_values['new_url'] = set_url_scheme( $markup_values['scheme'] . $markup_values['http_host'] . $markup_values['request_uri'] );
2175
  /*
2176
  * Build the new link, applying Gallery Display Content parameters
2177
  */
2178
+ if ( 'paginate_links' == $output_parameters[0] ) {
2179
  return self::_paginate_links( $output_parameters, $markup_values, $arguments, $found_rows, $output );
2180
+ }
2181
+
2182
  if ( 0 == $new_page ) {
2183
+ if ( ! empty( $arguments['mla_nolink_text'] ) ) {
2184
  return self::_process_shortcode_parameter( $arguments['mla_nolink_text'], $markup_values );
2185
+ } else {
2186
  return '';
2187
+ }
2188
  }
2189
+
2190
  $new_link = '<a ';
2191
+
2192
+ if ( ! empty( $arguments['mla_target'] ) ) {
2193
  $new_link .= 'target="' . $arguments['mla_target'] . '" ';
2194
+ }
2195
+
2196
+ if ( ! empty( $arguments['mla_link_class'] ) ) {
2197
  $new_link .= 'class="' . esc_attr( self::_process_shortcode_parameter( $arguments['mla_link_class'], $markup_values ) ) . '" ';
2198
+ }
2199
 
2200
+ if ( ! empty( $arguments['mla_rollover_text'] ) ) {
2201
  $new_link .= 'title="' . esc_attr( self::_process_shortcode_parameter( $arguments['mla_rollover_text'], $markup_values ) ) . '" ';
2202
+ }
2203
 
2204
+ if ( ! empty( $arguments['mla_link_attributes'] ) ) {
2205
  $new_link .= esc_attr( self::_process_shortcode_parameter( $arguments['mla_link_attributes'], $markup_values ) ) . ' ';
2206
+ }
2207
 
2208
+ if ( ! empty( $arguments['mla_link_href'] ) ) {
2209
  $new_link .= 'href="' . esc_attr( self::_process_shortcode_parameter( $arguments['mla_link_href'], $markup_values ) ) . '" >';
2210
+ } else {
2211
  $new_link .= 'href="' . $markup_values['new_url'] . '" >';
2212
+ }
2213
+
2214
+ if ( ! empty( $arguments['mla_link_text'] ) ) {
2215
  $new_link .= self::_process_shortcode_parameter( $arguments['mla_link_text'], $markup_values ) . '</a>';
2216
+ } else {
2217
  if ( 'previous_page' == $output_parameters[0] ) {
2218
+ if ( isset( $arguments['mla_prev_text'] ) ) {
2219
  $new_text = esc_attr( self::_process_shortcode_parameter( $arguments['mla_prev_text'], $markup_values ) );
2220
+ } else {
2221
+ $new_text = '&laquo; ' . __( 'Previous', 'media-library-assistant' );
2222
+ }
2223
+ } else {
2224
+ if ( isset( $arguments['mla_next_text'] ) ) {
2225
  $new_text = esc_attr( self::_process_shortcode_parameter( $arguments['mla_next_text'], $markup_values ) );
2226
+ } else {
2227
+ $new_text = __( 'Next', 'media-library-assistant' ) . ' &raquo;';
2228
+ }
2229
  }
2230
+
2231
  $new_link .= $new_text . '</a>';
2232
  }
2233
+
2234
  return $new_link;
2235
  }
2236
+
2237
  /**
2238
  * WP_Query filter "parameters"
2239
  *
2264
  $specification = str_replace( array( '<br />', '<p>', '</p>', "\r", "\n" ), ' ', $specification );
2265
  return $specification;
2266
  }
2267
+
2268
  /**
2269
  * Translates query parameters to a valid SQL order by clause.
2270
  *
2298
  $allowed_keys[] = 'meta_value';
2299
  $allowed_keys[] = 'meta_value_num';
2300
  }
2301
+
2302
  $obmatches = preg_split('/\s*,\s*/', trim($query_parameters['orderby']));
2303
  foreach ( $obmatches as $index => $value ) {
2304
  $count = preg_match('/([a-z0-9_]+)(\s+(ASC|DESC))?/i', $value, $matches);
2305
 
2306
  if ( $count && ( $value == $matches[0] ) && in_array( $matches[1], $allowed_keys ) ) {
2307
+ if ( 'rand' == $matches[1] ) {
2308
  $results[] = 'RAND()';
2309
+ } else {
2310
  switch ( $matches[1] ) {
2311
  case 'ID':
2312
  $matches[1] = "$wpdb->posts.ID";
2336
  default:
2337
  $matches[1] = "$wpdb->posts.post_" . $matches[1];
2338
  } // switch $matches[1]
2339
+
2340
  $results[] = isset( $matches[2] ) ? $matches[1] . $matches[2] : $matches[1] . $order;
2341
  } // not 'rand'
2342
  } // valid column specification
2343
  } // foreach $obmatches
2344
 
2345
  $orderby = implode( ', ', $results );
2346
+ if ( empty( $orderby ) ) {
2347
  return false;
2348
+ }
2349
  } // else filter by allowed keys, etc.
2350
 
2351
  return $orderby;
2412
  'meta_compare' => '',
2413
  'meta_query' => '',
2414
  // Search
2415
+ 's' => '',
2416
+ // Returned fields, for support topic by leoloso
2417
+ 'fields' => ''
2418
  );
2419
 
2420
  /**
2428
  * @var object
2429
  */
2430
  public static $mla_gallery_wp_query_object = NULL;
2431
+
2432
  /**
2433
  * Parses shortcode parameters and returns the gallery objects
2434
  *
2451
  /*
2452
  * Make sure $attr is an array, even if it's empty
2453
  */
2454
+ if ( empty( $attr ) ) {
2455
  $attr = array();
2456
+ } elseif ( is_string( $attr ) ) {
2457
  $attr = shortcode_parse_atts( $attr );
2458
+ }
2459
 
2460
  /*
2461
  * The "where used" queries have no $_REQUEST context available to them,
2465
  if ( isset( $attr['where_used_query'] ) && ( 'this-is-a-where-used-query' == $attr['where_used_query'] ) ) {
2466
  $where_used_query = true;
2467
  unset( $attr['where_used_query'] );
2468
+ } else {
 
2469
  $where_used_query = false;
2470
+ }
2471
 
2472
  /*
2473
  * Merge input arguments with defaults, then extract the query arguments.
2475
  * $return_found_rows is used to indicate that the call comes from gallery_shortcode(),
2476
  * which is the only call that supplies it.
2477
  */
2478
+ if ( ! is_null( $return_found_rows ) ) {
2479
  $attr = apply_filters( 'mla_gallery_query_attributes', $attr );
2480
+ }
2481
 
2482
  $arguments = shortcode_atts( self::$mla_get_shortcode_attachments_parameters, $attr );
2483
  $mla_page_parameter = $arguments['mla_page_parameter'];
2484
  unset( $arguments['mla_page_parameter'] );
2485
+
2486
  /*
2487
  * $mla_page_parameter, if set, doesn't make it through the shortcode_atts filter,
2488
  * so we handle it separately
2489
  */
2490
+ if ( ! isset( $arguments[ $mla_page_parameter ] ) ) {
2491
+ if ( isset( $attr[ $mla_page_parameter ] ) ) {
2492
  $arguments[ $mla_page_parameter ] = $attr[ $mla_page_parameter ];
2493
+ } else {
2494
  $arguments[ $mla_page_parameter ] = NULL;
2495
+ }
2496
+ }
2497
 
2498
  /*
2499
  * 'RAND' is not documented in the codex, but is present in the code.
2505
 
2506
  if ( !empty( $arguments['ids'] ) ) {
2507
  // 'ids' is explicitly ordered, unless you specify otherwise.
2508
+ if ( empty( $attr['orderby'] ) ) {
2509
  $arguments['orderby'] = 'post__in';
2510
+ }
2511
 
2512
  $arguments['include'] = $arguments['ids'];
2513
  }
2514
  unset( $arguments['ids'] );
2515
 
2516
+ if ( ! is_null( $return_found_rows ) ) {
2517
  $arguments = apply_filters( 'mla_gallery_query_arguments', $arguments );
2518
+ }
2519
+
2520
  /*
2521
  * Extract taxonomy arguments
2522
  */
2525
  if ( ! empty( $attr ) ) {
2526
  foreach ( $attr as $key => $value ) {
2527
  if ( 'tax_query' == $key ) {
2528
+ if ( is_array( $value ) ) {
2529
  $query_arguments[ $key ] = $value;
2530
+ } else {
2531
  $tax_query = NULL;
2532
  $value = self::_sanitize_query_specification( $value );
2533
 
2534
  /*
2535
  * Replace invalid queries from "where-used" callers with a harmless equivalent
2536
  */
2537
+ if ( $where_used_query && ( false !== strpos( $value, '{+' ) ) ) {
2538
  $value = "array( array( 'taxonomy' => 'none', 'field' => 'slug', 'terms' => 'none' ) )";
2539
+ }
2540
 
2541
  $function = @create_function('', 'return ' . $value . ';' );
2542
+ if ( is_callable( $function ) ) {
2543
  $tax_query = $function();
2544
+ }
2545
 
2546
+ if ( is_array( $tax_query ) ) {
2547
  $query_arguments[ $key ] = $tax_query;
2548
+ } else {
2549
+ return '<p>' . __( 'ERROR: Invalid mla_gallery', 'media-library-assistant' ) . ' tax_query = ' . var_export( $value, true ) . '</p>';
2550
  }
2551
  } // not array
2552
  } // tax_query
2553
  elseif ( array_key_exists( $key, $taxonomies ) ) {
2554
  $query_arguments[ $key ] = implode(',', array_filter( array_map( 'trim', explode( ',', $value ) ) ) );
2555
+
2556
  if ( 'false' == strtolower( trim( $arguments['tax_include_children'] ) ) ) {
2557
  $arguments['tax_include_children'] = false;
2558
+
2559
+ if ( '' == $arguments['tax_operator'] ) {
2560
+ $arguments['tax_operator'] = 'OR';
2561
+ }
2562
+ } else {
2563
  $arguments['tax_include_children'] = true;
2564
+ }
2565
+
2566
  if ( in_array( strtoupper( $arguments['tax_operator'] ), array( 'OR', 'IN', 'NOT IN', 'AND' ) ) ) {
2567
  $query_arguments['tax_query'] = array( array( 'taxonomy' => $key, 'field' => 'slug', 'terms' => explode( ',', $query_arguments[ $key ] ), 'operator' => strtoupper( $arguments['tax_operator'] ), 'include_children' => $arguments['tax_include_children'] ) );
2568
  unset( $query_arguments[ $key ] );
2572
  } // ! empty
2573
  unset( $arguments['tax_operator'] );
2574
  unset( $arguments['tax_include_children'] );
2575
+
2576
  /*
2577
  * $query_arguments has been initialized in the taxonomy code above.
2578
  */
2608
  case 'id':
2609
  if ( is_numeric( $value ) ) {
2610
  $query_arguments[ $key ] = intval( $value );
2611
+ if ( ! $children_ok ) {
2612
  $use_children = false;
2613
+ }
2614
  }
2615
  unset( $arguments[ $key ] );
2616
  break;
2631
  case 'offset':
2632
  if ( is_numeric( $value ) ) {
2633
  $query_arguments[ $key ] = intval( $value );
2634
+ if ( ! $children_ok ) {
2635
  $use_children = false;
2636
+ }
2637
  }
2638
  unset( $arguments[ $key ] );
2639
  break;
2643
  * Note: The query variable 'page' holds the pagenumber for a single paginated
2644
  * Post or Page that includes the <!--nextpage--> Quicktag in the post content.
2645
  */
2646
+ if ( get_query_var('page') ) {
2647
  $query_arguments[ $key ] = get_query_var('page');
2648
+ } else {
2649
  $query_arguments[ $key ] = (get_query_var('paged')) ? get_query_var('paged') : 1;
2650
+ }
2651
+ } elseif ( is_numeric( $value ) ) {
2652
  $query_arguments[ $key ] = intval( $value );
2653
+ } elseif ( '' === $value ) {
2654
  $query_arguments[ $key ] = 1;
2655
+ }
2656
+
2657
  unset( $arguments[ $key ] );
2658
  break;
2659
  case $mla_page_parameter :
2660
  case 'mla_paginate_total':
2661
+ if ( is_numeric( $value ) ) {
2662
  $query_arguments[ $key ] = intval( $value );
2663
+ } elseif ( '' === $value ) {
2664
  $query_arguments[ $key ] = 1;
2665
+ }
2666
+
2667
  unset( $arguments[ $key ] );
2668
  break;
2669
  case 'author':
2670
  case 'cat':
2671
  case 'tag_id':
2672
  if ( ! empty( $value ) ) {
2673
+ if ( is_array( $value ) ) {
2674
  $query_arguments[ $key ] = array_filter( $value );
2675
+ } else {
2676
  $query_arguments[ $key ] = array_filter( array_map( 'intval', explode( ",", $value ) ) );
2677
+ }
2678
+
2679
+ if ( 1 == count( $query_arguments[ $key ] ) ) {
2680
  $query_arguments[ $key ] = $query_arguments[ $key ][0];
2681
+ } else {
2682
  $query_arguments[ $key ] = implode(',', $query_arguments[ $key ] );
2683
+ }
2684
 
2685
  $use_children = false;
2686
  }
2697
  // fallthru
2698
  case 'exclude':
2699
  if ( ! empty( $value ) ) {
2700
+ if ( is_array( $value ) ) {
2701
  $query_arguments[ $key ] = array_filter( $value );
2702
+ } else {
2703
  $query_arguments[ $key ] = array_filter( array_map( 'intval', explode( ",", $value ) ) );
2704
+ }
2705
+
2706
+ if ( ! $children_ok ) {
2707
  $use_children = false;
2708
+ }
2709
  }
2710
  unset( $arguments[ $key ] );
2711
  break;
2712
  case 'tag_slug__and':
2713
  case 'tag_slug__in':
2714
  if ( ! empty( $value ) ) {
2715
+ if ( is_array( $value ) ) {
2716
  $query_arguments[ $key ] = $value;
2717
+ } else {
2718
  $query_arguments[ $key ] = array_filter( array_map( 'trim', explode( ",", $value ) ) );
2719
+ }
2720
 
2721
  $use_children = false;
2722
  }
2723
  unset( $arguments[ $key ] );
2724
  break;
2725
  case 'nopaging': // boolean
2726
+ if ( ! empty( $value ) && ( 'false' != strtolower( $value ) ) ) {
2727
  $query_arguments[ $key ] = true;
2728
+ }
2729
+
2730
  unset( $arguments[ $key ] );
2731
  break;
2732
  case 'author_name':
2744
  case 'orderby':
2745
  if ( ! empty( $value ) ) {
2746
  $query_arguments[ $key ] = $value;
2747
+
2748
+ if ( ! $children_ok ) {
2749
  $use_children = false;
2750
+ }
2751
  }
2752
+
2753
  unset( $arguments[ $key ] );
2754
  break;
2755
  case 'order':
2756
  if ( ! empty( $value ) ) {
2757
  $value = strtoupper( $value );
2758
+ if ( in_array( $value, array( 'ASC', 'DESC' ) ) ) {
2759
  $query_arguments[ $key ] = $value;
2760
+ }
2761
  }
2762
+
2763
  unset( $arguments[ $key ] );
2764
  break;
2765
  case 'meta_query':
2766
  if ( ! empty( $value ) ) {
2767
+ if ( is_array( $value ) ) {
2768
  $query_arguments[ $key ] = $value;
2769
+ } else {
2770
  $meta_query = NULL;
2771
  $value = self::_sanitize_query_specification( $value );
2772
 
2773
  /*
2774
  * Replace invalid queries from "where-used" callers with a harmless equivalent
2775
  */
2776
+ if ( $where_used_query && ( false !== strpos( $value, '{+' ) ) ) {
2777
  $value = "array( array( 'key' => 'unlikely', 'value' => 'none or otherwise unlikely' ) )";
2778
+ }
2779
 
2780
  $function = @create_function('', 'return ' . $value . ';' );
2781
+ if ( is_callable( $function ) ) {
2782
  $meta_query = $function();
2783
+ }
2784
+
2785
+ if ( is_array( $meta_query ) ) {
2786
  $query_arguments[ $key ] = $meta_query;
2787
+ } else {
2788
+ return '<p>' . __( 'ERROR: Invalid mla_gallery', 'media-library-assistant' ) . ' meta_query = ' . var_export( $value, true ) . '</p>';
2789
+ }
2790
  } // not array
2791
 
2792
  $use_children = false;
2793
  }
2794
+ unset( $arguments[ $key ] );
2795
+ break;
2796
+ case 'fields':
2797
+ if ( ! empty( $value ) ) {
2798
+ $value = strtolower( $value );
2799
+ if ( in_array( $value, array( 'ids', 'id=>parent' ) ) ) {
2800
+ $query_arguments[ $key ] = $value;
2801
+ }
2802
+ }
2803
+
2804
  unset( $arguments[ $key ] );
2805
  break;
2806
  default:
2812
  * Decide whether to use a "get_children" style query
2813
  */
2814
  if ( $use_children && ! isset( $query_arguments['post_parent'] ) ) {
2815
+ if ( ! isset( $query_arguments['id'] ) ) {
2816
  $query_arguments['post_parent'] = $post_parent;
2817
+ } else {
2818
  $query_arguments['post_parent'] = $query_arguments['id'];
2819
+ }
2820
 
2821
  unset( $query_arguments['id'] );
2822
  }
2833
  unset( $query_arguments['nopaging'] );
2834
  unset( $query_arguments['offset'] );
2835
  unset( $query_arguments['paged'] );
2836
+
2837
+ if ( isset( $query_arguments['mla_paginate_total'] ) && ( $query_arguments[ $mla_page_parameter ] > $query_arguments['mla_paginate_total'] ) ) {
2838
  $query_arguments['offset'] = 0x7FFFFFFF; // suppress further output
2839
+ } else {
2840
  $query_arguments['paged'] = $query_arguments[ $mla_page_parameter ];
2841
+ }
2842
+ } else {
2843
  if ( isset( $query_arguments['posts_per_page'] ) || isset( $query_arguments['posts_per_archive_page'] ) ||
2844
  isset( $query_arguments['paged'] ) || isset( $query_arguments['offset'] ) ) {
2845
  unset( $query_arguments['nopaging'] );
2848
  unset( $query_arguments[ $mla_page_parameter ] );
2849
  unset( $query_arguments['mla_paginate_total'] );
2850
 
2851
+ if ( isset( $query_arguments['post_mime_type'] ) && ('all' == strtolower( $query_arguments['post_mime_type'] ) ) ) {
2852
  unset( $query_arguments['post_mime_type'] );
2853
+ }
2854
 
2855
  if ( ! empty($query_arguments['include']) ) {
2856
  $incposts = wp_parse_id_list( $query_arguments['include'] );
2857
  $query_arguments['posts_per_page'] = count($incposts); // only the number of posts included
2858
  $query_arguments['post__in'] = $incposts;
2859
+ } elseif ( ! empty($query_arguments['exclude']) ) {
2860
  $query_arguments['post__not_in'] = wp_parse_id_list( $query_arguments['exclude'] );
2861
+ }
2862
+
2863
  $query_arguments['ignore_sticky_posts'] = true;
2864
  $query_arguments['no_found_rows'] = is_null( $return_found_rows ) ? true : ! $return_found_rows;
2865
+
2866
  /*
2867
  * We will always handle "orderby" in our filter
2868
  */
2869
  self::$query_parameters['orderby'] = self::_validate_sql_orderby( $query_arguments );
2870
+ if ( false === self::$query_parameters['orderby'] ) {
2871
  unset( self::$query_parameters['orderby'] );
2872
+ }
2873
+
2874
  unset( $query_arguments['orderby'] );
2875
  unset( $query_arguments['order'] );
2876
+
2877
  if ( self::$mla_debug ) {
2878
  add_filter( 'posts_clauses', 'MLAShortcodes::mla_shortcode_query_posts_clauses_filter', 0x7FFFFFFF, 1 );
2879
  add_filter( 'posts_clauses_request', 'MLAShortcodes::mla_shortcode_query_posts_clauses_request_filter', 0x7FFFFFFF, 1 );
2880
  }
2881
+
2882
  add_filter( 'posts_orderby', 'MLAShortcodes::mla_shortcode_query_posts_orderby_filter', 0x7FFFFFFF, 1 );
2883
  add_filter( 'posts_where', 'MLAShortcodes::mla_shortcode_query_posts_where_filter', 0x7FFFFFFF, 1 );
2884
 
2887
  self::$mla_debug_messages .= '<p><strong>mla_debug $wp_filter[posts_where]</strong> = ' . var_export( $wp_filter['posts_where'], true ) . '</p>';
2888
  self::$mla_debug_messages .= '<p><strong>mla_debug $wp_filter[posts_orderby]</strong> = ' . var_export( $wp_filter['posts_orderby'], true ) . '</p>';
2889
  }
2890
+
2891
  self::$mla_gallery_wp_query_object = new WP_Query;
2892
  $attachments = self::$mla_gallery_wp_query_object->query($query_arguments);
2893
+
2894
  /*
2895
  * $return_found_rows is used to indicate that the call comes from gallery_shortcode(),
2896
  * which is the only call that supplies it.
2897
  */
2898
+ if ( is_null( $return_found_rows ) ) {
2899
  $return_found_rows = false;
2900
+ } else {
2901
  do_action( 'mla_gallery_wp_query_object', $query_arguments );
2902
+ }
2903
+
2904
  if ( $return_found_rows ) {
2905
  $attachments['found_rows'] = self::$mla_gallery_wp_query_object->found_posts;
2906
  }
2907
+
2908
  remove_filter( 'posts_where', 'MLAShortcodes::mla_shortcode_query_posts_where_filter', 0x7FFFFFFF, 1 );
2909
  remove_filter( 'posts_orderby', 'MLAShortcodes::mla_shortcode_query_posts_orderby_filter', 0x7FFFFFFF, 1 );
2910
+
2911
  if ( self::$mla_debug ) {
2912
  remove_filter( 'posts_clauses', 'MLAShortcodes::mla_shortcode_query_posts_clauses_filter', 0x7FFFFFFF, 1 );
2913
  remove_filter( 'posts_clauses_request', 'MLAShortcodes::mla_shortcode_query_posts_clauses_request_filter', 0x7FFFFFFF, 1 );
2914
 
2915
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug query', 'media-library-assistant' ) . '</strong> = ' . var_export( $query_arguments, true ) . '</p>';
2916
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug request', 'media-library-assistant' ) . '</strong> = ' . var_export( self::$mla_gallery_wp_query_object->request, true ) . '</p>';
2917
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug query_vars', 'media-library-assistant' ) . '</strong> = ' . var_export( self::$mla_gallery_wp_query_object->query_vars, true ) . '</p>';
2918
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug post_count', 'media-library-assistant' ) . '</strong> = ' . var_export( self::$mla_gallery_wp_query_object->post_count, true ) . '</p>';
2919
  }
2920
+
2921
  self::$mla_gallery_wp_query_object = NULL;
2922
  return $attachments;
2923
  }
2941
 
2942
  if ( self::$mla_debug ) {
2943
  $old_clause = $where_clause;
2944
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug WHERE filter', 'media-library-assistant' ) . '</strong> = ' . var_export( $where_clause, true ) . '</p>';
2945
  }
2946
+
2947
  if ( strpos( $where_clause, "post_type = 'attachment'" ) ) {
2948
  $where_clause = str_replace( "post_type = 'attachment'", "post_type = 'attachment'", $where_clause );
2949
  }
2959
  }
2960
  }
2961
 
2962
+ if ( self::$mla_debug && ( $old_clause != $where_clause ) ) {
2963
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug modified WHERE filter', 'media-library-assistant' ) . '</strong> = ' . var_export( $where_clause, true ) . '</p>';
2964
+ }
2965
 
2966
  return $where_clause;
2967
  }
2982
  global $wpdb;
2983
 
2984
  if ( self::$mla_debug ) {
2985
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug ORDER BY filter, incoming', 'media-library-assistant' ) . '</strong> = ' . var_export( $orderby_clause, true ) . '<br>' . __( 'Replacement ORDER BY clause', 'media-library-assistant' ) . ' = ' . var_export( self::$query_parameters['orderby'], true ) . '</p>';
2986
  }
2987
 
2988
+ if ( isset( self::$query_parameters['orderby'] ) ) {
2989
  return self::$query_parameters['orderby'];
2990
+ }
2991
+
2992
+ return $orderby_clause;
2993
  }
2994
 
2995
  /**
3005
  * @return array query clauses after modification (none)
3006
  */
3007
  public static function mla_shortcode_query_posts_clauses_filter( $pieces ) {
3008
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug posts_clauses filter', 'media-library-assistant' ) . '</strong> = ' . var_export( $pieces, true ) . '</p>';
3009
 
3010
  return $pieces;
3011
  }
3023
  * @return array query clauses after modification (none)
3024
  */
3025
  public static function mla_shortcode_query_posts_clauses_request_filter( $pieces ) {
3026
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug posts_clauses_request filter', 'media-library-assistant' ) . '</strong> = ' . var_export( $pieces, true ) . '</p>';
3027
 
3028
  return $pieces;
3029
  }
3094
  /*
3095
  * Make sure $attr is an array, even if it's empty
3096
  */
3097
+ if ( empty( $attr ) ) {
3098
  $attr = array();
3099
+ } elseif ( is_string( $attr ) ) {
3100
  $attr = shortcode_parse_atts( $attr );
3101
+ }
3102
 
3103
  /*
3104
  * Merge input arguments with defaults
3106
  $attr = apply_filters( 'mla_get_terms_query_attributes', $attr );
3107
  $arguments = shortcode_atts( self::$mla_get_terms_parameters, $attr );
3108
  $arguments = apply_filters( 'mla_get_terms_query_arguments', $arguments );
3109
+
3110
  $query = array();
3111
  $query_parameters = array();
3112
 
3120
  /*
3121
  * Add taxonomy constraint
3122
  */
3123
+ if ( is_array( $arguments['taxonomy'] ) ) {
3124
  $taxonomies = $arguments['taxonomy'];
3125
+ } else {
3126
  $taxonomies = array( $arguments['taxonomy'] );
3127
+ }
3128
 
3129
  foreach ( $taxonomies as $taxonomy ) {
3130
  if ( ! taxonomy_exists( $taxonomy ) ) {
3131
+ $error = new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy', 'media-library-assistant' ), $taxonomy );
3132
  return $error;
3133
  }
3134
  }
3135
+
3136
  $placeholders = array();
3137
  foreach ($taxonomies as $taxonomy) {
3138
  $placeholders[] = '%s';
3140
  }
3141
 
3142
  $query[] = 'WHERE ( tt.taxonomy IN (' . join( ',', $placeholders ) . ')';
3143
+
3144
  /*
3145
  * Add include/exclude and parent constraints to WHERE cluse
3146
  */
3147
  if ( ! empty( $arguments['include'] ) ) {
3148
  $placeholders = implode( "','", wp_parse_id_list( $arguments['include'] ) );
3149
  $query[] = "AND t.term_id IN ( '{$placeholders}' )";
3150
+ } elseif ( ! empty( $arguments['exclude'] ) ) {
 
3151
  $placeholders = implode( "','", wp_parse_id_list( $arguments['exclude'] ) );
3152
  $query[] = "AND t.term_id NOT IN ( '{$placeholders}' )";
3153
  }
3163
  $query[] = 'HAVING count >= %d';
3164
  $query_parameters[] = absint( $arguments['minimum'] );
3165
  }
3166
+
3167
  /*
3168
  * For now, always select the most popular terms
3169
  */
3182
  * $final_parameters, if present, require an SQL subquery
3183
  */
3184
  $final_parameters = array();
3185
+
3186
  /*
3187
  * Add sort order
3188
  */
3189
  $orderby = strtolower( $arguments['orderby'] );
3190
  $order = strtoupper( $arguments['order'] );
3191
+ if ( 'DESC' != $order ) {
3192
  $order = 'ASC';
3193
+ }
3194
+
3195
  /*
3196
  * Count, Descending, is the default order so no further work
3197
  * is needed unless a different order is specified
3219
  break;
3220
  }
3221
  }
3222
+
3223
  /*
3224
  * Add pagination
3225
  */
3229
  $final_parameters[] = 'LIMIT %d, %d';
3230
  $query_parameters[] = $offset;
3231
  $query_parameters[] = $limit;
3232
+ } elseif ( 0 < $limit ) {
 
3233
  $final_parameters[] = 'LIMIT %d';
3234
  $query_parameters[] = $limit;
3235
+ } elseif ( 0 < $offset ) {
 
3236
  $final_parameters[] = 'LIMIT %d, %d';
3237
  $query_parameters[] = $offset;
3238
  $query_parameters[] = 0x7FFFFFFF; // big number!
3239
  }
3240
+
3241
  /*
3242
  * If we're limiting the final results, we need to get an accurate total count first
3243
  */
3246
  $count = $wpdb->get_results( $wpdb->prepare( $count_query, $query_parameters ) );
3247
  $found_rows = $count[0]->count;
3248
  }
3249
+
3250
  if ( ! empty( $final_parameters ) ) {
3251
  array_unshift($query, 'SELECT * FROM (');
3252
  $query[] = ') AS subQuery';
3253
  $query = array_merge( $query, $final_parameters );
3254
  }
3255
+
3256
  $query = join(' ', $query);
3257
+
3258
  $tags = $wpdb->get_results( $wpdb->prepare( $query, $query_parameters ) );
3259
+ if ( ! isset( $found_rows ) ) {
3260
  $found_rows = $wpdb->num_rows;
3261
+ }
3262
 
3263
  if ( self::$mla_debug ) {
3264
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug query arguments', 'media-library-assistant' ) . '</strong> = ' . var_export( $arguments, true ) . '</p>';
3265
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug last_query', 'media-library-assistant' ) . '</strong> = ' . var_export( $wpdb->last_query, true ) . '</p>';
3266
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug last_error', 'media-library-assistant' ) . '</strong> = ' . var_export( $wpdb->last_error, true ) . '</p>';
3267
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug num_rows', 'media-library-assistant' ) . '</strong> = ' . var_export( $wpdb->num_rows, true ) . '</p>';
3268
+ self::$mla_debug_messages .= '<p><strong>' . __( 'mla_debug found_rows', 'media-library-assistant' ) . '</strong> = ' . var_export( $found_rows, true ) . '</p>';
3269
  }
3270
+
3271
  $tags['found_rows'] = $found_rows;
3272
  $tags = apply_filters( 'mla_get_terms_query_results', $tags );
3273
 
includes/class-mla-upload-list-table.php CHANGED
@@ -25,33 +25,21 @@ class MLA_Upload_List_Table extends WP_List_Table {
25
  /*
26
  * These arrays define the table columns.
27
  */
28
-
29
  /**
30
  * Table column definitions
31
  *
32
  * This array defines table columns and titles where the key is the column slug (and class)
33
  * and the value is the column's title text.
34
  *
 
 
35
  * @since 1.40
36
  *
37
  * @var array
38
  */
39
- private static $default_columns = array(
40
- // '_title' => 'underscore title',
41
- 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
42
- 'icon' => '',
43
- 'name' => 'Extension',
44
- 'mime_type' => 'MIME Type',
45
- 'icon_type' => 'Icon Type',
46
- 'source' => 'Source',
47
- 'status' => 'Status',
48
- 'core_type' => 'WordPress Type',
49
- 'mla_type' => 'MLA Type',
50
- 'standard_source' => 'Std. Source',
51
- 'core_icon_type' => 'Std. Icon Type',
52
- 'description' => 'Description'
53
- );
54
-
55
  /**
56
  * Default values for hidden columns
57
  *
@@ -77,7 +65,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
77
  'core_icon_type',
78
  'description'
79
  );
80
-
81
  /**
82
  * Sortable column definitions
83
  *
@@ -116,7 +104,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
116
  private static function _default_hidden_columns( ) {
117
  return self::$default_hidden_columns;
118
  }
119
-
120
  /**
121
  * Return the names and display values of the sortable columns
122
  *
@@ -127,15 +115,15 @@ class MLA_Upload_List_Table extends WP_List_Table {
127
  public static function mla_get_sortable_columns( )
128
  {
129
  $results = array() ;
130
-
131
  foreach ( self::$default_sortable_columns as $key => $value ) {
132
  $value[1] = self::$default_columns[ $key ];
133
  $results[ $key ] = $value;
134
  }
135
-
136
  return $results;
137
  }
138
-
139
  /**
140
  * Handler for filter 'get_user_option_managesettings_page_mla-settings-menu-uploadcolumnshidden'
141
  *
@@ -152,12 +140,9 @@ class MLA_Upload_List_Table extends WP_List_Table {
152
  * @return array updated list of hidden columns
153
  */
154
  public static function mla_manage_hidden_columns_filter( $result, $option, $user_data ) {
155
- if ( $result )
156
- return $result;
157
- else
158
- return self::_default_hidden_columns();
159
  }
160
-
161
  /**
162
  * Handler for filter 'manage_settings_page_mla-settings-menu_columns'
163
  *
@@ -173,7 +158,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
173
  {
174
  return self::$default_columns;
175
  }
176
-
177
  /**
178
  * Called in the admin_init action because the list_table object isn't
179
  * created in time to affect the "screen options" setup.
@@ -184,15 +169,34 @@ class MLA_Upload_List_Table extends WP_List_Table {
184
  */
185
  public static function mla_admin_init_action( )
186
  {
187
- if ( isset( $_REQUEST['mla-optional-uploads-display'] ) || isset( $_REQUEST['mla-optional-uploads-search'] ) )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  return;
189
-
 
190
  if ( isset( $_REQUEST['mla_tab'] ) && $_REQUEST['mla_tab'] == 'upload' ) {
191
  add_filter( 'get_user_option_managesettings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-uploadcolumnshidden', 'MLA_Upload_list_Table::mla_manage_hidden_columns_filter', 10, 3 );
192
  add_filter( 'manage_settings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-upload_columns', 'MLA_Upload_list_Table::mla_manage_columns_filter', 10, 0 );
193
  }
194
  }
195
-
196
  /**
197
  * Initializes some properties from $_REQUEST variables, then
198
  * calls the parent constructor to set some default configs.
@@ -209,13 +213,12 @@ class MLA_Upload_List_Table extends WP_List_Table {
209
  'ajax' => true, //does this table support ajax?
210
  'screen' => 'settings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-upload'
211
  ) );
212
-
213
  /*
214
  * NOTE: There is one add_action call at the end of this source file.
215
- * NOTE: There are two add_filter calls at the end of this source file.
216
  */
217
  }
218
-
219
  /**
220
  * Supply a column value if no column-specific function has been defined
221
  *
@@ -231,9 +234,10 @@ class MLA_Upload_List_Table extends WP_List_Table {
231
  */
232
  function column_default( $item, $column_name ) {
233
  //Show the whole array for troubleshooting purposes
234
- return 'column_default: ' . $column_name . ', ' . print_r( $item, true );
 
235
  }
236
-
237
  /**
238
  * Displays checkboxes for using bulk actions. The 'cb' column
239
  * is given special treatment when columns are processed.
@@ -249,7 +253,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
249
  /*%1$s*/ $item->post_ID
250
  );
251
  }
252
-
253
  /**
254
  * Supply the content for a custom column
255
  *
@@ -262,7 +266,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
262
  {
263
  return MLAMime::mla_get_icon_type_image( $item->icon_type );
264
  }
265
-
266
  /**
267
  * Add rollover actions to a table column
268
  *
@@ -275,40 +279,44 @@ class MLA_Upload_List_Table extends WP_List_Table {
275
  */
276
  private function _build_rollover_actions( $item, $column ) {
277
  $actions = array();
278
-
279
  /*
280
  * Compose view arguments
281
  */
282
-
283
  $view_args = array(
284
  'page' => MLASettings::MLA_SETTINGS_SLUG . '-upload',
285
  'mla_tab' => 'upload',
286
  'mla_item_slug' => urlencode( $item->slug )
287
  );
288
 
289
- if ( isset( $_REQUEST['paged'] ) )
290
  $view_args['paged'] = $_REQUEST['paged'];
291
-
292
- if ( isset( $_REQUEST['order'] ) )
 
293
  $view_args['order'] = $_REQUEST['order'];
294
-
295
- if ( isset( $_REQUEST['orderby'] ) )
 
296
  $view_args['orderby'] = $_REQUEST['orderby'];
297
-
298
- $actions['edit'] = '<a href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_EDIT_DISPLAY, MLA::MLA_ADMIN_NONCE ) ) . '" title="Edit this item">Edit</a>';
 
 
 
299
 
300
- $actions['inline hide-if-no-js'] = '<a class="editinline" href="#" title="Edit this item inline">Quick Edit</a>';
301
-
302
  if ( 'custom' == $item->source ) {
303
- if ( empty( $item->standard_source ) )
304
- $actions['delete'] = '<a class="delete-tag"' . ' href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_DELETE, MLA::MLA_ADMIN_NONCE ) ) . '" title="Delete this item permanently">Delete Permanently</a>';
305
- else
306
- $actions['delete'] = '<a class="delete-tag"' . ' href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_DELETE, MLA::MLA_ADMIN_NONCE ) ) . '" title="Revert to standard item">Revert to Standard</a>';
 
307
  }
308
 
309
  return $actions;
310
  }
311
-
312
  /**
313
  * Add hidden fields with the data for use in the inline editor
314
  *
@@ -336,7 +344,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
336
  $inline_data .= "</div>\r\n";
337
  return $inline_data;
338
  }
339
-
340
  /**
341
  * Supply the content for a custom column
342
  *
@@ -350,7 +358,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
350
  $slug = esc_attr( $item->slug );
351
  return sprintf( '%1$s<br>%2$s%3$s', /*%1$s*/ $slug, /*%2$s*/ $this->row_actions( $row_actions ), /*%3$s*/ $this->_build_inline_data( $item ) );
352
  }
353
-
354
  /**
355
  * Supply the content for a custom column
356
  *
@@ -362,7 +370,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
362
  function column_mime_type( $item ) {
363
  return esc_attr( $item->mime_type );
364
  }
365
-
366
  /**
367
  * Supply the content for a custom column
368
  *
@@ -374,7 +382,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
374
  function column_icon_type( $item ) {
375
  return esc_attr( $item->icon_type );
376
  }
377
-
378
  /**
379
  * Supply the content for a custom column
380
  *
@@ -386,7 +394,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
386
  function column_source( $item ) {
387
  return esc_attr( $item->source );
388
  }
389
-
390
  /**
391
  * Supply the content for a custom column
392
  *
@@ -396,12 +404,13 @@ class MLA_Upload_List_Table extends WP_List_Table {
396
  * @return string HTML markup to be placed inside the column
397
  */
398
  function column_status( $item ) {
399
- if ( $item->disabled )
400
- return 'inactive';
401
- else
402
- return 'active';
 
403
  }
404
-
405
  /**
406
  * Supply the content for a custom column
407
  *
@@ -413,7 +422,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
413
  function column_core_type( $item ) {
414
  return esc_attr( $item->core_type );
415
  }
416
-
417
  /**
418
  * Supply the content for a custom column
419
  *
@@ -425,7 +434,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
425
  function column_mla_type( $item ) {
426
  return esc_attr( $item->mla_type );
427
  }
428
-
429
  /**
430
  * Supply the content for a custom column
431
  *
@@ -437,7 +446,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
437
  function column_standard_source( $item ) {
438
  return (string) $item->standard_source;
439
  }
440
-
441
  /**
442
  * Supply the content for a custom column
443
  *
@@ -449,7 +458,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
449
  function column_core_icon_type( $item ) {
450
  return esc_attr( $item->core_icon_type );
451
  }
452
-
453
  /**
454
  * Supply the content for a custom column
455
  *
@@ -461,7 +470,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
461
  function column_description( $item ) {
462
  return esc_attr( $item->description );
463
  }
464
-
465
  /**
466
  * This method dictates the table's columns and titles
467
  *
@@ -472,7 +481,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
472
  function get_columns( ) {
473
  return MLA_Upload_list_Table::mla_manage_columns_filter();
474
  }
475
-
476
  /**
477
  * Returns the list of currently hidden columns from a user option or
478
  * from default values if the option is not set
@@ -488,10 +497,10 @@ class MLA_Upload_List_Table extends WP_List_Table {
488
  if ( is_array( $columns ) ) {
489
  return $columns;
490
  }
491
- else
492
- return self::_default_hidden_columns();
493
  }
494
-
495
  /**
496
  * Returns an array where the key is the column that needs to be sortable
497
  * and the value is db column to sort by. Also notes the current sort column,
@@ -504,22 +513,20 @@ class MLA_Upload_List_Table extends WP_List_Table {
504
  */
505
  function get_sortable_columns( ) {
506
  $columns = self::$default_sortable_columns;
507
-
508
  if ( isset( $_REQUEST['orderby'] ) ) {
509
- $needle = array(
510
- $_REQUEST['orderby'],
511
- false
512
- );
513
  $key = array_search( $needle, $columns );
514
- if ( $key )
515
  $columns[ $key ][ 1 ] = true;
 
516
  } else {
517
  $columns['menu_order'][ 1 ] = true;
518
  }
519
 
520
  return $columns;
521
  }
522
-
523
  /**
524
  * Returns HTML markup for one view that can be used with this table
525
  *
@@ -533,7 +540,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
533
  */
534
  function _get_view( $view_slug, $upload_item, $current_view ) {
535
  static $base_url = NULL;
536
-
537
  $class = ( $view_slug == $current_view ) ? ' class="current"' : '';
538
 
539
  /*
@@ -544,20 +551,19 @@ class MLA_Upload_List_Table extends WP_List_Table {
544
  * Remember the view filters
545
  */
546
  $base_url = 'options-general.php?page=' . MLASettings::MLA_SETTINGS_SLUG . '-upload&mla_tab=upload';
547
-
548
- if ( isset( $_REQUEST['s'] ) )
549
- $base_url = add_query_arg( array(
550
- 's' => $_REQUEST['s']
551
- ), $base_url );
552
  }
553
-
554
  $singular = sprintf('%s <span class="count">(%%s)</span>', $upload_item['singular'] );
555
  $plural = sprintf('%s <span class="count">(%%s)</span>', $upload_item['plural'] );
556
- $nooped_plural = _n_noop( $singular, $plural );
557
  return "<a href='" . add_query_arg( array( 'mla_upload_view' => $view_slug ), $base_url )
558
- . "'$class>" . sprintf( translate_nooped_plural( $nooped_plural, $upload_item['count'] ), number_format_i18n( $upload_item['count'] ) ) . '</a>';
559
  } // _get_view
560
-
561
  /**
562
  * Returns an associative array listing all the views that can be used with this table.
563
  * These are listed across the top of the page and managed by WordPress.
@@ -571,7 +577,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
571
  * Find current view
572
  */
573
  $current_view = isset( $_REQUEST['mla_upload_view'] ) ? $_REQUEST['mla_upload_view'] : 'all';
574
-
575
  /*
576
  * Generate the list of views, retaining keyword search criterion
577
  */
@@ -583,7 +589,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
583
 
584
  return $view_links;
585
  }
586
-
587
  /**
588
  * Get an associative array ( option_name => option_title ) with the list
589
  * of bulk actions available on this table.
@@ -596,12 +602,12 @@ class MLA_Upload_List_Table extends WP_List_Table {
596
  {
597
  $actions = array();
598
 
599
- $actions['edit'] = 'Edit';
600
- $actions['delete'] = 'Delete/Revert Custom';
601
-
602
  return $actions;
603
  }
604
-
605
  /**
606
  * Prepares the list of items for displaying
607
  *
@@ -620,7 +626,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
620
  $this->get_hidden_columns(),
621
  $this->get_sortable_columns()
622
  );
623
-
624
  /*
625
  * REQUIRED for pagination.
626
  */
@@ -628,14 +634,16 @@ class MLA_Upload_List_Table extends WP_List_Table {
628
  $user = get_current_user_id();
629
  $screen = get_current_screen();
630
  $option = $screen->get_option( 'per_page', 'option' );
631
- if ( is_string( $option ) )
632
  $per_page = get_user_meta( $user, $option, true );
633
- else
634
  $per_page = 10;
635
-
636
- if ( empty( $per_page ) || $per_page < 1 )
 
637
  $per_page = $screen->get_option( 'per_page', 'default' );
638
-
 
639
  /*
640
  * REQUIRED. We also have to register our pagination options & calculations.
641
  */
@@ -653,7 +661,7 @@ class MLA_Upload_List_Table extends WP_List_Table {
653
  */
654
  $this->items = MLAMime::mla_query_upload_items( $_REQUEST, ( ( $current_page - 1 ) * $per_page ), $per_page );
655
  }
656
-
657
  /**
658
  * Generates (echoes) content for a single row of the table
659
  *
25
  /*
26
  * These arrays define the table columns.
27
  */
28
+
29
  /**
30
  * Table column definitions
31
  *
32
  * This array defines table columns and titles where the key is the column slug (and class)
33
  * and the value is the column's title text.
34
  *
35
+ * All of the columns are added to this array by MLA_Upload_List_Table::mla_admin_init_action.
36
+ *
37
  * @since 1.40
38
  *
39
  * @var array
40
  */
41
+ private static $default_columns = array();
42
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  /**
44
  * Default values for hidden columns
45
  *
65
  'core_icon_type',
66
  'description'
67
  );
68
+
69
  /**
70
  * Sortable column definitions
71
  *
104
  private static function _default_hidden_columns( ) {
105
  return self::$default_hidden_columns;
106
  }
107
+
108
  /**
109
  * Return the names and display values of the sortable columns
110
  *
115
  public static function mla_get_sortable_columns( )
116
  {
117
  $results = array() ;
118
+
119
  foreach ( self::$default_sortable_columns as $key => $value ) {
120
  $value[1] = self::$default_columns[ $key ];
121
  $results[ $key ] = $value;
122
  }
123
+
124
  return $results;
125
  }
126
+
127
  /**
128
  * Handler for filter 'get_user_option_managesettings_page_mla-settings-menu-uploadcolumnshidden'
129
  *
140
  * @return array updated list of hidden columns
141
  */
142
  public static function mla_manage_hidden_columns_filter( $result, $option, $user_data ) {
143
+ return $result ? $result : self::_default_hidden_columns();
 
 
 
144
  }
145
+
146
  /**
147
  * Handler for filter 'manage_settings_page_mla-settings-menu_columns'
148
  *
158
  {
159
  return self::$default_columns;
160
  }
161
+
162
  /**
163
  * Called in the admin_init action because the list_table object isn't
164
  * created in time to affect the "screen options" setup.
169
  */
170
  public static function mla_admin_init_action( )
171
  {
172
+ /*
173
+ * Build the default columns array at runtime to accomodate calls to the localization functions
174
+ */
175
+ self::$default_columns = array(
176
+ 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
177
+ 'icon' => '',
178
+ 'name' => _x( 'Extension', 'list_table_column', 'media-library-assistant' ),
179
+ 'mime_type' => _x( 'MIME Type', 'list_table_column', 'media-library-assistant' ),
180
+ 'icon_type' => _x( 'Icon Type', 'list_table_column', 'media-library-assistant' ),
181
+ 'source' => _x( 'Source', 'list_table_column', 'media-library-assistant' ),
182
+ 'status' => _x( 'Status', 'list_table_column', 'media-library-assistant' ),
183
+ 'core_type' => _x( 'WordPress Type', 'list_table_column', 'media-library-assistant' ),
184
+ 'mla_type' => _x( 'MLA Type', 'list_table_column', 'media-library-assistant' ),
185
+ 'standard_source' => _x( 'Std. Source', 'list_table_column', 'media-library-assistant' ),
186
+ 'core_icon_type' => _x( 'Std. Icon Type', 'list_table_column', 'media-library-assistant' ),
187
+ 'description' => _x( 'Description', 'list_table_column', 'media-library-assistant' )
188
+ );
189
+
190
+ if ( isset( $_REQUEST['mla-optional-uploads-display'] ) || isset( $_REQUEST['mla-optional-uploads-search'] ) ) {
191
  return;
192
+ }
193
+
194
  if ( isset( $_REQUEST['mla_tab'] ) && $_REQUEST['mla_tab'] == 'upload' ) {
195
  add_filter( 'get_user_option_managesettings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-uploadcolumnshidden', 'MLA_Upload_list_Table::mla_manage_hidden_columns_filter', 10, 3 );
196
  add_filter( 'manage_settings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-upload_columns', 'MLA_Upload_list_Table::mla_manage_columns_filter', 10, 0 );
197
  }
198
  }
199
+
200
  /**
201
  * Initializes some properties from $_REQUEST variables, then
202
  * calls the parent constructor to set some default configs.
213
  'ajax' => true, //does this table support ajax?
214
  'screen' => 'settings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-upload'
215
  ) );
216
+
217
  /*
218
  * NOTE: There is one add_action call at the end of this source file.
 
219
  */
220
  }
221
+
222
  /**
223
  * Supply a column value if no column-specific function has been defined
224
  *
234
  */
235
  function column_default( $item, $column_name ) {
236
  //Show the whole array for troubleshooting purposes
237
+ /* translators: 1: column_name 2: column_values */
238
+ return sprintf( __( 'column_default: %1$s, %2$s', 'media-library-assistant' ), $column_name, print_r( $item, true ) );
239
  }
240
+
241
  /**
242
  * Displays checkboxes for using bulk actions. The 'cb' column
243
  * is given special treatment when columns are processed.
253
  /*%1$s*/ $item->post_ID
254
  );
255
  }
256
+
257
  /**
258
  * Supply the content for a custom column
259
  *
266
  {
267
  return MLAMime::mla_get_icon_type_image( $item->icon_type );
268
  }
269
+
270
  /**
271
  * Add rollover actions to a table column
272
  *
279
  */
280
  private function _build_rollover_actions( $item, $column ) {
281
  $actions = array();
282
+
283
  /*
284
  * Compose view arguments
285
  */
286
+
287
  $view_args = array(
288
  'page' => MLASettings::MLA_SETTINGS_SLUG . '-upload',
289
  'mla_tab' => 'upload',
290
  'mla_item_slug' => urlencode( $item->slug )
291
  );
292
 
293
+ if ( isset( $_REQUEST['paged'] ) ) {
294
  $view_args['paged'] = $_REQUEST['paged'];
295
+ }
296
+
297
+ if ( isset( $_REQUEST['order'] ) ) {
298
  $view_args['order'] = $_REQUEST['order'];
299
+ }
300
+
301
+ if ( isset( $_REQUEST['orderby'] ) ) {
302
  $view_args['orderby'] = $_REQUEST['orderby'];
303
+ }
304
+
305
+ $actions['edit'] = '<a href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_EDIT_DISPLAY, MLA::MLA_ADMIN_NONCE ) ) . '" title="' . __( 'Edit this item', 'media-library-assistant' ) . '">' . __( 'Edit', 'media-library-assistant' ) . '</a>';
306
+
307
+ $actions['inline hide-if-no-js'] = '<a class="editinline" href="#" title="' . __( 'Edit this item inline', 'media-library-assistant' ) . '">' . __( 'Quick Edit', 'media-library-assistant' ) . '</a>';
308
 
 
 
309
  if ( 'custom' == $item->source ) {
310
+ if ( empty( $item->standard_source ) ) {
311
+ $actions['delete'] = '<a class="delete-tag"' . ' href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_DELETE, MLA::MLA_ADMIN_NONCE ) ) . '" title="' . __( 'Delete this item Permanently', 'media-library-assistant' ) . '">' . __( 'Delete Permanently', 'media-library-assistant' ) . '</a>';
312
+ } else {
313
+ $actions['delete'] = '<a class="delete-tag"' . ' href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_DELETE, MLA::MLA_ADMIN_NONCE ) ) . '" title="' . __( 'Revert to standard item', 'media-library-assistant' ) . '">' . __( 'Revert to Standard', 'media-library-assistant' ) . '</a>';
314
+ }
315
  }
316
 
317
  return $actions;
318
  }
319
+
320
  /**
321
  * Add hidden fields with the data for use in the inline editor
322
  *
344
  $inline_data .= "</div>\r\n";
345
  return $inline_data;
346
  }
347
+
348
  /**
349
  * Supply the content for a custom column
350
  *
358
  $slug = esc_attr( $item->slug );
359
  return sprintf( '%1$s<br>%2$s%3$s', /*%1$s*/ $slug, /*%2$s*/ $this->row_actions( $row_actions ), /*%3$s*/ $this->_build_inline_data( $item ) );
360
  }
361
+
362
  /**
363
  * Supply the content for a custom column
364
  *
370
  function column_mime_type( $item ) {
371
  return esc_attr( $item->mime_type );
372
  }
373
+
374
  /**
375
  * Supply the content for a custom column
376
  *
382
  function column_icon_type( $item ) {
383
  return esc_attr( $item->icon_type );
384
  }
385
+
386
  /**
387
  * Supply the content for a custom column
388
  *
394
  function column_source( $item ) {
395
  return esc_attr( $item->source );
396
  }
397
+
398
  /**
399
  * Supply the content for a custom column
400
  *
404
  * @return string HTML markup to be placed inside the column
405
  */
406
  function column_status( $item ) {
407
+ if ( $item->disabled ) {
408
+ return __( 'inactive', 'media-library-assistant' );
409
+ } else {
410
+ return __( 'active', 'media-library-assistant' );
411
+ }
412
  }
413
+
414
  /**
415
  * Supply the content for a custom column
416
  *
422
  function column_core_type( $item ) {
423
  return esc_attr( $item->core_type );
424
  }
425
+
426
  /**
427
  * Supply the content for a custom column
428
  *
434
  function column_mla_type( $item ) {
435
  return esc_attr( $item->mla_type );
436
  }
437
+
438
  /**
439
  * Supply the content for a custom column
440
  *
446
  function column_standard_source( $item ) {
447
  return (string) $item->standard_source;
448
  }
449
+
450
  /**
451
  * Supply the content for a custom column
452
  *
458
  function column_core_icon_type( $item ) {
459
  return esc_attr( $item->core_icon_type );
460
  }
461
+
462
  /**
463
  * Supply the content for a custom column
464
  *
470
  function column_description( $item ) {
471
  return esc_attr( $item->description );
472
  }
473
+
474
  /**
475
  * This method dictates the table's columns and titles
476
  *
481
  function get_columns( ) {
482
  return MLA_Upload_list_Table::mla_manage_columns_filter();
483
  }
484
+
485
  /**
486
  * Returns the list of currently hidden columns from a user option or
487
  * from default values if the option is not set
497
  if ( is_array( $columns ) ) {
498
  return $columns;
499
  }
500
+
501
+ return self::_default_hidden_columns();
502
  }
503
+
504
  /**
505
  * Returns an array where the key is the column that needs to be sortable
506
  * and the value is db column to sort by. Also notes the current sort column,
513
  */
514
  function get_sortable_columns( ) {
515
  $columns = self::$default_sortable_columns;
516
+
517
  if ( isset( $_REQUEST['orderby'] ) ) {
518
+ $needle = array( $_REQUEST['orderby'], false );
 
 
 
519
  $key = array_search( $needle, $columns );
520
+ if ( $key ) {
521
  $columns[ $key ][ 1 ] = true;
522
+ }
523
  } else {
524
  $columns['menu_order'][ 1 ] = true;
525
  }
526
 
527
  return $columns;
528
  }
529
+
530
  /**
531
  * Returns HTML markup for one view that can be used with this table
532
  *
540
  */
541
  function _get_view( $view_slug, $upload_item, $current_view ) {
542
  static $base_url = NULL;
543
+
544
  $class = ( $view_slug == $current_view ) ? ' class="current"' : '';
545
 
546
  /*
551
  * Remember the view filters
552
  */
553
  $base_url = 'options-general.php?page=' . MLASettings::MLA_SETTINGS_SLUG . '-upload&mla_tab=upload';
554
+
555
+ if ( isset( $_REQUEST['s'] ) ) {
556
+ $base_url = add_query_arg( array( 's' => $_REQUEST['s'] ), $base_url );
557
+ }
 
558
  }
559
+
560
  $singular = sprintf('%s <span class="count">(%%s)</span>', $upload_item['singular'] );
561
  $plural = sprintf('%s <span class="count">(%%s)</span>', $upload_item['plural'] );
562
+ $nooped_plural = _n_noop( $singular, $plural, 'media-library-assistant' );
563
  return "<a href='" . add_query_arg( array( 'mla_upload_view' => $view_slug ), $base_url )
564
+ . "'$class>" . sprintf( translate_nooped_plural( $nooped_plural, $upload_item['count'], 'media-library-assistant' ), number_format_i18n( $upload_item['count'] ) ) . '</a>';
565
  } // _get_view
566
+
567
  /**
568
  * Returns an associative array listing all the views that can be used with this table.
569
  * These are listed across the top of the page and managed by WordPress.
577
  * Find current view
578
  */
579
  $current_view = isset( $_REQUEST['mla_upload_view'] ) ? $_REQUEST['mla_upload_view'] : 'all';
580
+
581
  /*
582
  * Generate the list of views, retaining keyword search criterion
583
  */
589
 
590
  return $view_links;
591
  }
592
+
593
  /**
594
  * Get an associative array ( option_name => option_title ) with the list
595
  * of bulk actions available on this table.
602
  {
603
  $actions = array();
604
 
605
+ $actions['edit'] = __( 'Edit', 'media-library-assistant' );
606
+ $actions['delete'] = __( 'Delete/Revert Custom', 'media-library-assistant' );
607
+
608
  return $actions;
609
  }
610
+
611
  /**
612
  * Prepares the list of items for displaying
613
  *
626
  $this->get_hidden_columns(),
627
  $this->get_sortable_columns()
628
  );
629
+
630
  /*
631
  * REQUIRED for pagination.
632
  */
634
  $user = get_current_user_id();
635
  $screen = get_current_screen();
636
  $option = $screen->get_option( 'per_page', 'option' );
637
+ if ( is_string( $option ) ) {
638
  $per_page = get_user_meta( $user, $option, true );
639
+ } else {
640
  $per_page = 10;
641
+ }
642
+
643
+ if ( empty( $per_page ) || $per_page < 1 ) {
644
  $per_page = $screen->get_option( 'per_page', 'default' );
645
+ }
646
+
647
  /*
648
  * REQUIRED. We also have to register our pagination options & calculations.
649
  */
661
  */
662
  $this->items = MLAMime::mla_query_upload_items( $_REQUEST, ( ( $current_page - 1 ) * $per_page ), $per_page );
663
  }
664
+
665
  /**
666
  * Generates (echoes) content for a single row of the table
667
  *
includes/class-mla-upload-optional-list-table.php CHANGED
@@ -26,26 +26,21 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
26
  /*
27
  * These arrays define the table columns.
28
  */
29
-
30
  /**
31
  * Table column definitions
32
  *
33
  * This array defines table columns and titles where the key is the column slug (and class)
34
  * and the value is the column's title text.
35
  *
 
 
36
  * @since 1.40
37
  *
38
  * @var array
39
  */
40
- private static $default_columns = array(
41
- 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
42
- 'name' => 'Extension',
43
- 'mime_type' => 'MIME Type',
44
- 'core_type' => 'WordPress Type',
45
- 'mla_type' => 'MLA Type',
46
- 'description' => 'Description'
47
- );
48
-
49
  /**
50
  * Default values for hidden columns
51
  *
@@ -66,7 +61,7 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
66
  // 'mla_type',
67
  // 'description'
68
  );
69
-
70
  /**
71
  * Sortable column definitions
72
  *
@@ -100,7 +95,7 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
100
  private static function _default_hidden_columns( ) {
101
  return self::$default_hidden_columns;
102
  }
103
-
104
  /**
105
  * Return the names and display values of the sortable columns
106
  *
@@ -111,15 +106,15 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
111
  public static function mla_get_sortable_columns( )
112
  {
113
  $results = array() ;
114
-
115
  foreach ( self::$default_sortable_columns as $key => $value ) {
116
  $value[1] = self::$default_columns[ $key ];
117
  $results[ $key ] = $value;
118
  }
119
-
120
  return $results;
121
  }
122
-
123
  /**
124
  * Handler for filter 'get_user_option_managesettings_page_mla-settings-menu-viewcolumnshidden'
125
  *
@@ -136,14 +131,9 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
136
  * @return array updated list of hidden columns
137
  */
138
  public static function mla_manage_hidden_columns_filter( $result, $option, $user_data ) {
139
- return $result;
140
-
141
- if ( $result )
142
- return $result;
143
- else
144
- return self::_default_hidden_columns();
145
  }
146
-
147
  /**
148
  * Handler for filter 'manage_settings_page_mla-settings-menu_columns'
149
  *
@@ -159,7 +149,7 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
159
  {
160
  return self::$default_columns;
161
  }
162
-
163
  /**
164
  * Called in the admin_init action because the list_table object isn't
165
  * created in time to affect the "screen options" setup.
@@ -170,12 +160,24 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
170
  */
171
  public static function mla_admin_init_action( )
172
  {
 
 
 
 
 
 
 
 
 
 
 
 
173
  if ( isset( $_REQUEST['mla-optional-uploads-display'] ) || isset( $_REQUEST['mla-optional-uploads-search'] ) ) {
174
  add_filter( 'get_user_option_managesettings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-uploadcolumnshidden', 'MLA_Upload_Optional_List_Table::mla_manage_hidden_columns_filter', 10, 3 );
175
  add_filter( 'manage_settings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-upload_columns', 'MLA_Upload_Optional_List_Table::mla_manage_columns_filter', 10, 0 );
176
  }
177
  }
178
-
179
  /**
180
  * Initializes some properties from $_REQUEST variables, then
181
  * calls the parent constructor to set some default configs.
@@ -192,13 +194,12 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
192
  'ajax' => false, //does this table support ajax?
193
  'screen' => 'settings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-upload'
194
  ) );
195
-
196
  /*
197
  * NOTE: There is one add_action call at the end of this source file.
198
- * NOTE: There are two add_filter calls at the end of this source file.
199
  */
200
  }
201
-
202
  /**
203
  * Supply a column value if no column-specific function has been defined
204
  *
@@ -214,9 +215,10 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
214
  */
215
  function column_default( $item, $column_name ) {
216
  //Show the whole array for troubleshooting purposes
217
- return 'column_default: ' . $column_name . ', ' . print_r( $item, true );
 
218
  }
219
-
220
  /**
221
  * Displays checkboxes for using bulk actions. The 'cb' column
222
  * is given special treatment when columns are processed.
@@ -232,7 +234,7 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
232
  /*%1$s*/ $item->ID
233
  );
234
  }
235
-
236
  /**
237
  * Add rollover actions to a table column
238
  *
@@ -245,31 +247,34 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
245
  */
246
  private function _build_rollover_actions( $item, $column ) {
247
  $actions = array();
248
-
249
  /*
250
  * Compose view arguments
251
  */
252
-
253
  $view_args = array(
254
  'page' => MLASettings::MLA_SETTINGS_SLUG . '-upload',
255
  'mla_tab' => 'upload',
256
  'mla_item_ID' => urlencode( $item->ID )
257
  );
258
 
259
- if ( isset( $_REQUEST['paged'] ) )
260
  $view_args['paged'] = $_REQUEST['paged'];
261
-
262
- if ( isset( $_REQUEST['order'] ) )
 
263
  $view_args['order'] = $_REQUEST['order'];
264
-
265
- if ( isset( $_REQUEST['orderby'] ) )
 
266
  $view_args['orderby'] = $_REQUEST['orderby'];
267
-
268
- $actions['select'] = '<a href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_EDIT_UPDATE, MLA::MLA_ADMIN_NONCE ) ) . '" title="Select this entry">Select</a>';
 
269
 
270
  return $actions;
271
  }
272
-
273
  /**
274
  * Supply the content for a custom column
275
  *
@@ -283,7 +288,7 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
283
  $slug = esc_attr( $item->slug );
284
  return sprintf( '%1$s<br>%2$s', /*%1$s*/ $slug, /*%2$s*/ $this->row_actions( $row_actions ) );
285
  }
286
-
287
  /**
288
  * Supply the content for a custom column
289
  *
@@ -295,7 +300,7 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
295
  function column_mime_type( $item ) {
296
  return esc_attr( $item->mime_type );
297
  }
298
-
299
  /**
300
  * Supply the content for a custom column
301
  *
@@ -307,7 +312,7 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
307
  function column_core_type( $item ) {
308
  return esc_attr( $item->core_type );
309
  }
310
-
311
  /**
312
  * Supply the content for a custom column
313
  *
@@ -319,7 +324,7 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
319
  function column_mla_type( $item ) {
320
  return esc_attr( $item->mla_type );
321
  }
322
-
323
  /**
324
  * Supply the content for a custom column
325
  *
@@ -331,7 +336,7 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
331
  function column_description( $item ) {
332
  return esc_attr( $item->description );
333
  }
334
-
335
  /**
336
  * This method dictates the table's columns and titles
337
  *
@@ -342,7 +347,7 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
342
  function get_columns( ) {
343
  return $columns = MLA_Upload_Optional_List_Table::mla_manage_columns_filter();
344
  }
345
-
346
  /**
347
  * Returns the list of currently hidden columns from a user option or
348
  * from default values if the option is not set
@@ -358,10 +363,10 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
358
  if ( is_array( $columns ) ) {
359
  return $columns;
360
  }
361
- else
362
- return self::_default_hidden_columns();
363
  }
364
-
365
  /**
366
  * Returns an array where the key is the column that needs to be sortable
367
  * and the value is db column to sort by. Also notes the current sort column,
@@ -374,22 +379,20 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
374
  */
375
  function get_sortable_columns( ) {
376
  $columns = self::$default_sortable_columns;
377
-
378
  if ( isset( $_REQUEST['orderby'] ) ) {
379
- $needle = array(
380
- $_REQUEST['orderby'],
381
- false
382
- );
383
  $key = array_search( $needle, $columns );
384
- if ( $key )
385
  $columns[ $key ][ 1 ] = true;
 
386
  } else {
387
  $columns['menu_order'][ 1 ] = true;
388
  }
389
 
390
  return $columns;
391
  }
392
-
393
  /**
394
  * Get an associative array ( option_name => option_title ) with the list
395
  * of bulk actions available on this table.
@@ -402,11 +405,11 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
402
  {
403
  $actions = array();
404
 
405
- $actions['select'] = 'Select these entries';
406
-
407
  return $actions;
408
  }
409
-
410
  /**
411
  * Prepares the list of items for displaying
412
  *
@@ -425,7 +428,7 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
425
  $this->get_hidden_columns(),
426
  $this->get_sortable_columns()
427
  );
428
-
429
  /*
430
  * REQUIRED for pagination.
431
  */
@@ -433,14 +436,16 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
433
  $user = get_current_user_id();
434
  $screen = get_current_screen();
435
  $option = $screen->get_option( 'per_page', 'option' );
436
- if ( is_string( $option ) )
437
  $per_page = get_user_meta( $user, $option, true );
438
- else
439
  $per_page = 10;
440
-
441
- if ( empty( $per_page ) || $per_page < 1 )
 
442
  $per_page = $screen->get_option( 'per_page', 'default' );
443
-
 
444
  /*
445
  * REQUIRED. We also have to register our pagination options & calculations.
446
  */
@@ -458,7 +463,7 @@ class MLA_Upload_Optional_List_Table extends WP_List_Table {
458
  */
459
  $this->items = MLAMime::mla_query_optional_upload_items( $_REQUEST, ( ( $current_page - 1 ) * $per_page ), $per_page );
460
  }
461
-
462
  /**
463
  * Generates (echoes) content for a single row of the table
464
  *
26
  /*
27
  * These arrays define the table columns.
28
  */
29
+
30
  /**
31
  * Table column definitions
32
  *
33
  * This array defines table columns and titles where the key is the column slug (and class)
34
  * and the value is the column's title text.
35
  *
36
+ * All of the columns are added to this array by MLA_Upload_Optional_List_Table::mla_admin_init_action.
37
+ *
38
  * @since 1.40
39
  *
40
  * @var array
41
  */
42
+ private static $default_columns = array();
43
+
 
 
 
 
 
 
 
44
  /**
45
  * Default values for hidden columns
46
  *
61
  // 'mla_type',
62
  // 'description'
63
  );
64
+
65
  /**
66
  * Sortable column definitions
67
  *
95
  private static function _default_hidden_columns( ) {
96
  return self::$default_hidden_columns;
97
  }
98
+
99
  /**
100
  * Return the names and display values of the sortable columns
101
  *
106
  public static function mla_get_sortable_columns( )
107
  {
108
  $results = array() ;
109
+
110
  foreach ( self::$default_sortable_columns as $key => $value ) {
111
  $value[1] = self::$default_columns[ $key ];
112
  $results[ $key ] = $value;
113
  }
114
+
115
  return $results;
116
  }
117
+
118
  /**
119
  * Handler for filter 'get_user_option_managesettings_page_mla-settings-menu-viewcolumnshidden'
120
  *
131
  * @return array updated list of hidden columns
132
  */
133
  public static function mla_manage_hidden_columns_filter( $result, $option, $user_data ) {
134
+ return $result ? $result : self::_default_hidden_columns();
 
 
 
 
 
135
  }
136
+
137
  /**
138
  * Handler for filter 'manage_settings_page_mla-settings-menu_columns'
139
  *
149
  {
150
  return self::$default_columns;
151
  }
152
+
153
  /**
154
  * Called in the admin_init action because the list_table object isn't
155
  * created in time to affect the "screen options" setup.
160
  */
161
  public static function mla_admin_init_action( )
162
  {
163
+ /*
164
+ * Build the default columns array at runtime to accomodate calls to the localization functions
165
+ */
166
+ self::$default_columns = array(
167
+ 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
168
+ 'name' => _x( 'Extension', 'list_table_column', 'media-library-assistant' ),
169
+ 'mime_type' => _x( 'MIME Type', 'list_table_column', 'media-library-assistant' ),
170
+ 'core_type' => _x( 'WordPress Type', 'list_table_column', 'media-library-assistant' ),
171
+ 'mla_type' => _x( 'MLA Type', 'list_table_column', 'media-library-assistant' ),
172
+ 'description' => _x( 'Description', 'list_table_column', 'media-library-assistant' )
173
+ );
174
+
175
  if ( isset( $_REQUEST['mla-optional-uploads-display'] ) || isset( $_REQUEST['mla-optional-uploads-search'] ) ) {
176
  add_filter( 'get_user_option_managesettings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-uploadcolumnshidden', 'MLA_Upload_Optional_List_Table::mla_manage_hidden_columns_filter', 10, 3 );
177
  add_filter( 'manage_settings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-upload_columns', 'MLA_Upload_Optional_List_Table::mla_manage_columns_filter', 10, 0 );
178
  }
179
  }
180
+
181
  /**
182
  * Initializes some properties from $_REQUEST variables, then
183
  * calls the parent constructor to set some default configs.
194
  'ajax' => false, //does this table support ajax?
195
  'screen' => 'settings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-upload'
196
  ) );
197
+
198
  /*
199
  * NOTE: There is one add_action call at the end of this source file.
 
200
  */
201
  }
202
+
203
  /**
204
  * Supply a column value if no column-specific function has been defined
205
  *
215
  */
216
  function column_default( $item, $column_name ) {
217
  //Show the whole array for troubleshooting purposes
218
+ /* translators: 1: column_name 2: column_values */
219
+ return sprintf( __( 'column_default: %1$s, %2$s', 'media-library-assistant' ), $column_name, print_r( $item, true ) );
220
  }
221
+
222
  /**
223
  * Displays checkboxes for using bulk actions. The 'cb' column
224
  * is given special treatment when columns are processed.
234
  /*%1$s*/ $item->ID
235
  );
236
  }
237
+
238
  /**
239
  * Add rollover actions to a table column
240
  *
247
  */
248
  private function _build_rollover_actions( $item, $column ) {
249
  $actions = array();
250
+
251
  /*
252
  * Compose view arguments
253
  */
254
+
255
  $view_args = array(
256
  'page' => MLASettings::MLA_SETTINGS_SLUG . '-upload',
257
  'mla_tab' => 'upload',
258
  'mla_item_ID' => urlencode( $item->ID )
259
  );
260
 
261
+ if ( isset( $_REQUEST['paged'] ) ) {
262
  $view_args['paged'] = $_REQUEST['paged'];
263
+ }
264
+
265
+ if ( isset( $_REQUEST['order'] ) ) {
266
  $view_args['order'] = $_REQUEST['order'];
267
+ }
268
+
269
+ if ( isset( $_REQUEST['orderby'] ) ) {
270
  $view_args['orderby'] = $_REQUEST['orderby'];
271
+ }
272
+
273
+ $actions['select'] = '<a href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_EDIT_UPDATE, MLA::MLA_ADMIN_NONCE ) ) . '" title="' . __( 'Select this entry', 'media-library-assistant' ) . '">' . __( 'Select', 'media-library-assistant' ) . '</a>';
274
 
275
  return $actions;
276
  }
277
+
278
  /**
279
  * Supply the content for a custom column
280
  *
288
  $slug = esc_attr( $item->slug );
289
  return sprintf( '%1$s<br>%2$s', /*%1$s*/ $slug, /*%2$s*/ $this->row_actions( $row_actions ) );
290
  }
291
+
292
  /**
293
  * Supply the content for a custom column
294
  *
300
  function column_mime_type( $item ) {
301
  return esc_attr( $item->mime_type );
302
  }
303
+
304
  /**
305
  * Supply the content for a custom column
306
  *
312
  function column_core_type( $item ) {
313
  return esc_attr( $item->core_type );
314
  }
315
+
316
  /**
317
  * Supply the content for a custom column
318
  *
324
  function column_mla_type( $item ) {
325
  return esc_attr( $item->mla_type );
326
  }
327
+
328
  /**
329
  * Supply the content for a custom column
330
  *
336
  function column_description( $item ) {
337
  return esc_attr( $item->description );
338
  }
339
+
340
  /**
341
  * This method dictates the table's columns and titles
342
  *
347
  function get_columns( ) {
348
  return $columns = MLA_Upload_Optional_List_Table::mla_manage_columns_filter();
349
  }
350
+
351
  /**
352
  * Returns the list of currently hidden columns from a user option or
353
  * from default values if the option is not set
363
  if ( is_array( $columns ) ) {
364
  return $columns;
365
  }
366
+
367
+ return self::_default_hidden_columns();
368
  }
369
+
370
  /**
371
  * Returns an array where the key is the column that needs to be sortable
372
  * and the value is db column to sort by. Also notes the current sort column,
379
  */
380
  function get_sortable_columns( ) {
381
  $columns = self::$default_sortable_columns;
382
+
383
  if ( isset( $_REQUEST['orderby'] ) ) {
384
+ $needle = array( $_REQUEST['orderby'], false );
 
 
 
385
  $key = array_search( $needle, $columns );
386
+ if ( $key ) {
387
  $columns[ $key ][ 1 ] = true;
388
+ }
389
  } else {
390
  $columns['menu_order'][ 1 ] = true;
391
  }
392
 
393
  return $columns;
394
  }
395
+
396
  /**
397
  * Get an associative array ( option_name => option_title ) with the list
398
  * of bulk actions available on this table.
405
  {
406
  $actions = array();
407
 
408
+ $actions['select'] = __( 'Select these entries', 'media-library-assistant' );
409
+
410
  return $actions;
411
  }
412
+
413
  /**
414
  * Prepares the list of items for displaying
415
  *
428
  $this->get_hidden_columns(),
429
  $this->get_sortable_columns()
430
  );
431
+
432
  /*
433
  * REQUIRED for pagination.
434
  */
436
  $user = get_current_user_id();
437
  $screen = get_current_screen();
438
  $option = $screen->get_option( 'per_page', 'option' );
439
+ if ( is_string( $option ) ) {
440
  $per_page = get_user_meta( $user, $option, true );
441
+ } else {
442
  $per_page = 10;
443
+ }
444
+
445
+ if ( empty( $per_page ) || $per_page < 1 ) {
446
  $per_page = $screen->get_option( 'per_page', 'default' );
447
+ }
448
+
449
  /*
450
  * REQUIRED. We also have to register our pagination options & calculations.
451
  */
463
  */
464
  $this->items = MLAMime::mla_query_optional_upload_items( $_REQUEST, ( ( $current_page - 1 ) * $per_page ), $per_page );
465
  }
466
+
467
  /**
468
  * Generates (echoes) content for a single row of the table
469
  *
includes/class-mla-view-list-table.php CHANGED
@@ -25,29 +25,21 @@ class MLA_View_List_Table extends WP_List_Table {
25
  /*
26
  * These arrays define the table columns.
27
  */
28
-
29
  /**
30
  * Table column definitions
31
  *
32
  * This array defines table columns and titles where the key is the column slug (and class)
33
  * and the value is the column's title text.
34
  *
 
 
35
  * @since 1.40
36
  *
37
  * @var array
38
  */
39
- private static $default_columns = array(
40
- 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
41
- 'name' => 'Slug',
42
- 'specification' => 'Specification',
43
- 'post_mime_type' => 'Post Mime',
44
- 'table_view' => 'Table View',
45
- 'singular' => 'Singular Name',
46
- 'plural' => 'Plural Name',
47
- 'menu_order' => 'Order',
48
- 'description' => 'Description'
49
- );
50
-
51
  /**
52
  * Default values for hidden columns
53
  *
@@ -71,7 +63,7 @@ class MLA_View_List_Table extends WP_List_Table {
71
  'menu_order',
72
  'description'
73
  );
74
-
75
  /**
76
  * Sortable column definitions
77
  *
@@ -108,7 +100,7 @@ class MLA_View_List_Table extends WP_List_Table {
108
  private static function _default_hidden_columns( ) {
109
  return self::$default_hidden_columns;
110
  }
111
-
112
  /**
113
  * Return the names and display values of the sortable columns
114
  *
@@ -119,15 +111,15 @@ class MLA_View_List_Table extends WP_List_Table {
119
  public static function mla_get_sortable_columns( )
120
  {
121
  $results = array() ;
122
-
123
  foreach ( self::$default_sortable_columns as $key => $value ) {
124
  $value[1] = self::$default_columns[ $key ];
125
  $results[ $key ] = $value;
126
  }
127
-
128
  return $results;
129
  }
130
-
131
  /**
132
  * Handler for filter 'get_user_option_managesettings_page_mla-settings-menu-viewcolumnshidden'
133
  *
@@ -144,12 +136,9 @@ class MLA_View_List_Table extends WP_List_Table {
144
  * @return array updated list of hidden columns
145
  */
146
  public static function mla_manage_hidden_columns_filter( $result, $option, $user_data ) {
147
- if ( $result )
148
- return $result;
149
- else
150
- return self::_default_hidden_columns();
151
  }
152
-
153
  /**
154
  * Handler for filter 'manage_settings_page_mla-settings-menu_columns'
155
  *
@@ -165,7 +154,7 @@ class MLA_View_List_Table extends WP_List_Table {
165
  {
166
  return self::$default_columns;
167
  }
168
-
169
  /**
170
  * Called in the admin_init action because the list_table object isn't
171
  * created in time to affect the "screen options" setup.
@@ -176,12 +165,24 @@ class MLA_View_List_Table extends WP_List_Table {
176
  */
177
  public static function mla_admin_init_action( )
178
  {
 
 
 
 
 
 
 
 
 
 
 
 
179
  if ( isset( $_REQUEST['mla_tab'] ) && $_REQUEST['mla_tab'] == 'view' ) {
180
  add_filter( 'get_user_option_managesettings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-viewcolumnshidden', 'MLA_View_List_Table::mla_manage_hidden_columns_filter', 10, 3 );
181
  add_filter( 'manage_settings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-view_columns', 'MLA_View_List_Table::mla_manage_columns_filter', 10, 0 );
182
  }
183
  }
184
-
185
  /**
186
  * Initializes some properties from $_REQUEST variables, then
187
  * calls the parent constructor to set some default configs.
@@ -198,13 +199,12 @@ class MLA_View_List_Table extends WP_List_Table {
198
  'ajax' => true, //does this table support ajax?
199
  'screen' => 'settings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-view'
200
  ) );
201
-
202
  /*
203
  * NOTE: There is one add_action call at the end of this source file.
204
- * NOTE: There are two add_filter calls at the end of this source file.
205
  */
206
  }
207
-
208
  /**
209
  * Supply a column value if no column-specific function has been defined
210
  *
@@ -220,9 +220,10 @@ class MLA_View_List_Table extends WP_List_Table {
220
  */
221
  function column_default( $item, $column_name ) {
222
  //Show the whole array for troubleshooting purposes
223
- return 'column_default: ' . $column_name . ', ' . print_r( $item, true );
 
224
  }
225
-
226
  /**
227
  * Displays checkboxes for using bulk actions. The 'cb' column
228
  * is given special treatment when columns are processed.
@@ -238,7 +239,7 @@ class MLA_View_List_Table extends WP_List_Table {
238
  /*%1$s*/ $item->post_ID
239
  );
240
  }
241
-
242
  /**
243
  * Add rollover actions to a table column
244
  *
@@ -251,51 +252,57 @@ class MLA_View_List_Table extends WP_List_Table {
251
  */
252
  private function _build_rollover_actions( $item, $column ) {
253
  $actions = array();
254
-
255
  /*
256
  * Compose view arguments
257
  */
258
-
259
  $view_args = array(
260
  'page' => MLASettings::MLA_SETTINGS_SLUG . '-view',
261
  'mla_tab' => 'view',
262
  'mla_item_slug' => urlencode( $item->slug )
263
  );
264
 
265
- if ( isset( $_REQUEST['paged'] ) )
266
  $view_args['paged'] = $_REQUEST['paged'];
267
-
268
- if ( isset( $_REQUEST['order'] ) )
 
269
  $view_args['order'] = $_REQUEST['order'];
270
-
271
- if ( isset( $_REQUEST['orderby'] ) )
 
272
  $view_args['orderby'] = $_REQUEST['orderby'];
273
-
 
274
  /*
275
  * Get the standard and custom types
276
  */
277
  $mla_types = MLAOptions::mla_get_option( MLAOptions::MLA_POST_MIME_TYPES, true );
278
- if ( ! is_array( $mla_types ) )
279
  $mla_types = array ();
280
-
 
281
  $custom_types = MLAOptions::mla_get_option( MLAOptions::MLA_POST_MIME_TYPES, false, true );
282
- if ( ! is_array( $custom_types ) )
283
  $custom_types = array ();
284
-
285
- $actions['edit'] = '<a href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_EDIT_DISPLAY, MLA::MLA_ADMIN_NONCE ) ) . '" title="Edit this item">Edit</a>';
 
 
 
286
 
287
- $actions['inline hide-if-no-js'] = '<a class="editinline" href="#" title="Edit this item inline">Quick Edit</a>';
288
-
289
  if ( isset( $custom_types[ $item->slug ] ) ) {
290
- if ( isset( $mla_types[ $item->slug ] ) )
291
- $actions['delete'] = '<a class="delete-tag"' . ' href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_DELETE, MLA::MLA_ADMIN_NONCE ) ) . '" title="Revert to standard item">Revert to Standard</a>';
292
- else
293
- $actions['delete'] = '<a class="delete-tag"' . ' href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_DELETE, MLA::MLA_ADMIN_NONCE ) ) . '" title="Delete this item permanently">Delete Permanently</a>';
 
294
  } // custom type
295
 
296
  return $actions;
297
  }
298
-
299
  /**
300
  * Add hidden fields with the data for use in the inline editor
301
  *
@@ -319,7 +326,7 @@ class MLA_View_List_Table extends WP_List_Table {
319
  $inline_data .= "</div>\r\n";
320
  return $inline_data;
321
  }
322
-
323
  /**
324
  * Supply the content for a custom column
325
  *
@@ -333,7 +340,7 @@ class MLA_View_List_Table extends WP_List_Table {
333
  $slug = esc_attr( $item->slug );
334
  return sprintf( '%1$s<br>%2$s%3$s', /*%1$s*/ $slug, /*%2$s*/ $this->row_actions( $row_actions ), /*%3$s*/ $this->_build_inline_data( $item ) );
335
  }
336
-
337
  /**
338
  * Supply the content for a custom column
339
  *
@@ -345,7 +352,7 @@ class MLA_View_List_Table extends WP_List_Table {
345
  function column_specification( $item ) {
346
  return esc_attr( $item->specification );
347
  }
348
-
349
  /**
350
  * Supply the content for a custom column
351
  *
@@ -355,12 +362,13 @@ class MLA_View_List_Table extends WP_List_Table {
355
  * @return string HTML markup to be placed inside the column
356
  */
357
  function column_post_mime_type( $item ) {
358
- if ( $item->post_mime_type )
359
- return 'yes';
360
- else
361
- return 'no';
 
362
  }
363
-
364
  /**
365
  * Supply the content for a custom column
366
  *
@@ -370,12 +378,13 @@ class MLA_View_List_Table extends WP_List_Table {
370
  * @return string HTML markup to be placed inside the column
371
  */
372
  function column_table_view( $item ) {
373
- if ( $item->table_view )
374
- return 'yes';
375
- else
376
- return 'no';
 
377
  }
378
-
379
  /**
380
  * Supply the content for a custom column
381
  *
@@ -387,7 +396,7 @@ class MLA_View_List_Table extends WP_List_Table {
387
  function column_singular( $item ) {
388
  return esc_attr( $item->singular );
389
  }
390
-
391
  /**
392
  * Supply the content for a custom column
393
  *
@@ -399,7 +408,7 @@ class MLA_View_List_Table extends WP_List_Table {
399
  function column_plural( $item ) {
400
  return esc_attr( $item->plural );
401
  }
402
-
403
  /**
404
  * Supply the content for a custom column
405
  *
@@ -411,7 +420,7 @@ class MLA_View_List_Table extends WP_List_Table {
411
  function column_menu_order( $item ) {
412
  return (string) $item->menu_order;
413
  }
414
-
415
  /**
416
  * Supply the content for a custom column
417
  *
@@ -423,7 +432,7 @@ class MLA_View_List_Table extends WP_List_Table {
423
  function column_description( $item ) {
424
  return esc_attr( $item->description );
425
  }
426
-
427
  /**
428
  * This method dictates the table's columns and titles
429
  *
@@ -434,7 +443,7 @@ class MLA_View_List_Table extends WP_List_Table {
434
  function get_columns( ) {
435
  return $columns = MLA_View_List_Table::mla_manage_columns_filter();
436
  }
437
-
438
  /**
439
  * Returns the list of currently hidden columns from a user option or
440
  * from default values if the option is not set
@@ -450,10 +459,10 @@ class MLA_View_List_Table extends WP_List_Table {
450
  if ( is_array( $columns ) ) {
451
  return $columns;
452
  }
453
- else
454
- return self::_default_hidden_columns();
455
  }
456
-
457
  /**
458
  * Returns an array where the key is the column that needs to be sortable
459
  * and the value is db column to sort by. Also notes the current sort column,
@@ -466,22 +475,20 @@ class MLA_View_List_Table extends WP_List_Table {
466
  */
467
  function get_sortable_columns( ) {
468
  $columns = self::$default_sortable_columns;
469
-
470
  if ( isset( $_REQUEST['orderby'] ) ) {
471
- $needle = array(
472
- $_REQUEST['orderby'],
473
- false
474
- );
475
  $key = array_search( $needle, $columns );
476
- if ( $key )
477
  $columns[ $key ][ 1 ] = true;
 
478
  } else {
479
  $columns['menu_order'][ 1 ] = true;
480
  }
481
 
482
  return $columns;
483
  }
484
-
485
  /**
486
  * Get an associative array ( option_name => option_title ) with the list
487
  * of bulk actions available on this table.
@@ -494,12 +501,12 @@ class MLA_View_List_Table extends WP_List_Table {
494
  {
495
  $actions = array();
496
 
497
- $actions['edit'] = 'Edit';
498
- $actions['delete'] = 'Delete Permanently';
499
-
500
  return $actions;
501
  }
502
-
503
  /**
504
  * Prepares the list of items for displaying
505
  *
@@ -518,7 +525,7 @@ class MLA_View_List_Table extends WP_List_Table {
518
  $this->get_hidden_columns(),
519
  $this->get_sortable_columns()
520
  );
521
-
522
  /*
523
  * REQUIRED for pagination.
524
  */
@@ -526,14 +533,16 @@ class MLA_View_List_Table extends WP_List_Table {
526
  $user = get_current_user_id();
527
  $screen = get_current_screen();
528
  $option = $screen->get_option( 'per_page', 'option' );
529
- if ( is_string( $option ) )
530
  $per_page = get_user_meta( $user, $option, true );
531
- else
532
  $per_page = 10;
533
-
534
- if ( empty( $per_page ) || $per_page < 1 )
 
535
  $per_page = $screen->get_option( 'per_page', 'default' );
536
-
 
537
  /*
538
  * REQUIRED. We also have to register our pagination options & calculations.
539
  */
@@ -551,7 +560,7 @@ class MLA_View_List_Table extends WP_List_Table {
551
  */
552
  $this->items = MLAMime::mla_query_view_items( $_REQUEST, ( ( $current_page - 1 ) * $per_page ), $per_page );
553
  }
554
-
555
  /**
556
  * Generates (echoes) content for a single row of the table
557
  *
25
  /*
26
  * These arrays define the table columns.
27
  */
28
+
29
  /**
30
  * Table column definitions
31
  *
32
  * This array defines table columns and titles where the key is the column slug (and class)
33
  * and the value is the column's title text.
34
  *
35
+ * All of the columns are added to this array by MLA_View_List_Table::mla_admin_init_action.
36
+ *
37
  * @since 1.40
38
  *
39
  * @var array
40
  */
41
+ private static $default_columns = array();
42
+
 
 
 
 
 
 
 
 
 
 
43
  /**
44
  * Default values for hidden columns
45
  *
63
  'menu_order',
64
  'description'
65
  );
66
+
67
  /**
68
  * Sortable column definitions
69
  *
100
  private static function _default_hidden_columns( ) {
101
  return self::$default_hidden_columns;
102
  }
103
+
104
  /**
105
  * Return the names and display values of the sortable columns
106
  *
111
  public static function mla_get_sortable_columns( )
112
  {
113
  $results = array() ;
114
+
115
  foreach ( self::$default_sortable_columns as $key => $value ) {
116
  $value[1] = self::$default_columns[ $key ];
117
  $results[ $key ] = $value;
118
  }
119
+
120
  return $results;
121
  }
122
+
123
  /**
124
  * Handler for filter 'get_user_option_managesettings_page_mla-settings-menu-viewcolumnshidden'
125
  *
136
  * @return array updated list of hidden columns
137
  */
138
  public static function mla_manage_hidden_columns_filter( $result, $option, $user_data ) {
139
+ return $result ? $result : self::_default_hidden_columns();
 
 
 
140
  }
141
+
142
  /**
143
  * Handler for filter 'manage_settings_page_mla-settings-menu_columns'
144
  *
154
  {
155
  return self::$default_columns;
156
  }
157
+
158
  /**
159
  * Called in the admin_init action because the list_table object isn't
160
  * created in time to affect the "screen options" setup.
165
  */
166
  public static function mla_admin_init_action( )
167
  {
168
+ self::$default_columns = array(
169
+ 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
170
+ 'name' => 'Slug',
171
+ 'specification' => _x( 'Specification', 'list_table_column', 'media-library-assistant' ),
172
+ 'post_mime_type' => _x( 'Post Mime', 'list_table_column', 'media-library-assistant' ),
173
+ 'table_view' => _x( 'Table View', 'list_table_column', 'media-library-assistant' ),
174
+ 'singular' => _x( 'Singular Name', 'list_table_column', 'media-library-assistant' ),
175
+ 'plural' => _x( 'Plural Name', 'list_table_column', 'media-library-assistant' ),
176
+ 'menu_order' => _x( 'Order', 'list_table_column', 'media-library-assistant' ),
177
+ 'description' => _x( 'Description', 'list_table_column', 'media-library-assistant' )
178
+ );
179
+
180
  if ( isset( $_REQUEST['mla_tab'] ) && $_REQUEST['mla_tab'] == 'view' ) {
181
  add_filter( 'get_user_option_managesettings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-viewcolumnshidden', 'MLA_View_List_Table::mla_manage_hidden_columns_filter', 10, 3 );
182
  add_filter( 'manage_settings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-view_columns', 'MLA_View_List_Table::mla_manage_columns_filter', 10, 0 );
183
  }
184
  }
185
+
186
  /**
187
  * Initializes some properties from $_REQUEST variables, then
188
  * calls the parent constructor to set some default configs.
199
  'ajax' => true, //does this table support ajax?
200
  'screen' => 'settings_page_' . MLASettings::MLA_SETTINGS_SLUG . '-view'
201
  ) );
202
+
203
  /*
204
  * NOTE: There is one add_action call at the end of this source file.
 
205
  */
206
  }
207
+
208
  /**
209
  * Supply a column value if no column-specific function has been defined
210
  *
220
  */
221
  function column_default( $item, $column_name ) {
222
  //Show the whole array for troubleshooting purposes
223
+ /* translators: 1: column_name 2: column_values */
224
+ return sprintf( __( 'column_default: %1$s, %2$s', 'media-library-assistant' ), $column_name, print_r( $item, true ) );
225
  }
226
+
227
  /**
228
  * Displays checkboxes for using bulk actions. The 'cb' column
229
  * is given special treatment when columns are processed.
239
  /*%1$s*/ $item->post_ID
240
  );
241
  }
242
+
243
  /**
244
  * Add rollover actions to a table column
245
  *
252
  */
253
  private function _build_rollover_actions( $item, $column ) {
254
  $actions = array();
255
+
256
  /*
257
  * Compose view arguments
258
  */
259
+
260
  $view_args = array(
261
  'page' => MLASettings::MLA_SETTINGS_SLUG . '-view',
262
  'mla_tab' => 'view',
263
  'mla_item_slug' => urlencode( $item->slug )
264
  );
265
 
266
+ if ( isset( $_REQUEST['paged'] ) ) {
267
  $view_args['paged'] = $_REQUEST['paged'];
268
+ }
269
+
270
+ if ( isset( $_REQUEST['order'] ) ) {
271
  $view_args['order'] = $_REQUEST['order'];
272
+ }
273
+
274
+ if ( isset( $_REQUEST['orderby'] ) ) {
275
  $view_args['orderby'] = $_REQUEST['orderby'];
276
+ }
277
+
278
  /*
279
  * Get the standard and custom types
280
  */
281
  $mla_types = MLAOptions::mla_get_option( MLAOptions::MLA_POST_MIME_TYPES, true );
282
+ if ( ! is_array( $mla_types ) ) {
283
  $mla_types = array ();
284
+ }
285
+
286
  $custom_types = MLAOptions::mla_get_option( MLAOptions::MLA_POST_MIME_TYPES, false, true );
287
+ if ( ! is_array( $custom_types ) ) {
288
  $custom_types = array ();
289
+ }
290
+
291
+ $actions['edit'] = '<a href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_EDIT_DISPLAY, MLA::MLA_ADMIN_NONCE ) ) . '" title="' . __( 'Edit this item', 'media-library-assistant' ) . '">' . __( 'Edit', 'media-library-assistant' ) . '</a>';
292
+
293
+ $actions['inline hide-if-no-js'] = '<a class="editinline" href="#" title="' . __( 'Edit this item inline', 'media-library-assistant' ) . '">' . __( 'Quick Edit', 'media-library-assistant' ) . '</a>';
294
 
 
 
295
  if ( isset( $custom_types[ $item->slug ] ) ) {
296
+ if ( isset( $mla_types[ $item->slug ] ) ) {
297
+ $actions['delete'] = '<a class="delete-tag"' . ' href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_DELETE, MLA::MLA_ADMIN_NONCE ) ) . '" title="' . __( 'Revert to standard item', 'media-library-assistant' ) . '">' . __( 'Revert to Standard', 'media-library-assistant' ) . '</a>';
298
+ } else {
299
+ $actions['delete'] = '<a class="delete-tag"' . ' href="' . add_query_arg( $view_args, wp_nonce_url( '?mla_admin_action=' . MLA::MLA_ADMIN_SINGLE_DELETE, MLA::MLA_ADMIN_NONCE ) ) . '" title="' . __( 'Delete this item Permanently', 'media-library-assistant' ) . '">' . __( 'Delete Permanently', 'media-library-assistant' ) . '</a>';
300
+ }
301
  } // custom type
302
 
303
  return $actions;
304
  }
305
+
306
  /**
307
  * Add hidden fields with the data for use in the inline editor
308
  *
326
  $inline_data .= "</div>\r\n";
327
  return $inline_data;
328
  }
329
+
330
  /**
331
  * Supply the content for a custom column
332
  *
340
  $slug = esc_attr( $item->slug );
341
  return sprintf( '%1$s<br>%2$s%3$s', /*%1$s*/ $slug, /*%2$s*/ $this->row_actions( $row_actions ), /*%3$s*/ $this->_build_inline_data( $item ) );
342
  }
343
+
344
  /**
345
  * Supply the content for a custom column
346
  *
352
  function column_specification( $item ) {
353
  return esc_attr( $item->specification );
354
  }
355
+
356
  /**
357
  * Supply the content for a custom column
358
  *
362
  * @return string HTML markup to be placed inside the column
363
  */
364
  function column_post_mime_type( $item ) {
365
+ if ( $item->post_mime_type ) {
366
+ return __( 'Yes', 'media-library-assistant' );
367
+ } else {
368
+ return __( 'No', 'media-library-assistant' );
369
+ }
370
  }
371
+
372
  /**
373
  * Supply the content for a custom column
374
  *
378
  * @return string HTML markup to be placed inside the column
379
  */
380
  function column_table_view( $item ) {
381
+ if ( $item->table_view ) {
382
+ return __( 'Yes', 'media-library-assistant' );
383
+ } else {
384
+ return __( 'No', 'media-library-assistant' );
385
+ }
386
  }
387
+
388
  /**
389
  * Supply the content for a custom column
390
  *
396
  function column_singular( $item ) {
397
  return esc_attr( $item->singular );
398
  }
399
+
400
  /**
401
  * Supply the content for a custom column
402
  *
408
  function column_plural( $item ) {
409
  return esc_attr( $item->plural );
410
  }
411
+
412
  /**
413
  * Supply the content for a custom column
414
  *
420
  function column_menu_order( $item ) {
421
  return (string) $item->menu_order;
422
  }
423
+
424
  /**
425
  * Supply the content for a custom column
426
  *
432
  function column_description( $item ) {
433
  return esc_attr( $item->description );
434
  }
435
+
436
  /**
437
  * This method dictates the table's columns and titles
438
  *
443
  function get_columns( ) {
444
  return $columns = MLA_View_List_Table::mla_manage_columns_filter();
445
  }
446
+
447
  /**
448
  * Returns the list of currently hidden columns from a user option or
449
  * from default values if the option is not set
459
  if ( is_array( $columns ) ) {
460
  return $columns;
461
  }
462
+
463
+ return self::_default_hidden_columns();
464
  }
465
+
466
  /**
467
  * Returns an array where the key is the column that needs to be sortable
468
  * and the value is db column to sort by. Also notes the current sort column,
475
  */
476
  function get_sortable_columns( ) {
477
  $columns = self::$default_sortable_columns;
478
+
479
  if ( isset( $_REQUEST['orderby'] ) ) {
480
+ $needle = array( $_REQUEST['orderby'], false );
 
 
 
481
  $key = array_search( $needle, $columns );
482
+ if ( $key ) {
483
  $columns[ $key ][ 1 ] = true;
484
+ }
485
  } else {
486
  $columns['menu_order'][ 1 ] = true;
487
  }
488
 
489
  return $columns;
490
  }
491
+
492
  /**
493
  * Get an associative array ( option_name => option_title ) with the list
494
  * of bulk actions available on this table.
501
  {
502
  $actions = array();
503
 
504
+ $actions['edit'] = __( 'Edit', 'media-library-assistant' );
505
+ $actions['delete'] = __( 'Delete Permanently', 'media-library-assistant' );
506
+
507
  return $actions;
508
  }
509
+
510
  /**
511
  * Prepares the list of items for displaying
512
  *
525
  $this->get_hidden_columns(),
526
  $this->get_sortable_columns()
527
  );
528
+
529
  /*
530
  * REQUIRED for pagination.
531
  */
533
  $user = get_current_user_id();
534
  $screen = get_current_screen();
535
  $option = $screen->get_option( 'per_page', 'option' );
536
+ if ( is_string( $option ) ) {
537
  $per_page = get_user_meta( $user, $option, true );
538
+ } else {
539
  $per_page = 10;
540
+ }
541
+
542
+ if ( empty( $per_page ) || $per_page < 1 ) {
543
  $per_page = $screen->get_option( 'per_page', 'default' );
544
+ }
545
+
546
  /*
547
  * REQUIRED. We also have to register our pagination options & calculations.
548
  */
560
  */
561
  $this->items = MLAMime::mla_query_view_items( $_REQUEST, ( ( $current_page - 1 ) * $per_page ), $per_page );
562
  }
563
+
564
  /**
565
  * Generates (echoes) content for a single row of the table
566
  *
includes/mla-plugin-loader.php CHANGED
@@ -9,11 +9,12 @@
9
  * @since 0.20
10
  */
11
 
12
- if (!defined('MLA_OPTION_PREFIX'))
13
  /**
14
  * Gives a unique prefix for plugin options; can be set in wp-config.php
15
  */
16
  define('MLA_OPTION_PREFIX', 'mla_');
 
17
 
18
  /**
19
  * Accumulates error messages from name conflict tests
@@ -29,10 +30,10 @@ $mla_plugin_loader_error_messages = '';
29
  */
30
  function mla_plugin_loader_reporting_action () {
31
  global $mla_plugin_loader_error_messages;
32
-
33
- echo '<div class="error"><p><strong>The Media Library Assistant cannot load.</strong></p>'."\r\n";
34
  echo "<ul>{$mla_plugin_loader_error_messages}</ul>\r\n";
35
- echo '<p>You must resolve these conflicts before this plugin can safely load.</p></div>'."\r\n";
36
  }
37
 
38
  /*
@@ -45,34 +46,33 @@ $mla_plugin_loader_error_messages .= MLATest::min_WordPress_version( '3.3' );
45
 
46
  if ( ! empty( $mla_plugin_loader_error_messages ) ) {
47
  add_action( 'admin_notices', 'mla_plugin_loader_reporting_action' );
48
- }
49
- else {
50
  add_action( 'init', 'MLATest::initialize', 0x7FFFFFFF );
51
-
52
  /*
53
  * Template file and database access functions.
54
  */
55
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-data.php' );
56
  add_action( 'init', 'MLAData::initialize', 0x7FFFFFFF );
57
-
58
  /*
59
  * Custom Taxonomies and WordPress objects.
60
  */
61
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-objects.php' );
62
  add_action( 'init', 'MLAObjects::initialize', 0x7FFFFFFF );
63
-
64
  /*
65
  * MIME Type functions.
66
  */
67
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-mime-types.php' );
68
  add_action( 'init', 'MLAMime::initialize', 0x7FFFFFFF );
69
-
70
  /*
71
  * Shortcodes
72
  */
73
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-shortcodes.php' );
74
  add_action( 'init', 'MLAShortcodes::initialize', 0x7FFFFFFF );
75
-
76
  /*
77
  * WordPress 3.5 and later Edit Media screen additions, e.g., meta boxes
78
  */
@@ -80,7 +80,7 @@ else {
80
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-edit-media.php' );
81
  add_action( 'init', 'MLAEdit::initialize', 0x7FFFFFFF );
82
  }
83
-
84
  /*
85
  * WordPress 3.5 and later Media Manager (Modal window) additions
86
  */
@@ -88,7 +88,7 @@ else {
88
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-media-modal.php' );
89
  add_action( 'init', 'MLAModal::initialize', 0x7FFFFFFF );
90
  }
91
-
92
  /*
93
  * Plugin settings management
94
  */
@@ -100,31 +100,32 @@ else {
100
  */
101
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-settings.php' );
102
  add_action( 'init', 'MLASettings::initialize', 0x7FFFFFFF );
103
-
104
  /*
105
  * Main program
106
  */
107
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-main.php' );
108
  add_action( 'init', 'MLA::initialize', 0x7FFFFFFF );
109
-
 
110
  /*
111
  * Custom list table package that extends the core WP_List_Table class.
112
  * Doesn't need an initialize function; has a constructor.
113
  */
114
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-list-table.php' );
115
-
116
  /*
117
  * Custom list table package for the Post MIME Type Views.
118
  * Doesn't need an initialize function; has a constructor.
119
  */
120
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-view-list-table.php' );
121
-
122
  /*
123
  * Custom list table package for the Optional Upload MIME Type Views.
124
  * Doesn't need an initialize function; has a constructor.
125
  */
126
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-upload-optional-list-table.php' );
127
-
128
  /*
129
  * Custom list table package for the Upoload MIME Type Views.
130
  * Doesn't need an initialize function; has a constructor.
9
  * @since 0.20
10
  */
11
 
12
+ if (!defined('MLA_OPTION_PREFIX')) {
13
  /**
14
  * Gives a unique prefix for plugin options; can be set in wp-config.php
15
  */
16
  define('MLA_OPTION_PREFIX', 'mla_');
17
+ }
18
 
19
  /**
20
  * Accumulates error messages from name conflict tests
30
  */
31
  function mla_plugin_loader_reporting_action () {
32
  global $mla_plugin_loader_error_messages;
33
+
34
+ echo '<div class="error"><p><strong>' . __( 'The Media Library Assistant cannot load.', 'media-library-assistant' ) . '</strong></p>'."\r\n";
35
  echo "<ul>{$mla_plugin_loader_error_messages}</ul>\r\n";
36
+ echo '<p>' . __( 'You must resolve these conflicts before this plugin can safely load.', 'media-library-assistant' ) . '</p></div>'."\r\n";
37
  }
38
 
39
  /*
46
 
47
  if ( ! empty( $mla_plugin_loader_error_messages ) ) {
48
  add_action( 'admin_notices', 'mla_plugin_loader_reporting_action' );
49
+ } else {
 
50
  add_action( 'init', 'MLATest::initialize', 0x7FFFFFFF );
51
+
52
  /*
53
  * Template file and database access functions.
54
  */
55
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-data.php' );
56
  add_action( 'init', 'MLAData::initialize', 0x7FFFFFFF );
57
+
58
  /*
59
  * Custom Taxonomies and WordPress objects.
60
  */
61
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-objects.php' );
62
  add_action( 'init', 'MLAObjects::initialize', 0x7FFFFFFF );
63
+
64
  /*
65
  * MIME Type functions.
66
  */
67
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-mime-types.php' );
68
  add_action( 'init', 'MLAMime::initialize', 0x7FFFFFFF );
69
+
70
  /*
71
  * Shortcodes
72
  */
73
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-shortcodes.php' );
74
  add_action( 'init', 'MLAShortcodes::initialize', 0x7FFFFFFF );
75
+
76
  /*
77
  * WordPress 3.5 and later Edit Media screen additions, e.g., meta boxes
78
  */
80
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-edit-media.php' );
81
  add_action( 'init', 'MLAEdit::initialize', 0x7FFFFFFF );
82
  }
83
+
84
  /*
85
  * WordPress 3.5 and later Media Manager (Modal window) additions
86
  */
88
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-media-modal.php' );
89
  add_action( 'init', 'MLAModal::initialize', 0x7FFFFFFF );
90
  }
91
+
92
  /*
93
  * Plugin settings management
94
  */
100
  */
101
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-settings.php' );
102
  add_action( 'init', 'MLASettings::initialize', 0x7FFFFFFF );
103
+
104
  /*
105
  * Main program
106
  */
107
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-main.php' );
108
  add_action( 'init', 'MLA::initialize', 0x7FFFFFFF );
109
+ add_action( 'plugins_loaded', 'MLA::mla_plugins_loaded_action', 0x7FFFFFFF );
110
+
111
  /*
112
  * Custom list table package that extends the core WP_List_Table class.
113
  * Doesn't need an initialize function; has a constructor.
114
  */
115
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-list-table.php' );
116
+
117
  /*
118
  * Custom list table package for the Post MIME Type Views.
119
  * Doesn't need an initialize function; has a constructor.
120
  */
121
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-view-list-table.php' );
122
+
123
  /*
124
  * Custom list table package for the Optional Upload MIME Type Views.
125
  * Doesn't need an initialize function; has a constructor.
126
  */
127
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-upload-optional-list-table.php' );
128
+
129
  /*
130
  * Custom list table package for the Upoload MIME Type Views.
131
  * Doesn't need an initialize function; has a constructor.
index.php CHANGED
@@ -6,7 +6,7 @@
6
  * will the rest of the plugin be loaded and run.
7
  *
8
  * @package Media Library Assistant
9
- * @version 1.61
10
  */
11
 
12
  /*
@@ -14,7 +14,9 @@ Plugin Name: Media Library Assistant
14
  Plugin URI: http://fairtradejudaica.org/media-library-assistant-a-wordpress-plugin/
15
  Description: Enhances the Media Library; powerful[mla_gallery], taxonomy support, IPTC/EXIF processing, bulk & quick edit actions and where-used reporting.
16
  Author: David Lingren
17
- Version: 1.61
 
 
18
  Author URI: http://fairtradejudaica.org/our-story/staff/
19
 
20
  Copyright 2011-2013 David Lingren
6
  * will the rest of the plugin be loaded and run.
7
  *
8
  * @package Media Library Assistant
9
+ * @version 1.70
10
  */
11
 
12
  /*
14
  Plugin URI: http://fairtradejudaica.org/media-library-assistant-a-wordpress-plugin/
15
  Description: Enhances the Media Library; powerful[mla_gallery], taxonomy support, IPTC/EXIF processing, bulk & quick edit actions and where-used reporting.
16
  Author: David Lingren
17
+ Text Domain: media-library-assistant
18
+ Domain Path: /languages
19
+ Version: 1.70
20
  Author URI: http://fairtradejudaica.org/our-story/staff/
21
 
22
  Copyright 2011-2013 David Lingren
phpDocs/classes/MLA.html CHANGED
@@ -64,6 +64,7 @@
64
  <li class="method public "><a href="#mla_inline_edit_action" title="mla_inline_edit_action :: Ajax handler for inline editing (quick and bulk edit)"><span class="description">Ajax handler for inline editing (quick and bulk edit)</span><pre>mla_inline_edit_action()</pre></a></li>
65
  <li class="method public "><a href="#mla_load_media_action" title="mla_load_media_action :: Redirect to Media/Assistant if Media/Library is hidden"><span class="description">Redirect to Media/Assistant if Media/Library is hidden</span><pre>mla_load_media_action()</pre></a></li>
66
  <li class="method public "><a href="#mla_parent_file_filter" title="mla_parent_file_filter :: Cleanup menus for Edit Tags/Categories page"><span class="description">Cleanup menus for Edit Tags/Categories page</span><pre>mla_parent_file_filter()</pre></a></li>
 
67
  <li class="method public "><a href="#mla_render_admin_page" title='mla_render_admin_page :: Render the "Assistant" subpage in the Media section, using the list_table package'><span class="description">Render the "Assistant" subpage in the Media section, using the list_table package</span><pre>mla_render_admin_page()</pre></a></li>
68
  <li class="method public "><a href="#mla_screen_options_show_screen_filter" title="mla_screen_options_show_screen_filter :: Only show screen options on the table-list screen"><span class="description">Only show screen options on the table-list screen</span><pre>mla_screen_options_show_screen_filter()</pre></a></li>
69
  <li class="method public "><a href="#mla_set_screen_option_filter" title='mla_set_screen_option_filter :: Save the "Entries per page" option set by this user'><span class="description">Save the "Entries per page" option set by this user</span><pre>mla_set_screen_option_filter()</pre></a></li>
@@ -97,7 +98,6 @@ change the meta data for a single attachment.</span><pre>_display_single_item()<
97
  <li class="constant "><a href="#MLA_ADMIN_SINGLE_MAP" title="MLA_ADMIN_SINGLE_MAP :: mla_admin_action value for mapping IPTC/EXIF metadata"><span class="description">mla_admin_action value for mapping IPTC/EXIF metadata</span><pre>MLA_ADMIN_SINGLE_MAP</pre></a></li>
98
  <li class="constant "><a href="#MLA_ADMIN_SINGLE_RESTORE" title="MLA_ADMIN_SINGLE_RESTORE :: mla_admin_action value for restoring a single item from the trash"><span class="description">mla_admin_action value for restoring a single item from the trash</span><pre>MLA_ADMIN_SINGLE_RESTORE</pre></a></li>
99
  <li class="constant "><a href="#MLA_ADMIN_SINGLE_TRASH" title="MLA_ADMIN_SINGLE_TRASH :: mla_admin_action value for moving a single item to the trash"><span class="description">mla_admin_action value for moving a single item to the trash</span><pre>MLA_ADMIN_SINGLE_TRASH</pre></a></li>
100
- <li class="constant "><a href="#PLUGIN_NAME" title="PLUGIN_NAME :: Display name for this plugin"><span class="description">Display name for this plugin</span><pre>PLUGIN_NAME</pre></a></li>
101
  <li class="constant "><a href="#STYLESHEET_SLUG" title="STYLESHEET_SLUG :: Slug for registering and enqueueing plugin style sheet"><span class="description">Slug for registering and enqueueing plugin style sheet</span><pre>STYLESHEET_SLUG</pre></a></li>
102
  </ul>
103
  </div>
@@ -275,6 +275,20 @@ going to the Edit Media screen.</p></p>
275
  <code>string</code>The updated top-level menu page</div>
276
  </div></div>
277
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  <a name="mla_render_admin_page" id="mla_render_admin_page"></a><div class="element clickable method public mla_render_admin_page" data-toggle="collapse" data-target=".mla_render_admin_page .collapse">
279
  <h2>Render the "Assistant" subpage in the Media section, using the list_table package</h2>
280
  <pre>mla_render_admin_page() : void</pre>
@@ -657,18 +671,6 @@ change the meta data for a single attachment.</h2>
657
  </tr></table>
658
  </div></div>
659
  </div>
660
- <a name="PLUGIN_NAME" id="PLUGIN_NAME"> </a><div class="element clickable constant PLUGIN_NAME" data-toggle="collapse" data-target=".PLUGIN_NAME .collapse">
661
- <h2>Display name for this plugin</h2>
662
- <pre>PLUGIN_NAME : string</pre>
663
- <div class="labels"></div>
664
- <div class="row collapse"><div class="detail-description">
665
- <p class="long_description"></p>
666
- <table class="table table-bordered"><tr>
667
- <th>since</th>
668
- <td>0.1</td>
669
- </tr></table>
670
- </div></div>
671
- </div>
672
  <a name="STYLESHEET_SLUG" id="STYLESHEET_SLUG"> </a><div class="element clickable constant STYLESHEET_SLUG" data-toggle="collapse" data-target=".STYLESHEET_SLUG .collapse">
673
  <h2>Slug for registering and enqueueing plugin style sheet</h2>
674
  <pre>STYLESHEET_SLUG : string</pre>
@@ -688,7 +690,7 @@ change the meta data for a single attachment.</h2>
688
  <div class="row"><footer class="span12">
689
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
690
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
691
- generated on 2013-11-27T11:31:01-08:00.<br></footer></div>
692
  </div>
693
  </body>
694
  </html>
64
  <li class="method public "><a href="#mla_inline_edit_action" title="mla_inline_edit_action :: Ajax handler for inline editing (quick and bulk edit)"><span class="description">Ajax handler for inline editing (quick and bulk edit)</span><pre>mla_inline_edit_action()</pre></a></li>
65
  <li class="method public "><a href="#mla_load_media_action" title="mla_load_media_action :: Redirect to Media/Assistant if Media/Library is hidden"><span class="description">Redirect to Media/Assistant if Media/Library is hidden</span><pre>mla_load_media_action()</pre></a></li>
66
  <li class="method public "><a href="#mla_parent_file_filter" title="mla_parent_file_filter :: Cleanup menus for Edit Tags/Categories page"><span class="description">Cleanup menus for Edit Tags/Categories page</span><pre>mla_parent_file_filter()</pre></a></li>
67
+ <li class="method public "><a href="#mla_plugins_loaded_action" title="mla_plugins_loaded_action :: Load a plugin text domain"><span class="description">Load a plugin text domain</span><pre>mla_plugins_loaded_action()</pre></a></li>
68
  <li class="method public "><a href="#mla_render_admin_page" title='mla_render_admin_page :: Render the "Assistant" subpage in the Media section, using the list_table package'><span class="description">Render the "Assistant" subpage in the Media section, using the list_table package</span><pre>mla_render_admin_page()</pre></a></li>
69
  <li class="method public "><a href="#mla_screen_options_show_screen_filter" title="mla_screen_options_show_screen_filter :: Only show screen options on the table-list screen"><span class="description">Only show screen options on the table-list screen</span><pre>mla_screen_options_show_screen_filter()</pre></a></li>
70
  <li class="method public "><a href="#mla_set_screen_option_filter" title='mla_set_screen_option_filter :: Save the "Entries per page" option set by this user'><span class="description">Save the "Entries per page" option set by this user</span><pre>mla_set_screen_option_filter()</pre></a></li>
98
  <li class="constant "><a href="#MLA_ADMIN_SINGLE_MAP" title="MLA_ADMIN_SINGLE_MAP :: mla_admin_action value for mapping IPTC/EXIF metadata"><span class="description">mla_admin_action value for mapping IPTC/EXIF metadata</span><pre>MLA_ADMIN_SINGLE_MAP</pre></a></li>
99
  <li class="constant "><a href="#MLA_ADMIN_SINGLE_RESTORE" title="MLA_ADMIN_SINGLE_RESTORE :: mla_admin_action value for restoring a single item from the trash"><span class="description">mla_admin_action value for restoring a single item from the trash</span><pre>MLA_ADMIN_SINGLE_RESTORE</pre></a></li>
100
  <li class="constant "><a href="#MLA_ADMIN_SINGLE_TRASH" title="MLA_ADMIN_SINGLE_TRASH :: mla_admin_action value for moving a single item to the trash"><span class="description">mla_admin_action value for moving a single item to the trash</span><pre>MLA_ADMIN_SINGLE_TRASH</pre></a></li>
 
101
  <li class="constant "><a href="#STYLESHEET_SLUG" title="STYLESHEET_SLUG :: Slug for registering and enqueueing plugin style sheet"><span class="description">Slug for registering and enqueueing plugin style sheet</span><pre>STYLESHEET_SLUG</pre></a></li>
102
  </ul>
103
  </div>
275
  <code>string</code>The updated top-level menu page</div>
276
  </div></div>
277
  </div>
278
+ <a name="mla_plugins_loaded_action" id="mla_plugins_loaded_action"></a><div class="element clickable method public mla_plugins_loaded_action" data-toggle="collapse" data-target=".mla_plugins_loaded_action .collapse">
279
+ <h2>Load a plugin text domain</h2>
280
+ <pre>mla_plugins_loaded_action() : void</pre>
281
+ <div class="labels"></div>
282
+ <div class="row collapse"><div class="detail-description">
283
+ <p class="long_description"><p>The "add_action" for this function is in mla-plugin-loader.php, because the "initialize"
284
+ function above doesn't run in time.
285
+ Defined as public because it's an action.</p></p>
286
+ <table class="table table-bordered"><tr>
287
+ <th>since</th>
288
+ <td>1.60</td>
289
+ </tr></table>
290
+ </div></div>
291
+ </div>
292
  <a name="mla_render_admin_page" id="mla_render_admin_page"></a><div class="element clickable method public mla_render_admin_page" data-toggle="collapse" data-target=".mla_render_admin_page .collapse">
293
  <h2>Render the "Assistant" subpage in the Media section, using the list_table package</h2>
294
  <pre>mla_render_admin_page() : void</pre>
671
  </tr></table>
672
  </div></div>
673
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
674
  <a name="STYLESHEET_SLUG" id="STYLESHEET_SLUG"> </a><div class="element clickable constant STYLESHEET_SLUG" data-toggle="collapse" data-target=".STYLESHEET_SLUG .collapse">
675
  <h2>Slug for registering and enqueueing plugin style sheet</h2>
676
  <pre>STYLESHEET_SLUG : string</pre>
690
  <div class="row"><footer class="span12">
691
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
692
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
693
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
694
  </div>
695
  </body>
696
  </html>
phpDocs/classes/MLAData.html CHANGED
@@ -54,6 +54,7 @@
54
  <ul class="side-nav nav nav-list">
55
  <li class="nav-header">
56
  <i class="icon-custom icon-method"></i> Methods</li>
 
57
  <li class="method public "><a href="#initialize" title="initialize :: Initialization function, similar to __construct()"><span class="description">Initialization function, similar to __construct()</span><pre>initialize()</pre></a></li>
58
  <li class="method public "><a href="#mla_count_list_table_items" title="mla_count_list_table_items :: Get the total number of attachment posts"><span class="description">Get the total number of attachment posts</span><pre>mla_count_list_table_items()</pre></a></li>
59
  <li class="method public "><a href="#mla_exif_metadata_value" title="mla_exif_metadata_value :: Parse one EXIF metadata field"><span class="description">Parse one EXIF metadata field</span><pre>mla_exif_metadata_value()</pre></a></li>
@@ -83,6 +84,7 @@
83
  <li class="method public "><a href="#mla_update_single_item" title='mla_update_single_item :: Update a single item; change the "post" data, taxonomy terms
84
  and meta data for a single attachment'><span class="description">Update a single item; change the "post" data, taxonomy terms
85
  and meta data for a single attachment</span><pre>mla_update_single_item()</pre></a></li>
 
86
  <li class="nav-header private">» Private</li>
87
  <li class="method private "><a href="#_bin_to_utf8" title="_bin_to_utf8 :: Replace SQL incorrect characters (0x80 - 0xFF) with their UTF-8 equivalents"><span class="description">Replace SQL incorrect characters (0x80 - 0xFF) with their UTF-8 equivalents</span><pre>_bin_to_utf8()</pre></a></li>
88
  <li class="method private "><a href="#_build_mla_galleries" title="_build_mla_galleries :: Builds the $mla_galleries or $galleries array"><span class="description">Builds the $mla_galleries or $galleries array</span><pre>_build_mla_galleries()</pre></a></li>
@@ -96,7 +98,6 @@ and meta data for a single attachment</span><pre>mla_update_single_item()</pre><
96
  <li class="method private "><a href="#_find_pdf_indirect_dictionary" title="_find_pdf_indirect_dictionary :: Find the offset, length and contents of an indirect object containing a dictionary"><span class="description">Find the offset, length and contents of an indirect object containing a dictionary</span><pre>_find_pdf_indirect_dictionary()</pre></a></li>
97
  <li class="method private "><a href="#_find_template_substring" title="_find_template_substring :: Find a complete template, balancing opening and closing delimiters"><span class="description">Find a complete template, balancing opening and closing delimiters</span><pre>_find_template_substring()</pre></a></li>
98
  <li class="method private "><a href="#_find_test_substring" title="_find_test_substring :: Find a complete (test) element, balancing opening and closing delimiters"><span class="description">Find a complete (test) element, balancing opening and closing delimiters</span><pre>_find_test_substring()</pre></a></li>
99
- <li class="method private "><a href="#_hex_dump" title="_hex_dump :: Format printable version of binary data"><span class="description">Format printable version of binary data</span><pre>_hex_dump()</pre></a></li>
100
  <li class="method private "><a href="#_parse_field_level_template" title='_parse_field_level_template :: Convert field-level "template:" string into its component parts'><span class="description">Convert field-level "template:" string into its component parts</span><pre>_parse_field_level_template()</pre></a></li>
101
  <li class="method private "><a href="#_parse_iso8601_date" title="_parse_iso8601_date :: Parse a ISO 8601 Timestamp"><span class="description">Parse a ISO 8601 Timestamp</span><pre>_parse_iso8601_date()</pre></a></li>
102
  <li class="method private "><a href="#_parse_pdf_LPD_dictionary" title="_parse_pdf_LPD_dictionary :: Parse a PDF Linearization Parameter Dictionary object"><span class="description">Parse a PDF Linearization Parameter Dictionary object</span><pre>_parse_pdf_LPD_dictionary()</pre></a></li>
@@ -115,13 +116,12 @@ and meta data for a single attachment</span><pre>mla_update_single_item()</pre><
115
  <li class="method private "><a href="#_search_mla_galleries" title="_search_mla_galleries :: Search the $mla_galleries or $galleries array"><span class="description">Search the $mla_galleries or $galleries array</span><pre>_search_mla_galleries()</pre></a></li>
116
  <li class="method private "><a href="#_set_array_element" title="_set_array_element :: Adds or replaces the value of a key in a possibly nested array structure"><span class="description">Adds or replaces the value of a key in a possibly nested array structure</span><pre>_set_array_element()</pre></a></li>
117
  <li class="method private "><a href="#_unset_array_element" title="_unset_array_element :: Deletes the value of a key in a possibly nested array structure"><span class="description">Deletes the value of a key in a possibly nested array structure</span><pre>_unset_array_element()</pre></a></li>
118
- <li class="method private "><a href="#_update_wp_attachment_metadata" title='_update_wp_attachment_metadata :: Update one "meta:" data for a single attachment'><span class="description">Update one "meta:" data for a single attachment</span><pre>_update_wp_attachment_metadata()</pre></a></li>
119
  <li class="nav-header">
120
  <i class="icon-custom icon-property"></i> Properties</li>
121
  <li class="property public "><a href="#%24mla_iptc_keys" title="$mla_iptc_keys :: IPTC Dataset friendly name/slug and identifiers"><span class="description">IPTC Dataset friendly name/slug and identifiers</span><pre>$mla_iptc_keys</pre></a></li>
122
  <li class="nav-header private">» Private</li>
123
  <li class="property private "><a href="#%24galleries" title="$galleries :: Objects containing [gallery] shortcodes"><span class="description">Objects containing [gallery] shortcodes</span><pre>$galleries</pre></a></li>
124
- <li class="property private "><a href="#%24mla_alt_text_view" title="$mla_alt_text_view :: Provides a unique name for the ALT Text SQL VIEW"><span class="description">Provides a unique name for the ALT Text SQL VIEW</span><pre>$mla_alt_text_view</pre></a></li>
125
  <li class="property private "><a href="#%24mla_galleries" title="$mla_galleries :: Objects containing [mla_gallery] shortcodes"><span class="description">Objects containing [mla_gallery] shortcodes</span><pre>$mla_galleries</pre></a></li>
126
  <li class="property private "><a href="#%24mla_iptc_descriptions" title="$mla_iptc_descriptions :: IPTC Dataset descriptions"><span class="description">IPTC Dataset descriptions</span><pre>$mla_iptc_descriptions</pre></a></li>
127
  <li class="property private "><a href="#%24mla_iptc_formats" title="$mla_iptc_formats :: IPTC file format identifiers and descriptions"><span class="description">IPTC file format identifiers and descriptions</span><pre>$mla_iptc_formats</pre></a></li>
@@ -133,7 +133,7 @@ and meta data for a single attachment</span><pre>mla_update_single_item()</pre><
133
  <li class="property private "><a href="#%24utf8_chars" title="$utf8_chars :: UTF-8 replacements for invalid SQL characters"><span class="description">UTF-8 replacements for invalid SQL characters</span><pre>$utf8_chars</pre></a></li>
134
  <li class="nav-header">
135
  <i class="icon-custom icon-constant"></i> Constants</li>
136
- <li class="constant "><a href="#MLA_ALT_TEXT_VIEW_SUFFIX" title="MLA_ALT_TEXT_VIEW_SUFFIX :: Provides a unique suffix for the ALT Text SQL VIEW"><span class="description">Provides a unique suffix for the ALT Text SQL VIEW</span><pre>MLA_ALT_TEXT_VIEW_SUFFIX</pre></a></li>
137
  </ul>
138
  </div>
139
  <div class="span8">
@@ -163,6 +163,36 @@ Templates separate HTML markup from PHP code for easier maintenance and localiza
163
  </table>
164
  <h3>
165
  <i class="icon-custom icon-method"></i> Methods</h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  <a name="initialize" id="initialize"></a><div class="element clickable method public initialize" data-toggle="collapse" data-target=".initialize .collapse">
167
  <h2>Initialization function, similar to __construct()</h2>
168
  <pre>initialize() </pre>
@@ -489,7 +519,7 @@ where "key" becomes the key part of the array.</p></p>
489
  <code>string</code><p>Complete path and name of the template file, option name or the raw template</p></div>
490
  <div class="subelement argument">
491
  <h4>$type</h4>
492
- <code>string</code><p>Optional type of template source; 'file' (default), 'option', 'string'</p>
493
  </div>
494
  <h3>Returns</h3>
495
  <div class="subelement response">
@@ -789,6 +819,29 @@ and meta data for a single attachment</h2>
789
  <code>array</code>success/failure message and NULL content</div>
790
  </div></div>
791
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
792
  <a name="_bin_to_utf8" id="_bin_to_utf8"></a><div class="element clickable method private _bin_to_utf8" data-toggle="collapse" data-target="._bin_to_utf8 .collapse">
793
  <h2>Replace SQL incorrect characters (0x80 - 0xFF) with their UTF-8 equivalents</h2>
794
  <pre>_bin_to_utf8(string $string) : string</pre>
@@ -1055,36 +1108,6 @@ This is required because Adobe Acrobat does NOT increment the generation number
1055
  <code>string</code>'' or template string starting with '(' and ending with the matching ')'</div>
1056
  </div></div>
1057
  </div>
1058
- <a name="_hex_dump" id="_hex_dump"></a><div class="element clickable method private _hex_dump" data-toggle="collapse" data-target="._hex_dump .collapse">
1059
- <h2>Format printable version of binary data</h2>
1060
- <pre>_hex_dump(string $data, integer $limit, \intger $bytes_per_row, integer $offset) : string</pre>
1061
- <div class="labels"></div>
1062
- <div class="row collapse"><div class="detail-description">
1063
- <p class="long_description"></p>
1064
- <table class="table table-bordered"><tr>
1065
- <th>since</th>
1066
- <td>0.90</td>
1067
- </tr></table>
1068
- <h3>Parameters</h3>
1069
- <div class="subelement argument">
1070
- <h4>$data</h4>
1071
- <code>string</code><p>Binary data</p></div>
1072
- <div class="subelement argument">
1073
- <h4>$limit</h4>
1074
- <code>integer</code><p>Bytes to format, default = 0 (all bytes)</p>
1075
- </div>
1076
- <div class="subelement argument">
1077
- <h4>$bytes_per_row</h4>
1078
- <code>\intger</code><p>Bytes to format on each line</p></div>
1079
- <div class="subelement argument">
1080
- <h4>$offset</h4>
1081
- <code>integer</code><p>offset of initial byte, or -1 to suppress printing offset information</p>
1082
- </div>
1083
- <h3>Returns</h3>
1084
- <div class="subelement response">
1085
- <code>string</code>Printable representation of $data</div>
1086
- </div></div>
1087
- </div>
1088
  <a name="_parse_field_level_template" id="_parse_field_level_template"></a><div class="element clickable method private _parse_field_level_template" data-toggle="collapse" data-target="._parse_field_level_template .collapse">
1089
  <h2>Convert field-level "template:" string into its component parts</h2>
1090
  <pre>_parse_field_level_template(string $tpl) : array</pre>
@@ -1509,29 +1532,6 @@ Modeled after wp_edit_attachments_query in wp-admin/post.php</p></p>
1509
  <code>boolean</code>true if $needle element found, false if not</div>
1510
  </div></div>
1511
  </div>
1512
- <a name="_update_wp_attachment_metadata" id="_update_wp_attachment_metadata"></a><div class="element clickable method private _update_wp_attachment_metadata" data-toggle="collapse" data-target="._update_wp_attachment_metadata .collapse">
1513
- <h2>Update one "meta:" data for a single attachment</h2>
1514
- <pre>_update_wp_attachment_metadata(array $current_values, array $new_meta) : string</pre>
1515
- <div class="labels"></div>
1516
- <div class="row collapse"><div class="detail-description">
1517
- <p class="long_description"></p>
1518
- <table class="table table-bordered"><tr>
1519
- <th>since</th>
1520
- <td>1.51</td>
1521
- </tr></table>
1522
- <h3>Parameters</h3>
1523
- <div class="subelement argument">
1524
- <h4>$current_values</h4>
1525
- <code>array</code><p>The current wp_attachment_metadata value</p></div>
1526
- <div class="subelement argument">
1527
- <h4>$new_meta</h4>
1528
- <code>array</code><p>Field name => value pairs</p>
1529
- </div>
1530
- <h3>Returns</h3>
1531
- <div class="subelement response">
1532
- <code>string</code>success/failure message(s); empty string if no changes.</div>
1533
- </div></div>
1534
- </div>
1535
  <h3>
1536
  <i class="icon-custom icon-property"></i> Properties</h3>
1537
  <a name="%24mla_iptc_keys" id="$mla_iptc_keys"> </a><div class="element clickable property public $mla_iptc_keys" data-toggle="collapse" data-target=".$mla_iptc_keys .collapse">
@@ -1570,7 +1570,7 @@ galleries[X]['results'] contains an array ( ID ) of post_ids for the objects in
1570
  </div></div>
1571
  </div>
1572
  <a name="%24mla_alt_text_view" id="$mla_alt_text_view"> </a><div class="element clickable property private $mla_alt_text_view" data-toggle="collapse" data-target=".$mla_alt_text_view .collapse">
1573
- <h2>Provides a unique name for the ALT Text SQL VIEW</h2>
1574
  <pre>$mla_alt_text_view : array</pre>
1575
  <div class="labels"></div>
1576
  <div class="row collapse"><div class="detail-description">
@@ -1704,11 +1704,12 @@ any further logic required to translate those values is contained in the filters
1704
  <h3>
1705
  <i class="icon-custom icon-constant"></i> Constants</h3>
1706
  <a name="MLA_ALT_TEXT_VIEW_SUFFIX" id="MLA_ALT_TEXT_VIEW_SUFFIX"> </a><div class="element clickable constant MLA_ALT_TEXT_VIEW_SUFFIX" data-toggle="collapse" data-target=".MLA_ALT_TEXT_VIEW_SUFFIX .collapse">
1707
- <h2>Provides a unique suffix for the ALT Text SQL VIEW</h2>
1708
  <pre>MLA_ALT_TEXT_VIEW_SUFFIX </pre>
1709
  <div class="labels"></div>
1710
  <div class="row collapse"><div class="detail-description">
1711
- <p class="long_description"></p>
 
1712
  <table class="table table-bordered"><tr>
1713
  <th>since</th>
1714
  <td>0.40</td>
@@ -1722,7 +1723,7 @@ any further logic required to translate those values is contained in the filters
1722
  <div class="row"><footer class="span12">
1723
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
1724
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
1725
- generated on 2013-11-27T11:31:01-08:00.<br></footer></div>
1726
  </div>
1727
  </body>
1728
  </html>
54
  <ul class="side-nav nav nav-list">
55
  <li class="nav-header">
56
  <i class="icon-custom icon-method"></i> Methods</li>
57
+ <li class="method public "><a href="#_hex_dump" title="_hex_dump :: Format printable version of binary data"><span class="description">Format printable version of binary data</span><pre>_hex_dump()</pre></a></li>
58
  <li class="method public "><a href="#initialize" title="initialize :: Initialization function, similar to __construct()"><span class="description">Initialization function, similar to __construct()</span><pre>initialize()</pre></a></li>
59
  <li class="method public "><a href="#mla_count_list_table_items" title="mla_count_list_table_items :: Get the total number of attachment posts"><span class="description">Get the total number of attachment posts</span><pre>mla_count_list_table_items()</pre></a></li>
60
  <li class="method public "><a href="#mla_exif_metadata_value" title="mla_exif_metadata_value :: Parse one EXIF metadata field"><span class="description">Parse one EXIF metadata field</span><pre>mla_exif_metadata_value()</pre></a></li>
84
  <li class="method public "><a href="#mla_update_single_item" title='mla_update_single_item :: Update a single item; change the "post" data, taxonomy terms
85
  and meta data for a single attachment'><span class="description">Update a single item; change the "post" data, taxonomy terms
86
  and meta data for a single attachment</span><pre>mla_update_single_item()</pre></a></li>
87
+ <li class="method public "><a href="#mla_update_wp_attachment_metadata" title='mla_update_wp_attachment_metadata :: Update "meta:" data for a single attachment'><span class="description">Update "meta:" data for a single attachment</span><pre>mla_update_wp_attachment_metadata()</pre></a></li>
88
  <li class="nav-header private">» Private</li>
89
  <li class="method private "><a href="#_bin_to_utf8" title="_bin_to_utf8 :: Replace SQL incorrect characters (0x80 - 0xFF) with their UTF-8 equivalents"><span class="description">Replace SQL incorrect characters (0x80 - 0xFF) with their UTF-8 equivalents</span><pre>_bin_to_utf8()</pre></a></li>
90
  <li class="method private "><a href="#_build_mla_galleries" title="_build_mla_galleries :: Builds the $mla_galleries or $galleries array"><span class="description">Builds the $mla_galleries or $galleries array</span><pre>_build_mla_galleries()</pre></a></li>
98
  <li class="method private "><a href="#_find_pdf_indirect_dictionary" title="_find_pdf_indirect_dictionary :: Find the offset, length and contents of an indirect object containing a dictionary"><span class="description">Find the offset, length and contents of an indirect object containing a dictionary</span><pre>_find_pdf_indirect_dictionary()</pre></a></li>
99
  <li class="method private "><a href="#_find_template_substring" title="_find_template_substring :: Find a complete template, balancing opening and closing delimiters"><span class="description">Find a complete template, balancing opening and closing delimiters</span><pre>_find_template_substring()</pre></a></li>
100
  <li class="method private "><a href="#_find_test_substring" title="_find_test_substring :: Find a complete (test) element, balancing opening and closing delimiters"><span class="description">Find a complete (test) element, balancing opening and closing delimiters</span><pre>_find_test_substring()</pre></a></li>
 
101
  <li class="method private "><a href="#_parse_field_level_template" title='_parse_field_level_template :: Convert field-level "template:" string into its component parts'><span class="description">Convert field-level "template:" string into its component parts</span><pre>_parse_field_level_template()</pre></a></li>
102
  <li class="method private "><a href="#_parse_iso8601_date" title="_parse_iso8601_date :: Parse a ISO 8601 Timestamp"><span class="description">Parse a ISO 8601 Timestamp</span><pre>_parse_iso8601_date()</pre></a></li>
103
  <li class="method private "><a href="#_parse_pdf_LPD_dictionary" title="_parse_pdf_LPD_dictionary :: Parse a PDF Linearization Parameter Dictionary object"><span class="description">Parse a PDF Linearization Parameter Dictionary object</span><pre>_parse_pdf_LPD_dictionary()</pre></a></li>
116
  <li class="method private "><a href="#_search_mla_galleries" title="_search_mla_galleries :: Search the $mla_galleries or $galleries array"><span class="description">Search the $mla_galleries or $galleries array</span><pre>_search_mla_galleries()</pre></a></li>
117
  <li class="method private "><a href="#_set_array_element" title="_set_array_element :: Adds or replaces the value of a key in a possibly nested array structure"><span class="description">Adds or replaces the value of a key in a possibly nested array structure</span><pre>_set_array_element()</pre></a></li>
118
  <li class="method private "><a href="#_unset_array_element" title="_unset_array_element :: Deletes the value of a key in a possibly nested array structure"><span class="description">Deletes the value of a key in a possibly nested array structure</span><pre>_unset_array_element()</pre></a></li>
 
119
  <li class="nav-header">
120
  <i class="icon-custom icon-property"></i> Properties</li>
121
  <li class="property public "><a href="#%24mla_iptc_keys" title="$mla_iptc_keys :: IPTC Dataset friendly name/slug and identifiers"><span class="description">IPTC Dataset friendly name/slug and identifiers</span><pre>$mla_iptc_keys</pre></a></li>
122
  <li class="nav-header private">» Private</li>
123
  <li class="property private "><a href="#%24galleries" title="$galleries :: Objects containing [gallery] shortcodes"><span class="description">Objects containing [gallery] shortcodes</span><pre>$galleries</pre></a></li>
124
+ <li class="property private "><a href="#%24mla_alt_text_view" title="$mla_alt_text_view :: Provides a unique name for the ALT Text/custom field SQL View"><span class="description">Provides a unique name for the ALT Text/custom field SQL View</span><pre>$mla_alt_text_view</pre></a></li>
125
  <li class="property private "><a href="#%24mla_galleries" title="$mla_galleries :: Objects containing [mla_gallery] shortcodes"><span class="description">Objects containing [mla_gallery] shortcodes</span><pre>$mla_galleries</pre></a></li>
126
  <li class="property private "><a href="#%24mla_iptc_descriptions" title="$mla_iptc_descriptions :: IPTC Dataset descriptions"><span class="description">IPTC Dataset descriptions</span><pre>$mla_iptc_descriptions</pre></a></li>
127
  <li class="property private "><a href="#%24mla_iptc_formats" title="$mla_iptc_formats :: IPTC file format identifiers and descriptions"><span class="description">IPTC file format identifiers and descriptions</span><pre>$mla_iptc_formats</pre></a></li>
133
  <li class="property private "><a href="#%24utf8_chars" title="$utf8_chars :: UTF-8 replacements for invalid SQL characters"><span class="description">UTF-8 replacements for invalid SQL characters</span><pre>$utf8_chars</pre></a></li>
134
  <li class="nav-header">
135
  <i class="icon-custom icon-constant"></i> Constants</li>
136
+ <li class="constant "><a href="#MLA_ALT_TEXT_VIEW_SUFFIX" title="MLA_ALT_TEXT_VIEW_SUFFIX :: Provides a unique suffix for the ALT Text/custom field SQL View"><span class="description">Provides a unique suffix for the ALT Text/custom field SQL View</span><pre>MLA_ALT_TEXT_VIEW_SUFFIX</pre></a></li>
137
  </ul>
138
  </div>
139
  <div class="span8">
163
  </table>
164
  <h3>
165
  <i class="icon-custom icon-method"></i> Methods</h3>
166
+ <a name="_hex_dump" id="_hex_dump"></a><div class="element clickable method public _hex_dump" data-toggle="collapse" data-target="._hex_dump .collapse">
167
+ <h2>Format printable version of binary data</h2>
168
+ <pre>_hex_dump(string $data, integer $limit, \intger $bytes_per_row, integer $offset) : string</pre>
169
+ <div class="labels"></div>
170
+ <div class="row collapse"><div class="detail-description">
171
+ <p class="long_description"></p>
172
+ <table class="table table-bordered"><tr>
173
+ <th>since</th>
174
+ <td>0.90</td>
175
+ </tr></table>
176
+ <h3>Parameters</h3>
177
+ <div class="subelement argument">
178
+ <h4>$data</h4>
179
+ <code>string</code><p>Binary data</p></div>
180
+ <div class="subelement argument">
181
+ <h4>$limit</h4>
182
+ <code>integer</code><p>Bytes to format, default = 0 (all bytes)</p>
183
+ </div>
184
+ <div class="subelement argument">
185
+ <h4>$bytes_per_row</h4>
186
+ <code>\intger</code><p>Bytes to format on each line</p></div>
187
+ <div class="subelement argument">
188
+ <h4>$offset</h4>
189
+ <code>integer</code><p>offset of initial byte, or -1 to suppress printing offset information</p>
190
+ </div>
191
+ <h3>Returns</h3>
192
+ <div class="subelement response">
193
+ <code>string</code>Printable representation of $data</div>
194
+ </div></div>
195
+ </div>
196
  <a name="initialize" id="initialize"></a><div class="element clickable method public initialize" data-toggle="collapse" data-target=".initialize .collapse">
197
  <h2>Initialization function, similar to __construct()</h2>
198
  <pre>initialize() </pre>
519
  <code>string</code><p>Complete path and name of the template file, option name or the raw template</p></div>
520
  <div class="subelement argument">
521
  <h4>$type</h4>
522
+ <code>string</code><p>Optional type of template source; 'path', 'file' (default), 'option', 'string'</p>
523
  </div>
524
  <h3>Returns</h3>
525
  <div class="subelement response">
819
  <code>array</code>success/failure message and NULL content</div>
820
  </div></div>
821
  </div>
822
+ <a name="mla_update_wp_attachment_metadata" id="mla_update_wp_attachment_metadata"></a><div class="element clickable method public mla_update_wp_attachment_metadata" data-toggle="collapse" data-target=".mla_update_wp_attachment_metadata .collapse">
823
+ <h2>Update "meta:" data for a single attachment</h2>
824
+ <pre>mla_update_wp_attachment_metadata(array $current_values, array $new_meta) : string</pre>
825
+ <div class="labels"></div>
826
+ <div class="row collapse"><div class="detail-description">
827
+ <p class="long_description"></p>
828
+ <table class="table table-bordered"><tr>
829
+ <th>since</th>
830
+ <td>1.51</td>
831
+ </tr></table>
832
+ <h3>Parameters</h3>
833
+ <div class="subelement argument">
834
+ <h4>$current_values</h4>
835
+ <code>array</code><p>The current wp_attachment_metadata value</p></div>
836
+ <div class="subelement argument">
837
+ <h4>$new_meta</h4>
838
+ <code>array</code><p>Field name => value pairs</p>
839
+ </div>
840
+ <h3>Returns</h3>
841
+ <div class="subelement response">
842
+ <code>string</code>success/failure message(s); empty string if no changes.</div>
843
+ </div></div>
844
+ </div>
845
  <a name="_bin_to_utf8" id="_bin_to_utf8"></a><div class="element clickable method private _bin_to_utf8" data-toggle="collapse" data-target="._bin_to_utf8 .collapse">
846
  <h2>Replace SQL incorrect characters (0x80 - 0xFF) with their UTF-8 equivalents</h2>
847
  <pre>_bin_to_utf8(string $string) : string</pre>
1108
  <code>string</code>'' or template string starting with '(' and ending with the matching ')'</div>
1109
  </div></div>
1110
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1111
  <a name="_parse_field_level_template" id="_parse_field_level_template"></a><div class="element clickable method private _parse_field_level_template" data-toggle="collapse" data-target="._parse_field_level_template .collapse">
1112
  <h2>Convert field-level "template:" string into its component parts</h2>
1113
  <pre>_parse_field_level_template(string $tpl) : array</pre>
1532
  <code>boolean</code>true if $needle element found, false if not</div>
1533
  </div></div>
1534
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1535
  <h3>
1536
  <i class="icon-custom icon-property"></i> Properties</h3>
1537
  <a name="%24mla_iptc_keys" id="$mla_iptc_keys"> </a><div class="element clickable property public $mla_iptc_keys" data-toggle="collapse" data-target=".$mla_iptc_keys .collapse">
1570
  </div></div>
1571
  </div>
1572
  <a name="%24mla_alt_text_view" id="$mla_alt_text_view"> </a><div class="element clickable property private $mla_alt_text_view" data-toggle="collapse" data-target=".$mla_alt_text_view .collapse">
1573
+ <h2>Provides a unique name for the ALT Text/custom field SQL View</h2>
1574
  <pre>$mla_alt_text_view : array</pre>
1575
  <div class="labels"></div>
1576
  <div class="row collapse"><div class="detail-description">
1704
  <h3>
1705
  <i class="icon-custom icon-constant"></i> Constants</h3>
1706
  <a name="MLA_ALT_TEXT_VIEW_SUFFIX" id="MLA_ALT_TEXT_VIEW_SUFFIX"> </a><div class="element clickable constant MLA_ALT_TEXT_VIEW_SUFFIX" data-toggle="collapse" data-target=".MLA_ALT_TEXT_VIEW_SUFFIX .collapse">
1707
+ <h2>Provides a unique suffix for the ALT Text/custom field SQL View</h2>
1708
  <pre>MLA_ALT_TEXT_VIEW_SUFFIX </pre>
1709
  <div class="labels"></div>
1710
  <div class="row collapse"><div class="detail-description">
1711
+ <p class="long_description"><p>The SQL View is used to sort the Media/Assistant submenu table on
1712
+ ALT Text and custom field columns.</p></p>
1713
  <table class="table table-bordered"><tr>
1714
  <th>since</th>
1715
  <td>0.40</td>
1723
  <div class="row"><footer class="span12">
1724
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
1725
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
1726
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
1727
  </div>
1728
  </body>
1729
  </html>
phpDocs/classes/MLAEdit.html CHANGED
@@ -345,7 +345,7 @@ The array is built once each page load and cached for subsequent calls.</p></p>
345
  <div class="row"><footer class="span12">
346
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
347
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
348
- generated on 2013-11-27T11:31:01-08:00.<br></footer></div>
349
  </div>
350
  </body>
351
  </html>
345
  <div class="row"><footer class="span12">
346
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
347
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
348
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
349
  </div>
350
  </body>
351
  </html>
phpDocs/classes/MLAMime.html CHANGED
@@ -618,7 +618,7 @@ of attachments of each type, and
618
  <h3>Parameters</h3>
619
  <div class="subelement argument">
620
  <h4>$post_mime_types</h4>
621
- <code>array</code><p>Content types (image, audio, video) and presentation strings, e.g. 'image' => array(__('Images'), __('Manage Images'), _n_noop('Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>')),</p>
622
  </div>
623
  <h3>Returns</h3>
624
  <div class="subelement response">
@@ -808,7 +808,7 @@ Defined as public because it's a filter.</p></p>
808
  </div>
809
  <a name="mla_upload_mimes_filter" id="mla_upload_mimes_filter"></a><div class="element clickable method public mla_upload_mimes_filter" data-toggle="collapse" data-target=".mla_upload_mimes_filter .collapse">
810
  <h2>Retrieve list of allowed MIME types and file extensions; use this filter to remove types</h2>
811
- <pre>mla_upload_mimes_filter(array $mime_types) : array</pre>
812
  <div class="labels"></div>
813
  <div class="row collapse"><div class="detail-description">
814
  <p class="long_description"><p>Called from /wp-includes/functions.php, function get_allowed_mime_types(). That function
@@ -830,6 +830,10 @@ respect this restriction, so any list we produce will be passed thru that functi
830
  <div class="subelement argument">
831
  <h4>$mime_types</h4>
832
  <code>array</code><p>Mime types keyed by the file extension regex corresponding to those types</p></div>
 
 
 
 
833
  <h3>Returns</h3>
834
  <div class="subelement response">
835
  <code>array</code>Updated allowed MIME types</div>
@@ -1268,7 +1272,7 @@ Defined as public because it's a filter.</p></p>
1268
  <div class="row"><footer class="span12">
1269
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
1270
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
1271
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
1272
  </div>
1273
  </body>
1274
  </html>
618
  <h3>Parameters</h3>
619
  <div class="subelement argument">
620
  <h4>$post_mime_types</h4>
621
+ <code>array</code><p>Content types (image, audio, video) and presentation strings, e.g. 'image' => array(__('Images', 'media-library-assistant'), __('Manage Images', 'media-library-assistant'), _n_noop('Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>', 'media-library-assistant')),</p>
622
  </div>
623
  <h3>Returns</h3>
624
  <div class="subelement response">
808
  </div>
809
  <a name="mla_upload_mimes_filter" id="mla_upload_mimes_filter"></a><div class="element clickable method public mla_upload_mimes_filter" data-toggle="collapse" data-target=".mla_upload_mimes_filter .collapse">
810
  <h2>Retrieve list of allowed MIME types and file extensions; use this filter to remove types</h2>
811
+ <pre>mla_upload_mimes_filter(array $mime_types, mixed $user) : array</pre>
812
  <div class="labels"></div>
813
  <div class="row collapse"><div class="detail-description">
814
  <p class="long_description"><p>Called from /wp-includes/functions.php, function get_allowed_mime_types(). That function
830
  <div class="subelement argument">
831
  <h4>$mime_types</h4>
832
  <code>array</code><p>Mime types keyed by the file extension regex corresponding to those types</p></div>
833
+ <div class="subelement argument">
834
+ <h4>$user</h4>
835
+ <code>mixed</code><p>User ID (integer) or object for checking against 'unfiltered_html' capability</p>
836
+ </div>
837
  <h3>Returns</h3>
838
  <div class="subelement response">
839
  <code>array</code>Updated allowed MIME types</div>
1272
  <div class="row"><footer class="span12">
1273
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
1274
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
1275
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
1276
  </div>
1277
  </body>
1278
  </html>
phpDocs/classes/MLAModal.html CHANGED
@@ -309,7 +309,7 @@ and mla_print_media_templates_action</h2>
309
  <div class="row"><footer class="span12">
310
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
311
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
312
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
313
  </div>
314
  </body>
315
  </html>
309
  <div class="row"><footer class="span12">
310
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
311
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
312
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
313
  </div>
314
  </body>
315
  </html>
phpDocs/classes/MLAObjects.html CHANGED
@@ -169,7 +169,7 @@ which replaces the "Posts" column with an equivalent "Attachments" column.</h2>
169
  <div class="row"><footer class="span12">
170
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
171
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
172
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
173
  </div>
174
  </body>
175
  </html>
169
  <div class="row"><footer class="span12">
170
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
171
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
172
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
173
  </div>
174
  </body>
175
  </html>
phpDocs/classes/MLAOptions.html CHANGED
@@ -55,7 +55,7 @@
55
  <li class="nav-header">
56
  <i class="icon-custom icon-method"></i> Methods</li>
57
  <li class="method public "><a href="#initialize" title="initialize :: Initialization function, similar to __construct()"><span class="description">Initialization function, similar to __construct()</span><pre>initialize()</pre></a></li>
58
- <li class="method public "><a href="#mla_add_attachment_action" title="mla_add_attachment_action :: Perform ITC/EXIF mapping on just-inserted attachment"><span class="description">Perform ITC/EXIF mapping on just-inserted attachment</span><pre>mla_add_attachment_action()</pre></a></li>
59
  <li class="method public "><a href="#mla_custom_field_option_handler" title="mla_custom_field_option_handler :: Render and manage custom field mapping options"><span class="description">Render and manage custom field mapping options</span><pre>mla_custom_field_option_handler()</pre></a></li>
60
  <li class="method public "><a href="#mla_custom_field_option_value" title="mla_custom_field_option_value :: Fetch custom field option value given a slug"><span class="description">Fetch custom field option value given a slug</span><pre>mla_custom_field_option_value()</pre></a></li>
61
  <li class="method public "><a href="#mla_custom_field_support" title="mla_custom_field_support :: Evaluate file information for custom field mapping"><span class="description">Evaluate file information for custom field mapping</span><pre>mla_custom_field_support()</pre></a></li>
@@ -63,18 +63,22 @@
63
  <li class="method public "><a href="#mla_evaluate_custom_field_mapping" title="mla_evaluate_custom_field_mapping :: Evaluate custom field mapping updates for a post"><span class="description">Evaluate custom field mapping updates for a post</span><pre>mla_evaluate_custom_field_mapping()</pre></a></li>
64
  <li class="method public "><a href="#mla_evaluate_iptc_exif_mapping" title="mla_evaluate_iptc_exif_mapping :: Evaluate IPTC/EXIF mapping updates for a post"><span class="description">Evaluate IPTC/EXIF mapping updates for a post</span><pre>mla_evaluate_iptc_exif_mapping()</pre></a></li>
65
  <li class="method public "><a href="#mla_fetch_gallery_template" title="mla_fetch_gallery_template :: Fetch style or markup template from $mla_templates"><span class="description">Fetch style or markup template from $mla_templates</span><pre>mla_fetch_gallery_template()</pre></a></li>
 
66
  <li class="method public "><a href="#mla_get_markup_templates" title="mla_get_markup_templates :: Get ALL markup templates from $mla_templates, including 'default'"><span class="description">Get ALL markup templates from $mla_templates, including 'default'</span><pre>mla_get_markup_templates()</pre></a></li>
67
  <li class="method public "><a href="#mla_get_option" title="mla_get_option :: Return the stored value or default value of a defined MLA option"><span class="description">Return the stored value or default value of a defined MLA option</span><pre>mla_get_option()</pre></a></li>
68
  <li class="method public "><a href="#mla_get_style_templates" title="mla_get_style_templates :: Get ALL style templates from $mla_templates, including 'default'"><span class="description">Get ALL style templates from $mla_templates, including 'default'</span><pre>mla_get_style_templates()</pre></a></li>
69
  <li class="method public "><a href="#mla_iptc_exif_option_handler" title="mla_iptc_exif_option_handler :: Render and manage iptc/exif support options"><span class="description">Render and manage iptc/exif support options</span><pre>mla_iptc_exif_option_handler()</pre></a></li>
 
70
  <li class="method public "><a href="#mla_put_markup_templates" title="mla_put_markup_templates :: Put user-defined markup templates to $mla_templates and database"><span class="description">Put user-defined markup templates to $mla_templates and database</span><pre>mla_put_markup_templates()</pre></a></li>
71
  <li class="method public "><a href="#mla_put_style_templates" title="mla_put_style_templates :: Put user-defined style templates to $mla_templates and database"><span class="description">Put user-defined style templates to $mla_templates and database</span><pre>mla_put_style_templates()</pre></a></li>
72
  <li class="method public "><a href="#mla_taxonomy_option_handler" title="mla_taxonomy_option_handler :: Render and manage taxonomy support options, e.g., Categories and Post Tags"><span class="description">Render and manage taxonomy support options, e.g., Categories and Post Tags</span><pre>mla_taxonomy_option_handler()</pre></a></li>
73
  <li class="method public "><a href="#mla_taxonomy_support" title="mla_taxonomy_support :: Determine MLA support for a taxonomy, handling the special case where the
74
  settings are being updated or reset."><span class="description">Determine MLA support for a taxonomy, handling the special case where the
75
  settings are being updated or reset.</span><pre>mla_taxonomy_support()</pre></a></li>
76
- <li class="method public "><a href="#mla_update_attachment_metadata_filter" title="mla_update_attachment_metadata_filter :: Perform Custom Field mapping on just-inserted or updated attachment"><span class="description">Perform Custom Field mapping on just-inserted or updated attachment</span><pre>mla_update_attachment_metadata_filter()</pre></a></li>
77
  <li class="method public "><a href="#mla_update_option" title="mla_update_option :: Add or update the stored value of a defined MLA option"><span class="description">Add or update the stored value of a defined MLA option</span><pre>mla_update_option()</pre></a></li>
 
 
78
  <li class="nav-header private">» Private</li>
79
  <li class="method private "><a href="#_compose_custom_field_option_list" title="_compose_custom_field_option_list :: Compose a Custom Field Options list with current selection"><span class="description">Compose a Custom Field Options list with current selection</span><pre>_compose_custom_field_option_list()</pre></a></li>
80
  <li class="method private "><a href="#_compose_data_source_option_list" title="_compose_data_source_option_list :: Compose a (Custom Field) Data Source Options list with current selection"><span class="description">Compose a (Custom Field) Data Source Options list with current selection</span><pre>_compose_data_source_option_list()</pre></a></li>
@@ -86,18 +90,20 @@ settings are being updated or reset.</span><pre>mla_taxonomy_support()</pre></a>
86
  <li class="method private "><a href="#_evaluate_post_information" title="_evaluate_post_information :: Evaluate post information for custom field mapping"><span class="description">Evaluate post information for custom field mapping</span><pre>_evaluate_post_information()</pre></a></li>
87
  <li class="method private "><a href="#_get_custom_field_names" title="_get_custom_field_names :: Generate a list of all (post) Custom Field names"><span class="description">Generate a list of all (post) Custom Field names</span><pre>_get_custom_field_names()</pre></a></li>
88
  <li class="method private "><a href="#_load_option_templates" title="_load_option_templates :: Load style and markup templates to $mla_templates"><span class="description">Load style and markup templates to $mla_templates</span><pre>_load_option_templates()</pre></a></li>
 
89
  <li class="method private "><a href="#_update_custom_field_mapping" title="_update_custom_field_mapping :: Update custom field mappings"><span class="description">Update custom field mappings</span><pre>_update_custom_field_mapping()</pre></a></li>
90
  <li class="method private "><a href="#_update_iptc_exif_custom_mapping" title="_update_iptc_exif_custom_mapping :: Update Custom field portion of IPTC/EXIF mappings"><span class="description">Update Custom field portion of IPTC/EXIF mappings</span><pre>_update_iptc_exif_custom_mapping()</pre></a></li>
91
  <li class="method private "><a href="#_update_iptc_exif_standard_mapping" title="_update_iptc_exif_standard_mapping :: Update Standard field portion of IPTC/EXIF mappings"><span class="description">Update Standard field portion of IPTC/EXIF mappings</span><pre>_update_iptc_exif_standard_mapping()</pre></a></li>
92
  <li class="method private "><a href="#_update_iptc_exif_taxonomy_mapping" title="_update_iptc_exif_taxonomy_mapping :: Update Taxonomy term portion of IPTC/EXIF mappings"><span class="description">Update Taxonomy term portion of IPTC/EXIF mappings</span><pre>_update_iptc_exif_taxonomy_mapping()</pre></a></li>
93
  <li class="nav-header">
94
  <i class="icon-custom icon-property"></i> Properties</li>
95
- <li class="property public "><a href="#%24mla_option_definitions" title="$mla_option_definitions :: $mla_option_definitions defines the database options and admin page areas for setting/updating them."><span class="description">$mla_option_definitions defines the database options and admin page areas for setting/updating them.</span><pre>$mla_option_definitions</pre></a></li>
96
  <li class="property public "><a href="#%24process_featured_in" title='$process_featured_in :: Option setting for "Featured in" reporting'><span class="description">Option setting for "Featured in" reporting</span><pre>$process_featured_in</pre></a></li>
97
  <li class="property public "><a href="#%24process_gallery_in" title='$process_gallery_in :: Option setting for "Gallery in" reporting'><span class="description">Option setting for "Gallery in" reporting</span><pre>$process_gallery_in</pre></a></li>
98
  <li class="property public "><a href="#%24process_inserted_in" title='$process_inserted_in :: Option setting for "Inserted in" reporting'><span class="description">Option setting for "Inserted in" reporting</span><pre>$process_inserted_in</pre></a></li>
99
  <li class="property public "><a href="#%24process_mla_gallery_in" title='$process_mla_gallery_in :: Option setting for "MLA Gallery in" reporting'><span class="description">Option setting for "MLA Gallery in" reporting</span><pre>$process_mla_gallery_in</pre></a></li>
100
  <li class="nav-header private">» Private</li>
 
101
  <li class="property private "><a href="#%24custom_field_data_sources" title="$custom_field_data_sources :: Array of Data Source names for custom field mapping"><span class="description">Array of Data Source names for custom field mapping</span><pre>$custom_field_data_sources</pre></a></li>
102
  <li class="property private "><a href="#%24mla_option_templates" title="$mla_option_templates :: Style and Markup templates"><span class="description">Style and Markup templates</span><pre>$mla_option_templates</pre></a></li>
103
  <li class="nav-header">
@@ -181,18 +187,18 @@ and provides functions to get and put them from/to WordPress option variables</p
181
  </div></div>
182
  </div>
183
  <a name="mla_add_attachment_action" id="mla_add_attachment_action"></a><div class="element clickable method public mla_add_attachment_action" data-toggle="collapse" data-target=".mla_add_attachment_action .collapse">
184
- <h2>Perform ITC/EXIF mapping on just-inserted attachment</h2>
185
- <pre>mla_add_attachment_action(integer $post_id) : void</pre>
186
  <div class="labels"></div>
187
  <div class="row collapse"><div class="detail-description">
188
- <p class="long_description"></p>
189
  <table class="table table-bordered"><tr>
190
  <th>since</th>
191
  <td>1.00</td>
192
  </tr></table>
193
  <h3>Parameters</h3>
194
  <div class="subelement argument">
195
- <h4>$post_id</h4>
196
  <code>integer</code><p>ID of just-inserted attachment</p>
197
  </div>
198
  </div></div>
@@ -326,7 +332,7 @@ and provides functions to get and put them from/to WordPress option variables</p
326
  </div>
327
  <a name="mla_evaluate_iptc_exif_mapping" id="mla_evaluate_iptc_exif_mapping"></a><div class="element clickable method public mla_evaluate_iptc_exif_mapping" data-toggle="collapse" data-target=".mla_evaluate_iptc_exif_mapping .collapse">
328
  <h2>Evaluate IPTC/EXIF mapping updates for a post</h2>
329
- <pre>mla_evaluate_iptc_exif_mapping(object $post, string $category, array $settings) : array</pre>
330
  <div class="labels"></div>
331
  <div class="row collapse"><div class="detail-description">
332
  <p class="long_description"></p>
@@ -345,6 +351,10 @@ and provides functions to get and put them from/to WordPress option variables</p
345
  <h4>$settings</h4>
346
  <code>array</code><p>(optional) iptc_exif_mapping values, default - current option value</p>
347
  </div>
 
 
 
 
348
  <h3>Returns</h3>
349
  <div class="subelement response">
350
  <code>array</code>Updates suitable for MLAData::mla_update_single_item, if any</div>
@@ -373,6 +383,39 @@ and provides functions to get and put them from/to WordPress option variables</p
373
  <code>string</code><code>boolean</code><code>null</code>requested template, false if not found or null if no templates</div>
374
  </div></div>
375
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  <a name="mla_get_markup_templates" id="mla_get_markup_templates"></a><div class="element clickable method public mla_get_markup_templates" data-toggle="collapse" data-target=".mla_get_markup_templates .collapse">
377
  <h2>Get ALL markup templates from $mla_templates, including 'default'</h2>
378
  <pre>mla_get_markup_templates() : array | null</pre>
@@ -465,6 +508,19 @@ and provides functions to get and put them from/to WordPress option variables</p
465
  <code>string</code>HTML table row markup for 'render' else message(s) reflecting the results of the operation.</div>
466
  </div></div>
467
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
468
  <a name="mla_put_markup_templates" id="mla_put_markup_templates"></a><div class="element clickable method public mla_put_markup_templates" data-toggle="collapse" data-target=".mla_put_markup_templates .collapse">
469
  <h2>Put user-defined markup templates to $mla_templates and database</h2>
470
  <pre>mla_put_markup_templates(array $templates) : boolean</pre>
@@ -567,11 +623,12 @@ settings are being updated or reset.</h2>
567
  </div></div>
568
  </div>
569
  <a name="mla_update_attachment_metadata_filter" id="mla_update_attachment_metadata_filter"></a><div class="element clickable method public mla_update_attachment_metadata_filter" data-toggle="collapse" data-target=".mla_update_attachment_metadata_filter .collapse">
570
- <h2>Perform Custom Field mapping on just-inserted or updated attachment</h2>
571
  <pre>mla_update_attachment_metadata_filter(array $data, integer $post_id) : void</pre>
572
  <div class="labels"></div>
573
  <div class="row collapse"><div class="detail-description">
574
- <p class="long_description"></p>
 
575
  <table class="table table-bordered"><tr>
576
  <th>since</th>
577
  <td>1.10</td>
@@ -609,6 +666,46 @@ settings are being updated or reset.</h2>
609
  <code>boolean</code>True if the value was changed or false if the update failed</div>
610
  </div></div>
611
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612
  <a name="_compose_custom_field_option_list" id="_compose_custom_field_option_list"></a><div class="element clickable method private _compose_custom_field_option_list" data-toggle="collapse" data-target="._compose_custom_field_option_list .collapse">
613
  <h2>Compose a Custom Field Options list with current selection</h2>
614
  <pre>_compose_custom_field_option_list(string $selection, array $blacklist) : string</pre>
@@ -748,7 +845,7 @@ settings are being updated or reset.</h2>
748
  </div>
749
  <a name="_evaluate_data_source" id="_evaluate_data_source"></a><div class="element clickable method private _evaluate_data_source" data-toggle="collapse" data-target="._evaluate_data_source .collapse">
750
  <h2>Evaluate custom field mapping data source</h2>
751
- <pre>_evaluate_data_source(integer $post_id, string $category, array $data_value, array $attachment_metadata) : string</pre>
752
  <div class="labels"></div>
753
  <div class="row collapse"><div class="detail-description">
754
  <p class="long_description"></p>
@@ -767,15 +864,15 @@ settings are being updated or reset.</h2>
767
  </div>
768
  <div class="subelement argument">
769
  <h4>$data_value</h4>
770
- <code>array</code><p>data source specification ( name, data_source, keep_existing, format, mla_column, quick_edit, bulk_edit, meta_name, no_null, option )</p>
771
  </div>
772
  <div class="subelement argument">
773
  <h4>$attachment_metadata</h4>
774
- <code>array</code><p>(optional) attachment_metadata, default NULL (use current postmeta database value)</p>
775
  </div>
776
  <h3>Returns</h3>
777
  <div class="subelement response">
778
- <code>string</code>data source value</div>
779
  </div></div>
780
  </div>
781
  <a name="_evaluate_file_information" id="_evaluate_file_information"></a><div class="element clickable method private _evaluate_file_information" data-toggle="collapse" data-target="._evaluate_file_information .collapse">
@@ -863,6 +960,28 @@ haven't been mapped to any attachments, yet.</p></p>
863
  </tr></table>
864
  </div></div>
865
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
866
  <a name="_update_custom_field_mapping" id="_update_custom_field_mapping"></a><div class="element clickable method private _update_custom_field_mapping" data-toggle="collapse" data-target="._update_custom_field_mapping .collapse">
867
  <h2>Update custom field mappings</h2>
868
  <pre>_update_custom_field_mapping(array $current_values, array $new_values) : array</pre>
@@ -954,10 +1073,13 @@ haven't been mapped to any attachments, yet.</p></p>
954
  <h3>
955
  <i class="icon-custom icon-property"></i> Properties</h3>
956
  <a name="%24mla_option_definitions" id="$mla_option_definitions"> </a><div class="element clickable property public $mla_option_definitions" data-toggle="collapse" data-target=".$mla_option_definitions .collapse">
957
- <h2>$mla_option_definitions defines the database options and admin page areas for setting/updating them.</h2>
958
  <pre>$mla_option_definitions </pre>
959
  <div class="labels"></div>
960
- <div class="row collapse"><div class="detail-description"><p class="long_description"><p>Each option is defined by an array with the following elements:</p>
 
 
 
961
 
962
  <p>array key => HTML id/name attribute and option database key (OMIT MLA_OPTION_PREFIX)</p>
963
 
@@ -1028,6 +1150,19 @@ reset => reset function for 'custom' options; returns nothing. Usage:
1028
  </tr></table>
1029
  </div></div>
1030
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
1031
  <a name="%24custom_field_data_sources" id="$custom_field_data_sources"> </a><div class="element clickable property private $custom_field_data_sources" data-toggle="collapse" data-target=".$custom_field_data_sources .collapse">
1032
  <h2>Array of Data Source names for custom field mapping</h2>
1033
  <pre>$custom_field_data_sources : array</pre>
@@ -1261,7 +1396,7 @@ This option is for flat taxonomies, e.g., "Att.</h2>
1261
  <div class="row"><footer class="span12">
1262
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
1263
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
1264
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
1265
  </div>
1266
  </body>
1267
  </html>
55
  <li class="nav-header">
56
  <i class="icon-custom icon-method"></i> Methods</li>
57
  <li class="method public "><a href="#initialize" title="initialize :: Initialization function, similar to __construct()"><span class="description">Initialization function, similar to __construct()</span><pre>initialize()</pre></a></li>
58
+ <li class="method public "><a href="#mla_add_attachment_action" title="mla_add_attachment_action :: Set $add_attachment_id to just-inserted attachment"><span class="description">Set $add_attachment_id to just-inserted attachment</span><pre>mla_add_attachment_action()</pre></a></li>
59
  <li class="method public "><a href="#mla_custom_field_option_handler" title="mla_custom_field_option_handler :: Render and manage custom field mapping options"><span class="description">Render and manage custom field mapping options</span><pre>mla_custom_field_option_handler()</pre></a></li>
60
  <li class="method public "><a href="#mla_custom_field_option_value" title="mla_custom_field_option_value :: Fetch custom field option value given a slug"><span class="description">Fetch custom field option value given a slug</span><pre>mla_custom_field_option_value()</pre></a></li>
61
  <li class="method public "><a href="#mla_custom_field_support" title="mla_custom_field_support :: Evaluate file information for custom field mapping"><span class="description">Evaluate file information for custom field mapping</span><pre>mla_custom_field_support()</pre></a></li>
63
  <li class="method public "><a href="#mla_evaluate_custom_field_mapping" title="mla_evaluate_custom_field_mapping :: Evaluate custom field mapping updates for a post"><span class="description">Evaluate custom field mapping updates for a post</span><pre>mla_evaluate_custom_field_mapping()</pre></a></li>
64
  <li class="method public "><a href="#mla_evaluate_iptc_exif_mapping" title="mla_evaluate_iptc_exif_mapping :: Evaluate IPTC/EXIF mapping updates for a post"><span class="description">Evaluate IPTC/EXIF mapping updates for a post</span><pre>mla_evaluate_iptc_exif_mapping()</pre></a></li>
65
  <li class="method public "><a href="#mla_fetch_gallery_template" title="mla_fetch_gallery_template :: Fetch style or markup template from $mla_templates"><span class="description">Fetch style or markup template from $mla_templates</span><pre>mla_fetch_gallery_template()</pre></a></li>
66
+ <li class="method public "><a href="#mla_get_data_source" title="mla_get_data_source :: Get IPTC/EXIF or custom field mapping data source"><span class="description">Get IPTC/EXIF or custom field mapping data source</span><pre>mla_get_data_source()</pre></a></li>
67
  <li class="method public "><a href="#mla_get_markup_templates" title="mla_get_markup_templates :: Get ALL markup templates from $mla_templates, including 'default'"><span class="description">Get ALL markup templates from $mla_templates, including 'default'</span><pre>mla_get_markup_templates()</pre></a></li>
68
  <li class="method public "><a href="#mla_get_option" title="mla_get_option :: Return the stored value or default value of a defined MLA option"><span class="description">Return the stored value or default value of a defined MLA option</span><pre>mla_get_option()</pre></a></li>
69
  <li class="method public "><a href="#mla_get_style_templates" title="mla_get_style_templates :: Get ALL style templates from $mla_templates, including 'default'"><span class="description">Get ALL style templates from $mla_templates, including 'default'</span><pre>mla_get_style_templates()</pre></a></li>
70
  <li class="method public "><a href="#mla_iptc_exif_option_handler" title="mla_iptc_exif_option_handler :: Render and manage iptc/exif support options"><span class="description">Render and manage iptc/exif support options</span><pre>mla_iptc_exif_option_handler()</pre></a></li>
71
+ <li class="method public "><a href="#mla_localize_option_definitions_array" title="mla_localize_option_definitions_array :: Localize $mla_option_definitions array"><span class="description">Localize $mla_option_definitions array</span><pre>mla_localize_option_definitions_array()</pre></a></li>
72
  <li class="method public "><a href="#mla_put_markup_templates" title="mla_put_markup_templates :: Put user-defined markup templates to $mla_templates and database"><span class="description">Put user-defined markup templates to $mla_templates and database</span><pre>mla_put_markup_templates()</pre></a></li>
73
  <li class="method public "><a href="#mla_put_style_templates" title="mla_put_style_templates :: Put user-defined style templates to $mla_templates and database"><span class="description">Put user-defined style templates to $mla_templates and database</span><pre>mla_put_style_templates()</pre></a></li>
74
  <li class="method public "><a href="#mla_taxonomy_option_handler" title="mla_taxonomy_option_handler :: Render and manage taxonomy support options, e.g., Categories and Post Tags"><span class="description">Render and manage taxonomy support options, e.g., Categories and Post Tags</span><pre>mla_taxonomy_option_handler()</pre></a></li>
75
  <li class="method public "><a href="#mla_taxonomy_support" title="mla_taxonomy_support :: Determine MLA support for a taxonomy, handling the special case where the
76
  settings are being updated or reset."><span class="description">Determine MLA support for a taxonomy, handling the special case where the
77
  settings are being updated or reset.</span><pre>mla_taxonomy_support()</pre></a></li>
78
+ <li class="method public "><a href="#mla_update_attachment_metadata_filter" title="mla_update_attachment_metadata_filter :: Perform IPTC/EXIF and Custom Field mapping on just-inserted attachment"><span class="description">Perform IPTC/EXIF and Custom Field mapping on just-inserted attachment</span><pre>mla_update_attachment_metadata_filter()</pre></a></li>
79
  <li class="method public "><a href="#mla_update_option" title="mla_update_option :: Add or update the stored value of a defined MLA option"><span class="description">Add or update the stored value of a defined MLA option</span><pre>mla_update_option()</pre></a></li>
80
+ <li class="method public "><a href="#mla_wp_handle_upload_filter" title="mla_wp_handle_upload_filter :: Called once for each file uploaded"><span class="description">Called once for each file uploaded</span><pre>mla_wp_handle_upload_filter()</pre></a></li>
81
+ <li class="method public "><a href="#mla_wp_handle_upload_prefilter_filter" title="mla_wp_handle_upload_prefilter_filter :: Examine or alter the filename before the file is made permanent"><span class="description">Examine or alter the filename before the file is made permanent</span><pre>mla_wp_handle_upload_prefilter_filter()</pre></a></li>
82
  <li class="nav-header private">» Private</li>
83
  <li class="method private "><a href="#_compose_custom_field_option_list" title="_compose_custom_field_option_list :: Compose a Custom Field Options list with current selection"><span class="description">Compose a Custom Field Options list with current selection</span><pre>_compose_custom_field_option_list()</pre></a></li>
84
  <li class="method private "><a href="#_compose_data_source_option_list" title="_compose_data_source_option_list :: Compose a (Custom Field) Data Source Options list with current selection"><span class="description">Compose a (Custom Field) Data Source Options list with current selection</span><pre>_compose_data_source_option_list()</pre></a></li>
90
  <li class="method private "><a href="#_evaluate_post_information" title="_evaluate_post_information :: Evaluate post information for custom field mapping"><span class="description">Evaluate post information for custom field mapping</span><pre>_evaluate_post_information()</pre></a></li>
91
  <li class="method private "><a href="#_get_custom_field_names" title="_get_custom_field_names :: Generate a list of all (post) Custom Field names"><span class="description">Generate a list of all (post) Custom Field names</span><pre>_get_custom_field_names()</pre></a></li>
92
  <li class="method private "><a href="#_load_option_templates" title="_load_option_templates :: Load style and markup templates to $mla_templates"><span class="description">Load style and markup templates to $mla_templates</span><pre>_load_option_templates()</pre></a></li>
93
+ <li class="method private "><a href="#_update_attachment_metadata" title="_update_attachment_metadata :: Update _wp_attachment_metadata for just-inserted attachment"><span class="description">Update _wp_attachment_metadata for just-inserted attachment</span><pre>_update_attachment_metadata()</pre></a></li>
94
  <li class="method private "><a href="#_update_custom_field_mapping" title="_update_custom_field_mapping :: Update custom field mappings"><span class="description">Update custom field mappings</span><pre>_update_custom_field_mapping()</pre></a></li>
95
  <li class="method private "><a href="#_update_iptc_exif_custom_mapping" title="_update_iptc_exif_custom_mapping :: Update Custom field portion of IPTC/EXIF mappings"><span class="description">Update Custom field portion of IPTC/EXIF mappings</span><pre>_update_iptc_exif_custom_mapping()</pre></a></li>
96
  <li class="method private "><a href="#_update_iptc_exif_standard_mapping" title="_update_iptc_exif_standard_mapping :: Update Standard field portion of IPTC/EXIF mappings"><span class="description">Update Standard field portion of IPTC/EXIF mappings</span><pre>_update_iptc_exif_standard_mapping()</pre></a></li>
97
  <li class="method private "><a href="#_update_iptc_exif_taxonomy_mapping" title="_update_iptc_exif_taxonomy_mapping :: Update Taxonomy term portion of IPTC/EXIF mappings"><span class="description">Update Taxonomy term portion of IPTC/EXIF mappings</span><pre>_update_iptc_exif_taxonomy_mapping()</pre></a></li>
98
  <li class="nav-header">
99
  <i class="icon-custom icon-property"></i> Properties</li>
100
+ <li class="property public "><a href="#%24mla_option_definitions" title="$mla_option_definitions :: $mla_option_definitions defines the database options and admin page areas for setting/updating them"><span class="description">$mla_option_definitions defines the database options and admin page areas for setting/updating them</span><pre>$mla_option_definitions</pre></a></li>
101
  <li class="property public "><a href="#%24process_featured_in" title='$process_featured_in :: Option setting for "Featured in" reporting'><span class="description">Option setting for "Featured in" reporting</span><pre>$process_featured_in</pre></a></li>
102
  <li class="property public "><a href="#%24process_gallery_in" title='$process_gallery_in :: Option setting for "Gallery in" reporting'><span class="description">Option setting for "Gallery in" reporting</span><pre>$process_gallery_in</pre></a></li>
103
  <li class="property public "><a href="#%24process_inserted_in" title='$process_inserted_in :: Option setting for "Inserted in" reporting'><span class="description">Option setting for "Inserted in" reporting</span><pre>$process_inserted_in</pre></a></li>
104
  <li class="property public "><a href="#%24process_mla_gallery_in" title='$process_mla_gallery_in :: Option setting for "MLA Gallery in" reporting'><span class="description">Option setting for "MLA Gallery in" reporting</span><pre>$process_mla_gallery_in</pre></a></li>
105
  <li class="nav-header private">» Private</li>
106
+ <li class="property private "><a href="#%24add_attachment_id" title="$add_attachment_id :: Attachment ID passed from mla_add_attachment_action to mla_update_attachment_metadata_filter"><span class="description">Attachment ID passed from mla_add_attachment_action to mla_update_attachment_metadata_filter</span><pre>$add_attachment_id</pre></a></li>
107
  <li class="property private "><a href="#%24custom_field_data_sources" title="$custom_field_data_sources :: Array of Data Source names for custom field mapping"><span class="description">Array of Data Source names for custom field mapping</span><pre>$custom_field_data_sources</pre></a></li>
108
  <li class="property private "><a href="#%24mla_option_templates" title="$mla_option_templates :: Style and Markup templates"><span class="description">Style and Markup templates</span><pre>$mla_option_templates</pre></a></li>
109
  <li class="nav-header">
187
  </div></div>
188
  </div>
189
  <a name="mla_add_attachment_action" id="mla_add_attachment_action"></a><div class="element clickable method public mla_add_attachment_action" data-toggle="collapse" data-target=".mla_add_attachment_action .collapse">
190
+ <h2>Set $add_attachment_id to just-inserted attachment</h2>
191
+ <pre>mla_add_attachment_action(integer $post_ID) : void</pre>
192
  <div class="labels"></div>
193
  <div class="row collapse"><div class="detail-description">
194
+ <p class="long_description"><p>All of the actual processing is done later, in mla_update_attachment_metadata_filter.</p></p>
195
  <table class="table table-bordered"><tr>
196
  <th>since</th>
197
  <td>1.00</td>
198
  </tr></table>
199
  <h3>Parameters</h3>
200
  <div class="subelement argument">
201
+ <h4>$post_ID</h4>
202
  <code>integer</code><p>ID of just-inserted attachment</p>
203
  </div>
204
  </div></div>
332
  </div>
333
  <a name="mla_evaluate_iptc_exif_mapping" id="mla_evaluate_iptc_exif_mapping"></a><div class="element clickable method public mla_evaluate_iptc_exif_mapping" data-toggle="collapse" data-target=".mla_evaluate_iptc_exif_mapping .collapse">
334
  <h2>Evaluate IPTC/EXIF mapping updates for a post</h2>
335
+ <pre>mla_evaluate_iptc_exif_mapping(object $post, string $category, array $settings, array $attachment_metadata) : array</pre>
336
  <div class="labels"></div>
337
  <div class="row collapse"><div class="detail-description">
338
  <p class="long_description"></p>
351
  <h4>$settings</h4>
352
  <code>array</code><p>(optional) iptc_exif_mapping values, default - current option value</p>
353
  </div>
354
+ <div class="subelement argument">
355
+ <h4>$attachment_metadata</h4>
356
+ <code>array</code><p>(optional) _wp_attachment_metadata, for MLAOptions::mla_update_attachment_metadata_filter</p>
357
+ </div>
358
  <h3>Returns</h3>
359
  <div class="subelement response">
360
  <code>array</code>Updates suitable for MLAData::mla_update_single_item, if any</div>
383
  <code>string</code><code>boolean</code><code>null</code>requested template, false if not found or null if no templates</div>
384
  </div></div>
385
  </div>
386
+ <a name="mla_get_data_source" id="mla_get_data_source"></a><div class="element clickable method public mla_get_data_source" data-toggle="collapse" data-target=".mla_get_data_source .collapse">
387
+ <h2>Get IPTC/EXIF or custom field mapping data source</h2>
388
+ <pre>mla_get_data_source(integer $post_id, string $category, array $data_value, array $attachment_metadata) : string | array</pre>
389
+ <div class="labels"></div>
390
+ <div class="row collapse"><div class="detail-description">
391
+ <p class="long_description"><p>Defined as public so MLA Mapping Hooks clients can call it.
392
+ Isolates clients from changes to _evaluate_data_source().</p></p>
393
+ <table class="table table-bordered"><tr>
394
+ <th>since</th>
395
+ <td>1.70</td>
396
+ </tr></table>
397
+ <h3>Parameters</h3>
398
+ <div class="subelement argument">
399
+ <h4>$post_id</h4>
400
+ <code>integer</code><p>post->ID of attachment</p>
401
+ </div>
402
+ <div class="subelement argument">
403
+ <h4>$category</h4>
404
+ <code>string</code><p>category/scope to evaluate against: custom_field_mapping or single_attachment_mapping</p>
405
+ </div>
406
+ <div class="subelement argument">
407
+ <h4>$data_value</h4>
408
+ <code>array</code><p>data source specification ( name, *data_source, *keep_existing, *format, mla_column, quick_edit, bulk_edit, *meta_name, *option, no_null )</p>
409
+ </div>
410
+ <div class="subelement argument">
411
+ <h4>$attachment_metadata</h4>
412
+ <code>array</code><p>(optional) _wp_attachment_metadata, default NULL (use current postmeta database value)</p>
413
+ </div>
414
+ <h3>Returns</h3>
415
+ <div class="subelement response">
416
+ <code>string</code><code>array</code>data source value</div>
417
+ </div></div>
418
+ </div>
419
  <a name="mla_get_markup_templates" id="mla_get_markup_templates"></a><div class="element clickable method public mla_get_markup_templates" data-toggle="collapse" data-target=".mla_get_markup_templates .collapse">
420
  <h2>Get ALL markup templates from $mla_templates, including 'default'</h2>
421
  <pre>mla_get_markup_templates() : array | null</pre>
508
  <code>string</code>HTML table row markup for 'render' else message(s) reflecting the results of the operation.</div>
509
  </div></div>
510
  </div>
511
+ <a name="mla_localize_option_definitions_array" id="mla_localize_option_definitions_array"></a><div class="element clickable method public mla_localize_option_definitions_array" data-toggle="collapse" data-target=".mla_localize_option_definitions_array .collapse">
512
+ <h2>Localize $mla_option_definitions array</h2>
513
+ <pre>mla_localize_option_definitions_array() : void</pre>
514
+ <div class="labels"></div>
515
+ <div class="row collapse"><div class="detail-description">
516
+ <p class="long_description"><p>Localization must be done at runtime, and these calls cannot be placed
517
+ in the "public static" array definition itself.</p></p>
518
+ <table class="table table-bordered"><tr>
519
+ <th>since</th>
520
+ <td>1.6x</td>
521
+ </tr></table>
522
+ </div></div>
523
+ </div>
524
  <a name="mla_put_markup_templates" id="mla_put_markup_templates"></a><div class="element clickable method public mla_put_markup_templates" data-toggle="collapse" data-target=".mla_put_markup_templates .collapse">
525
  <h2>Put user-defined markup templates to $mla_templates and database</h2>
526
  <pre>mla_put_markup_templates(array $templates) : boolean</pre>
623
  </div></div>
624
  </div>
625
  <a name="mla_update_attachment_metadata_filter" id="mla_update_attachment_metadata_filter"></a><div class="element clickable method public mla_update_attachment_metadata_filter" data-toggle="collapse" data-target=".mla_update_attachment_metadata_filter .collapse">
626
+ <h2>Perform IPTC/EXIF and Custom Field mapping on just-inserted attachment</h2>
627
  <pre>mla_update_attachment_metadata_filter(array $data, integer $post_id) : void</pre>
628
  <div class="labels"></div>
629
  <div class="row collapse"><div class="detail-description">
630
+ <p class="long_description"><p>This filter tests the $add_attachment_id variable set by the mla_add_attachment_action
631
+ to ensure that mapping is only performed for new additions, not metadata updates.</p></p>
632
  <table class="table table-bordered"><tr>
633
  <th>since</th>
634
  <td>1.10</td>
666
  <code>boolean</code>True if the value was changed or false if the update failed</div>
667
  </div></div>
668
  </div>
669
+ <a name="mla_wp_handle_upload_filter" id="mla_wp_handle_upload_filter"></a><div class="element clickable method public mla_wp_handle_upload_filter" data-toggle="collapse" data-target=".mla_wp_handle_upload_filter .collapse">
670
+ <h2>Called once for each file uploaded</h2>
671
+ <pre>mla_wp_handle_upload_filter(array $file) : array</pre>
672
+ <div class="labels"></div>
673
+ <div class="row collapse"><div class="detail-description">
674
+ <p class="long_description"></p>
675
+ <table class="table table-bordered"><tr>
676
+ <th>since</th>
677
+ <td>1.70</td>
678
+ </tr></table>
679
+ <h3>Parameters</h3>
680
+ <div class="subelement argument">
681
+ <h4>$file</h4>
682
+ <code>array</code><p>file parameters ( 'name' )</p>
683
+ </div>
684
+ <h3>Returns</h3>
685
+ <div class="subelement response">
686
+ <code>array</code>updated file parameters</div>
687
+ </div></div>
688
+ </div>
689
+ <a name="mla_wp_handle_upload_prefilter_filter" id="mla_wp_handle_upload_prefilter_filter"></a><div class="element clickable method public mla_wp_handle_upload_prefilter_filter" data-toggle="collapse" data-target=".mla_wp_handle_upload_prefilter_filter .collapse">
690
+ <h2>Examine or alter the filename before the file is made permanent</h2>
691
+ <pre>mla_wp_handle_upload_prefilter_filter(array $file) : array</pre>
692
+ <div class="labels"></div>
693
+ <div class="row collapse"><div class="detail-description">
694
+ <p class="long_description"></p>
695
+ <table class="table table-bordered"><tr>
696
+ <th>since</th>
697
+ <td>1.70</td>
698
+ </tr></table>
699
+ <h3>Parameters</h3>
700
+ <div class="subelement argument">
701
+ <h4>$file</h4>
702
+ <code>array</code><p>file parameters ( 'name' )</p>
703
+ </div>
704
+ <h3>Returns</h3>
705
+ <div class="subelement response">
706
+ <code>array</code>updated file parameters</div>
707
+ </div></div>
708
+ </div>
709
  <a name="_compose_custom_field_option_list" id="_compose_custom_field_option_list"></a><div class="element clickable method private _compose_custom_field_option_list" data-toggle="collapse" data-target="._compose_custom_field_option_list .collapse">
710
  <h2>Compose a Custom Field Options list with current selection</h2>
711
  <pre>_compose_custom_field_option_list(string $selection, array $blacklist) : string</pre>
845
  </div>
846
  <a name="_evaluate_data_source" id="_evaluate_data_source"></a><div class="element clickable method private _evaluate_data_source" data-toggle="collapse" data-target="._evaluate_data_source .collapse">
847
  <h2>Evaluate custom field mapping data source</h2>
848
+ <pre>_evaluate_data_source(integer $post_id, string $category, array $data_value, array $attachment_metadata) : string | array</pre>
849
  <div class="labels"></div>
850
  <div class="row collapse"><div class="detail-description">
851
  <p class="long_description"></p>
864
  </div>
865
  <div class="subelement argument">
866
  <h4>$data_value</h4>
867
+ <code>array</code><p>data source specification ( name, *data_source, *keep_existing, *format, mla_column, quick_edit, bulk_edit, *meta_name, *option, no_null )</p>
868
  </div>
869
  <div class="subelement argument">
870
  <h4>$attachment_metadata</h4>
871
+ <code>array</code><p>(optional) _wp_attachment_metadata, default NULL (use current postmeta database value)</p>
872
  </div>
873
  <h3>Returns</h3>
874
  <div class="subelement response">
875
+ <code>string</code><code>array</code>data source value</div>
876
  </div></div>
877
  </div>
878
  <a name="_evaluate_file_information" id="_evaluate_file_information"></a><div class="element clickable method private _evaluate_file_information" data-toggle="collapse" data-target="._evaluate_file_information .collapse">
960
  </tr></table>
961
  </div></div>
962
  </div>
963
+ <a name="_update_attachment_metadata" id="_update_attachment_metadata"></a><div class="element clickable method private _update_attachment_metadata" data-toggle="collapse" data-target="._update_attachment_metadata .collapse">
964
+ <h2>Update _wp_attachment_metadata for just-inserted attachment</h2>
965
+ <pre>_update_attachment_metadata(array $updates, array $data) : array</pre>
966
+ <div class="labels"></div>
967
+ <div class="row collapse"><div class="detail-description">
968
+ <p class="long_description"></p>
969
+ <table class="table table-bordered"><tr>
970
+ <th>since</th>
971
+ <td>1.70</td>
972
+ </tr></table>
973
+ <h3>Parameters</h3>
974
+ <div class="subelement argument">
975
+ <h4>$updates</h4>
976
+ <code>array</code><p>Attachment metadata updates</p></div>
977
+ <div class="subelement argument">
978
+ <h4>$data</h4>
979
+ <code>array</code><p>Attachment metadata, by reference; updated by this function</p></div>
980
+ <h3>Returns</h3>
981
+ <div class="subelement response">
982
+ <code>array</code>Attachment metadata updates, with "meta:" elements removed</div>
983
+ </div></div>
984
+ </div>
985
  <a name="_update_custom_field_mapping" id="_update_custom_field_mapping"></a><div class="element clickable method private _update_custom_field_mapping" data-toggle="collapse" data-target="._update_custom_field_mapping .collapse">
986
  <h2>Update custom field mappings</h2>
987
  <pre>_update_custom_field_mapping(array $current_values, array $new_values) : array</pre>
1073
  <h3>
1074
  <i class="icon-custom icon-property"></i> Properties</h3>
1075
  <a name="%24mla_option_definitions" id="$mla_option_definitions"> </a><div class="element clickable property public $mla_option_definitions" data-toggle="collapse" data-target=".$mla_option_definitions .collapse">
1076
+ <h2>$mla_option_definitions defines the database options and admin page areas for setting/updating them</h2>
1077
  <pre>$mla_option_definitions </pre>
1078
  <div class="labels"></div>
1079
+ <div class="row collapse"><div class="detail-description"><p class="long_description"><p>The array must be populated at runtime in MLAOptions::mla_localize_option_definitions_array(),
1080
+ because Localization calls cannot be placed in the "public static" array definition itself.</p>
1081
+
1082
+ <p>Each option is defined by an array with the following elements:</p>
1083
 
1084
  <p>array key => HTML id/name attribute and option database key (OMIT MLA_OPTION_PREFIX)</p>
1085
 
1150
  </tr></table>
1151
  </div></div>
1152
  </div>
1153
+ <a name="%24add_attachment_id" id="$add_attachment_id"> </a><div class="element clickable property private $add_attachment_id" data-toggle="collapse" data-target=".$add_attachment_id .collapse">
1154
+ <h2>Attachment ID passed from mla_add_attachment_action to mla_update_attachment_metadata_filter</h2>
1155
+ <pre>$add_attachment_id : integer</pre>
1156
+ <div class="labels"></div>
1157
+ <div class="row collapse"><div class="detail-description">
1158
+ <p class="long_description"><p>Ensures that IPTC/EXIF and Custom Field mapping is only performed when the attachment is first
1159
+ added to the Media Library.</p></p>
1160
+ <table class="table table-bordered"><tr>
1161
+ <th>since</th>
1162
+ <td>1.70</td>
1163
+ </tr></table>
1164
+ </div></div>
1165
+ </div>
1166
  <a name="%24custom_field_data_sources" id="$custom_field_data_sources"> </a><div class="element clickable property private $custom_field_data_sources" data-toggle="collapse" data-target=".$custom_field_data_sources .collapse">
1167
  <h2>Array of Data Source names for custom field mapping</h2>
1168
  <pre>$custom_field_data_sources : array</pre>
1396
  <div class="row"><footer class="span12">
1397
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
1398
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
1399
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
1400
  </div>
1401
  </body>
1402
  </html>
phpDocs/classes/MLASettings.html CHANGED
@@ -70,6 +70,7 @@ add settings link in the Plugins section entry for MLA.</span><pre>mla_admin_men
70
  <li class="method public "><a href="#mla_get_icon_type_dropdown" title="mla_get_icon_type_dropdown :: Get an HTML select element representing a list of icon types"><span class="description">Get an HTML select element representing a list of icon types</span><pre>mla_get_icon_type_dropdown()</pre></a></li>
71
  <li class="method public "><a href="#mla_inline_edit_upload_action" title="mla_inline_edit_upload_action :: Ajax handler for Upload MIME Types inline editing (quick and bulk edit)"><span class="description">Ajax handler for Upload MIME Types inline editing (quick and bulk edit)</span><pre>mla_inline_edit_upload_action()</pre></a></li>
72
  <li class="method public "><a href="#mla_inline_edit_view_action" title="mla_inline_edit_view_action :: Ajax handler for Post MIME Types inline editing (quick and bulk edit)"><span class="description">Ajax handler for Post MIME Types inline editing (quick and bulk edit)</span><pre>mla_inline_edit_view_action()</pre></a></li>
 
73
  <li class="method public "><a href="#mla_render_settings_page" title='mla_render_settings_page :: Render (echo) the "Media Library Assistant" subpage in the Settings section'><span class="description">Render (echo) the "Media Library Assistant" subpage in the Settings section</span><pre>mla_render_settings_page()</pre></a></li>
74
  <li class="method public "><a href="#mla_screen_options_show_screen_filter" title="mla_screen_options_show_screen_filter :: Only show screen options on the View and Upload tabs"><span class="description">Only show screen options on the View and Upload tabs</span><pre>mla_screen_options_show_screen_filter()</pre></a></li>
75
  <li class="method public "><a href="#mla_set_screen_option_filter" title='mla_set_screen_option_filter :: Save the "Views/Uploads per page" option set by this user'><span class="description">Save the "Views/Uploads per page" option set by this user</span><pre>mla_set_screen_option_filter()</pre></a></li>
@@ -331,6 +332,19 @@ add settings link in the Plugins section entry for MLA.</h2>
331
  </tr></table>
332
  </div></div>
333
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  <a name="mla_render_settings_page" id="mla_render_settings_page"></a><div class="element clickable method public mla_render_settings_page" data-toggle="collapse" data-target=".mla_render_settings_page .collapse">
335
  <h2>Render (echo) the "Media Library Assistant" subpage in the Settings section</h2>
336
  <pre>mla_render_settings_page() : void</pre>
@@ -1065,7 +1079,10 @@ Each tab is defined by an array with the following elements:</h2>
1065
  <pre>$mla_tablist : array</pre>
1066
  <div class="labels"></div>
1067
  <div class="row collapse"><div class="detail-description">
1068
- <p class="long_description"><p>array key => HTML id/name attribute and option database key (OMIT MLA_OPTION_PREFIX)</p>
 
 
 
1069
 
1070
  <p>title => tab label / heading text
1071
  render => rendering function for tab messages and content. Usage:
@@ -1152,7 +1169,7 @@ each page load and cached for subsequent use.</p></p>
1152
  <div class="row"><footer class="span12">
1153
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
1154
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
1155
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
1156
  </div>
1157
  </body>
1158
  </html>
70
  <li class="method public "><a href="#mla_get_icon_type_dropdown" title="mla_get_icon_type_dropdown :: Get an HTML select element representing a list of icon types"><span class="description">Get an HTML select element representing a list of icon types</span><pre>mla_get_icon_type_dropdown()</pre></a></li>
71
  <li class="method public "><a href="#mla_inline_edit_upload_action" title="mla_inline_edit_upload_action :: Ajax handler for Upload MIME Types inline editing (quick and bulk edit)"><span class="description">Ajax handler for Upload MIME Types inline editing (quick and bulk edit)</span><pre>mla_inline_edit_upload_action()</pre></a></li>
72
  <li class="method public "><a href="#mla_inline_edit_view_action" title="mla_inline_edit_view_action :: Ajax handler for Post MIME Types inline editing (quick and bulk edit)"><span class="description">Ajax handler for Post MIME Types inline editing (quick and bulk edit)</span><pre>mla_inline_edit_view_action()</pre></a></li>
73
+ <li class="method public "><a href="#mla_localize_tablist" title="mla_localize_tablist :: Localize $mla_option_definitions array"><span class="description">Localize $mla_option_definitions array</span><pre>mla_localize_tablist()</pre></a></li>
74
  <li class="method public "><a href="#mla_render_settings_page" title='mla_render_settings_page :: Render (echo) the "Media Library Assistant" subpage in the Settings section'><span class="description">Render (echo) the "Media Library Assistant" subpage in the Settings section</span><pre>mla_render_settings_page()</pre></a></li>
75
  <li class="method public "><a href="#mla_screen_options_show_screen_filter" title="mla_screen_options_show_screen_filter :: Only show screen options on the View and Upload tabs"><span class="description">Only show screen options on the View and Upload tabs</span><pre>mla_screen_options_show_screen_filter()</pre></a></li>
76
  <li class="method public "><a href="#mla_set_screen_option_filter" title='mla_set_screen_option_filter :: Save the "Views/Uploads per page" option set by this user'><span class="description">Save the "Views/Uploads per page" option set by this user</span><pre>mla_set_screen_option_filter()</pre></a></li>
332
  </tr></table>
333
  </div></div>
334
  </div>
335
+ <a name="mla_localize_tablist" id="mla_localize_tablist"></a><div class="element clickable method public mla_localize_tablist" data-toggle="collapse" data-target=".mla_localize_tablist .collapse">
336
+ <h2>Localize $mla_option_definitions array</h2>
337
+ <pre>mla_localize_tablist() : void</pre>
338
+ <div class="labels"></div>
339
+ <div class="row collapse"><div class="detail-description">
340
+ <p class="long_description"><p>Localization must be done at runtime, and these calls cannot be placed
341
+ in the "public static" array definition itself.</p></p>
342
+ <table class="table table-bordered"><tr>
343
+ <th>since</th>
344
+ <td>1.6x</td>
345
+ </tr></table>
346
+ </div></div>
347
+ </div>
348
  <a name="mla_render_settings_page" id="mla_render_settings_page"></a><div class="element clickable method public mla_render_settings_page" data-toggle="collapse" data-target=".mla_render_settings_page .collapse">
349
  <h2>Render (echo) the "Media Library Assistant" subpage in the Settings section</h2>
350
  <pre>mla_render_settings_page() : void</pre>
1079
  <pre>$mla_tablist : array</pre>
1080
  <div class="labels"></div>
1081
  <div class="row collapse"><div class="detail-description">
1082
+ <p class="long_description"><p>The array must be populated at runtime in MLASettings::mla_localize_tablist(),
1083
+ because Localization calls cannot be placed in the "public static" array definition itself.</p>
1084
+
1085
+ <p>array key => HTML id/name attribute and option database key (OMIT MLA_OPTION_PREFIX)</p>
1086
 
1087
  <p>title => tab label / heading text
1088
  render => rendering function for tab messages and content. Usage:
1169
  <div class="row"><footer class="span12">
1170
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
1171
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
1172
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
1173
  </div>
1174
  </body>
1175
  </html>
phpDocs/classes/MLAShortcodes.html CHANGED
@@ -568,7 +568,7 @@ any further logic required to translate those values is contained in the filter.
568
  <div class="row"><footer class="span12">
569
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
570
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
571
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
572
  </div>
573
  </body>
574
  </html>
568
  <div class="row"><footer class="span12">
569
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
570
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
571
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
572
  </div>
573
  </body>
574
  </html>
phpDocs/classes/MLATest.html CHANGED
@@ -162,7 +162,7 @@ to ensure the plugin can run in the current WordPress envrionment.</p>
162
  <div class="row"><footer class="span12">
163
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
164
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
165
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
166
  </div>
167
  </body>
168
  </html>
162
  <div class="row"><footer class="span12">
163
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
164
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
165
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
166
  </div>
167
  </body>
168
  </html>
phpDocs/classes/MLATextWidget.html CHANGED
@@ -56,13 +56,9 @@
56
  <i class="icon-custom icon-method"></i> Methods</li>
57
  <li class="method public "><a href="#__construct" title="__construct :: Calls the parent constructor to set some defaults."><span class="description">Calls the parent constructor to set some defaults.</span><pre>__construct()</pre></a></li>
58
  <li class="method public "><a href="#form" title='form :: Echo the "edit widget" form on the Appearance/Widgets admin screen'><span class="description">Echo the "edit widget" form on the Appearance/Widgets admin screen</span><pre>form()</pre></a></li>
59
- <li class="method public "><a href="#mla_text_widget_plugins_loaded_action" title="mla_text_widget_plugins_loaded_action :: Load a plugin text domain"><span class="description">Load a plugin text domain</span><pre>mla_text_widget_plugins_loaded_action()</pre></a></li>
60
  <li class="method public "><a href="#mla_text_widget_widgets_init_action" title="mla_text_widget_widgets_init_action :: Register the widget with WordPress"><span class="description">Register the widget with WordPress</span><pre>mla_text_widget_widgets_init_action()</pre></a></li>
61
  <li class="method public "><a href="#update" title="update :: Sanitize widget definition as it is saved to the database"><span class="description">Sanitize widget definition as it is saved to the database</span><pre>update()</pre></a></li>
62
  <li class="method public "><a href="#widget" title='widget :: Display the widget content - called from the WordPress "front end"'><span class="description">Display the widget content - called from the WordPress "front end"</span><pre>widget()</pre></a></li>
63
- <li class="nav-header">
64
- <i class="icon-custom icon-constant"></i> Constants</li>
65
- <li class="constant "><a href="#MLA_TEXT_DOMAIN" title="MLA_TEXT_DOMAIN :: Provides a unique name for the plugin text domain"><span class="description">Provides a unique name for the plugin text domain</span><pre>MLA_TEXT_DOMAIN</pre></a></li>
66
  </ul>
67
  </div>
68
  <div class="span8">
@@ -119,18 +115,6 @@
119
  <code>array</code><p>Previous definition values, from the database</p></div>
120
  </div></div>
121
  </div>
122
- <a name="mla_text_widget_plugins_loaded_action" id="mla_text_widget_plugins_loaded_action"></a><div class="element clickable method public mla_text_widget_plugins_loaded_action" data-toggle="collapse" data-target=".mla_text_widget_plugins_loaded_action .collapse">
123
- <h2>Load a plugin text domain</h2>
124
- <pre>mla_text_widget_plugins_loaded_action() : void</pre>
125
- <div class="labels"></div>
126
- <div class="row collapse"><div class="detail-description">
127
- <p class="long_description"><p>Defined as public because it's an action.</p></p>
128
- <table class="table table-bordered"><tr>
129
- <th>since</th>
130
- <td>1.60</td>
131
- </tr></table>
132
- </div></div>
133
- </div>
134
  <a name="mla_text_widget_widgets_init_action" id="mla_text_widget_widgets_init_action"></a><div class="element clickable method public mla_text_widget_widgets_init_action" data-toggle="collapse" data-target=".mla_text_widget_widgets_init_action .collapse">
135
  <h2>Register the widget with WordPress</h2>
136
  <pre>mla_text_widget_widgets_init_action() : void</pre>
@@ -184,14 +168,6 @@
184
  <code>array</code><p>Widget definition, from the database</p></div>
185
  </div></div>
186
  </div>
187
- <h3>
188
- <i class="icon-custom icon-constant"></i> Constants</h3>
189
- <a name="MLA_TEXT_DOMAIN" id="MLA_TEXT_DOMAIN"> </a><div class="element clickable constant MLA_TEXT_DOMAIN" data-toggle="collapse" data-target=".MLA_TEXT_DOMAIN .collapse">
190
- <h2>Provides a unique name for the plugin text domain</h2>
191
- <pre>MLA_TEXT_DOMAIN </pre>
192
- <div class="labels"></div>
193
- <div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div>
194
- </div>
195
  </div>
196
  </div>
197
  </div>
@@ -199,7 +175,7 @@
199
  <div class="row"><footer class="span12">
200
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
201
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
202
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
203
  </div>
204
  </body>
205
  </html>
56
  <i class="icon-custom icon-method"></i> Methods</li>
57
  <li class="method public "><a href="#__construct" title="__construct :: Calls the parent constructor to set some defaults."><span class="description">Calls the parent constructor to set some defaults.</span><pre>__construct()</pre></a></li>
58
  <li class="method public "><a href="#form" title='form :: Echo the "edit widget" form on the Appearance/Widgets admin screen'><span class="description">Echo the "edit widget" form on the Appearance/Widgets admin screen</span><pre>form()</pre></a></li>
 
59
  <li class="method public "><a href="#mla_text_widget_widgets_init_action" title="mla_text_widget_widgets_init_action :: Register the widget with WordPress"><span class="description">Register the widget with WordPress</span><pre>mla_text_widget_widgets_init_action()</pre></a></li>
60
  <li class="method public "><a href="#update" title="update :: Sanitize widget definition as it is saved to the database"><span class="description">Sanitize widget definition as it is saved to the database</span><pre>update()</pre></a></li>
61
  <li class="method public "><a href="#widget" title='widget :: Display the widget content - called from the WordPress "front end"'><span class="description">Display the widget content - called from the WordPress "front end"</span><pre>widget()</pre></a></li>
 
 
 
62
  </ul>
63
  </div>
64
  <div class="span8">
115
  <code>array</code><p>Previous definition values, from the database</p></div>
116
  </div></div>
117
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
118
  <a name="mla_text_widget_widgets_init_action" id="mla_text_widget_widgets_init_action"></a><div class="element clickable method public mla_text_widget_widgets_init_action" data-toggle="collapse" data-target=".mla_text_widget_widgets_init_action .collapse">
119
  <h2>Register the widget with WordPress</h2>
120
  <pre>mla_text_widget_widgets_init_action() : void</pre>
168
  <code>array</code><p>Widget definition, from the database</p></div>
169
  </div></div>
170
  </div>
 
 
 
 
 
 
 
 
171
  </div>
172
  </div>
173
  </div>
175
  <div class="row"><footer class="span12">
176
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
177
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
178
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
179
  </div>
180
  </body>
181
  </html>
phpDocs/classes/MLA_List_Table.html CHANGED
@@ -1030,8 +1030,7 @@ use the special slug "cb".</p>
1030
  column in your table you must create a column_cb() method. If you don't need
1031
  bulk actions or checkboxes, simply leave the 'cb' entry out of your array.</p>
1032
 
1033
- <p>Taxonomy columns are added to this array by mla_admin_init_action.
1034
- Custom field columns are added to this array by mla_admin_init_action.</p></p>
1035
  <table class="table table-bordered"><tr>
1036
  <th>since</th>
1037
  <td>0.1</td>
@@ -1049,8 +1048,8 @@ the user has not altered the selection of hidden columns.</p>
1049
  <p>The value on the right-hand side must match the column slug, e.g.,
1050
  array(0 => 'ID_parent, 1 => 'title_name').</p>
1051
 
1052
- <p>Taxonomy columns are added to this array by mla_admin_init_action.
1053
- Custom field columns are added to this array by mla_admin_init_action.</p></p>
1054
  <table class="table table-bordered"><tr>
1055
  <th>since</th>
1056
  <td>0.1</td>
@@ -1070,8 +1069,8 @@ the case (as the value is a column name from the database, not the list table).<
1070
  <p>The array value also contains a boolean which is 'true' if the data is currently
1071
  sorted by that column. This is computed each time the table is displayed.</p>
1072
 
1073
- <p>Taxonomy columns, if any, are added to this array by mla_admin_init_action.
1074
- Custom field columns are added to this array by mla_admin_init_action.</p></p>
1075
  <table class="table table-bordered"><tr>
1076
  <th>since</th>
1077
  <td>0.1</td>
@@ -1097,7 +1096,7 @@ Custom field columns are added to this array by mla_admin_init_action.</p></p>
1097
  <div class="row"><footer class="span12">
1098
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
1099
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
1100
- generated on 2013-11-27T11:31:01-08:00.<br></footer></div>
1101
  </div>
1102
  </body>
1103
  </html>
1030
  column in your table you must create a column_cb() method. If you don't need
1031
  bulk actions or checkboxes, simply leave the 'cb' entry out of your array.</p>
1032
 
1033
+ <p>All of the columns are added to this array by MLA_List_Table::mla_admin_init_action.</p></p>
 
1034
  <table class="table table-bordered"><tr>
1035
  <th>since</th>
1036
  <td>0.1</td>
1048
  <p>The value on the right-hand side must match the column slug, e.g.,
1049
  array(0 => 'ID_parent, 1 => 'title_name').</p>
1050
 
1051
+ <p>Taxonomy and custom field columns are added to this array by
1052
+ MLA_List_Table::mla_admin_init_action.</p></p>
1053
  <table class="table table-bordered"><tr>
1054
  <th>since</th>
1055
  <td>0.1</td>
1069
  <p>The array value also contains a boolean which is 'true' if the data is currently
1070
  sorted by that column. This is computed each time the table is displayed.</p>
1071
 
1072
+ <p>Taxonomy and custom field columns are added to this array by
1073
+ MLA_List_Table::mla_admin_init_action.</p></p>
1074
  <table class="table table-bordered"><tr>
1075
  <th>since</th>
1076
  <td>0.1</td>
1096
  <div class="row"><footer class="span12">
1097
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
1098
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
1099
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
1100
  </div>
1101
  </body>
1102
  </html>
phpDocs/classes/MLA_Upload_List_Table.html CHANGED
@@ -669,7 +669,9 @@ $this->set_pagination_args().</p></p>
669
  <div class="labels"></div>
670
  <div class="row collapse"><div class="detail-description">
671
  <p class="long_description"><p>This array defines table columns and titles where the key is the column slug (and class)
672
- and the value is the column's title text.</p></p>
 
 
673
  <table class="table table-bordered"><tr>
674
  <th>since</th>
675
  <td>1.40</td>
@@ -717,7 +719,7 @@ sorted by that column. This is computed each time the table is displayed.</p></p
717
  <div class="row"><footer class="span12">
718
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
719
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
720
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
721
  </div>
722
  </body>
723
  </html>
669
  <div class="labels"></div>
670
  <div class="row collapse"><div class="detail-description">
671
  <p class="long_description"><p>This array defines table columns and titles where the key is the column slug (and class)
672
+ and the value is the column's title text.</p>
673
+
674
+ <p>All of the columns are added to this array by MLA_Upload_List_Table::mla_admin_init_action.</p></p>
675
  <table class="table table-bordered"><tr>
676
  <th>since</th>
677
  <td>1.40</td>
719
  <div class="row"><footer class="span12">
720
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
721
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
722
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
723
  </div>
724
  </body>
725
  </html>
phpDocs/classes/MLA_Upload_Optional_List_Table.html CHANGED
@@ -487,7 +487,9 @@ $this->set_pagination_args().</p></p>
487
  <div class="labels"></div>
488
  <div class="row collapse"><div class="detail-description">
489
  <p class="long_description"><p>This array defines table columns and titles where the key is the column slug (and class)
490
- and the value is the column's title text.</p></p>
 
 
491
  <table class="table table-bordered"><tr>
492
  <th>since</th>
493
  <td>1.40</td>
@@ -535,7 +537,7 @@ sorted by that column. This is computed each time the table is displayed.</p></p
535
  <div class="row"><footer class="span12">
536
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
537
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
538
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
539
  </div>
540
  </body>
541
  </html>
487
  <div class="labels"></div>
488
  <div class="row collapse"><div class="detail-description">
489
  <p class="long_description"><p>This array defines table columns and titles where the key is the column slug (and class)
490
+ and the value is the column's title text.</p>
491
+
492
+ <p>All of the columns are added to this array by MLA_Upload_Optional_List_Table::mla_admin_init_action.</p></p>
493
  <table class="table table-bordered"><tr>
494
  <th>since</th>
495
  <td>1.40</td>
537
  <div class="row"><footer class="span12">
538
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
539
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
540
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
541
  </div>
542
  </body>
543
  </html>
phpDocs/classes/MLA_View_List_Table.html CHANGED
@@ -566,7 +566,9 @@ $this->set_pagination_args().</p></p>
566
  <div class="labels"></div>
567
  <div class="row collapse"><div class="detail-description">
568
  <p class="long_description"><p>This array defines table columns and titles where the key is the column slug (and class)
569
- and the value is the column's title text.</p></p>
 
 
570
  <table class="table table-bordered"><tr>
571
  <th>since</th>
572
  <td>1.40</td>
@@ -614,7 +616,7 @@ sorted by that column. This is computed each time the table is displayed.</p></p
614
  <div class="row"><footer class="span12">
615
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
616
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
617
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
618
  </div>
619
  </body>
620
  </html>
566
  <div class="labels"></div>
567
  <div class="row collapse"><div class="detail-description">
568
  <p class="long_description"><p>This array defines table columns and titles where the key is the column slug (and class)
569
+ and the value is the column's title text.</p>
570
+
571
+ <p>All of the columns are added to this array by MLA_View_List_Table::mla_admin_init_action.</p></p>
572
  <table class="table table-bordered"><tr>
573
  <th>since</th>
574
  <td>1.40</td>
616
  <div class="row"><footer class="span12">
617
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
618
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
619
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
620
  </div>
621
  </body>
622
  </html>
phpDocs/deprecated.html CHANGED
@@ -64,7 +64,7 @@
64
  <div class="row"><footer class="span12">
65
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
66
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
67
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
68
  </div>
69
  </body>
70
  </html>
64
  <div class="row"><footer class="span12">
65
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
66
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
67
+ generated on 2014-01-11T19:47:38-08:00.<br></footer></div>
68
  </div>
69
  </body>
70
  </html>
phpDocs/errors.html CHANGED
@@ -83,7 +83,7 @@
83
  <div class="row"><footer class="span12">
84
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
85
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
86
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
87
  </div>
88
  </body>
89
  </html>
83
  <div class="row"><footer class="span12">
84
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
85
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
86
+ generated on 2014-01-11T19:47:38-08:00.<br></footer></div>
87
  </div>
88
  </body>
89
  </html>
phpDocs/graph_class.html CHANGED
@@ -61,7 +61,7 @@
61
  </script><div class="row"><footer class="span12">
62
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
63
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
64
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
65
  </div>
66
  </body>
67
  </html>
61
  </script><div class="row"><footer class="span12">
62
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
63
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
64
+ generated on 2014-01-11T19:47:38-08:00.<br></footer></div>
65
  </div>
66
  </body>
67
  </html>
phpDocs/index.html CHANGED
@@ -83,7 +83,7 @@
83
  <div class="row"><footer class="span12">
84
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
85
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
86
- generated on 2013-11-27T11:31:01-08:00.<br></footer></div>
87
  </div>
88
  </body>
89
  </html>
83
  <div class="row"><footer class="span12">
84
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
85
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
86
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
87
  </div>
88
  </body>
89
  </html>
phpDocs/markers.html CHANGED
@@ -76,7 +76,7 @@
76
  </tr>
77
  <tr>
78
  <td>todo</td>
79
- <td>2937</td>
80
  <td>encode the rest</td>
81
  </tr>
82
  </table></div>
@@ -86,7 +86,7 @@
86
  <div class="row"><footer class="span12">
87
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
88
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
89
- generated on 2013-11-27T11:31:02-08:00.<br></footer></div>
90
  </div>
91
  </body>
92
  </html>
76
  </tr>
77
  <tr>
78
  <td>todo</td>
79
+ <td>3055</td>
80
  <td>encode the rest</td>
81
  </tr>
82
  </table></div>
86
  <div class="row"><footer class="span12">
87
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
88
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
89
+ generated on 2014-01-11T19:47:38-08:00.<br></footer></div>
90
  </div>
91
  </body>
92
  </html>
phpDocs/namespaces/global.html CHANGED
@@ -237,7 +237,7 @@ searchable database of exension/type associations for the "Uploads" admin settin
237
  <div class="row"><footer class="span12">
238
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
239
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
240
- generated on 2013-11-27T11:31:01-08:00.<br></footer></div>
241
  </div>
242
  </body>
243
  </html>
237
  <div class="row"><footer class="span12">
238
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
239
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
240
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
241
  </div>
242
  </body>
243
  </html>
phpDocs/packages/Media Library Assistant.html CHANGED
@@ -269,7 +269,7 @@ searchable database of exension/type associations for the "Uploads" admin settin
269
  <div class="row"><footer class="span12">
270
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
271
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
272
- generated on 2013-11-27T11:31:01-08:00.<br></footer></div>
273
  </div>
274
  </body>
275
  </html>
269
  <div class="row"><footer class="span12">
270
  Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
271
  Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a8</a> and<br>
272
+ generated on 2014-01-11T19:47:37-08:00.<br></footer></div>
273
  </div>
274
  </body>
275
  </html>
phpDocs/structure.xml CHANGED
@@ -1,6 +1,6 @@
1
  <?xml version="1.0" encoding="utf-8"?>
2
  <project version="2.0.0a8" title="Media Library Assistant">
3
- <file path="includes\class-mla-data.php" hash="2eee9355da57f60772df83fd26540b65" package="Media Library Assistant">
4
  <docblock line="2">
5
  <description><![CDATA[Database and template file access for MLA needs]]></description>
6
  <long-description><![CDATA[]]></long-description>
@@ -18,60 +18,61 @@ Templates separate HTML markup from PHP code for easier maintenance and localiza
18
  <tag line="9" name="package" description="Media Library Assistant"/>
19
  <tag line="9" name="since" description="0.1"/>
20
  </docblock>
21
- <constant namespace="global" line="24" package="Media Library Assistant">
22
  <name>MLA_ALT_TEXT_VIEW_SUFFIX</name>
23
  <full_name>MLA_ALT_TEXT_VIEW_SUFFIX</full_name>
24
  <value><![CDATA['alt_text_view']]></value>
25
  <docblock line="19">
26
- <description><![CDATA[Provides a unique suffix for the ALT Text SQL VIEW]]></description>
27
- <long-description><![CDATA[]]></long-description>
 
28
  <tag line="19" name="since" description="0.40"/>
29
  </docblock>
30
  </constant>
31
- <property final="false" static="true" visibility="private" line="33" namespace="global" package="Media Library Assistant">
32
  <name>$mla_alt_text_view</name>
33
  <default><![CDATA[NULL]]></default>
34
- <docblock line="26">
35
- <description><![CDATA[Provides a unique name for the ALT Text SQL VIEW]]></description>
36
  <long-description><![CDATA[]]></long-description>
37
- <tag line="26" name="since" description="0.40"/>
38
- <tag line="26" name="var" description="" type="array">
39
  <type by_reference="false">array</type>
40
  </tag>
41
  </docblock>
42
  </property>
43
- <property final="false" static="true" visibility="private" line="1041" namespace="global" package="Media Library Assistant">
44
  <name>$mla_list_table_items</name>
45
  <default><![CDATA[NULL]]></default>
46
- <docblock line="1034">
47
  <description><![CDATA[Cache the results of mla_count_list_table_items for reuse in mla_query_list_table_items]]></description>
48
  <long-description><![CDATA[]]></long-description>
49
- <tag line="1034" name="since" description="1.40"/>
50
- <tag line="1034" name="var" description="" type="array">
51
  <type by_reference="false">array</type>
52
  </tag>
53
  </docblock>
54
  </property>
55
- <property final="false" static="true" visibility="private" line="1147" namespace="global" package="Media Library Assistant">
56
  <name>$query_parameters</name>
57
  <default><![CDATA[array()]]></default>
58
- <docblock line="1134">
59
  <description><![CDATA[WP_Query filter "parameters"]]></description>
60
  <long-description><![CDATA[<p>This array defines parameters for the query's join, where and orderby filters.
61
  The parameters are set up in the _prepare_list_table_query function, and
62
  any further logic required to translate those values is contained in the filters.</p>
63
 
64
  <p>Array index values are: use_postmeta_view, postmeta_key, postmeta_value, patterns, detached, orderby, order, mla-metavalue, debug, s, mla_search_connector, mla_search_fields, sentence, exact</p>]]></long-description>
65
- <tag line="1134" name="since" description="0.30"/>
66
- <tag line="1134" name="var" description="" type="array">
67
  <type by_reference="false">array</type>
68
  </tag>
69
  </docblock>
70
  </property>
71
- <property final="false" static="true" visibility="private" line="2386" namespace="global" package="Media Library Assistant">
72
  <name>$galleries</name>
73
  <default><![CDATA[null]]></default>
74
- <docblock line="2367">
75
  <description><![CDATA[Objects containing [gallery] shortcodes]]></description>
76
  <long-description><![CDATA[<p>This array contains all of the objects containing one or more [gallery] shortcodes
77
  and array(s) of which attachments each [gallery] contains. The arrays are built once
@@ -84,1806 +85,1806 @@ each page load and cached for subsequent calls.</p>
84
  ['galleries'] array of [gallery] entries numbered from one (1), containing:
85
  galleries[X]['query'] contains a string with the arguments of the [gallery],
86
  galleries[X]['results'] contains an array ( ID ) of post_ids for the objects in the gallery.</p>]]></long-description>
87
- <tag line="2367" name="since" description="0.70"/>
88
- <tag line="2367" name="var" description="" type="array">
89
  <type by_reference="false">array</type>
90
  </tag>
91
  </docblock>
92
  </property>
93
- <property final="false" static="true" visibility="private" line="2399" namespace="global" package="Media Library Assistant">
94
  <name>$mla_galleries</name>
95
  <default><![CDATA[null]]></default>
96
- <docblock line="2388">
97
  <description><![CDATA[Objects containing [mla_gallery] shortcodes]]></description>
98
  <long-description><![CDATA[<p>This array contains all of the objects containing one or more [mla_gallery] shortcodes
99
  and array(s) of which attachments each [mla_gallery] contains. The arrays are built once
100
  each page load and cached for subsequent calls.</p>]]></long-description>
101
- <tag line="2388" name="since" description="0.70"/>
102
- <tag line="2388" name="var" description="" type="array">
103
  <type by_reference="false">array</type>
104
  </tag>
105
  </docblock>
106
  </property>
107
- <property final="false" static="true" visibility="private" line="2586" namespace="global" package="Media Library Assistant">
108
  <name>$pdf_indirect_objects</name>
109
  <default><![CDATA[NULL]]></default>
110
- <docblock line="2575">
111
  <description><![CDATA[Array of PDF indirect objects]]></description>
112
  <long-description><![CDATA[<p>This array contains all of the indirect object offsets and lengths.
113
  The array key is ( object ID * 1000 ) + object generation.
114
  The array value is array( number, generation, start, optional /length )</p>]]></long-description>
115
- <tag line="2575" name="since" description="1.50"/>
116
- <tag line="2575" name="var" description="" type="array">
117
  <type by_reference="false">array</type>
118
  </tag>
119
  </docblock>
120
  </property>
121
- <property final="false" static="true" visibility="private" line="3654" namespace="global" package="Media Library Assistant">
122
  <name>$utf8_chars</name>
123
  <default><![CDATA[array("\xC2\x80", "\xC2\x81", "\xC2\x82", "\xC2\x83", "\xC2\x84", "\xC2\x85", "\xC2\x86", "\xC2\x87", "\xC2\x88", "\xC2\x89", "\xC2\x8A", "\xC2\x8B", "\xC2\x8C", "\xC2\x8D", "\xC2\x8E", "\xC2\x8F", "\xC2\x90", "\xC2\x91", "\xC2\x92", "\xC2\x93", "\xC2\x94", "\xC2\x95", "\xC2\x96", "\xC2\x97", "\xC2\x98", "\xC2\x99", "\xC2\x9A", "\xC2\x9B", "\xC2\x9C", "\xC2\x9D", "\xC2\x9E", "\xC2\x9F", "\xC2\xA0", "\xC2\xA1", "\xC2\xA2", "\xC2\xA3", "\xC2\xA4", "\xC2\xA5", "\xC2\xA6", "\xC2\xA7", "\xC2\xA8", "\xC2\xA9", "\xC2\xAA", "\xC2\xAB", "\xC2\xAC", "\xC2\xAD", "\xC2\xAE", "\xC2\xAF", "\xC2\xB0", "\xC2\xB1", "\xC2\xB2", "\xC2\xB3", "\xC2\xB4", "\xC2\xB5", "\xC2\xB6", "\xC2\xB7", "\xC2\xB8", "\xC2\xB9", "\xC2\xBA", "\xC2\xBB", "\xC2\xBC", "\xC2\xBD", "\xC2\xBE", "\xC2\xBF", "\xC3\x80", "\xC3\x81", "\xC3\x82", "\xC3\x83", "\xC3\x84", "\xC3\x85", "\xC3\x86", "\xC3\x87", "\xC3\x88", "\xC3\x89", "\xC3\x8A", "\xC3\x8B", "\xC3\x8C", "\xC3\x8D", "\xC3\x8E", "\xC3\x8F", "\xC3\x90", "\xC3\x91", "\xC3\x92", "\xC3\x93", "\xC3\x94", "\xC3\x95", "\xC3\x96", "\xC3\x97", "\xC3\x98", "\xC3\x99", "\xC3\x9A", "\xC3\x9B", "\xC3\x9C", "\xC3\x9D", "\xC3\x9E", "\xC3\x9F", "\xC3\xA0", "\xC3\xA1", "\xC3\xA2", "\xC3\xA3", "\xC3\xA4", "\xC3\xA5", "\xC3\xA6", "\xC3\xA7", "\xC3\xA8", "\xC3\xA9", "\xC3\xAA", "\xC3\xAB", "\xC3\xAC", "\xC3\xAD", "\xC3\xAE", "\xC3\xAF", "\xC3\xB0", "\xC3\xB1", "\xC3\xB2", "\xC3\xB3", "\xC3\xB4", "\xC3\xB5", "\xC3\xB6", "\xC3\xB7", "\xC3\xB8", "\xC3\xB9", "\xC3\xBA", "\xC3\xBB", "\xC3\xBC", "\xC3\xBD", "\xC3\xBE", "\xC3\xBF")]]></default>
124
- <docblock line="3647">
125
  <description><![CDATA[UTF-8 replacements for invalid SQL characters]]></description>
126
  <long-description><![CDATA[]]></long-description>
127
- <tag line="3647" name="since" description="1.41"/>
128
- <tag line="3647" name="var" description="" type="array">
129
  <type by_reference="false">array</type>
130
  </tag>
131
  </docblock>
132
  </property>
133
- <property final="false" static="true" visibility="private" line="3712" namespace="global" package="Media Library Assistant">
134
  <name>$mla_iptc_records</name>
135
  <default><![CDATA[array("1#000" => "Model Version", "1#005" => "Destination", "1#020" => "File Format", "1#022" => "File Format Version", "1#030" => "Service Identifier", "1#040" => "Envelope Number", "1#050" => "Product ID", "1#060" => "Envelope Priority", "1#070" => "Date Sent", "1#080" => "Time Sent", "1#090" => "Coded Character Set", "1#100" => "UNO", "1#120" => "ARM Identifier", "1#122" => "ARM Version", "2#000" => "Record Version", "2#003" => "Object Type Reference", "2#004" => "Object Attribute Reference", "2#005" => "Object Name", "2#007" => "Edit Status", "2#008" => "Editorial Update", "2#010" => "Urgency", "2#012" => "Subject Reference", "2#015" => "Category", "2#020" => "Supplemental Category", "2#022" => "Fixture Identifier", "2#025" => "Keywords", "2#026" => "Content Location Code", "2#027" => "Content Location Name", "2#030" => "Release Date", "2#035" => "Release Time", "2#037" => "Expiration Date", "2#038" => "Expiration Time", "2#040" => "Special Instructions", "2#042" => "Action Advised", "2#045" => "Reference Service", "2#047" => "Reference Date", "2#050" => "Reference Number", "2#055" => "Date Created", "2#060" => "Time Created", "2#062" => "Digital Creation Date", "2#063" => "Digital Creation Time", "2#065" => "Originating Program", "2#070" => "Program Version", "2#075" => "Object Cycle", "2#080" => "By-line", "2#085" => "By-line Title", "2#090" => "City", "2#092" => "Sub-location", "2#095" => "Province or State", "2#100" => "Country or Primary Location Code", "2#101" => "Country or Primary Location Name", "2#103" => "Original Transmission Reference", "2#105" => "Headline", "2#110" => "Credit", "2#115" => "Source", "2#116" => "Copyright Notice", "2#118" => "Contact", "2#120" => "Caption or Abstract", "2#122" => "Caption Writer or Editor", "2#125" => "Rasterized Caption", "2#130" => "Image Type", "2#131" => "Image Orientation", "2#135" => "Language Identifier", "2#150" => "Audio Type", "2#151" => "Audio Sampling Rate", "2#152" => "Audio Sampling Resolution", "2#153" => "Audio Duration", "2#154" => "Audio Outcue", "2#200" => "ObjectData Preview File Format", "2#201" => "ObjectData Preview File Format Version", "2#202" => "ObjectData Preview Data", "7#010" => "Size Mode", "7#020" => "Max Subfile Size", "7#090" => "ObjectData Size Announced", "7#095" => "Maximum ObjectData Size", "8#010" => "Subfile", "9#010" => "Confirmed ObjectData Size")]]></default>
136
- <docblock line="3702">
137
  <description><![CDATA[IPTC Dataset identifiers and names]]></description>
138
  <long-description><![CDATA[<p>This array contains the identifiers and names of Datasets defined in
139
  the "IPTC-NAA Information Interchange Model Version No. 4.1".</p>]]></long-description>
140
- <tag line="3702" name="since" description="0.90"/>
141
- <tag line="3702" name="var" description="" type="array">
142
  <type by_reference="false">array</type>
143
  </tag>
144
  </docblock>
145
  </property>
146
- <property final="false" static="true" visibility="public" line="3811" namespace="global" package="Media Library Assistant">
147
  <name>$mla_iptc_keys</name>
148
  <default><![CDATA[array('model-version' => '1#000', 'destination' => '1#005', 'file-format' => '1#020', 'file-format-version' => '1#022', 'service-identifier' => '1#030', 'envelope-number' => '1#040', 'product-id' => '1#050', 'envelope-priority' => '1#060', 'date-sent' => '1#070', 'time-sent' => '1#080', 'coded-character-set' => '1#090', 'uno' => '1#100', 'arm-identifier' => '1#120', 'arm-version' => '1#122', 'record-version' => '2#000', 'object-type-reference' => '2#003', 'object-attribute-reference' => '2#004', 'object-name' => '2#005', 'edit-status' => '2#007', 'editorial-update' => '2#008', 'urgency' => '2#010', 'subject-reference' => '2#012', 'category' => '2#015', 'supplemental-category' => '2#020', 'fixture-identifier' => '2#022', 'keywords' => '2#025', 'content-location-code' => '2#026', 'content-location-name' => '2#027', 'release-date' => '2#030', 'release-time' => '2#035', 'expiration-date' => '2#037', 'expiration-time' => '2#038', 'special-instructions' => '2#040', 'action-advised' => '2#042', 'reference-service' => '2#045', 'reference-date' => '2#047', 'reference-number' => '2#050', 'date-created' => '2#055', 'time-created' => '2#060', 'digital-creation-date' => '2#062', 'digital-creation-time' => '2#063', 'originating-program' => '2#065', 'program-version' => '2#070', 'object-cycle' => '2#075', 'by-line' => '2#080', 'by-line-title' => '2#085', 'city' => '2#090', 'sub-location' => '2#092', 'province-or-state' => '2#095', 'country-or-primary-location-code' => '2#100', 'country-or-primary-location-name' => '2#101', 'original-transmission-reference' => '2#103', 'headline' => '2#105', 'credit' => '2#110', 'source' => '2#115', 'copyright-notice' => '2#116', 'contact' => '2#118', 'caption-or-abstract' => '2#120', 'caption-writer-or-editor' => '2#122', 'rasterized-caption' => '2#125', 'image-type' => '2#130', 'image-orientation' => '2#131', 'language-identifier' => '2#135', 'audio-type' => '2#150', 'audio-sampling-rate' => '2#151', 'audio-sampling-resolution' => '2#152', 'audio-duration' => '2#153', 'audio-outcue' => '2#154', 'objectdata-preview-file-format' => '2#200', 'objectdata-preview-file-format-version' => '2#201', 'objectdata-preview-data' => '2#202', 'size-mode' => '7#010', 'max-subfile-size' => '7#020', 'objectdata-size-announced' => '7#090', 'maximum-objectdata-size' => '7#095', 'subfile' => '8#010', 'confirmed-objectdata-size' => '9#010')]]></default>
149
- <docblock line="3801">
150
  <description><![CDATA[IPTC Dataset friendly name/slug and identifiers]]></description>
151
  <long-description><![CDATA[<p>This array contains the sanitized names and identifiers of Datasets defined in
152
  the "IPTC-NAA Information Interchange Model Version No. 4.1".</p>]]></long-description>
153
- <tag line="3801" name="since" description="0.90"/>
154
- <tag line="3801" name="var" description="" type="array">
155
  <type by_reference="false">array</type>
156
  </tag>
157
  </docblock>
158
  </property>
159
- <property final="false" static="true" visibility="private" line="3910" namespace="global" package="Media Library Assistant">
160
  <name>$mla_iptc_descriptions</name>
161
  <default><![CDATA[array("1#000" => "2 octet binary IIM version number", "1#005" => "Max 1024 characters of Destination (ISO routing information); repeatable", "1#020" => "2 octet binary file format number, see IPTC-NAA V4 Appendix A", "1#022" => "2 octet binary file format version number", "1#030" => "Max 10 characters of Service Identifier and product", "1#040" => "8 Character Envelope Number", "1#050" => "Max 32 characters subset of provider's overall service; repeatable", "1#060" => "1 numeric character of envelope handling priority (not urgency)", "1#070" => "8 numeric characters of Date Sent by service - CCYYMMDD", "1#080" => "11 characters of Time Sent by service - HHMMSS±HHMM", "1#090" => "Max 32 characters of control functions, etc.", "1#100" => "14 to 80 characters of eternal, globally unique identification for objects", "1#120" => "2 octet binary Abstract Relationship Model Identifier", "1#122" => "2 octet binary Abstract Relationship Model Version", "2#000" => "2 octet binary Information Interchange Model, Part II version number", "2#003" => "3 to 67 Characters of Object Type Reference number and optional text", "2#004" => "3 to 67 Characters of Object Attribute Reference number and optional text; repeatable", "2#005" => "Max 64 characters of the object name or shorthand reference", "2#007" => "Max 64 characters of the status of the objectdata", "2#008" => "2 numeric characters of the type of update this object provides", "2#010" => "1 numeric character of the editorial urgency of content", "2#012" => "13 to 236 characters of a structured definition of the subject matter; repeatable", "2#015" => "Max 3 characters of the subject of the objectdata, DEPRECATED", "2#020" => "Max 32 characters (each) of further refinement of subject, DEPRECATED; repeatable", "2#022" => "Max 32 characters identifying recurring, predictable content", "2#025" => "Max 64 characters (each) of tags; repeatable", "2#026" => "3 characters of ISO3166 country code or IPTC-assigned code; repeatable", "2#027" => "Max 64 characters of publishable country/geographical location name; repeatable", "2#030" => "8 numeric characters of Release Date - CCYYMMDD", "2#035" => "11 characters of Release Time (earliest use) - HHMMSS±HHMM", "2#037" => "8 numeric characters of Expiration Date (latest use) - CCYYMDD", "2#038" => "11 characters of Expiration Time (latest use) - HHMMSS±HHMM", "2#040" => "Max 256 Characters of editorial instructions, e.g., embargoes and warnings", "2#042" => "2 numeric characters of type of action this object provides to a previous object", "2#045" => "Max 10 characters of the Service ID (1#030) of a prior envelope; repeatable", "2#047" => "8 numeric characters of prior envelope Reference Date (1#070) - CCYYMMDD; repeatable", "2#050" => "8 characters of prior envelope Reference Number (1#040); repeatable", "2#055" => "8 numeric characters of intellectual content Date Created - CCYYMMDD", "2#060" => "11 characters of intellectual content Time Created - HHMMSS±HHMM", "2#062" => "8 numeric characters of digital representation creation date - CCYYMMDD", "2#063" => "11 characters of digital representation creation time - HHMMSS±HHMM", "2#065" => "Max 32 characters of the program used to create the objectdata", "2#070" => "Program Version - Max 10 characters of the version of the program used to create the objectdata", "2#075" => "1 character where a=morning, p=evening, b=both", "2#080" => "Max 32 Characters of the name of the objectdata creator, e.g., the writer, photographer; repeatable", "2#085" => "Max 32 characters of the title of the objectdata creator; repeatable", "2#090" => "Max 32 Characters of the city of objectdata origin", "2#092" => "Max 32 Characters of the location within the city of objectdata origin", "2#095" => "Max 32 Characters of the objectdata origin Province or State", "2#100" => "3 characters of ISO3166 or IPTC-assigned code for Country of objectdata origin", "2#101" => "Max 64 characters of publishable country/geographical location name of objectdata origin", "2#103" => "Max 32 characters of a code representing the location of original transmission", "2#105" => "Max 256 Characters of a publishable entry providing a synopsis of the contents of the objectdata", "2#110" => "Max 32 Characters that identifies the provider of the objectdata (Vs the owner/creator)", "2#115" => "Max 32 Characters that identifies the original owner of the intellectual content", "2#116" => "Max 128 Characters that contains any necessary copyright notice", "2#118" => "Max 128 characters that identifies the person or organisation which can provide further background information; repeatable", "2#120" => "Max 2000 Characters of a textual description of the objectdata", "2#122" => "Max 32 Characters that the identifies the person involved in the writing, editing or correcting the objectdata or caption/abstract; repeatable", "2#125" => "7360 binary octets of the rasterized caption - 1 bit per pixel, 460x128-pixel image", "2#130" => "2 characters of color composition type and information", "2#131" => "1 alphabetic character indicating the image area layout - P=portrait, L=landscape, S=square", "2#135" => "2 or 3 aphabetic characters containing the major national language of the object, according to the ISO 639:1988 codes", "2#150" => "2 characters identifying monaural/stereo and exact type of audio content", "2#151" => "6 numeric characters representing the audio sampling rate in hertz (Hz)", "2#152" => "2 numeric characters representing the number of bits in each audio sample", "2#153" => "6 numeric characters of the Audio Duration - HHMMSS", "2#154" => "Max 64 characters of the content of the end of an audio objectdata", "2#200" => "2 octet binary file format of the ObjectData Preview", "2#201" => "2 octet binary particular version of the ObjectData Preview File Format", "2#202" => "Max 256000 binary octets containing the ObjectData Preview data", "7#010" => "1 numeric character - 0=objectdata size not known, 1=objectdata size known at beginning of transfer", "7#020" => "4 octet binary maximum subfile dataset(s) size", "7#090" => "4 octet binary objectdata size if known at beginning of transfer", "7#095" => "4 octet binary largest possible objectdata size", "8#010" => "Subfile DataSet containing the objectdata itself; repeatable", "9#010" => "4 octet binary total objectdata size")]]></default>
162
- <docblock line="3900">
163
  <description><![CDATA[IPTC Dataset descriptions]]></description>
164
  <long-description><![CDATA[<p>This array contains the descriptions of Datasets defined in
165
  the "IPTC-NAA Information Interchange Model Version No. 4.1".</p>]]></long-description>
166
- <tag line="3900" name="since" description="0.90"/>
167
- <tag line="3900" name="var" description="" type="array">
168
  <type by_reference="false">array</type>
169
  </tag>
170
  </docblock>
171
  </property>
172
- <property final="false" static="true" visibility="private" line="4009" namespace="global" package="Media Library Assistant">
173
  <name>$mla_iptc_formats</name>
174
  <default><![CDATA[array(0 => "No ObjectData", 1 => "IPTC-NAA Digital Newsphoto Parameter Record", 2 => "IPTC7901 Recommended Message Format", 3 => "Tagged Image File Format (Adobe/Aldus Image data)", 4 => "Illustrator (Adobe Graphics data)", 5 => "AppleSingle (Apple Computer Inc)", 6 => "NAA 89-3 (ANPA 1312)", 7 => "MacBinary II", 0 => "IPTC Unstructured Character Oriented File Format (UCOFF)", 0 => "United Press International ANPA 1312 variant", 10 => "United Press International Down-Load Message", 11 => "JPEG File Interchange (JFIF)", 12 => "Photo-CD Image-Pac (Eastman Kodak)", 13 => "Microsoft Bit Mapped Graphics File [*.BMP]", 14 => "Digital Audio File [*.WAV] (Microsoft & Creative Labs)", 15 => "Audio plus Moving Video [*.AVI] (Microsoft)", 16 => "PC DOS/Windows Executable Files [*.COM][*.EXE]", 17 => "Compressed Binary File [*.ZIP] (PKWare Inc)", 18 => "Audio Interchange File Format AIFF (Apple Computer Inc)", 19 => "RIFF Wave (Microsoft Corporation)", 20 => "Freehand (Macromedia/Aldus)", 21 => "Hypertext Markup Language - HTML (The Internet Society)", 22 => "MPEG 2 Audio Layer 2 (Musicom), ISO/IEC", 23 => "MPEG 2 Audio Layer 3, ISO/IEC", 24 => "Portable Document File (*.PDF) Adobe", 25 => "News Industry Text Format (NITF)", 26 => "Tape Archive (*.TAR)", 27 => "Tidningarnas Telegrambyrå NITF version (TTNITF DTD)", 28 => "Ritzaus Bureau NITF version (RBNITF DTD)", 29 => "Corel Draw [*.CDR]")]]></default>
175
- <docblock line="3999">
176
  <description><![CDATA[IPTC file format identifiers and descriptions]]></description>
177
  <long-description><![CDATA[<p>This array contains the file format identifiers and descriptions defined in
178
  the "IPTC-NAA Information Interchange Model Version No. 4.1" for dataset 1#020.</p>]]></long-description>
179
- <tag line="3999" name="since" description="0.90"/>
180
- <tag line="3999" name="var" description="" type="array">
181
  <type by_reference="false">array</type>
182
  </tag>
183
  </docblock>
184
  </property>
185
- <property final="false" static="true" visibility="private" line="4052" namespace="global" package="Media Library Assistant">
186
  <name>$mla_iptc_image_types</name>
187
  <default><![CDATA[array("M" => "Monochrome", "Y" => "Yellow Component", "M" => "Magenta Component", "C" => "Cyan Component", "K" => "Black Component", "R" => "Red Component", "G" => "Green Component", "B" => "Blue Component", "T" => "Text Only", "F" => "Full colour composite, frame sequential", "L" => "Full colour composite, line sequential", "P" => "Full colour composite, pixel sequential", "S" => "Full colour composite, special interleaving")]]></default>
188
- <docblock line="4042">
189
  <description><![CDATA[IPTC image type identifiers and descriptions]]></description>
190
  <long-description><![CDATA[<p>This array contains the image type identifiers and descriptions defined in
191
  the "IPTC-NAA Information Interchange Model Version No. 4.1" for dataset 2#130, octet 2.</p>]]></long-description>
192
- <tag line="4042" name="since" description="0.90"/>
193
- <tag line="4042" name="var" description="" type="array">
194
  <type by_reference="false">array</type>
195
  </tag>
196
  </docblock>
197
  </property>
198
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="40" package="Media Library Assistant">
199
  <name>initialize</name>
200
  <full_name>initialize</full_name>
201
- <docblock line="35">
202
  <description><![CDATA[Initialization function, similar to __construct()]]></description>
203
  <long-description><![CDATA[]]></long-description>
204
- <tag line="35" name="since" description="0.1"/>
205
  </docblock>
206
  </method>
207
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="67" package="Media Library Assistant">
208
  <name>mla_load_template</name>
209
  <full_name>mla_load_template</full_name>
210
- <docblock line="49">
211
  <description><![CDATA[Load an HTML template from a file]]></description>
212
  <long-description><![CDATA[<p>Loads a template to a string or a multi-part template to an array.
213
  Multi-part templates are divided by comments of the form <!-- template="key" -->,
214
  where "key" becomes the key part of the array.</p>]]></long-description>
215
- <tag line="49" name="since" description="0.1"/>
216
- <tag line="49" name="param" description="Complete path and name of the template file, option name or the raw template" type="string" variable="$source">
217
  <type by_reference="false">string</type>
218
  </tag>
219
- <tag line="49" name="param" description="Optional type of template source; 'file' (default), 'option', 'string'" type="string" variable="$type">
220
  <type by_reference="false">string</type>
221
  </tag>
222
- <tag line="49" name="return" description="string for files that do not contain template divider comments, array for files containing template divider comments, false if file or option does not exist, NULL if file could not be loaded." type="string|array|false|NULL">
223
  <type by_reference="false">string</type>
224
  <type by_reference="false">array</type>
225
  <type by_reference="false">false</type>
226
  <type by_reference="false">NULL</type>
227
  </tag>
228
  </docblock>
229
- <argument line="67">
230
  <name>$source</name>
231
  <default><![CDATA[]]></default>
232
  <type/>
233
  </argument>
234
- <argument line="67">
235
  <name>$type</name>
236
  <default><![CDATA['file']]></default>
237
  <type/>
238
  </argument>
239
  </method>
240
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="159" package="Media Library Assistant">
241
  <name>_find_template_substring</name>
242
  <full_name>_find_template_substring</full_name>
243
- <docblock line="150">
244
  <description><![CDATA[Find a complete template, balancing opening and closing delimiters]]></description>
245
  <long-description><![CDATA[]]></long-description>
246
- <tag line="150" name="since" description="1.50"/>
247
- <tag line="150" name="param" description="A string possibly starting with '[+template:'" type="string" variable="$tpl">
248
  <type by_reference="false">string</type>
249
  </tag>
250
- <tag line="150" name="return" description="'' or template string starting with '[+template:' and ending with the matching '+]'" type="string">
251
  <type by_reference="false">string</type>
252
  </tag>
253
  </docblock>
254
- <argument line="159">
255
  <name>$tpl</name>
256
  <default><![CDATA[]]></default>
257
  <type/>
258
  </argument>
259
  </method>
260
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="206" package="Media Library Assistant">
261
  <name>mla_parse_array_template</name>
262
  <full_name>mla_parse_array_template</full_name>
263
- <docblock line="194">
264
  <description><![CDATA[Expand a template, replacing placeholders with their values]]></description>
265
  <long-description><![CDATA[<p>Will return an array of values if one or more of the placeholders returns an array.</p>]]></long-description>
266
- <tag line="194" name="since" description="1.50"/>
267
- <tag line="194" name="param" description="A formatting string containing [+placeholders+]" type="string" variable="$tpl">
268
  <type by_reference="false">string</type>
269
  </tag>
270
- <tag line="194" name="param" description="An associative array containing keys and values e.g. array('key' =&gt; 'value')" type="array" variable="$markup_values">
271
  <type by_reference="false">array</type>
272
  </tag>
273
- <tag line="194" name="return" description="string or array, depending on placeholder values. Placeholders corresponding to the keys of the markup_values will be replaced with their values." type="mixed">
274
  <type by_reference="false">mixed</type>
275
  </tag>
276
  </docblock>
277
- <argument line="206">
278
  <name>$tpl</name>
279
  <default><![CDATA[]]></default>
280
  <type/>
281
  </argument>
282
- <argument line="206">
283
  <name>$markup_values</name>
284
  <default><![CDATA[]]></default>
285
  <type/>
286
  </argument>
287
  </method>
288
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="293" package="Media Library Assistant">
289
  <name>mla_parse_template</name>
290
  <full_name>mla_parse_template</full_name>
291
- <docblock line="281">
292
  <description><![CDATA[Expand a template, replacing placeholders with their values]]></description>
293
  <long-description><![CDATA[<p>A simple parsing function for basic templating.</p>]]></long-description>
294
- <tag line="281" name="since" description="0.1"/>
295
- <tag line="281" name="param" description="A formatting string containing [+placeholders+]" type="string" variable="$tpl">
296
  <type by_reference="false">string</type>
297
  </tag>
298
- <tag line="281" name="param" description="An associative array containing keys and values e.g. array('key' =&gt; 'value')" type="array" variable="$markup_values">
299
  <type by_reference="false">array</type>
300
  </tag>
301
- <tag line="281" name="return" description="Placeholders corresponding to the keys of the markup_values will be replaced with their values." type="\strng">
302
  <type by_reference="false">\strng</type>
303
  </tag>
304
  </docblock>
305
- <argument line="293">
306
  <name>$tpl</name>
307
  <default><![CDATA[]]></default>
308
  <type/>
309
  </argument>
310
- <argument line="293">
311
  <name>$markup_values</name>
312
  <default><![CDATA[]]></default>
313
  <type/>
314
  </argument>
315
  </method>
316
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="344" package="Media Library Assistant">
317
  <name>_find_test_substring</name>
318
  <full_name>_find_test_substring</full_name>
319
- <docblock line="335">
320
  <description><![CDATA[Find a complete (test) element, balancing opening and closing delimiters]]></description>
321
  <long-description><![CDATA[]]></long-description>
322
- <tag line="335" name="since" description="1.50"/>
323
- <tag line="335" name="param" description="A string possibly starting with '('" type="string" variable="$tpl">
324
  <type by_reference="false">string</type>
325
  </tag>
326
- <tag line="335" name="return" description="'' or template string starting with '(' and ending with the matching ')'" type="string">
327
  <type by_reference="false">string</type>
328
  </tag>
329
  </docblock>
330
- <argument line="344">
331
  <name>$tpl</name>
332
  <default><![CDATA[]]></default>
333
  <type/>
334
  </argument>
335
  </method>
336
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="387" package="Media Library Assistant">
337
  <name>_parse_field_level_template</name>
338
  <full_name>_parse_field_level_template</full_name>
339
- <docblock line="378">
340
  <description><![CDATA[Convert field-level "template:" string into its component parts]]></description>
341
  <long-description><![CDATA[]]></long-description>
342
- <tag line="378" name="since" description="1.50"/>
343
- <tag line="378" name="param" description="Template content with string, test and choice elements" type="string" variable="$tpl">
344
  <type by_reference="false">string</type>
345
  </tag>
346
- <tag line="378" name="return" description="( node =&gt; array( type =&gt; &quot;string | test | choice | template&quot;, length =&gt; bytes, value =&gt; string | node(s) ) )" type="array">
347
  <type by_reference="false">array</type>
348
  </tag>
349
  </docblock>
350
- <argument line="387">
351
  <name>$tpl</name>
352
  <default><![CDATA[]]></default>
353
  <type/>
354
  </argument>
355
  </method>
356
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="531" package="Media Library Assistant">
357
  <name>_evaluate_template_array_node</name>
358
  <full_name>_evaluate_template_array_node</full_name>
359
- <docblock line="519">
360
  <description><![CDATA[Analyze a field-level "template:" element, expanding Field-level Markup Substitution Parameters]]></description>
361
  <long-description><![CDATA[<p>Will return an array of values if one or more of the placeholders returns an array.</p>]]></long-description>
362
- <tag line="519" name="since" description="1.50"/>
363
- <tag line="519" name="param" description="A field-level template element node" type="array" variable="$node">
364
  <type by_reference="false">array</type>
365
  </tag>
366
- <tag line="519" name="param" description="An array of markup substitution values" type="array" variable="$markup_values">
367
  <type by_reference="false">array</type>
368
  </tag>
369
- <tag line="519" name="return" description="string or array, depending on placeholder values. Placeholders corresponding to the keys of the markup_values will be replaced with their values." type="mixed">
370
  <type by_reference="false">mixed</type>
371
  </tag>
372
  </docblock>
373
- <argument line="531">
374
  <name>$node</name>
375
  <default><![CDATA[]]></default>
376
  <type/>
377
  </argument>
378
- <argument line="531">
379
  <name>$markup_values</name>
380
  <default><![CDATA[array()]]></default>
381
  <type/>
382
  </argument>
383
  </method>
384
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="615" package="Media Library Assistant">
385
  <name>_evaluate_template_node</name>
386
  <full_name>_evaluate_template_node</full_name>
387
- <docblock line="605">
388
  <description><![CDATA[Analyze a field-level "template:" element, expanding Field-level Markup Substitution Parameters]]></description>
389
  <long-description><![CDATA[]]></long-description>
390
- <tag line="605" name="since" description="1.50"/>
391
- <tag line="605" name="param" description="A field-level template element node" type="array" variable="$node">
392
  <type by_reference="false">array</type>
393
  </tag>
394
- <tag line="605" name="param" description="An array of markup substitution values" type="array" variable="$markup_values">
395
  <type by_reference="false">array</type>
396
  </tag>
397
- <tag line="605" name="return" description="String with expanded values, if any" type="string">
398
  <type by_reference="false">string</type>
399
  </tag>
400
  </docblock>
401
- <argument line="615">
402
  <name>$node</name>
403
  <default><![CDATA[]]></default>
404
  <type/>
405
  </argument>
406
- <argument line="615">
407
  <name>$markup_values</name>
408
  <default><![CDATA[array()]]></default>
409
  <type/>
410
  </argument>
411
  </method>
412
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="677" package="Media Library Assistant">
413
  <name>_expand_field_level_template</name>
414
  <full_name>_expand_field_level_template</full_name>
415
- <docblock line="666">
416
  <description><![CDATA[Analyze a field-level "template:" element, expanding Field-level Markup Substitution Parameters]]></description>
417
  <long-description><![CDATA[]]></long-description>
418
- <tag line="666" name="since" description="1.50"/>
419
- <tag line="666" name="param" description="A formatting string containing [+placeholders+]" type="string" variable="$tpl">
420
  <type by_reference="false">string</type>
421
  </tag>
422
- <tag line="666" name="param" description="An array of markup substitution values" type="array" variable="$markup_values">
423
  <type by_reference="false">array</type>
424
  </tag>
425
- <tag line="666" name="param" description="True to return array value(s), false to return a string" type="boolean" variable="$return_arrays">
426
  <type by_reference="false">boolean</type>
427
  </tag>
428
- <tag line="666" name="return" description="Element with expanded string/array values, if any" type="mixed">
429
  <type by_reference="false">mixed</type>
430
  </tag>
431
  </docblock>
432
- <argument line="677">
433
  <name>$tpl</name>
434
  <default><![CDATA[]]></default>
435
  <type/>
436
  </argument>
437
- <argument line="677">
438
  <name>$markup_values</name>
439
  <default><![CDATA[array()]]></default>
440
  <type/>
441
  </argument>
442
- <argument line="677">
443
  <name>$return_arrays</name>
444
  <default><![CDATA[false]]></default>
445
  <type/>
446
  </argument>
447
  </method>
448
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="719" package="Media Library Assistant">
449
  <name>_process_field_level_array</name>
450
  <full_name>_process_field_level_array</full_name>
451
- <docblock line="708">
452
  <description><![CDATA[Process an markup field array value according to the supplied data-format option]]></description>
453
  <long-description><![CDATA[]]></long-description>
454
- <tag line="708" name="since" description="1.50"/>
455
- <tag line="708" name="param" description="an array of scalar values" type="array" variable="$record">
456
  <type by_reference="false">array</type>
457
  </tag>
458
- <tag line="708" name="param" description="data option 'text'|'single'|'export'|'array'|'multi'" type="string" variable="$option">
459
  <type by_reference="false">string</type>
460
  </tag>
461
- <tag line="708" name="param" description="Optional: for option 'multi', retain existing values" type="boolean" variable="$keep_existing">
462
  <type by_reference="false">boolean</type>
463
  </tag>
464
- <tag line="708" name="return" description="( parameter =&gt; value ) for all field-level parameters and anything in $markup_values" type="array">
465
  <type by_reference="false">array</type>
466
  </tag>
467
  </docblock>
468
- <argument line="719">
469
  <name>$record</name>
470
  <default><![CDATA[]]></default>
471
  <type/>
472
  </argument>
473
- <argument line="719">
474
  <name>$option</name>
475
  <default><![CDATA['text']]></default>
476
  <type/>
477
  </argument>
478
- <argument line="719">
479
  <name>$keep_existing</name>
480
  <default><![CDATA[false]]></default>
481
  <type/>
482
  </argument>
483
  </method>
484
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="763" package="Media Library Assistant">
485
  <name>mla_expand_field_level_parameters</name>
486
  <full_name>mla_expand_field_level_parameters</full_name>
487
- <docblock line="745">
488
  <description><![CDATA[Analyze a template, expanding Field-level Markup Substitution Parameters]]></description>
489
  <long-description><![CDATA[<p>Field-level parameters must have one of the following prefix values:
490
  template, request, query, custom, terms, meta, iptc, exif, pdf.
491
  All but request and query require an attachment ID.</p>]]></long-description>
492
- <tag line="745" name="since" description="1.50"/>
493
- <tag line="745" name="param" description="A formatting string containing [+placeholders+]" type="string" variable="$tpl">
494
  <type by_reference="false">string</type>
495
  </tag>
496
- <tag line="745" name="param" description="Optional: an array of values from the query, if any, e.g. shortcode parameters" type="array" variable="$query">
497
  <type by_reference="false">array</type>
498
  </tag>
499
- <tag line="745" name="param" description="Optional: an array of values to add to the returned array" type="array" variable="$markup_values">
500
  <type by_reference="false">array</type>
501
  </tag>
502
- <tag line="745" name="param" description="Optional: attachment ID for attachment-specific placeholders" type="integer" variable="$post_id">
503
  <type by_reference="false">integer</type>
504
  </tag>
505
- <tag line="745" name="param" description="Optional: for option 'multi', retain existing values" type="boolean" variable="$keep_existing">
506
  <type by_reference="false">boolean</type>
507
  </tag>
508
- <tag line="745" name="param" description="Optional: default option value" type="string" variable="$default_option">
509
  <type by_reference="false">string</type>
510
  </tag>
511
- <tag line="745" name="return" description="( parameter =&gt; value ) for all field-level parameters and anything in $markup_values" type="array">
512
  <type by_reference="false">array</type>
513
  </tag>
514
  </docblock>
515
- <argument line="763">
516
  <name>$tpl</name>
517
  <default><![CDATA[]]></default>
518
  <type/>
519
  </argument>
520
- <argument line="763">
521
  <name>$query</name>
522
  <default><![CDATA[NULL]]></default>
523
  <type/>
524
  </argument>
525
- <argument line="763">
526
  <name>$markup_values</name>
527
  <default><![CDATA[array()]]></default>
528
  <type/>
529
  </argument>
530
- <argument line="763">
531
  <name>$post_id</name>
532
  <default><![CDATA[0]]></default>
533
  <type/>
534
  </argument>
535
- <argument line="763">
536
  <name>$keep_existing</name>
537
  <default><![CDATA[false]]></default>
538
  <type/>
539
  </argument>
540
- <argument line="763">
541
  <name>$default_option</name>
542
  <default><![CDATA['text']]></default>
543
  <type/>
544
  </argument>
545
  </method>
546
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="962" package="Media Library Assistant">
547
  <name>mla_get_template_placeholders</name>
548
  <full_name>mla_get_template_placeholders</full_name>
549
- <docblock line="951">
550
  <description><![CDATA[Analyze a template, returning an array of the placeholders it contains]]></description>
551
  <long-description><![CDATA[]]></long-description>
552
- <tag line="951" name="since" description="0.90"/>
553
- <tag line="951" name="param" description="A formatting string containing [+placeholders+]" type="string" variable="$tpl">
554
  <type by_reference="false">string</type>
555
  </tag>
556
- <tag line="951" name="param" description="Optional: default option value" type="string" variable="$default_option">
557
  <type by_reference="false">string</type>
558
  </tag>
559
- <tag line="951" name="return" description="Placeholder information: each entry is an array with ['prefix'] =&gt; string, ['value'] =&gt; string, ['option'] =&gt; string 'text'|single'|'export'|'array'|'multi'" type="array">
560
  <type by_reference="false">array</type>
561
  </tag>
562
  </docblock>
563
- <argument line="962">
564
  <name>$tpl</name>
565
  <default><![CDATA[]]></default>
566
  <type/>
567
  </argument>
568
- <argument line="962">
569
  <name>$default_option</name>
570
  <default><![CDATA['text']]></default>
571
  <type/>
572
  </argument>
573
  </method>
574
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1054" package="Media Library Assistant">
575
  <name>mla_count_list_table_items</name>
576
  <full_name>mla_count_list_table_items</full_name>
577
- <docblock line="1043">
578
  <description><![CDATA[Get the total number of attachment posts]]></description>
579
  <long-description><![CDATA[]]></long-description>
580
- <tag line="1043" name="since" description="0.30"/>
581
- <tag line="1043" name="param" description="Query variables, e.g., from $_REQUEST" type="array" variable="$request">
582
  <type by_reference="false">array</type>
583
  </tag>
584
- <tag line="1043" name="param" description="(optional) number of rows to skip over to reach desired page" type="int" variable="$offset">
585
  <type by_reference="false">int</type>
586
  </tag>
587
- <tag line="1043" name="param" description="(optional) number of rows on each page" type="int" variable="$count">
588
  <type by_reference="false">int</type>
589
  </tag>
590
- <tag line="1043" name="return" description="Number of attachment posts" type="integer">
591
  <type by_reference="false">integer</type>
592
  </tag>
593
  </docblock>
594
- <argument line="1054">
595
  <name>$request</name>
596
  <default><![CDATA[]]></default>
597
  <type/>
598
  </argument>
599
- <argument line="1054">
600
  <name>$offset</name>
601
  <default><![CDATA[NULL]]></default>
602
  <type/>
603
  </argument>
604
- <argument line="1054">
605
  <name>$count</name>
606
  <default><![CDATA[NULL]]></default>
607
  <type/>
608
  </argument>
609
  </method>
610
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1083" package="Media Library Assistant">
611
  <name>mla_query_list_table_items</name>
612
  <full_name>mla_query_list_table_items</full_name>
613
- <docblock line="1069">
614
  <description><![CDATA[Retrieve attachment objects for list table display]]></description>
615
  <long-description><![CDATA[<p>Supports prepare_items in class-mla-list-table.php.
616
  Modeled after wp_edit_attachments_query in wp-admin/post.php</p>]]></long-description>
617
- <tag line="1069" name="since" description="0.1"/>
618
- <tag line="1069" name="param" description="query parameters from web page, usually found in $_REQUEST" type="array" variable="$request">
619
  <type by_reference="false">array</type>
620
  </tag>
621
- <tag line="1069" name="param" description="number of rows to skip over to reach desired page" type="int" variable="$offset">
622
  <type by_reference="false">int</type>
623
  </tag>
624
- <tag line="1069" name="param" description="number of rows on each page" type="int" variable="$count">
625
  <type by_reference="false">int</type>
626
  </tag>
627
- <tag line="1069" name="return" description="attachment objects (posts) including parent data, meta data and references" type="array">
628
  <type by_reference="false">array</type>
629
  </tag>
630
  </docblock>
631
- <argument line="1083">
632
  <name>$request</name>
633
  <default><![CDATA[]]></default>
634
  <type/>
635
  </argument>
636
- <argument line="1083">
637
  <name>$offset</name>
638
  <default><![CDATA[]]></default>
639
  <type/>
640
  </argument>
641
- <argument line="1083">
642
  <name>$count</name>
643
  <default><![CDATA[]]></default>
644
  <type/>
645
  </argument>
646
  </method>
647
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1129" package="Media Library Assistant">
648
  <name>mla_query_media_modal_items</name>
649
  <full_name>mla_query_media_modal_items</full_name>
650
- <docblock line="1116">
651
  <description><![CDATA[Retrieve attachment objects for the WordPress Media Manager]]></description>
652
  <long-description><![CDATA[<p>Supports month-year and taxonomy-term filters as well as the enhanced search box</p>]]></long-description>
653
- <tag line="1116" name="since" description="1.20"/>
654
- <tag line="1116" name="param" description="query parameters from Media Manager" type="array" variable="$request">
655
  <type by_reference="false">array</type>
656
  </tag>
657
- <tag line="1116" name="param" description="number of rows to skip over to reach desired page" type="int" variable="$offset">
658
  <type by_reference="false">int</type>
659
  </tag>
660
- <tag line="1116" name="param" description="number of rows on each page" type="int" variable="$count">
661
  <type by_reference="false">int</type>
662
  </tag>
663
- <tag line="1116" name="return" description="attachment objects (posts)" type="array">
664
  <type by_reference="false">array</type>
665
  </tag>
666
  </docblock>
667
- <argument line="1129">
668
  <name>$request</name>
669
  <default><![CDATA[]]></default>
670
  <type/>
671
  </argument>
672
- <argument line="1129">
673
  <name>$offset</name>
674
  <default><![CDATA[]]></default>
675
  <type/>
676
  </argument>
677
- <argument line="1129">
678
  <name>$count</name>
679
  <default><![CDATA[]]></default>
680
  <type/>
681
  </argument>
682
  </method>
683
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="1163" package="Media Library Assistant">
684
  <name>_prepare_list_table_query</name>
685
  <full_name>_prepare_list_table_query</full_name>
686
- <docblock line="1149">
687
  <description><![CDATA[Sanitize and expand query arguments from request variables]]></description>
688
  <long-description><![CDATA[<p>Prepare the arguments for WP_Query.
689
  Modeled after wp_edit_attachments_query in wp-admin/post.php</p>]]></long-description>
690
- <tag line="1149" name="since" description="0.1"/>
691
- <tag line="1149" name="param" description="query parameters from web page, usually found in $_REQUEST" type="array" variable="$raw_request">
692
  <type by_reference="false">array</type>
693
  </tag>
694
- <tag line="1149" name="param" description="Optional number of rows (default 0) to skip over to reach desired page" type="int" variable="$offset">
695
  <type by_reference="false">int</type>
696
  </tag>
697
- <tag line="1149" name="param" description="Optional number of rows on each page (0 = all rows, default)" type="int" variable="$count">
698
  <type by_reference="false">int</type>
699
  </tag>
700
- <tag line="1149" name="return" description="revised arguments suitable for WP_Query" type="array">
701
  <type by_reference="false">array</type>
702
  </tag>
703
  </docblock>
704
- <argument line="1163">
705
  <name>$raw_request</name>
706
  <default><![CDATA[]]></default>
707
  <type/>
708
  </argument>
709
- <argument line="1163">
710
  <name>$offset</name>
711
  <default><![CDATA[0]]></default>
712
  <type/>
713
  </argument>
714
- <argument line="1163">
715
  <name>$count</name>
716
  <default><![CDATA[0]]></default>
717
  <type/>
718
  </argument>
719
  </method>
720
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="1490" package="Media Library Assistant">
721
  <name>_execute_list_table_query</name>
722
  <full_name>_execute_list_table_query</full_name>
723
- <docblock line="1481">
724
  <description><![CDATA[Add filters, run query, remove filters]]></description>
725
  <long-description><![CDATA[]]></long-description>
726
- <tag line="1481" name="since" description="0.30"/>
727
- <tag line="1481" name="param" description="query parameters from web page, usually found in $_REQUEST" type="array" variable="$request">
728
  <type by_reference="false">array</type>
729
  </tag>
730
- <tag line="1481" name="return" description="WP_Query object with query results" type="object">
731
  <type by_reference="false">object</type>
732
  </tag>
733
  </docblock>
734
- <argument line="1490">
735
  <name>$request</name>
736
  <default><![CDATA[]]></default>
737
  <type/>
738
  </argument>
739
  </method>
740
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1566" package="Media Library Assistant">
741
  <name>mla_search_terms_tidy</name>
742
  <full_name>mla_search_terms_tidy</full_name>
743
- <docblock line="1555">
744
  <description><![CDATA[Replaces a WordPress function deprecated in v3.7]]></description>
745
  <long-description><![CDATA[<p>Defined as public because it's a callback from array_map().</p>]]></long-description>
746
- <tag line="1555" name="since" description="1.51"/>
747
- <tag line="1555" name="param" description="search term before modification" type="string" variable="$term">
748
  <type by_reference="false">string</type>
749
  </tag>
750
- <tag line="1555" name="return" description="cleaned up search term" type="string">
751
  <type by_reference="false">string</type>
752
  </tag>
753
  </docblock>
754
- <argument line="1566">
755
  <name>$term</name>
756
  <default><![CDATA[]]></default>
757
  <type/>
758
  </argument>
759
  </method>
760
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1582" package="Media Library Assistant">
761
  <name>mla_query_posts_search_filter</name>
762
  <full_name>mla_query_posts_search_filter</full_name>
763
- <docblock line="1570">
764
  <description><![CDATA[Adds a keyword search to the WHERE clause, if required]]></description>
765
  <long-description><![CDATA[<p>Defined as public because it's a filter.</p>]]></long-description>
766
- <tag line="1570" name="since" description="0.60"/>
767
- <tag line="1570" name="param" description="query clause before modification" type="string" variable="$search_string">
768
  <type by_reference="false">string</type>
769
  </tag>
770
- <tag line="1570" name="param" description="WP_Query object" type="object" variable="$query_object">
771
  <type by_reference="false">object</type>
772
  </tag>
773
- <tag line="1570" name="return" description="query clause after keyword search addition" type="string">
774
  <type by_reference="false">string</type>
775
  </tag>
776
  </docblock>
777
- <argument line="1582">
778
  <name>$search_string</name>
779
  <default><![CDATA[]]></default>
780
  <type/>
781
  </argument>
782
- <argument line="1582">
783
  <name>$query_object</name>
784
  <default><![CDATA[]]></default>
785
  <type/>
786
  </argument>
787
  </method>
788
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1697" package="Media Library Assistant">
789
  <name>mla_query_posts_join_filter</name>
790
  <full_name>mla_query_posts_join_filter</full_name>
791
- <docblock line="1686">
792
  <description><![CDATA[Adds a JOIN clause, if required, to handle sorting/searching on custom fields or ALT Text]]></description>
793
  <long-description><![CDATA[<p>Defined as public because it's a filter.</p>]]></long-description>
794
- <tag line="1686" name="since" description="0.30"/>
795
- <tag line="1686" name="param" description="query clause before modification" type="string" variable="$join_clause">
796
  <type by_reference="false">string</type>
797
  </tag>
798
- <tag line="1686" name="return" description="query clause after &quot;LEFT JOIN view ON post_id&quot; item modification" type="string">
799
  <type by_reference="false">string</type>
800
  </tag>
801
  </docblock>
802
- <argument line="1697">
803
  <name>$join_clause</name>
804
  <default><![CDATA[]]></default>
805
  <type/>
806
  </argument>
807
  </method>
808
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1724" package="Media Library Assistant">
809
  <name>mla_query_posts_where_filter</name>
810
  <full_name>mla_query_posts_where_filter</full_name>
811
- <docblock line="1712">
812
  <description><![CDATA[Adds a WHERE clause for detached items]]></description>
813
  <long-description><![CDATA[<p>Modeled after _edit_attachments_query_helper in wp-admin/post.php.
814
  Defined as public because it's a filter.</p>]]></long-description>
815
- <tag line="1712" name="since" description="0.1"/>
816
- <tag line="1712" name="param" description="query clause before modification" type="string" variable="$where_clause">
817
  <type by_reference="false">string</type>
818
  </tag>
819
- <tag line="1712" name="return" description="query clause after &quot;detached&quot; item modification" type="string">
820
  <type by_reference="false">string</type>
821
  </tag>
822
  </docblock>
823
- <argument line="1724">
824
  <name>$where_clause</name>
825
  <default><![CDATA[]]></default>
826
  <type/>
827
  </argument>
828
  </method>
829
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1772" package="Media Library Assistant">
830
  <name>mla_query_posts_orderby_filter</name>
831
  <full_name>mla_query_posts_orderby_filter</full_name>
832
- <docblock line="1760">
833
  <description><![CDATA[Adds a ORDERBY clause, if required]]></description>
834
  <long-description><![CDATA[<p>Expands the range of sort options because the logic in WP_Query is limited.
835
  Defined as public because it's a filter.</p>]]></long-description>
836
- <tag line="1760" name="since" description="0.30"/>
837
- <tag line="1760" name="param" description="query clause before modification" type="string" variable="$orderby_clause">
838
  <type by_reference="false">string</type>
839
  </tag>
840
- <tag line="1760" name="return" description="updated query clause" type="string">
841
  <type by_reference="false">string</type>
842
  </tag>
843
  </docblock>
844
- <argument line="1772">
845
  <name>$orderby_clause</name>
846
  <default><![CDATA[]]></default>
847
  <type/>
848
  </argument>
849
  </method>
850
- <method final="false" abstract="false" static="false" visibility="public" namespace="global" line="1831" package="Media Library Assistant">
851
  <name>mla_get_attachment_by_id</name>
852
  <full_name>mla_get_attachment_by_id</full_name>
853
- <docblock line="1819">
854
  <description><![CDATA[Retrieve an Attachment array given a $post_id]]></description>
855
  <long-description><![CDATA[<p>The (associative) array will contain every field that can be found in
856
  the posts and postmeta tables, and all references to the attachment.</p>]]></long-description>
857
- <tag line="1819" name="since" description="0.1"/>
858
- <tag line="1819" name="uses" description="\global\$post" refers="\global\$post"/>
859
- <tag line="1819" name="param" description="The ID of the attachment post" type="int" variable="$post_id">
860
  <type by_reference="false">int</type>
861
  </tag>
862
- <tag line="1819" name="return" description="NULL on failure else associative array" type="NULL|array">
863
  <type by_reference="false">NULL</type>
864
  <type by_reference="false">array</type>
865
  </tag>
866
  </docblock>
867
- <argument line="1831">
868
  <name>$post_id</name>
869
  <default><![CDATA[]]></default>
870
  <type/>
871
  </argument>
872
  </method>
873
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1885" package="Media Library Assistant">
874
  <name>mla_fetch_attachment_parent_data</name>
875
  <full_name>mla_fetch_attachment_parent_data</full_name>
876
- <docblock line="1876">
877
  <description><![CDATA[Returns information about an attachment's parent, if found]]></description>
878
  <long-description><![CDATA[]]></long-description>
879
- <tag line="1876" name="since" description="0.1"/>
880
- <tag line="1876" name="param" description="post ID of attachment's parent, if any" type="int" variable="$parent_id">
881
  <type by_reference="false">int</type>
882
  </tag>
883
- <tag line="1876" name="return" description="Parent information; post_date, post_title and post_type" type="array">
884
  <type by_reference="false">array</type>
885
  </tag>
886
  </docblock>
887
- <argument line="1885">
888
  <name>$parent_id</name>
889
  <default><![CDATA[]]></default>
890
  <type/>
891
  </argument>
892
  </method>
893
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="1917" package="Media Library Assistant">
894
  <name>_set_array_element</name>
895
  <full_name>_set_array_element</full_name>
896
- <docblock line="1906">
897
  <description><![CDATA[Adds or replaces the value of a key in a possibly nested array structure]]></description>
898
  <long-description><![CDATA[]]></long-description>
899
- <tag line="1906" name="since" description="1.51"/>
900
- <tag line="1906" name="param" description="key value, e.g. array1.array2.element" type="string" variable="$needle">
901
  <type by_reference="false">string</type>
902
  </tag>
903
- <tag line="1906" name="param" description="replacement value, string or array, by reference" type="mixed" variable="$value">
904
  <type by_reference="false">mixed</type>
905
  </tag>
906
- <tag line="1906" name="param" description="PHP nested arrays, by reference" type="array" variable="$haystack">
907
  <type by_reference="false">array</type>
908
  </tag>
909
- <tag line="1906" name="return" description="true if $needle element set, false if not" type="boolean">
910
  <type by_reference="false">boolean</type>
911
  </tag>
912
  </docblock>
913
- <argument line="1917">
914
  <name>$needle</name>
915
  <default><![CDATA[]]></default>
916
  <type/>
917
  </argument>
918
- <argument line="1917">
919
  <name>$value</name>
920
  <default><![CDATA[]]></default>
921
  <type/>
922
  </argument>
923
- <argument line="1917">
924
  <name>$haystack</name>
925
  <default><![CDATA[]]></default>
926
  <type/>
927
  </argument>
928
  </method>
929
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="1950" package="Media Library Assistant">
930
  <name>_unset_array_element</name>
931
  <full_name>_unset_array_element</full_name>
932
- <docblock line="1940">
933
  <description><![CDATA[Deletes the value of a key in a possibly nested array structure]]></description>
934
  <long-description><![CDATA[]]></long-description>
935
- <tag line="1940" name="since" description="1.51"/>
936
- <tag line="1940" name="param" description="key value, e.g. array1.array2.element" type="string" variable="$needle">
937
  <type by_reference="false">string</type>
938
  </tag>
939
- <tag line="1940" name="param" description="PHP nested arrays, by reference" type="array" variable="$haystack">
940
  <type by_reference="false">array</type>
941
  </tag>
942
- <tag line="1940" name="return" description="true if $needle element found, false if not" type="boolean">
943
  <type by_reference="false">boolean</type>
944
  </tag>
945
  </docblock>
946
- <argument line="1950">
947
  <name>$needle</name>
948
  <default><![CDATA[]]></default>
949
  <type/>
950
  </argument>
951
- <argument line="1950">
952
  <name>$haystack</name>
953
  <default><![CDATA[]]></default>
954
  <type/>
955
  </argument>
956
  </method>
957
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1984" package="Media Library Assistant">
958
  <name>mla_find_array_element</name>
959
  <full_name>mla_find_array_element</full_name>
960
- <docblock line="1969">
961
  <description><![CDATA[Finds the value of a key in a possibly nested array structure]]></description>
962
  <long-description><![CDATA[<p>Used primarily to extract fields from the _wp_attachment_metadata custom field.
963
  Could also be used with the ID3 metadata exposed in WordPress 3.6 and later.</p>]]></long-description>
964
- <tag line="1969" name="since" description="1.30"/>
965
- <tag line="1969" name="param" description="key value, e.g. array1.array2.element" type="string" variable="$needle">
966
  <type by_reference="false">string</type>
967
  </tag>
968
- <tag line="1969" name="param" description="PHP nested arrays" type="array" variable="$haystack">
969
  <type by_reference="false">array</type>
970
  </tag>
971
- <tag line="1969" name="param" description="data option 'text'|'single'|'export'|'array'|'multi'" type="string" variable="$option">
972
  <type by_reference="false">string</type>
973
  </tag>
974
- <tag line="1969" name="param" description="keep existing values - for 'multi' option" type="boolean" variable="$keep_existing">
975
  <type by_reference="false">boolean</type>
976
  </tag>
977
- <tag line="1969" name="return" description="string or array value matching key(.key ...) or ''" type="mixed">
978
  <type by_reference="false">mixed</type>
979
  </tag>
980
  </docblock>
981
- <argument line="1984">
982
  <name>$needle</name>
983
  <default><![CDATA[]]></default>
984
  <type/>
985
  </argument>
986
- <argument line="1984">
987
  <name>$haystack</name>
988
  <default><![CDATA[]]></default>
989
  <type/>
990
  </argument>
991
- <argument line="1984">
992
  <name>$option</name>
993
  <default><![CDATA[]]></default>
994
  <type/>
995
  </argument>
996
- <argument line="1984">
997
  <name>$keep_existing</name>
998
  <default><![CDATA[false]]></default>
999
  <type/>
1000
  </argument>
1001
  </method>
1002
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="2035" package="Media Library Assistant">
1003
  <name>mla_fetch_attachment_metadata</name>
1004
  <full_name>mla_fetch_attachment_metadata</full_name>
1005
- <docblock line="2023">
1006
  <description><![CDATA[Fetch and filter meta data for an attachment]]></description>
1007
  <long-description><![CDATA[<p>Returns a filtered array of a post's meta data. Internal values beginning with '<em>'
1008
  are stripped out or converted to an 'mla</em>' equivalent.</p>]]></long-description>
1009
- <tag line="2023" name="since" description="0.1"/>
1010
- <tag line="2023" name="param" description="post ID of attachment" type="int" variable="$post_id">
1011
  <type by_reference="false">int</type>
1012
  </tag>
1013
- <tag line="2023" name="return" description="Meta data variables" type="array">
1014
  <type by_reference="false">array</type>
1015
  </tag>
1016
  </docblock>
1017
- <argument line="2035">
1018
  <name>$post_id</name>
1019
  <default><![CDATA[]]></default>
1020
  <type/>
1021
  </argument>
1022
  </method>
1023
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="2113" package="Media Library Assistant">
1024
  <name>mla_fetch_attachment_references</name>
1025
  <full_name>mla_fetch_attachment_references</full_name>
1026
- <docblock line="2100">
1027
  <description><![CDATA[Find Featured Image and inserted image/link references to an attachment]]></description>
1028
  <long-description><![CDATA[<p>Searches all post and page content to see if the attachment is used
1029
  as a Featured Image or inserted in the post as an image or link.</p>]]></long-description>
1030
- <tag line="2100" name="since" description="0.1"/>
1031
- <tag line="2100" name="param" description="post ID of attachment" type="int" variable="$ID">
1032
  <type by_reference="false">int</type>
1033
  </tag>
1034
- <tag line="2100" name="param" description="post ID of attachment's parent, if any" type="int" variable="$parent">
1035
  <type by_reference="false">int</type>
1036
  </tag>
1037
- <tag line="2100" name="return" description="Reference information; see $references array comments" type="array">
1038
  <type by_reference="false">array</type>
1039
  </tag>
1040
  </docblock>
1041
- <argument line="2113">
1042
  <name>$ID</name>
1043
  <default><![CDATA[]]></default>
1044
  <type/>
1045
  </argument>
1046
- <argument line="2113">
1047
  <name>$parent</name>
1048
  <default><![CDATA[]]></default>
1049
  <type/>
1050
  </argument>
1051
  </method>
1052
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="2410" package="Media Library Assistant">
1053
  <name>mla_flush_mla_galleries</name>
1054
  <full_name>mla_flush_mla_galleries</full_name>
1055
- <docblock line="2401">
1056
  <description><![CDATA[Invalidates the $mla_galleries or $galleries array and cached values]]></description>
1057
  <long-description><![CDATA[]]></long-description>
1058
- <tag line="2401" name="since" description="1.00"/>
1059
- <tag line="2401" name="param" description="name of the gallery's cache/option variable" type="string" variable="$option_name">
1060
  <type by_reference="false">string</type>
1061
  </tag>
1062
- <tag line="2401" name="return" description="" type="void">
1063
  <type by_reference="false">void</type>
1064
  </tag>
1065
  </docblock>
1066
- <argument line="2410">
1067
  <name>$option_name</name>
1068
  <default><![CDATA[]]></default>
1069
  <type/>
1070
  </argument>
1071
  </method>
1072
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="2434" package="Media Library Assistant">
1073
  <name>mla_save_post_action</name>
1074
  <full_name>mla_save_post_action</full_name>
1075
- <docblock line="2425">
1076
  <description><![CDATA[Invalidates $mla_galleries and $galleries arrays and cached values after post, page or attachment updates]]></description>
1077
  <long-description><![CDATA[]]></long-description>
1078
- <tag line="2425" name="since" description="1.00"/>
1079
- <tag line="2425" name="param" description="ID of post/page/attachment; not used at this time" type="integer" variable="$post_id">
1080
  <type by_reference="false">integer</type>
1081
  </tag>
1082
- <tag line="2425" name="return" description="" type="void">
1083
  <type by_reference="false">void</type>
1084
  </tag>
1085
  </docblock>
1086
- <argument line="2434">
1087
  <name>$post_id</name>
1088
  <default><![CDATA[]]></default>
1089
  <type/>
1090
  </argument>
1091
  </method>
1092
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2451" package="Media Library Assistant">
1093
  <name>_build_mla_galleries</name>
1094
  <full_name>_build_mla_galleries</full_name>
1095
- <docblock line="2439">
1096
  <description><![CDATA[Builds the $mla_galleries or $galleries array]]></description>
1097
  <long-description><![CDATA[]]></long-description>
1098
- <tag line="2439" name="since" description="0.70"/>
1099
- <tag line="2439" name="param" description="name of the gallery's cache/option variable" type="string" variable="$option_name">
1100
  <type by_reference="false">string</type>
1101
  </tag>
1102
- <tag line="2439" name="param" description="by reference to the private static galleries array variable" type="array" variable="$galleries_array">
1103
  <type by_reference="false">array</type>
1104
  </tag>
1105
- <tag line="2439" name="param" description="the shortcode to be searched for and processed" type="string" variable="$shortcode">
1106
  <type by_reference="false">string</type>
1107
  </tag>
1108
- <tag line="2439" name="param" description="true to exclude revisions from the search" type="boolean" variable="$exclude_revisions">
1109
  <type by_reference="false">boolean</type>
1110
  </tag>
1111
- <tag line="2439" name="return" description="true if the galleries array is not empty" type="boolean">
1112
  <type by_reference="false">boolean</type>
1113
  </tag>
1114
  </docblock>
1115
- <argument line="2451">
1116
  <name>$option_name</name>
1117
  <default><![CDATA[]]></default>
1118
  <type/>
1119
  </argument>
1120
- <argument line="2451">
1121
  <name>$galleries_array</name>
1122
  <default><![CDATA[]]></default>
1123
  <type/>
1124
  </argument>
1125
- <argument line="2451">
1126
  <name>$shortcode</name>
1127
  <default><![CDATA[]]></default>
1128
  <type/>
1129
  </argument>
1130
- <argument line="2451">
1131
  <name>$exclude_revisions</name>
1132
  <default><![CDATA[]]></default>
1133
  <type/>
1134
  </argument>
1135
  </method>
1136
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2562" package="Media Library Assistant">
1137
  <name>_search_mla_galleries</name>
1138
  <full_name>_search_mla_galleries</full_name>
1139
- <docblock line="2551">
1140
  <description><![CDATA[Search the $mla_galleries or $galleries array]]></description>
1141
  <long-description><![CDATA[]]></long-description>
1142
- <tag line="2551" name="since" description="0.70"/>
1143
- <tag line="2551" name="param" description="by reference to the private static galleries array variable" type="array" variable="$galleries_array">
1144
  <type by_reference="false">array</type>
1145
  </tag>
1146
- <tag line="2551" name="param" description="the attachment ID to be searched for and processed" type="int" variable="$attachment_id">
1147
  <type by_reference="false">int</type>
1148
  </tag>
1149
- <tag line="2551" name="return" description="All posts/pages with one or more galleries that include the attachment. The array key is the parent_post ID; each entry contains post_title and post_type." type="array">
1150
  <type by_reference="false">array</type>
1151
  </tag>
1152
  </docblock>
1153
- <argument line="2562">
1154
  <name>$galleries_array</name>
1155
  <default><![CDATA[]]></default>
1156
  <type/>
1157
  </argument>
1158
- <argument line="2562">
1159
  <name>$attachment_id</name>
1160
  <default><![CDATA[]]></default>
1161
  <type/>
1162
  </argument>
1163
  </method>
1164
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2601" package="Media Library Assistant">
1165
  <name>_parse_pdf_xref_subsection</name>
1166
  <full_name>_parse_pdf_xref_subsection</full_name>
1167
- <docblock line="2588">
1168
  <description><![CDATA[Parse a cross-reference table subsection into the array of indirect object definitions]]></description>
1169
  <long-description><![CDATA[<p>A cross-reference subsection is a sequence of 20-byte entries, each with offset and generation values.</p>]]></long-description>
1170
- <tag line="2588" name="since" description="1.50"/>
1171
- <tag line="2588" name="param" description="buffer containing the subsection" type="string" variable="$xref_section">
1172
  <type by_reference="false">string</type>
1173
  </tag>
1174
- <tag line="2588" name="param" description="offset within the buffer of the first entry" type="integer" variable="$offset">
1175
  <type by_reference="false">integer</type>
1176
  </tag>
1177
- <tag line="2588" name="param" description="number of the first object in the subsection" type="integer" variable="$object_id">
1178
  <type by_reference="false">integer</type>
1179
  </tag>
1180
- <tag line="2588" name="param" description="number of entries in the subsection" type="integer" variable="$count">
1181
  <type by_reference="false">integer</type>
1182
  </tag>
1183
- <tag line="2588" name="return" description="" type="void">
1184
  <type by_reference="false">void</type>
1185
  </tag>
1186
  </docblock>
1187
- <argument line="2601">
1188
  <name>$xref_section</name>
1189
  <default><![CDATA[]]></default>
1190
  <type/>
1191
  </argument>
1192
- <argument line="2601">
1193
  <name>$offset</name>
1194
  <default><![CDATA[]]></default>
1195
  <type/>
1196
  </argument>
1197
- <argument line="2601">
1198
  <name>$object_id</name>
1199
  <default><![CDATA[]]></default>
1200
  <type/>
1201
  </argument>
1202
- <argument line="2601">
1203
  <name>$count</name>
1204
  <default><![CDATA[]]></default>
1205
  <type/>
1206
  </argument>
1207
  </method>
1208
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2631" package="Media Library Assistant">
1209
  <name>_parse_pdf_xref_section</name>
1210
  <full_name>_parse_pdf_xref_section</full_name>
1211
- <docblock line="2620">
1212
  <description><![CDATA[Parse a cross-reference table section into the array of indirect object definitions]]></description>
1213
  <long-description><![CDATA[<p>Creates the array of indirect object offsets and lengths</p>]]></long-description>
1214
- <tag line="2620" name="since" description="1.50"/>
1215
- <tag line="2620" name="param" description="full path and file name" type="string" variable="$file_name">
1216
  <type by_reference="false">string</type>
1217
  </tag>
1218
- <tag line="2620" name="param" description="offset within the file of the xref id and count entry" type="integer" variable="$file_offset">
1219
  <type by_reference="false">integer</type>
1220
  </tag>
1221
- <tag line="2620" name="return" description="length of the section" type="integer">
1222
  <type by_reference="false">integer</type>
1223
  </tag>
1224
  </docblock>
1225
- <argument line="2631">
1226
  <name>$file_name</name>
1227
  <default><![CDATA[]]></default>
1228
  <type/>
1229
  </argument>
1230
- <argument line="2631">
1231
  <name>$file_offset</name>
1232
  <default><![CDATA[]]></default>
1233
  <type/>
1234
  </argument>
1235
  </method>
1236
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2665" package="Media Library Assistant">
1237
  <name>_parse_pdf_xref_stream</name>
1238
  <full_name>_parse_pdf_xref_stream</full_name>
1239
- <docblock line="2653">
1240
  <description><![CDATA[Parse a cross-reference steam into the array of indirect object definitions]]></description>
1241
  <long-description><![CDATA[<p>Creates the array of indirect object offsets and lengths</p>]]></long-description>
1242
- <tag line="2653" name="since" description="1.50"/>
1243
- <tag line="2653" name="param" description="full path and file name" type="string" variable="$file_name">
1244
  <type by_reference="false">string</type>
1245
  </tag>
1246
- <tag line="2653" name="param" description="offset within the file of the xref id and count entry" type="integer" variable="$file_offset">
1247
  <type by_reference="false">integer</type>
1248
  </tag>
1249
- <tag line="2653" name="param" description="&quot;/W&quot; entry, representing the size of the fields in a single entry" type="string" variable="$entry_parms_string">
1250
  <type by_reference="false">string</type>
1251
  </tag>
1252
- <tag line="2653" name="return" description="length of the stream" type="integer">
1253
  <type by_reference="false">integer</type>
1254
  </tag>
1255
  </docblock>
1256
- <argument line="2665">
1257
  <name>$file_name</name>
1258
  <default><![CDATA[]]></default>
1259
  <type/>
1260
  </argument>
1261
- <argument line="2665">
1262
  <name>$file_offset</name>
1263
  <default><![CDATA[]]></default>
1264
  <type/>
1265
  </argument>
1266
- <argument line="2665">
1267
  <name>$entry_parms_string</name>
1268
  <default><![CDATA[]]></default>
1269
  <type/>
1270
  </argument>
1271
  </method>
1272
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2739" package="Media Library Assistant">
1273
  <name>_build_pdf_indirect_objects</name>
1274
  <full_name>_build_pdf_indirect_objects</full_name>
1275
- <docblock line="2729">
1276
  <description><![CDATA[Build an array of indirect object definitions]]></description>
1277
  <long-description><![CDATA[<p>Creates the array of indirect object offsets and lengths</p>]]></long-description>
1278
- <tag line="2729" name="since" description="1.50"/>
1279
- <tag line="2729" name="param" description="The entire PDF document, passsed by reference" type="string" variable="$string">
1280
  <type by_reference="false">string</type>
1281
  </tag>
1282
- <tag line="2729" name="return" description="" type="void">
1283
  <type by_reference="false">void</type>
1284
  </tag>
1285
  </docblock>
1286
- <argument line="2739">
1287
  <name>$string</name>
1288
  <default><![CDATA[]]></default>
1289
  <type/>
1290
  </argument>
1291
  </method>
1292
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2788" package="Media Library Assistant">
1293
  <name>_find_pdf_indirect_dictionary</name>
1294
  <full_name>_find_pdf_indirect_dictionary</full_name>
1295
- <docblock line="2774">
1296
  <description><![CDATA[Find the offset, length and contents of an indirect object containing a dictionary]]></description>
1297
  <long-description><![CDATA[<p>The function searches the entire file, if necessary, to find the last/most recent copy of the object.
1298
  This is required because Adobe Acrobat does NOT increment the generation number when it reuses an object.</p>]]></long-description>
1299
- <tag line="2774" name="since" description="1.50"/>
1300
- <tag line="2774" name="param" description="full path and file name" type="string" variable="$file_name">
1301
  <type by_reference="false">string</type>
1302
  </tag>
1303
- <tag line="2774" name="param" description="The object number" type="integer" variable="$object">
1304
  <type by_reference="false">integer</type>
1305
  </tag>
1306
- <tag line="2774" name="param" description="The object generation number; default zero (0)" type="integer" variable="$generation">
1307
  <type by_reference="false">integer</type>
1308
  </tag>
1309
- <tag line="2774" name="return" description="NULL on failure else array( 'start' =&gt; offset in the file, 'length' =&gt; object length, 'content' =&gt; dictionary contents )" type="mixed">
1310
  <type by_reference="false">mixed</type>
1311
  </tag>
1312
  </docblock>
1313
- <argument line="2788">
1314
  <name>$file_name</name>
1315
  <default><![CDATA[]]></default>
1316
  <type/>
1317
  </argument>
1318
- <argument line="2788">
1319
  <name>$object</name>
1320
  <default><![CDATA[]]></default>
1321
  <type/>
1322
  </argument>
1323
- <argument line="2788">
1324
  <name>$generation</name>
1325
  <default><![CDATA[0]]></default>
1326
  <type/>
1327
  </argument>
1328
  </method>
1329
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2884" package="Media Library Assistant">
1330
  <name>_parse_iso8601_date</name>
1331
  <full_name>_parse_iso8601_date</full_name>
1332
- <docblock line="2875">
1333
  <description><![CDATA[Parse a ISO 8601 Timestamp]]></description>
1334
  <long-description><![CDATA[]]></long-description>
1335
- <tag line="2875" name="since" description="1.50"/>
1336
- <tag line="2875" name="param" description="ISO string of the form YYYY-MM-DDTHH:MM:SS-HH:MM (inc time zone)" type="string" variable="$source_string">
1337
  <type by_reference="false">string</type>
1338
  </tag>
1339
- <tag line="2875" name="return" description="formatted date string YYYY-MM-DD HH:mm:SS" type="string">
1340
  <type by_reference="false">string</type>
1341
  </tag>
1342
  </docblock>
1343
- <argument line="2884">
1344
  <name>$source_string</name>
1345
  <default><![CDATA[]]></default>
1346
  <type/>
1347
  </argument>
1348
  </method>
1349
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2906" package="Media Library Assistant">
1350
  <name>_parse_pdf_date</name>
1351
  <full_name>_parse_pdf_date</full_name>
1352
- <docblock line="2897">
1353
  <description><![CDATA[Parse a PDF date string]]></description>
1354
  <long-description><![CDATA[]]></long-description>
1355
- <tag line="2897" name="since" description="1.50"/>
1356
- <tag line="2897" name="param" description="PDF date string of the form D:YYYYMMDDHHmmSSOHH'mm" type="string" variable="$source_string">
1357
  <type by_reference="false">string</type>
1358
  </tag>
1359
- <tag line="2897" name="return" description="formatted date string YYYY-MM-DD HH:mm:SS" type="string">
1360
  <type by_reference="false">string</type>
1361
  </tag>
1362
  </docblock>
1363
- <argument line="2906">
1364
  <name>$source_string</name>
1365
  <default><![CDATA[]]></default>
1366
  <type/>
1367
  </argument>
1368
  </method>
1369
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2928" package="Media Library Assistant">
1370
  <name>_parse_pdf_UTF16BE</name>
1371
  <full_name>_parse_pdf_UTF16BE</full_name>
1372
- <docblock line="2919">
1373
  <description><![CDATA[Parse a PDF Unicode (16-bit Big Endian) object]]></description>
1374
  <long-description><![CDATA[]]></long-description>
1375
- <tag line="2919" name="since" description="1.50"/>
1376
- <tag line="2919" name="param" description="PDF string of 16-bit characters" type="string" variable="$source_string">
1377
  <type by_reference="false">string</type>
1378
  </tag>
1379
- <tag line="2919" name="return" description="UTF-8 encoded string" type="string">
1380
  <type by_reference="false">string</type>
1381
  </tag>
1382
  </docblock>
1383
- <argument line="2928">
1384
  <name>$source_string</name>
1385
  <default><![CDATA[]]></default>
1386
  <type/>
1387
  </argument>
1388
  </method>
1389
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2957" package="Media Library Assistant">
1390
  <name>_parse_pdf_string</name>
1391
  <full_name>_parse_pdf_string</full_name>
1392
- <docblock line="2944">
1393
  <description><![CDATA[Parse a PDF string object]]></description>
1394
  <long-description><![CDATA[<p>Returns an array with one dictionary entry. The array also has a '/length' element containing
1395
  the number of bytes occupied by the string in the source string, including the enclosing parentheses.</p>]]></long-description>
1396
- <tag line="2944" name="since" description="1.50"/>
1397
- <tag line="2944" name="param" description="data within which the string occurs" type="string" variable="$source_string">
1398
  <type by_reference="false">string</type>
1399
  </tag>
1400
- <tag line="2944" name="param" description="offset within the source string of the opening '(' character." type="integer" variable="$offset">
1401
  <type by_reference="false">integer</type>
1402
  </tag>
1403
- <tag line="2944" name="return" description="( key =&gt; array( 'type' =&gt; type, 'value' =&gt; value, '/length' =&gt; length ) ) for the string" type="array">
1404
  <type by_reference="false">array</type>
1405
  </tag>
1406
  </docblock>
1407
- <argument line="2957">
1408
  <name>$source_string</name>
1409
  <default><![CDATA[]]></default>
1410
  <type/>
1411
  </argument>
1412
- <argument line="2957">
1413
  <name>$offset</name>
1414
  <default><![CDATA[]]></default>
1415
  <type/>
1416
  </argument>
1417
  </method>
1418
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3045" package="Media Library Assistant">
1419
  <name>_parse_pdf_LPD_dictionary</name>
1420
  <full_name>_parse_pdf_LPD_dictionary</full_name>
1421
- <docblock line="3031">
1422
  <description><![CDATA[Parse a PDF Linearization Parameter Dictionary object]]></description>
1423
  <long-description><![CDATA[<p>Returns an array of dictionary contents, classified by object type: boolean, numeric, string, hex (string),
1424
  indirect (object), name, array, dictionary, stream, and null.
1425
  The array also has a '/length' element containing the number of bytes occupied by the
1426
  dictionary in the source string, excluding the enclosing delimiters, if passed in.</p>]]></long-description>
1427
- <tag line="3031" name="since" description="1.50"/>
1428
- <tag line="3031" name="param" description="data within which the object occurs, typically the start of a PDF document" type="string" variable="$source_string">
1429
  <type by_reference="false">string</type>
1430
  </tag>
1431
- <tag line="3031" name="param" description="filesize of the PDF document, for validation purposes, or zero (0) to ignore filesize" type="integer" variable="$filesize">
1432
  <type by_reference="false">integer</type>
1433
  </tag>
1434
- <tag line="3031" name="return" description="array of dictionary objects on success, false on failure" type="mixed">
1435
  <type by_reference="false">mixed</type>
1436
  </tag>
1437
  </docblock>
1438
- <argument line="3045">
1439
  <name>$source_string</name>
1440
  <default><![CDATA[]]></default>
1441
  <type/>
1442
  </argument>
1443
- <argument line="3045">
1444
  <name>$filesize</name>
1445
  <default><![CDATA[]]></default>
1446
  <type/>
1447
  </argument>
1448
  </method>
1449
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3069" package="Media Library Assistant">
1450
  <name>_parse_pdf_dictionary</name>
1451
  <full_name>_parse_pdf_dictionary</full_name>
1452
- <docblock line="3055">
1453
  <description><![CDATA[Parse a PDF dictionary object]]></description>
1454
  <long-description><![CDATA[<p>Returns an array of dictionary contents, classified by object type: boolean, numeric, string, hex (string),
1455
  indirect (object), name, array, dictionary, stream, and null.
1456
  The array also has a '/length' element containing the number of bytes occupied by the
1457
  dictionary in the source string, excluding the enclosing delimiters.</p>]]></long-description>
1458
- <tag line="3055" name="since" description="1.50"/>
1459
- <tag line="3055" name="param" description="data within which the string occurs" type="string" variable="$source_string">
1460
  <type by_reference="false">string</type>
1461
  </tag>
1462
- <tag line="3055" name="param" description="offset within the source string of the opening '&lt;&lt;' characters or the first content character." type="integer" variable="$offset">
1463
  <type by_reference="false">integer</type>
1464
  </tag>
1465
- <tag line="3055" name="return" description="( '/length' =&gt; length, key =&gt; array( 'type' =&gt; type, 'value' =&gt; value ) ) for each dictionary field" type="array">
1466
  <type by_reference="false">array</type>
1467
  </tag>
1468
  </docblock>
1469
- <argument line="3069">
1470
  <name>$source_string</name>
1471
  <default><![CDATA[]]></default>
1472
  <type/>
1473
  </argument>
1474
- <argument line="3069">
1475
  <name>$offset</name>
1476
  <default><![CDATA[]]></default>
1477
  <type/>
1478
  </argument>
1479
  </method>
1480
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3203" package="Media Library Assistant">
1481
  <name>_parse_xmp_metadata</name>
1482
  <full_name>_parse_xmp_metadata</full_name>
1483
- <docblock line="3189">
1484
  <description><![CDATA[Parse an XMP object]]></description>
1485
  <long-description><![CDATA[<p>Returns an array of dictionary contents, classified by object type: boolean, numeric, string, hex (string),
1486
  indirect (object), name, array, dictionary, stream, and null.
1487
  The array also has a '/length' element containing the number of bytes occupied by the
1488
  dictionary in the source string, excluding the enclosing delimiters, if passed in.</p>]]></long-description>
1489
- <tag line="3189" name="since" description="1.50"/>
1490
- <tag line="3189" name="param" description="full path and file name" type="string" variable="$file_name">
1491
  <type by_reference="false">string</type>
1492
  </tag>
1493
- <tag line="3189" name="param" description="offset within the file of the search start point" type="integer" variable="$file_offset">
1494
  <type by_reference="false">integer</type>
1495
  </tag>
1496
- <tag line="3189" name="return" description="array of metadata values or NULL on failure" type="mixed">
1497
  <type by_reference="false">mixed</type>
1498
  </tag>
1499
  </docblock>
1500
- <argument line="3203">
1501
  <name>$file_name</name>
1502
  <default><![CDATA[]]></default>
1503
  <type/>
1504
  </argument>
1505
- <argument line="3203">
1506
  <name>$file_offset</name>
1507
  <default><![CDATA[]]></default>
1508
  <type/>
1509
  </argument>
1510
  </method>
1511
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3471" package="Media Library Assistant">
1512
  <name>_extract_pdf_trailer</name>
1513
  <full_name>_extract_pdf_trailer</full_name>
1514
- <docblock line="3461">
1515
  <description><![CDATA[Extract dictionary from traditional cross-reference + trailer documents]]></description>
1516
  <long-description><![CDATA[]]></long-description>
1517
- <tag line="3461" name="since" description="1.50"/>
1518
- <tag line="3461" name="param" description="full path to the desired file" type="string" variable="$file_name">
1519
  <type by_reference="false">string</type>
1520
  </tag>
1521
- <tag line="3461" name="param" description="offset within file of the cross-reference table" type="integer" variable="$file_offset">
1522
  <type by_reference="false">integer</type>
1523
  </tag>
1524
- <tag line="3461" name="return" description="array of &quot;PDF dictionary arrays&quot;, newest first, or NULL on failure" type="mixed">
1525
  <type by_reference="false">mixed</type>
1526
  </tag>
1527
  </docblock>
1528
- <argument line="3471">
1529
  <name>$file_name</name>
1530
  <default><![CDATA[]]></default>
1531
  <type/>
1532
  </argument>
1533
- <argument line="3471">
1534
  <name>$file_offset</name>
1535
  <default><![CDATA[]]></default>
1536
  <type/>
1537
  </argument>
1538
  </method>
1539
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3555" package="Media Library Assistant">
1540
  <name>_extract_pdf_metadata</name>
1541
  <full_name>_extract_pdf_metadata</full_name>
1542
- <docblock line="3546">
1543
  <description><![CDATA[Extract Metadata from a PDF file]]></description>
1544
  <long-description><![CDATA[]]></long-description>
1545
- <tag line="3546" name="since" description="1.50"/>
1546
- <tag line="3546" name="param" description="full path to the desired file" type="string" variable="$file_name">
1547
  <type by_reference="false">string</type>
1548
  </tag>
1549
- <tag line="3546" name="return" description="( key =&gt; value ) for each metadata field, in string format" type="array">
1550
  <type by_reference="false">array</type>
1551
  </tag>
1552
  </docblock>
1553
- <argument line="3555">
1554
  <name>$file_name</name>
1555
  <default><![CDATA[]]></default>
1556
  <type/>
1557
  </argument>
1558
  </method>
1559
- <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3682" package="Media Library Assistant">
1560
  <name>_bin_to_utf8</name>
1561
  <full_name>_bin_to_utf8</full_name>
1562
- <docblock line="3673">
1563
  <description><![CDATA[Replace SQL incorrect characters (0x80 - 0xFF) with their UTF-8 equivalents]]></description>
1564
  <long-description><![CDATA[]]></long-description>
1565
- <tag line="3673" name="since" description="1.41"/>
1566
- <tag line="3673" name="param" description="unencoded string" type="string" variable="$string">
1567
  <type by_reference="false">string</type>
1568
  </tag>
1569
- <tag line="3673" name="return" description="UTF-8 encoded string" type="string">
1570
  <type by_reference="false">string</type>
1571
  </tag>
1572
  </docblock>
1573
- <argument line="3682">
1574
  <name>$string</name>
1575
  <default><![CDATA[]]></default>
1576
  <type/>
1577
  </argument>
1578
  </method>
1579
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="4078" package="Media Library Assistant">
1580
  <name>mla_iptc_metadata_value</name>
1581
  <full_name>mla_iptc_metadata_value</full_name>
1582
- <docblock line="4068">
1583
  <description><![CDATA[Parse one IPTC metadata field]]></description>
1584
  <long-description><![CDATA[]]></long-description>
1585
- <tag line="4068" name="since" description="1.41"/>
1586
- <tag line="4068" name="param" description="field name - IPTC Identifier or friendly name/slug" type="string" variable="$iptc_key">
1587
  <type by_reference="false">string</type>
1588
  </tag>
1589
- <tag line="4068" name="param" description="metadata array containing iptc, exif, and pdf metadata arrays" type="string" variable="$item_metadata">
1590
  <type by_reference="false">string</type>
1591
  </tag>
1592
- <tag line="4068" name="return" description="string/array representation of metadata value or an empty string" type="mixed">
1593
  <type by_reference="false">mixed</type>
1594
  </tag>
1595
  </docblock>
1596
- <argument line="4078">
1597
  <name>$iptc_key</name>
1598
  <default><![CDATA[]]></default>
1599
  <type/>
1600
  </argument>
1601
- <argument line="4078">
1602
  <name>$item_metadata</name>
1603
  <default><![CDATA[]]></default>
1604
  <type/>
1605
  </argument>
1606
  </method>
1607
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="4110" package="Media Library Assistant">
1608
  <name>mla_exif_metadata_value</name>
1609
  <full_name>mla_exif_metadata_value</full_name>
1610
- <docblock line="4098">
1611
  <description><![CDATA[Parse one EXIF metadata field]]></description>
1612
  <long-description><![CDATA[<p>Also handles the special pseudo-values 'ALL_EXIF' and 'ALL_IPTC'.</p>]]></long-description>
1613
- <tag line="4098" name="since" description="1.13"/>
1614
- <tag line="4098" name="param" description="field name" type="string" variable="$exif_key">
1615
  <type by_reference="false">string</type>
1616
  </tag>
1617
- <tag line="4098" name="param" description="metadata array containing iptc, exif, and pdf metadata arrays" type="string" variable="$item_metadata">
1618
  <type by_reference="false">string</type>
1619
  </tag>
1620
- <tag line="4098" name="return" description="string/array representation of metadata value or an empty string" type="mixed">
1621
  <type by_reference="false">mixed</type>
1622
  </tag>
1623
  </docblock>
1624
- <argument line="4110">
1625
  <name>$exif_key</name>
1626
  <default><![CDATA[]]></default>
1627
  <type/>
1628
  </argument>
1629
- <argument line="4110">
1630
  <name>$item_metadata</name>
1631
  <default><![CDATA[]]></default>
1632
  <type/>
1633
  </argument>
1634
  </method>
1635
- <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="4169" package="Media Library Assistant">
1636
  <name>mla_pdf_metadata_value</name>
1637
  <full_name>mla_pdf_metadata_value</full_name>
1638
- <docblock line="4157">
1639
  <description><![CDATA[Parse one PDF metadata field]]></description>
1640
  <long-description><![CDATA[<p>Also handles the special pseudo-value 'ALL_PDF'.</p>]]></long-description>
1641
- <tag line="4157" name="since" description="1.50"/>
1642
- <tag line="4157" name="param" description="field name" type="string" variable="$pdf_key">
1643
  <type by_reference="false">string</type>
1644
  </tag>
1645
- <t
1
  <?xml version="1.0" encoding="utf-8"?>
2
  <project version="2.0.0a8" title="Media Library Assistant">
3
+ <file path="includes\class-mla-data.php" hash="eed95e31bb26d9cf7218c1a3513c0eeb" package="Media Library Assistant">
4
  <docblock line="2">
5
  <description><![CDATA[Database and template file access for MLA needs]]></description>
6
  <long-description><![CDATA[]]></long-description>
18
  <tag line="9" name="package" description="Media Library Assistant"/>
19
  <tag line="9" name="since" description="0.1"/>
20
  </docblock>
21
+ <constant namespace="global" line="27" package="Media Library Assistant">
22
  <name>MLA_ALT_TEXT_VIEW_SUFFIX</name>
23
  <full_name>MLA_ALT_TEXT_VIEW_SUFFIX</full_name>
24
  <value><![CDATA['alt_text_view']]></value>
25
  <docblock line="19">
26
+ <description><![CDATA[Provides a unique suffix for the ALT Text/custom field SQL View]]></description>
27
+ <long-description><![CDATA[<p>The SQL View is used to sort the Media/Assistant submenu table on
28
+ ALT Text and custom field columns.</p>]]></long-description>
29
  <tag line="19" name="since" description="0.40"/>
30
  </docblock>
31
  </constant>
32
+ <property final="false" static="true" visibility="private" line="36" namespace="global" package="Media Library Assistant">
33
  <name>$mla_alt_text_view</name>
34
  <default><![CDATA[NULL]]></default>
35
+ <docblock line="29">
36
+ <description><![CDATA[Provides a unique name for the ALT Text/custom field SQL View]]></description>
37
  <long-description><![CDATA[]]></long-description>
38
+ <tag line="29" name="since" description="0.40"/>
39
+ <tag line="29" name="var" description="" type="array">
40
  <type by_reference="false">array</type>
41
  </tag>
42
  </docblock>
43
  </property>
44
+ <property final="false" static="true" visibility="private" line="1099" namespace="global" package="Media Library Assistant">
45
  <name>$mla_list_table_items</name>
46
  <default><![CDATA[NULL]]></default>
47
+ <docblock line="1092">
48
  <description><![CDATA[Cache the results of mla_count_list_table_items for reuse in mla_query_list_table_items]]></description>
49
  <long-description><![CDATA[]]></long-description>
50
+ <tag line="1092" name="since" description="1.40"/>
51
+ <tag line="1092" name="var" description="" type="array">
52
  <type by_reference="false">array</type>
53
  </tag>
54
  </docblock>
55
  </property>
56
+ <property final="false" static="true" visibility="private" line="1205" namespace="global" package="Media Library Assistant">
57
  <name>$query_parameters</name>
58
  <default><![CDATA[array()]]></default>
59
+ <docblock line="1192">
60
  <description><![CDATA[WP_Query filter "parameters"]]></description>
61
  <long-description><![CDATA[<p>This array defines parameters for the query's join, where and orderby filters.
62
  The parameters are set up in the _prepare_list_table_query function, and
63
  any further logic required to translate those values is contained in the filters.</p>
64
 
65
  <p>Array index values are: use_postmeta_view, postmeta_key, postmeta_value, patterns, detached, orderby, order, mla-metavalue, debug, s, mla_search_connector, mla_search_fields, sentence, exact</p>]]></long-description>
66
+ <tag line="1192" name="since" description="0.30"/>
67
+ <tag line="1192" name="var" description="" type="array">
68
  <type by_reference="false">array</type>
69
  </tag>
70
  </docblock>
71
  </property>
72
+ <property final="false" static="true" visibility="private" line="2491" namespace="global" package="Media Library Assistant">
73
  <name>$galleries</name>
74
  <default><![CDATA[null]]></default>
75
+ <docblock line="2472">
76
  <description><![CDATA[Objects containing [gallery] shortcodes]]></description>
77
  <long-description><![CDATA[<p>This array contains all of the objects containing one or more [gallery] shortcodes
78
  and array(s) of which attachments each [gallery] contains. The arrays are built once
85
  ['galleries'] array of [gallery] entries numbered from one (1), containing:
86
  galleries[X]['query'] contains a string with the arguments of the [gallery],
87
  galleries[X]['results'] contains an array ( ID ) of post_ids for the objects in the gallery.</p>]]></long-description>
88
+ <tag line="2472" name="since" description="0.70"/>
89
+ <tag line="2472" name="var" description="" type="array">
90
  <type by_reference="false">array</type>
91
  </tag>
92
  </docblock>
93
  </property>
94
+ <property final="false" static="true" visibility="private" line="2504" namespace="global" package="Media Library Assistant">
95
  <name>$mla_galleries</name>
96
  <default><![CDATA[null]]></default>
97
+ <docblock line="2493">
98
  <description><![CDATA[Objects containing [mla_gallery] shortcodes]]></description>
99
  <long-description><![CDATA[<p>This array contains all of the objects containing one or more [mla_gallery] shortcodes
100
  and array(s) of which attachments each [mla_gallery] contains. The arrays are built once
101
  each page load and cached for subsequent calls.</p>]]></long-description>
102
+ <tag line="2493" name="since" description="0.70"/>
103
+ <tag line="2493" name="var" description="" type="array">
104
  <type by_reference="false">array</type>
105
  </tag>
106
  </docblock>
107
  </property>
108
+ <property final="false" static="true" visibility="private" line="2695" namespace="global" package="Media Library Assistant">
109
  <name>$pdf_indirect_objects</name>
110
  <default><![CDATA[NULL]]></default>
111
+ <docblock line="2684">
112
  <description><![CDATA[Array of PDF indirect objects]]></description>
113
  <long-description><![CDATA[<p>This array contains all of the indirect object offsets and lengths.
114
  The array key is ( object ID * 1000 ) + object generation.
115
  The array value is array( number, generation, start, optional /length )</p>]]></long-description>
116
+ <tag line="2684" name="since" description="1.50"/>
117
+ <tag line="2684" name="var" description="" type="array">
118
  <type by_reference="false">array</type>
119
  </tag>
120
  </docblock>
121
  </property>
122
+ <property final="false" static="true" visibility="private" line="3806" namespace="global" package="Media Library Assistant">
123
  <name>$utf8_chars</name>
124
  <default><![CDATA[array("\xC2\x80", "\xC2\x81", "\xC2\x82", "\xC2\x83", "\xC2\x84", "\xC2\x85", "\xC2\x86", "\xC2\x87", "\xC2\x88", "\xC2\x89", "\xC2\x8A", "\xC2\x8B", "\xC2\x8C", "\xC2\x8D", "\xC2\x8E", "\xC2\x8F", "\xC2\x90", "\xC2\x91", "\xC2\x92", "\xC2\x93", "\xC2\x94", "\xC2\x95", "\xC2\x96", "\xC2\x97", "\xC2\x98", "\xC2\x99", "\xC2\x9A", "\xC2\x9B", "\xC2\x9C", "\xC2\x9D", "\xC2\x9E", "\xC2\x9F", "\xC2\xA0", "\xC2\xA1", "\xC2\xA2", "\xC2\xA3", "\xC2\xA4", "\xC2\xA5", "\xC2\xA6", "\xC2\xA7", "\xC2\xA8", "\xC2\xA9", "\xC2\xAA", "\xC2\xAB", "\xC2\xAC", "\xC2\xAD", "\xC2\xAE", "\xC2\xAF", "\xC2\xB0", "\xC2\xB1", "\xC2\xB2", "\xC2\xB3", "\xC2\xB4", "\xC2\xB5", "\xC2\xB6", "\xC2\xB7", "\xC2\xB8", "\xC2\xB9", "\xC2\xBA", "\xC2\xBB", "\xC2\xBC", "\xC2\xBD", "\xC2\xBE", "\xC2\xBF", "\xC3\x80", "\xC3\x81", "\xC3\x82", "\xC3\x83", "\xC3\x84", "\xC3\x85", "\xC3\x86", "\xC3\x87", "\xC3\x88", "\xC3\x89", "\xC3\x8A", "\xC3\x8B", "\xC3\x8C", "\xC3\x8D", "\xC3\x8E", "\xC3\x8F", "\xC3\x90", "\xC3\x91", "\xC3\x92", "\xC3\x93", "\xC3\x94", "\xC3\x95", "\xC3\x96", "\xC3\x97", "\xC3\x98", "\xC3\x99", "\xC3\x9A", "\xC3\x9B", "\xC3\x9C", "\xC3\x9D", "\xC3\x9E", "\xC3\x9F", "\xC3\xA0", "\xC3\xA1", "\xC3\xA2", "\xC3\xA3", "\xC3\xA4", "\xC3\xA5", "\xC3\xA6", "\xC3\xA7", "\xC3\xA8", "\xC3\xA9", "\xC3\xAA", "\xC3\xAB", "\xC3\xAC", "\xC3\xAD", "\xC3\xAE", "\xC3\xAF", "\xC3\xB0", "\xC3\xB1", "\xC3\xB2", "\xC3\xB3", "\xC3\xB4", "\xC3\xB5", "\xC3\xB6", "\xC3\xB7", "\xC3\xB8", "\xC3\xB9", "\xC3\xBA", "\xC3\xBB", "\xC3\xBC", "\xC3\xBD", "\xC3\xBE", "\xC3\xBF")]]></default>
125
+ <docblock line="3799">
126
  <description><![CDATA[UTF-8 replacements for invalid SQL characters]]></description>
127
  <long-description><![CDATA[]]></long-description>
128
+ <tag line="3799" name="since" description="1.41"/>
129
+ <tag line="3799" name="var" description="" type="array">
130
  <type by_reference="false">array</type>
131
  </tag>
132
  </docblock>
133
  </property>
134
+ <property final="false" static="true" visibility="private" line="3866" namespace="global" package="Media Library Assistant">
135
  <name>$mla_iptc_records</name>
136
  <default><![CDATA[array("1#000" => "Model Version", "1#005" => "Destination", "1#020" => "File Format", "1#022" => "File Format Version", "1#030" => "Service Identifier", "1#040" => "Envelope Number", "1#050" => "Product ID", "1#060" => "Envelope Priority", "1#070" => "Date Sent", "1#080" => "Time Sent", "1#090" => "Coded Character Set", "1#100" => "UNO", "1#120" => "ARM Identifier", "1#122" => "ARM Version", "2#000" => "Record Version", "2#003" => "Object Type Reference", "2#004" => "Object Attribute Reference", "2#005" => "Object Name", "2#007" => "Edit Status", "2#008" => "Editorial Update", "2#010" => "Urgency", "2#012" => "Subject Reference", "2#015" => "Category", "2#020" => "Supplemental Category", "2#022" => "Fixture Identifier", "2#025" => "Keywords", "2#026" => "Content Location Code", "2#027" => "Content Location Name", "2#030" => "Release Date", "2#035" => "Release Time", "2#037" => "Expiration Date", "2#038" => "Expiration Time", "2#040" => "Special Instructions", "2#042" => "Action Advised", "2#045" => "Reference Service", "2#047" => "Reference Date", "2#050" => "Reference Number", "2#055" => "Date Created", "2#060" => "Time Created", "2#062" => "Digital Creation Date", "2#063" => "Digital Creation Time", "2#065" => "Originating Program", "2#070" => "Program Version", "2#075" => "Object Cycle", "2#080" => "By-line", "2#085" => "By-line Title", "2#090" => "City", "2#092" => "Sub-location", "2#095" => "Province or State", "2#100" => "Country or Primary Location Code", "2#101" => "Country or Primary Location Name", "2#103" => "Original Transmission Reference", "2#105" => "Headline", "2#110" => "Credit", "2#115" => "Source", "2#116" => "Copyright Notice", "2#118" => "Contact", "2#120" => "Caption or Abstract", "2#122" => "Caption Writer or Editor", "2#125" => "Rasterized Caption", "2#130" => "Image Type", "2#131" => "Image Orientation", "2#135" => "Language Identifier", "2#150" => "Audio Type", "2#151" => "Audio Sampling Rate", "2#152" => "Audio Sampling Resolution", "2#153" => "Audio Duration", "2#154" => "Audio Outcue", "2#200" => "ObjectData Preview File Format", "2#201" => "ObjectData Preview File Format Version", "2#202" => "ObjectData Preview Data", "7#010" => "Size Mode", "7#020" => "Max Subfile Size", "7#090" => "ObjectData Size Announced", "7#095" => "Maximum ObjectData Size", "8#010" => "Subfile", "9#010" => "Confirmed ObjectData Size")]]></default>
137
+ <docblock line="3856">
138
  <description><![CDATA[IPTC Dataset identifiers and names]]></description>
139
  <long-description><![CDATA[<p>This array contains the identifiers and names of Datasets defined in
140
  the "IPTC-NAA Information Interchange Model Version No. 4.1".</p>]]></long-description>
141
+ <tag line="3856" name="since" description="0.90"/>
142
+ <tag line="3856" name="var" description="" type="array">
143
  <type by_reference="false">array</type>
144
  </tag>
145
  </docblock>
146
  </property>
147
+ <property final="false" static="true" visibility="public" line="3965" namespace="global" package="Media Library Assistant">
148
  <name>$mla_iptc_keys</name>
149
  <default><![CDATA[array('model-version' => '1#000', 'destination' => '1#005', 'file-format' => '1#020', 'file-format-version' => '1#022', 'service-identifier' => '1#030', 'envelope-number' => '1#040', 'product-id' => '1#050', 'envelope-priority' => '1#060', 'date-sent' => '1#070', 'time-sent' => '1#080', 'coded-character-set' => '1#090', 'uno' => '1#100', 'arm-identifier' => '1#120', 'arm-version' => '1#122', 'record-version' => '2#000', 'object-type-reference' => '2#003', 'object-attribute-reference' => '2#004', 'object-name' => '2#005', 'edit-status' => '2#007', 'editorial-update' => '2#008', 'urgency' => '2#010', 'subject-reference' => '2#012', 'category' => '2#015', 'supplemental-category' => '2#020', 'fixture-identifier' => '2#022', 'keywords' => '2#025', 'content-location-code' => '2#026', 'content-location-name' => '2#027', 'release-date' => '2#030', 'release-time' => '2#035', 'expiration-date' => '2#037', 'expiration-time' => '2#038', 'special-instructions' => '2#040', 'action-advised' => '2#042', 'reference-service' => '2#045', 'reference-date' => '2#047', 'reference-number' => '2#050', 'date-created' => '2#055', 'time-created' => '2#060', 'digital-creation-date' => '2#062', 'digital-creation-time' => '2#063', 'originating-program' => '2#065', 'program-version' => '2#070', 'object-cycle' => '2#075', 'by-line' => '2#080', 'by-line-title' => '2#085', 'city' => '2#090', 'sub-location' => '2#092', 'province-or-state' => '2#095', 'country-or-primary-location-code' => '2#100', 'country-or-primary-location-name' => '2#101', 'original-transmission-reference' => '2#103', 'headline' => '2#105', 'credit' => '2#110', 'source' => '2#115', 'copyright-notice' => '2#116', 'contact' => '2#118', 'caption-or-abstract' => '2#120', 'caption-writer-or-editor' => '2#122', 'rasterized-caption' => '2#125', 'image-type' => '2#130', 'image-orientation' => '2#131', 'language-identifier' => '2#135', 'audio-type' => '2#150', 'audio-sampling-rate' => '2#151', 'audio-sampling-resolution' => '2#152', 'audio-duration' => '2#153', 'audio-outcue' => '2#154', 'objectdata-preview-file-format' => '2#200', 'objectdata-preview-file-format-version' => '2#201', 'objectdata-preview-data' => '2#202', 'size-mode' => '7#010', 'max-subfile-size' => '7#020', 'objectdata-size-announced' => '7#090', 'maximum-objectdata-size' => '7#095', 'subfile' => '8#010', 'confirmed-objectdata-size' => '9#010')]]></default>
150
+ <docblock line="3955">
151
  <description><![CDATA[IPTC Dataset friendly name/slug and identifiers]]></description>
152
  <long-description><![CDATA[<p>This array contains the sanitized names and identifiers of Datasets defined in
153
  the "IPTC-NAA Information Interchange Model Version No. 4.1".</p>]]></long-description>
154
+ <tag line="3955" name="since" description="0.90"/>
155
+ <tag line="3955" name="var" description="" type="array">
156
  <type by_reference="false">array</type>
157
  </tag>
158
  </docblock>
159
  </property>
160
+ <property final="false" static="true" visibility="private" line="4064" namespace="global" package="Media Library Assistant">
161
  <name>$mla_iptc_descriptions</name>
162
  <default><![CDATA[array("1#000" => "2 octet binary IIM version number", "1#005" => "Max 1024 characters of Destination (ISO routing information); repeatable", "1#020" => "2 octet binary file format number, see IPTC-NAA V4 Appendix A", "1#022" => "2 octet binary file format version number", "1#030" => "Max 10 characters of Service Identifier and product", "1#040" => "8 Character Envelope Number", "1#050" => "Max 32 characters subset of provider's overall service; repeatable", "1#060" => "1 numeric character of envelope handling priority (not urgency)", "1#070" => "8 numeric characters of Date Sent by service - CCYYMMDD", "1#080" => "11 characters of Time Sent by service - HHMMSS±HHMM", "1#090" => "Max 32 characters of control functions, etc.", "1#100" => "14 to 80 characters of eternal, globally unique identification for objects", "1#120" => "2 octet binary Abstract Relationship Model Identifier", "1#122" => "2 octet binary Abstract Relationship Model Version", "2#000" => "2 octet binary Information Interchange Model, Part II version number", "2#003" => "3 to 67 Characters of Object Type Reference number and optional text", "2#004" => "3 to 67 Characters of Object Attribute Reference number and optional text; repeatable", "2#005" => "Max 64 characters of the object name or shorthand reference", "2#007" => "Max 64 characters of the status of the objectdata", "2#008" => "2 numeric characters of the type of update this object provides", "2#010" => "1 numeric character of the editorial urgency of content", "2#012" => "13 to 236 characters of a structured definition of the subject matter; repeatable", "2#015" => "Max 3 characters of the subject of the objectdata, DEPRECATED", "2#020" => "Max 32 characters (each) of further refinement of subject, DEPRECATED; repeatable", "2#022" => "Max 32 characters identifying recurring, predictable content", "2#025" => "Max 64 characters (each) of tags; repeatable", "2#026" => "3 characters of ISO3166 country code or IPTC-assigned code; repeatable", "2#027" => "Max 64 characters of publishable country/geographical location name; repeatable", "2#030" => "8 numeric characters of Release Date - CCYYMMDD", "2#035" => "11 characters of Release Time (earliest use) - HHMMSS±HHMM", "2#037" => "8 numeric characters of Expiration Date (latest use) - CCYYMDD", "2#038" => "11 characters of Expiration Time (latest use) - HHMMSS±HHMM", "2#040" => "Max 256 Characters of editorial instructions, e.g., embargoes and warnings", "2#042" => "2 numeric characters of type of action this object provides to a previous object", "2#045" => "Max 10 characters of the Service ID (1#030) of a prior envelope; repeatable", "2#047" => "8 numeric characters of prior envelope Reference Date (1#070) - CCYYMMDD; repeatable", "2#050" => "8 characters of prior envelope Reference Number (1#040); repeatable", "2#055" => "8 numeric characters of intellectual content Date Created - CCYYMMDD", "2#060" => "11 characters of intellectual content Time Created - HHMMSS±HHMM", "2#062" => "8 numeric characters of digital representation creation date - CCYYMMDD", "2#063" => "11 characters of digital representation creation time - HHMMSS±HHMM", "2#065" => "Max 32 characters of the program used to create the objectdata", "2#070" => "Program Version - Max 10 characters of the version of the program used to create the objectdata", "2#075" => "1 character where a=morning, p=evening, b=both", "2#080" => "Max 32 Characters of the name of the objectdata creator, e.g., the writer, photographer; repeatable", "2#085" => "Max 32 characters of the title of the objectdata creator; repeatable", "2#090" => "Max 32 Characters of the city of objectdata origin", "2#092" => "Max 32 Characters of the location within the city of objectdata origin", "2#095" => "Max 32 Characters of the objectdata origin Province or State", "2#100" => "3 characters of ISO3166 or IPTC-assigned code for Country of objectdata origin", "2#101" => "Max 64 characters of publishable country/geographical location name of objectdata origin", "2#103" => "Max 32 characters of a code representing the location of original transmission", "2#105" => "Max 256 Characters of a publishable entry providing a synopsis of the contents of the objectdata", "2#110" => "Max 32 Characters that identifies the provider of the objectdata (Vs the owner/creator)", "2#115" => "Max 32 Characters that identifies the original owner of the intellectual content", "2#116" => "Max 128 Characters that contains any necessary copyright notice", "2#118" => "Max 128 characters that identifies the person or organisation which can provide further background information; repeatable", "2#120" => "Max 2000 Characters of a textual description of the objectdata", "2#122" => "Max 32 Characters that the identifies the person involved in the writing, editing or correcting the objectdata or caption/abstract; repeatable", "2#125" => "7360 binary octets of the rasterized caption - 1 bit per pixel, 460x128-pixel image", "2#130" => "2 characters of color composition type and information", "2#131" => "1 alphabetic character indicating the image area layout - P=portrait, L=landscape, S=square", "2#135" => "2 or 3 aphabetic characters containing the major national language of the object, according to the ISO 639:1988 codes", "2#150" => "2 characters identifying monaural/stereo and exact type of audio content", "2#151" => "6 numeric characters representing the audio sampling rate in hertz (Hz)", "2#152" => "2 numeric characters representing the number of bits in each audio sample", "2#153" => "6 numeric characters of the Audio Duration - HHMMSS", "2#154" => "Max 64 characters of the content of the end of an audio objectdata", "2#200" => "2 octet binary file format of the ObjectData Preview", "2#201" => "2 octet binary particular version of the ObjectData Preview File Format", "2#202" => "Max 256000 binary octets containing the ObjectData Preview data", "7#010" => "1 numeric character - 0=objectdata size not known, 1=objectdata size known at beginning of transfer", "7#020" => "4 octet binary maximum subfile dataset(s) size", "7#090" => "4 octet binary objectdata size if known at beginning of transfer", "7#095" => "4 octet binary largest possible objectdata size", "8#010" => "Subfile DataSet containing the objectdata itself; repeatable", "9#010" => "4 octet binary total objectdata size")]]></default>
163
+ <docblock line="4054">
164
  <description><![CDATA[IPTC Dataset descriptions]]></description>
165
  <long-description><![CDATA[<p>This array contains the descriptions of Datasets defined in
166
  the "IPTC-NAA Information Interchange Model Version No. 4.1".</p>]]></long-description>
167
+ <tag line="4054" name="since" description="0.90"/>
168
+ <tag line="4054" name="var" description="" type="array">
169
  <type by_reference="false">array</type>
170
  </tag>
171
  </docblock>
172
  </property>
173
+ <property final="false" static="true" visibility="private" line="4163" namespace="global" package="Media Library Assistant">
174
  <name>$mla_iptc_formats</name>
175
  <default><![CDATA[array(0 => "No ObjectData", 1 => "IPTC-NAA Digital Newsphoto Parameter Record", 2 => "IPTC7901 Recommended Message Format", 3 => "Tagged Image File Format (Adobe/Aldus Image data)", 4 => "Illustrator (Adobe Graphics data)", 5 => "AppleSingle (Apple Computer Inc)", 6 => "NAA 89-3 (ANPA 1312)", 7 => "MacBinary II", 0 => "IPTC Unstructured Character Oriented File Format (UCOFF)", 0 => "United Press International ANPA 1312 variant", 10 => "United Press International Down-Load Message", 11 => "JPEG File Interchange (JFIF)", 12 => "Photo-CD Image-Pac (Eastman Kodak)", 13 => "Microsoft Bit Mapped Graphics File [*.BMP]", 14 => "Digital Audio File [*.WAV] (Microsoft & Creative Labs)", 15 => "Audio plus Moving Video [*.AVI] (Microsoft)", 16 => "PC DOS/Windows Executable Files [*.COM][*.EXE]", 17 => "Compressed Binary File [*.ZIP] (PKWare Inc)", 18 => "Audio Interchange File Format AIFF (Apple Computer Inc)", 19 => "RIFF Wave (Microsoft Corporation)", 20 => "Freehand (Macromedia/Aldus)", 21 => "Hypertext Markup Language - HTML (The Internet Society)", 22 => "MPEG 2 Audio Layer 2 (Musicom), ISO/IEC", 23 => "MPEG 2 Audio Layer 3, ISO/IEC", 24 => "Portable Document File (*.PDF) Adobe", 25 => "News Industry Text Format (NITF)", 26 => "Tape Archive (*.TAR)", 27 => "Tidningarnas Telegrambyrå NITF version (TTNITF DTD)", 28 => "Ritzaus Bureau NITF version (RBNITF DTD)", 29 => "Corel Draw [*.CDR]")]]></default>
176
+ <docblock line="4153">
177
  <description><![CDATA[IPTC file format identifiers and descriptions]]></description>
178
  <long-description><![CDATA[<p>This array contains the file format identifiers and descriptions defined in
179
  the "IPTC-NAA Information Interchange Model Version No. 4.1" for dataset 1#020.</p>]]></long-description>
180
+ <tag line="4153" name="since" description="0.90"/>
181
+ <tag line="4153" name="var" description="" type="array">
182
  <type by_reference="false">array</type>
183
  </tag>
184
  </docblock>
185
  </property>
186
+ <property final="false" static="true" visibility="private" line="4206" namespace="global" package="Media Library Assistant">
187
  <name>$mla_iptc_image_types</name>
188
  <default><![CDATA[array("M" => "Monochrome", "Y" => "Yellow Component", "M" => "Magenta Component", "C" => "Cyan Component", "K" => "Black Component", "R" => "Red Component", "G" => "Green Component", "B" => "Blue Component", "T" => "Text Only", "F" => "Full colour composite, frame sequential", "L" => "Full colour composite, line sequential", "P" => "Full colour composite, pixel sequential", "S" => "Full colour composite, special interleaving")]]></default>
189
+ <docblock line="4196">
190
  <description><![CDATA[IPTC image type identifiers and descriptions]]></description>
191
  <long-description><![CDATA[<p>This array contains the image type identifiers and descriptions defined in
192
  the "IPTC-NAA Information Interchange Model Version No. 4.1" for dataset 2#130, octet 2.</p>]]></long-description>
193
+ <tag line="4196" name="since" description="0.90"/>
194
+ <tag line="4196" name="var" description="" type="array">
195
  <type by_reference="false">array</type>
196
  </tag>
197
  </docblock>
198
  </property>
199
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="43" package="Media Library Assistant">
200
  <name>initialize</name>
201
  <full_name>initialize</full_name>
202
+ <docblock line="38">
203
  <description><![CDATA[Initialization function, similar to __construct()]]></description>
204
  <long-description><![CDATA[]]></long-description>
205
+ <tag line="38" name="since" description="0.1"/>
206
  </docblock>
207
  </method>
208
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="70" package="Media Library Assistant">
209
  <name>mla_load_template</name>
210
  <full_name>mla_load_template</full_name>
211
+ <docblock line="52">
212
  <description><![CDATA[Load an HTML template from a file]]></description>
213
  <long-description><![CDATA[<p>Loads a template to a string or a multi-part template to an array.
214
  Multi-part templates are divided by comments of the form <!-- template="key" -->,
215
  where "key" becomes the key part of the array.</p>]]></long-description>
216
+ <tag line="52" name="since" description="0.1"/>
217
+ <tag line="52" name="param" description="Complete path and name of the template file, option name or the raw template" type="string" variable="$source">
218
  <type by_reference="false">string</type>
219
  </tag>
220
+ <tag line="52" name="param" description="Optional type of template source; 'path', 'file' (default), 'option', 'string'" type="string" variable="$type">
221
  <type by_reference="false">string</type>
222
  </tag>
223
+ <tag line="52" name="return" description="string for files that do not contain template divider comments, array for files containing template divider comments, false if file or option does not exist, NULL if file could not be loaded." type="string|array|false|NULL">
224
  <type by_reference="false">string</type>
225
  <type by_reference="false">array</type>
226
  <type by_reference="false">false</type>
227
  <type by_reference="false">NULL</type>
228
  </tag>
229
  </docblock>
230
+ <argument line="70">
231
  <name>$source</name>
232
  <default><![CDATA[]]></default>
233
  <type/>
234
  </argument>
235
+ <argument line="70">
236
  <name>$type</name>
237
  <default><![CDATA['file']]></default>
238
  <type/>
239
  </argument>
240
  </method>
241
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="190" package="Media Library Assistant">
242
  <name>_find_template_substring</name>
243
  <full_name>_find_template_substring</full_name>
244
+ <docblock line="181">
245
  <description><![CDATA[Find a complete template, balancing opening and closing delimiters]]></description>
246
  <long-description><![CDATA[]]></long-description>
247
+ <tag line="181" name="since" description="1.50"/>
248
+ <tag line="181" name="param" description="A string possibly starting with '[+template:'" type="string" variable="$tpl">
249
  <type by_reference="false">string</type>
250
  </tag>
251
+ <tag line="181" name="return" description="'' or template string starting with '[+template:' and ending with the matching '+]'" type="string">
252
  <type by_reference="false">string</type>
253
  </tag>
254
  </docblock>
255
+ <argument line="190">
256
  <name>$tpl</name>
257
  <default><![CDATA[]]></default>
258
  <type/>
259
  </argument>
260
  </method>
261
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="237" package="Media Library Assistant">
262
  <name>mla_parse_array_template</name>
263
  <full_name>mla_parse_array_template</full_name>
264
+ <docblock line="224">
265
  <description><![CDATA[Expand a template, replacing placeholders with their values]]></description>
266
  <long-description><![CDATA[<p>Will return an array of values if one or more of the placeholders returns an array.</p>]]></long-description>
267
+ <tag line="224" name="since" description="1.50"/>
268
+ <tag line="224" name="param" description="A formatting string containing [+placeholders+]" type="string" variable="$tpl">
269
  <type by_reference="false">string</type>
270
  </tag>
271
+ <tag line="224" name="param" description="An associative array containing keys and values e.g. array('key' =&gt; 'value')" type="array" variable="$markup_values">
272
  <type by_reference="false">array</type>
273
  </tag>
274
+ <tag line="224" name="return" description="string or array, depending on placeholder values. Placeholders corresponding to the keys of the markup_values will be replaced with their values." type="mixed">
275
  <type by_reference="false">mixed</type>
276
  </tag>
277
  </docblock>
278
+ <argument line="237">
279
  <name>$tpl</name>
280
  <default><![CDATA[]]></default>
281
  <type/>
282
  </argument>
283
+ <argument line="237">
284
  <name>$markup_values</name>
285
  <default><![CDATA[]]></default>
286
  <type/>
287
  </argument>
288
  </method>
289
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="329" package="Media Library Assistant">
290
  <name>mla_parse_template</name>
291
  <full_name>mla_parse_template</full_name>
292
+ <docblock line="317">
293
  <description><![CDATA[Expand a template, replacing placeholders with their values]]></description>
294
  <long-description><![CDATA[<p>A simple parsing function for basic templating.</p>]]></long-description>
295
+ <tag line="317" name="since" description="0.1"/>
296
+ <tag line="317" name="param" description="A formatting string containing [+placeholders+]" type="string" variable="$tpl">
297
  <type by_reference="false">string</type>
298
  </tag>
299
+ <tag line="317" name="param" description="An associative array containing keys and values e.g. array('key' =&gt; 'value')" type="array" variable="$markup_values">
300
  <type by_reference="false">array</type>
301
  </tag>
302
+ <tag line="317" name="return" description="Placeholders corresponding to the keys of the markup_values will be replaced with their values." type="\strng">
303
  <type by_reference="false">\strng</type>
304
  </tag>
305
  </docblock>
306
+ <argument line="329">
307
  <name>$tpl</name>
308
  <default><![CDATA[]]></default>
309
  <type/>
310
  </argument>
311
+ <argument line="329">
312
  <name>$markup_values</name>
313
  <default><![CDATA[]]></default>
314
  <type/>
315
  </argument>
316
  </method>
317
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="381" package="Media Library Assistant">
318
  <name>_find_test_substring</name>
319
  <full_name>_find_test_substring</full_name>
320
+ <docblock line="372">
321
  <description><![CDATA[Find a complete (test) element, balancing opening and closing delimiters]]></description>
322
  <long-description><![CDATA[]]></long-description>
323
+ <tag line="372" name="since" description="1.50"/>
324
+ <tag line="372" name="param" description="A string possibly starting with '('" type="string" variable="$tpl">
325
  <type by_reference="false">string</type>
326
  </tag>
327
+ <tag line="372" name="return" description="'' or template string starting with '(' and ending with the matching ')'" type="string">
328
  <type by_reference="false">string</type>
329
  </tag>
330
  </docblock>
331
+ <argument line="381">
332
  <name>$tpl</name>
333
  <default><![CDATA[]]></default>
334
  <type/>
335
  </argument>
336
  </method>
337
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="423" package="Media Library Assistant">
338
  <name>_parse_field_level_template</name>
339
  <full_name>_parse_field_level_template</full_name>
340
+ <docblock line="414">
341
  <description><![CDATA[Convert field-level "template:" string into its component parts]]></description>
342
  <long-description><![CDATA[]]></long-description>
343
+ <tag line="414" name="since" description="1.50"/>
344
+ <tag line="414" name="param" description="Template content with string, test and choice elements" type="string" variable="$tpl">
345
  <type by_reference="false">string</type>
346
  </tag>
347
+ <tag line="414" name="return" description="( node =&gt; array( type =&gt; &quot;string | test | choice | template&quot;, length =&gt; bytes, value =&gt; string | node(s) ) )" type="array">
348
  <type by_reference="false">array</type>
349
  </tag>
350
  </docblock>
351
+ <argument line="423">
352
  <name>$tpl</name>
353
  <default><![CDATA[]]></default>
354
  <type/>
355
  </argument>
356
  </method>
357
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="572" package="Media Library Assistant">
358
  <name>_evaluate_template_array_node</name>
359
  <full_name>_evaluate_template_array_node</full_name>
360
+ <docblock line="560">
361
  <description><![CDATA[Analyze a field-level "template:" element, expanding Field-level Markup Substitution Parameters]]></description>
362
  <long-description><![CDATA[<p>Will return an array of values if one or more of the placeholders returns an array.</p>]]></long-description>
363
+ <tag line="560" name="since" description="1.50"/>
364
+ <tag line="560" name="param" description="A field-level template element node" type="array" variable="$node">
365
  <type by_reference="false">array</type>
366
  </tag>
367
+ <tag line="560" name="param" description="An array of markup substitution values" type="array" variable="$markup_values">
368
  <type by_reference="false">array</type>
369
  </tag>
370
+ <tag line="560" name="return" description="string or array, depending on placeholder values. Placeholders corresponding to the keys of the markup_values will be replaced with their values." type="mixed">
371
  <type by_reference="false">mixed</type>
372
  </tag>
373
  </docblock>
374
+ <argument line="572">
375
  <name>$node</name>
376
  <default><![CDATA[]]></default>
377
  <type/>
378
  </argument>
379
+ <argument line="572">
380
  <name>$markup_values</name>
381
  <default><![CDATA[array()]]></default>
382
  <type/>
383
  </argument>
384
  </method>
385
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="654" package="Media Library Assistant">
386
  <name>_evaluate_template_node</name>
387
  <full_name>_evaluate_template_node</full_name>
388
+ <docblock line="644">
389
  <description><![CDATA[Analyze a field-level "template:" element, expanding Field-level Markup Substitution Parameters]]></description>
390
  <long-description><![CDATA[]]></long-description>
391
+ <tag line="644" name="since" description="1.50"/>
392
+ <tag line="644" name="param" description="A field-level template element node" type="array" variable="$node">
393
  <type by_reference="false">array</type>
394
  </tag>
395
+ <tag line="644" name="param" description="An array of markup substitution values" type="array" variable="$markup_values">
396
  <type by_reference="false">array</type>
397
  </tag>
398
+ <tag line="644" name="return" description="String with expanded values, if any" type="string">
399
  <type by_reference="false">string</type>
400
  </tag>
401
  </docblock>
402
+ <argument line="654">
403
  <name>$node</name>
404
  <default><![CDATA[]]></default>
405
  <type/>
406
  </argument>
407
+ <argument line="654">
408
  <name>$markup_values</name>
409
  <default><![CDATA[array()]]></default>
410
  <type/>
411
  </argument>
412
  </method>
413
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="717" package="Media Library Assistant">
414
  <name>_expand_field_level_template</name>
415
  <full_name>_expand_field_level_template</full_name>
416
+ <docblock line="706">
417
  <description><![CDATA[Analyze a field-level "template:" element, expanding Field-level Markup Substitution Parameters]]></description>
418
  <long-description><![CDATA[]]></long-description>
419
+ <tag line="706" name="since" description="1.50"/>
420
+ <tag line="706" name="param" description="A formatting string containing [+placeholders+]" type="string" variable="$tpl">
421
  <type by_reference="false">string</type>
422
  </tag>
423
+ <tag line="706" name="param" description="An array of markup substitution values" type="array" variable="$markup_values">
424
  <type by_reference="false">array</type>
425
  </tag>
426
+ <tag line="706" name="param" description="True to return array value(s), false to return a string" type="boolean" variable="$return_arrays">
427
  <type by_reference="false">boolean</type>
428
  </tag>
429
+ <tag line="706" name="return" description="Element with expanded string/array values, if any" type="mixed">
430
  <type by_reference="false">mixed</type>
431
  </tag>
432
  </docblock>
433
+ <argument line="717">
434
  <name>$tpl</name>
435
  <default><![CDATA[]]></default>
436
  <type/>
437
  </argument>
438
+ <argument line="717">
439
  <name>$markup_values</name>
440
  <default><![CDATA[array()]]></default>
441
  <type/>
442
  </argument>
443
+ <argument line="717">
444
  <name>$return_arrays</name>
445
  <default><![CDATA[false]]></default>
446
  <type/>
447
  </argument>
448
  </method>
449
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="762" package="Media Library Assistant">
450
  <name>_process_field_level_array</name>
451
  <full_name>_process_field_level_array</full_name>
452
+ <docblock line="751">
453
  <description><![CDATA[Process an markup field array value according to the supplied data-format option]]></description>
454
  <long-description><![CDATA[]]></long-description>
455
+ <tag line="751" name="since" description="1.50"/>
456
+ <tag line="751" name="param" description="an array of scalar values" type="array" variable="$record">
457
  <type by_reference="false">array</type>
458
  </tag>
459
+ <tag line="751" name="param" description="data option 'text'|'single'|'export'|'array'|'multi'" type="string" variable="$option">
460
  <type by_reference="false">string</type>
461
  </tag>
462
+ <tag line="751" name="param" description="Optional: for option 'multi', retain existing values" type="boolean" variable="$keep_existing">
463
  <type by_reference="false">boolean</type>
464
  </tag>
465
+ <tag line="751" name="return" description="( parameter =&gt; value ) for all field-level parameters and anything in $markup_values" type="array">
466
  <type by_reference="false">array</type>
467
  </tag>
468
  </docblock>
469
+ <argument line="762">
470
  <name>$record</name>
471
  <default><![CDATA[]]></default>
472
  <type/>
473
  </argument>
474
+ <argument line="762">
475
  <name>$option</name>
476
  <default><![CDATA['text']]></default>
477
  <type/>
478
  </argument>
479
+ <argument line="762">
480
  <name>$keep_existing</name>
481
  <default><![CDATA[false]]></default>
482
  <type/>
483
  </argument>
484
  </method>
485
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="806" package="Media Library Assistant">
486
  <name>mla_expand_field_level_parameters</name>
487
  <full_name>mla_expand_field_level_parameters</full_name>
488
+ <docblock line="788">
489
  <description><![CDATA[Analyze a template, expanding Field-level Markup Substitution Parameters]]></description>
490
  <long-description><![CDATA[<p>Field-level parameters must have one of the following prefix values:
491
  template, request, query, custom, terms, meta, iptc, exif, pdf.
492
  All but request and query require an attachment ID.</p>]]></long-description>
493
+ <tag line="788" name="since" description="1.50"/>
494
+ <tag line="788" name="param" description="A formatting string containing [+placeholders+]" type="string" variable="$tpl">
495
  <type by_reference="false">string</type>
496
  </tag>
497
+ <tag line="788" name="param" description="Optional: an array of values from the query, if any, e.g. shortcode parameters" type="array" variable="$query">
498
  <type by_reference="false">array</type>
499
  </tag>
500
+ <tag line="788" name="param" description="Optional: an array of values to add to the returned array" type="array" variable="$markup_values">
501
  <type by_reference="false">array</type>
502
  </tag>
503
+ <tag line="788" name="param" description="Optional: attachment ID for attachment-specific placeholders" type="integer" variable="$post_id">
504
  <type by_reference="false">integer</type>
505
  </tag>
506
+ <tag line="788" name="param" description="Optional: for option 'multi', retain existing values" type="boolean" variable="$keep_existing">
507
  <type by_reference="false">boolean</type>
508
  </tag>
509
+ <tag line="788" name="param" description="Optional: default option value" type="string" variable="$default_option">
510
  <type by_reference="false">string</type>
511
  </tag>
512
+ <tag line="788" name="return" description="( parameter =&gt; value ) for all field-level parameters and anything in $markup_values" type="array">
513
  <type by_reference="false">array</type>
514
  </tag>
515
  </docblock>
516
+ <argument line="806">
517
  <name>$tpl</name>
518
  <default><![CDATA[]]></default>
519
  <type/>
520
  </argument>
521
+ <argument line="806">
522
  <name>$query</name>
523
  <default><![CDATA[NULL]]></default>
524
  <type/>
525
  </argument>
526
+ <argument line="806">
527
  <name>$markup_values</name>
528
  <default><![CDATA[array()]]></default>
529
  <type/>
530
  </argument>
531
+ <argument line="806">
532
  <name>$post_id</name>
533
  <default><![CDATA[0]]></default>
534
  <type/>
535
  </argument>
536
+ <argument line="806">
537
  <name>$keep_existing</name>
538
  <default><![CDATA[false]]></default>
539
  <type/>
540
  </argument>
541
+ <argument line="806">
542
  <name>$default_option</name>
543
  <default><![CDATA['text']]></default>
544
  <type/>
545
  </argument>
546
  </method>
547
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1022" package="Media Library Assistant">
548
  <name>mla_get_template_placeholders</name>
549
  <full_name>mla_get_template_placeholders</full_name>
550
+ <docblock line="1011">
551
  <description><![CDATA[Analyze a template, returning an array of the placeholders it contains]]></description>
552
  <long-description><![CDATA[]]></long-description>
553
+ <tag line="1011" name="since" description="0.90"/>
554
+ <tag line="1011" name="param" description="A formatting string containing [+placeholders+]" type="string" variable="$tpl">
555
  <type by_reference="false">string</type>
556
  </tag>
557
+ <tag line="1011" name="param" description="Optional: default option value" type="string" variable="$default_option">
558
  <type by_reference="false">string</type>
559
  </tag>
560
+ <tag line="1011" name="return" description="Placeholder information: each entry is an array with ['prefix'] =&gt; string, ['value'] =&gt; string, ['option'] =&gt; string 'text'|single'|'export'|'array'|'multi'" type="array">
561
  <type by_reference="false">array</type>
562
  </tag>
563
  </docblock>
564
+ <argument line="1022">
565
  <name>$tpl</name>
566
  <default><![CDATA[]]></default>
567
  <type/>
568
  </argument>
569
+ <argument line="1022">
570
  <name>$default_option</name>
571
  <default><![CDATA['text']]></default>
572
  <type/>
573
  </argument>
574
  </method>
575
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1112" package="Media Library Assistant">
576
  <name>mla_count_list_table_items</name>
577
  <full_name>mla_count_list_table_items</full_name>
578
+ <docblock line="1101">
579
  <description><![CDATA[Get the total number of attachment posts]]></description>
580
  <long-description><![CDATA[]]></long-description>
581
+ <tag line="1101" name="since" description="0.30"/>
582
+ <tag line="1101" name="param" description="Query variables, e.g., from $_REQUEST" type="array" variable="$request">
583
  <type by_reference="false">array</type>
584
  </tag>
585
+ <tag line="1101" name="param" description="(optional) number of rows to skip over to reach desired page" type="int" variable="$offset">
586
  <type by_reference="false">int</type>
587
  </tag>
588
+ <tag line="1101" name="param" description="(optional) number of rows on each page" type="int" variable="$count">
589
  <type by_reference="false">int</type>
590
  </tag>
591
+ <tag line="1101" name="return" description="Number of attachment posts" type="integer">
592
  <type by_reference="false">integer</type>
593
  </tag>
594
  </docblock>
595
+ <argument line="1112">
596
  <name>$request</name>
597
  <default><![CDATA[]]></default>
598
  <type/>
599
  </argument>
600
+ <argument line="1112">
601
  <name>$offset</name>
602
  <default><![CDATA[NULL]]></default>
603
  <type/>
604
  </argument>
605
+ <argument line="1112">
606
  <name>$count</name>
607
  <default><![CDATA[NULL]]></default>
608
  <type/>
609
  </argument>
610
  </method>
611
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1141" package="Media Library Assistant">
612
  <name>mla_query_list_table_items</name>
613
  <full_name>mla_query_list_table_items</full_name>
614
+ <docblock line="1127">
615
  <description><![CDATA[Retrieve attachment objects for list table display]]></description>
616
  <long-description><![CDATA[<p>Supports prepare_items in class-mla-list-table.php.
617
  Modeled after wp_edit_attachments_query in wp-admin/post.php</p>]]></long-description>
618
+ <tag line="1127" name="since" description="0.1"/>
619
+ <tag line="1127" name="param" description="query parameters from web page, usually found in $_REQUEST" type="array" variable="$request">
620
  <type by_reference="false">array</type>
621
  </tag>
622
+ <tag line="1127" name="param" description="number of rows to skip over to reach desired page" type="int" variable="$offset">
623
  <type by_reference="false">int</type>
624
  </tag>
625
+ <tag line="1127" name="param" description="number of rows on each page" type="int" variable="$count">
626
  <type by_reference="false">int</type>
627
  </tag>
628
+ <tag line="1127" name="return" description="attachment objects (posts) including parent data, meta data and references" type="array">
629
  <type by_reference="false">array</type>
630
  </tag>
631
  </docblock>
632
+ <argument line="1141">
633
  <name>$request</name>
634
  <default><![CDATA[]]></default>
635
  <type/>
636
  </argument>
637
+ <argument line="1141">
638
  <name>$offset</name>
639
  <default><![CDATA[]]></default>
640
  <type/>
641
  </argument>
642
+ <argument line="1141">
643
  <name>$count</name>
644
  <default><![CDATA[]]></default>
645
  <type/>
646
  </argument>
647
  </method>
648
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1187" package="Media Library Assistant">
649
  <name>mla_query_media_modal_items</name>
650
  <full_name>mla_query_media_modal_items</full_name>
651
+ <docblock line="1174">
652
  <description><![CDATA[Retrieve attachment objects for the WordPress Media Manager]]></description>
653
  <long-description><![CDATA[<p>Supports month-year and taxonomy-term filters as well as the enhanced search box</p>]]></long-description>
654
+ <tag line="1174" name="since" description="1.20"/>
655
+ <tag line="1174" name="param" description="query parameters from Media Manager" type="array" variable="$request">
656
  <type by_reference="false">array</type>
657
  </tag>
658
+ <tag line="1174" name="param" description="number of rows to skip over to reach desired page" type="int" variable="$offset">
659
  <type by_reference="false">int</type>
660
  </tag>
661
+ <tag line="1174" name="param" description="number of rows on each page" type="int" variable="$count">
662
  <type by_reference="false">int</type>
663
  </tag>
664
+ <tag line="1174" name="return" description="attachment objects (posts)" type="array">
665
  <type by_reference="false">array</type>
666
  </tag>
667
  </docblock>
668
+ <argument line="1187">
669
  <name>$request</name>
670
  <default><![CDATA[]]></default>
671
  <type/>
672
  </argument>
673
+ <argument line="1187">
674
  <name>$offset</name>
675
  <default><![CDATA[]]></default>
676
  <type/>
677
  </argument>
678
+ <argument line="1187">
679
  <name>$count</name>
680
  <default><![CDATA[]]></default>
681
  <type/>
682
  </argument>
683
  </method>
684
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="1221" package="Media Library Assistant">
685
  <name>_prepare_list_table_query</name>
686
  <full_name>_prepare_list_table_query</full_name>
687
+ <docblock line="1207">
688
  <description><![CDATA[Sanitize and expand query arguments from request variables]]></description>
689
  <long-description><![CDATA[<p>Prepare the arguments for WP_Query.
690
  Modeled after wp_edit_attachments_query in wp-admin/post.php</p>]]></long-description>
691
+ <tag line="1207" name="since" description="0.1"/>
692
+ <tag line="1207" name="param" description="query parameters from web page, usually found in $_REQUEST" type="array" variable="$raw_request">
693
  <type by_reference="false">array</type>
694
  </tag>
695
+ <tag line="1207" name="param" description="Optional number of rows (default 0) to skip over to reach desired page" type="int" variable="$offset">
696
  <type by_reference="false">int</type>
697
  </tag>
698
+ <tag line="1207" name="param" description="Optional number of rows on each page (0 = all rows, default)" type="int" variable="$count">
699
  <type by_reference="false">int</type>
700
  </tag>
701
+ <tag line="1207" name="return" description="revised arguments suitable for WP_Query" type="array">
702
  <type by_reference="false">array</type>
703
  </tag>
704
  </docblock>
705
+ <argument line="1221">
706
  <name>$raw_request</name>
707
  <default><![CDATA[]]></default>
708
  <type/>
709
  </argument>
710
+ <argument line="1221">
711
  <name>$offset</name>
712
  <default><![CDATA[0]]></default>
713
  <type/>
714
  </argument>
715
+ <argument line="1221">
716
  <name>$count</name>
717
  <default><![CDATA[0]]></default>
718
  <type/>
719
  </argument>
720
  </method>
721
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="1564" package="Media Library Assistant">
722
  <name>_execute_list_table_query</name>
723
  <full_name>_execute_list_table_query</full_name>
724
+ <docblock line="1555">
725
  <description><![CDATA[Add filters, run query, remove filters]]></description>
726
  <long-description><![CDATA[]]></long-description>
727
+ <tag line="1555" name="since" description="0.30"/>
728
+ <tag line="1555" name="param" description="query parameters from web page, usually found in $_REQUEST" type="array" variable="$request">
729
  <type by_reference="false">array</type>
730
  </tag>
731
+ <tag line="1555" name="return" description="WP_Query object with query results" type="object">
732
  <type by_reference="false">object</type>
733
  </tag>
734
  </docblock>
735
+ <argument line="1564">
736
  <name>$request</name>
737
  <default><![CDATA[]]></default>
738
  <type/>
739
  </argument>
740
  </method>
741
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1642" package="Media Library Assistant">
742
  <name>mla_search_terms_tidy</name>
743
  <full_name>mla_search_terms_tidy</full_name>
744
+ <docblock line="1631">
745
  <description><![CDATA[Replaces a WordPress function deprecated in v3.7]]></description>
746
  <long-description><![CDATA[<p>Defined as public because it's a callback from array_map().</p>]]></long-description>
747
+ <tag line="1631" name="since" description="1.51"/>
748
+ <tag line="1631" name="param" description="search term before modification" type="string" variable="$term">
749
  <type by_reference="false">string</type>
750
  </tag>
751
+ <tag line="1631" name="return" description="cleaned up search term" type="string">
752
  <type by_reference="false">string</type>
753
  </tag>
754
  </docblock>
755
+ <argument line="1642">
756
  <name>$term</name>
757
  <default><![CDATA[]]></default>
758
  <type/>
759
  </argument>
760
  </method>
761
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1658" package="Media Library Assistant">
762
  <name>mla_query_posts_search_filter</name>
763
  <full_name>mla_query_posts_search_filter</full_name>
764
+ <docblock line="1646">
765
  <description><![CDATA[Adds a keyword search to the WHERE clause, if required]]></description>
766
  <long-description><![CDATA[<p>Defined as public because it's a filter.</p>]]></long-description>
767
+ <tag line="1646" name="since" description="0.60"/>
768
+ <tag line="1646" name="param" description="query clause before modification" type="string" variable="$search_string">
769
  <type by_reference="false">string</type>
770
  </tag>
771
+ <tag line="1646" name="param" description="WP_Query object" type="object" variable="$query_object">
772
  <type by_reference="false">object</type>
773
  </tag>
774
+ <tag line="1646" name="return" description="query clause after keyword search addition" type="string">
775
  <type by_reference="false">string</type>
776
  </tag>
777
  </docblock>
778
+ <argument line="1658">
779
  <name>$search_string</name>
780
  <default><![CDATA[]]></default>
781
  <type/>
782
  </argument>
783
+ <argument line="1658">
784
  <name>$query_object</name>
785
  <default><![CDATA[]]></default>
786
  <type/>
787
  </argument>
788
  </method>
789
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1776" package="Media Library Assistant">
790
  <name>mla_query_posts_join_filter</name>
791
  <full_name>mla_query_posts_join_filter</full_name>
792
+ <docblock line="1765">
793
  <description><![CDATA[Adds a JOIN clause, if required, to handle sorting/searching on custom fields or ALT Text]]></description>
794
  <long-description><![CDATA[<p>Defined as public because it's a filter.</p>]]></long-description>
795
+ <tag line="1765" name="since" description="0.30"/>
796
+ <tag line="1765" name="param" description="query clause before modification" type="string" variable="$join_clause">
797
  <type by_reference="false">string</type>
798
  </tag>
799
+ <tag line="1765" name="return" description="query clause after &quot;LEFT JOIN view ON post_id&quot; item modification" type="string">
800
  <type by_reference="false">string</type>
801
  </tag>
802
  </docblock>
803
+ <argument line="1776">
804
  <name>$join_clause</name>
805
  <default><![CDATA[]]></default>
806
  <type/>
807
  </argument>
808
  </method>
809
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1803" package="Media Library Assistant">
810
  <name>mla_query_posts_where_filter</name>
811
  <full_name>mla_query_posts_where_filter</full_name>
812
+ <docblock line="1791">
813
  <description><![CDATA[Adds a WHERE clause for detached items]]></description>
814
  <long-description><![CDATA[<p>Modeled after _edit_attachments_query_helper in wp-admin/post.php.
815
  Defined as public because it's a filter.</p>]]></long-description>
816
+ <tag line="1791" name="since" description="0.1"/>
817
+ <tag line="1791" name="param" description="query clause before modification" type="string" variable="$where_clause">
818
  <type by_reference="false">string</type>
819
  </tag>
820
+ <tag line="1791" name="return" description="query clause after &quot;detached&quot; item modification" type="string">
821
  <type by_reference="false">string</type>
822
  </tag>
823
  </docblock>
824
+ <argument line="1803">
825
  <name>$where_clause</name>
826
  <default><![CDATA[]]></default>
827
  <type/>
828
  </argument>
829
  </method>
830
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1852" package="Media Library Assistant">
831
  <name>mla_query_posts_orderby_filter</name>
832
  <full_name>mla_query_posts_orderby_filter</full_name>
833
+ <docblock line="1840">
834
  <description><![CDATA[Adds a ORDERBY clause, if required]]></description>
835
  <long-description><![CDATA[<p>Expands the range of sort options because the logic in WP_Query is limited.
836
  Defined as public because it's a filter.</p>]]></long-description>
837
+ <tag line="1840" name="since" description="0.30"/>
838
+ <tag line="1840" name="param" description="query clause before modification" type="string" variable="$orderby_clause">
839
  <type by_reference="false">string</type>
840
  </tag>
841
+ <tag line="1840" name="return" description="updated query clause" type="string">
842
  <type by_reference="false">string</type>
843
  </tag>
844
  </docblock>
845
+ <argument line="1852">
846
  <name>$orderby_clause</name>
847
  <default><![CDATA[]]></default>
848
  <type/>
849
  </argument>
850
  </method>
851
+ <method final="false" abstract="false" static="false" visibility="public" namespace="global" line="1911" package="Media Library Assistant">
852
  <name>mla_get_attachment_by_id</name>
853
  <full_name>mla_get_attachment_by_id</full_name>
854
+ <docblock line="1899">
855
  <description><![CDATA[Retrieve an Attachment array given a $post_id]]></description>
856
  <long-description><![CDATA[<p>The (associative) array will contain every field that can be found in
857
  the posts and postmeta tables, and all references to the attachment.</p>]]></long-description>
858
+ <tag line="1899" name="since" description="0.1"/>
859
+ <tag line="1899" name="uses" description="\global\$post" refers="\global\$post"/>
860
+ <tag line="1899" name="param" description="The ID of the attachment post" type="int" variable="$post_id">
861
  <type by_reference="false">int</type>
862
  </tag>
863
+ <tag line="1899" name="return" description="NULL on failure else associative array" type="NULL|array">
864
  <type by_reference="false">NULL</type>
865
  <type by_reference="false">array</type>
866
  </tag>
867
  </docblock>
868
+ <argument line="1911">
869
  <name>$post_id</name>
870
  <default><![CDATA[]]></default>
871
  <type/>
872
  </argument>
873
  </method>
874
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="1967" package="Media Library Assistant">
875
  <name>mla_fetch_attachment_parent_data</name>
876
  <full_name>mla_fetch_attachment_parent_data</full_name>
877
+ <docblock line="1958">
878
  <description><![CDATA[Returns information about an attachment's parent, if found]]></description>
879
  <long-description><![CDATA[]]></long-description>
880
+ <tag line="1958" name="since" description="0.1"/>
881
+ <tag line="1958" name="param" description="post ID of attachment's parent, if any" type="int" variable="$parent_id">
882
  <type by_reference="false">int</type>
883
  </tag>
884
+ <tag line="1958" name="return" description="Parent information; post_date, post_title and post_type" type="array">
885
  <type by_reference="false">array</type>
886
  </tag>
887
  </docblock>
888
+ <argument line="1967">
889
  <name>$parent_id</name>
890
  <default><![CDATA[]]></default>
891
  <type/>
892
  </argument>
893
  </method>
894
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2006" package="Media Library Assistant">
895
  <name>_set_array_element</name>
896
  <full_name>_set_array_element</full_name>
897
+ <docblock line="1995">
898
  <description><![CDATA[Adds or replaces the value of a key in a possibly nested array structure]]></description>
899
  <long-description><![CDATA[]]></long-description>
900
+ <tag line="1995" name="since" description="1.51"/>
901
+ <tag line="1995" name="param" description="key value, e.g. array1.array2.element" type="string" variable="$needle">
902
  <type by_reference="false">string</type>
903
  </tag>
904
+ <tag line="1995" name="param" description="replacement value, string or array, by reference" type="mixed" variable="$value">
905
  <type by_reference="false">mixed</type>
906
  </tag>
907
+ <tag line="1995" name="param" description="PHP nested arrays, by reference" type="array" variable="$haystack">
908
  <type by_reference="false">array</type>
909
  </tag>
910
+ <tag line="1995" name="return" description="true if $needle element set, false if not" type="boolean">
911
  <type by_reference="false">boolean</type>
912
  </tag>
913
  </docblock>
914
+ <argument line="2006">
915
  <name>$needle</name>
916
  <default><![CDATA[]]></default>
917
  <type/>
918
  </argument>
919
+ <argument line="2006">
920
  <name>$value</name>
921
  <default><![CDATA[]]></default>
922
  <type/>
923
  </argument>
924
+ <argument line="2006">
925
  <name>$haystack</name>
926
  <default><![CDATA[]]></default>
927
  <type/>
928
  </argument>
929
  </method>
930
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2040" package="Media Library Assistant">
931
  <name>_unset_array_element</name>
932
  <full_name>_unset_array_element</full_name>
933
+ <docblock line="2030">
934
  <description><![CDATA[Deletes the value of a key in a possibly nested array structure]]></description>
935
  <long-description><![CDATA[]]></long-description>
936
+ <tag line="2030" name="since" description="1.51"/>
937
+ <tag line="2030" name="param" description="key value, e.g. array1.array2.element" type="string" variable="$needle">
938
  <type by_reference="false">string</type>
939
  </tag>
940
+ <tag line="2030" name="param" description="PHP nested arrays, by reference" type="array" variable="$haystack">
941
  <type by_reference="false">array</type>
942
  </tag>
943
+ <tag line="2030" name="return" description="true if $needle element found, false if not" type="boolean">
944
  <type by_reference="false">boolean</type>
945
  </tag>
946
  </docblock>
947
+ <argument line="2040">
948
  <name>$needle</name>
949
  <default><![CDATA[]]></default>
950
  <type/>
951
  </argument>
952
+ <argument line="2040">
953
  <name>$haystack</name>
954
  <default><![CDATA[]]></default>
955
  <type/>
956
  </argument>
957
  </method>
958
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="2075" package="Media Library Assistant">
959
  <name>mla_find_array_element</name>
960
  <full_name>mla_find_array_element</full_name>
961
+ <docblock line="2060">
962
  <description><![CDATA[Finds the value of a key in a possibly nested array structure]]></description>
963
  <long-description><![CDATA[<p>Used primarily to extract fields from the _wp_attachment_metadata custom field.
964
  Could also be used with the ID3 metadata exposed in WordPress 3.6 and later.</p>]]></long-description>
965
+ <tag line="2060" name="since" description="1.30"/>
966
+ <tag line="2060" name="param" description="key value, e.g. array1.array2.element" type="string" variable="$needle">
967
  <type by_reference="false">string</type>
968
  </tag>
969
+ <tag line="2060" name="param" description="PHP nested arrays" type="array" variable="$haystack">
970
  <type by_reference="false">array</type>
971
  </tag>
972
+ <tag line="2060" name="param" description="data option 'text'|'single'|'export'|'array'|'multi'" type="string" variable="$option">
973
  <type by_reference="false">string</type>
974
  </tag>
975
+ <tag line="2060" name="param" description="keep existing values - for 'multi' option" type="boolean" variable="$keep_existing">
976
  <type by_reference="false">boolean</type>
977
  </tag>
978
+ <tag line="2060" name="return" description="string or array value matching key(.key ...) or ''" type="mixed">
979
  <type by_reference="false">mixed</type>
980
  </tag>
981
  </docblock>
982
+ <argument line="2075">
983
  <name>$needle</name>
984
  <default><![CDATA[]]></default>
985
  <type/>
986
  </argument>
987
+ <argument line="2075">
988
  <name>$haystack</name>
989
  <default><![CDATA[]]></default>
990
  <type/>
991
  </argument>
992
+ <argument line="2075">
993
  <name>$option</name>
994
  <default><![CDATA[]]></default>
995
  <type/>
996
  </argument>
997
+ <argument line="2075">
998
  <name>$keep_existing</name>
999
  <default><![CDATA[false]]></default>
1000
  <type/>
1001
  </argument>
1002
  </method>
1003
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="2128" package="Media Library Assistant">
1004
  <name>mla_fetch_attachment_metadata</name>
1005
  <full_name>mla_fetch_attachment_metadata</full_name>
1006
+ <docblock line="2116">
1007
  <description><![CDATA[Fetch and filter meta data for an attachment]]></description>
1008
  <long-description><![CDATA[<p>Returns a filtered array of a post's meta data. Internal values beginning with '<em>'
1009
  are stripped out or converted to an 'mla</em>' equivalent.</p>]]></long-description>
1010
+ <tag line="2116" name="since" description="0.1"/>
1011
+ <tag line="2116" name="param" description="post ID of attachment" type="int" variable="$post_id">
1012
  <type by_reference="false">int</type>
1013
  </tag>
1014
+ <tag line="2116" name="return" description="Meta data variables" type="array">
1015
  <type by_reference="false">array</type>
1016
  </tag>
1017
  </docblock>
1018
+ <argument line="2128">
1019
  <name>$post_id</name>
1020
  <default><![CDATA[]]></default>
1021
  <type/>
1022
  </argument>
1023
  </method>
1024
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="2210" package="Media Library Assistant">
1025
  <name>mla_fetch_attachment_references</name>
1026
  <full_name>mla_fetch_attachment_references</full_name>
1027
+ <docblock line="2197">
1028
  <description><![CDATA[Find Featured Image and inserted image/link references to an attachment]]></description>
1029
  <long-description><![CDATA[<p>Searches all post and page content to see if the attachment is used
1030
  as a Featured Image or inserted in the post as an image or link.</p>]]></long-description>
1031
+ <tag line="2197" name="since" description="0.1"/>
1032
+ <tag line="2197" name="param" description="post ID of attachment" type="int" variable="$ID">
1033
  <type by_reference="false">int</type>
1034
  </tag>
1035
+ <tag line="2197" name="param" description="post ID of attachment's parent, if any" type="int" variable="$parent">
1036
  <type by_reference="false">int</type>
1037
  </tag>
1038
+ <tag line="2197" name="return" description="Reference information; see $references array comments" type="array">
1039
  <type by_reference="false">array</type>
1040
  </tag>
1041
  </docblock>
1042
+ <argument line="2210">
1043
  <name>$ID</name>
1044
  <default><![CDATA[]]></default>
1045
  <type/>
1046
  </argument>
1047
+ <argument line="2210">
1048
  <name>$parent</name>
1049
  <default><![CDATA[]]></default>
1050
  <type/>
1051
  </argument>
1052
  </method>
1053
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="2515" package="Media Library Assistant">
1054
  <name>mla_flush_mla_galleries</name>
1055
  <full_name>mla_flush_mla_galleries</full_name>
1056
+ <docblock line="2506">
1057
  <description><![CDATA[Invalidates the $mla_galleries or $galleries array and cached values]]></description>
1058
  <long-description><![CDATA[]]></long-description>
1059
+ <tag line="2506" name="since" description="1.00"/>
1060
+ <tag line="2506" name="param" description="name of the gallery's cache/option variable" type="string" variable="$option_name">
1061
  <type by_reference="false">string</type>
1062
  </tag>
1063
+ <tag line="2506" name="return" description="" type="void">
1064
  <type by_reference="false">void</type>
1065
  </tag>
1066
  </docblock>
1067
+ <argument line="2515">
1068
  <name>$option_name</name>
1069
  <default><![CDATA[]]></default>
1070
  <type/>
1071
  </argument>
1072
  </method>
1073
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="2539" package="Media Library Assistant">
1074
  <name>mla_save_post_action</name>
1075
  <full_name>mla_save_post_action</full_name>
1076
+ <docblock line="2530">
1077
  <description><![CDATA[Invalidates $mla_galleries and $galleries arrays and cached values after post, page or attachment updates]]></description>
1078
  <long-description><![CDATA[]]></long-description>
1079
+ <tag line="2530" name="since" description="1.00"/>
1080
+ <tag line="2530" name="param" description="ID of post/page/attachment; not used at this time" type="integer" variable="$post_id">
1081
  <type by_reference="false">integer</type>
1082
  </tag>
1083
+ <tag line="2530" name="return" description="" type="void">
1084
  <type by_reference="false">void</type>
1085
  </tag>
1086
  </docblock>
1087
+ <argument line="2539">
1088
  <name>$post_id</name>
1089
  <default><![CDATA[]]></default>
1090
  <type/>
1091
  </argument>
1092
  </method>
1093
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2556" package="Media Library Assistant">
1094
  <name>_build_mla_galleries</name>
1095
  <full_name>_build_mla_galleries</full_name>
1096
+ <docblock line="2544">
1097
  <description><![CDATA[Builds the $mla_galleries or $galleries array]]></description>
1098
  <long-description><![CDATA[]]></long-description>
1099
+ <tag line="2544" name="since" description="0.70"/>
1100
+ <tag line="2544" name="param" description="name of the gallery's cache/option variable" type="string" variable="$option_name">
1101
  <type by_reference="false">string</type>
1102
  </tag>
1103
+ <tag line="2544" name="param" description="by reference to the private static galleries array variable" type="array" variable="$galleries_array">
1104
  <type by_reference="false">array</type>
1105
  </tag>
1106
+ <tag line="2544" name="param" description="the shortcode to be searched for and processed" type="string" variable="$shortcode">
1107
  <type by_reference="false">string</type>
1108
  </tag>
1109
+ <tag line="2544" name="param" description="true to exclude revisions from the search" type="boolean" variable="$exclude_revisions">
1110
  <type by_reference="false">boolean</type>
1111
  </tag>
1112
+ <tag line="2544" name="return" description="true if the galleries array is not empty" type="boolean">
1113
  <type by_reference="false">boolean</type>
1114
  </tag>
1115
  </docblock>
1116
+ <argument line="2556">
1117
  <name>$option_name</name>
1118
  <default><![CDATA[]]></default>
1119
  <type/>
1120
  </argument>
1121
+ <argument line="2556">
1122
  <name>$galleries_array</name>
1123
  <default><![CDATA[]]></default>
1124
  <type/>
1125
  </argument>
1126
+ <argument line="2556">
1127
  <name>$shortcode</name>
1128
  <default><![CDATA[]]></default>
1129
  <type/>
1130
  </argument>
1131
+ <argument line="2556">
1132
  <name>$exclude_revisions</name>
1133
  <default><![CDATA[]]></default>
1134
  <type/>
1135
  </argument>
1136
  </method>
1137
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2671" package="Media Library Assistant">
1138
  <name>_search_mla_galleries</name>
1139
  <full_name>_search_mla_galleries</full_name>
1140
+ <docblock line="2660">
1141
  <description><![CDATA[Search the $mla_galleries or $galleries array]]></description>
1142
  <long-description><![CDATA[]]></long-description>
1143
+ <tag line="2660" name="since" description="0.70"/>
1144
+ <tag line="2660" name="param" description="by reference to the private static galleries array variable" type="array" variable="$galleries_array">
1145
  <type by_reference="false">array</type>
1146
  </tag>
1147
+ <tag line="2660" name="param" description="the attachment ID to be searched for and processed" type="int" variable="$attachment_id">
1148
  <type by_reference="false">int</type>
1149
  </tag>
1150
+ <tag line="2660" name="return" description="All posts/pages with one or more galleries that include the attachment. The array key is the parent_post ID; each entry contains post_title and post_type." type="array">
1151
  <type by_reference="false">array</type>
1152
  </tag>
1153
  </docblock>
1154
+ <argument line="2671">
1155
  <name>$galleries_array</name>
1156
  <default><![CDATA[]]></default>
1157
  <type/>
1158
  </argument>
1159
+ <argument line="2671">
1160
  <name>$attachment_id</name>
1161
  <default><![CDATA[]]></default>
1162
  <type/>
1163
  </argument>
1164
  </method>
1165
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2710" package="Media Library Assistant">
1166
  <name>_parse_pdf_xref_subsection</name>
1167
  <full_name>_parse_pdf_xref_subsection</full_name>
1168
+ <docblock line="2697">
1169
  <description><![CDATA[Parse a cross-reference table subsection into the array of indirect object definitions]]></description>
1170
  <long-description><![CDATA[<p>A cross-reference subsection is a sequence of 20-byte entries, each with offset and generation values.</p>]]></long-description>
1171
+ <tag line="2697" name="since" description="1.50"/>
1172
+ <tag line="2697" name="param" description="buffer containing the subsection" type="string" variable="$xref_section">
1173
  <type by_reference="false">string</type>
1174
  </tag>
1175
+ <tag line="2697" name="param" description="offset within the buffer of the first entry" type="integer" variable="$offset">
1176
  <type by_reference="false">integer</type>
1177
  </tag>
1178
+ <tag line="2697" name="param" description="number of the first object in the subsection" type="integer" variable="$object_id">
1179
  <type by_reference="false">integer</type>
1180
  </tag>
1181
+ <tag line="2697" name="param" description="number of entries in the subsection" type="integer" variable="$count">
1182
  <type by_reference="false">integer</type>
1183
  </tag>
1184
+ <tag line="2697" name="return" description="" type="void">
1185
  <type by_reference="false">void</type>
1186
  </tag>
1187
  </docblock>
1188
+ <argument line="2710">
1189
  <name>$xref_section</name>
1190
  <default><![CDATA[]]></default>
1191
  <type/>
1192
  </argument>
1193
+ <argument line="2710">
1194
  <name>$offset</name>
1195
  <default><![CDATA[]]></default>
1196
  <type/>
1197
  </argument>
1198
+ <argument line="2710">
1199
  <name>$object_id</name>
1200
  <default><![CDATA[]]></default>
1201
  <type/>
1202
  </argument>
1203
+ <argument line="2710">
1204
  <name>$count</name>
1205
  <default><![CDATA[]]></default>
1206
  <type/>
1207
  </argument>
1208
  </method>
1209
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2742" package="Media Library Assistant">
1210
  <name>_parse_pdf_xref_section</name>
1211
  <full_name>_parse_pdf_xref_section</full_name>
1212
+ <docblock line="2731">
1213
  <description><![CDATA[Parse a cross-reference table section into the array of indirect object definitions]]></description>
1214
  <long-description><![CDATA[<p>Creates the array of indirect object offsets and lengths</p>]]></long-description>
1215
+ <tag line="2731" name="since" description="1.50"/>
1216
+ <tag line="2731" name="param" description="full path and file name" type="string" variable="$file_name">
1217
  <type by_reference="false">string</type>
1218
  </tag>
1219
+ <tag line="2731" name="param" description="offset within the file of the xref id and count entry" type="integer" variable="$file_offset">
1220
  <type by_reference="false">integer</type>
1221
  </tag>
1222
+ <tag line="2731" name="return" description="length of the section" type="integer">
1223
  <type by_reference="false">integer</type>
1224
  </tag>
1225
  </docblock>
1226
+ <argument line="2742">
1227
  <name>$file_name</name>
1228
  <default><![CDATA[]]></default>
1229
  <type/>
1230
  </argument>
1231
+ <argument line="2742">
1232
  <name>$file_offset</name>
1233
  <default><![CDATA[]]></default>
1234
  <type/>
1235
  </argument>
1236
  </method>
1237
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2776" package="Media Library Assistant">
1238
  <name>_parse_pdf_xref_stream</name>
1239
  <full_name>_parse_pdf_xref_stream</full_name>
1240
+ <docblock line="2764">
1241
  <description><![CDATA[Parse a cross-reference steam into the array of indirect object definitions]]></description>
1242
  <long-description><![CDATA[<p>Creates the array of indirect object offsets and lengths</p>]]></long-description>
1243
+ <tag line="2764" name="since" description="1.50"/>
1244
+ <tag line="2764" name="param" description="full path and file name" type="string" variable="$file_name">
1245
  <type by_reference="false">string</type>
1246
  </tag>
1247
+ <tag line="2764" name="param" description="offset within the file of the xref id and count entry" type="integer" variable="$file_offset">
1248
  <type by_reference="false">integer</type>
1249
  </tag>
1250
+ <tag line="2764" name="param" description="&quot;/W&quot; entry, representing the size of the fields in a single entry" type="string" variable="$entry_parms_string">
1251
  <type by_reference="false">string</type>
1252
  </tag>
1253
+ <tag line="2764" name="return" description="length of the stream" type="integer">
1254
  <type by_reference="false">integer</type>
1255
  </tag>
1256
  </docblock>
1257
+ <argument line="2776">
1258
  <name>$file_name</name>
1259
  <default><![CDATA[]]></default>
1260
  <type/>
1261
  </argument>
1262
+ <argument line="2776">
1263
  <name>$file_offset</name>
1264
  <default><![CDATA[]]></default>
1265
  <type/>
1266
  </argument>
1267
+ <argument line="2776">
1268
  <name>$entry_parms_string</name>
1269
  <default><![CDATA[]]></default>
1270
  <type/>
1271
  </argument>
1272
  </method>
1273
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2855" package="Media Library Assistant">
1274
  <name>_build_pdf_indirect_objects</name>
1275
  <full_name>_build_pdf_indirect_objects</full_name>
1276
+ <docblock line="2845">
1277
  <description><![CDATA[Build an array of indirect object definitions]]></description>
1278
  <long-description><![CDATA[<p>Creates the array of indirect object offsets and lengths</p>]]></long-description>
1279
+ <tag line="2845" name="since" description="1.50"/>
1280
+ <tag line="2845" name="param" description="The entire PDF document, passsed by reference" type="string" variable="$string">
1281
  <type by_reference="false">string</type>
1282
  </tag>
1283
+ <tag line="2845" name="return" description="" type="void">
1284
  <type by_reference="false">void</type>
1285
  </tag>
1286
  </docblock>
1287
+ <argument line="2855">
1288
  <name>$string</name>
1289
  <default><![CDATA[]]></default>
1290
  <type/>
1291
  </argument>
1292
  </method>
1293
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="2903" package="Media Library Assistant">
1294
  <name>_find_pdf_indirect_dictionary</name>
1295
  <full_name>_find_pdf_indirect_dictionary</full_name>
1296
+ <docblock line="2889">
1297
  <description><![CDATA[Find the offset, length and contents of an indirect object containing a dictionary]]></description>
1298
  <long-description><![CDATA[<p>The function searches the entire file, if necessary, to find the last/most recent copy of the object.
1299
  This is required because Adobe Acrobat does NOT increment the generation number when it reuses an object.</p>]]></long-description>
1300
+ <tag line="2889" name="since" description="1.50"/>
1301
+ <tag line="2889" name="param" description="full path and file name" type="string" variable="$file_name">
1302
  <type by_reference="false">string</type>
1303
  </tag>
1304
+ <tag line="2889" name="param" description="The object number" type="integer" variable="$object">
1305
  <type by_reference="false">integer</type>
1306
  </tag>
1307
+ <tag line="2889" name="param" description="The object generation number; default zero (0)" type="integer" variable="$generation">
1308
  <type by_reference="false">integer</type>
1309
  </tag>
1310
+ <tag line="2889" name="return" description="NULL on failure else array( 'start' =&gt; offset in the file, 'length' =&gt; object length, 'content' =&gt; dictionary contents )" type="mixed">
1311
  <type by_reference="false">mixed</type>
1312
  </tag>
1313
  </docblock>
1314
+ <argument line="2903">
1315
  <name>$file_name</name>
1316
  <default><![CDATA[]]></default>
1317
  <type/>
1318
  </argument>
1319
+ <argument line="2903">
1320
  <name>$object</name>
1321
  <default><![CDATA[]]></default>
1322
  <type/>
1323
  </argument>
1324
+ <argument line="2903">
1325
  <name>$generation</name>
1326
  <default><![CDATA[0]]></default>
1327
  <type/>
1328
  </argument>
1329
  </method>
1330
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3000" package="Media Library Assistant">
1331
  <name>_parse_iso8601_date</name>
1332
  <full_name>_parse_iso8601_date</full_name>
1333
+ <docblock line="2991">
1334
  <description><![CDATA[Parse a ISO 8601 Timestamp]]></description>
1335
  <long-description><![CDATA[]]></long-description>
1336
+ <tag line="2991" name="since" description="1.50"/>
1337
+ <tag line="2991" name="param" description="ISO string of the form YYYY-MM-DDTHH:MM:SS-HH:MM (inc time zone)" type="string" variable="$source_string">
1338
  <type by_reference="false">string</type>
1339
  </tag>
1340
+ <tag line="2991" name="return" description="formatted date string YYYY-MM-DD HH:mm:SS" type="string">
1341
  <type by_reference="false">string</type>
1342
  </tag>
1343
  </docblock>
1344
+ <argument line="3000">
1345
  <name>$source_string</name>
1346
  <default><![CDATA[]]></default>
1347
  <type/>
1348
  </argument>
1349
  </method>
1350
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3023" package="Media Library Assistant">
1351
  <name>_parse_pdf_date</name>
1352
  <full_name>_parse_pdf_date</full_name>
1353
+ <docblock line="3014">
1354
  <description><![CDATA[Parse a PDF date string]]></description>
1355
  <long-description><![CDATA[]]></long-description>
1356
+ <tag line="3014" name="since" description="1.50"/>
1357
+ <tag line="3014" name="param" description="PDF date string of the form D:YYYYMMDDHHmmSSOHH'mm" type="string" variable="$source_string">
1358
  <type by_reference="false">string</type>
1359
  </tag>
1360
+ <tag line="3014" name="return" description="formatted date string YYYY-MM-DD HH:mm:SS" type="string">
1361
  <type by_reference="false">string</type>
1362
  </tag>
1363
  </docblock>
1364
+ <argument line="3023">
1365
  <name>$source_string</name>
1366
  <default><![CDATA[]]></default>
1367
  <type/>
1368
  </argument>
1369
  </method>
1370
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3046" package="Media Library Assistant">
1371
  <name>_parse_pdf_UTF16BE</name>
1372
  <full_name>_parse_pdf_UTF16BE</full_name>
1373
+ <docblock line="3037">
1374
  <description><![CDATA[Parse a PDF Unicode (16-bit Big Endian) object]]></description>
1375
  <long-description><![CDATA[]]></long-description>
1376
+ <tag line="3037" name="since" description="1.50"/>
1377
+ <tag line="3037" name="param" description="PDF string of 16-bit characters" type="string" variable="$source_string">
1378
  <type by_reference="false">string</type>
1379
  </tag>
1380
+ <tag line="3037" name="return" description="UTF-8 encoded string" type="string">
1381
  <type by_reference="false">string</type>
1382
  </tag>
1383
  </docblock>
1384
+ <argument line="3046">
1385
  <name>$source_string</name>
1386
  <default><![CDATA[]]></default>
1387
  <type/>
1388
  </argument>
1389
  </method>
1390
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3075" package="Media Library Assistant">
1391
  <name>_parse_pdf_string</name>
1392
  <full_name>_parse_pdf_string</full_name>
1393
+ <docblock line="3062">
1394
  <description><![CDATA[Parse a PDF string object]]></description>
1395
  <long-description><![CDATA[<p>Returns an array with one dictionary entry. The array also has a '/length' element containing
1396
  the number of bytes occupied by the string in the source string, including the enclosing parentheses.</p>]]></long-description>
1397
+ <tag line="3062" name="since" description="1.50"/>
1398
+ <tag line="3062" name="param" description="data within which the string occurs" type="string" variable="$source_string">
1399
  <type by_reference="false">string</type>
1400
  </tag>
1401
+ <tag line="3062" name="param" description="offset within the source string of the opening '(' character." type="integer" variable="$offset">
1402
  <type by_reference="false">integer</type>
1403
  </tag>
1404
+ <tag line="3062" name="return" description="( key =&gt; array( 'type' =&gt; type, 'value' =&gt; value, '/length' =&gt; length ) ) for the string" type="array">
1405
  <type by_reference="false">array</type>
1406
  </tag>
1407
  </docblock>
1408
+ <argument line="3075">
1409
  <name>$source_string</name>
1410
  <default><![CDATA[]]></default>
1411
  <type/>
1412
  </argument>
1413
+ <argument line="3075">
1414
  <name>$offset</name>
1415
  <default><![CDATA[]]></default>
1416
  <type/>
1417
  </argument>
1418
  </method>
1419
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3169" package="Media Library Assistant">
1420
  <name>_parse_pdf_LPD_dictionary</name>
1421
  <full_name>_parse_pdf_LPD_dictionary</full_name>
1422
+ <docblock line="3155">
1423
  <description><![CDATA[Parse a PDF Linearization Parameter Dictionary object]]></description>
1424
  <long-description><![CDATA[<p>Returns an array of dictionary contents, classified by object type: boolean, numeric, string, hex (string),
1425
  indirect (object), name, array, dictionary, stream, and null.
1426
  The array also has a '/length' element containing the number of bytes occupied by the
1427
  dictionary in the source string, excluding the enclosing delimiters, if passed in.</p>]]></long-description>
1428
+ <tag line="3155" name="since" description="1.50"/>
1429
+ <tag line="3155" name="param" description="data within which the object occurs, typically the start of a PDF document" type="string" variable="$source_string">
1430
  <type by_reference="false">string</type>
1431
  </tag>
1432
+ <tag line="3155" name="param" description="filesize of the PDF document, for validation purposes, or zero (0) to ignore filesize" type="integer" variable="$filesize">
1433
  <type by_reference="false">integer</type>
1434
  </tag>
1435
+ <tag line="3155" name="return" description="array of dictionary objects on success, false on failure" type="mixed">
1436
  <type by_reference="false">mixed</type>
1437
  </tag>
1438
  </docblock>
1439
+ <argument line="3169">
1440
  <name>$source_string</name>
1441
  <default><![CDATA[]]></default>
1442
  <type/>
1443
  </argument>
1444
+ <argument line="3169">
1445
  <name>$filesize</name>
1446
  <default><![CDATA[]]></default>
1447
  <type/>
1448
  </argument>
1449
  </method>
1450
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3194" package="Media Library Assistant">
1451
  <name>_parse_pdf_dictionary</name>
1452
  <full_name>_parse_pdf_dictionary</full_name>
1453
+ <docblock line="3180">
1454
  <description><![CDATA[Parse a PDF dictionary object]]></description>
1455
  <long-description><![CDATA[<p>Returns an array of dictionary contents, classified by object type: boolean, numeric, string, hex (string),
1456
  indirect (object), name, array, dictionary, stream, and null.
1457
  The array also has a '/length' element containing the number of bytes occupied by the
1458
  dictionary in the source string, excluding the enclosing delimiters.</p>]]></long-description>
1459
+ <tag line="3180" name="since" description="1.50"/>
1460
+ <tag line="3180" name="param" description="data within which the string occurs" type="string" variable="$source_string">
1461
  <type by_reference="false">string</type>
1462
  </tag>
1463
+ <tag line="3180" name="param" description="offset within the source string of the opening '&lt;&lt;' characters or the first content character." type="integer" variable="$offset">
1464
  <type by_reference="false">integer</type>
1465
  </tag>
1466
+ <tag line="3180" name="return" description="( '/length' =&gt; length, key =&gt; array( 'type' =&gt; type, 'value' =&gt; value ) ) for each dictionary field" type="array">
1467
  <type by_reference="false">array</type>
1468
  </tag>
1469
  </docblock>
1470
+ <argument line="3194">
1471
  <name>$source_string</name>
1472
  <default><![CDATA[]]></default>
1473
  <type/>
1474
  </argument>
1475
+ <argument line="3194">
1476
  <name>$offset</name>
1477
  <default><![CDATA[]]></default>
1478
  <type/>
1479
  </argument>
1480
  </method>
1481
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3326" package="Media Library Assistant">
1482
  <name>_parse_xmp_metadata</name>
1483
  <full_name>_parse_xmp_metadata</full_name>
1484
+ <docblock line="3312">
1485
  <description><![CDATA[Parse an XMP object]]></description>
1486
  <long-description><![CDATA[<p>Returns an array of dictionary contents, classified by object type: boolean, numeric, string, hex (string),
1487
  indirect (object), name, array, dictionary, stream, and null.
1488
  The array also has a '/length' element containing the number of bytes occupied by the
1489
  dictionary in the source string, excluding the enclosing delimiters, if passed in.</p>]]></long-description>
1490
+ <tag line="3312" name="since" description="1.50"/>
1491
+ <tag line="3312" name="param" description="full path and file name" type="string" variable="$file_name">
1492
  <type by_reference="false">string</type>
1493
  </tag>
1494
+ <tag line="3312" name="param" description="offset within the file of the search start point" type="integer" variable="$file_offset">
1495
  <type by_reference="false">integer</type>
1496
  </tag>
1497
+ <tag line="3312" name="return" description="array of metadata values or NULL on failure" type="mixed">
1498
  <type by_reference="false">mixed</type>
1499
  </tag>
1500
  </docblock>
1501
+ <argument line="3326">
1502
  <name>$file_name</name>
1503
  <default><![CDATA[]]></default>
1504
  <type/>
1505
  </argument>
1506
+ <argument line="3326">
1507
  <name>$file_offset</name>
1508
  <default><![CDATA[]]></default>
1509
  <type/>
1510
  </argument>
1511
  </method>
1512
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3615" package="Media Library Assistant">
1513
  <name>_extract_pdf_trailer</name>
1514
  <full_name>_extract_pdf_trailer</full_name>
1515
+ <docblock line="3605">
1516
  <description><![CDATA[Extract dictionary from traditional cross-reference + trailer documents]]></description>
1517
  <long-description><![CDATA[]]></long-description>
1518
+ <tag line="3605" name="since" description="1.50"/>
1519
+ <tag line="3605" name="param" description="full path to the desired file" type="string" variable="$file_name">
1520
  <type by_reference="false">string</type>
1521
  </tag>
1522
+ <tag line="3605" name="param" description="offset within file of the cross-reference table" type="integer" variable="$file_offset">
1523
  <type by_reference="false">integer</type>
1524
  </tag>
1525
+ <tag line="3605" name="return" description="array of &quot;PDF dictionary arrays&quot;, newest first, or NULL on failure" type="mixed">
1526
  <type by_reference="false">mixed</type>
1527
  </tag>
1528
  </docblock>
1529
+ <argument line="3615">
1530
  <name>$file_name</name>
1531
  <default><![CDATA[]]></default>
1532
  <type/>
1533
  </argument>
1534
+ <argument line="3615">
1535
  <name>$file_offset</name>
1536
  <default><![CDATA[]]></default>
1537
  <type/>
1538
  </argument>
1539
  </method>
1540
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3701" package="Media Library Assistant">
1541
  <name>_extract_pdf_metadata</name>
1542
  <full_name>_extract_pdf_metadata</full_name>
1543
+ <docblock line="3692">
1544
  <description><![CDATA[Extract Metadata from a PDF file]]></description>
1545
  <long-description><![CDATA[]]></long-description>
1546
+ <tag line="3692" name="since" description="1.50"/>
1547
+ <tag line="3692" name="param" description="full path to the desired file" type="string" variable="$file_name">
1548
  <type by_reference="false">string</type>
1549
  </tag>
1550
+ <tag line="3692" name="return" description="( key =&gt; value ) for each metadata field, in string format" type="array">
1551
  <type by_reference="false">array</type>
1552
  </tag>
1553
  </docblock>
1554
+ <argument line="3701">
1555
  <name>$file_name</name>
1556
  <default><![CDATA[]]></default>
1557
  <type/>
1558
  </argument>
1559
  </method>
1560
+ <method final="false" abstract="false" static="true" visibility="private" namespace="global" line="3834" package="Media Library Assistant">
1561
  <name>_bin_to_utf8</name>
1562
  <full_name>_bin_to_utf8</full_name>
1563
+ <docblock line="3825">
1564
  <description><![CDATA[Replace SQL incorrect characters (0x80 - 0xFF) with their UTF-8 equivalents]]></description>
1565
  <long-description><![CDATA[]]></long-description>
1566
+ <tag line="3825" name="since" description="1.41"/>
1567
+ <tag line="3825" name="param" description="unencoded string" type="string" variable="$string">
1568
  <type by_reference="false">string</type>
1569
  </tag>
1570
+ <tag line="3825" name="return" description="UTF-8 encoded string" type="string">
1571
  <type by_reference="false">string</type>
1572
  </tag>
1573
  </docblock>
1574
+ <argument line="3834">
1575
  <name>$string</name>
1576
  <default><![CDATA[]]></default>
1577
  <type/>
1578
  </argument>
1579
  </method>
1580
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="4232" package="Media Library Assistant">
1581
  <name>mla_iptc_metadata_value</name>
1582
  <full_name>mla_iptc_metadata_value</full_name>
1583
+ <docblock line="4222">
1584
  <description><![CDATA[Parse one IPTC metadata field]]></description>
1585
  <long-description><![CDATA[]]></long-description>
1586
+ <tag line="4222" name="since" description="1.41"/>
1587
+ <tag line="4222" name="param" description="field name - IPTC Identifier or friendly name/slug" type="string" variable="$iptc_key">
1588
  <type by_reference="false">string</type>
1589
  </tag>
1590
+ <tag line="4222" name="param" description="metadata array containing iptc, exif, and pdf metadata arrays" type="string" variable="$item_metadata">
1591
  <type by_reference="false">string</type>
1592
  </tag>
1593
+ <tag line="4222" name="return" description="string/array representation of metadata value or an empty string" type="mixed">
1594
  <type by_reference="false">mixed</type>
1595
  </tag>
1596
  </docblock>
1597
+ <argument line="4232">
1598
  <name>$iptc_key</name>
1599
  <default><![CDATA[]]></default>
1600
  <type/>
1601
  </argument>
1602
+ <argument line="4232">
1603
  <name>$item_metadata</name>
1604
  <default><![CDATA[]]></default>
1605
  <type/>
1606
  </argument>
1607
  </method>
1608
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="4264" package="Media Library Assistant">
1609
  <name>mla_exif_metadata_value</name>
1610
  <full_name>mla_exif_metadata_value</full_name>
1611
+ <docblock line="4252">
1612
  <description><![CDATA[Parse one EXIF metadata field]]></description>
1613
  <long-description><![CDATA[<p>Also handles the special pseudo-values 'ALL_EXIF' and 'ALL_IPTC'.</p>]]></long-description>
1614
+ <tag line="4252" name="since" description="1.13"/>
1615
+ <tag line="4252" name="param" description="field name" type="string" variable="$exif_key">
1616
  <type by_reference="false">string</type>
1617
  </tag>
1618
+ <tag line="4252" name="param" description="metadata array containing iptc, exif, and pdf metadata arrays" type="string" variable="$item_metadata">
1619
  <type by_reference="false">string</type>
1620
  </tag>
1621
+ <tag line="4252" name="return" description="string/array representation of metadata value or an empty string" type="mixed">
1622
  <type by_reference="false">mixed</type>
1623
  </tag>
1624
  </docblock>
1625
+ <argument line="4264">
1626
  <name>$exif_key</name>
1627
  <default><![CDATA[]]></default>
1628
  <type/>
1629
  </argument>
1630
+ <argument line="4264">
1631
  <name>$item_metadata</name>
1632
  <default><![CDATA[]]></default>
1633
  <type/>
1634
  </argument>
1635
  </method>
1636
+ <method final="false" abstract="false" static="true" visibility="public" namespace="global" line="4325" package="Media Library Assistant">
1637
  <name>mla_pdf_metadata_value</name>
1638
  <full_name>mla_pdf_metadata_value</full_name>
1639
+ <docblock line="4313">
1640
  <description><![CDATA[Parse one PDF metadata field]]></description>
1641
  <long-description><![CDATA[<p>Also handles the special pseudo-value 'ALL_PDF'.</p>]]></long-description>
1642
+ <tag line="4313" name="since" description="1.50"/>
1643
+ <tag line="4313" name="param" description="field name" type="string" variable="$pdf_key">
1644
  <type by_reference="false">string</type>
1645
  </tag>