apply_filters( 'sports_bench_team_division_standings', $html, $teams, $division_id, $sport )

Filters
Standings

Outputs the HTML for the division/conference standings for a team

Parameters

  • $html, string, current HTML for the standings
  • $teams, array, the teams in the division/conference standings
  • $division_id, integer, the id for the division or conference
  • $sport, string, the sport used for the site

Returns

  • string, the HTML for the conference/division standings

Since: 1.5

Source: standings.php, line 31

Example

/**
 * Returns the html for the team division standings table
 *
 * @param string $html
 *
 * @param array $teams
 *
 * @param int $division
 *
 * @param string $sport
 *
 * @return string, html for the team division standings table
 *
 * @since 1.5
 */
function sports_bench_do_team_division_standings( $html, $teams, $division, $sport ) {

	$standings = [];
	if ( 'soccer' == $sport || 'rugby' == $sport ) {
		foreach ( $teams as $team ) {
			$the_team = new Sports_Bench_Team( (int) $team->team_id );
			$standing = array(
				'team_id'       => $the_team->team_id,
				'team_link'     => $the_team->get_permalink(),
				'team_location' => $the_team->team_location,
				'games_played'  => $the_team->get_games_played( '"' . get_option( 'sports-bench-season-year' ) . '"' ),
				'wins'          => $the_team->get_wins( '"' . get_option( 'sports-bench-season-year' ) . '"' ),
				'losses'        => $the_team->get_losses( '"' . get_option( 'sports-bench-season-year' ) . '"' ),
				'draws'         => $the_team->get_draws( '"' . get_option( 'sports-bench-season-year' ) . '"' ),
				'points'        => sports_bench_get_points( $the_team->team_id )
			);
			array_push( $standings, $standing );
		}

		foreach ( $standings as $key => $row ) {
			$points[ $key ] = $row[ 'points' ];
		}
		array_multisort( $points, SORT_DESC, $standings );

		$table_head_styles = apply_filters( 'sports_bench_standings_head_row', '', $division );
		$html = '';
		$html .= '';
		$html .= '';
		$html .= '';
		$html .= '';
		$html .= '';
		$html .= '';
		$html .= '';
		$html .= '';
		$html .= '';
		$html .= '';
		$html .= '';
		foreach ( $standings as $team ) {
			$table_team_styles = apply_filters( 'sports_bench_standings_team_row', '', $team[ 'team_id' ] );
			$html .= '';
			$html .= '';
			$html .= '';
			$html .= '';
			$html .= '';
			$html .= '';
			$html .= '';
			$html .= '';
		}
		$html .= '';
		$html .= '
' . __( 'GP', 'sports-bench' ) . '' . __( 'W', 'sports-bench' ) . '' . __( 'D', 'sports-bench' ) . '' . __( 'L', 'sports-bench' ) . '' . __( 'PTS', 'sports-bench' ) . '
' . $team[ 'team_location' ] . '' . $team[ 'games_played' ] . '' . $team[ 'wins' ] . '' . $team[ 'draws' ] . '' . $team[ 'losses' ] . '' . $team[ 'points' ] . '
'; } elseif ( 'hockey' == $sport ) { foreach ( $teams as $team ) { $the_team = new Sports_Bench_Team( (int) $team->team_id ); $standing = array( 'team_id' => $the_team->team_id, 'team_location' => $the_team->team_location, 'team_link' => $the_team->get_permalink(), 'wins' => $the_team->get_wins( '"' . get_option( 'sports-bench-season-year' ) . '"' ), 'losses' => $the_team->get_losses( '"' . get_option( 'sports-bench-season-year' ) . '"' ), 'overtime_losses' => $the_team->get_overtime_losses( '"' . get_option( 'sports-bench-season-year' ) . '"' ), 'points' => sports_bench_get_points( $the_team->team_id ) ); array_push( $standings, $standing ); } foreach ( $standings as $key => $row ) { $points[ $key ] = $row[ 'points' ]; } array_multisort( $points, SORT_DESC, $standings ); $table_head_styles = apply_filters( 'sports_bench_standings_head_row', '', $division ); $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; foreach ( $standings as $team ) { $table_team_styles = apply_filters( 'sports_bench_standings_team_row', '', $team[ 'team_id' ] ); $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; } $html .= ''; $html .= '
' . __( 'W', 'sports-bench' ) . '' . __( 'L', 'sports-bench' ) . '' . __( 'OTL', 'sports-bench' ) . '' . __( 'PTS', 'sports-bench' ) . '
' . $team[ 'team_location' ] . '' . $team[ 'wins' ] . '' . $team[ 'losses' ] . '' . $team[ 'overtime_losses' ] . '' . $team[ 'points' ] . '
'; } else { foreach ( $teams as $team ) { $the_team = new Sports_Bench_Team( (int) $team->team_id ); $standing = array( 'team_id' => $the_team->team_id, 'team_location' => $the_team->team_location, 'team_link' => $the_team->get_permalink(), 'wins' => $the_team->get_wins( '"' . get_option( 'sports-bench-season-year' ) . '"' ), 'losses' => $the_team->get_losses( '"' . get_option( 'sports-bench-season-year' ) . '"' ), 'draws' => $the_team->get_draws( '"' . get_option( 'sports-bench-season-year' ) . '"' ), 'win_percentage' => $the_team->get_win_percentage( '"' . get_option( 'sports-bench-season-year' ) . '"' ), ); array_push( $standings, $standing ); } foreach ( $standings as $key => $row ) { $percent[ $key ] = $row[ 'win_percentage' ]; } array_multisort( $percent, SORT_DESC, $standings ); $i = 0; foreach ( $standings as $team ) { $games_back = ( ( $standings[ 0 ][ 'wins' ] - $team[ 'wins' ] ) + ( $team[ 'losses' ] - $standings[ 0 ][ 'losses' ] ) ) / 2; if ( $games_back == 0 ) { $games_back = '—'; } else { $games_back = number_format( (float)$games_back, 1, '.', '' ); } $standings[ $i ][ 'games_back' ] = $games_back; $i++; } $games_back = []; foreach ( $standings as $key => $row ) { $games_back[ $key ] = $row[ 'games_back' ]; } array_multisort( $games_back, SORT_ASC, $standings ); $table_head_styles = apply_filters( 'sports_bench_standings_head_row', '', $division ); $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; foreach ( $standings as $team ) { $table_team_styles = apply_filters( 'sports_bench_standings_team_row', '', $team[ 'team_id' ] ); $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; if ( $team[ 'games_back' ] == 0 ) { $html .= ''; } else { $html .= ''; } $html .= ''; $html .= ''; } $html .= ''; $html .= '
' . __( 'W', 'sports-bench' ) . '' . __( 'D', 'sports-bench' ) . '' . __( 'L', 'sports-bench' ) . '' . __( 'GB', 'sports-bench' ) . '' . __( 'PCT', 'sports-bench' ) . '
' . $team[ 'team_location' ] . '' . $team[ 'wins' ] . '' . $team[ 'draws' ] . '' . $team[ 'losses' ] . '' . '—' . '' . $team[ 'games_back' ] . '' . $team[ 'win_percentage' ] . '
'; } return $html; } add_filter( 'sports_bench_team_division_standings', 'sports_bench_do_team_division_standings', 10, 4 );