apply_filters( 'sports_bench_scoreboard_widget_game', $html, $game )

Type

Filters

Section

Scoreboard

Outputs the HTML for a game in the scoreboard widget

Parameters

  • $html, string, the current HTML for the game
  • $game, Sports_Bench_Game object, the game object for the current game

Returns

  • string, the HTML for the game in the scoreboard widget

Since: 1.5

Source: scoreboard.php, line 304

Example

/**
 * Prints out the default layout for a game in the scoreboard widget
 *
 * Customize this by running remove_action('sports_bench_scoreboard_widget_game', 'sports_bench_do_scoreboard_widget_game') and creating your own function to run in its place.
 *
 * @param $default string
 *
 * @param $game object
 *
 * @since 1.5
 */
function sports_bench_do_scoreboard_widget_game( $default, $game ) {

	$html = '';
	$theme = wp_get_theme();
	$parent_theme = $theme->parent();

	$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;
	if ( $status == 'in_progress' ) {
		$away_score = $game->game_current_away_score;
		$home_score = $game->game_current_home_score;
		$datetime   = '';
		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;
		$datetime     = '';
		$time_in_game = 'FINAL';
		$time = '';
		$period = '';
	} else {
		$away_score   = '';
		$home_score   = '';
		$time_in_game = '';
		$date         = date_create( $game->game_day );
		$time = '';
		$period = '';
		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' );
		}
	}
	$id = 'game-' . $game->game_id;

	$html .= apply_filters( 'sports_bench_before_scoreboard_widget_game', '', $game->game_id, $away_team, $home_team );
	$html .= '
'; $html .= ''; $away_row_style = apply_filters( 'sports_bench_scoreboard_row_styles', '', $away_team, 'widget' ); $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $home_row_style = apply_filters( 'sports_bench_scoreboard_row_styles', '', $home_team, 'widget' ); $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= '
' . $away_team->team_location . '' . $away_score . '
' . $home_team->team_location . '' . $home_score . '
' . $datetime . $time_in_game . '
'; if ( $game->game_preview != null && ( $game->game_status == 'scheduled' || $game->game_status == 'in_progress' ) ) { $html .= ''; } if ( $game->game_status == 'in_progress' && ( $theme->name != 'Sports Bench' || ( $parent_theme && $parent_theme->name != 'Sports Bench' ) ) ) { $html .= ''; } if ( $game->game_recap != null && $game->game_status == 'final' ) { $html .= ''; $html .= ''; } $html .= '
'; $html .= '
'; $html .= apply_filters( 'sports_bench_after_scoreboard_widget_game', '', $game->game_id, $away_team, $home_team ); $html .= apply_filters( 'sports_bench_scoreboard_modal', '', $game, $away_team, $home_team, $status, $time, $period ); return $html; } add_filter( 'sports_bench_scoreboard_widget_game', 'sports_bench_do_scoreboard_widget_game', 10, 2 );