Move date range properties to abstract

This commit is contained in:
Brian Miyaji
2017-11-08 18:53:59 +11:00
parent 88ac36a930
commit b6bac0618b
2 changed files with 19 additions and 18 deletions

View File

@@ -11,6 +11,25 @@
* @author ThemeBoy
*/
abstract class SP_Secondary_Post extends SP_Custom_Post {
/** @var string The date filter for events. */
public $date = 0;
/** @var string The date to range from. */
public $from = 'now';
/** @var string The date to range to. */
public $to = 'now';
/** @var string The number of days to query in the past. */
public $past = 0;
/** @var string The number of days to query in the future. */
public $future = 0;
/** @var boolean Determines whether the date range is relative. */
public $relative = false;
public function range( $where = '', $format = 'Y-m-d' ) {
$from = new DateTime( $this->from, new DateTimeZone( get_option( 'timezone_string' ) ) );
$to = new DateTime( $this->to, new DateTimeZone( get_option( 'timezone_string' ) ) );

View File

@@ -19,30 +19,12 @@ class SP_Calendar extends SP_Secondary_Post {
/** @var string The events status. */
public $status;
/** @var string The date filter for events. */
public $date;
/** @var string The events order. */
public $order;
/** @var string The events orderby. */
public $orderby;
/** @var string The date to range from. */
public $from;
/** @var string The date to range to. */
public $to;
/** @var string The number of days to query in the past. */
public $past;
/** @var string The number of days to query in the future. */
public $future;
/** @var boolean Determines whether the date range is relative. */
public $relative;
/** @var string The match day. */
public $day;