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
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | 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.