Created
April 23, 2018 23:52
-
-
Save JMWebDevelopment/3b04bd02f3e348fcd8f520fde2acc168 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sports_bench_theme_scoreboard_game( $html, $game, $count, $num_games ) { | |
$theme = wp_get_theme(); | |
$parent_theme = $theme->get( 'Template' ); | |
$game_id = $game->game_id; | |
$away_team = new Sports_Bench_Team( (int) $game->game_away_id ); | |
$home_team = new Sports_Bench_Team( (int) $game->game_home_id ); | |
$status = $game->game_status; | |
$date = date_create( $game->game_day ); | |
if ( sports_bench_is_game_time_set( $date ) === true ) { | |
$datetime = date_format( $date, 'g:i a, F j' ); | |
} else { | |
$datetime = date_format( $date, 'F j' ); | |
} | |
if ( $status == 'in_progress' ) { | |
$away_score = $game->game_current_away_score; | |
$home_score = $game->game_current_home_score; | |
if ( $game->game_current_period != null | |
and $game->game_current_time != null | |
) { | |
$sep = ' | '; | |
} else { | |
$sep = ''; | |
} | |
$period = $game->game_current_period; | |
$time = stripslashes( $game->game_current_time ); | |
$time_in_game = $time . $sep . $period; | |
} elseif ( $status == 'final' ) { | |
$away_score = $game->game_away_final; | |
$home_score = $game->game_home_final; | |
$time_in_game = __( 'Final', 'sports-bench' ); | |
$time = ''; | |
$period = ''; | |
} else { | |
$away_score = ''; | |
$home_score = ''; | |
$time_in_game = __( 'Pregame', 'sports-bench' ); | |
$time = ''; | |
$period = ''; | |
} | |
$id = 'game-' . $game_id; | |
if ( 0 == $count ) { | |
$html .= '<div class="sports-bench-scoreboard masonry-css">'; | |
} | |
$html .= apply_filters( 'sports_bench_before_scoreboard_game', '', $game_id, $away_team, $home_team ); | |
$html .= '<div id="' . $id . '" class="scoreboard-page-game masonry-css-item">'; | |
$html .= '<div class="top-border-div clearfix">'; | |
$html .= '<div class="away-team-border" style="background-color: ' . $away_team->team_primary_color . '">'; | |
$html .= '</div>'; | |
$html .= '<div class="home-team-border" style="background-color: ' . $home_team->team_primary_color . '">'; | |
$html .= '</div>'; | |
$html .= '</div>'; | |
$html .= '<table class="scoreboard-table">'; | |
$html .= '<tr class="date-row">'; | |
$html .= '<td colspan="3">' . $datetime .'</td>'; | |
$html .= '</tr>'; | |
$away_row_style = apply_filters( 'sports_bench_scoreboard_row_styles', '', $away_team, 'scoreboard' ); | |
$html .= '<tr class="team" style="' . $away_row_style . '">'; | |
$html .= '<td class="logo">' . $away_team->get_team_photo( 'team-logo' ) . '</td>'; | |
$html .= '<td><a href="' . $away_team->get_permalink() . '">' . $away_team->team_location . '</a></td>'; | |
$html .= '<td id="away-score" class="right">' . $away_score . '</td>'; | |
$html .= '</tr>'; | |
$home_row_style = apply_filters( 'sports_bench_scoreboard_row_styles', '', $home_team, 'scoreboard' ); | |
$html .= '<tr class="team" style="' . $home_row_style . '">'; | |
$html .= '<td class="logo">' . $home_team->get_team_photo( 'team-logo' ) . '</td>'; | |
$html .= '<td><a href="' . $home_team->get_permalink() . '">' . $home_team->team_location . '</a></td>'; | |
$html .= '<td id="home-score" class="right">' . $home_score . '</td>'; | |
$html .= '</tr>'; | |
$html .= '<tr class="time-row">'; | |
$html .= '<td colspan="3" id="time" class="right">' . $time_in_game . '</td>'; | |
$html .= '</tr>'; | |
$html .= '<tr class="preview-recap-row">'; | |
$html .= '<td colspan="3">'; | |
if ( $game->game_preview != null && ( $game->game_status == 'scheduled' || $game->game_status == 'in_progress' ) ) { | |
$html .= '<h4 class="preview-recap-link preview"><a href="' . $game->game_preview . '">' . __( 'PREVIEW', 'sports-bench' ) . '</a></h4>'; | |
} | |
if ( $game->game_status == 'in_progress' && ( $theme->name != 'Sports Bench' || ( $parent_theme && $parent_theme->name != 'Sports Bench' ) ) ) { | |
$html .= '<h4 class="preview-recap-link live"><a data-open="game-modal-' . $id . '">' . __( 'LIVE', 'sports-bench' ) . '</a></h4>'; | |
} | |
if ( $game->game_recap != null && $game->game_status == 'final' ) { | |
$html .= '<h4 class="preview-recap-link preview"><a href="' . $game->game_preview . '">' . __( 'PREVIEW', 'sports-bench' ) . '</a></h4>'; | |
$html .= '<h4 class="preview-recap-link recap"><a href="' . $game->game_recap . '">' . __( 'RECAP', 'sports-bench' ) . '</a></h4>'; | |
} | |
$html .= '</td>'; | |
$html .= '</tr>'; | |
$html .= '</table>'; | |
$html .= '</div>'; | |
$html .= apply_filters( 'sports_bench_scoreboard_modal', '', $game, $away_team, $home_team, $status, $time, $period ); | |
$html .= apply_filters( 'sports_bench_after_scoreboard_game', '', $game_id, $away_team, $home_team ); | |
if ( $num_games - 1 == $count ) { | |
$html .= '</div>'; | |
} | |
return $html; | |
} | |
remove_filter( 'sports_bench_scoreboard_game', 'sports_bench_do_scoreboard_game' ); | |
add_filter( 'sports_bench_scoreboard_game', 'sports_bench_theme_scoreboard_game', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment