Changeset 52972 for trunk/src/wp-includes/class-wp-term-query.php
- Timestamp:
- 03/21/2022 11:54:01 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-term-query.php
r52970 r52972 454 454 455 455 if ( $taxonomies ) { 456 $this->sql_clauses['where']['taxonomy'] = "tt.taxonomy IN ('" . implode( "', '", array_map( 'esc_sql', $taxonomies ) ) . "')"; 456 $this->sql_clauses['where']['taxonomy'] = 457 "tt.taxonomy IN ('" . implode( "', '", array_map( 'esc_sql', $taxonomies ) ) . "')"; 457 458 } 458 459 … … 527 528 } 528 529 529 $args['name'] = is_string( $args['name'] ) && 0 === strlen( $args['name'] ) ? array() : (array) $args['name']; 530 if ( '' === $args['name'] ) { 531 $args['name'] = array(); 532 } else { 533 $args['name'] = (array) $args['name']; 534 } 535 530 536 if ( ! empty( $args['name'] ) ) { 531 537 $names = $args['name']; … … 538 544 } 539 545 540 $args['slug'] = is_string( $args['slug'] ) && 0 === strlen( $args['slug'] ) ? array() : array_map( 'sanitize_title', (array) $args['slug'] ); 546 if ( '' === $args['slug'] ) { 547 $args['slug'] = array(); 548 } else { 549 $args['slug'] = array_map( 'sanitize_title', (array) $args['slug'] ); 550 } 551 541 552 if ( ! empty( $args['slug'] ) ) { 542 553 $slug = implode( "', '", $args['slug'] ); … … 545 556 } 546 557 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'] ); 558 if ( '' === $args['term_taxonomy_id'] ) { 559 $args['term_taxonomy_id'] = array(); 560 } else { 561 $args['term_taxonomy_id'] = array_map( 'intval', (array) $args['term_taxonomy_id'] ); 562 } 563 548 564 if ( ! empty( $args['term_taxonomy_id'] ) ) { 549 565 $tt_ids = implode( ',', $args['term_taxonomy_id'] ); … … 553 569 554 570 if ( ! empty( $args['name__like'] ) ) { 555 $this->sql_clauses['where']['name__like'] = $wpdb->prepare( 't.name LIKE %s', '%' . $wpdb->esc_like( $args['name__like'] ) . '%' ); 571 $this->sql_clauses['where']['name__like'] = $wpdb->prepare( 572 't.name LIKE %s', 573 '%' . $wpdb->esc_like( $args['name__like'] ) . '%' 574 ); 556 575 } 557 576 558 577 if ( ! empty( $args['description__like'] ) ) { 559 $this->sql_clauses['where']['description__like'] = $wpdb->prepare( 'tt.description LIKE %s', '%' . $wpdb->esc_like( $args['description__like'] ) . '%' ); 560 } 561 562 $args['object_ids'] = is_string( $args['object_ids'] ) && 0 === strlen( $args['object_ids'] ) ? array() : array_map( 'intval', (array) $args['object_ids'] ); 578 $this->sql_clauses['where']['description__like'] = $wpdb->prepare( 579 'tt.description LIKE %s', 580 '%' . $wpdb->esc_like( $args['description__like'] ) . '%' 581 ); 582 } 583 584 if ( '' === $args['object_ids'] ) { 585 $args['object_ids'] = array(); 586 } else { 587 $args['object_ids'] = array_map( 'intval', (array) $args['object_ids'] ); 588 } 589 563 590 if ( ! empty( $args['object_ids'] ) ) { 564 591 $object_ids = implode( ', ', $args['object_ids'] ); … … 666 693 $where = implode( ' AND ', $this->sql_clauses['where'] ); 667 694 695 $pieces = compact( 'fields', 'join', 'where', 'distinct', 'orderby', 'order', 'limits' ); 696 668 697 /** 669 698 * Filters the terms query SQL clauses. … … 675 704 * @param array $args An array of term query arguments. 676 705 */ 677 $clauses = apply_filters( 'terms_clauses', compact( 'fields', 'join', 'where', 'distinct', 'orderby', 'order', 'limits' ), $taxonomies, $args );706 $clauses = apply_filters( 'terms_clauses', $pieces, $taxonomies, $args ); 678 707 679 708 $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; … … 717 746 // $args can be anything. Only use the args defined in defaults to compute the key. 718 747 $cache_args = wp_array_slice_assoc( $args, array_keys( $this->query_var_defaults ) ); 748 719 749 unset( $cache_args['pad_counts'], $cache_args['update_term_meta_cache'] ); 750 720 751 if ( 'count' !== $_fields && 'all_with_object_id' !== $_fields ) { 721 752 $cache_args['fields'] = 'all'; 722 753 } 754 723 755 $key = md5( serialize( $cache_args ) . serialize( $taxonomies ) . $this->request ); 724 756 $last_changed = wp_cache_get_last_changed( 'terms' ); 725 757 $cache_key = "get_terms:$key:$last_changed"; 726 758 $cache = wp_cache_get( $cache_key, 'terms' ); 759 727 760 if ( false !== $cache ) { 728 761 if ( 'ids' === $_fields ) {
Note: See TracChangeset
for help on using the changeset viewer.