WordPress.org

Make WordPress Core

Ticket #15020: wp-includes-taxonomy-filters-refresh.patch

File wp-includes-taxonomy-filters-refresh.patch, 1.8 KB (added by sc0ttkclark, 4 years ago)

Refreshed patch, also adjusted final returns (cached / non-cached) to use best-practice coding as per @scribu's suggestion

  • wp-includes/taxonomy.php

     
    941941                $args['hierarchical'] = false; 
    942942                $args['pad_counts'] = false; 
    943943        } 
     944        $args = apply_filters( 'pre_get_terms', $args, $taxonomies ); 
    944945        extract($args, EXTR_SKIP); 
    945946 
    946947        if ( $child_of ) { 
     
    966967        $cache_key = "get_terms:$key:$last_changed"; 
    967968        $cache = wp_cache_get( $cache_key, 'terms' ); 
    968969        if ( false !== $cache ) { 
    969                 $cache = apply_filters('get_terms', $cache, $taxonomies, $args); 
    970                 return $cache; 
     970                return apply_filters('get_terms', $cache, $taxonomies, $args); 
    971971        } 
    972972 
    973973        $_orderby = strtolower($orderby); 
     
    10891089        } 
    10901090        $select_this = implode(', ', apply_filters( 'get_terms_fields', $selects, $args )); 
    10911091 
     1092        $pieces = array( 'select_this', 'in_taxonomies', 'where', 'orderby', 'order', 'limit' ); 
     1093        $clauses = apply_filters( 'terms_clauses', compact( $pieces ) ); 
     1094        foreach ( $pieces as $piece ) 
     1095                $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : ''; 
     1096 
    10921097        $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where $orderby $order $limit"; 
    10931098 
    10941099        if ( 'count' == $fields ) { 
     
    11031108 
    11041109        if ( empty($terms) ) { 
    11051110                wp_cache_add( $cache_key, array(), 'terms', 86400 ); // one day 
    1106                 $terms = apply_filters('get_terms', array(), $taxonomies, $args); 
    1107                 return $terms; 
     1111                return apply_filters('get_terms', array(), $taxonomies, $args); 
    11081112        } 
    11091113 
    11101114        if ( $child_of ) { 
     
    11551159 
    11561160        wp_cache_add( $cache_key, $terms, 'terms', 86400 ); // one day 
    11571161 
    1158         $terms = apply_filters('get_terms', $terms, $taxonomies, $args); 
    1159         return $terms; 
     1162        return apply_filters('get_terms', $terms, $taxonomies, $args); 
    11601163} 
    11611164 
    11621165/**