function _pp_flt_administrator_pad_term_counts($terms, $taxonomies, $args)
{
    if (!defined('XMLRPC_REQUEST') && 'all' == $args['fields'] && empty($args['pp_no_filter'])) {
        global $pagenow;
        if (!is_admin() || !in_array($pagenow, array('post.php', 'post-new.php'))) {
            require_once PPC_ABSPATH . '/terms-query-lib_pp.php';
            // pp_tally_term_counts() is PP equivalent to WP _pad_term_counts()
            $args['required_operation'] = pp_is_front() && !is_preview() ? 'read' : 'edit';
            PP_TermsQueryLib::tally_term_counts($terms, reset($taxonomies), $args);
        }
    }
    return $terms;
}
 public static function flt_get_terms($terms, $taxonomies, $args)
 {
     if (!is_array($terms)) {
         return $terms;
     }
     if (empty($terms)) {
         return array();
     }
     global $terms_interceptor;
     if ($terms_interceptor->skip_filtering($taxonomies, $args)) {
         return $terms;
     }
     extract($args, EXTR_SKIP);
     if ('ids' == $fields) {
         return $terms;
     }
     // if some args were forced to prevent core post-processing, restore actual values now
     if (!empty($args['actual_args'])) {
         extract($args['actual_args']);
     }
     if ('all' == $fields) {
         // buffer term names in case they were filtered previously
         $term_names = pp_get_property_array($terms, 'term_id', 'name');
     }
     if (!empty($child_of)) {
         $children = _get_term_hierarchy(reset($taxonomies));
         if (!empty($children)) {
             $terms = _get_term_children($child_of, $terms, reset($taxonomies));
         }
     }
     // Replace DB-stored term counts with actual number of posts this user can read.
     // In addition, without the pp_tally_term_counts() call, WP will hide terms that have no public posts (even if this user can read some of the pvt posts).
     // Post counts will be incremented to include child terms only if $pad_counts is true
     if (!defined('XMLRPC_REQUEST') && 1 == count($taxonomies)) {
         global $pagenow;
         if (!is_admin() || !in_array($pagenow, array('post.php', 'post-new.php'))) {
             if ($hide_empty || !empty($args['actual_args']['hide_empty'])) {
                 // need to tally for all terms in case some were hidden by core function due to lack of public posts
                 $all_terms = get_terms(reset($taxonomies), array('fields' => 'all', 'pp_no_filter' => true, 'hide_empty' => false));
                 PP_TermsQueryLib::tally_term_counts($all_terms, reset($taxonomies), compact('pad_counts', 'skip_teaser', 'post_type'));
                 foreach (array_keys($terms) as $k) {
                     foreach (array_keys($all_terms) as $key) {
                         if ($all_terms[$key]->term_taxonomy_id == $terms[$k]->term_taxonomy_id) {
                             $terms[$k]->count = $all_terms[$key]->count;
                             break;
                         }
                     }
                 }
             } else {
                 PP_TermsQueryLib::tally_term_counts($terms, reset($taxonomies), compact('pad_counts', 'skip_teaser', 'post_type'));
             }
         }
     }
     if ($hide_empty || !empty($args['actual_args']['hide_empty'])) {
         if ($hierarchical) {
             foreach ($taxonomies as $taxonomy) {
                 if (empty($all_terms) || count($taxonomies) > 1) {
                     $all_terms = get_terms($taxonomy, array('fields' => 'all', 'pp_no_filter' => true, 'hide_empty' => false));
                 }
                 // Remove empty terms, but only if their descendants are all empty too.
                 foreach ($terms as $k => $term) {
                     if (!$term->count) {
                         if ($descendants = _get_term_children($term->term_id, $all_terms, $taxonomy)) {
                             foreach ($descendants as $child) {
                                 if ($child->count) {
                                     continue 2;
                                 }
                             }
                         }
                         // It really is empty
                         unset($terms[$k]);
                     }
                 }
             }
         } else {
             foreach ($terms as $key => $term) {
                 if (!$term->count) {
                     unset($terms[$key]);
                 }
             }
         }
     }
     if ($hierarchical && !$parent && count($taxonomies) == 1) {
         require_once PPC_ABSPATH . '/lib/ancestry_lib_pp.php';
         $ancestors = PP_Ancestry::get_term_ancestors(reset($taxonomies));
         // array of all ancestor IDs for keyed term_id, with direct parent first
         $remap_args = array_merge(compact('child_of', 'parent', 'exclude'), array('orderby' => 'name', 'col_id' => 'term_id', 'col_parent' => 'parent'));
         PP_Ancestry::remap_tree($terms, $ancestors, $remap_args);
     }
     reset($terms);
     // === Standard WP post-processing for include, fields, number args ===
     //
     $_terms = array();
     if ('id=>parent' == $fields) {
         while ($term = array_shift($terms)) {
             $_terms[$term->term_id] = $term->parent;
         }
         $terms = $_terms;
     } elseif ('ids' == $fields) {
         while ($term = array_shift($terms)) {
             $_terms[] = $term->term_id;
         }
         $terms = $_terms;
     } elseif ('names' == $fields) {
         while ($term = array_shift($terms)) {
             $_terms[] = $term->name;
         }
         $terms = $_terms;
     }
     if (0 < $number && intval(@count($terms)) > $number) {
         $terms = array_slice($terms, $offset, $number);
     }
     // === end standard WP block ===
     // restore buffered term names in case they were filtered previously
     if ('all' == $fields) {
         pp_restore_property_array($terms, $term_names, 'term_id', 'name');
     }
     return $terms;
 }