BP_Date_Query
BuddyPress date query class.
Description
Extends the WP_Date_Query class for use with BuddyPress.
Parameters
- $date_query
-
(Required) Date query arguments. See first parameter of WP_Date_Query::__construct().
- $column
-
(Required) The DB column to query against.
Source
File: bp-core/classes/class-bp-date-query.php
class BP_Date_Query extends WP_Date_Query { /** * The column to query against. Can be changed via the query arguments. * * @var string */ public $column; /** * Constructor. * * @param array $date_query Date query arguments. * @param string $column THe DB column to query against. * * @see WP_Date_Query::__construct() */ public function __construct( $date_query, $column = '' ) { if ( ! empty( $column ) ) { $this->column = $column; add_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) ); } parent::__construct( $date_query, $column ); } /** * Destructor. */ public function __destruct() { remove_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) ); } /** * Registers our date column with WP Date Query to pass validation. * * @param array $retval Current DB columns. * @return array */ public function register_date_column( $retval = array() ) { $retval[] = $this->column; return $retval; } }
Changelog
Version | Description |
---|---|
BuddyPress 2.1.0 | Introduced. |
Methods
- __construct — Constructor.
- __destruct — Destructor.
- register_date_column — Registers our date column with WP Date Query to pass validation.
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.