Add separate career totals option and group statistic settings

This commit is contained in:
Brian Miyaji
2017-01-15 10:25:57 +11:00
parent 151ad04fca
commit efa1895da7
4 changed files with 57 additions and 24 deletions

View File

@@ -23,6 +23,7 @@ class SP_Meta_Box_Player_Statistics {
$leagues = get_the_terms( $post->ID, 'sp_league' ); $leagues = get_the_terms( $post->ID, 'sp_league' );
$league_num = sizeof( $leagues ); $league_num = sizeof( $leagues );
$sections = get_option( 'sportspress_player_performance_sections', -1 ); $sections = get_option( 'sportspress_player_performance_sections', -1 );
$show_career_totals = 'yes' === get_option( 'sportspress_player_show_career_total', 'no' ) ? true : false;
if ( $leagues ) { if ( $leagues ) {
if ( -1 == $sections ) { if ( -1 == $sections ) {
@@ -36,11 +37,13 @@ class SP_Meta_Box_Player_Statistics {
self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes && $i == 0, true, $formats ); self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes && $i == 0, true, $formats );
$i ++; $i ++;
endforeach; endforeach;
if ( $show_career_totals ) {
?> ?>
<p><strong><?php _e( 'Career Total', 'sportspress' ); ?></strong></p> <p><strong><?php _e( 'Career Total', 'sportspress' ); ?></strong></p>
<?php <?php
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = $player->data( 0, true ); list( $columns, $data, $placeholders, $merged, $seasons_teams ) = $player->data( 0, true );
self::table( $post->ID, 0, $columns, $data, $placeholders, $merged, $seasons_teams ); self::table( $post->ID, 0, $columns, $data, $placeholders, $merged, $seasons_teams );
}
} else { } else {
// Determine order of sections // Determine order of sections
if ( 1 == $sections ) { if ( 1 == $sections ) {
@@ -61,11 +64,13 @@ class SP_Meta_Box_Player_Statistics {
self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes && $i == 0 && $s == 0, $s == 0 ); self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes && $i == 0 && $s == 0, $s == 0 );
$i ++; $i ++;
endforeach; endforeach;
if ( $show_career_totals ) {
?> ?>
<p><strong><?php _e( 'Career Total', 'sportspress' ); ?> &mdash; <?php echo $section_label; ?></strong></p> <p><strong><?php _e( 'Career Total', 'sportspress' ); ?> &mdash; <?php echo $section_label; ?></strong></p>
<?php <?php
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = $player->data( 0, true, $section_id ); list( $columns, $data, $placeholders, $merged, $seasons_teams ) = $player->data( 0, true, $section_id );
self::table( $post->ID, 0, $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes && $i == 0 && $s == 0, $s == 0 ); self::table( $post->ID, 0, $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes && $i == 0 && $s == 0, $s == 0 );
}
$s ++; $s ++;
} }
} }

View File

@@ -122,6 +122,22 @@ class SP_Settings_Players extends SP_Settings_Page {
'checkboxgroup' => 'end', 'checkboxgroup' => 'end',
), ),
array(
'title' => __( 'Nationality', 'sportspress' ),
'desc' => __( 'Display national flags', 'sportspress' ),
'id' => 'sportspress_player_show_flags',
'default' => 'yes',
'type' => 'checkbox',
),
) ),
array(
array( 'type' => 'sectionend', 'id' => 'player_options' ),
),
array(
array( 'title' => __( 'Statistics', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'player_statistic_options' ),
array( array(
'title' => __( 'Columns', 'sportspress' ), 'title' => __( 'Columns', 'sportspress' ),
'id' => 'sportspress_player_columns', 'id' => 'sportspress_player_columns',
@@ -134,7 +150,7 @@ class SP_Settings_Players extends SP_Settings_Page {
), ),
array( array(
'title' => __( 'Statistics', 'sportspress' ), 'title' => __( 'Categories', 'sportspress' ),
'id' => 'sportspress_player_performance_sections', 'id' => 'sportspress_player_performance_sections',
'default' => -1, 'default' => -1,
'type' => 'radio', 'type' => 'radio',
@@ -146,24 +162,28 @@ class SP_Settings_Players extends SP_Settings_Page {
), ),
array( array(
'title' => __( 'Total', 'sportspress' ), 'title' => __( 'Display', 'sportspress' ),
'desc' => __( 'Display total', 'sportspress' ), 'desc' => __( 'Total', 'sportspress' ),
'id' => 'sportspress_player_show_total', 'id' => 'sportspress_player_show_total',
'default' => 'no', 'default' => 'no',
'type' => 'checkbox', 'type' => 'checkbox',
'checkboxgroup' => 'start',
), ),
array( array(
'title' => __( 'Nationality', 'sportspress' ), 'desc' => __( 'Career Total', 'sportspress' ),
'desc' => __( 'Display national flags', 'sportspress' ), 'id' => 'sportspress_player_show_career_total',
'id' => 'sportspress_player_show_flags', 'default' => 'no',
'default' => 'yes',
'type' => 'checkbox', 'type' => 'checkbox',
'checkboxgroup' => 'end',
), ),
),
apply_filters( 'sportspress_player_statistic_options', array(
) ), ) ),
array( array(
array( 'type' => 'sectionend', 'id' => 'player_options' ), array( 'type' => 'sectionend', 'id' => 'player_statistic_options' ),
) )
); );

View File

@@ -429,6 +429,11 @@ class SP_Install {
update_option( 'sportspress_event_show_timeline', 'no' ); update_option( 'sportspress_event_show_timeline', 'no' );
update_option( 'sportspress_event_logos_show_team_names', 'no' ); update_option( 'sportspress_event_logos_show_team_names', 'no' );
} }
if ( version_compare( $version, '2.2.3', '<' ) ) {
$option = get_option( 'sportspress_player_show_total', 'no' );
update_option( 'sportspress_player_show_career_total', $option );
}
} }
/** /**

View File

@@ -16,6 +16,7 @@ if ( ! isset( $id ) )
$player = new SP_Player( $id ); $player = new SP_Player( $id );
$scrollable = get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false; $scrollable = get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false;
$show_career_totals = 'yes' === get_option( 'sportspress_player_show_career_total', 'no' ) ? true : false;
$sections = get_option( 'sportspress_player_performance_sections', -1 ); $sections = get_option( 'sportspress_player_performance_sections', -1 );
$show_teams = apply_filters( 'sportspress_player_team_statistics', true ); $show_teams = apply_filters( 'sportspress_player_team_statistics', true );
$leagues = get_the_terms( $id, 'sp_league' ); $leagues = get_the_terms( $id, 'sp_league' );
@@ -65,6 +66,7 @@ if ( is_array( $leagues ) ):
sp_get_template( 'player-statistics-league.php', $args ); sp_get_template( 'player-statistics-league.php', $args );
endforeach; endforeach;
if ( $show_career_totals ) {
sp_get_template( 'player-statistics-league.php', array( sp_get_template( 'player-statistics-league.php', array(
'data' => $player->data( 0, false, $section_id ), 'data' => $player->data( 0, false, $section_id ),
'caption' => __( 'Career Total', 'sportspress' ), 'caption' => __( 'Career Total', 'sportspress' ),
@@ -72,4 +74,5 @@ if ( is_array( $leagues ) ):
'hide_teams' => true, 'hide_teams' => true,
) ); ) );
} }
}
endif; endif;