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