Add league, season, venue, and team filter to calendar shortcodes
This commit is contained in:
@@ -201,6 +201,62 @@ class SP_AJAX {
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Team:', 'sportspress' ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'show_option_all' => __( 'Default', 'sportspress' ),
|
||||
'name' => 'team',
|
||||
'values' => 'ID',
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Competition:', 'sportspress' ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'show_option_all' => __( 'Default', 'sportspress' ),
|
||||
'name' => 'league',
|
||||
'values' => 'term_id',
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Season:', 'sportspress' ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'show_option_all' => __( 'Default', 'sportspress' ),
|
||||
'name' => 'season',
|
||||
'values' => 'term_id',
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Venue:', 'sportspress' ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_venue',
|
||||
'show_option_all' => __( 'Default', 'sportspress' ),
|
||||
'name' => 'venue',
|
||||
'values' => 'term_id',
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Status:', 'sportspress' ); ?>
|
||||
@@ -248,6 +304,7 @@ class SP_AJAX {
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_calendar',
|
||||
'show_option_all' => __( 'All', 'sportspress' ),
|
||||
'name' => 'id',
|
||||
'values' => 'ID',
|
||||
);
|
||||
@@ -255,6 +312,62 @@ class SP_AJAX {
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Team:', 'sportspress' ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'show_option_all' => __( 'Default', 'sportspress' ),
|
||||
'name' => 'team',
|
||||
'values' => 'ID',
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Competition:', 'sportspress' ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'show_option_all' => __( 'Default', 'sportspress' ),
|
||||
'name' => 'league',
|
||||
'values' => 'term_id',
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Season:', 'sportspress' ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'show_option_all' => __( 'Default', 'sportspress' ),
|
||||
'name' => 'season',
|
||||
'values' => 'term_id',
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Venue:', 'sportspress' ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_venue',
|
||||
'show_option_all' => __( 'Default', 'sportspress' ),
|
||||
'name' => 'venue',
|
||||
'values' => 'term_id',
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Status:', 'sportspress' ); ?>
|
||||
@@ -301,6 +414,8 @@ class SP_AJAX {
|
||||
'event' => __( 'Event', 'sportspress' ),
|
||||
'teams' => __( 'Teams', 'sportspress' ),
|
||||
'time' => __( 'Time', 'sportspress' ),
|
||||
'league' => __( 'Competition', 'sportspress' ),
|
||||
'season' => __( 'Season', 'sportspress' ),
|
||||
'venue' => __( 'Venue', 'sportspress' ),
|
||||
'article' => __( 'Article', 'sportspress' ),
|
||||
);
|
||||
@@ -346,6 +461,7 @@ class SP_AJAX {
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_calendar',
|
||||
'show_option_all' => __( 'All', 'sportspress' ),
|
||||
'name' => 'id',
|
||||
'values' => 'ID',
|
||||
);
|
||||
@@ -353,6 +469,62 @@ class SP_AJAX {
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Team:', 'sportspress' ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'show_option_all' => __( 'Default', 'sportspress' ),
|
||||
'name' => 'team',
|
||||
'values' => 'ID',
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Competition:', 'sportspress' ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'show_option_all' => __( 'Default', 'sportspress' ),
|
||||
'name' => 'league',
|
||||
'values' => 'term_id',
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Season:', 'sportspress' ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'show_option_all' => __( 'Default', 'sportspress' ),
|
||||
'name' => 'season',
|
||||
'values' => 'term_id',
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Venue:', 'sportspress' ); ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_venue',
|
||||
'show_option_all' => __( 'Default', 'sportspress' ),
|
||||
'name' => 'venue',
|
||||
'values' => 'term_id',
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<?php _e( 'Status:', 'sportspress' ); ?>
|
||||
@@ -735,10 +907,18 @@ class SP_AJAX {
|
||||
args.show_venue = $div.find('[name=show_venue]:checked').length;
|
||||
args.show_league = $div.find('[name=show_league]:checked').length;
|
||||
} else if ( 'event_calendar' == type ) {
|
||||
args.team = $div.find('[name=team]').val();
|
||||
args.league = $div.find('[name=league]').val();
|
||||
args.season = $div.find('[name=season]').val();
|
||||
args.venue = $div.find('[name=venue]').val();
|
||||
args.status = $div.find('[name=status]').val();
|
||||
args.show_all_events_link = $div.find('[name=show_all_events_link]:checked').length;
|
||||
} else if ( 'event_list' == type ) {
|
||||
args.title = $div.find('[name=title]').val();
|
||||
args.team = $div.find('[name=team]').val();
|
||||
args.league = $div.find('[name=league]').val();
|
||||
args.season = $div.find('[name=season]').val();
|
||||
args.venue = $div.find('[name=venue]').val();
|
||||
args.status = $div.find('[name=status]').val();
|
||||
args.date = $div.find('[name=date]').val();
|
||||
args.number = $div.find('[name=number]').val();
|
||||
@@ -747,6 +927,10 @@ class SP_AJAX {
|
||||
args.show_all_events_link = $div.find('[name=show_all_events_link]:checked').length;
|
||||
} else if ( 'event_blocks' == type ) {
|
||||
args.title = $div.find('[name=title]').val();
|
||||
args.team = $div.find('[name=team]').val();
|
||||
args.league = $div.find('[name=league]').val();
|
||||
args.season = $div.find('[name=season]').val();
|
||||
args.venue = $div.find('[name=venue]').val();
|
||||
args.status = $div.find('[name=status]').val();
|
||||
args.date = $div.find('[name=date]').val();
|
||||
args.number = $div.find('[name=number]').val();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* The SportsPress calendar class handles individual calendar data.
|
||||
*
|
||||
* @class SP_Calendar
|
||||
* @version 1.9
|
||||
* @version 2.0
|
||||
* @package SportsPress/Classes
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
@@ -34,6 +34,9 @@ class SP_Calendar extends SP_Custom_Post {
|
||||
/** @var int The season ID. */
|
||||
public $season;
|
||||
|
||||
/** @var int The venue ID. */
|
||||
public $venue;
|
||||
|
||||
/** @var int The team ID. */
|
||||
public $team;
|
||||
|
||||
@@ -120,6 +123,10 @@ class SP_Calendar extends SP_Custom_Post {
|
||||
$season_ids = array( $this->season );
|
||||
endif;
|
||||
|
||||
if ( $this->venue ):
|
||||
$venue_ids = array( $this->venue );
|
||||
endif;
|
||||
|
||||
if ( $this->team ):
|
||||
$args['meta_query'] = array(
|
||||
array(
|
||||
@@ -145,14 +152,6 @@ class SP_Calendar extends SP_Custom_Post {
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
if ( isset( $league_ids ) ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'id',
|
||||
'terms' => $league_ids
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! isset( $season_ids ) && $seasons ):
|
||||
$season_ids = array();
|
||||
foreach( $seasons as $season ):
|
||||
@@ -160,38 +159,49 @@ class SP_Calendar extends SP_Custom_Post {
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
if ( isset( $season_ids ) ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'field' => 'id',
|
||||
'terms' => $season_ids
|
||||
);
|
||||
}
|
||||
|
||||
if ( $venues ):
|
||||
if ( ! isset( $venue_ids ) && $venues ):
|
||||
$venue_ids = array();
|
||||
foreach( $venues as $venue ):
|
||||
$venue_ids[] = $venue->term_id;
|
||||
endforeach;
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_venue',
|
||||
'field' => 'id',
|
||||
'terms' => $venue_ids
|
||||
);
|
||||
endif;
|
||||
|
||||
if ( ! empty( $teams ) ):
|
||||
$args['meta_query'] = array(
|
||||
array(
|
||||
'key' => 'sp_team',
|
||||
'value' => $teams,
|
||||
'compare' => 'IN',
|
||||
),
|
||||
);
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
if ( isset( $league_ids ) ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'id',
|
||||
'terms' => $league_ids
|
||||
);
|
||||
}
|
||||
|
||||
if ( isset( $season_ids ) ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'field' => 'id',
|
||||
'terms' => $season_ids
|
||||
);
|
||||
}
|
||||
|
||||
if ( isset( $venue_ids ) ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_venue',
|
||||
'field' => 'id',
|
||||
'terms' => $venue_ids
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! empty( $teams ) ) {
|
||||
$args['meta_query'] = array(
|
||||
array(
|
||||
'key' => 'sp_team',
|
||||
'value' => $teams,
|
||||
'compare' => 'IN',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if ( 'auto' === $this->date ) {
|
||||
if ( 'any' === $this->status ) {
|
||||
$args['post_status'] = 'publish';
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 1.9.13
|
||||
* @version 2.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
@@ -18,6 +18,7 @@ $defaults = array(
|
||||
'date_to' => 'default',
|
||||
'league' => null,
|
||||
'season' => null,
|
||||
'venue' => null,
|
||||
'team' => null,
|
||||
'number' => -1,
|
||||
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
|
||||
@@ -48,6 +49,8 @@ if ( $league )
|
||||
$calendar->league = $league;
|
||||
if ( $season )
|
||||
$calendar->season = $season;
|
||||
if ( $venue )
|
||||
$calendar->venue = $venue;
|
||||
if ( $team )
|
||||
$calendar->team = $team;
|
||||
if ( $order != 'default' )
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 1.9
|
||||
* @version 2.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
@@ -19,6 +19,7 @@ $defaults = array(
|
||||
'date_to' => 'default',
|
||||
'league' => null,
|
||||
'season' => null,
|
||||
'venue' => null,
|
||||
'team' => null,
|
||||
'initial' => true,
|
||||
'caption_tag' => 'h4',
|
||||
@@ -40,6 +41,8 @@ if ( $league )
|
||||
$calendar->league = $league;
|
||||
if ( $season )
|
||||
$calendar->season = $season;
|
||||
if ( $venue )
|
||||
$calendar->venue = $venue;
|
||||
if ( $team )
|
||||
$calendar->team = $team;
|
||||
$events = $calendar->data();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 1.9.13
|
||||
* @version 2.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
@@ -18,6 +18,7 @@ $defaults = array(
|
||||
'date_to' => 'default',
|
||||
'league' => null,
|
||||
'season' => null,
|
||||
'venue' => null,
|
||||
'team' => null,
|
||||
'number' => -1,
|
||||
'show_team_logo' => get_option( 'sportspress_event_list_show_logos', 'no' ) == 'yes' ? true : false,
|
||||
@@ -50,6 +51,8 @@ if ( $league )
|
||||
$calendar->league = $league;
|
||||
if ( $season )
|
||||
$calendar->season = $season;
|
||||
if ( $venue )
|
||||
$calendar->venue = $venue;
|
||||
if ( $team )
|
||||
$calendar->team = $team;
|
||||
if ( $order != 'default' )
|
||||
|
||||
Reference in New Issue
Block a user