Changeset 43049 for trunk/src/wp-includes/class-wp-term-query.php
- Timestamp:
- 04/30/2018 09:07:16 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-term-query.php
r42876 r43049 679 679 if ( false !== $cache ) { 680 680 if ( 'all' === $_fields ) { 681 $cache = array_map( 'get_term',$cache );681 $cache = $this->populate_terms( $cache ); 682 682 } 683 683 … … 811 811 812 812 if ( 'all' === $_fields || 'all_with_object_id' === $_fields ) { 813 $terms = array_map( 'get_term',$terms );813 $terms = $this->populate_terms( $terms ); 814 814 } 815 815 … … 973 973 return $wpdb->prepare( '((t.name LIKE %s) OR (t.slug LIKE %s))', $like, $like ); 974 974 } 975 976 /** 977 * Creates an array of term objects from an array of term IDs. 978 * 979 * Also discards invalid term objects. 980 * 981 * @since 5.0.0 982 * 983 * @param array $term_ids Term IDs. 984 * @return array 985 */ 986 protected function populate_terms( $term_ids ) { 987 $terms = array(); 988 989 if ( ! is_array( $term_ids ) ) { 990 return $terms; 991 } 992 993 foreach ( $term_ids as $key => $term_id ) { 994 $term = get_term( $term_id ); 995 if ( $term instanceof WP_Term ) { 996 $terms[ $key ] = $term; 997 } 998 } 999 1000 return $terms; 1001 } 975 1002 }
Note: See TracChangeset
for help on using the changeset viewer.