Media Library Assistant - Version 2.78

Version Description

  • New: For the Media/Assistant "Search Media" and "Terms Search" functions, keywords and terms can be excluded from the results by enclosing them in "/" delimiters, e.g., "/not/ happy" will return items containing "happy" after excluding items containing "not". This new feature also works in the Media/Library "grid" view and in the "Add media" popup window.
  • Fix: Eliminate fatal errors supporting Admin Columns Pro version 4.5.x
  • Fix: When Polylang is active, eliminate PHP error messages from MLA_Polylang_Shortcodes::mla_get_terms_clauses.
  • Fix: For [mla_gallery] eliminate PHP warning messages for some invalid parameter situations.
  • Fix: Simplify MLA_Ajax logging and remove PHP Notice regarding missing "action" value.
  • Fix: For "MLA USP Novo-Map Example" plugin, rewrite the "Introduction" section in the Documentation tab.
Download this release

Release Info

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

Code changes from version 2.77 to 2.78

examples/plugins/mla-path-mapping-example/mla-path-mapping-example.php CHANGED
@@ -14,7 +14,7 @@
14
  * https://wordpress.org/support/topic/help-with-custom-taxonomy/
15
  *
16
  * @package MLA Path Mapping Example
17
- * @version 1.01
18
  */
19
 
20
  /*
@@ -22,7 +22,7 @@ Plugin Name: MLA Path Mapping Example
22
  Plugin URI: http://davidlingren.com/
23
  Description: Adds hierarchical path specification to the IPTC/EXIF taxonomy mapping features
24
  Author: David Lingren
25
- Version: 1.01
26
  Author URI: http://davidlingren.com/
27
 
28
  Copyright 2018 David Lingren
@@ -58,7 +58,7 @@ class MLAPathMappingExample {
58
  *
59
  * @var string
60
  */
61
- const CURRENT_VERSION = '1.01';
62
 
63
  /**
64
  * Slug prefix for registering and enqueueing submenu pages, style sheets, scripts and settings
@@ -593,7 +593,7 @@ class MLAPathMappingExample {
593
 
594
  // Is this a simple, unqualified term already in the cache?
595
  if ( isset( $unqualified_cache[ $setting_key ][ $term_name ] ) ) {
596
- error_log( __LINE__ . " mla_mapping_new_text found $term_name in unqualified_cache", 0 );
597
  MLAOptions::$mla_term_cache[ $setting_key ][ $term_parent ][ $term_name ] = $unqualified_cache[ $setting_key ][ $term_name ]['term_id'];
598
  continue;
599
  }
@@ -612,7 +612,7 @@ error_log( __LINE__ . " mla_mapping_new_text found $term_name in unqualified_cac
612
  } else {
613
  $current_parent = $term_parent;
614
  }
615
- error_log( __LINE__ . " mla_mapping_new_text parent = " . var_export( $current_parent, true ) . ", path = " . var_export( $path, true ), 0 );
616
 
617
  // Holder for the $assign_parents entries
618
  $assign_parents_entry = 0;
@@ -630,13 +630,13 @@ error_log( __LINE__ . " mla_mapping_new_text parent = " . var_export( $current_p
630
 
631
  // Ignore initial or duplicate delimiters
632
  if ( empty( $path_name ) ) {
633
- error_log( __LINE__ . " mla_mapping_new_text ignoring empty path_name", 0 );
634
  continue;
635
  }
636
 
637
  // Is this component in the cache?
638
  if ( isset( $term_cache[ $setting_key ][ $current_parent ][ $path_name ] ) ) {
639
- error_log( __LINE__ . " mla_mapping_new_text found $path_name under $current_parent in cache", 0 );
640
  $current_parent = $term_cache[ $setting_key ][ $current_parent ][ $path_name ]['term_id'];
641
 
642
  if ( $assign_parents ) {
@@ -650,13 +650,13 @@ error_log( __LINE__ . " mla_mapping_new_text found $path_name under $current_par
650
  if ( $unqualified_name ) {
651
  // Is this component in the cache?
652
  if ( isset( $unqualified_cache[ $setting_key ][ $path_name ] ) ) {
653
- error_log( __LINE__ . " mla_mapping_new_text found $path_name in unqualified cache", 0 );
654
  $path_term = $unqualified_cache[ $setting_key ][ $path_name ];
655
  } else {
656
  $path_term = term_exists( $path_name, $setting_key );
657
 
658
  if ( $path_term !== 0 && $path_term !== NULL ) {
659
- error_log( __LINE__ . " mla_mapping_new_text adding $path_name to unqualified cache", 0 );
660
  $unqualified_cache[ $setting_key ][ $path_name ] = $path_term;
661
  }
662
  }
@@ -667,8 +667,8 @@ error_log( __LINE__ . " mla_mapping_new_text adding $path_name to unqualified ca
667
  }
668
 
669
  if ( $path_term !== 0 && $path_term !== NULL ) {
670
- error_log( __LINE__ . " mla_mapping_new_text found $path_name under $current_parent in database = " . var_export( $path_term, true ), 0 );
671
- $term_cache[ $setting_key ][ $path_term['parent'] ][ $path_name ] = $path_term;
672
  $current_parent = absint( $path_term['term_id'] );
673
 
674
  if ( $assign_parents ) {
@@ -681,7 +681,7 @@ error_log( __LINE__ . " mla_mapping_new_text found $path_name under $current_par
681
  // Create the term
682
  $path_term = wp_insert_term( $path_name, $setting_key, array( 'parent' => $current_parent ) );
683
  if ( ( ! is_wp_error( $path_term ) ) && isset( $path_term['term_id'] ) ) {
684
- error_log( __LINE__ . " mla_mapping_new_text created $path_name under $current_parent = " . var_export( $path_term, true ), 0 );
685
  $term_cache[ $setting_key ][ $current_parent ][ $path_name ] = $path_term;
686
  $current_parent = absint( $path_term['term_id'] );
687
 
@@ -701,7 +701,7 @@ error_log( __LINE__ . " mla_mapping_new_text created $path_name under $current_p
701
  $new_text[] = 'rule_parent-term';
702
  }
703
 
704
- error_log( __LINE__ . " MLAPathMappingExample::mla_mapping_new_text_filter( {$setting_key}, {$post_id}, {$category} ) mla term cache = " . var_export( MLAOptions::$mla_term_cache, true ), 0 );
705
  return $new_text;
706
  } // mla_mapping_new_text_filter
707
 
@@ -723,8 +723,8 @@ error_log( __LINE__ . " MLAPathMappingExample::mla_mapping_new_text_filter( {$se
723
  * @return array updated attachment's updates
724
  */
