Changeset 38275 for trunk/src/wp-includes/class-wp-term-query.php
- Timestamp:
- 08/18/2016 06:20:55 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-term-query.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-term-query.php
r38212 r38275 86 86 */ 87 87 public $terms; 88 89 /** 90 * @since 4.7.0 91 * @access protected 92 * @var wpdb 93 */ 94 protected $db; 88 95 89 96 /** … … 173 180 */ 174 181 public function __construct( $query = '' ) { 182 $this->db = $GLOBALS['wpdb']; 183 175 184 $this->query_var_defaults = array( 176 185 'taxonomy' => null, … … 294 303 * @access public 295 304 * 296 * @global wpdb $wpdb WordPress database abstraction object.297 *298 305 * @return array 299 306 */ 300 307 public function get_terms() { 301 global $wpdb;302 303 308 $this->parse_query( $this->query_vars ); 304 309 $args = $this->query_vars; … … 487 492 $this->sql_clauses['where']['term_taxonomy_id'] = "tt.term_taxonomy_id IN ({$tt_ids})"; 488 493 } else { 489 $this->sql_clauses['where']['term_taxonomy_id'] = $ wpdb->prepare( "tt.term_taxonomy_id = %d", $args['term_taxonomy_id'] );494 $this->sql_clauses['where']['term_taxonomy_id'] = $this->db->prepare( "tt.term_taxonomy_id = %d", $args['term_taxonomy_id'] ); 490 495 } 491 496 } 492 497 493 498 if ( ! empty( $args['name__like'] ) ) { 494 $this->sql_clauses['where']['name__like'] = $ wpdb->prepare( "t.name LIKE %s", '%' . $wpdb->esc_like( $args['name__like'] ) . '%' );499 $this->sql_clauses['where']['name__like'] = $this->db->prepare( "t.name LIKE %s", '%' . $this->db->esc_like( $args['name__like'] ) . '%' ); 495 500 } 496 501 497 502 if ( ! empty( $args['description__like'] ) ) { 498 $this->sql_clauses['where']['description__like'] = $ wpdb->prepare( "tt.description LIKE %s", '%' . $wpdb->esc_like( $args['description__like'] ) . '%' );503 $this->sql_clauses['where']['description__like'] = $this->db->prepare( "tt.description LIKE %s", '%' . $this->db->esc_like( $args['description__like'] ) . '%' ); 499 504 } 500 505 … … 592 597 $fields = implode( ', ', apply_filters( 'get_terms_fields', $selects, $args, $taxonomies ) ); 593 598 594 $join .= " INNER JOIN $wpdb->term_taxonomyAS tt ON t.term_id = tt.term_id";599 $join .= " INNER JOIN {$this->db->term_taxonomy} AS tt ON t.term_id = tt.term_id"; 595 600 596 601 $where = implode( ' AND ', $this->sql_clauses['where'] ); … … 622 627 623 628 $this->sql_clauses['select'] = "SELECT $distinct $fields"; 624 $this->sql_clauses['from'] = "FROM $wpdb->termsAS t $join";629 $this->sql_clauses['from'] = "FROM {$this->db->terms} AS t $join"; 625 630 $this->sql_clauses['orderby'] = $orderby ? "$orderby $order" : ''; 626 631 $this->sql_clauses['limits'] = $limits; … … 647 652 648 653 if ( 'count' == $_fields ) { 649 return $ wpdb->get_var( $this->request );650 } 651 652 $terms = $ wpdb->get_results( $this->request );654 return $this->db->get_var( $this->request ); 655 } 656 657 $terms = $this->db->get_results( $this->request ); 653 658 if ( 'all' == $_fields ) { 654 659 update_term_cache( $terms ); … … 753 758 * @since 4.6.0 754 759 * @access protected 755 *756 * @global wpdb $wpdb WordPress database abstraction object.757 760 * 758 761 * @param string $orderby_raw Alias for the field to order by. … … 895 898 * @access protected 896 899 * 897 * @global wpdb $wpdb WordPress database abstraction object.898 *899 900 * @param string $string 900 901 * @return string 901 902 */ 902 903 protected function get_search_sql( $string ) { 903 global $wpdb; 904 905 $like = '%' . $wpdb->esc_like( $string ) . '%'; 906 907 return $wpdb->prepare( '((t.name LIKE %s) OR (t.slug LIKE %s))', $like, $like ); 904 $like = '%' . $this->db->esc_like( $string ) . '%'; 905 906 return $this->db->prepare( '((t.name LIKE %s) OR (t.slug LIKE %s))', $like, $like ); 908 907 } 909 908 }
Note: See TracChangeset
for help on using the changeset viewer.