Filter by event_status (published or/and scheduled) the League Tables
This commit is contained in:
@@ -23,6 +23,12 @@ class SP_League_Table extends SP_Secondary_Post {
|
||||
|
||||
/** @var array Teams to check for tiebreakers. */
|
||||
public $tiebreakers = array();
|
||||
|
||||
/** @var int Show Published events. */
|
||||
public $show_published_events;
|
||||
|
||||
/** @var int Show Scheduled events. */
|
||||
public $show_future_events;
|
||||
|
||||
/**
|
||||
* Returns formatted data
|
||||
@@ -222,10 +228,40 @@ class SP_League_Table extends SP_Secondary_Post {
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
|
||||
|
||||
// Get which event status to include
|
||||
$event_status = get_post_meta( $this->ID, 'sp_event_status', true );
|
||||
|
||||
if ( empty( $event_status ) ) {
|
||||
$event_status = array( 'publish', 'future' );
|
||||
}
|
||||
|
||||
if ( isset( $this->show_published_events ) ) { // If an attribute was pass through shortcode
|
||||
if ( $this->show_published_events == '1' ) {
|
||||
$event_status[] = 'publish';
|
||||
}else{
|
||||
if ( ( $status_key = array_search( 'publish', $event_status ) ) !== false ) {
|
||||
unset( $event_status[ $status_key ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $this->show_future_events ) ) { // If an attribute was pass through shortcode
|
||||
if ( $this->show_future_events == '1' ) {
|
||||
$event_status[] = 'future';
|
||||
}else{
|
||||
if ( ( $status_key = array_search('future', $event_status) ) !== false ) {
|
||||
unset( $event_status[ $status_key ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure to have unique values in the array
|
||||
$event_status = array_unique( $event_status );
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'sp_event',
|
||||
'post_status' => array( 'publish', 'future' ),
|
||||
'post_status' => $event_status,
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'post_date',
|
||||
|
||||
Reference in New Issue
Block a user