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; if ( sizeof( $leagues ) > 1 ) { printf( '

%s

', $section_label ); } foreach ( $leagues as $league ): $caption = $league->name; if ( null !== $section_label ) { if ( sizeof( $leagues ) === 1 ) { $caption = $section_label; } } sp_get_template( 'player-statistics-league.php', array( 'data' => $player->data( $league->term_id, false, $section_id ), 'league' => $league, 'caption' => $caption, 'scrollable' => $scrollable, ) ); endforeach; } endif;