Changeset 38768 for trunk/src/wp-includes/date.php
- Timestamp:
- 10/10/2016 06:37:02 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/date.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/date.php
r38280 r38768 62 62 */ 63 63 public $time_keys = array( 'after', 'before', 'year', 'month', 'monthnum', 'week', 'w', 'dayofyear', 'day', 'dayofweek', 'dayofweek_iso', 'hour', 'minute', 'second' ); 64 65 /**66 * @since 4.7.067 * @access protected68 * @var wpdb69 */70 protected $db;71 64 72 65 /** … … 159 152 */ 160 153 public function __construct( $date_query, $default_column = 'post_date' ) { 161 $this->db = $GLOBALS['wpdb'];162 163 154 if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) { 164 155 $this->relation = 'OR'; … … 495 486 */ 496 487 public function validate_column( $column ) { 488 global $wpdb; 489 497 490 $valid_columns = array( 498 491 'post_date', 'post_date_gmt', 'post_modified', … … 519 512 520 513 $known_columns = array( 521 $ this->db->posts => array(514 $wpdb->posts => array( 522 515 'post_date', 523 516 'post_date_gmt', … … 525 518 'post_modified_gmt', 526 519 ), 527 $ this->db->comments => array(520 $wpdb->comments => array( 528 521 'comment_date', 529 522 'comment_date_gmt', 530 523 ), 531 $ this->db->users => array(524 $wpdb->users => array( 532 525 'user_registered', 533 526 ), 534 $ this->db->blogs => array(527 $wpdb->blogs => array( 535 528 'registered', 536 529 'last_updated', … … 724 717 */ 725 718 protected function get_sql_for_clause( $query, $parent_query ) { 719 global $wpdb; 720 726 721 // The sub-parts of a $where part. 727 722 $where_parts = array(); … … 746 741 // Range queries. 747 742 if ( ! empty( $query['after'] ) ) { 748 $where_parts[] = $ this->db->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) );743 $where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) ); 749 744 } 750 745 if ( ! empty( $query['before'] ) ) { 751 $where_parts[] = $ this->db->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) );746 $where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) ); 752 747 } 753 748 // Specific value queries. … … 963 958 */ 964 959 public function build_time_query( $column, $compare, $hour = null, $minute = null, $second = null ) { 960 global $wpdb; 961 965 962 // Have to have at least one 966 963 if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) … … 1016 1013 } 1017 1014 1018 return $ this->db->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time );1015 return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time ); 1019 1016 } 1020 1017 }
Note: See TracChangeset
for help on using the changeset viewer.