Add date selector to calendars

This commit is contained in:
Brian Miyaji
2014-06-18 23:01:53 +10:00
parent a9a47decd5
commit 51b115377e
5 changed files with 148 additions and 74 deletions

View File

@@ -12,10 +12,13 @@
*/
class SP_Calendar extends SP_Custom_Post {
/** @var array The events status. */
/** @var string The events status. */
public $status;
/** @var array The events order. */
/** @var string The date filter for events. */
public $date;
/** @var string The events order. */
public $order;
/**
@@ -34,11 +37,15 @@ class SP_Calendar extends SP_Custom_Post {
endif;
$this->status = $this->__get( 'status' );
$this->date = $this->__get( 'date' );
$this->order = $this->__get( 'order' );
if ( ! $this->status )
$this->status = 'any';
if ( ! $this->date )
$this->date = 0;
if ( ! $this->order )
$this->order = 'ASC';
}
@@ -64,6 +71,16 @@ class SP_Calendar extends SP_Custom_Post {
),
);
if ( $this->date !== 0 ):
$args['year'] = date('Y');
if ( $this->date == 'w' ):
$args['w'] = date('W');
elseif ( $this->date == 'day' ):
$args['day'] = date('j');
$args['monthnum'] = date('n');
endif;
endif;
if ( $pagenow != 'post-new.php' ):
if ( $this->ID ):
$leagues = get_the_terms( $this->ID, 'sp_league' );
@@ -121,7 +138,7 @@ class SP_Calendar extends SP_Custom_Post {
$events = get_posts( $args );
else:
$events = array();
$events = null;
endif;
return $events;