725
  public static function mla_mapping_updates( $updates, $post_id, $category, $settings, $attachment_metadata ) {
726
- error_log( __LINE__ . " MLAPathMappingExample::mla_mapping_updates_filter( {$post_id}, {$category} ) updates = " . var_export( $updates, true ), 0 );
727
- error_log( __LINE__ . " MLAPathMappingExample::mla_mapping_updates_filter( {$post_id}, {$category} ) settings = " . var_export( $settings, true ), 0 );
728
  //error_log( __LINE__ . " MLAPathMappingExample::mla_mapping_updates_filter( {$post_id}, {$category} ) attachment_metadata = " . var_export( $attachment_metadata, true ), 0 );
729
 
730
  // To stop this rule's updates, return an empty array, i.e., return array();
14
  * https://wordpress.org/support/topic/help-with-custom-taxonomy/
15
  *
16
  * @package MLA Path Mapping Example
17
+ * @version 1.02
18
  */
19
 
20
  /*
22
  Plugin URI: http://davidlingren.com/
23
  Description: Adds hierarchical path specification to the IPTC/EXIF taxonomy mapping features
24
  Author: David Lingren
25
+ Version: 1.02
26
  Author URI: http://davidlingren.com/
27
 
28
  Copyright 2018 David Lingren
58
  *
59
  * @var string
60
  */
61
+ const CURRENT_VERSION = '1.02';
62
 
63
  /**
64
  * Slug prefix for registering and enqueueing submenu pages, style sheets, scripts and settings
593
 
594
  // Is this a simple, unqualified term already in the cache?
595
  if ( isset( $unqualified_cache[ $setting_key ][ $term_name ] ) ) {
596
+ //error_log( __LINE__ . " mla_mapping_new_text found $term_name in unqualified_cache", 0 );
597
  MLAOptions::$mla_term_cache[ $setting_key ][ $term_parent ][ $term_name ] = $unqualified_cache[ $setting_key ][ $term_name ]['term_id'];
598
  continue;
599
  }
612
  } else {
613
  $current_parent = $term_parent;
614
  }
615
+ //error_log( __LINE__ . " mla_mapping_new_text parent = " . var_export( $current_parent, true ) . ", path = " . var_export( $path, true ), 0 );
616
 
617
  // Holder for the $assign_parents entries
618
  $assign_parents_entry = 0;
630
 
631
  // Ignore initial or duplicate delimiters
632
  if ( empty( $path_name ) ) {
633
+ //error_log( __LINE__ . " mla_mapping_new_text ignoring empty path_name", 0 );
634
  continue;
635
  }
636
 
637
  // Is this component in the cache?
638
  if ( isset( $term_cache[ $setting_key ][ $current_parent ][ $path_name ] ) ) {
639
+ //error_log( __LINE__ . " mla_mapping_new_text found $path_name under $current_parent in cache", 0 );
640
  $current_parent = $term_cache[ $setting_key ][ $current_parent ][ $path_name ]['term_id'];
641
 
642
  if ( $assign_parents ) {
650
  if ( $unqualified_name ) {
651
  // Is this component in the cache?
652
  if ( isset( $unqualified_cache[ $setting_key ][ $path_name ] ) ) {
653
+ //error_log( __LINE__ . " mla_mapping_new_text found $path_name in unqualified cache", 0 );
654
  $path_term = $unqualified_cache[ $setting_key ][ $path_name ];
655
  } else {
656
  $path_term = term_exists( $path_name, $setting_key );
657
 
658
  if ( $path_term !== 0 && $path_term !== NULL ) {
659
+ //error_log( __LINE__ . " mla_mapping_new_text adding $path_name to unqualified cache", 0 );
660
  $unqualified_cache[ $setting_key ][ $path_name ] = $path_term;
661
  }
662
  }
667
  }
668
 
669
  if ( $path_term !== 0 && $path_term !== NULL ) {
670
+ //error_log( __LINE__ . " mla_mapping_new_text found $path_name under $current_parent in database = " . var_export( $path_term, true ), 0 );
671
+ $term_cache[ $setting_key ][ $current_parent ][ $path_name ] = $path_term;
672
  $current_parent = absint( $path_term['term_id'] );
673
 
674
  if ( $assign_parents ) {
681
  // Create the term
682
  $path_term = wp_insert_term( $path_name, $setting_key, array( 'parent' => $current_parent ) );
683
  if ( ( ! is_wp_error( $path_term ) ) && isset( $path_term['term_id'] ) ) {
684
+ //error_log( __LINE__ . " mla_mapping_new_text created $path_name under $current_parent = " . var_export( $path_term, true ), 0 );
685
  $term_cache[ $setting_key ][ $current_parent ][ $path_name ] = $path_term;
686
  $current_parent = absint( $path_term['term_id'] );
687
 
701
  $new_text[] = 'rule_parent-term';
702
  }
703
 
704
+ //error_log( __LINE__ . " MLAPathMappingExample::mla_mapping_new_text_filter( {$setting_key}, {$post_id}, {$category} ) mla term cache = " . var_export( MLAOptions::$mla_term_cache, true ), 0 );
705
  return $new_text;
706
  } // mla_mapping_new_text_filter
707
 
723
  * @return array updated attachment's updates
724
  */
725
  public static function mla_mapping_updates( $updates, $post_id, $category, $settings, $attachment_metadata ) {
726
+ //error_log( __LINE__ . " MLAPathMappingExample::mla_mapping_updates_filter( {$post_id}, {$category} ) updates = " . var_export( $updates, true ), 0 );
727
+ //error_log( __LINE__ . " MLAPathMappingExample::mla_mapping_updates_filter( {$post_id}, {$category} ) settings = " . var_export( $settings, true ), 0 );
728
  //error_log( __LINE__ . " MLAPathMappingExample::mla_mapping_updates_filter( {$post_id}, {$category} ) attachment_metadata = " . var_export( $attachment_metadata, true ), 0 );
729
 
730
  // To stop this rule's updates, return an empty array, i.e., return array();
examples/plugins/mla-usp-novo-map-example/admin-settings-page.tpl CHANGED
@@ -255,10 +255,23 @@ p.submit.mla-settings-submit {
255
  </p>
256
  <h3>Introduction</h3>
257
  <p>
258
- The current MLA version provides mapping rules to assign taxonomy terms to Media Library items from IPTC, EXIF and XMP metadata values embedded in the image files. For hierarchical taxonomies, the current version allows new terms to be added under a specified &ldquo;Parent&rdquo; term, but does not support more general mapping of terms within multiple levels.
259
  </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  <p>
261
- The current version allows the specification of &ldquo;Delimiters&rdquo; (including a space character) to separate multiple terms within a metadata value. This example plugin adds a &ldquo;Path Delimiter&rdquo; that allows term parent and higher-level ancestor values to be specified, more precisely placing a term in the hierarchy. For example, a value such as &ldquo;/grand parent/parent/child&rdquo; denotes a specific term within a three-level hierarchy. In this example the delimiter at the start of the value means that &ldquo;grand parent&rdquo; must be a root term, i.e., it appears at the highest level and has no ancestors. This is an absolute path specification. A path such as &ldquo;parent/child&rdquo; is a relative path specification, starting wherever &ldquo;parent&rdquo; appears in the hierarchy.
262
  <a name="process-usp"></a>
263
  </p>
264
  <p>
255
  </p>
256
  <h3>Introduction</h3>
257
  <p>
258
+ This plugin enhances any application that combines two WordPress plugins to produce annotated maps:
259
  </p>
260
+ <ul class="mla-doc-toc-list">
261
+ <li><a href="https://wordpress.org/plugins/novo-map/" title="Plugin Repository page" target="_blank">Novo-Map : your WP posts on custom google maps</a></li>
262
+ <li><a href="https://wordpress.org/plugins/user-submitted-posts/" title="Plugin Repository page" target="_blank">User Submitted Posts (USP)</a></li>
263
+ </ul>
264
+ <p>
265
+ The plugin includes features to automatically add content to the USP posts and to create a Novo-Map marker with the location of an uploaded image attached as the post's Featured Image. To use the plugin:
266
+ </p>
267
+ <ul class="mla-doc-toc-list">
268
+ <li>Create a WordPress page that includes the <code>[user-submitted-posts]</code> shortcode,</li>
269
+ <li>Set the "Post Status" field to "Pending" so posts must be reviewed before publication,</li>
270
+ <li>Display the "Post Images" form field and check the "Featured Image" box in the USP "Image Uploads" section,</li>
271
+ <li>Configure the options for this plugin to add content, assign terms and create a Novo-Map marker when the post is reviewed for publication.</li>
272
+ </ul>
273
  <p>
274
+ The sections below give you more details about each of the plugin options in the General tab.
275
  <a name="process-usp"></a>
276
  </p>
277
  <p>
examples/plugins/mla-usp-novo-map-example/mla-usp-novo-map-example.php CHANGED
@@ -9,7 +9,7 @@
9
  * https://wordpress.org/support/topic/gps-fields/
10
  *
11
  * @package MLA USP Novo-Map Example
12
- * @version 1.02
13
  */
14
 
15
  /*
@@ -17,7 +17,7 @@ Plugin Name: MLA USP Novo-Map Example
17
  Plugin URI: http://davidlingren.com/
18
  Description: Fills posts created by the "User Submitted Posts" plugin with information for the "Novo Map" plugin
19
  Author: David Lingren
20
- Version: 1.02
21
  Author URI: http://davidlingren.com/
22
 
23
  Copyright 2018 David Lingren
@@ -53,7 +53,7 @@ class MLAUSPNovoMapExample {
53
  *
54
  * @var string
55
  */
56
- const CURRENT_VERSION = '1.02';
57
 
58
  /**
59
  * Slug prefix for registering and enqueueing submenu pages, style sheets, scripts and settings
9
  * https://wordpress.org/support/topic/gps-fields/
10
  *
11
  * @package MLA USP Novo-Map Example
12
+ * @version 1.03
13
  */
14
 
15
  /*
17
  Plugin URI: http://davidlingren.com/
18
  Description: Fills posts created by the "User Submitted Posts" plugin with information for the "Novo Map" plugin
19
  Author: David Lingren
20
+ Version: 1.03
21
  Author URI: http://davidlingren.com/
22
 
23
  Copyright 2018 David Lingren
53
  *
54
  * @var string
55
  */
56
+ const CURRENT_VERSION = '1.03';
57
 
58
  /**
59
  * Slug prefix for registering and enqueueing submenu pages, style sheets, scripts and settings
includes/class-mla-admin-columns-pro-support-44.php ADDED
@@ -0,0 +1,1408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Media Library Assistant Admin Columns Pro (plugin) Support
4
+ *
5
+ * @package Media Library Assistant
6
+ * @since 2.71
7
+ */
8
+ defined( 'ABSPATH' ) or die();
9
+
10
+ /**
11
+ * Class Admin Columns Addon MLA (Media Library Assistant) List Screen supports the Admin Columns plugin
12
+ *
13
+ * @package Media Library Assistant
14
+ * @since 2.71
15
+ */
16
+ class ACP_Addon_MLA_ListScreen extends AC_Addon_MLA_ListScreen
17
+ implements ACP\Editing\ListScreen, ACP\Export\ListScreen {
18
+
19
+ /**
20
+ * Initializes some properties, installs filters and then
21
+ * calls the parent constructor to set some default configs.
22
+ *
23
+ * @since 2.71
24
+ */
25
+ public function __construct() {
26
+ parent::__construct();
27
+
28
+ add_action( 'ac/table/list_screen', array( $this, 'export_table_global' ) );
29
+ }
30
+
31
+ /**
32
+ * Set MLA-specific inline editing strategy for Admin Columns Pro
33
+ *
34
+ * @since 2.71
35
+ *
36
+ * @param ACP\Editing\Model $model
37
+ */
38
+ public function editing( $model ) {
39
+ return new ACP_Addon_MLA_Editing_Strategy( $model );
40
+ }
41
+
42
+ /**
43
+ * Create and populate an MLA_List_Table object in the $wp_list_table global variable
44
+ *
45
+ * When exporting the same page is being requested by an ajax request and triggers the filter 'the_posts'.
46
+ * The callback for this filter will print a json string. This needs to be done before any rendering of the page.
47
+ *
48
+ * Also, export needs the $GLOBALS['wp_list_table'] to be populated for displaying the export button.
49
+ *
50
+ * @since 2.71
51
+ *
52
+ * @param AC_ListScreen $list_screen
53
+ */
54
+ public function export_table_global( AC_ListScreen $list_screen ) {
55
+ global $wp_list_table;
56
+
57
+ if ( ! $list_screen instanceof ACP_Addon_MLA_ListScreen ) {
58
+ return;
59
+ }
60
+
61
+ if ( ! class_exists( 'MLA_List_Table' ) ) {
62
+ require_once( MLA_PLUGIN_PATH . 'includes/class-mla-list-table.php' );
63
+ MLA_List_Table::mla_admin_init_action();
64
+ }
65
+
66
+ if ( $wp_list_table instanceof MLA_List_Table ) {
67
+ return;
68
+ }
69
+
70
+ $wp_list_table = new MLA_List_Table();
71
+ $wp_list_table->prepare_items();
72
+ }
73
+
74
+ /**
75
+ * Set MLA-specific export strategy for Admin Columns Pro
76
+ *
77
+ * @since 2.71
78
+ */
79
+ public function export() {
80
+ return new ACP_Addon_MLA_Export_Strategy( $this );
81
+ }
82
+
83
+ /**
84
+ * Register MLA-specific column definitions for Admin Columns Pro
85
+ *
86
+ * @since 2.71
87
+ */
88
+ public function register_column_types() {
89
+ parent::register_column_types();
90
+
91
+ // Autoload the CustomField class if necessary
92
+ if ( class_exists( 'ACP\Column\CustomField' ) ) {
93
+ $this->register_column_type( new ACP\Column\CustomField );
94
+ }
95
+
96
+ $this->register_column_type( new ACP_Addon_MLA_Column_ID_Parent );
97
+ $this->register_column_type( new ACP_Addon_MLA_Column_Title_Name() );
98
+ $this->register_column_type( new ACP_Addon_MLA_Column_Title() );
99
+ $this->register_column_type( new ACP_Addon_MLA_Column_Name() );
100
+ $this->register_column_type( new ACP_Addon_MLA_Column_Parent() );
101
+ $this->register_column_type( new ACP_Addon_MLA_Column_MenuOrder() );
102
+ $this->register_column_type( new ACP_Addon_MLA_Column_Features() );
103
+ $this->register_column_type( new ACP_Addon_MLA_Column_Inserts() );
104
+ $this->register_column_type( new ACP_Addon_MLA_Column_Galleries() );
105
+ $this->register_column_type( new ACP_Addon_MLA_Column_MLA_Galleries() );
106
+ $this->register_column_type( new ACP_Addon_MLA_Column_AltText() );
107
+ $this->register_column_type( new ACP_Addon_MLA_Column_Caption() );
108
+ $this->register_column_type( new ACP_Addon_MLA_Column_Description() );
109
+ $this->register_column_type( new ACP_Addon_MLA_Column_MimeType() );
110
+ $this->register_column_type( new ACP_Addon_MLA_Column_FileURL() );
111
+ $this->register_column_type( new ACP_Addon_MLA_Column_Base_File() );
112
+ $this->register_column_type( new ACP_Addon_MLA_Column_Date() );
113
+ $this->register_column_type( new ACP_Addon_MLA_Column_Modified() );
114
+ $this->register_column_type( new ACP_Addon_MLA_Column_Author() );
115
+ $this->register_column_type( new ACP_Addon_MLA_Column_Attached() );
116
+
117
+ // Set up the taxonomy column definitions
118
+ $taxonomies = get_taxonomies( array ( 'show_ui' => true ), 'names' );
119
+ foreach ( $taxonomies as $tax_name ) {
120
+ if ( MLACore::mla_taxonomy_support( $tax_name ) ) {
121
+ $tax_object = get_taxonomy( $tax_name );
122
+ $column = new ACP_Addon_MLA_Column_Taxonomy();
123
+ $column->set_type( 't_' . $tax_object->name );
124
+
125
+ $this->register_column_type( $column );
126
+ } // supported taxonomy
127
+ } // foreach $tax_name
128
+
129
+ // Set up the custom field definitions
130
+ $custom_columns = MLACore::mla_custom_field_support( 'custom_columns' );
131
+ foreach ( $custom_columns as $type => $label ) {
132
+ $column = new ACP_Addon_MLA_Column_CustomField();
133
+ $column->set_type( $type );
134
+ $column->set_name( $type );
135
+ $column->set_label( $label );
136
+
137
+ $this->register_column_type( $column );
138
+ } // foreach custom column
139
+ }
140
+
141
+ /**
142
+ * Return list table item object given ID
143
+ *
144
+ * @param integer $id List table item ID
145
+ *
146
+ * @since 2.71
147
+ */
148
+ public static function get_item( $id ) {
149
+ global $wp_list_table;
150
+
151
+ if ( $wp_list_table instanceof MLA_List_Table ) {
152
+ foreach ( $wp_list_table->items as $index => $item ) {
153
+ if ( $id == $item->ID ) {
154
+ return $item;
155
+ }
156
+ }
157
+ }
158
+
159
+ return get_post( $id );
160
+ }
161
+
162
+ /**
163
+ * Translate post_status 'future', 'pending', 'draft' and 'trash' to label
164
+ *
165
+ * @since 2.01
166
+ *
167
+ * @param string post_status
168
+ *
169
+ * @return string Status label or empty string
170
+ */
171
+ public static function format_post_status( $post_status ) {
172
+ $flag = ', ';
173
+ switch ( $post_status ) {
174
+ case 'draft' :
175
+ $flag .= __('Draft');
176
+ break;
177
+ case 'future' :
178
+ $flag .= __('Scheduled');
179
+ break;
180
+ case 'pending' :
181
+ $flag .= _x('Pending', 'post state');
182
+ break;
183
+ case 'trash' :
184
+ $flag .= __('Trash');
185
+ break;
186
+ default:
187
+ $flag = '';
188
+ }
189
+
190
+ return $flag;
191
+ }
192
+
193
+ } // class ACP_Addon_MLA_ListScreen
194
+
195
+ /**
196
+ * Exportability class for posts list screen
197
+ *
198
+ * @since 2.71
199
+ */
200
+ class ACP_Addon_MLA_Export_Strategy extends ACP\Export\Strategy {
201
+
202
+ /**
203
+ * Call parent constructor
204
+ *
205
+ * @param AC_ListScreen $list_screen
206
+ */
207
+ public function __construct( $list_screen ) {
208
+ parent::__construct( $list_screen );
209
+ }
210
+
211
+ /**
212
+ * Retrieve the headers for the columns
213
+ *
214
+ * @param AC\Column[] $columns
215
+ *
216
+ * @since 1.0
217
+ * @return string[] Associative array of header labels for the columns.
218
+ */
219
+ public function get_headers( array $columns ) {
220
+ $headers = parent::get_headers( $columns );
221
+
222
+ // Fix the first header to avoid MS Excel SYLK file format error
223
+ foreach ( $headers as $name => $label ) {
224
+ if ( 'ID' === substr( $label, 0, 2) ) {
225
+ $headers[ $name ] = '.' . $label;
226
+ }
227
+
228
+ break; // Only the first label matters
229
+ }
230
+
231
+ return $headers;
232
+ }
233
+
234
+ /**
235
+ * Add hooks for MLA_List_table to support AJAX export operation
236
+ *
237
+ * @since 2.71
238
+ * @see ACP_Export_ExportableListScreen::ajax_export()
239
+ */
240
+ protected function ajax_export() {
241
+ // Hooks
242
+ add_filter( 'mla_list_table_query_final_terms', array( $this, 'mla_list_table_query_final_terms' ), 1e6 );
243
+ add_action( 'mla_list_table_prepare_items', array( $this, 'mla_list_table_prepare_items' ), 10, 2 );
244
+ }
245
+
246
+ /**
247
+ * Modify the main posts query to use the correct pagination arguments. This should be attached
248
+ * to the pre_get_posts hook when an AJAX request is sent
249
+ *
250
+ * @param WP_Query $request
251
+ *
252
+ * @since 2.71
253
+ * @see action:pre_get_posts
254
+ */
255
+ public function mla_list_table_query_final_terms( $request ) {
256
+ $per_page = $this->get_num_items_per_iteration();
257
+ $request['offset'] = $this->get_export_counter() * $per_page;
258
+ $request['posts_per_page'] = $per_page;
259
+ $request['posts_per_archive_page'] = $per_page;
260
+
261
+ return $request;
262
+ }
263
+
264
+ /**
265
+ * Run the actual export when the posts query is finalized. This should be attached to the
266
+ * the_posts filter when an AJAX request is run
267
+ *
268
+ * @param WP_Query $query
269
+ *
270
+ * @since 2.71
271
+ * @see action:the_posts
272
+ */
273
+ public function mla_list_table_prepare_items( $query ) {
274
+ $this->export( wp_list_pluck( $query->items, 'ID' ) );
275
+ }
276
+ } // class ACP_Addon_MLA_Export_Strategy
277
+
278
+ /**
279
+ * Class Admin Columns Addon MLA (Media Library Assistant) Editing Strategy supports the Admin Columns plugin
280
+ *
281
+ * @package Media Library Assistant
282
+ * @since 2.71
283
+ */
284
+ class ACP_Addon_MLA_Editing_Strategy extends ACP\Editing\Strategy\Post {
285
+
286
+ /**
287
+ * Get the available items on the current page for passing them to JS
288
+ *
289
+ * @since 2.71
290
+ *
291
+ * @return array Items on the current page ([entry_id] => (array) [entry_data])
292
+ */
293
+ public function get_rows() {
294
+ global $wp_list_table;
295
+
296
+ // Re-execute the query because the table object can be shared with custom plugins using the MLA filters/actions
297
+ $wp_list_table->prepare_items();
298
+
299
+ return $this->get_editable_rows( $wp_list_table->items );
300
+ }
301
+ } // class ACP_Addon_MLA_Editing_Strategy
302
+
303
+ /**
304
+ * Provides view_settings for MLA's post_title
305
+ *
306
+ * @package Media Library Assistant
307
+ * @since 2.52
308
+ */
309
+ class ACP_Addon_MLA_Editing_Model_Media_Title extends ACP\Editing\Model\Media\Title {
310
+
311
+ /**
312
+ * Remove JavaScript selector settings
313
+ */
314
+ public function get_view_settings() {
315
+ return array(
316
+ 'type' => 'text',
317
+ 'display_ajax' => false,
318
+ );
319
+ }
320
+ }
321
+
322
+ /**
323
+ * Provides export for ID portion of ID/Parent
324
+ *
325
+ * @package Media Library Assistant
326
+ * @since 2.71
327
+ */
328
+ class ACP_Addon_MLA_Column_ID_Parent extends AC\Column
329
+ implements ACP\Export\Exportable {
330
+
331
+ /**
332
+ * Define column properties
333
+ */
334
+ public function __construct() {
335
+ // Mark as an existing column
336
+ $this->set_original( true );
337
+
338
+ // Type of column
339
+ $this->set_type( 'ID_parent' );
340
+ }
341
+
342
+ /**
343
+ * Support export
344
+ */
345
+ public function export() {
346
+ return new ACP\Export\Model\StrippedValue( $this );
347
+ }
348
+
349
+ /**
350
+ * Supply value for export
351
+ *
352
+ * @param integer $id MLA_List_table item ID
353
+ */
354
+ public function get_raw_value( $id ) {
355
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
356
+ return $item->ID;
357
+ }
358
+ }
359
+
360
+ /**
361
+ * Provides export for Name (slug)
362
+ *
363
+ * @package Media Library Assistant
364
+ * @since 2.71
365
+ */
366
+ class ACP_Addon_MLA_Column_Title_Name extends AC\Column
367
+ implements ACP\Export\Exportable {
368
+
369
+ /**
370
+ * Define column properties
371
+ */
372
+ public function __construct() {
373
+ $this->set_original( true );
374
+ $this->set_type( 'title_name' );
375
+ }
376
+
377
+ /**
378
+ * Support export
379
+ */
380
+ public function export() {
381
+ return new ACP\Export\Model\StrippedValue( $this );
382
+ }
383
+
384
+ /**
385
+ * Supply value for export
386
+ *
387
+ * @param integer $id MLA_List_table item ID
388
+ */
389
+ public function get_raw_value( $id ) {
390
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
391
+ $errors = $item->mla_references['parent_errors'];
392
+ if ( '(' . __( 'NO REFERENCE TESTS', 'media-library-assistant' ) . ')' == $errors ) {
393
+ $errors = '';
394
+ }
395
+ $format = "%1\$s\n%2\$s\n%3\$s";
396
+ return sprintf( $format, _draft_or_post_title( $item ), esc_attr( $item->post_name ), $errors );
397
+ }
398
+ }
399
+
400
+ /**
401
+ * Provides inline-editing, export for post_title
402
+ *
403
+ * @package Media Library Assistant
404
+ * @since 2.52
405
+ * @since 2.71 Added export
406
+ */
407
+ class ACP_Addon_MLA_Column_Title extends AC\Column\Media\Title
408
+ implements ACP\Editing\Editable, ACP\Export\Exportable {
409
+
410
+ /**
411
+ * Define column properties
412
+ */
413
+ public function __construct() {
414
+ $this->set_original( true );
415
+ $this->set_type( 'post_title' );
416
+ }
417
+
418
+ /**
419
+ * Add inline editing support
420
+ *
421
+ * @return ACP\Editing\Model\Media\Title
422
+ */
423
+ public function editing() {
424
+ return new ACP_Addon_MLA_Editing_Model_Media_Title( $this );
425
+ }
426
+
427
+ /**
428
+ * Support export
429
+ */
430
+ public function export() {
431
+ return new ACP\Export\Model\StrippedValue( $this );
432
+ }
433
+
434
+ /**
435
+ * Supply value for export
436
+ *
437
+ * @param integer $id MLA_List_table item ID
438
+ */
439
+ public function get_raw_value( $id ) {
440
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
441
+ return (string) $item->post_title;
442
+ }
443
+ }
444
+
445
+ /**
446
+ * Provides export for Name (slug)
447
+ *
448
+ * @package Media Library Assistant
449
+ * @since 2.71
450
+ */
451
+ class ACP_Addon_MLA_Column_Name extends AC\Column
452
+ implements ACP\Export\Exportable {
453
+
454
+ /**
455
+ * Define column properties
456
+ */
457
+ public function __construct() {
458
+ $this->set_original( true );
459
+ $this->set_type( 'post_name' );
460
+ }
461
+
462
+ /**
463
+ * Support export
464
+ */
465
+ public function export() {
466
+ return new ACP\Export\Model\StrippedValue( $this );
467
+ }
468
+
469
+ /**
470
+ * Supply value for export
471
+ *
472
+ * @param integer $id MLA_List_table item ID
473
+ */
474
+ public function get_raw_value( $id ) {
475
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
476
+ return (string) $item->post_name;
477
+ }
478
+ }
479
+
480
+ /**
481
+ * Removes ACP defaults, provides export for post_parent
482
+ *
483
+ * @package Media Library Assistant
484
+ * @since 2.52
485
+ * @since 2.71 Added export
486
+ */
487
+ class ACP_Addon_MLA_Column_Parent extends AC\Column\Media\MediaParent
488
+ implements ACP\Export\Exportable {
489
+ /**
490
+ * Remove default column width
491
+ */
492
+ public function register_settings() {
493
+ }
494
+
495
+ /**
496
+ * Support export
497
+ */
498
+ public function export() {
499
+ return new ACP\Export\Model\StrippedValue( $this );
500
+ }
501
+
502
+ /**
503
+ * Supply value for export
504
+ *
505
+ * @param integer $id MLA_List_table item ID
506
+ */
507
+ public function get_raw_value( $id ) {
508
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
509
+ return (string) $item->post_parent;
510
+ }
511
+ }
512
+
513
+ /**
514
+ * Provides inline-editing, export for menu_order
515
+ *
516
+ * @package Media Library Assistant
517
+ * @since 2.52
518
+ * @since 2.71 Added export
519
+ */
520
+ class ACP_Addon_MLA_Column_MenuOrder extends AC\Column
521
+ implements ACP\Editing\Editable, ACP\Export\Exportable {
522
+
523
+ /**
524
+ * Define column properties
525
+ */
526
+ public function __construct() {
527
+ $this->set_original( true );
528
+ $this->set_type( 'menu_order' );
529
+ }
530
+
531
+ /**
532
+ * Add inline editing support
533
+ *
534
+ * @return ACP\Editing\Model\Post\Order
535
+ */
536
+ public function editing() {
537
+ return new ACP\Editing\Model\Post\Order( $this );
538
+ }
539
+
540
+ /**
541
+ * Support export
542
+ */
543
+ public function export() {
544
+ return new ACP\Export\Model\StrippedValue( $this );
545
+ }
546
+
547
+ /**
548
+ * Supply value for export
549
+ *
550
+ * @param integer $id MLA_List_table item ID
551
+ */
552
+ public function get_raw_value( $id ) {
553
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
554
+ return (string) $item->menu_order;
555
+ }
556
+ }
557
+
558
+ /**
559
+ * Provides export for Featured in
560
+ *
561
+ * @package Media Library Assistant
562
+ * @since 2.71
563
+ */
564
+ class ACP_Addon_MLA_Column_Features extends AC\Column
565
+ implements ACP\Export\Exportable {
566
+
567
+ /**
568
+ * Define column properties
569
+ */
570
+ public function __construct() {
571
+ $this->set_original( true );
572
+ $this->set_type( 'featured' );
573
+ }
574
+
575
+ /**
576
+ * Support export
577
+ */
578
+ public function export() {
579
+ return new ACP\Export\Model\StrippedValue( $this );
580
+ }
581
+
582
+ /**
583
+ * Supply value for export
584
+ *
585
+ * @param integer $id MLA_List_table item ID
586
+ */
587
+ public function get_raw_value( $id ) {
588
+ if ( !MLACore::$process_featured_in ) {
589
+ return __( 'Disabled', 'media-library-assistant' );
590
+ }
591
+
592
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
593
+
594
+ // Move parent to the top of the list
595
+ $features = $item->mla_references['features'];
596
+ if ( isset( $features[ $item->post_parent ] ) ) {
597
+ $parent = $features[ $item->post_parent ];
598
+ unset( $features[ $item->post_parent ] );
599
+ array_unshift( $features, $parent );
600
+ }
601
+
602
+ $format = "%1\$s (%2\$s %3\$s%4\$s%5\$s),\n";
603
+ $value = '';
604
+ foreach ( $features as $feature ) {
605
+ $status = ACP_Addon_MLA_ListScreen::format_post_status( $feature->post_status );
606
+
607
+ if ( $feature->ID == $item->post_parent ) {
608
+ $parent = ", " . __( 'PARENT', 'media-library-assistant' );
609
+ } else {
610
+ $parent = '';
611
+ }
612
+
613
+ $value .= sprintf( $format, esc_attr( $feature->post_title ), esc_attr( $feature->post_type ), $feature->ID, $status, $parent );
614
+ } // foreach $feature
615
+
616
+ return $value;
617
+ }
618
+ }
619
+
620
+ /**
621
+ * Provides export for Inserted in
622
+ *
623
+ * @package Media Library Assistant
624
+ * @since 2.71
625
+ */
626
+ class ACP_Addon_MLA_Column_Inserts extends AC\Column
627
+ implements ACP\Export\Exportable {
628
+
629
+ /**
630
+ * Define column properties
631
+ */
632
+ public function __construct() {
633
+ $this->set_original( true );
634
+ $this->set_type( 'inserted' );
635
+ }
636
+
637
+ /**
638
+ * Support export
639
+ */
640
+ public function export() {
641
+ return new ACP\Export\Model\StrippedValue( $this );
642
+ }
643
+
644
+ /**
645
+ * Supply value for export
646
+ *
647
+ * @param integer $id MLA_List_table item ID
648
+ */
649
+ public function get_raw_value( $id ) {
650
+ if ( !MLACore::$process_inserted_in ) {
651
+ return __( 'Disabled', 'media-library-assistant' );
652
+ }
653
+
654
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
655
+
656
+ $format = "%1\$s (%2\$s %3\$s%4\$s%5\$s),\n";
657
+ $value = '';
658
+ foreach ( $item->mla_references['inserts'] as $file => $inserts ) {
659
+ if ( 'base' != $item->mla_references['inserted_option'] ) {
660
+ $value .= $file . "\n";
661
+ }
662
+
663
+ // Move parent to the top of the list
664
+ if ( isset( $inserts[ $item->post_parent ] ) ) {
665
+ $parent = $inserts[ $item->post_parent ];
666
+ unset( $inserts[ $item->post_parent ] );
667
+ array_unshift( $inserts, $parent );
668
+ }
669
+
670
+ foreach ( $inserts as $insert ) {
671
+ $status = ACP_Addon_MLA_ListScreen::format_post_status( $insert->post_status );
672
+
673
+ if ( $insert->ID == $item->post_parent ) {
674
+ $parent = ", " . __( 'PARENT', 'media-library-assistant' );
675
+ } else {
676
+ $parent = '';
677
+ }
678
+
679
+ $value .= sprintf( $format, esc_attr( $insert->post_title ), esc_attr( $insert->post_type ), $insert->ID, $status, $parent );
680
+ } // foreach $insert
681
+ } // foreach $file
682
+
683
+ return $value;
684
+ }
685
+ }
686
+
687
+ /**
688
+ * Provides export for Gallery in
689
+ *
690
+ * @package Media Library Assistant
691
+ * @since 2.71
692
+ */
693
+ class ACP_Addon_MLA_Column_Galleries extends AC\Column
694
+ implements ACP\Export\Exportable {
695
+
696
+ /**
697
+ * Define column properties
698
+ */
699
+ public function __construct() {
700
+ $this->set_original( true );
701
+ $this->set_type( 'galleries' );
702
+ }
703
+
704
+ /**
705
+ * Support export
706
+ */
707
+ public function export() {
708
+ return new ACP\Export\Model\StrippedValue( $this );
709
+ }
710
+
711
+ /**
712
+ * Supply value for export
713
+ *
714
+ * @param integer $id MLA_List_table item ID
715
+ */
716
+ public function get_raw_value( $id ) {
717
+ if ( !MLACore::$process_gallery_in ) {
718
+ return __( 'Disabled', 'media-library-assistant' );
719
+ }
720
+
721
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
722
+
723
+ // Move parent to the top of the list
724
+ $galleries = $item->mla_references['galleries'];
725
+ if ( isset( $galleries[ $item->post_parent ] ) ) {
726
+ $parent = $galleries[ $item->post_parent ];
727
+ unset( $galleries[ $item->post_parent ] );
728
+ array_unshift( $galleries, $parent );
729
+ }
730
+
731
+ $format = "%1\$s (%2\$s %3\$s%4\$s%5\$s),\n";
732
+ $value = '';
733
+ foreach ( $galleries as $ID => $gallery ) {
734
+ $status = ACP_Addon_MLA_ListScreen::format_post_status( $gallery['post_status'] );
735
+
736
+ if ( $gallery['ID'] == $item->post_parent ) {
737
+ $parent = ", " . __( 'PARENT', 'media-library-assistant' );
738
+ } else {
739
+ $parent = '';
740
+ }
741
+
742
+ $value .= sprintf( $format, esc_attr( $gallery['post_title'] ), esc_attr( $gallery['post_type'] ), $gallery['ID'], $status, $parent );
743
+ } // foreach $gallery
744
+
745
+ return $value;
746
+ }
747
+ }
748
+
749
+ /**
750
+ * Provides export for Gallery in
751
+ *
752
+ * @package Media Library Assistant
753
+ * @since 2.71
754
+ */
755
+ class ACP_Addon_MLA_Column_MLA_Galleries extends AC\Column
756
+ implements ACP\Export\Exportable {
757
+
758
+ /**
759
+ * Define column properties
760
+ */
761
+ public function __construct() {
762
+ $this->set_original( true );
763
+ $this->set_type( 'mla_galleries' );
764
+ }
765
+
766
+ /**
767
+ * Support export
768
+ */
769
+ public function export() {
770
+ return new ACP\Export\Model\StrippedValue( $this );
771
+ }
772
+
773
+ /**
774
+ * Supply value for export
775
+ *
776
+ * @param integer $id MLA_List_table item ID
777
+ */
778
+ public function get_raw_value( $id ) {
779
+ if ( !MLACore::$process_mla_gallery_in ) {
780
+ return __( 'Disabled', 'media-library-assistant' );
781
+ }
782
+
783
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
784
+
785
+ // Move parent to the top of the list
786
+ $mla_galleries = $item->mla_references['mla_galleries'];
787
+ if ( isset( $mla_galleries[ $item->post_parent ] ) ) {
788
+ $parent = $mla_galleries[ $item->post_parent ];
789
+ unset( $mla_galleries[ $item->post_parent ] );
790
+ array_unshift( $mla_galleries, $parent );
791
+ }
792
+
793
+ $format = "%1\$s (%2\$s %3\$s%4\$s%5\$s),\n";
794
+ $value = '';
795
+ foreach ( $mla_galleries as $gallery ) {
796
+ $status = ACP_Addon_MLA_ListScreen::format_post_status( $gallery['post_status'] );
797
+
798
+ if ( $gallery['ID'] == $item->post_parent ) {
799
+ $parent = ", " . __( 'PARENT', 'media-library-assistant' );
800
+ } else {
801
+ $parent = '';
802
+ }
803
+
804
+ $value .= sprintf( $format, esc_attr( $gallery['post_title'] ), esc_attr( $gallery['post_type'] ), $gallery['ID'], $status, $parent );
805
+ } // foreach $gallery
806
+
807
+ return $value;
808
+ }
809
+ }
810
+
811
+ /**
812
+ * Provides inline-editing, export for alt_text
813
+ *
814
+ * @package Media Library Assistant
815
+ * @since 2.52
816
+ * @since 2.71 Added export
817
+ */
818
+ class ACP_Addon_MLA_Column_AltText extends ACP\Column\Media\AlternateText
819
+ implements ACP\Editing\Editable, ACP\Export\Exportable {
820
+
821
+ /**
822
+ * Define column properties
823
+ */
824
+ public function __construct() {
825
+ $this->set_original( true );
826
+ $this->set_type( 'alt_text' );
827
+ }
828
+
829
+ /**
830
+ * Add inline editing support
831
+ *
832
+ * @return ACP\Editing\Model\Media\AlternateText
833
+ */
834
+ public function editing() {
835
+ return new ACP\Editing\Model\Media\AlternateText( $this );
836
+ }
837
+
838
+ /**
839
+ * Support export
840
+ */
841
+ public function export() {
842
+ return new ACP\Export\Model\StrippedValue( $this );
843
+ }
844
+
845
+ /**
846
+ * Supply value for export
847
+ *
848
+ * @param integer $id MLA_List_table item ID
849
+ */
850
+ public function get_raw_value( $id ) {
851
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
852
+
853
+ if ( isset( $item->mla_wp_attachment_image_alt ) ) {
854
+ if ( is_array( $item->mla_wp_attachment_image_alt ) ) {
855
+ $alt_text = $item->mla_wp_attachment_image_alt[0];
856
+ } else {
857
+ $alt_text = $item->mla_wp_attachment_image_alt;
858
+ }
859
+
860
+ return $alt_text;
861
+ }
862
+
863
+ return '';
864
+ }
865
+ }
866
+
867
+ /**
868
+ * Provides inline-editing, export for Caption/Excerpt
869
+ *
870
+ * @package Media Library Assistant
871
+ * @since 2.52
872
+ * @since 2.71 Added export
873
+ */
874
+ class ACP_Addon_MLA_Column_Caption extends ACP\Column\Media\Caption
875
+ implements ACP\Editing\Editable, ACP\Export\Exportable {
876
+
877
+ /**
878
+ * Define column properties
879
+ */
880
+ public function __construct() {
881
+ $this->set_original( true );
882
+ $this->set_type( 'caption' );
883
+ }
884
+
885
+ /**
886
+ * Support export
887
+ */
888
+ public function export() {
889
+ return new ACP\Export\Model\StrippedValue( $this );
890
+ }
891
+
892
+ /**
893
+ * Supply value for export
894
+ *
895
+ * @param integer $id MLA_List_table item ID
896
+ */
897
+ public function get_raw_value( $id ) {
898
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
899
+ return (string) $item->post_excerpt;
900
+ }
901
+ }
902
+
903
+ /**
904
+ * Provides inline-editing, export for Description
905
+ *
906
+ * @package Media Library Assistant
907
+ * @since 2.52
908
+ * @since 2.71 Added export
909
+ */
910
+ class ACP_Addon_MLA_Column_Description extends AC\Column\Media\Description
911
+ implements ACP\Editing\Editable, ACP\Export\Exportable {
912
+
913
+ /**
914
+ * Define column properties
915
+ */
916
+ public function __construct() {
917
+ $this->set_original( true );
918
+ $this->set_type( 'description' );
919
+ }
920
+
921
+ /**
922
+ * Add inline editing and provides export for Description
923
+ *
924
+ * @return ACP\Editing\Model\Post\Content
925
+ */
926
+ public function editing() {
927
+ return new ACP\Editing\Model\Post\Content( $this );
928
+ }
929
+
930
+ /**
931
+ * Support export
932
+ */
933
+ public function export() {
934
+ return new ACP\Export\Model\StrippedValue( $this );
935
+ }
936
+
937
+ /**
938
+ * Supply value for export
939
+ *
940
+ * @param integer $id MLA_List_table item ID
941
+ */
942
+ public function get_raw_value( $id ) {
943
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
944
+ return (string) $item->post_content;
945
+ }
946
+ }
947
+
948
+ /**
949
+ * Provides inline-editing, export for MIME Type
950
+ *
951
+ * @package Media Library Assistant
952
+ * @since 2.52
953
+ * @since 2.71 Added export
954
+ */
955
+ class ACP_Addon_MLA_Column_MimeType extends AC\Column\Media\MimeType
956
+ implements ACP\Editing\Editable, ACP\Export\Exportable {
957
+
958
+ /**
959
+ * Define column properties
960
+ */
961
+ public function __construct() {
962
+ $this->set_original( true );
963
+ $this->set_type( 'post_mime_type' );
964
+ }
965
+
966
+ /**
967
+ * Add inline editing support
968
+ *
969
+ * @return ACP\Editing\Model\Media\MimeType
970
+ */
971
+ public function editing() {
972
+ return new ACP\Editing\Model\Media\MimeType( $this );
973
+ }
974
+
975
+ /**
976
+ * Support export
977
+ */
978
+ public function export() {
979
+ return new ACP\Export\Model\StrippedValue( $this );
980
+ }
981
+
982
+ /**
983
+ * Supply value for export
984
+ *
985
+ * @param integer $id MLA_List_table item ID
986
+ */
987
+ public function get_raw_value( $id ) {
988
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
989
+ return (string) $item->post_mime_type;
990
+ }
991
+ }
992
+
993
+ /**
994
+ * Provides export for File URL
995
+ *
996
+ * @package Media Library Assistant
997
+ * @since 2.71
998
+ */
999
+ class ACP_Addon_MLA_Column_FileURL extends AC\Column
1000
+ implements ACP\Export\Exportable {
1001
+
1002
+ /**
1003
+ * Define column properties
1004
+ */
1005
+ public function __construct() {
1006
+ $this->set_original( true );
1007
+ $this->set_type( 'file_url' );
1008
+ }
1009
+
1010
+ /**
1011
+ * Support export
1012
+ */
1013
+ public function export() {
1014
+ return new ACP\Export\Model\StrippedValue( $this );
1015
+ }
1016
+
1017
+ /**
1018
+ * Supply value for export
1019
+ *
1020
+ * @param integer $id MLA_List_table item ID
1021
+ */
1022
+ public function get_raw_value( $id ) {
1023
+ $attachment_url = wp_get_attachment_url( $id );
1024
+ return $attachment_url ? $attachment_url : __( 'None', 'media-library-assistant' );
1025
+ }
1026
+ }
1027
+
1028
+ /**
1029
+ * Provides export for Base File
1030
+ *
1031
+ * @package Media Library Assistant
1032
+ * @since 2.71
1033
+ */
1034
+ class ACP_Addon_MLA_Column_Base_File extends AC\Column
1035
+ implements ACP\Export\Exportable {
1036
+
1037
+ /**
1038
+ * Define column properties
1039
+ */
1040
+ public function __construct() {
1041
+ $this->set_original( true );
1042
+ $this->set_type( 'base_file' );
1043
+ }
1044
+
1045
+ /**
1046
+ * Support export
1047
+ */
1048
+ public function export() {
1049
+ return new ACP\Export\Model\StrippedValue( $this );
1050
+ }
1051
+
1052
+ /**
1053
+ * Supply value for export
1054
+ *
1055
+ * @param integer $id MLA_List_table item ID
1056
+ */
1057
+ public function get_raw_value( $id ) {
1058
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
1059
+ if ( isset( $item->mla_wp_attached_file ) ) {
1060
+ return (string) $item->mla_wp_attached_file;
1061
+ }
1062
+
1063
+ return 'ERROR';
1064
+ }
1065
+ }
1066
+
1067
+ /**
1068
+ * Provides export for Attached to
1069
+ *
1070
+ * @package Media Library Assistant
1071
+ * @since 2.71
1072
+ */
1073
+ class ACP_Addon_MLA_Column_Attached extends AC\Column
1074
+ implements ACP\Export\Exportable {
1075
+
1076
+ /**
1077
+ * Define column properties
1078
+ */
1079
+ public function __construct() {
1080
+ $this->set_original( true );
1081
+ $this->set_type( 'attached_to' );
1082
+ }
1083
+
1084
+ /**
1085
+ * Support export
1086
+ */
1087
+ public function export() {
1088
+ return new ACP\Export\Model\StrippedValue( $this );
1089
+ }
1090
+
1091
+ /**
1092
+ * Supply value for export
1093
+ *
1094
+ * @param integer $id MLA_List_table item ID
1095
+ */
1096
+ public function get_raw_value( $id ) {
1097
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
1098
+
1099
+ if ( isset( $item->parent_title ) ) {
1100
+ $parent_type = get_post_type_object( $item->parent_type );
1101
+ if ( $parent_type ) {
1102
+ if ( $parent_type->show_ui ) {
1103
+ $user_can_read_parent = current_user_can( 'read_post', $item->post_parent );
1104
+ } else {
1105
+ $user_can_read_parent = true;
1106
+ }
1107
+ } else {
1108
+ $user_can_read_parent = false;
1109
+ }
1110
+
1111
+ if ( $user_can_read_parent ) {
1112
+ $parent_title = esc_attr( $item->parent_title );
1113
+ } else {
1114
+ $parent_title = __( '(Private post)' );
1115
+ }
1116
+
1117
+ if ( isset( $item->parent_date ) && $user_can_read_parent ) {
1118
+ $parent_date = "\n" . mysql2date( __( 'Y/m/d', 'media-library-assistant' ), $item->parent_date );
1119
+ } else {
1120
+ $parent_date = '';
1121
+ }
1122
+
1123
+ if ( isset( $item->parent_type ) && $user_can_read_parent ) {
1124
+ $parent_type = "\n" . '(' . $item->parent_type . ' ' . (string) $item->post_parent . ACP_Addon_MLA_ListScreen::format_post_status( $item->parent_status ) . ')';
1125
+ } else {
1126
+ $parent_type = '';
1127
+ }
1128
+
1129
+ $parent = sprintf( '%1$s%2$s%3$s', /*%1$s*/ $parent_title, /*%2$s*/ $parent_date, /*%3$s*/ $parent_type );
1130
+ } else {
1131
+ $parent = '(' . _x( 'Unattached', 'table_view_singular', 'media-library-assistant' ) . ')';
1132
+ }
1133
+
1134
+ return $parent;
1135
+ }
1136
+ }
1137
+
1138
+ /**
1139
+ * Removes ACP defaults and provides export for date
1140
+ *
1141
+ * @package Media Library Assistant
1142
+ * @since 2.52
1143
+ * @since 2.71 Added export
1144
+ */
1145
+ class ACP_Addon_MLA_Column_Date extends ACP\Column\Media\Date
1146
+ implements ACP\Export\Exportable {
1147
+
1148
+ /**
1149
+ * Remove default column width
1150
+ */
1151
+ public function register_settings() {
1152
+ }
1153
+
1154
+ /**
1155
+ * Support export
1156
+ */
1157
+ public function export() {
1158
+ return new ACP\Export\Model\StrippedValue( $this );
1159
+ }
1160
+
1161
+ /**
1162
+ * Supply value for export
1163
+ *
1164
+ * @param integer $id MLA_List_table item ID
1165
+ */
1166
+ public function get_raw_value( $id ) {
1167
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
1168
+ return (string) $item->post_date;
1169
+ }
1170
+ }
1171
+
1172
+ /**
1173
+ * Provides export for Last Modified date
1174
+ *
1175
+ * @package Media Library Assistant
1176
+ * @since 2.71
1177
+ */
1178
+ class ACP_Addon_MLA_Column_Modified extends AC\Column
1179
+ implements ACP\Export\Exportable {
1180
+
1181
+ /**
1182
+ * Define column properties
1183
+ */
1184
+ public function __construct() {
1185
+ $this->set_original( true );
1186
+ $this->set_type( 'modified' );
1187
+ }
1188
+
1189
+ /**
1190
+ * Support export
1191
+ */
1192
+ public function export() {
1193
+ return new ACP\Export\Model\StrippedValue( $this );
1194
+ }
1195
+
1196
+ /**
1197
+ * Supply value for export
1198
+ *
1199
+ * @param integer $id MLA_List_table item ID
1200
+ */
1201
+ public function get_raw_value( $id ) {
1202
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
1203
+ return (string) $item->post_modified;
1204
+ }
1205
+ }
1206
+
1207
+ /**
1208
+ * Removes ACP defaults & provides inline-editing, export for Author name
1209
+ *
1210
+ * @package Media Library Assistant
1211
+ * @since 2.52
1212
+ * @since 2.71 Added export
1213
+ */
1214
+ class ACP_Addon_MLA_Column_Author extends AC\Column\Media\Author
1215
+ implements ACP\Editing\Editable, ACP\Export\Exportable {
1216
+
1217
+ /**
1218
+ * Remove default column width
1219
+ */
1220
+ public function register_settings() {
1221
+ }
1222
+
1223
+ /**
1224
+ * Add inline editing support
1225
+ *
1226
+ * @return ACP\Editing\Model\Post\Author
1227
+ */
1228
+ public function editing() {
1229
+ return new ACP\Editing\Model\Post\Author( $this );
1230
+ }
1231
+
1232
+ /**
1233
+ * Support export
1234
+ */
1235
+ public function export() {
1236
+ return new ACP\Export\Model\StrippedValue( $this );
1237
+ }
1238
+
1239
+ /**
1240
+ * Supply value for export
1241
+ *
1242
+ * @param integer $id MLA_List_table item ID
1243
+ */
1244
+ public function get_raw_value( $id ) {
1245
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
1246
+ $user = get_user_by( 'id', $item->post_author );
1247
+
1248
+ if ( isset( $user->data->display_name ) ) {
1249
+ return $user->data->display_name;
1250
+ }
1251
+
1252
+ return 'unknown';
1253
+ }
1254
+ }
1255
+
1256
+ /**
1257
+ * Provides export for supported taxonomies
1258
+ *
1259
+ * @package Media Library Assistant
1260
+ * @since 2.71
1261
+ */
1262
+ class ACP_Addon_MLA_Column_Taxonomy extends AC\Column
1263
+ implements ACP\Export\Exportable {
1264
+
1265
+ /**
1266
+ * Define column properties
1267
+ *
1268
+ * set_type( 't_' . taxonomy ) is done by the calling function.
1269
+ */
1270
+ public function __construct() {
1271
+ $this->set_original( true );
1272
+ }
1273
+
1274
+ /**
1275
+ * Extract taxonomy slug from type name
1276
+ *
1277
+ * @return string Taxonomy name/slug
1278
+ */
1279
+ public function get_taxonomy() {
1280
+ return substr( $this->get_type(), 2 );
1281
+ }
1282
+
1283
+ /**
1284
+ * Does this post type have registered taxonomies
1285
+ *
1286
+ * @return bool True when post type has associated taxonomies
1287
+ */
1288
+ public function is_valid() {
1289
+ return true;
1290
+ }
1291
+
1292
+ /**
1293
+ * Support export
1294
+ */
1295
+ public function export() {
1296
+ return new ACP\Export\Model\StrippedValue( $this );
1297
+ }
1298
+
1299
+ /**
1300
+ * Supply value for export
1301
+ *
1302
+ * @param integer $id MLA_List_table item ID
1303
+ */
1304
+ public function get_raw_value( $id ) {
1305
+ $terms = wp_get_post_terms( $id, $this->get_taxonomy(), array( 'fields' => 'names' ) );
1306
+
1307
+ if ( ! $terms || is_wp_error( $terms ) ) {
1308
+ return '';
1309
+ }
1310
+
1311
+ return implode( ', ', $terms );
1312
+ }
1313
+ }
1314
+
1315
+ /**
1316
+ * Provides export for supported custom fields
1317
+ *
1318
+ * @package Media Library Assistant
1319
+ * @since 2.71
1320
+ */
1321
+ class ACP_Addon_MLA_Column_CustomField extends AC\Column
1322
+ implements ACP\Export\Exportable {
1323
+
1324
+ /**
1325
+ * Define column properties
1326
+ *
1327
+ * set_type( 'c_' . field number ) is done by the calling function.
1328
+ */
1329
+ public function __construct() {
1330
+ $this->set_original( true );
1331
+ }
1332
+
1333
+ /**
1334
+ * Does this post type support custom fields
1335
+ *
1336
+ * @return bool True when post type has custom fields
1337
+ */
1338
+ public function is_valid() {
1339
+ return true;
1340
+ }
1341
+
1342
+ /**
1343
+ * Support export
1344
+ */
1345
+ public function export() {
1346
+ return new ACP\Export\Model\StrippedValue( $this );
1347
+ }
1348
+
1349
+ /**
1350
+ * Supply value for export
1351
+ *
1352
+ * @param integer $id MLA_List_table item ID
1353
+ */
1354
+ public function get_raw_value( $id ) {
1355
+ static $custom_columns = NULL;
1356
+
1357
+ if ( NULL === $custom_columns ) {
1358
+ $custom_columns = MLACore::mla_custom_field_support( 'custom_columns' );
1359
+ }
1360
+
1361
+ $column_name = $this->get_name();
1362
+ $item = ACP_Addon_MLA_ListScreen::get_item( $id );
1363
+
1364
+ if ( 'meta:' == substr( $custom_columns[ $column_name ], 0, 5 ) ) {
1365
+ $is_meta = true;
1366
+ $meta_key = substr( $custom_columns[ $column_name ], 5 );
1367
+
1368
+ if ( !empty( $item->mla_wp_attachment_metadata ) ) {
1369
+ $values = MLAData::mla_find_array_element( $meta_key, $item->mla_wp_attachment_metadata, 'array' );
1370
+
1371
+ if ( is_scalar( $values ) ) {
1372
+ $values = array( $values );
1373
+ }
1374
+ } else {
1375
+ $values = NULL;
1376
+ }
1377
+ } else {
1378
+ $is_meta = false;
1379
+ $values = get_post_meta( $item->ID, $custom_columns[ $column_name ], false );
1380
+ }
1381
+
1382
+ if ( empty( $values ) ) {
1383
+ return '';
1384
+ }
1385
+
1386
+ $list = array();
1387
+ foreach ( $values as $index => $value ) {
1388
+ /*
1389
+ * For display purposes, convert array values.
1390
+ * Use "@" because embedded arrays throw PHP Warnings from implode.
1391
+ */
1392
+ if ( is_array( $value ) ) {
1393
+ $list[] = 'array( ' . @implode( ', ', $value ) . ' )'; // TODO PHP 7 error handling
1394
+ } elseif ( $is_meta ) {
1395
+ $list[] = $value;
1396
+ } else {
1397
+ $list[] = esc_html( $value );
1398
+ }
1399
+ }
1400
+
1401
+ if ( count( $list ) > 1 ) {
1402
+ return '[' . join( '], [', $list ) . ']';
1403
+ } else {
1404
+ return $list[0];
1405
+ }
1406
+ }
1407
+ }
1408
+ ?>
includes/class-mla-admin-columns-pro-support.php CHANGED
@@ -35,8 +35,8 @@ class ACP_Addon_MLA_ListScreen extends AC_Addon_MLA_ListScreen
35
  *
36
  * @param ACP\Editing\Model $model
37
  */
38
- public function editing( $model ) {
39
- return new ACP_Addon_MLA_Editing_Strategy( $model );
40
  }
41
 
42
  /**
35
  *
36
  * @param ACP\Editing\Model $model
37
  */
38
+ public function editing( /* $model */ ) {
39
+ return new ACP_Addon_MLA_Editing_Strategy( 'attachment' /* $model */ );
40
  }
41
 
42
  /**
includes/class-mla-ajax.php CHANGED
@@ -32,14 +32,22 @@ class MLA_Ajax {
32
  * @return void
33
  */
34
  public static function initialize() {
35
- $ajax_only = var_export( self::$ajax_only, true );
36
- MLACore::mla_debug_add( __LINE__ . " MLA_Ajax::initialize( {$ajax_only} ) \$_REQUEST = " . var_export( $_REQUEST, true ), MLACore::MLA_DEBUG_CATEGORY_AJAX );
37
- add_action( 'admin_init', 'MLA_Ajax::mla_admin_init_action' );
 
 
 
 
 
 
38
 
39
  // Defined here because the "admin_init" action is not called for item transfers
40
- if ( ( defined('DOING_AJAX') && DOING_AJAX ) && ( 'mla_named_transfer' == $_REQUEST['action'] ) ) {
41
  add_action( 'wp_ajax_' . 'mla_named_transfer', 'MLA_Ajax::mla_named_transfer_ajax_action' );
42
  add_action( 'wp_ajax_nopriv_' . 'mla_named_transfer', 'MLA_Ajax::mla_named_transfer_ajax_action' );
 
 
43
  }
44
  }
45
 
@@ -50,27 +58,12 @@ class MLA_Ajax {
50
  * @since 2.20
51
  */
52
  public static function mla_admin_init_action( ) {
53
- $ajax_only = var_export( self::$ajax_only, true );
54
-
55
- //error_log( __LINE__ . " MLA_Ajax::mla_admin_init_action( {$ajax_only} ) \$_REQUEST = " . var_export( $_REQUEST, true ), 0 );
56
- //error_log( __LINE__ . " MLA_Ajax::mla_admin_init_action( {$ajax_only} ) \$_POST = " . var_export( $_POST, true ), 0 );
57
- //error_log( __LINE__ . " MLA_Ajax::mla_admin_init_action( {$ajax_only} ) \$_GET = " . var_export( $_GET, true ), 0 );
58
- if ( $_REQUEST['action'] !== 'heartbeat' ) {
59
- //error_log( __LINE__ . " MLA_Ajax::mla_admin_init_action( {$ajax_only} ) \$_REQUEST = " . var_export( $_REQUEST, true ), 0 );
60
- MLACore::mla_debug_add( __LINE__ . " MLA_Ajax::mla_admin_init_action( {$ajax_only} ) \$_REQUEST = " . var_export( $_REQUEST, true ), MLACore::MLA_DEBUG_CATEGORY_AJAX );
61
- }
62
-
63
- // If there's no action variable, we have nothing more to do
64
- if ( ! isset( $_POST['action'] ) ) {
65
- return;
66
- }
67
-
68
  /*
69
  * For flat taxonomies that use the checklist meta box, substitute our own handler
70
  * for /wp-admin/includes/ajax-actions.php function _wp_ajax_add_hierarchical_term().
71
  */
72
- if ( ( defined('DOING_AJAX') && DOING_AJAX ) && ( 'add-' == substr( $_POST['action'], 0, 4 ) ) ) {
73
- $key = substr( $_POST['action'], 4 );
74
  if ( MLACore::mla_taxonomy_support( $key, 'flat-checklist' ) ) {
75
  self::_mla_ajax_add_flat_term( $key );
76
  /* note: this function sends an Ajax response and then dies; no return */
@@ -88,13 +81,13 @@ class MLA_Ajax {
88
  *
89
  * @since 2.20
90
  *
91
- * @param string The taxonomy name, from $_POST['action']
92
  *
93
  * @return void Sends JSON response with updated HTML for the checklist
94
  */
95
  private static function _mla_ajax_add_flat_term( $key ) {
96
  $taxonomy = get_taxonomy( $key );
97
- check_ajax_referer( $_POST['action'], '_ajax_nonce-add-' . $key, true );
98
 
99
  if ( !current_user_can( $taxonomy->cap->edit_terms ) ) {
100
  wp_die( -1 );
32
  * @return void
33
  */
34
  public static function initialize() {
35
+ if ( ! ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'heartbeat' ) ) {
36
+ $ajax_only = var_export( self::$ajax_only, true );
37
+ MLACore::mla_debug_add( __LINE__ . " MLA_Ajax::initialize( {$ajax_only} ) \$_REQUEST = " . var_export( $_REQUEST, true ), MLACore::MLA_DEBUG_CATEGORY_AJAX );
38
+ }
39
+
40
+ // If there's no action variable, we have nothing more to do
41
+ if ( ! isset( $_REQUEST['action'] ) ) {
42
+ return;
43
+ }
44
 
45
  // Defined here because the "admin_init" action is not called for item transfers
46
+ if ( 'mla_named_transfer' == $_REQUEST['action'] ) {
47
  add_action( 'wp_ajax_' . 'mla_named_transfer', 'MLA_Ajax::mla_named_transfer_ajax_action' );
48
  add_action( 'wp_ajax_nopriv_' . 'mla_named_transfer', 'MLA_Ajax::mla_named_transfer_ajax_action' );
49
+ } else {
50
+ add_action( 'admin_init', 'MLA_Ajax::mla_admin_init_action' );
51
  }
52
  }
53
 
58
  * @since 2.20
59
  */
60
  public static function mla_admin_init_action( ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  /*
62
  * For flat taxonomies that use the checklist meta box, substitute our own handler
63
  * for /wp-admin/includes/ajax-actions.php function _wp_ajax_add_hierarchical_term().
64
  */
65
+ if ( ( defined('DOING_AJAX') && DOING_AJAX ) && ( 'add-' == substr( $_REQUEST['action'], 0, 4 ) ) ) {
66
+ $key = substr( $_REQUEST['action'], 4 );
67
  if ( MLACore::mla_taxonomy_support( $key, 'flat-checklist' ) ) {
68
  self::_mla_ajax_add_flat_term( $key );
69
  /* note: this function sends an Ajax response and then dies; no return */
81
  *
82
  * @since 2.20
83
  *
84
+ * @param string The taxonomy name, from $_REQUEST['action']
85
  *
86
  * @return void Sends JSON response with updated HTML for the checklist
87
  */
88
  private static function _mla_ajax_add_flat_term( $key ) {
89
  $taxonomy = get_taxonomy( $key );
90
+ check_ajax_referer( $_REQUEST['action'], '_ajax_nonce-add-' . $key, true );
91
 
92
  if ( !current_user_can( $taxonomy->cap->edit_terms ) ) {
93
  wp_die( -1 );
includes/class-mla-core.php CHANGED
@@ -21,7 +21,7 @@ class MLACore {
21
  *
22
  * @var string
23
  */
24
- const CURRENT_MLA_VERSION = '2.77';
25
 
26
  /**
27
  * Slug for registering and enqueueing plugin style sheets (moved from class-mla-main.php)
@@ -596,7 +596,7 @@ class MLACore {
596
 
597
  if ( $mla_reporting ) {
598
  MLACore::$mla_debug_level = $mla_reporting | 1;
599
- if ( class_exists( 'MLA' ) ) {
600
  MLACore::mla_debug_add( __LINE__ . sprintf( ' MLACore::mla_plugins_loaded_action() MLA %s (%s) mla_debug_level 0x%X', MLACore::CURRENT_MLA_VERSION, MLA::MLA_DEVELOPMENT_VERSION, MLACore::$mla_debug_level, true ), MLACore::MLA_DEBUG_CATEGORY_ANY );
601
  }
602
  } else {
@@ -1776,9 +1776,12 @@ class MLACore {
1776
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-admin-columns-support.php' );
1777
 
1778
  if ( function_exists( 'ACP' ) ) {
1779
- if ( version_compare( ACP()->get_version(), '4.3', '>=' ) ) {
1780
  // Load the latest version, with namespace support
1781
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-admin-columns-pro-support.php' );
 
 
 
1782
  } elseif ( version_compare( ACP()->get_version(), '4.2.3', '>=' ) ) {
1783
  // Load the interim version, with export support
1784
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-admin-columns-pro-support-423.php' );
21
  *
22
  * @var string
23
  */
24
+ const CURRENT_MLA_VERSION = '2.78';
25
 
26
  /**
27
  * Slug for registering and enqueueing plugin style sheets (moved from class-mla-main.php)
596
 
597
  if ( $mla_reporting ) {
598
  MLACore::$mla_debug_level = $mla_reporting | 1;
599
+ if ( class_exists( 'MLA' ) && ! ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'heartbeat' ) ) {
600
  MLACore::mla_debug_add( __LINE__ . sprintf( ' MLACore::mla_plugins_loaded_action() MLA %s (%s) mla_debug_level 0x%X', MLACore::CURRENT_MLA_VERSION, MLA::MLA_DEVELOPMENT_VERSION, MLACore::$mla_debug_level, true ), MLACore::MLA_DEBUG_CATEGORY_ANY );
601
  }
602
  } else {
1776
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-admin-columns-support.php' );
1777
 
1778
  if ( function_exists( 'ACP' ) ) {
1779
+ if ( version_compare( ACP()->get_version(), '4.5', '>=' ) ) {
1780
  // Load the latest version, with namespace support
1781
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-admin-columns-pro-support.php' );
1782
+ } elseif ( version_compare( ACP()->get_version(), '4.3', '>=' ) ) {
1783
+ // Load the interim version, without bulk edit support
1784
+ require_once( MLA_PLUGIN_PATH . 'includes/class-mla-admin-columns-pro-support-44.php' );
1785
  } elseif ( version_compare( ACP()->get_version(), '4.2.3', '>=' ) ) {
1786
  // Load the interim version, with export support
1787
  require_once( MLA_PLUGIN_PATH . 'includes/class-mla-admin-columns-pro-support-423.php' );
includes/class-mla-data-query.php CHANGED
@@ -671,6 +671,128 @@ class MLAQuery {
671
  return array();
672
  } // mla_custom_field_option_value
673
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
674
  /**
675
  * Sanitize and expand query arguments from request variables
676
  *
@@ -696,9 +818,7 @@ class MLAQuery {
696
  return NULL;
697
  }
698
 
699
- /*
700
- * Make sure the current orderby choice still exists or revert to default.
701
- */
702
  $default_orderby = array_merge( array( 'none' => array('none',false) ), self::mla_get_sortable_columns( ) );
703
  $current_orderby = MLACore::mla_get_option( MLACoreOptions::MLA_DEFAULT_ORDERBY );
704
  $found_current = false;
@@ -934,22 +1054,16 @@ class MLAQuery {
934
  unset( $clean_request['debug'] );
935
  }
936
 
937
- /*
938
- * We must patch the WHERE clause if there are leading spaces in the meta_value
939
- */
940
  if ( isset( $clean_request['mla-metavalue'] ) && ( 0 < strlen( $clean_request['mla-metavalue'] ) ) && ( ' ' == $clean_request['mla-metavalue'][0] ) ) {
941
  self::$query_parameters['mla-metavalue'] = $clean_request['mla-metavalue'];
942
  }
943
 
944
- /*
945
- * We will handle "Terms Search" in the mla_query_posts_search_filter.
946
- */
947
  if ( isset( $clean_request['mla_terms_search'] ) ) {
948
  self::$search_parameters['mla_terms_search'] = $clean_request['mla_terms_search'];
949
 
950
- /*
951
- * The Terms Search overrides any terms-based keyword search for now; too complicated.
952
- */
953
  if ( isset( $clean_request['mla_search_fields'] ) ) {
954
  foreach ( $clean_request['mla_search_fields'] as $index => $field ) {
955
  if ( 'terms' == $field ) {
@@ -959,9 +1073,7 @@ class MLAQuery {
959
  }
960
  }
961
 
962
- /*
963
- * We will handle keyword search in the mla_query_posts_search_filter.
964
- */
965
  if ( isset( $clean_request['s'] ) ) {
966
  self::$search_parameters['s'] = $clean_request['s'];
967
  self::$search_parameters['mla_search_fields'] = apply_filters( 'mla_list_table_search_filter_fields', $clean_request['mla_search_fields'], array( 'title', 'name', 'alt-text', 'excerpt', 'content', 'file' ,'terms' ) );
@@ -1033,9 +1145,7 @@ class MLAQuery {
1033
  } // switch $orderby
1034
  }
1035
 
1036
- /*
1037
- * Ignore incoming paged value; use offset and count instead
1038
- */
1039
  if ( ( (int) $count ) > 0 ) {
1040
  $clean_request['offset'] = $offset;
1041
  $clean_request['posts_per_page'] = $count;
@@ -1103,7 +1213,43 @@ class MLAQuery {
1103
  unset( $clean_request['mla-metakey'] );
1104
  unset( $clean_request['mla-metavalue'] );
1105
  } // isset mla_tax
1106
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1107
  return $clean_request;
1108
  }
1109
 
@@ -1282,7 +1428,7 @@ class MLAQuery {
1282
  * @return array individual arguments, e.g. array( 0 => '"a phrase"', 1 => 'separate', 2 => 'phrase' )
1283
  */
1284
  private static function _parse_terms_search( $whole_string, $delimiter = ',', $full_parse = false ) {
1285
- $trim_list = " \n\t\r\0\x0B,";
1286
  if ( false === strpos( $trim_list, $delimiter ) ) {
1287
  $trim_list .= $delimiter;
1288
  }
@@ -1290,6 +1436,7 @@ class MLAQuery {
1290
  $whole_string = trim( $whole_string, $trim_list );
1291
  $phrases = array();
1292
 
 
1293
  while ( strlen( $whole_string ) ) {
1294
  $argument = '';
1295
  $index = 0;
@@ -1341,7 +1488,10 @@ class MLAQuery {
1341
  $phrases[] = $current_delimiter . $argument . $current_delimiter;
1342
  }
1343
 
 
1344
  $whole_string = trim( substr( $whole_string, $index ), $trim_list );
 
 
1345
  } // strlen( $whole_string )
1346
 
1347
  return $phrases;
@@ -1360,12 +1510,14 @@ class MLAQuery {
1360
  * @return integer Taxonomy JOIN clauses required. Updates $tax_clause as well
1361
  */
1362
  private static function _generate_tax_clause( $terms_search_parameters, &$tax_clause ) {
 
1363
  $term_delimiter = isset( $terms_search_parameters['term_delimiter'] ) ? $terms_search_parameters['term_delimiter'] : ',';
1364
  $phrase_delimiter = isset( $terms_search_parameters['phrase_delimiter'] ) ? $terms_search_parameters['phrase_delimiter'] : ' ';
1365
  $tax_clause = '';
1366
  $tax_index = 0;
1367
 
1368
  $terms = self::_parse_terms_search( $terms_search_parameters['phrases'], $term_delimiter );
 
1369
  if ( 1 < count( $terms ) ) {
1370
  $terms_connector = '(';
1371
  } else {
@@ -1377,14 +1529,17 @@ class MLAQuery {
1377
 
1378
  // Find the quoted phrases for a word-boundary check
1379
  $phrases = self::_parse_terms_search( $term, $phrase_delimiter, false );
 
1380
  $quoted = array();
1381
  foreach ( $phrases as $index => $phrase ) {
1382
  $delimiter = substr( $phrase, 0, 1 );
1383
  $quoted[ $index ] = ( '"' == $delimiter ) || ( "'" == $delimiter );
1384
  }
 
1385
 
1386
  // Strip delimiters and escape backslashes
1387
  $phrases = self::_parse_terms_search( $term, $phrase_delimiter, true );
 
1388
 
1389
  $tax_terms = array();
1390
  $tax_counts = array();
@@ -1426,6 +1581,7 @@ class MLAQuery {
1426
  } // quoted phrase
1427
  } // not exact
1428
 
 
1429
  foreach( $the_terms as $the_term ) {
1430
  $tax_terms[ $the_term->taxonomy ][ $the_term->term_id ] = (integer) $the_term->term_taxonomy_id;
1431
 
@@ -1437,9 +1593,8 @@ class MLAQuery {
1437
  }
1438
  } // foreach phrase
1439
 
1440
- /*
1441
- * For the AND connector, a taxonomy term must have all of the search terms within it
1442
- */
1443
  if ( 'AND' == $terms_search_parameters['radio_phrases'] ) {
1444
  $search_term_count = count( $phrases );
1445
  foreach ($tax_terms as $taxonomy => $term_ids ) {
@@ -1457,6 +1612,7 @@ class MLAQuery {
1457
  } // foreach taxonomy
1458
  } // AND (i.e., All phrases)
1459
 
 
1460
  if ( empty( $tax_terms ) ) {
1461
  if ( 'AND' == $terms_search_parameters['radio_terms'] ) {
1462
  $tax_clause = '';
@@ -1491,6 +1647,7 @@ class MLAQuery {
1491
  $tax_index = 0;
1492
  };
1493
 
 
1494
  return $tax_index;
1495
  }
1496
 
@@ -1514,14 +1671,19 @@ class MLAQuery {
1514
  $tax_connector = 'AND';
1515
  $tax_index = 0;
1516
 
 
 
1517
  // Process the Terms Search arguments, if present.
1518
  if ( isset( self::$search_parameters['mla_terms_search']['phrases'] ) ) {
1519
  self::$search_parameters['tax_terms_count'] = self::_generate_tax_clause( self::$search_parameters['mla_terms_search'], $tax_clause );
 
 
 
 
 
1520
  }
1521
 
1522
- /*
1523
- * Process the keyword search argument, if present.
1524
- */
1525
  if ( ! empty( self::$search_parameters['s'] ) ) {
1526
  // WordPress v3.7 says: there are no line breaks in <input /> fields
1527
  $keyword_string = stripslashes( str_replace( array( "\r", "\n" ), '', self::$search_parameters['s'] ) );
@@ -1534,6 +1696,7 @@ class MLAQuery {
1534
  preg_match_all('/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', $keyword_string, $matches);
1535
  $keyword_array = array_map( 'MLAQuery::mla_search_terms_tidy', $matches[0]);
1536
  $numeric_array = array_filter( $keyword_array, 'is_numeric' );
 
1537
 
1538
  /*
1539
  * If all the "keywords" are numeric, interpret it/them as the ID(s) of a specific attachment
@@ -1619,6 +1782,7 @@ class MLAQuery {
1619
 
1620
  if ( $allow_terms_search ) {
1621
  self::$search_parameters['tax_terms_count'] = self::_generate_tax_clause( array( 'phrases' => $keyword_string, 'radio_phrases' => self::$search_parameters['mla_search_connector'], 'radio_terms' => self::$search_parameters['mla_search_connector'], 'taxonomies' => self::$search_parameters['mla_search_taxonomies'] ), $tax_clause );
 
1622
 
1623
  if ( '1=0' === $tax_clause ) {
1624
  // If "Terms" is the only field and no terms are present, the search must fail.
@@ -1657,6 +1821,21 @@ class MLAQuery {
1657
  }
1658
  } // debug
1659
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1660
  return $search_clause;
1661
  }
1662
 
@@ -1679,9 +1858,7 @@ class MLAQuery {
1679
  $debug_array = array( 'where_string' => $where_clause );
1680
  }
1681
 
1682
- /*
1683
- * WordPress filters meta_value thru trim() - which we must reverse
1684
- */
1685
  if ( isset( self::$query_parameters['mla-metavalue'] ) ) {
1686
  if ( is_array( self::$query_parameters['mla-metavalue'] ) ) {
1687
  foreach ( self::$query_parameters['mla-metavalue'] as $pattern => $replacement ) {
@@ -1692,16 +1869,12 @@ class MLAQuery {
1692
  }
1693
  }
1694
 
1695
- /*
1696
- * Matching a NULL meta value
1697
- */
1698
  if ( array_key_exists( 'postmeta_value', self::$query_parameters ) && NULL == self::$query_parameters['postmeta_value'] ) {
1699
  $where_clause .= ' AND ' . self::MLA_TABLE_VIEW_SUBQUERY . '.meta_value IS NULL';
1700
  }
1701
 
1702
- /*
1703
- * WordPress modifies the LIKE clause - which we must reverse
1704
- */
1705
  if ( isset( self::$query_parameters['patterns'] ) ) {
1706
  foreach ( self::$query_parameters['patterns'] as $pattern ) {
1707
  $pattern = str_replace( '_', '\\\\_', $pattern );
@@ -1710,9 +1883,7 @@ class MLAQuery {
1710
  }
1711
  }
1712
 
1713
- /*
1714
- * Unattached items require some help
1715
- */
1716
  if ( isset( self::$query_parameters['detached'] ) ) {
1717
  if ( '1' == self::$query_parameters['detached'] ) {
1718
  $where_clause .= sprintf( ' AND %1$s.post_parent < 1', $wpdb->posts );
671
  return array();
672
  } // mla_custom_field_option_value
673
 
674
+ /**
675
+ * Separate negative ("NOT IN") search string phrases from positive phrases
676
+ *
677
+ * @since 2.78
678
+ *
679
+ * @uses array self::$search_parameters
680
+ *
681
+ * @param string phrases, e.g., ( "a phrase" separate phrase ) without parens, space delimited
682
+ *
683
+ * @return array ( 'original' => all phrases, 'positive' => positive phrases, 'negative' => negative phrases )
684
+ */
685
+ private static function _divide_search_string( $whole_string ) {
686
+ $separator = ','; // TODO default value
687
+ $negative_delimiter = '/'; // TODO default value
688
+ $phrases = array( 'original' => $whole_string, 'positive' => '', 'negative' => '' );
689
+
690
+ $separator_list = " \n\t\r\0\x0B";
691
+ if ( false === strpos( $separator_list, $separator ) ) {
692
+ $separator_list .= $separator;
693
+ } else {
694
+ $separator_list .= ',';
695
+ }
696
+
697
+ $in_negative = false;
698
+ $current_quote = '';
699
+ $in_trim = false;
700
+ $current_separator = ' ';
701
+ $argument = '';
702
+ $index = 0;
703
+
704
+ while ( $index < strlen( $whole_string ) ) {
705
+ $byte = $whole_string[ $index++ ];
706
+ //error_log( __LINE__ . " MLAQuery::_divide_search_string byte |{$byte}| in_trim |{$in_trim}| in_negative |{$in_negative}| current_quote |{$current_quote}| current_separator |{$current_separator}| argument |{$argument}| phrases = " . var_export( $phrases, true ), 0 );
707
+
708
+ // Are we between arguments?
709
+ if ( ( false !== strpos( $separator_list, $byte ) ) && !( $in_negative || $current_quote ) ) {
710
+ $in_trim = true;
711
+
712
+ if ( $separator === $byte ) {
713
+ $current_separator = $separator;
714
+ }
715
+
716
+ continue;
717
+ } elseif ( $in_trim ) {
718
+ // Have we seen a positive argument?
719
+ if ( strlen( $argument ) ) {
720
+ $phrases['positive'] .= $argument;
721
+ $argument = '';
722
+ }
723
+
724
+ if ( strlen( $phrases['positive'] ) ) {
725
+ $phrases['positive'] .= $current_separator;
726
+ }
727
+
728
+ if ( strlen( $phrases['negative'] ) ) {
729
+ $phrases['negative'] .= $current_separator;
730
+ }
731
+
732
+ $current_separator = ' ';
733
+ $in_trim = false;
734
+ }
735
+
736
+ // Are we finishing a negative phrase?
737
+ if ( $in_negative && ( $negative_delimiter == $byte ) ) {
738
+ if ( strlen( $argument ) ) {
739
+ $phrases['negative'] .= $argument;
740
+ $argument = '';
741
+ }
742
+
743
+ $in_negative = false;
744
+ continue;
745
+ }
746
+
747
+ // Are we finishing a quoted phrase?
748
+ if ( $current_quote == $byte ) {
749
+ if ( strlen( $argument ) ) {
750
+ if ( $in_negative ) {
751
+ $phrases['negative'] .= $current_quote . $argument . $current_quote;
752
+ } else {
753
+ $phrases['positive'] .= $current_quote . $argument . $current_quote;
754
+ }
755
+
756
+ $argument = '';
757
+ }
758
+
759
+ $current_quote = '';
760
+ continue;
761
+ }
762
+
763
+ // Are we starting a negative phrase?
764
+ if ( ( $negative_delimiter == $byte ) && !$current_quote ) {
765
+ if ( strlen( $argument ) ) {
766
+ $phrases['positive'] .= $argument;
767
+ $argument = '';
768
+ }
769
+
770
+ $in_negative = true;
771
+ continue;
772
+ }
773
+
774
+ // Are we starting a quoted phrase?
775
+ if ( !$current_quote && ( '\'' == $byte || '"' == $byte ) ) {
776
+ $current_quote = $byte;
777
+ continue;
778
+ }
779
+
780
+ // Accumulate a phrase
781
+ $argument .= $byte;
782
+ } // index < strlen
783
+
784
+ // Close out the final argument
785
+ if ( strlen( $argument ) ) {
786
+ // Restore quotes for word-boundary check
787
+ $phrases['positive'] .= $argument;
788
+ }
789
+
790
+ //error_log( __LINE__ . ' MLAQuery::_divide_search_string phrases = ' . var_export( $phrases, true ), 0 );
791
+
792
+ return $phrases;
793
+ return array( 'original' => 'america /statue/', 'positive' => 'america', 'negative' => 'statue' );
794
+ } // _divide_search_string
795
+
796
  /**
797
  * Sanitize and expand query arguments from request variables
798
  *
818
  return NULL;
819
  }
820
 
821
+ // Make sure the current orderby choice still exists or revert to default.
 
 
822
  $default_orderby = array_merge( array( 'none' => array('none',false) ), self::mla_get_sortable_columns( ) );
823
  $current_orderby = MLACore::mla_get_option( MLACoreOptions::MLA_DEFAULT_ORDERBY );
824
  $found_current = false;
1054
  unset( $clean_request['debug'] );
1055
  }
1056
 
1057
+ // We must patch the WHERE clause if there are leading spaces in the meta_value
 
 
1058
  if ( isset( $clean_request['mla-metavalue'] ) && ( 0 < strlen( $clean_request['mla-metavalue'] ) ) && ( ' ' == $clean_request['mla-metavalue'][0] ) ) {
1059
  self::$query_parameters['mla-metavalue'] = $clean_request['mla-metavalue'];
1060
  }
1061
 
1062
+ // We will handle "Terms Search" in the mla_query_posts_search_filter.
 
 
1063
  if ( isset( $clean_request['mla_terms_search'] ) ) {
1064
  self::$search_parameters['mla_terms_search'] = $clean_request['mla_terms_search'];
1065
 
1066
+ // The Terms Search overrides any terms-based keyword search for now; too complicated.
 
 
1067
  if ( isset( $clean_request['mla_search_fields'] ) ) {
1068
  foreach ( $clean_request['mla_search_fields'] as $index => $field ) {
1069
  if ( 'terms' == $field ) {
1073
  }
1074
  }
1075
 
1076
+ // We will handle keyword search in the mla_query_posts_search_filter.
 
 
1077
  if ( isset( $clean_request['s'] ) ) {
1078
  self::$search_parameters['s'] = $clean_request['s'];
1079
  self::$search_parameters['mla_search_fields'] = apply_filters( 'mla_list_table_search_filter_fields', $clean_request['mla_search_fields'], array( 'title', 'name', 'alt-text', 'excerpt', 'content', 'file' ,'terms' ) );
1145
  } // switch $orderby
1146
  }
1147
 
1148
+ // Ignore incoming paged value; use offset and count instead
 
 
1149
  if ( ( (int) $count ) > 0 ) {
1150
  $clean_request['offset'] = $offset;
1151
  $clean_request['posts_per_page'] = $count;
1213
  unset( $clean_request['mla-metakey'] );
1214
  unset( $clean_request['mla-metavalue'] );
1215
  } // isset mla_tax
1216
+
1217
+ if ( !empty( self::$search_parameters['s'] ) ) {
1218
+ $search_phrases = self::_divide_search_string( self::$search_parameters['s'] );
1219
+ //error_log( __LINE__ . " MLAQuery::_prepare_list_table_query search_phrases = " . var_export( $search_phrases, true ), 0 );
1220
+
1221
+ if ( !empty( $search_phrases['negative'] ) ) {
1222
+ self::$search_parameters['s'] = $search_phrases['negative'];
1223
+ $clean_request['fields'] = 'ids';
1224
+ $excluded_items = self::_execute_list_table_query( $clean_request );
1225
+ //error_log( __LINE__ . " MLAQuery::_prepare_list_table_query posts = " . var_export( $excluded_items->posts, true ), 0 );
1226
+ unset( $clean_request['fields'] );
1227
+ self::$search_parameters['s'] = $search_phrases['positive'];
1228
+ self::$search_parameters['exclude'] = implode( ',', $excluded_items->posts);
1229
+ }
1230
+ }
1231
+
1232
+ //error_log( __LINE__ . " MLAQuery::_prepare_list_table_query clean_request = " . var_export( $clean_request, true ), 0 );
1233
+ //error_log( __LINE__ . " MLAQuery::_prepare_list_table_query search_parameters = " . var_export( self::$search_parameters, true ), 0 );
1234
+
1235
+ if ( !empty( self::$search_parameters['mla_terms_search'] ) ) {
1236
+ $search_phrases = self::_divide_search_string( self::$search_parameters['mla_terms_search']['phrases'] );
1237
+ //error_log( __LINE__ . " MLAQuery::_prepare_list_table_query mla_terms_search search_phrases = " . var_export( $search_phrases, true ), 0 );
1238
+
1239
+ if ( !empty( $search_phrases['negative'] ) ) {
1240
+ self::$search_parameters['mla_terms_search']['phrases'] = $search_phrases['negative'];
1241
+ $clean_request['fields'] = 'ids';
1242
+ $excluded_items = self::_execute_list_table_query( $clean_request );
1243
+ //error_log( __LINE__ . " MLAQuery::_prepare_list_table_query mla_terms_search posts = " . var_export( $excluded_items->posts, true ), 0 );
1244
+ unset( $clean_request['fields'] );
1245
+ unset( self::$search_parameters['tax_terms_count'] );
1246
+ self::$search_parameters['mla_terms_search']['phrases'] = $search_phrases['positive'];
1247
+ self::$search_parameters['mla_terms_search']['exclude'] = implode( ',', $excluded_items->posts );
1248
+ }
1249
+ }
1250
+
1251
+ //error_log( __LINE__ . " MLAQuery::_prepare_list_table_query clean_request = " . var_export( $clean_request, true ), 0 );
1252
+ //error_log( __LINE__ . " MLAQuery::_prepare_list_table_query search_parameters = " . var_export( self::$search_parameters, true ), 0 );
1253
  return $clean_request;
1254
  }
1255
 
1428
  * @return array individual arguments, e.g. array( 0 => '"a phrase"', 1 => 'separate', 2 => 'phrase' )
1429
  */
1430
  private static function _parse_terms_search( $whole_string, $delimiter = ',', $full_parse = false ) {
1431
+ $trim_list = " \n\t\r\0\x0B,"; // space,line feed,tab,carriage return, null,vertical tab,comma
1432
  if ( false === strpos( $trim_list, $delimiter ) ) {
1433
  $trim_list .= $delimiter;
1434
  }
1436
  $whole_string = trim( $whole_string, $trim_list );
1437
  $phrases = array();
1438
 
1439
+ //error_log( __LINE__ . " MLAQuery::_parse_terms_search( {$full_parse} ) whole_string = " . var_export( $whole_string, true ), 0 );
1440
  while ( strlen( $whole_string ) ) {
1441
  $argument = '';
1442
  $index = 0;
1488
  $phrases[] = $current_delimiter . $argument . $current_delimiter;
1489
  }
1490
 
1491
+ //error_log( __LINE__ . " MLAQuery::_parse_terms_search( {$index} ) whole_string = " . var_export( $whole_string, true ), 0 );
1492
  $whole_string = trim( substr( $whole_string, $index ), $trim_list );
1493
+ //error_log( __LINE__ . ' MLAQuery::_parse_terms_search whole_string = ' . var_export( $whole_string, true ), 0 );
1494
+ //error_log( __LINE__ . ' MLAQuery::_parse_terms_search phrases = ' . var_export( $phrases, true ), 0 );
1495
  } // strlen( $whole_string )
1496
 
1497
  return $phrases;
1510
  * @return integer Taxonomy JOIN clauses required. Updates $tax_clause as well
1511
  */
1512
  private static function _generate_tax_clause( $terms_search_parameters, &$tax_clause ) {
1513
+ //error_log( __LINE__ . ' MLAQuery::_generate_tax_clause terms_search_parameters = ' . var_export( $terms_search_parameters, true ), 0 );
1514
  $term_delimiter = isset( $terms_search_parameters['term_delimiter'] ) ? $terms_search_parameters['term_delimiter'] : ',';
1515
  $phrase_delimiter = isset( $terms_search_parameters['phrase_delimiter'] ) ? $terms_search_parameters['phrase_delimiter'] : ' ';
1516
  $tax_clause = '';
1517
  $tax_index = 0;
1518
 
1519
  $terms = self::_parse_terms_search( $terms_search_parameters['phrases'], $term_delimiter );
1520
+ //error_log( __LINE__ . " MLAQuery::_generate_tax_clause terms_search_parameters terms = " . var_export( $terms, true ), 0 );
1521
  if ( 1 < count( $terms ) ) {
1522
  $terms_connector = '(';
1523
  } else {
1529
 
1530
  // Find the quoted phrases for a word-boundary check
1531
  $phrases = self::_parse_terms_search( $term, $phrase_delimiter, false );
1532
+ //error_log( __LINE__ . " MLAQuery::_generate_tax_clause terms_search_parameters( {$term} ) phrases = " . var_export( $phrases, true ), 0 );
1533
  $quoted = array();
1534
  foreach ( $phrases as $index => $phrase ) {
1535
  $delimiter = substr( $phrase, 0, 1 );
1536
  $quoted[ $index ] = ( '"' == $delimiter ) || ( "'" == $delimiter );
1537
  }
1538
+ //error_log( __LINE__ . " MLAQuery::_generate_tax_clause terms_search_parameters( {$term} ) quoted = " . var_export( $quoted, true ), 0 );
1539
 
1540
  // Strip delimiters and escape backslashes
1541
  $phrases = self::_parse_terms_search( $term, $phrase_delimiter, true );
1542
+ //error_log( __LINE__ . " MLAQuery::_generate_tax_clause terms_search_parameters( {$term} ) phrases = " . var_export( $phrases, true ), 0 );
1543
 
1544
  $tax_terms = array();
1545
  $tax_counts = array();
1581
  } // quoted phrase
1582
  } // not exact
1583
 
1584
+ //error_log( __LINE__ . " MLAQuery::_generate_tax_clause terms_search_parameters( {$index}, {$phrase} ) the_terms = " . var_export( $the_terms, true ), 0 );
1585
  foreach( $the_terms as $the_term ) {
1586
  $tax_terms[ $the_term->taxonomy ][ $the_term->term_id ] = (integer) $the_term->term_taxonomy_id;
1587
 
1593
  }
1594
  } // foreach phrase
1595
 
1596
+ //error_log( __LINE__ . ' MLAQuery::_generate_tax_clause tax_counts = ' . var_export( $tax_counts, true ), 0 );
1597
+ // For the AND connector, a taxonomy term must have all of the search terms within it
 
1598
  if ( 'AND' == $terms_search_parameters['radio_phrases'] ) {
1599
  $search_term_count = count( $phrases );
1600
  foreach ($tax_terms as $taxonomy => $term_ids ) {
1612
  } // foreach taxonomy
1613
  } // AND (i.e., All phrases)
1614
 
1615
+ //error_log( __LINE__ . ' MLAQuery::_generate_tax_clause tax_terms = ' . var_export( $tax_terms, true ), 0 );
1616
  if ( empty( $tax_terms ) ) {
1617
  if ( 'AND' == $terms_search_parameters['radio_terms'] ) {
1618
  $tax_clause = '';
1647
  $tax_index = 0;
1648
  };
1649
 
1650
+ //error_log( __LINE__ . " MLAQuery::_generate_tax_clause( {$tax_index} ) tax_clause = " . var_export( $tax_clause, true ), 0 );
1651
  return $tax_index;
1652
  }
1653
 
1671
  $tax_connector = 'AND';
1672
  $tax_index = 0;
1673
 
1674
+ //error_log( __LINE__ . " MLAQuery::mla_query_posts_search_filter search_string = " . var_export( $search_string, true ), 0 );
1675
+ //error_log( __LINE__ . " MLAQuery::mla_query_posts_search_filter search_parameters = " . var_export( self::$search_parameters, true ), 0 );
1676
  // Process the Terms Search arguments, if present.
1677
  if ( isset( self::$search_parameters['mla_terms_search']['phrases'] ) ) {
1678
  self::$search_parameters['tax_terms_count'] = self::_generate_tax_clause( self::$search_parameters['mla_terms_search'], $tax_clause );
1679
+ //error_log( __LINE__ . " MLAQuery::mla_query_posts_search_filter tax_clause = " . var_export( $tax_clause, true ), 0 );
1680
+
1681
+ if ( '1=0' === $tax_clause && !empty( self::$search_parameters['mla_terms_search']['exclude'] ) ) {
1682
+ $tax_clause = '';
1683
+ }
1684
  }
1685
 
1686
+ // Process the keyword search argument, if present.
 
 
1687
  if ( ! empty( self::$search_parameters['s'] ) ) {
1688
  // WordPress v3.7 says: there are no line breaks in <input /> fields
1689
  $keyword_string = stripslashes( str_replace( array( "\r", "\n" ), '', self::$search_parameters['s'] ) );
1696
  preg_match_all('/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', $keyword_string, $matches);
1697
  $keyword_array = array_map( 'MLAQuery::mla_search_terms_tidy', $matches[0]);
1698
  $numeric_array = array_filter( $keyword_array, 'is_numeric' );
1699
+ //error_log( __LINE__ . " MLAQuery::mla_query_posts_search_filter keyword_array = " . var_export( $keyword_array, true ), 0 );
1700
 
1701
  /*
1702
  * If all the "keywords" are numeric, interpret it/them as the ID(s) of a specific attachment
1782
 
1783
  if ( $allow_terms_search ) {
1784
  self::$search_parameters['tax_terms_count'] = self::_generate_tax_clause( array( 'phrases' => $keyword_string, 'radio_phrases' => self::$search_parameters['mla_search_connector'], 'radio_terms' => self::$search_parameters['mla_search_connector'], 'taxonomies' => self::$search_parameters['mla_search_taxonomies'] ), $tax_clause );
1785
+ //error_log( __LINE__ . " MLAQuery::mla_query_posts_search_filter tax_clause = " . var_export( $tax_clause, true ), 0 );
1786
 
1787
  if ( '1=0' === $tax_clause ) {
1788
  // If "Terms" is the only field and no terms are present, the search must fail.
1821
  }
1822
  } // debug
1823
 
1824
+ // Remove posts containing "negative" search phrases
1825
+ $excludes = array();
1826
+ if ( !empty( self::$search_parameters['exclude'] ) ) {
1827
+ $excludes[] = self::$search_parameters['exclude'];
1828
+ }
1829
+
1830
+ if ( !empty( self::$search_parameters['mla_terms_search']['exclude'] ) ) {
1831
+ $excludes[] = self::$search_parameters['mla_terms_search']['exclude'];
1832
+ }
1833
+
1834
+ if ( count( $excludes ) ) {
1835
+ $search_clause .= " AND ( {$wpdb->posts}.ID NOT IN ( " . implode( ',', $excludes ) . " ) )";
1836
+ }
1837
+
1838
+ //error_log( __LINE__ . " MLAQuery::mla_query_posts_search_filter search_clause = " . var_export( $search_clause, true ), 0 );
1839
  return $search_clause;
1840
  }
1841
 
1858
  $debug_array = array( 'where_string' => $where_clause );
1859
  }
1860
 
1861
+ // WordPress filters meta_value thru trim() - which we must reverse
 
 
1862
  if ( isset( self::$query_parameters['mla-metavalue'] ) ) {
1863
  if ( is_array( self::$query_parameters['mla-metavalue'] ) ) {
1864
  foreach ( self::$query_parameters['mla-metavalue'] as $pattern => $replacement ) {
1869
  }
1870
  }
1871
 
1872
+ // Matching a NULL meta value
 
 
1873
  if ( array_key_exists( 'postmeta_value', self::$query_parameters ) && NULL == self::$query_parameters['postmeta_value'] ) {
1874
  $where_clause .= ' AND ' . self::MLA_TABLE_VIEW_SUBQUERY . '.meta_value IS NULL';
1875
  }
1876
 
1877
+ // WordPress modifies the LIKE clause - which we must reverse
 
 
1878
  if ( isset( self::$query_parameters['patterns'] ) ) {
1879
  foreach ( self::$query_parameters['patterns'] as $pattern ) {
1880
  $pattern = str_replace( '_', '\\\\_', $pattern );
1883
  }
1884
  }
1885
 
1886
+ // Unattached items require some help
 
 
1887
  if ( isset( self::$query_parameters['detached'] ) ) {
1888
  if ( '1' == self::$query_parameters['detached'] ) {
1889
  $where_clause .= sprintf( ' AND %1$s.post_parent < 1', $wpdb->posts );
includes/class-mla-edit-media.php CHANGED
@@ -86,9 +86,7 @@ class MLAEdit {
86
 
87
  add_post_type_support( 'attachment', apply_filters( 'mla_edit_media_support', $edit_media_support ) );
88
 
89
- /*
90
- * Check for Media/Add New bulk edit area updates
91
- */
92
  if ( ! empty( $_REQUEST['mlaAddNewBulkEditFormString'] ) && ( 'checked' == MLACore::mla_get_option( MLACoreOptions::MLA_ADD_NEW_BULK_EDIT ) ) ) {
93
  /*
94
  * If any of the mapping rule options is enabled, use the MLA filter so this
@@ -106,10 +104,8 @@ class MLAEdit {
106
  }
107
  }
108
 
109
- /*
110
- * If there's no action variable, we have nothing more to do
111
- */
112
- if ( ! isset( $_POST['action'] ) ) {
113
  return;
114
  }
115
 
@@ -117,7 +113,7 @@ class MLAEdit {
117
  * For flat taxonomies that use the checklist meta box, convert the term array
118
  * back into a string of slug values.
119
  */
120
- if ( 'editpost' == $_POST['action'] ) {
121
  if ( isset( $_POST['tax_input'] ) && is_array( $_POST['tax_input'] ) ) {
122
  foreach( $_POST['tax_input'] as $key => $value ) {
123
  if ( is_array( $value ) ) {
86
 
87
  add_post_type_support( 'attachment', apply_filters( 'mla_edit_media_support', $edit_media_support ) );
88
 
89
+ // Check for Media/Add New bulk edit area updates
 
 
90
  if ( ! empty( $_REQUEST['mlaAddNewBulkEditFormString'] ) && ( 'checked' == MLACore::mla_get_option( MLACoreOptions::MLA_ADD_NEW_BULK_EDIT ) ) ) {
91
  /*
92
  * If any of the mapping rule options is enabled, use the MLA filter so this
104
  }
105
  }
106
 
107
+ // If there's no action variable, we have nothing more to do
108
+ if ( ! isset( $_REQUEST['action'] ) ) {
 
 
109
  return;
110
  }
111
 
113
  * For flat taxonomies that use the checklist meta box, convert the term array
114
  * back into a string of slug values.
115
  */
116
+ if ( 'editpost' == $_REQUEST['action'] ) {
117
  if ( isset( $_POST['tax_input'] ) && is_array( $_POST['tax_input'] ) ) {
118
  foreach( $_POST['tax_input'] as $key => $value ) {
119
  if ( is_array( $value ) ) {
includes/class-mla-main.php CHANGED
@@ -1577,7 +1577,7 @@ class MLA {
1577
  if ( !empty( $_REQUEST['heading_suffix'] ) ) {
1578
  echo ' - ' . esc_html( $_REQUEST['heading_suffix'] ) . $heading_tail;
1579
  } elseif ( !empty( $_REQUEST['mla_terms_search'] ) ) {
1580
- echo ' - ' . __( 'term search results for', 'media-library-assistant' ) . ' "' . esc_html( stripslashes( trim( $_REQUEST['mla_terms_search']['phrases'] ) ) ) . $heading_tail;
1581
  } elseif ( !empty( $_REQUEST['s'] ) ) {
1582
  if ( empty( $_REQUEST['mla_search_fields'] ) ) {
1583
  echo ' - ' . __( 'post/parent results for', 'media-library-assistant' ) . ' "' . esc_html( stripslashes( trim( $_REQUEST['s'] ) ) ) . "\"" . $heading_tail;
1577
  if ( !empty( $_REQUEST['heading_suffix'] ) ) {
1578
  echo ' - ' . esc_html( $_REQUEST['heading_suffix'] ) . $heading_tail;
1579
  } elseif ( !empty( $_REQUEST['mla_terms_search'] ) ) {
1580
+ echo ' - ' . __( 'term search results for', 'media-library-assistant' ) . ' "' . esc_html( stripslashes( trim( $_REQUEST['mla_terms_search']['phrases'] ) ) ) . "\"" . $heading_tail;
1581
  } elseif ( !empty( $_REQUEST['s'] ) ) {
1582
  if ( empty( $_REQUEST['mla_search_fields'] ) ) {
1583
  echo ' - ' . __( 'post/parent results for', 'media-library-assistant' ) . ' "' . esc_html( stripslashes( trim( $_REQUEST['s'] ) ) ) . "\"" . $heading_tail;
includes/class-mla-media-modal-ajax.php CHANGED
@@ -59,10 +59,8 @@ class MLAModal_Ajax {
59
  //$cause_notice = $screen->bad_property;
60
  //trigger_error( 'mla_print_media_templates_action', E_USER_WARNING );
61
  //error_log( 'DEBUG: xdebug_get_function_stack = ' . var_export( xdebug_get_function_stack(), true), 0 );
62
- /*
63
- * If there's no action variable, we have nothing to do
64
- */
65
- if ( ! isset( $_POST['action'] ) ) {
66
  return;
67
  }
68
 
@@ -99,7 +97,7 @@ class MLAModal_Ajax {
99
  * If the 's' value is an array, the MLA Enhanced elements are present; unpack the arguments
100
  * and substitute our handler for the WordPress default handler.
101
  */
102
- if ( ( $_POST['action'] == 'query-attachments' ) && isset( $_POST['query']['s'] ) && is_array( $_POST['query']['s'] ) ){
103
  foreach ( $_POST['query']['s'] as $key => $value ) {
104
  $_POST['query'][ $key ] = $value;
105
  $_REQUEST['query'][ $key ] = $value;
@@ -118,7 +116,7 @@ class MLAModal_Ajax {
118
  * incoming data. The other taxonomies will be processed by
119
  * /wp-admin/includes/ajax-actions.php, function wp_ajax_save_attachment_compat().
120
  */
121
- if ( ( $_POST['action'] == 'save-attachment-compat' ) ){
122
  if ( empty( $_REQUEST['id'] ) || ! $id = absint( $_REQUEST['id'] ) ) {
123
  wp_send_json_error();
124
  }
@@ -127,9 +125,7 @@ class MLAModal_Ajax {
127
  wp_send_json_error();
128
  }
129
 
130
- /*
131
- * Media Categories uses this
132
- */
133
  if ( isset( $_REQUEST['category-filter'] ) ) {
134
  unset( $_REQUEST['category-filter'] );
135
  unset( $_POST['category-filter'] );
59
  //$cause_notice = $screen->bad_property;
60
  //trigger_error( 'mla_print_media_templates_action', E_USER_WARNING );
61
  //error_log( 'DEBUG: xdebug_get_function_stack = ' . var_export( xdebug_get_function_stack(), true), 0 );
62
+ // If there's no action variable, we have nothing to do
63
+ if ( ! isset( $_REQUEST['action'] ) ) {
 
 
64
  return;
65
  }
66
 
97
  * If the 's' value is an array, the MLA Enhanced elements are present; unpack the arguments
98
  * and substitute our handler for the WordPress default handler.
99
  */
100
+ if ( ( $_REQUEST['action'] == 'query-attachments' ) && isset( $_POST['query']['s'] ) && is_array( $_POST['query']['s'] ) ){
101
  foreach ( $_POST['query']['s'] as $key => $value ) {
102
  $_POST['query'][ $key ] = $value;
103
  $_REQUEST['query'][ $key ] = $value;
116
  * incoming data. The other taxonomies will be processed by
117
  * /wp-admin/includes/ajax-actions.php, function wp_ajax_save_attachment_compat().
118
  */
119
+ if ( ( $_REQUEST['action'] == 'save-attachment-compat' ) ){
120
  if ( empty( $_REQUEST['id'] ) || ! $id = absint( $_REQUEST['id'] ) ) {
121
  wp_send_json_error();
122
  }
125
  wp_send_json_error();
126
  }
127
 
128
+ // Media Categories uses this
 
 
129
  if ( isset( $_REQUEST['category-filter'] ) ) {
130
  unset( $_REQUEST['category-filter'] );
131
  unset( $_POST['category-filter'] );
includes/class-mla-objects.php CHANGED
@@ -130,7 +130,7 @@ class MLAObjects {
130
  */
131
  public static function mla_taxonomy_get_columns_filter( $columns ) {
132
  // Adding or inline-editing a tag is done with AJAX, and there's no current screen object
133
- if ( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'add-tag', 'inline-save-tax' ) ) ) {
134
  $post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post';
135
  $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
136
  } else {
130
  */
131
  public static function mla_taxonomy_get_columns_filter( $columns ) {
132
  // Adding or inline-editing a tag is done with AJAX, and there's no current screen object
133
+ if ( isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], array( 'add-tag', 'inline-save-tax' ) ) ) {
134
  $post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post';
135
  $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
136
  } else {
includes/class-mla-polylang-shortcode-support.php CHANGED
@@ -16,6 +16,15 @@
16
  * @since 2.40
17
  */
18
  class MLA_Polylang_Shortcodes {
 
 
 
 
 
 
 
 
 
19
  /**
20
  * Initialization function, similar to __construct()
21
  *
@@ -24,12 +33,7 @@ class MLA_Polylang_Shortcodes {
24
  * @return void
25
  */
26
  public static function initialize() {
27
- global $polylang;
28
-
29
- // If no language is defined, there's nothing to do
30
- if ( NULL === $polylang->curlang ) {
31
- return;
32
- }
33
 
34
  // Defined in /media-library-assistant/includes/class-mla-shortcode-support.php
35
  add_filter( 'mla_get_terms_query_arguments', 'MLA_Polylang_Shortcodes::mla_get_terms_query_arguments', 10, 1 );
@@ -74,11 +78,15 @@ class MLA_Polylang_Shortcodes {
74
  public static function mla_get_terms_clauses( $clauses ) {
75
  global $polylang;
76
 
77
- // The Polylang terms_clauses method is in one of two places
78
- if ( is_admin() ) {
79
- $clauses = $polylang->filters_term->terms_clauses($clauses, MLA_Polylang_Shortcodes::$all_query_parameters['taxonomy'], MLA_Polylang_Shortcodes::$all_query_parameters );
80
  } else {
81
- $clauses = $polylang->filters->terms_clauses($clauses, MLA_Polylang_Shortcodes::$all_query_parameters['taxonomy'], MLA_Polylang_Shortcodes::$all_query_parameters );
 
 
 
 
 
82
  }
83
 
84
  return $clauses;
16
  * @since 2.40
17
  */
18
  class MLA_Polylang_Shortcodes {
19
+ /**
20
+ * Polylang version conditional to avoid deprecated functions in v1.8+
21
+ *
22
+ * @since 2.78
23
+ *
24
+ * @var boolean
25
+ */
26
+ private static $polylang_2dot4_plus = false;
27
+
28
  /**
29
  * Initialization function, similar to __construct()
30
  *
33
  * @return void
34
  */
35
  public static function initialize() {
36
+ self::$polylang_2dot4_plus = version_compare( POLYLANG_VERSION, '2.3.99', '>' );
 
 
 
 
 
37
 
38
  // Defined in /media-library-assistant/includes/class-mla-shortcode-support.php
39
  add_filter( 'mla_get_terms_query_arguments', 'MLA_Polylang_Shortcodes::mla_get_terms_query_arguments', 10, 1 );
78
  public static function mla_get_terms_clauses( $clauses ) {
79
  global $polylang;
80
 
81
+ if ( self::$polylang_2dot4_plus ) {
82
+ $clauses = $polylang->terms->terms_clauses($clauses, MLA_Polylang_Shortcodes::$all_query_parameters['taxonomy'], MLA_Polylang_Shortcodes::$all_query_parameters );
 
83
  } else {
84
+ // Before v2.4, the Polylang terms_clauses method is in one of two places
85
+ if ( is_admin() ) {
86
+ $clauses = $polylang->filters_term->terms_clauses($clauses, MLA_Polylang_Shortcodes::$all_query_parameters['taxonomy'], MLA_Polylang_Shortcodes::$all_query_parameters );
87
+ } else {
88
+ $clauses = $polylang->filters->terms_clauses($clauses, MLA_Polylang_Shortcodes::$all_query_parameters['taxonomy'], MLA_Polylang_Shortcodes::$all_query_parameters );
89
+ }
90
  }
91
 
92
  return $clauses;
includes/class-mla-shortcode-support.php CHANGED
@@ -273,7 +273,7 @@ class MLAShortcode_Support {
273
  $attr = shortcode_parse_atts( $new_attr );
274
 
275
  // Remove empty values and still-invalid parameters
276
- $new_attr = '';
277
  foreach ( $attr as $key => $value ) {
278
  if ( is_numeric( $key ) || empty( $value ) ) {
279
  continue;
273
  $attr = shortcode_parse_atts( $new_attr );
274
 
275
  // Remove empty values and still-invalid parameters
276
+ $new_attr = array();
277
  foreach ( $attr as $key => $value ) {
278
  if ( is_numeric( $key ) || empty( $value ) ) {
279
  continue;
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 2.77
10
  */
11
 
12
  /*
@@ -16,7 +16,7 @@ Description: Enhances the Media Library; powerful [mla_gallery] [mla_tag_cloud]
16
  Author: David Lingren
17
  Text Domain: media-library-assistant
18
  Domain Path: /languages
19
- Version: 2.77
20
  Author URI: http://davidlingren.com/
21
 
22
  Copyright 2011-2019 David Lingren
6
  * will the rest of the plugin be loaded and run.
7
  *
8
  * @package Media Library Assistant
9
+ * @version 2.78
10
  */
11
 
12
  /*
16
  Author: David Lingren
17
  Text Domain: media-library-assistant
18
  Domain Path: /languages
19
+ Version: 2.78
20
  Author URI: http://davidlingren.com/
21
 
22
  Copyright 2011-2019 David Lingren
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: dglingren
3
  Donate link: http://davidlingren.com/#two
4
  Tags: attachments, gallery, images, media, media library, tags, categories, IPTC, EXIF, XMP, GPS, PDF, metadata, photos, photographs, photo albums, MIME, mime-type, icon, upload, file extensions, WPML, Polylang
5
  Requires at least: 3.5.0
6
- Tested up to: 5.0.2
7
  Requires PHP: 5.3
8
- Stable tag: 2.77
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -181,6 +181,14 @@ All of the MLA source code has been annotated with "DocBlocks", a special type o
181
 
182
  == Changelog ==
183
 
 
 
 
 
 
 
 
 
184
  = 2.77 =
185
  * Fix: Preserve current term assignments for checklist-style taxonomies when opening the Media/Assistant Quick Edit area. This defect was introduced in v2.76.
186
 
@@ -297,11 +305,8 @@ All of the MLA source code has been annotated with "DocBlocks", a special type o
297
 
298
  == Upgrade Notice ==
299
 
300
- = 2.77 =
301
- Preserve current term assignments for checklist-style taxonomies when opening the Media/Assistant Quick Edit area. Corrects a defect introduced in v2.76.
302
-
303
- = 2.76 =
304
- "Checklist-style" term search and additions in the Bulk and Quick Edit areas. New and improved example plugins. Seven enhancements, four fixes.
305
 
306
  == Other Notes ==
307
 
3
  Donate link: http://davidlingren.com/#two
4
  Tags: attachments, gallery, images, media, media library, tags, categories, IPTC, EXIF, XMP, GPS, PDF, metadata, photos, photographs, photo albums, MIME, mime-type, icon, upload, file extensions, WPML, Polylang
5
  Requires at least: 3.5.0
6
+ Tested up to: 5.0.3
7
  Requires PHP: 5.3
8
+ Stable tag: 2.78
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
181
 
182
  == Changelog ==
183
 
184
+ = 2.78 =
185
+ * New: For the Media/Assistant "Search Media" and "Terms Search" functions, keywords and terms can be excluded from the results by enclosing them in "/" delimiters, e.g., "/not/ happy" will return items containing "happy" after excluding items containing "not". This new feature also works in the Media/Library "grid" view and in the "Add media" popup window.
186
+ * Fix: Eliminate fatal errors supporting Admin Columns Pro version 4.5.x
187
+ * Fix: When Polylang is active, eliminate PHP error messages from MLA_Polylang_Shortcodes::mla_get_terms_clauses.
188
+ * Fix: For `[mla_gallery]` eliminate PHP warning messages for some invalid parameter situations.
189
+ * Fix: Simplify MLA_Ajax logging and remove PHP Notice regarding missing "action" value.
190
+ * Fix: For "MLA USP Novo-Map Example" plugin, rewrite the "Introduction" section in the Documentation tab.
191
+
192
  = 2.77 =
193
  * Fix: Preserve current term assignments for checklist-style taxonomies when opening the Media/Assistant Quick Edit area. This defect was introduced in v2.76.
194
 
305
 
306
  == Upgrade Notice ==
307
 
308
+ = 2.78 =
309
+ Support Admin Columns Pro v4.5.x, add "Search Media" and "Terms Search" exclude logic, Eliminate PHP messages for Polylang and some AJAX actions. One enhancements five fixes.
 
 
 
310
 
311
  == Other Notes ==
312
 
tpls/documentation-settings-tab.tpl CHANGED
@@ -5444,6 +5444,13 @@ If you choose the 'or'/'Any phrase' connector and enter 'man "bites dog"' in the
5444
  <p>
5445
  The Search Terms popup window has an additional capability, "Exact match" and a checkbox to activate it. When you check the "Exact" box, each phrase must match the entire text of a term name. For example, if you check "Exact", the phrase "man" will match a term of the same name but not a term named "big man". If you check "Exact" and enter "big man" you will match terms named "big" or "man" <strong>but not</strong> "big man". If you want an exact match on a multi-word term such as "big man", put quotes around the name, i.e., ' "big man" '.
5446
  </p>
 
 
 
 
 
 
 
5447
  <h4>Entering multiple terms</h4>
5448
  <p>
5449
  The Search Terms popup window has an additional capability and another control to refine it. The additional capability lets you search for multiple terms and the control sets the connector between terms. For example, consider two taxonomies, each with several terms:
5444
  <p>
5445
  The Search Terms popup window has an additional capability, "Exact match" and a checkbox to activate it. When you check the "Exact" box, each phrase must match the entire text of a term name. For example, if you check "Exact", the phrase "man" will match a term of the same name but not a term named "big man". If you check "Exact" and enter "big man" you will match terms named "big" or "man" <strong>but not</strong> "big man". If you want an exact match on a multi-word term such as "big man", put quotes around the name, i.e., ' "big man" '.
5446
  </p>
5447
+ <h4>Excluding phrases</h4>
5448
+ <p>
5449
+ If you want to exclude items that match a phrase, enclose the phrase in slash ("/") delimiters. For example, enter "/dog/" to exclude terms containing the word dog. To exclude a multi word phrase, enter something like "/bites dog/" to exclude both words or ' /"bites dog"/ ' to exclude the exact phrase. You can combine include and exclude phrases, e.g., something like "man /that/ dog" to select terms containing "man" and "dog" but not containing "that".
5450
+ </p>
5451
+ <p>
5452
+ When you add exclude phrases to your search, the phrases you enter are divided into two sub-values, "positive" and "negative", with everything enclosed by the exclude delmiters going to the negative sub-value and everything else to the positive. Two queries are performed. First, the negative sub-value is used and a list of the item IDs that pass the query is compiled. Second, the positive sub-value is used and items with the "negative" IDs are excluded.
5453
+ </p>
5454
  <h4>Entering multiple terms</h4>
5455
  <p>
5456
  The Search Terms popup window has an additional capability and another control to refine it. The additional capability lets you search for multiple terms and the control sets the connector between terms. For example, consider two taxonomies, each with several terms:
tpls/help-for-media_page_mla-menu.tpl CHANGED
@@ -44,10 +44,11 @@ There are four where-used reporting categories and you can turn them on or off w
44
  <p>You can add sortable columns to the Media/Assistant submenu table by visiting the Custom Fields tab on the Settings page. There you define rules that map attachment metadata such as file size to WordPress custom fields. The &#8220;MLA Column&#8221; checkbox for each rule lets you select which rules will appear on this screen.</p>
45
  <!-- template="mla-search-media" -->
46
  <!-- title="Search Media" order="70" -->
47
- <p>The &#8220;Search Media&#8221; box supports a keyword search of several attachment fields; enter words and/or phrases in the box, separated by spaces. Click the Search Media button for a case-insensitive "SQL LIKE" search. Each keyword in the search phrase is matched independently, so the order of search words does not have to match the order in the text. For example, searching on "friend" and "best" will match "Best Friend". If you put quotes around a search phrase then word order is required for a match (and spaces between words must match as well). You can also match on partial words, e.g., "rien" will match "friend".</p>
48
- <p>You can also do wildcard searches using an asterisk ("*") as the wildcard placeholder. For example, "friend*" will match fields beginning with "friend", and "best*friend*" will match "Best Friend" and "Best of frends" but not "The best of friends". The pattern "*best*friend*" will match all three of the previous examples. If you want to match an asterisk explicitly, put it in quotes.</p>
49
- <p>Once you&#8217;ve entered the terms you want, use the options below the box to tailor your search. You can pick the connector used between search terms; "or" means any of the terms will match, "and" means all of the terms must match. Use the checkboxes to extend your search to more fields in the database. The "Terms" checkbox will extend the search to the name field of the taxonomies you set on the Settings/Media Library Assistant General tab.</p>
50
- <p>If you enter a numeric value (only) in the search box, it is interpreted as a search by attachment ID or parent ID (post_parent). This is in addition to the normal search in the text fields, e.g., title.</p>
 
51
  <!-- template="mla-terms-search" -->
52
  <!-- title="Terms Search" order="80" -->
53
  <p>The &#8220;Terms Search&#8221; features let you filter the Media/Assistant submenu table and the Media Manager Modal Window by matching one or more phrases in the Name field of taxonomy terms. There are two ways to access this feature:
44
  <p>You can add sortable columns to the Media/Assistant submenu table by visiting the Custom Fields tab on the Settings page. There you define rules that map attachment metadata such as file size to WordPress custom fields. The &#8220;MLA Column&#8221; checkbox for each rule lets you select which rules will appear on this screen.</p>
45
  <!-- template="mla-search-media" -->
46
  <!-- title="Search Media" order="70" -->
47
+ <p>The &#8220;Search Media&#8221; box supports a keyword search of several attachment fields; enter words and/or phrases in the box, separated by spaces. Click the Search Media button for a case-insensitive &#8220;SQL LIKE&#8221; search. Each keyword in the search phrase is matched independently, so the order of search words does not have to match the order in the text. For example, searching on &#8220;friend&#8221; and &#8220;best&#8221; will match &#8220;Best Friend&#8221;. If you put quotes around a search phrase then word order is required for a match (and spaces between words must match as well). You can match on partial words, e.g., &#8220;rien&#8221; will match &#8220;friend&#8221;.</p>
48
+ <p>You can also do wildcard searches using an asterisk (&#8220;*&#8221;) as the wildcard placeholder. For example, &#8220;friend*&#8221; will match fields beginning with &#8220;friend&#8221;, and &#8220;best*friend*&#8221; will match &#8220;Best Friend&#8221; and &#8220;Best of frends&#8221; but not &#8220;The best of friends&#8221;. The pattern &#8220;*best*friend*&#8221; will match all three of the previous examples. If you want to match an asterisk explicitly, put it in quotes. Note that wildcard searches are not supported in the Terms field.</p>
49
+ <p>If you want to <strong><em>exclude</em></strong> items that match a search phrase, enclose the phrase in slash (&#8220;/&#8221;) delimiters. For example, to exclude your friends, enter &#8220;/friend/&#8221;. To exclude only your best friends, enter &#8220;/best/ friend&#8221;.</p>
50
+ <p>If you enter one or more (comma-separated) numeric values (only) in the search box, they are interpreted as a search by attachment ID or parent ID (post_parent). This is in addition to the normal search in the text fields, e.g., title.</p>
51
+ <p>Once you&#8217;ve entered the search phrases you want, use the options below the box to tailor your search. You can pick the connector used between search phrases; &#8220;or&#8221; means any of the phrases will match, &#8220;and&#8221; means all of the phrases must match. Use the checkboxes to extend your search to more fields in the database. The &#8220;Terms&#8221; checkbox will extend the search to the name field of the taxonomies you set on the Settings/Media Library Assistant General tab. See the &#8220;Terms Search&#8221; section in the Settings/Media Library Assistant <a href="[+settingsURL+]?page=mla-settings-menu-documentation&mla_tab=documentation#terms_search" target="_blank">Documentation tab</a> for details.</p>
52
  <!-- template="mla-terms-search" -->
53
  <!-- title="Terms Search" order="80" -->
54
  <p>The &#8220;Terms Search&#8221; features let you filter the Media/Assistant submenu table and the Media Manager Modal Window by matching one or more phrases in the Name field of taxonomy terms. There are two ways to access this feature: