sports_bench_do_stat_search_table( $html, $player, $stat_type )

Type

Filters

Section

Stats

Returns the table row for the search stat table

Parameters

  • $html, previous HTML added for the row
  • $player, the player info from the return MySQL data
  • $stat_type, the stat that's being searched

Returns

  • string, the HTML for the search stat table row

Since: 1.6

Source: statistics.php, line 2482

Example

function sports_bench_do_stat_search_table( $html, $player, $stat_type ) {
	$the_player = new Sports_Bench_Player( (int) $player->player_id );
	$team       = new Sports_Bench_Team( (int) $the_player->team_id );
	$row_styles = apply_filters( 'sports_bench_search_results_row', '', $the_player, $team );

	if ( 'single-game' === $stat_type ) {
		$game = new Sports_Bench_Game( $player->game_id );
		if ( $game->game_away_id === $player->team_id ) {
			$location = __( 'at', 'sports-bench' );
			$opponent = new Sports_Bench_Team( (int) $game->game_home_id );
		} else {
			$location = __( 'vs', 'sports-bench' );
			$opponent = new Sports_Bench_Team( (int) $game->game_away_id );
		}
		$date = date( get_option( 'date_format' ), strtotime( $game->game_day ) );
		if ( '' != $game->recap_link ) {
			$middle_column = '' . $location . ' ' . $opponent->team_name . ', ' . $date . '';
		} else {
			$middle_column = $location . ' ' . $opponent->team_name . ', ' . $date;
		}
	} elseif ( 'season' === $stat_type ) {
		$middle_column = $player->game_season;
	} else {
		$middle_column = '';
	}

	$html .= '';
	$html .= '' . $team->get_team_photo( 'team-logo' ) . '';
	$html .= '' . $the_player->player_first_name . ' ' . $the_player->player_last_name . '';
	$html .= '' . $middle_column . '';
	$html .= '' . $player->STAT . '';
	$html .= '';

	return $html;
}
add_filter( 'sports_bench_stat_search_table', 'sports_bench_do_stat_search_table', 10, 3 );