Changeset 8787 for trunk/src/bp-core/bp-core-classes.php
- Timestamp:
- 08/11/2014 03:13:23 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-classes.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-classes.php
r8753 r8787 1508 1508 } 1509 1509 1510 if ( class_exists( 'WP_Date_Query' ) ) : 1511 /** 1512 * BuddyPress date query class. 1513 * 1514 * Extends the {@link WP_Date_Query} class for use with BuddyPress. 1515 * 1516 * @since BuddyPress (2.1.0) 1517 * 1518 * @param array $date_query { 1519 * Date query arguments. See first parameter of {@link WP_Date_Query::__construct()}. 1520 * } 1521 * @param string $column The DB column to query against. 1522 */ 1523 class BP_Date_Query extends WP_Date_Query { 1524 /** 1525 * The column to query against. Can be changed via the query arguments. 1526 * 1527 * @var string 1528 */ 1529 public $column; 1530 1531 /** 1532 * Constructor. 1533 * 1534 * @see WP_Date_Query::__construct() 1535 */ 1536 public function __construct( $date_query, $column = '' ) { 1537 if ( ! empty( $column ) ) { 1538 $this->column = $column; 1539 add_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) ); 1540 } 1541 1542 parent::__construct( $date_query, $column ); 1543 } 1544 1545 /** 1546 * Destructor. 1547 */ 1548 public function __destruct() { 1549 remove_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) ); 1550 } 1551 1552 /** 1553 * Registers our date column with WP Date Query to pass validation. 1554 * 1555 * @param array $retval Current DB columns 1556 * @return array 1557 */ 1558 public function register_date_column( $retval = array() ) { 1559 $retval[] = $this->column; 1560 return $retval; 1561 } 1562 } 1563 endif; 1510 1564 1511 1565 /**
Note: See TracChangeset
for help on using the changeset viewer.