Changeset 35120
- Timestamp:
- 10/13/2015 03:06:27 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy-functions.php
r35117 r35120 1145 1145 } 1146 1146 1147 // $args can be whatever, only use the args defined in defaults to compute the key.1148 $filter_key = ( has_filter('list_terms_exclusions') ) ? serialize($GLOBALS['wp_filter']['list_terms_exclusions']) : '';1149 $key = md5( serialize( wp_array_slice_assoc( $args, array_keys( $defaults ) ) ) . serialize( $taxonomies ) . $filter_key );1150 $last_changed = wp_cache_get( 'last_changed', 'terms' );1151 if ( ! $last_changed ) {1152 $last_changed = microtime();1153 wp_cache_set( 'last_changed', $last_changed, 'terms' );1154 }1155 $cache_key = "get_terms:$key:$last_changed";1156 $cache = wp_cache_get( $cache_key, 'terms' );1157 if ( false !== $cache ) {1158 if ( 'all' === $args['fields'] ) {1159 $cache = array_map( 'get_term', $cache );1160 }1161 1162 /**1163 * Filter the given taxonomy's terms cache.1164 *1165 * @since 2.3.01166 *1167 * @param array $cache Cached array of terms for the given taxonomy.1168 * @param array $taxonomies An array of taxonomies.1169 * @param array $args An array of get_terms() arguments.1170 */1171 return apply_filters( 'get_terms', $cache, $taxonomies, $args );1172 }1173 1174 1147 $_orderby = strtolower( $args['orderby'] ); 1175 1148 if ( 'count' == $_orderby ) { … … 1419 1392 $query = "SELECT $fields FROM $wpdb->terms AS t $join WHERE $where $orderby $order $limits"; 1420 1393 1394 // $args can be anything. Only use the args defined in defaults to compute the key. 1395 $key = md5( serialize( wp_array_slice_assoc( $args, array_keys( $defaults ) ) ) . serialize( $taxonomies ) . $query ); 1396 $last_changed = wp_cache_get( 'last_changed', 'terms' ); 1397 if ( ! $last_changed ) { 1398 $last_changed = microtime(); 1399 wp_cache_set( 'last_changed', $last_changed, 'terms' ); 1400 } 1401 $cache_key = "get_terms:$key:$last_changed"; 1402 $cache = wp_cache_get( $cache_key, 'terms' ); 1403 if ( false !== $cache ) { 1404 if ( 'all' === $_fields ) { 1405 $cache = array_map( 'get_term', $cache ); 1406 } 1407 1408 /** 1409 * Filter the given taxonomy's terms cache. 1410 * 1411 * @since 2.3.0 1412 * 1413 * @param array $cache Cached array of terms for the given taxonomy. 1414 * @param array $taxonomies An array of taxonomies. 1415 * @param array $args An array of get_terms() arguments. 1416 */ 1417 return apply_filters( 'get_terms', $cache, $taxonomies, $args ); 1418 } 1419 1421 1420 if ( 'count' == $_fields ) { 1422 1421 return $wpdb->get_var( $query );
Note: See TracChangeset
for help on using the changeset viewer.