Changeset 38768 for trunk/src/wp-includes/class-wp-term-query.php
- Timestamp:
- 10/10/2016 06:37:02 AM (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
r38667 r38768 86 86 */ 87 87 public $terms; 88 89 /**90 * @since 4.7.091 * @access protected92 * @var wpdb93 */94 protected $db;95 88 96 89 /** … … 187 180 */ 188 181 public function __construct( $query = '' ) { 189 $this->db = $GLOBALS['wpdb'];190 191 182 $this->query_var_defaults = array( 192 183 'taxonomy' => null, … … 315 306 * @access public 316 307 * 308 * @global wpdb $wpdb WordPress database abstraction object. 309 * 317 310 * @return array 318 311 */ 319 312 public function get_terms() { 313 global $wpdb; 314 320 315 $this->parse_query( $this->query_vars ); 321 316 $args = $this->query_vars; … … 510 505 $this->sql_clauses['where']['term_taxonomy_id'] = "tt.term_taxonomy_id IN ({$tt_ids})"; 511 506 } else { 512 $this->sql_clauses['where']['term_taxonomy_id'] = $ this->db->prepare( "tt.term_taxonomy_id = %d", $args['term_taxonomy_id'] );507 $this->sql_clauses['where']['term_taxonomy_id'] = $wpdb->prepare( "tt.term_taxonomy_id = %d", $args['term_taxonomy_id'] ); 513 508 } 514 509 } 515 510 516 511 if ( ! empty( $args['name__like'] ) ) { 517 $this->sql_clauses['where']['name__like'] = $ this->db->prepare( "t.name LIKE %s", '%' . $this->db->esc_like( $args['name__like'] ) . '%' );512 $this->sql_clauses['where']['name__like'] = $wpdb->prepare( "t.name LIKE %s", '%' . $wpdb->esc_like( $args['name__like'] ) . '%' ); 518 513 } 519 514 520 515 if ( ! empty( $args['description__like'] ) ) { 521 $this->sql_clauses['where']['description__like'] = $ this->db->prepare( "tt.description LIKE %s", '%' . $this->db->esc_like( $args['description__like'] ) . '%' );516 $this->sql_clauses['where']['description__like'] = $wpdb->prepare( "tt.description LIKE %s", '%' . $wpdb->esc_like( $args['description__like'] ) . '%' ); 522 517 } 523 518 … … 639 634 $fields = implode( ', ', apply_filters( 'get_terms_fields', $selects, $args, $taxonomies ) ); 640 635 641 $join .= " INNER JOIN {$this->db->term_taxonomy}AS tt ON t.term_id = tt.term_id";636 $join .= " INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id"; 642 637 643 638 if ( ! empty( $this->query_vars['object_ids'] ) ) { 644 $join .= " INNER JOIN {$ this->db->term_relationships} AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id";639 $join .= " INNER JOIN {$wpdb->term_relationships} AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id"; 645 640 } 646 641 … … 671 666 672 667 $this->sql_clauses['select'] = "SELECT $distinct $fields"; 673 $this->sql_clauses['from'] = "FROM {$this->db->terms}AS t $join";668 $this->sql_clauses['from'] = "FROM $wpdb->terms AS t $join"; 674 669 $this->sql_clauses['orderby'] = $orderby ? "$orderby $order" : ''; 675 670 $this->sql_clauses['limits'] = $limits; … … 696 691 697 692 if ( 'count' == $_fields ) { 698 return $ this->db->get_var( $this->request );699 } 700 701 $terms = $ this->db->get_results( $this->request );693 return $wpdb->get_var( $this->request ); 694 } 695 696 $terms = $wpdb->get_results( $this->request ); 702 697 if ( 'all' == $_fields || 'all_with_object_id' === $_fields ) { 703 698 update_term_cache( $terms ); … … 830 825 * @since 4.6.0 831 826 * @access protected 827 * 828 * @global wpdb $wpdb WordPress database abstraction object. 832 829 * 833 830 * @param string $orderby_raw Alias for the field to order by. … … 967 964 * @access protected 968 965 * 966 * @global wpdb $wpdb WordPress database abstraction object. 967 * 969 968 * @param string $string 970 969 * @return string 971 970 */ 972 971 protected function get_search_sql( $string ) { 973 $like = '%' . $this->db->esc_like( $string ) . '%'; 974 975 return $this->db->prepare( '((t.name LIKE %s) OR (t.slug LIKE %s))', $like, $like ); 972 global $wpdb; 973 974 $like = '%' . $wpdb->esc_like( $string ) . '%'; 975 976 return $wpdb->prepare( '((t.name LIKE %s) OR (t.slug LIKE %s))', $like, $like ); 976 977 } 977 978 }
Note: See TracChangeset
for help on using the changeset viewer.