Clean up spaces, tabs, indentation, and bracket formatting
This commit is contained in:
@@ -2,37 +2,42 @@
|
||||
/**
|
||||
* Player Statistics
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 2.6.1
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( 'no' === get_option( 'sportspress_player_show_statistics', 'yes' ) && 'no' === get_option( 'sportspress_player_show_total', 'no' ) ) return;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
if ( 'no' === get_option( 'sportspress_player_show_statistics', 'yes' ) && 'no' === get_option( 'sportspress_player_show_total', 'no' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! isset( $id ) )
|
||||
if ( ! isset( $id ) ) {
|
||||
$id = get_the_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 );
|
||||
$show_teams = apply_filters( 'sportspress_player_team_statistics', true );
|
||||
$leagues = array_filter( ( array ) get_the_terms( $id, 'sp_league' ) );
|
||||
$sections = get_option( 'sportspress_player_performance_sections', -1 );
|
||||
$show_teams = apply_filters( 'sportspress_player_team_statistics', true );
|
||||
$leagues = array_filter( (array) get_the_terms( $id, 'sp_league' ) );
|
||||
|
||||
// Sort Leagues by User Defined Order (PHP5.2 supported)
|
||||
foreach ( $leagues as $key => $league ) {
|
||||
$leagues[ $key ]->sp_order = get_term_meta ( $league->term_id , 'sp_order', true );
|
||||
$leagues[ $key ]->sp_order = get_term_meta( $league->term_id, 'sp_order', true );
|
||||
}
|
||||
if ( ! function_exists( 'sortByOrder' ) ) {
|
||||
function sortByOrder($a, $b) {
|
||||
if ( ! function_exists( 'sortByOrder' ) ) {
|
||||
function sortByOrder( $a, $b ) {
|
||||
return (int) $a->sp_order - (int) $b->sp_order;
|
||||
}
|
||||
}
|
||||
usort($leagues, 'sortByOrder');
|
||||
usort( $leagues, 'sortByOrder' );
|
||||
|
||||
$positions = $player->positions();
|
||||
$positions = $player->positions();
|
||||
$player_sections = array();
|
||||
if ( $positions ) {
|
||||
foreach ( $positions as $position ) {
|
||||
@@ -42,7 +47,10 @@ if ( $positions ) {
|
||||
|
||||
// Determine order of sections
|
||||
if ( 1 == $sections ) {
|
||||
$section_order = array( 1 => __( 'Defense', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ) );
|
||||
$section_order = array(
|
||||
1 => __( 'Defense', 'sportspress' ),
|
||||
0 => __( 'Offense', 'sportspress' ),
|
||||
);
|
||||
} elseif ( 0 == $sections ) {
|
||||
$section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) );
|
||||
} else {
|
||||
@@ -50,17 +58,19 @@ if ( 1 == $sections ) {
|
||||
}
|
||||
|
||||
// Loop through statistics for each league
|
||||
if ( is_array( $leagues ) ):
|
||||
if ( is_array( $leagues ) ) :
|
||||
foreach ( $section_order as $section_id => $section_label ) {
|
||||
if ( -1 !== $section_id && ! empty( $player_sections ) && ! in_array( $section_id, $player_sections ) ) continue;
|
||||
|
||||
if ( -1 !== $section_id && ! empty( $player_sections ) && ! in_array( $section_id, $player_sections ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( sizeof( $leagues ) > 1 ) {
|
||||
printf( '<h3 class="sp-post-caption sp-player-statistics-section">%s</h3>', $section_label );
|
||||
}
|
||||
|
||||
foreach ( $leagues as $league ):
|
||||
|
||||
foreach ( $leagues as $league ) :
|
||||
$caption = $league->name;
|
||||
|
||||
|
||||
if ( null !== $section_label ) {
|
||||
if ( sizeof( $leagues ) === 1 ) {
|
||||
$caption = $section_label;
|
||||
@@ -68,10 +78,10 @@ if ( is_array( $leagues ) ):
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'data' => $player->data( $league->term_id, false, $section_id ),
|
||||
'caption' => $caption,
|
||||
'data' => $player->data( $league->term_id, false, $section_id ),
|
||||
'caption' => $caption,
|
||||
'scrollable' => $scrollable,
|
||||
'league_id' => $league->term_id,
|
||||
'league_id' => $league->term_id,
|
||||
);
|
||||
if ( ! $show_teams ) {
|
||||
$args['hide_teams'] = true;
|
||||
@@ -80,12 +90,15 @@ if ( is_array( $leagues ) ):
|
||||
endforeach;
|
||||
|
||||
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,
|
||||
) );
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user