apply_filters( 'sports_bench_player_game_stats_table', $html, $game, $team_id, $seasons, $POST )

Type

Filters

Section

Players

Outputs the HTML player’s individual game stats table row

Parameters

  • $html, string, the current HTML for the individual game stats table row
  • $game, array, information for the game
  • $team_id, integer, the team id for the player's team that season
  • $sport, string, the sport that's being used on the site
  • $POST, array, information from the screen that can be used (includes team, player and season)

Returns

  • string, the HTML for the player's individual game stats table row

Since: 1.5

Source: baseball-player-info.php, line 141; basketball-player-info.php, line 113; football-player-info.php, line 96; hockey-player-info.php, line 114; rugby-player-info.php, line 62; soccer-game-info.php, line 100; volleyball-player-info.php, line 86

Example

/**
 * Returns the html for a single game row in the player stats table
 * @param string $html
 *
 * @param Sports_Bench_Game $game
 *
 * @param int $team_id
 *
 * @param string $sport
 *
 * @param array $POST
 *
 * @return string, html for a single game row
 *
 * @since 1.5
 */
function sports_bench_do_player_game_stats_table( $html, $game, $team_id, $sport, $POST = [] ) {
	if ( 'baseball' == $sport ) {
		if ( $game->game_away_id == $team_id ) {
			$opponent = new Sports_Bench_Team( (int) $game->game_home_id );
			$opponent = $opponent->team_location . ' ' . $opponent->get_team_photo( 'team-logo' );
		} else {
			$opponent = new Sports_Bench_Team( (int) $game->game_away_id );
			$opponent = 'at ' . $opponent->team_location . ' ' . $opponent->get_team_photo( 'team-logo' );
		}
		if ( $POST['stat_group'] == 'batting' ) {
			if ( $game->AB == 0 ) {
				$batting_average = '.000';
			} else {
				$batting_average = sports_bench_get_batting_average( $game->AB, $game->HITS );
			}
			$html .= '';
			$html .= ' ' . $opponent . '';
			$html .= '' . $game->AB . '';
			$html .= '' . $batting_average . '';
			$html .= '' . $game->HITS . '';
			$html .= '' . $game->RUNS . '';
			$html .= '' . $game->RBI . '';
			$html .= '' . $game->DOUBLES . '';
			$html .= '' . $game->TRIPLES . '';
			$html .= '' . $game->HOMERUNS . '';
			$html .= '' . $game->STRIKEOUTS . '';
			$html .= '' . $game->WALKS . '';
			$html .= '' . $game->HIT_BY_PITCH . '';
			$html .= '';
		} else {
			$html .= '';
			$html .= ' ' . $opponent . '';
			$html .= '';
			$html .= '';
			$html .= '' . $game->IP . '';
			$html .= '' . sports_bench_get_ERA( (int) $game->ER, (int) $game->IP, 9 ) . '';
			$html .= '' . $game->RA . '';
			$html .= '' . $game->ER . '';
			$html .= '' . $game->HA . '';
			$html .= '' . $game->KS . '';
			$html .= '' . $game->BB . '';
			$html .= '' . $game->HPB . '';
			$html .= '' . $game->HRA . '';
			$html .= '' . $game->PC . '';
			$html .= '';
		}
	} elseif ( 'basketball' == $sport ) {
		if ( $game->game_away_id == $team_id ) {
			$opponent = new Sports_Bench_Team( (int)$game->game_home_id );
			$opponent =  $opponent->team_location . ' ' . $opponent->get_team_photo( 'team-logo' );
		} else {
			$opponent = new Sports_Bench_Team( (int)$game->game_away_id );
			$opponent = 'at ' .  $opponent->team_location . ' '  . $opponent->get_team_photo( 'team-logo' );
		}
		if ( strlen( $game->MIN ) > 4 ) {
			$seconds = substr( $game->MIN, -2, 2 );
			$time = substr_replace( $game->MIN, '', -2, 2 );
			$minutes = substr( $time, -2, 2 );
			$time = substr_replace( $time, '', -2, 2 );
			$times = array( $time, $minutes, $seconds );
			$time = implode( ':', $times );
		} else {
			$seconds = substr( $game->MIN, -2, 2 );
			$minutes = substr_replace( $game->MIN, '', -2, 2 );
			$times = array( $minutes, $seconds );
			$time = implode( ':', $times );
		}
		$html .= '';
		$html .= ' ' . $opponent . '';
		$html .= '';
		$html .= '';
		$html .= '' . $time . '';
		$html .= '' . $game->FGM . '-' . $game->FGA . '';
		$html .= '' . $game->TPM . '-' . $game->TPA . '';
		$html .= '' . $game->FTM . '-' . $game->FTA . '';
		$html .= '' . $game->PTS . '';
		$html .= '';
		$html .= '' . $game->OFF_REB . '-' . $game->DEF_REB . '';
		$html .= '' . ( $game->OFF_REB + $game->DEF_REB ) . '';
		$html .= '' . $game->ASSISTS . '';
		$html .= '' . $game->STEALS . '';
		$html .= '' . $game->BLOCKS . '';
		$html .= '' . $game->TURNOVERS . '';
		$html .= '' . $game->PM . '';
		$html .= '';
	} elseif ( 'football' == $sport ) {
		if ( $game->game_away_id == $team_id ) {
			$opponent = new Sports_Bench_Team( (int) $game->game_home_id );
			$opponent = $opponent->team_location . ' ' . $opponent->get_team_photo( 'team-logo' );
		} else {
			$opponent = new Sports_Bench_Team( (int) $game->game_away_id );
			$opponent = 'at ' . $opponent->team_location . ' ' . $opponent->get_team_photo( 'team-logo' );
		}
		if ( $POST['stat_group'] == 'passing' ) {
			$html .= '';
			$html .= ' ' . $opponent . '';
			$html .= '' . $game->COMP . '';
			$html .= '' . $game->ATT . '';
			$html .= '' . $game->PASS_YD . '';
			$html .= '' . $game->PASS_TD . '';
			$html .= '' . $game->PASS_INT . '';
			$html .= '';
		} elseif ( $POST['stat_group'] == 'rushing' ) {
			$html .= '';
			$html .= ' ' . $opponent . '';
			echo '' . $game->RUSHES . '';
			$html .= '' . $game->RUSH_YARDS . '';
			$html .= '' . $game->RUSH_TD . '';
			$html .= '' . $game->RUSH_FUM . '';
			$html .= '';
		} elseif ( $POST['stat_group'] == 'receiving' ) {
			$html .= '';
			$html .= ' ' . $opponent . '';
			$html .= '' . $game->CATCHES . '';
			$html .= '' . $game->RECEIVE_YARDS . '';
			$html .= '' . $game->RECEIVE_TD . '';
			$html .= '' . $game->RECEIVE_FUM . '';
			$html .= '';
		} elseif ( $POST['stat_group'] == 'defense' ) {
			$html .= '';
			$html .= ' ' . $opponent . '';
			$html .= '' . $game->TACKLES . '';
			$html .= '' . $game->TFL . '';
			$html .= '' . $game->SACKS . '';
			$html .= '' . $game->INTS . '';
			$html .= '' . $game->TDS . '';
			$html .= '' . $game->FF . '';
			$html .= '' . $game->FR . '';
			$html .= '' . $game->BLOCKED . '';
			$html .= '' . $game->YARDS . '';
			$html .= '';
		} elseif ( $POST['stat_group'] == 'kicking' ) {
			$html .= '';
			$html .= ' ' . $opponent . '';
			$html .= '' . $game->FGM . '';
			$html .= '' . $game->FGA . '';
			$html .= '' . $game->XPM . '';
			$html .= '' . $game->XPA . '';
			$html .= '' . $game->TB . '';
			$html .= '';
		} elseif ( $POST['stat_group'] == 'returns' ) {
			$html .= '';
			$html .= ' ' . $opponent . '';
			$html .= '' . $game->RETURNS . '';
			$html .= '' . $game->RETURN_YARDS . '';
			$html .= '' . $game->RETURN_TDS . '';
			$html .= '' . $game->RETURN_FUMBLES . '';
			$html .= '';
		}
	} elseif ( 'hockey' == $sport ) {
		if ( $game->game_away_id == $team_id ) {
			$opponent = new Sports_Bench_Team( (int) $game->game_home_id );
			$opponent = $opponent->team_location . ' ' . $opponent->get_team_photo( 'team-logo' );
		} else {
			$opponent = new Sports_Bench_Team( (int) $game->game_away_id );
			$opponent = 'at ' . $opponent->team_location . ' ' . $opponent->get_team_photo( 'team-logo' );
		}
		if ( strlen( $game->ICE_TIME ) > 4 ) {
			$seconds = substr( $game->ICE_TIME, -2, 2 );
			$time = substr_replace( $game->ICE_TIME, '', -2, 2 );
			$minutes = substr( $time, -2, 2 );
			$time = substr_replace( $time, '', -2, 2 );
			$times = array( $time, $minutes, $seconds );
			$time = implode( ':', $times );
		} else {
			$seconds = substr( $game->ICE_TIME, -2, 2 );
			$minutes = substr_replace( $game->ICE_TIME, '', -2, 2 );
			$times = array( $minutes, $seconds );
			$time = implode( ':', $times );
		}
		if ( $POST[ 'stat_group' ] == 'normal' ) {
			$html .= '';
			$html .= ' ' . $opponent . '';
			$html .= '' . $game->GOALS . '';
			$html .= '' . $game->ASSISTS . '';
			$html .= '' . ( $game->GOALS + $game->ASSISTS ) . '';
			$html .= '' . $game->SOG . '';
			$html .= '' . $game->PM . '';
			$html .= '' . $game->PEN . '';
			$html .= '' . $game->PEN_MIN . '';
			$html .= '' . $game->HITS . '';
			$html .= '' . $game->SHIFTS . '';
			$html .= '' . $time . '';
			$html .= '' . $game->FACE . '-' . $game->FACE_WINS . '';
			$html .= '';
		} elseif ( $POST[ 'stat_group' ] == 'goalie' ) {
			$html .= '';
			$html .= ' ' . $opponent . '';
			$html .= '' . $game->SHOTS_FACED . '';
			$html .= '' . $game->SAVES . '';
			$html .= '' . $game->GOALS_ALLOWED . '';
			$html .= '';
		}
	} elseif ( 'rugby' == $sport ) {
		if ( $game->game_away_id == $team_id ) {
			$opponent = new Sports_Bench_Team( (int)$game->game_home_id );
			$opponent =  $opponent->team_location . ' ' . $opponent->get_team_photo( 'team-logo' );
		} else {
			$opponent = new Sports_Bench_Team( (int)$game->game_away_id );
			$opponent = 'at ' .  $opponent->team_location . ' '  . $opponent->get_team_photo( 'team-logo' );
		}
		$html .= '';
		$html .= ' ' . $opponent . '';
		$html .= '';
		$html .= '' . $game->TRIES . '';
		$html .= '' . $game->ASSISTS . '';
		$html .= '' . $game->CONVERSIONS . '';
		$html .= '' . $game->PK_GOALS . '';
		$html .= '' . $game->DROP_KICKS . '';
		$html .= '' . $game->POINTS . '';
		$html .= '' . $game->PENALTIES_CONCEEDED . '';
		$html .= '' . $game->METERS_RUN . '';
		$html .= '' . $game->REDS . '';
		$html .= '' . $game->YELLOWS . '';
		$html .= '';
	} elseif ( 'soccer' == $sport ) {
		if ( $game->game_away_id == $team_id ) {
			$opponent = new Sports_Bench_Team( (int)$game->game_home_id );
			$opponent =  $opponent->team_location . ' ' . $opponent->get_team_photo( 'team-logo' );
		} else {
			$opponent = new Sports_Bench_Team( (int)$game->game_away_id );
			$opponent = 'at ' .  $opponent->team_location . ' '  . $opponent->get_team_photo( 'team-logo' );
		}
		$html .= '';
		$html .= ' ' . $opponent . '';
		$html .= '' . $game->MINUTES. '';
		$html .= '' . $game->GOALS. '';
		$html .= '' . $game->ASSISTS . '';
		$html .= '' . $game->SHOTS . '';
		$html .= '' . $game->SOG . '';
		$html .= '' . $game->FOULS . '';
		$html .= '' . $game->FOULS_SUFFERED . '';
		$html .= '' . $game->SHOTS_FACED . '';
		$html .= '' . $game->SHOTS_SAVED . '';
		$html .= '' . $game->GOALS_ALLOWED . '';
		$html .= '' . sports_bench_get_goals_against_average( (int)$game->GOALS_ALLOWED, (int)$game->GP ) . '';
		$html .= '';
	} elseif ( 'volleyball' == $sport ) {
		if ( $game->game_away_id == $team_id ) {
			$opponent = new Sports_Bench_Team( (int)$game->game_home_id );
			$opponent =  $opponent->team_location . ' ' . $opponent->get_team_photo( 'team-logo' );
		} else {
			$opponent = new Sports_Bench_Team( (int)$game->game_away_id );
			$opponent = 'at ' .  $opponent->team_location . ' '  . $opponent->get_team_photo( 'team-logo' );
		}

		$html .= '';
		$html .= ' ' . $opponent . '';
		$html .= '';
		$html .= '';
		$html .= '' . $game->POINTS . '';
		$html .= '' . sports_bench_get_hitting_percentage( $game->ATTACKS, $game->KILLS, $game->HITTING_ERRORS ) . '';
		$html .= '' . $game->KILLS . '';
		$html .= '' . $game->ATTACKS . '';
		$html .= '' . $game->HITTING_ERRORS . '';
		$html .= '' . $game->SET_ERR . '';
		$html .= '' . $game->SET_ATT . '';
		$html .= '' . $game->SERVES . '';
		$html .= '' . $game->SE . '';
		$html .= '' . $game->SA . '';
		$html .= '' . $game->BLOCKS . '';
		$html .= '' . $game->BA . '';
		$html .= '' . $game->BE . '';
		$html .= '' . $game->DIGS . '';
		$html .= '' . $game->RE . '';
		$html .= '';
	} else {

	}

	return $html;
}
add_filter( 'sports_bench_player_game_stats_table', 'sports_bench_do_player_game_stats_table', 10, 5 );