57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Player Statistics
|
|
*
|
|
* @author ThemeBoy
|
|
* @package SportsPress/Templates
|
|
* @version 1.7.4
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
if ( get_option( 'sportspress_player_show_statistics', 'yes' ) === 'no' ) return;
|
|
|
|
if ( ! isset( $id ) )
|
|
$id = get_the_ID();
|
|
|
|
$player = new SP_Player( $id );
|
|
|
|
$scrollable = get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false;
|
|
$sections = get_option( 'sportspress_player_performance_sections', -1 );
|
|
$leagues = get_the_terms( $id, 'sp_league' );
|
|
$positions = $player->positions();
|
|
$player_sections = array();
|
|
foreach ( $positions as $position ) {
|
|
$player_sections = array_merge( $player_sections, sp_get_term_sections( $position->term_id ) );
|
|
}
|
|
|
|
// Determine order of sections
|
|
if ( 1 == $sections ) {
|
|
$section_order = array( 1 => __( 'Defense', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ) );
|
|
} elseif ( 0 == $sections ) {
|
|
$section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) );
|
|
} else {
|
|
$section_order = array( -1 => null );
|
|
}
|
|
|
|
// Loop through statistics for each league
|
|
if ( is_array( $leagues ) ):
|
|
foreach ( $section_order as $section_id => $section_label ) {
|
|
if ( -1 !== $section_id && ! in_array( $section_id, $player_sections ) ) continue;
|
|
|
|
foreach ( $leagues as $league ):
|
|
if ( null !== $section_label ) {
|
|
printf( '<h3 class="sp-post-caption sp-player-statistics-section">%s</h3>', $section_label );
|
|
}
|
|
sp_get_template( 'player-statistics-league.php', array(
|
|
'data' => $player->data( $league->term_id, false, $section_id ),
|
|
'league' => $league,
|
|
'scrollable' => $scrollable,
|
|
) );
|
|
endforeach;
|
|
|
|
sp_get_template( 'player-statistics-total.php', array(
|
|
'data' => $player->data( 0, false, $section_id ),
|
|
'scrollable' => $scrollable,
|
|
) );
|
|
}
|
|
endif; |