Merge pull request #304 from ThemeBoy/feature-flexible-player-list-shortcode
Make the Player List shortcode more flexible (selection of Season, Le…
This commit is contained in:
@@ -1071,6 +1071,48 @@ 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( 'League:', '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>
|
<p>
|
||||||
<label>
|
<label>
|
||||||
<?php _e( 'Number of players to show:', 'sportspress' ); ?>
|
<?php _e( 'Number of players to show:', 'sportspress' ); ?>
|
||||||
@@ -1315,6 +1357,9 @@ class SP_AJAX {
|
|||||||
} else if ( 'player_list' == type ) {
|
} else if ( 'player_list' == type ) {
|
||||||
args.title = $div.find('[name=title]').val();
|
args.title = $div.find('[name=title]').val();
|
||||||
args.number = $div.find('[name=number]').val();
|
args.number = $div.find('[name=number]').val();
|
||||||
|
args.team = $div.find('[name=team]').val();
|
||||||
|
args.seasons = $div.find('[name=season]').val();
|
||||||
|
args.leagues = $div.find('[name=league]').val();
|
||||||
args.columns = $div.find('[name="columns[]"]:checked').map(function() { return this.value; }).get().join(',');
|
args.columns = $div.find('[name="columns[]"]:checked').map(function() { return this.value; }).get().join(',');
|
||||||
args.orderby = $div.find('[name=orderby]').val();
|
args.orderby = $div.find('[name=orderby]').val();
|
||||||
args.order = $div.find('[name=order]').val();
|
args.order = $div.find('[name=order]').val();
|
||||||
|
|||||||
@@ -35,11 +35,23 @@ class SP_Player_List extends SP_Secondary_Post {
|
|||||||
* @param bool $admin
|
* @param bool $admin
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function data( $admin = false ) {
|
public function data( $admin = false, $leagues = null, $seasons = null, $team_id = null ) {
|
||||||
|
if ( !is_null( $leagues ) && '0' != $leagues ) {
|
||||||
|
$league_ids = explode( ",", $leagues );
|
||||||
|
}else{
|
||||||
$league_ids = sp_get_the_term_ids( $this->ID, 'sp_league' );
|
$league_ids = sp_get_the_term_ids( $this->ID, 'sp_league' );
|
||||||
|
}
|
||||||
|
if ( !is_null( $seasons ) && '0' != $seasons ) {
|
||||||
|
$season_ids = explode( ",", $seasons );
|
||||||
|
}else{
|
||||||
$season_ids = sp_get_the_term_ids( $this->ID, 'sp_season' );
|
$season_ids = sp_get_the_term_ids( $this->ID, 'sp_season' );
|
||||||
|
}
|
||||||
$position_ids = sp_get_the_term_ids( $this->ID, 'sp_position' );
|
$position_ids = sp_get_the_term_ids( $this->ID, 'sp_position' );
|
||||||
|
if ( !is_null( $team_id ) && '0' != $team_id ) {
|
||||||
|
$team = $team_id;
|
||||||
|
}else{
|
||||||
$team = get_post_meta( $this->ID, 'sp_team', true );
|
$team = get_post_meta( $this->ID, 'sp_team', true );
|
||||||
|
}
|
||||||
$era = get_post_meta( $this->ID, 'sp_era', true );
|
$era = get_post_meta( $this->ID, 'sp_era', true );
|
||||||
$list_stats = (array)get_post_meta( $this->ID, 'sp_players', true );
|
$list_stats = (array)get_post_meta( $this->ID, 'sp_players', true );
|
||||||
$adjustments = get_post_meta( $this->ID, 'sp_adjustments', true );
|
$adjustments = get_post_meta( $this->ID, 'sp_adjustments', true );
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ $defaults = array(
|
|||||||
'scrollable' => get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false,
|
'scrollable' => get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false,
|
||||||
'paginated' => get_option( 'sportspress_list_paginated', 'yes' ) == 'yes' ? true : false,
|
'paginated' => get_option( 'sportspress_list_paginated', 'yes' ) == 'yes' ? true : false,
|
||||||
'rows' => get_option( 'sportspress_list_rows', 10 ),
|
'rows' => get_option( 'sportspress_list_rows', 10 ),
|
||||||
|
'leagues' => null,
|
||||||
|
'seasons' => null,
|
||||||
|
'team' => null,
|
||||||
);
|
);
|
||||||
|
|
||||||
extract( $defaults, EXTR_SKIP );
|
extract( $defaults, EXTR_SKIP );
|
||||||
@@ -51,7 +54,7 @@ $list = new SP_Player_List( $id );
|
|||||||
if ( isset( $columns ) && null !== $columns ):
|
if ( isset( $columns ) && null !== $columns ):
|
||||||
$list->columns = $columns;
|
$list->columns = $columns;
|
||||||
endif;
|
endif;
|
||||||
$data = $list->data();
|
$data = $list->data( false, $leagues, $seasons, $team );
|
||||||
|
|
||||||
// The first row should be labels
|
// The first row should be labels
|
||||||
$labels = $data[0];
|
$labels = $data[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user