/**
  * Constructor - set the MLA Terms.
  *
  * @param string Taxonomy name/slug.
  */
 function __construct($taxonomy)
 {
     $attr = array('taxonomy' => $taxonomy, 'pad_counts' => 'true');
     $terms = MLAShortcodes::mla_get_terms($attr);
     unset($terms['found_rows']);
     foreach ($terms as $term) {
         $this->mla_terms[$term->term_taxonomy_id] = $term->count;
     }
 }
 /**
  * WordPress Filter for edit taxonomy "Attachments" column,
  * which returns a count of the attachments assigned a given term
  *
  * @since 0.30
  *
  * @param	string	current column value; always ''
  * @param	array	name of the column
  * @param	array	ID of the term for which the count is desired
  *
  * @return	array	HTML markup for the column content; number of attachments in the category
  *					and alink to retrieve a list of them
  */
 public static function mla_taxonomy_column_filter($place_holder, $column_name, $term_id)
 {
     static $taxonomy = NULL, $tax_object = NULL, $count_terms = false, $terms = array();
     /*
      * Do these setup tasks once per page load
      */
     if (NULL == $taxonomy) {
         /*
          * Adding or inline-editing a tag is done with AJAX, and there's no current screen object
          */
         if (defined('DOING_AJAX') && DOING_AJAX) {
             $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
         } else {
             $screen = get_current_screen();
             $taxonomy = !empty($screen->taxonomy) ? $screen->taxonomy : 'post_tag';
         }
         $tax_object = get_taxonomy($taxonomy);
         $count_terms = 'checked' == MLAOptions::mla_get_option(MLAOptions::MLA_COUNT_TERM_ATTACHMENTS);
         if ($count_terms) {
             $terms = get_transient(MLA_OPTION_PREFIX . 't_term_counts_' . $taxonomy);
             if (!is_array($terms)) {
                 $cloud = MLAShortcodes::mla_get_terms(array('taxonomy' => $taxonomy, 'fields' => 't.term_id, t.name, t.slug, COUNT(p.ID) AS `count`', 'number' => 0, 'no_orderby' => true));
                 unset($cloud['found_rows']);
                 foreach ($cloud as $term) {
                     $terms[$term->term_id] = $term;
                 }
                 set_transient(MLA_OPTION_PREFIX . 't_term_counts_' . $taxonomy, $terms, 300);
                 // five minutes
             }
             // build the array
         }
         // set $terms
     }
     // setup tasks
     if (isset($terms[$term_id])) {
         $term = $terms[$term_id];
         $column_text = number_format_i18n($term->count);
     } else {
         $term = get_term($term_id, $taxonomy);
         if (is_wp_error($term)) {
             /* translators: 1: ERROR tag 2: taxonomy 3: error message */
             error_log(sprintf(_x('%1$s: mla_taxonomy_column_filter( "%2$s" ) - get_term failed: "%3$s"', 'error_log', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), $taxonomy, $term->get_error_message()), 0);
             return 0;
         } elseif ($count_terms) {
             $column_text = number_format_i18n(0);
         } else {
             $column_text = __('click to search', 'media-library-assistant');
         }
     }
     return sprintf('<a href="%1$s">%2$s</a>', esc_url(add_query_arg(array('page' => MLA::ADMIN_PAGE_SLUG, 'mla-tax' => $taxonomy, 'mla-term' => $term->slug, 'heading_suffix' => urlencode($tax_object->label . ':' . $term->name)), 'upload.php')), $column_text);
 }