~canonical-sysadmins/wordpress/4.8

« back to all changes in this revision

Viewing changes to wp-includes/date.php

  • Committer: Barry Price
  • Date: 2016-08-17 04:50:12 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: barry.price@canonical.com-20160817045012-qfui81zhqnqv2ba9
Merge WP4.6 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/**
3
3
 * Class for generating SQL clauses that filter a primary query according to date.
4
4
 *
5
 
 * `WP_Date_Query` is a helper that allows primary query classes, such as {@see WP_Query},
6
 
 * to filter their results by date columns, by generating `WHERE` subclauses to be attached
7
 
 * to the primary SQL query string.
 
5
 * WP_Date_Query is a helper that allows primary query classes, such as WP_Query, to filter
 
6
 * their results by date columns, by generating `WHERE` subclauses to be attached to the
 
7
 * primary SQL query string.
8
8
 *
9
9
 * Attempting to filter by an invalid date value (eg month=13) will generate SQL that will
10
10
 * return no results. In these cases, a _doing_it_wrong() error notice is also thrown.
11
 
 * See {@link WP_Date_Query::validate_date_values()}.
 
11
 * See WP_Date_Query::validate_date_values().
12
12
 *
13
13
 * @link https://codex.wordpress.org/Function_Reference/WP_Query Codex page.
14
14
 *
18
18
        /**
19
19
         * Array of date queries.
20
20
         *
21
 
         * See {@see WP_Date_Query::__construct()} for information on date query arguments.
 
21
         * See WP_Date_Query::__construct() for information on date query arguments.
22
22
         *
23
23
         * @since 3.7.0
24
24
         * @access public
491
491
                $valid_columns = array(
492
492
                        'post_date', 'post_date_gmt', 'post_modified',
493
493
                        'post_modified_gmt', 'comment_date', 'comment_date_gmt',
494
 
                        'user_registered',
 
494
                        'user_registered', 'registered', 'last_updated',
495
495
                );
496
496
 
497
497
                // Attempt to detect a table prefix.
498
498
                if ( false === strpos( $column, '.' ) ) {
499
499
                        /**
500
 
                         * Filter the list of valid date query columns.
 
500
                         * Filters the list of valid date query columns.
501
501
                         *
502
502
                         * @since 3.7.0
503
503
                         * @since 4.1.0 Added 'user_registered' to the default recognized columns.
525
525
                                $wpdb->users => array(
526
526
                                        'user_registered',
527
527
                                ),
 
528
                                $wpdb->blogs => array(
 
529
                                        'registered',
 
530
                                        'last_updated',
 
531
                                ),
528
532
                        );
529
533
 
530
534
                        // If it's a known column name, add the appropriate table prefix.
555
559
                $where = $sql['where'];
556
560
 
557
561
                /**
558
 
                 * Filter the date query WHERE clause.
 
562
                 * Filters the date query WHERE clause.
559
563
                 *
560
564
                 * @since 3.7.0
561
565
                 *
568
572
        /**
569
573
         * Generate SQL clauses to be appended to a main query.
570
574
         *
571
 
         * Called by the public {@see WP_Date_Query::get_sql()}, this method
572
 
         * is abstracted out to maintain parity with the other Query classes.
 
575
         * Called by the public WP_Date_Query::get_sql(), this method is abstracted
 
576
         * out to maintain parity with the other Query classes.
573
577
         *
574
578
         * @since 4.1.0
575
579
         * @access protected