apply_filters( 'sports_bench_stat_leader_table', $html, $players, $stat, $location )

Type

Filters

Section

Stats

Outputs the leaderboard table for a given stat

Parameters

  • $html, string, the current HTML for the table
  • $players, array, the players for the table
  • $stat, string, the stat the table is for
  • $location, string, whether this is the first set of players or not

Returns

  • string, the HTML for the table

Since: 1.5

Source: statistics.php, line 63, 94, 126, 149, 181, 217, 240, 271, 302, 333, 356, 379, 402, 425, 462, 498, 522, 545, 578, 601, 657, 692, 728, 749, 785, 821, 845, 880, 915, 950, 974, 997, 1021, 1046, 1086, 1122, 1148, 1172, 1208, 1232

Example

/**
 * Returns the html for the stats leader table
 *
 * @param string $html
 *
 * @param array $stats
 *
 * @param string  $stat
 *
 * @param string $type
 *
 * @return string, html for the stats leader table
 *
 * @since 1.5
 */
function sports_bench_do_stat_leader_table( $html, $stats, $stat, $type ) {

	if ( 'first' == $type ) {
		$html .= '';
		$html .= '';
		$table_head_style = apply_filters( 'sports_bench_stats_head_row', '', $stat );
		$html .= '';
		$html .= '';
		$html .= '';
		$html .= '';
		$html .= '';
		$count = 1;
		foreach ( $stats as $player ) {
			$the_player = new Sports_Bench_Player( (int) $player[ 'player_id' ] );
			$team       = new Sports_Bench_Team( (int) $the_player->team_id );
			$table_row_style = apply_filters( 'sports_bench_stats_player_row', '', $player, $team, $stat );
			$html .= '';
			$html .= '';
			$html .= '';
			$html .= '';
			$html .= '';
			if ( $count == 10 ) {
				break;
			}
			$count++;
		}
		$html .= '';
		$html .= '
' . sports_bench_get_stat_title( $stat ) . '
' . $team->get_team_photo( 'team-logo' ) . '' . $the_player->player_first_name . ' ' . $the_player->player_last_name . '' . $player[ 'stat' ] . '
'; $html .= '' . __( 'Load More', 'sports-bench' ) . ''; } else { $count = 1; foreach ( $stats as $player ) { $the_player = new Sports_Bench_Player( (int) $player[ 'player_id' ] ); $team = new Sports_Bench_Team( (int) $the_player->team_id ); $table_row_style = apply_filters( 'sports_bench_stats_player_row', '', $player, $team, $stat ); $html .= ''; $html .= '' . $team->get_team_photo( 'team-logo' ) . ''; $html .= '' . $the_player->player_first_name . ' ' . $the_player->player_last_name . ''; $html .= '' . $player[ 'stat' ] . ''; $html .= ''; if ( $count == 10 ) { break; } $count++; } } return $html; } add_filter( 'sports_bench_stat_leader_table', 'sports_bench_do_stat_leader_table', 10, 4 );