Changeset 34999 for trunk/src/wp-includes/taxonomy-functions.php
- Timestamp:
- 10/10/2015 03:38:41 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/taxonomy-functions.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy-functions.php
r34998 r34999 2195 2195 * @since 4.2.0 Added support for 'taxonomy', 'parent', and 'term_taxonomy_id' values of `$orderby`. 2196 2196 * Introduced `$parent` argument. 2197 * @since 4.4.0 Introduced `$meta_query` and `$update_term_meta_cache` arguments. 2197 * @since 4.4.0 Introduced `$meta_query` and `$update_term_meta_cache` arguments. When `$fields` is 'all' or 2198 * 'all_with_object_id', an array of `WP_Term` objects will be returned. 2198 2199 * 2199 2200 * @global wpdb $wpdb WordPress database abstraction object. … … 2337 2338 if ( 'all' == $fields || 'all_with_object_id' == $fields ) { 2338 2339 $_terms = $wpdb->get_results( $query ); 2340 $object_id_index = array(); 2339 2341 foreach ( $_terms as $key => $term ) { 2340 $_terms[$key] = sanitize_term( $term, $taxonomy, 'raw' ); 2341 } 2342 $term = sanitize_term( $term, $taxonomy, 'raw' ); 2343 $_terms[ $key ] = $term; 2344 2345 if ( isset( $term->object_id ) ) { 2346 $object_id_index[ $key ] = $term->object_id; 2347 } 2348 } 2349 2350 update_term_cache( $_terms ); 2351 $_terms = array_map( 'get_term', $_terms ); 2352 2353 // Re-add the object_id data, which is lost when fetching terms from cache. 2354 if ( 'all_with_object_id' === $fields ) { 2355 foreach ( $_terms as $key => $_term ) { 2356 if ( isset( $object_id_index[ $key ] ) ) { 2357 $_term->object_id = $object_id_index[ $key ]; 2358 } 2359 } 2360 } 2361 2342 2362 $terms = array_merge( $terms, $_terms ); 2343 update_term_cache( $terms );2344 2363 $objects = true; 2364 2345 2365 } elseif ( 'ids' == $fields || 'names' == $fields || 'slugs' == $fields ) { 2346 2366 $_terms = $wpdb->get_col( $query ); … … 3556 3576 function update_term_cache( $terms, $taxonomy = '' ) { 3557 3577 foreach ( (array) $terms as $term ) { 3558 $term_taxonomy = $taxonomy; 3559 if ( empty($term_taxonomy) ) 3560 $term_taxonomy = $term->taxonomy; 3561 3562 wp_cache_add( $term->term_id, $term, 'terms' ); 3578 // Create a copy in case the array was passed by reference. 3579 $_term = $term; 3580 3581 // Object ID should not be cached. 3582 unset( $_term->object_id ); 3583 3584 wp_cache_add( $term->term_id, $_term, 'terms' ); 3563 3585 } 3564 3586 }
Note: See TracChangeset
for help on using the changeset viewer.