Skip to content

Instantly share code, notes, and snippets.

View ViewFromTheBox's full-sized avatar

Jacob Martella ViewFromTheBox

View GitHub Profile
<?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; ?>">
<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 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>
<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';
<?php
/**
* Template Name: Team
*/
if ( get_query_var( 'team_slug' ) ) {
$team = new Sports_Bench_Team( get_query_var( 'team_slug' ) );
}
get_header(); ?>
public function get_goals( $season = false ) {
if ( $season == false ) {
$where = '';
} else {
$where = ' AND game_season = "' . $season . '" ';
}
global $wpdb;
$player_table = $wpdb->prefix . 'sb_players';
public function get_stats( $season = false ) {
$stats = array(
'goals' => $this->get_goals( $season ),
'assists' => $this->get_assists( $season ),
'shots_on_goal' => $this->get_sog( $season ),
'fouls' => $this->get_gouls( $season ),
);
return $stats;
}
public function get_red_cards( $team = 'home' ) {
$game_id = $this->game_id;
global $wpdb;
$table = $wpdb->prefix . 'sb_games';
$querystr = "SELECT * FROM $table WHERE game_id = $game_id";
$game_info = $wpdb->get_results( $querystr );
if ( $team == 'away' ) {
return $game_info[0]->game_away_red;
} else {
public function get_team_stats() {
$game_id = $this->game_id;
global $wpdb;
$table = $wpdb->prefix . 'sb_games';
$querystr = "SELECT * FROM $table WHERE game_id = $game_id";
$game_info = $wpdb->get_results( $querystr );
$home_stats = array (
'shots' => $this->get_shots( 'home' ),
'sog' => $this->get_sog( 'home' ),
add_action( 'rest_api_init', 'theme_slug_extend_rest_post_response' );
function theme_slug_extend_rest_post_response() {
register_rest_field( 'post',
'comments',
array(
'get_callback' => 'theme_slug_get_comments',
'update_callback' => null,
'schema' => null,
) );
}