Instantly share code, notes, and snippets.

Embed
What would you like to do?
For more information, go to: https://sportsbenchwp.com
<?php
/**
* Template Name: Team
*/
if ( get_query_var( 'team_slug' ) ) {
$team = new Sports_Bench_Team( get_query_var( 'team_slug' ) );
}
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<?php if ( function_exists( 'sports_bench_get_teams' ) ) { ?>
<?php if ( isset( $team ) ) { ?>
<div class="team-photo">
<?php echo $team->get_team_photo( 'team-photo' ); ?>
</div>
<div class="team-name row">
<div class="large-2 medium-2 small-2 columns">
<?php echo $team->get_team_photo( 'team-logo' ); ?>
</div>
<div class="large-10 medium-10 small-10 columns">
<h1 class="team-title" style="color:<?php echo $team->team_primary_color; ?>"><?php echo $team->team_name ?></h1>
</div>
</div>
<div id="team-stats" class="widget" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
<h4 class="widgettitle"><?php echo get_option( 'sports-bench-season-year' ) . ' ' . __( 'Stats', 'sports-bench' ); ?></h4>
<?php echo sports_bench_get_players_stats_table( sports_bench_get_players_stats( $team->team_id, '"' . get_option( 'sports-bench-season-year' ) . '"' ) ); ?>
</div>
<div id="team-roster" class="widget" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
<h4 class="widgettitle"><?php _e( 'Roster', 'sports-bench' ); ?></h4>
<?php echo sports_bench_show_roster( $team->team_id ); ?>
</div>
<?php } else { ?>
<?php
$teams = sports_bench_get_teams( true ); $num_teams = count( $teams ); $count = 0;
foreach( $teams as $team_id => $team_name ) {
$current_team = new Sports_Bench_Team( (int)$team_id );
if ( $count % 2 == 0 ) { ?>
<div class="row">
<?php } ?>
<div class="large-6 medium-6 small-12 columns">
<a href="<?php echo $current_team->get_permalink(); ?>">
<div class="team-info clearfix" style="border-top: 2px solid <?php echo $current_team->team_primary_color; ?>">
<h4 class="team-name"><?php echo $team_name; ?></h4>
<div class="right">
<?php echo $current_team->get_team_photo( 'team-logo' ); ?>
</div>
<p>
<?php echo $current_team->get_division_name(); ?><br />
<?php _e( 'Location', 'sports-bench' ); ?>: <?php echo $current_team->team_city; ?>, <?php echo $current_team->team_state; ?><br />
<?php _e( 'Stadium', 'sports-bench' ); ?>: <?php echo $current_team->team_stadium; ?><br />
<?php _e( 'Head Coach', 'sports-bench' ); ?>': <?php echo $current_team->team_head_coach; ?><br />
</p>
</div>
</a>
</div>
<?php if ( ( $count % 2 == 1 ) or ( $count == $num_teams ) ) { ?>
</div>
<?php } ?>
<?php $count++;
}
?>
<?php } ?>
<?php } ?>
</div>
</article>
<?php endwhile;
?>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php if ( function_exists( 'sports_bench_get_teams' ) ) { ?>
<?php if ( isset( $team ) ) { ?>
<aside id="secondary" class="sidebar widget-area" role="complementary">
<aside id="schedule-info" class="widget" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
<h4 class="widgettitle"><?php echo $team->team_name . ' ' . get_theme_mod( 'sports-bench-season-year' ) . ' ' . __( 'Schedule', 'sports-bench' ); ?></h4>
<?php echo sports_bench_show_team_schedule( $team->team_id ); ?>
</aside>
<aside id="standings" class="widget" style="border-top: 2px solid <?php echo $team->team_secondary_color; ?>">
<?php global $wpdb;
$table = $wpdb->prefix . 'sb_divisions';
$querystr = "SELECT * FROM $table WHERE division_id = $team->team_division;";
$division = $wpdb->get_results($querystr);
$division_title = $division[ 0 ]->division_name . ' ' . __( 'Standings', 'sports-bench' ); ?>
<h4 class="widgettitle"><?php echo $division_title; ?></h4>
<?php echo sports_bench_team_division_standings( $team->team_division ); ?>
</aside>
<aside id="team-info" class="widget clearfix" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
<h4 class="widgettitle"><?php _e( 'Team Info', 'sports-bench' ); ?></h4>
<?php echo sports_bench_show_team_info( $team->team_id ); ?>
</aside>
</aside>
<?php } else { ?>
<?php get_sidebar(); ?>
<?php } ?>
<?php } ?>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment