Skip to content

Instantly share code, notes, and snippets.

@JMWebDevelopment
Created June 14, 2017 15:46
Show Gist options
  • Save JMWebDevelopment/cbd2ac3fa25437feb70c9553c99bde14 to your computer and use it in GitHub Desktop.
Save JMWebDevelopment/cbd2ac3fa25437feb70c9553c99bde14 to your computer and use it in GitHub Desktop.
For more information, go to: https://sportsbenchwp.com
<?php
/**
* Template Name: Player
*/
if ( get_query_var( 'player_slug' ) ) {
$player = new Sports_Bench_Player(get_query_var('player_slug'));
$team = new Sports_Bench_Team((int)$player->team_id);
}
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 ( class_exists( 'Sports_Bench_Player' ) ) { ?>
<?php if ( get_query_var( 'player_slug' ) ) { ?>
<div class="player-info-top clearfix">
<div class="player-photo" style="width: 23%; padding: 0 1%; float: left; position: relative">
<?php $photo = $player->get_player_photo(); ?>
<?php if ( $photo == null ) { ?>
<img src="<?php echo plugins_url( 'sports-bench/images/mystery-person.jpg' ); ?>" />
<?php } else { ?>
<?php echo $photo; ?>
<?php } ?>
</div>
<div class="player-info" style="width: 73%; padding: 0 1%; float: right; position: relative">
<h2 class="player-name" style="margin-bottom:5px"><?php echo $player->player_first_name . ' ' . $player->player_last_name; ?></h2>
<h4 class="player-details" style="margin-bottom:5px; margin-top: 0;"><?php echo $player->player_position; ?></h4>
<h4 class="player-details" style="margin-bottom:5px; margin-top: 0;"><?php echo $team->team_name; ?></h4>
<h4 class="player-details" style="margin-bottom:5px; margin-top: 0;"><?php echo $player->player_home_city . ', ' . $player->player_home_state; ?></h4>
<h4 class="player-details" style="margin-bottom:5px; margin-top: 0;"><?php echo __( 'Age: ', 'sports-bench' ) . $player->get_age(); ?></h4>
<h4 class="player-details" style="margin-bottom:5px; margin-top: 0;"><?php echo stripslashes( $player->player_height ) . ' | ' . $player->player_weight; ?></h4>
<div id="sports-bench-player-id" class="hide" style="display: none;"><?php echo $player->player_id; ?></div>
</div>
</div>
<div class="player-info-bottom clearfix">
<h4>Career Stats</h4>
<?php echo sports_bench_get_season_stats( $player ); ?>
</div>
<?php } else { ?>
<div id="team-select" class="row">
<select name="player-page-select" id="player-page-select">
<option value=""><?php _e( '--- Select a Team ---', 'sports-bench' ); ?></option>
<option value="0"><?php _e( 'Free Agent', 'sports-bench' ); ?></option>
<?php
$teams = sports_bench_get_teams( true );
foreach ( $teams as $team_id => $team_name ) {
echo '<option value="' . $team_id . '">' . $team_name . '</option>';
}
?>
</select>
</div>
<div id="team-players" class="row"></div>
<?php } ?>
<?php } ?>
</div>
</article>
<?php endwhile;
?>
</main><!-- .site-main -->
<?php get_sidebar( 'content-bottom' ); ?>
</div><!-- .content-area -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment