Changeset 52970 for trunk/src/wp-includes/class-wp-term-query.php
- Timestamp:
- 03/21/2022 03:53:33 AM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-term-query.php
r52836 r52970 527 527 } 528 528 529 if ( 530 ( ! empty( $args['name'] ) ) || 531 ( is_string( $args['name'] ) && 0 !== strlen( $args['name'] ) ) 532 ) { 533 $names = (array) $args['name']; 529 $args['name'] = is_string( $args['name'] ) && 0 === strlen( $args['name'] ) ? array() : (array) $args['name']; 530 if ( ! empty( $args['name'] ) ) { 531 $names = $args['name']; 534 532 foreach ( $names as &$_name ) { 535 533 // `sanitize_term_field()` returns slashed data. … … 540 538 } 541 539 542 if ( 543 ( ! empty( $args['slug'] ) ) || 544 ( is_string( $args['slug'] ) && 0 !== strlen( $args['slug'] ) ) 545 ) { 546 if ( is_array( $args['slug'] ) ) { 547 $slug = array_map( 'sanitize_title', $args['slug'] ); 548 $this->sql_clauses['where']['slug'] = "t.slug IN ('" . implode( "', '", $slug ) . "')"; 549 } else { 550 $slug = sanitize_title( $args['slug'] ); 551 $this->sql_clauses['where']['slug'] = "t.slug = '$slug'"; 552 } 553 } 554 540 $args['slug'] = is_string( $args['slug'] ) && 0 === strlen( $args['slug'] ) ? array() : array_map( 'sanitize_title', (array) $args['slug'] ); 541 if ( ! empty( $args['slug'] ) ) { 542 $slug = implode( "', '", $args['slug'] ); 543 544 $this->sql_clauses['where']['slug'] = "t.slug IN ('" . $slug . "')"; 545 } 546 547 $args['term_taxonomy_id'] = is_string( $args['term_taxonomy_id'] ) && 0 === strlen( $args['term_taxonomy_id'] ) ? array() : array_map( 'intval', (array) $args['term_taxonomy_id'] ); 555 548 if ( ! empty( $args['term_taxonomy_id'] ) ) { 556 if ( is_array( $args['term_taxonomy_id'] ) ) { 557 $tt_ids = implode( ',', array_map( 'intval', $args['term_taxonomy_id'] ) ); 558 $this->sql_clauses['where']['term_taxonomy_id'] = "tt.term_taxonomy_id IN ({$tt_ids})"; 559 } else { 560 $this->sql_clauses['where']['term_taxonomy_id'] = $wpdb->prepare( 'tt.term_taxonomy_id = %d', $args['term_taxonomy_id'] ); 561 } 549 $tt_ids = implode( ',', $args['term_taxonomy_id'] ); 550 551 $this->sql_clauses['where']['term_taxonomy_id'] = "tt.term_taxonomy_id IN ({$tt_ids})"; 562 552 } 563 553 … … 570 560 } 571 561 562 $args['object_ids'] = is_string( $args['object_ids'] ) && 0 === strlen( $args['object_ids'] ) ? array() : array_map( 'intval', (array) $args['object_ids'] ); 572 563 if ( ! empty( $args['object_ids'] ) ) { 573 $object_ids = $args['object_ids']; 574 if ( ! is_array( $object_ids ) ) { 575 $object_ids = array( $object_ids ); 576 } 577 578 $object_ids = implode( ', ', array_map( 'intval', $object_ids ) ); 564 $object_ids = implode( ', ', $args['object_ids'] ); 565 579 566 $this->sql_clauses['where']['object_ids'] = "tr.object_id IN ($object_ids)"; 580 567 } … … 729 716 730 717 // $args can be anything. Only use the args defined in defaults to compute the key. 731 $key = md5( serialize( wp_array_slice_assoc( $args, array_keys( $this->query_var_defaults ) ) ) . serialize( $taxonomies ) . $this->request ); 718 $cache_args = wp_array_slice_assoc( $args, array_keys( $this->query_var_defaults ) ); 719 unset( $cache_args['pad_counts'], $cache_args['update_term_meta_cache'] ); 720 if ( 'count' !== $_fields && 'all_with_object_id' !== $_fields ) { 721 $cache_args['fields'] = 'all'; 722 } 723 $key = md5( serialize( $cache_args ) . serialize( $taxonomies ) . $this->request ); 732 724 $last_changed = wp_cache_get_last_changed( 'terms' ); 733 725 $cache_key = "get_terms:$key:$last_changed";
Note: See TracChangeset
for help on using the changeset viewer.