Filter events based on format (Competitive, Friendly, Tournament etc)
This commit is contained in:
@@ -28,6 +28,7 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
$date_past = get_post_meta( $post->ID, 'sp_date_past', true );
|
$date_past = get_post_meta( $post->ID, 'sp_date_past', true );
|
||||||
$date_future = get_post_meta( $post->ID, 'sp_date_future', true );
|
$date_future = get_post_meta( $post->ID, 'sp_date_future', true );
|
||||||
$date_relative = get_post_meta( $post->ID, 'sp_date_relative', true );
|
$date_relative = get_post_meta( $post->ID, 'sp_date_relative', true );
|
||||||
|
$event_format = get_post_meta( $post->ID, 'sp_event_format', true );
|
||||||
$day = get_post_meta( $post->ID, 'sp_day', true );
|
$day = get_post_meta( $post->ID, 'sp_day', true );
|
||||||
$teams = get_post_meta( $post->ID, 'sp_team', false );
|
$teams = get_post_meta( $post->ID, 'sp_team', false );
|
||||||
$table_id = get_post_meta( $post->ID, 'sp_table', true );
|
$table_id = get_post_meta( $post->ID, 'sp_table', true );
|
||||||
@@ -49,6 +50,15 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
sp_dropdown_statuses( $args );
|
sp_dropdown_statuses( $args );
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
<p><strong><?php _e( 'Event Format', 'sportspress' ); ?></strong></p>
|
||||||
|
<p>
|
||||||
|
<select name="sp_event_format" class="postform">
|
||||||
|
<option value="all">All</option>
|
||||||
|
<?php foreach ( SP()->formats->event as $key => $format ): ?>
|
||||||
|
<option value="<?php echo $key; ?>" <?php selected( $event_format, $key ); ?>><?php echo $format; ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
<div class="sp-date-selector">
|
<div class="sp-date-selector">
|
||||||
<p><strong><?php _e( 'Date', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Date', 'sportspress' ); ?></strong></p>
|
||||||
<p>
|
<p>
|
||||||
@@ -139,6 +149,7 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
public static function save( $post_id, $post ) {
|
public static function save( $post_id, $post ) {
|
||||||
update_post_meta( $post_id, 'sp_caption', esc_attr( sp_array_value( $_POST, 'sp_caption', 0 ) ) );
|
update_post_meta( $post_id, 'sp_caption', esc_attr( sp_array_value( $_POST, 'sp_caption', 0 ) ) );
|
||||||
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 0 ) );
|
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 0 ) );
|
||||||
|
update_post_meta( $post_id, 'sp_event_format', sp_array_value( $_POST, 'sp_event_format', 0 ) );
|
||||||
update_post_meta( $post_id, 'sp_date', sp_array_value( $_POST, 'sp_date', 0 ) );
|
update_post_meta( $post_id, 'sp_date', sp_array_value( $_POST, 'sp_date', 0 ) );
|
||||||
update_post_meta( $post_id, 'sp_date_from', sp_array_value( $_POST, 'sp_date_from', null ) );
|
update_post_meta( $post_id, 'sp_date_from', sp_array_value( $_POST, 'sp_date_from', null ) );
|
||||||
update_post_meta( $post_id, 'sp_date_to', sp_array_value( $_POST, 'sp_date_to', null ) );
|
update_post_meta( $post_id, 'sp_date_to', sp_array_value( $_POST, 'sp_date_to', null ) );
|
||||||
|
|||||||
@@ -423,6 +423,18 @@ class SP_AJAX {
|
|||||||
?>
|
?>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
<?php _e( 'Format:', 'sportspress' ); ?>
|
||||||
|
<select name="format" class="postform">
|
||||||
|
<option value="default">Default</option>
|
||||||
|
<option value="all">All</option>
|
||||||
|
<?php foreach ( SP()->formats->event as $key => $format ): ?>
|
||||||
|
<option value="<?php echo $key; ?>"><?php echo $format; ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
<div class="sp-date-selector">
|
<div class="sp-date-selector">
|
||||||
<p><?php _e( 'Date:', 'sportspress' ); ?>
|
<p><?php _e( 'Date:', 'sportspress' ); ?>
|
||||||
<?php
|
<?php
|
||||||
@@ -617,6 +629,18 @@ class SP_AJAX {
|
|||||||
?>
|
?>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
<?php _e( 'Format:', 'sportspress' ); ?>
|
||||||
|
<select name="format" class="postform">
|
||||||
|
<option value="default">Default</option>
|
||||||
|
<option value="all">All</option>
|
||||||
|
<?php foreach ( SP()->formats->event as $key => $format ): ?>
|
||||||
|
<option value="<?php echo $key; ?>"><?php echo $format; ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
<div class="sp-date-selector">
|
<div class="sp-date-selector">
|
||||||
<p><?php _e( 'Date:', 'sportspress' ); ?>
|
<p><?php _e( 'Date:', 'sportspress' ); ?>
|
||||||
<?php
|
<?php
|
||||||
@@ -1121,6 +1145,7 @@ class SP_AJAX {
|
|||||||
args.season = $div.find('[name=season]').val();
|
args.season = $div.find('[name=season]').val();
|
||||||
args.venue = $div.find('[name=venue]').val();
|
args.venue = $div.find('[name=venue]').val();
|
||||||
args.status = $div.find('[name=status]').val();
|
args.status = $div.find('[name=status]').val();
|
||||||
|
args.format = $div.find('[name=format]').val();
|
||||||
args.date = $div.find('[name=date]').val();
|
args.date = $div.find('[name=date]').val();
|
||||||
args.date_from = $div.find('[name=date_from]').val();
|
args.date_from = $div.find('[name=date_from]').val();
|
||||||
args.date_to = $div.find('[name=date_to]').val();
|
args.date_to = $div.find('[name=date_to]').val();
|
||||||
@@ -1140,6 +1165,7 @@ class SP_AJAX {
|
|||||||
args.season = $div.find('[name=season]').val();
|
args.season = $div.find('[name=season]').val();
|
||||||
args.venue = $div.find('[name=venue]').val();
|
args.venue = $div.find('[name=venue]').val();
|
||||||
args.status = $div.find('[name=status]').val();
|
args.status = $div.find('[name=status]').val();
|
||||||
|
args.format = $div.find('[name=format]').val();
|
||||||
args.date = $div.find('[name=date]').val();
|
args.date = $div.find('[name=date]').val();
|
||||||
args.date_from = $div.find('[name=date_from]').val();
|
args.date_from = $div.find('[name=date_from]').val();
|
||||||
args.date_to = $div.find('[name=date_to]').val();
|
args.date_to = $div.find('[name=date_to]').val();
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ class SP_Calendar extends SP_Secondary_Post {
|
|||||||
/** @var int The event ID. */
|
/** @var int The event ID. */
|
||||||
public $event;
|
public $event;
|
||||||
|
|
||||||
|
/** @var integer The event format slug. */
|
||||||
|
public $event_format;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* __construct function.
|
* __construct function.
|
||||||
*
|
*
|
||||||
@@ -103,6 +106,9 @@ class SP_Calendar extends SP_Secondary_Post {
|
|||||||
if ( ! $this->day )
|
if ( ! $this->day )
|
||||||
$this->day = get_post_meta( $this->ID, 'sp_day', true );
|
$this->day = get_post_meta( $this->ID, 'sp_day', true );
|
||||||
|
|
||||||
|
if ( ! $this->event_format )
|
||||||
|
$this->event_format = get_post_meta( $this->ID, 'sp_event_format', true );
|
||||||
|
|
||||||
if ( ! $this->number )
|
if ( ! $this->number )
|
||||||
$this->number = -1;
|
$this->number = -1;
|
||||||
}
|
}
|
||||||
@@ -205,6 +211,13 @@ class SP_Calendar extends SP_Secondary_Post {
|
|||||||
);
|
);
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
if ( $this->event_format && 'all' != $this->event_format ):
|
||||||
|
$args['meta_query'][] = array(
|
||||||
|
'key' => 'sp_format',
|
||||||
|
'value' => $this->event_format,
|
||||||
|
);
|
||||||
|
endif;
|
||||||
|
|
||||||
if ( $this->day ):
|
if ( $this->day ):
|
||||||
$args['meta_query'][] = array(
|
$args['meta_query'][] = array(
|
||||||
'key' => 'sp_day',
|
'key' => 'sp_day',
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ $defaults = array(
|
|||||||
'event' => null,
|
'event' => null,
|
||||||
'title' => false,
|
'title' => false,
|
||||||
'status' => 'default',
|
'status' => 'default',
|
||||||
|
'format' => 'all',
|
||||||
'date' => 'default',
|
'date' => 'default',
|
||||||
'date_from' => 'default',
|
'date_from' => 'default',
|
||||||
'date_to' => 'default',
|
'date_to' => 'default',
|
||||||
@@ -48,6 +49,8 @@ extract( $defaults, EXTR_SKIP );
|
|||||||
$calendar = new SP_Calendar( $id );
|
$calendar = new SP_Calendar( $id );
|
||||||
if ( $status != 'default' )
|
if ( $status != 'default' )
|
||||||
$calendar->status = $status;
|
$calendar->status = $status;
|
||||||
|
if ( $format != 'all' )
|
||||||
|
$calendar->event_format = $format;
|
||||||
if ( $date != 'default' )
|
if ( $date != 'default' )
|
||||||
$calendar->date = $date;
|
$calendar->date = $date;
|
||||||
if ( $date_from != 'default' )
|
if ( $date_from != 'default' )
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ $defaults = array(
|
|||||||
'id' => null,
|
'id' => null,
|
||||||
'title' => false,
|
'title' => false,
|
||||||
'status' => 'default',
|
'status' => 'default',
|
||||||
|
'format' => 'all',
|
||||||
'date' => 'default',
|
'date' => 'default',
|
||||||
'date_from' => 'default',
|
'date_from' => 'default',
|
||||||
'date_to' => 'default',
|
'date_to' => 'default',
|
||||||
@@ -48,6 +49,8 @@ extract( $defaults, EXTR_SKIP );
|
|||||||
$calendar = new SP_Calendar( $id );
|
$calendar = new SP_Calendar( $id );
|
||||||
if ( $status != 'default' )
|
if ( $status != 'default' )
|
||||||
$calendar->status = $status;
|
$calendar->status = $status;
|
||||||
|
if ( $format != 'all' )
|
||||||
|
$calendar->event_format = $format;
|
||||||
if ( $date != 'default' )
|
if ( $date != 'default' )
|
||||||
$calendar->date = $date;
|
$calendar->date = $date;
|
||||||
if ( $date_from != 'default' )
|
if ( $date_from != 'default' )
|
||||||
|
|||||||
Reference in New Issue
Block a user