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' );
$league_num = sizeof( $leagues );
$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 ( -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 );
$i ++;
endforeach;
?>
<p><strong><?php _e( 'Career Total', 'sportspress' ); ?></strong></p>
<?php
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = $player->data( 0, true );
self::table( $post->ID, 0, $columns, $data, $placeholders, $merged, $seasons_teams );
if ( $show_career_totals ) {
?>
<p><strong><?php _e( 'Career Total', 'sportspress' ); ?></strong></p>
<?php
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = $player->data( 0, true );
self::table( $post->ID, 0, $columns, $data, $placeholders, $merged, $seasons_teams );
}
} else {
// Determine order of 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 );
$i ++;
endforeach;
?>
<p><strong><?php _e( 'Career Total', 'sportspress' ); ?> &mdash; <?php echo $section_label; ?></strong></p>
<?php
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 );
if ( $show_career_totals ) {
?>
<p><strong><?php _e( 'Career Total', 'sportspress' ); ?> &mdash; <?php echo $section_label; ?></strong></p>
<?php
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 );
}
$s ++;
}
}

View File

@@ -122,6 +122,22 @@ class SP_Settings_Players extends SP_Settings_Page {
'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(
'title' => __( 'Columns', 'sportspress' ),
'id' => 'sportspress_player_columns',
@@ -134,7 +150,7 @@ class SP_Settings_Players extends SP_Settings_Page {
),
array(
'title' => __( 'Statistics', 'sportspress' ),
'title' => __( 'Categories', 'sportspress' ),
'id' => 'sportspress_player_performance_sections',
'default' => -1,
'type' => 'radio',
@@ -146,24 +162,28 @@ class SP_Settings_Players extends SP_Settings_Page {
),
array(
'title' => __( 'Total', 'sportspress' ),
'desc' => __( 'Display total', 'sportspress' ),
'title' => __( 'Display', 'sportspress' ),
'desc' => __( 'Total', 'sportspress' ),
'id' => 'sportspress_player_show_total',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'title' => __( 'Nationality', 'sportspress' ),
'desc' => __( 'Display national flags', 'sportspress' ),
'id' => 'sportspress_player_show_flags',
'default' => 'yes',
'desc' => __( 'Career Total', 'sportspress' ),
'id' => 'sportspress_player_show_career_total',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
),
apply_filters( 'sportspress_player_statistic_options', 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_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 );
$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 );
$show_teams = apply_filters( 'sportspress_player_team_statistics', true );
$leagues = get_the_terms( $id, 'sp_league' );
@@ -65,11 +66,13 @@ if ( is_array( $leagues ) ):
sp_get_template( 'player-statistics-league.php', $args );
endforeach;
sp_get_template( 'player-statistics-league.php', array(
'data' => $player->data( 0, false, $section_id ),
'caption' => __( 'Career Total', 'sportspress' ),
'scrollable' => $scrollable,
'hide_teams' => true,
) );
if ( $show_career_totals ) {
sp_get_template( 'player-statistics-league.php', array(
'data' => $player->data( 0, false, $section_id ),
'caption' => __( 'Career Total', 'sportspress' ),
'scrollable' => $scrollable,
'hide_teams' => true,
) );
}
}
endif;