apply_filters( 'sports_bench_standings_table', $html, $teams, $division_id, $sport, $type, $items )

Filters
Standings

Outputs the HTML for the standings table

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
  • $type, string, whether this is all teams, conference or division standings

Returns

  • string, the HTML for the standings table

Since: 1.5

Source: standings.php, line 50, 93

Example

/**
 * Returns the html for the standings table
 *
 * @param string $html
 *
 * @param array $teams
 *
 * @param int $division
 *
 * @param string $sport
 *
 * @param string $type
 *
 * @param $items
 *
 * @return string
 */
function sports_bench_do_standings_table( $html, $teams, $division, $sport, $type, $items ) {

	$standings = [];
	if ( 'soccer' == $sport || 'rugby' == $sport ) {
		if ( 'league' == $type ) {
			foreach ( $teams as $team ) {
				$the_team = new Sports_Bench_Team( (int) $team->team_id );
				$standing = array(
					'team_id'       => $the_team->team_id,
					'team_name'     => $the_team->team_name,
					'team_link'     => $the_team->get_permalink(),
					'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 )
				);
				if ( $items ) {
					foreach ( $items as $item ) {
						if ( $item['sports_bench_standings_items'] == 'goals-for' ) {
							$standing['goals-for'] = $the_team->get_points_for( '"' . get_option( 'sports-bench-season-year' ) . '"' );
						}
						if ( $item['sports_bench_standings_items'] == 'goals-against' ) {
							$standing['goals-against'] = $the_team->get_points_against( '"' . get_option( 'sports-bench-season-year' ) . '"' );
						}
						if ( $item['sports_bench_standings_items'] == 'goals-differential' ) {
							$standing['goal-differential'] = $the_team->get_point_differential( '"' . get_option( 'sports-bench-season-year' ) . '"' );
						}
						if ( $item['sports_bench_standings_items'] == 'home-record' ) {
							$standing['home-record'] = $the_team->get_home_record( '"' . get_option( 'sports-bench-season-year' ) . '"' );
						}
						if ( $item['sports_bench_standings_items'] == 'away-record' ) {
							$standing['away-record'] = $the_team->get_road_record( '"' . get_option( 'sports-bench-season-year' ) . '"' );
						}
						if ( $item['sports_bench_standings_items'] == 'division-record' ) {
							$standing['division-record'] = $the_team->get_division_record( '"' . get_option( 'sports-bench-season-year' ) . '"' );
						}
						if ( $item['sports_bench_standings_items'] == 'conference-record' ) {
							$standing['conference-record'] = $the_team->get_conference_record( '"' . get_option( 'sports-bench-season-year' ) . '"' );
						}
					}
				}
				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[ 0 ] );
			$html = '';
			$html .= '';
			$html .= '';
			$html .= '';
			$html .= '';
			$html .= '';
			$html .= '';
			$html .= '';
			$html .= '';
			if ( $items ) {
				foreach ( $items as $item ) {
					if ( $item['sports_bench_standings_items'] == 'goals-for' ) {
						$html .= '';
						continue;
					}
					if ( $item['sports_bench_standings_items'] == 'goals-against' ) {
						$html .= '';
						continue;
					}
					if ( $item['sports_bench_standings_items'] == 'goals-differential' ) {
						$html .= '';
						continue;
					}
					if ( $item['sports_bench_standings_items'] == 'home-record' ) {
						$html .= '';
						continue;
					}
					if ( $item['sports_bench_standings_items'] == 'away-record' ) {
						$html .= '';
						continue;
					}
					if ( $item['sports_bench_standings_items'] == 'division-record' ) {
						$html .= '';
						continue;
					}
					if ( $item['sports_bench_standings_items'] == 'conference-record' ) {
						$html .= '';
						continue;
					}
				}
			}
			$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 .= '';
				if ( isset( $team[ 'goals-for' ] ) ) {
					$html .= '';
				}
				if ( isset( $team[ 'goals-against' ] ) ) {
					$html .= '';
				}
				if ( isset( $team[ 'goal-differential' ] ) ) {
					$html .= '';
				}
				if ( isset( $team[ 'home-record' ] ) ) {
					$html .= '';
				}
				if ( isset( $team[ 'away-record' ] ) ) {
					$html .= '';
				}
				if ( isset( $team[ 'division-record' ] ) ) {
					$html .= '';
				}
				if ( isset( $team[ 'conference-record' ] ) ) {
					$html .= '';
				}
				$html .= '';
			}
			$html .= '';
			$html .= '
' . $division[ 0 ]->division_name . '' . __( 'GP', 'sports-bench' ) . '' . __( 'W', 'sports-bench' ) . '' . __( 'D', 'sports-bench' ) . '' . __( 'L', 'sports-bench' ) . '' . __( 'PTS', 'sports-bench' ) . '' . __( 'GF', 'sports-bench' ) . '' . __( 'GA', 'sports-bench' ) . '' . __( 'GD', 'sports-bench' ) . '' . __( 'HOME', 'sports-bench' ) . '' . __( 'AWAY', 'sports-bench' ) . '' . __( 'DIV', 'sports-bench' ) . '' . __( 'CONF', 'sports-bench' ) . '
' . $team[ 'team_name' ] . '' . $team[ 'games_played' ] . '' . $team[ 'wins' ] . '' . $team[ 'draws' ] . '' . $team[ 'losses' ] . '' . $team[ 'points' ] . '' . $team[ 'goals-for' ] . '' . $team[ 'goals-against' ] . '' . $team[ 'goal-differential' ] . '' . $team[ 'home-record' ][ 0 ] . '-' . $team[ 'home-record' ][ 1 ] . '-' . $team[ 'home-record' ][ 2 ] . '' . $team[ 'away-record' ][ 0 ] . '-' . $team[ 'away-record' ][ 1 ] . '-' . $team[ 'away-record' ][ 2 ] . '' . $team[ 'division-record' ][ 0 ] . '-' . $team[ 'division-record' ][ 1 ] . '-' . $team[ 'division-record' ][ 2 ] . '' . $team[ 'conference-record' ][ 0 ] . '-' . $team[ 'conference-record' ][ 1 ] . '-' . $team[ 'conference-record' ][ 2 ] . '
'; } else { foreach ( $teams as $team ) { $the_team = new Sports_Bench_Team( (int) $team->team_id ); $standing = array( 'team_id' => $the_team->team_id, 'team_name' => $the_team->team_name, 'team_link' => $the_team->get_permalink(), '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 ) ); if ( $items ) { foreach ( $items as $item ) { if ( $item['sports_bench_standings_items'] == 'goals-for' ) { $standing['goals-for'] = $the_team->get_points_for( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'goals-against' ) { $standing['goals-against'] = $the_team->get_points_against( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'goals-differential' ) { $standing['goal-differential'] = $the_team->get_point_differential( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'home-record' ) { $standing['home-record'] = $the_team->get_home_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'away-record' ) { $standing['away-record'] = $the_team->get_road_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'division-record' ) { $standing['division-record'] = $the_team->get_division_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'conference-record' ) { $standing['conference-record'] = $the_team->get_conference_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } } } 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', '', 0 ); $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; if ( $items ) { foreach ( $items as $item ) { if ( $item['sports_bench_standings_items'] == 'goals-for' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'goals-against' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'goals-differential' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'home-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'away-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'division-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'conference-record' ) { $html .= ''; continue; } } } $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 .= ''; if ( isset( $team[ 'goals-for' ] ) ) { $html .= ''; } if ( isset( $team[ 'goals-against' ] ) ) { $html .= ''; } if ( isset( $team[ 'goal-differential' ] ) ) { $html .= ''; } if ( isset( $team[ 'home-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'away-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'division-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'conference-record' ] ) ) { $html .= ''; } $html .= ''; } $html .= ''; $html .= '
' . __( 'GP', 'sports-bench' ) . '' . __( 'W', 'sports-bench' ) . '' . __( 'D', 'sports-bench' ) . '' . __( 'L', 'sports-bench' ) . '' . __( 'PTS', 'sports-bench' ) . '' . __( 'GF', 'sports-bench' ) . '' . __( 'GA', 'sports-bench' ) . '' . __( 'GD', 'sports-bench' ) . '' . __( 'HOME', 'sports-bench' ) . '' . __( 'AWAY', 'sports-bench' ) . '' . __( 'DIV', 'sports-bench' ) . '' . __( 'CONF', 'sports-bench' ) . '
' . $team[ 'team_name' ] . '' . $team[ 'games_played' ] . '' . $team[ 'wins' ] . '' . $team[ 'draws' ] . '' . $team[ 'losses' ] . '' . $team[ 'points' ] . '' . $team[ 'goals-for' ] . '' . $team[ 'goals-against' ] . '' . $team[ 'goal-differential' ] . '' . $team[ 'home-record' ][ 0 ] . '-' . $team[ 'home-record' ][ 1 ] . '-' . $team[ 'home-record' ][ 2 ] . '' . $team[ 'away-record' ][ 0 ] . '-' . $team[ 'away-record' ][ 1 ] . '-' . $team[ 'away-record' ][ 2 ] . '' . $team[ 'division-record' ][ 0 ] . '-' . $team[ 'division-record' ][ 1 ] . '-' . $team[ 'division-record' ][ 2 ] . '' . $team[ 'conference-record' ][ 0 ] . '-' . $team[ 'conference-record' ][ 1 ] . '-' . $team[ 'conference-record' ][ 2 ] . '
'; } } elseif ( 'hockey' == $sport ) { if ( 'league' == $type ) { foreach ( $teams as $team ) { $the_team = new Sports_Bench_Team( (int) $team->team_id ); $standing = array( 'team_id' => $the_team->team_id, 'team_name' => $the_team->team_name, '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 ) ); if ( $items ) { foreach ( $items as $item ) { if ( $item['sports_bench_standings_items'] == 'goals-for' ) { $standing['goals-for'] = $the_team->get_points_for( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'goals-against' ) { $standing['goals-against'] = $the_team->get_points_against( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'goals-differential' ) { $standing['goal-differential'] = $the_team->get_point_differential( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'home-record' ) { $standing['home-record'] = $the_team->get_home_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'away-record' ) { $standing['away-record'] = $the_team->get_road_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'division-record' ) { $standing['division-record'] = $the_team->get_division_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'conference-record' ) { $standing['conference-record'] = $the_team->get_conference_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } } } 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', '', 0 ); $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; if ( $items ) { foreach ( $items as $item ) { if ( $item['sports_bench_standings_items'] == 'goals-for' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'goals-against' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'goals-differential' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'home-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'away-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'division-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'conference-record' ) { $html .= ''; continue; } } } $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 .= ''; if ( isset( $team[ 'goals-for' ] ) ) { $html .= ''; } if ( isset( $team[ 'goals-against' ] ) ) { $html .= ''; } if ( isset( $team[ 'goal-differential' ] ) ) { $html .= ''; } if ( isset( $team[ 'home-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'away-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'division-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'conference-record' ] ) ) { $html .= ''; } $html .= ''; } $html .= ''; $html .= '
' . $division[ 0 ]->division_name . '' . __( 'W', 'sports-bench' ) . '' . __( 'L', 'sports-bench' ) . '' . __( 'OTL', 'sports-bench' ) . '' . __( 'PTS', 'sports-bench' ) . '' . __( 'GF', 'sports-bench' ) . '' . __( 'GA', 'sports-bench' ) . '' . __( 'GD', 'sports-bench' ) . '' . __( 'HOME', 'sports-bench' ) . '' . __( 'AWAY', 'sports-bench' ) . '' . __( 'DIV', 'sports-bench' ) . '' . __( 'CONF', 'sports-bench' ) . '
' . $team[ 'team_name' ] . '' . $team[ 'wins' ] . '' . $team[ 'losses' ] . '' . $team[ 'overtime_losses' ] . '' . $team[ 'points' ] . '' . $team[ 'goals-for' ] . '' . $team[ 'goals-against' ] . '' . $team[ 'goal-differential' ] . '' . $team[ 'home-record' ][ 0 ] . '-' . $team[ 'home-record' ][ 1 ] . '-' . $team[ 'home-record' ][ 2 ] . '' . $team[ 'away-record' ][ 0 ] . '-' . $team[ 'away-record' ][ 1 ] . '-' . $team[ 'away-record' ][ 2 ] . '' . $team[ 'division-record' ][ 0 ] . '-' . $team[ 'division-record' ][ 1 ] . '-' . $team[ 'division-record' ][ 2 ] . '' . $team[ 'conference-record' ][ 0 ] . '-' . $team[ 'conference-record' ][ 1 ] . '-' . $team[ 'conference-record' ][ 2 ] . '
'; } else { foreach ( $teams as $team ) { $the_team = new Sports_Bench_Team( (int) $team->team_id ); $standing = array( 'team_id' => $the_team->team_id, 'team_name' => $the_team->team_name, '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 ) ); if ( $items ) { foreach ( $items as $item ) { if ( $item['sports_bench_standings_items'] == 'goals-for' ) { $standing['goals-for'] = $the_team->get_points_for( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'goals-against' ) { $standing['goals-against'] = $the_team->get_points_against( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'goals-differential' ) { $standing['goal-differential'] = $the_team->get_point_differential( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'home-record' ) { $standing['home-record'] = $the_team->get_home_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'away-record' ) { $standing['away-record'] = $the_team->get_road_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'division-record' ) { $standing['division-record'] = $the_team->get_division_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'conference-record' ) { $standing['conference-record'] = $the_team->get_conference_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } } } 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', '', 0 ); $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; if ( $items ) { foreach ( $items as $item ) { if ( $item['sports_bench_standings_items'] == 'goals-for' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'goals-against' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'goals-differential' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'home-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'away-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'division-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'conference-record' ) { $html .= ''; continue; } } } $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 .= ''; if ( isset( $team[ 'goals-for' ] ) ) { $html .= ''; } if ( isset( $team[ 'goals-against' ] ) ) { $html .= ''; } if ( isset( $team[ 'goal-differential' ] ) ) { $html .= ''; } if ( isset( $team[ 'home-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'away-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'division-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'conference-record' ] ) ) { $html .= ''; } $html .= ''; } $html .= ''; $html .= '
' . __( 'W', 'sports-bench' ) . '' . __( 'L', 'sports-bench' ) . '' . __( 'OTL', 'sports-bench' ) . '' . __( 'PTS', 'sports-bench' ) . '' . __( 'GF', 'sports-bench' ) . '' . __( 'GA', 'sports-bench' ) . '' . __( 'GD', 'sports-bench' ) . '' . __( 'HOME', 'sports-bench' ) . '' . __( 'AWAY', 'sports-bench' ) . '' . __( 'DIV', 'sports-bench' ) . '' . __( 'CONF', 'sports-bench' ) . '
' . $team[ 'team_name' ] . '' . $team[ 'wins' ] . '' . $team[ 'losses' ] . '' . $team[ 'overtime_losses' ] . '' . $team[ 'points' ] . '' . $team[ 'goals-for' ] . '' . $team[ 'goals-against' ] . '' . $team[ 'goal-differential' ] . '' . $team[ 'home-record' ][ 0 ] . '-' . $team[ 'home-record' ][ 1 ] . '-' . $team[ 'home-record' ][ 2 ] . '' . $team[ 'away-record' ][ 0 ] . '-' . $team[ 'away-record' ][ 1 ] . '-' . $team[ 'away-record' ][ 2 ] . '' . $team[ 'division-record' ][ 0 ] . '-' . $team[ 'division-record' ][ 1 ] . '-' . $team[ 'division-record' ][ 2 ] . '' . $team[ 'conference-record' ][ 0 ] . '-' . $team[ 'conference-record' ][ 1 ] . '-' . $team[ 'conference-record' ][ 2 ] . '
'; } } else { if ( 'league' == $type ) { foreach ( $teams as $team ) { $the_team = new Sports_Bench_Team( (int) $team->team_id ); $standing = array( 'team_id' => $the_team->team_id, 'team_name' => $the_team->team_name, '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' ) . '"' ), ); if ( get_option( 'sports-bench-sport' ) == 'baseball' ) { if ( $items ) { foreach ( $items as $item ) { if ( $item['sports_bench_standings_items'] == 'runs-for' ) { $standing['runs-for'] = $the_team->get_points_for( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'runs-against' ) { $standing['runs-against'] = $the_team->get_points_against( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'run-differential' ) { $standing['run-differential'] = $the_team->get_point_differential( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'home-record' ) { $standing['home-record'] = $the_team->get_home_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'away-record' ) { $standing['away-record'] = $the_team->get_road_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'division-record' ) { $standing['division-record'] = $the_team->get_division_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'conference-record' ) { $standing['conference-record'] = $the_team->get_conference_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } } } } else { if ( $items ) { foreach ( $items as $item ) { if ( $item['sports_bench_standings_items'] == 'points-for' ) { $standing['points-for'] = $the_team->get_points_for( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'points-against' ) { $standing['points-against'] = $the_team->get_points_against( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'points-differential' ) { $standing['points-differential'] = $the_team->get_point_differential( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'home-record' ) { $standing['home-record'] = $the_team->get_home_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'away-record' ) { $standing['away-record'] = $the_team->get_road_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'division-record' ) { $standing['division-record'] = $the_team->get_division_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'conference-record' ) { $standing['conference-record'] = $the_team->get_conference_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } } } } array_push( $standings, $standing ); } foreach ( $standings as $key => $row ) { $percent[ $key ] = $row[ 'win_percentage' ]; $wins[ $key ] = $row[ 'wins' ]; $losses[ $key ] = $row[ 'losses' ]; } array_multisort( $percent, SORT_DESC, $wins, SORT_DESC, $losses, SORT_ASC, $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 = 0; } 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[ 0 ] ); $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; if ( $items ) { foreach ( $items as $item ) { if ( $item['sports_bench_standings_items'] == 'runs-for' or $item['sports_bench_standings_items'] == 'points-for' ) { if ( get_option( 'sports-bench-sport' ) == 'baseball' ) { $html .= ''; } else { $html .= ''; } } if ( $item['sports_bench_standings_items'] == 'runs-against' or $item['sports_bench_standings_items'] == 'points-against' ) { if ( get_option( 'sports-bench-sport' ) == 'baseball' ) { $html .= ''; continue; } else { $html .= ''; continue; } } if ( $item['sports_bench_standings_items'] == 'run-differential' or $item['sports_bench_standings_items'] == 'points-differential' ) { if ( get_option( 'sports-bench-sport' ) == 'baseball' ) { $html .= ''; continue; } else { $html .= ''; continue; } } if ( $item['sports_bench_standings_items'] == 'home-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'away-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'division-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'conference-record' ) { $html .= ''; continue; } } } $html .= ''; $html .= ''; $html .= ''; foreach ( $standings as $team ) { $table_team_styles = apply_filters( 'sports_bench_standings_team_row', '', $team[ 'team_id' ] ); $html .= ''; $html .= ''; $html .= ''; $html .= ''; if ( $team[ 'games_back' ] == 0 ) { $html .= ''; } else { $html .= ''; } $html .= ''; if ( get_option( 'sports-bench-sport' ) == 'baseball' ) { if ( isset( $team[ 'runs-for' ] ) ) { $html .= ''; } if ( isset( $team[ 'runs-against' ] ) ) { $html .= ''; } if ( isset( $team[ 'run-differential' ] ) ) { $html .= ''; } } else { if ( isset( $team[ 'points-for' ] ) ) { $html .= ''; } if ( isset( $team[ 'points-against' ] ) ) { $html .= ''; } if ( isset( $team[ 'points-differential' ] ) ) { $html .= ''; } } if ( isset( $team[ 'home-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'away-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'division-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'conference-record' ] ) ) { $html .= ''; } $html .= ''; } $html .= ''; $html .= '
' . $division[ 0 ]->division_name . '' . __( 'W', 'sports-bench' ) . '' . __( 'L', 'sports-bench' ) . '' . __( 'GB', 'sports-bench' ) . '' . __( 'PCT', 'sports-bench' ) . '' . __( 'RF', 'sports-bench' ) . '' . __( 'PF', 'sports-bench' ) . '' . __( 'RA', 'sports-bench' ) . '' . __( 'PF', 'sports-bench' ) . '' . __( 'RD', 'sports-bench' ) . '' . __( 'PD', 'sports-bench' ) . '' . __( 'HOME', 'sports-bench' ) . '' . __( 'AWAY', 'sports-bench' ) . '' . __( 'DIV', 'sports-bench' ) . '' . __( 'CONF', 'sports-bench' ) . '
' . $team[ 'team_name' ] . '' . $team[ 'wins' ] . '' . $team[ 'losses' ] . '' . '—' . '' . $team[ 'games_back' ] . '' . $team['win_percentage'] . '' . $team[ 'runs-for' ] . '' . $team[ 'runs-against' ] . '' . $team[ 'run-differential' ] . '' . $team[ 'points-for' ] . '' . $team[ 'points-against' ] . '' . $team[ 'points-differential' ] . '' . $team[ 'home-record' ][ 0 ] . '-' . $team[ 'home-record' ][ 1 ] . '-' . $team[ 'home-record' ][ 2 ] . '' . $team[ 'away-record' ][ 0 ] . '-' . $team[ 'away-record' ][ 1 ] . '-' . $team[ 'away-record' ][ 2 ] . '' . $team[ 'division-record' ][ 0 ] . '-' . $team[ 'division-record' ][ 1 ] . '-' . $team[ 'division-record' ][ 2 ] . '' . $team[ 'conference-record' ][ 0 ] . '-' . $team[ 'conference-record' ][ 1 ] . '-' . $team[ 'conference-record' ][ 2 ] . '
'; } else { foreach ( $teams as $team ) { $the_team = new Sports_Bench_Team( (int) $team->team_id ); $standing = array( 'team_id' => $the_team->team_id, 'team_name' => $the_team->team_name, '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' ) . '"' ), ); if ( get_option( 'sports-bench-sport' ) == 'baseball' ) { if ( $items ) { foreach ( $items as $item ) { if ( $item['sports_bench_standings_items'] == 'runs-for' ) { $standing['runs-for'] = $the_team->get_points_for( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'runs-against' ) { $standing['runs-against'] = $the_team->get_points_against( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'run-differential' ) { $standing['run-differential'] = $the_team->get_point_differential( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'home-record' ) { $standing['home-record'] = $the_team->get_home_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'away-record' ) { $standing['away-record'] = $the_team->get_road_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'division-record' ) { $standing['division-record'] = $the_team->get_division_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'conference-record' ) { $standing['conference-record'] = $the_team->get_conference_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } } } } else { if ( $items ) { foreach ( $items as $item ) { if ( $item['sports_bench_standings_items'] == 'points-for' ) { $standing['points-for'] = $the_team->get_points_for( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'points-against' ) { $standing['points-against'] = $the_team->get_points_against( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'points-differential' ) { $standing['points-differential'] = $the_team->get_point_differential( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'home-record' ) { $standing['home-record'] = $the_team->get_home_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'away-record' ) { $standing['away-record'] = $the_team->get_road_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'division-record' ) { $standing['division-record'] = $the_team->get_division_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } if ( $item['sports_bench_standings_items'] == 'conference-record' ) { $standing['conference-record'] = $the_team->get_conference_record( '"' . get_option( 'sports-bench-season-year' ) . '"' ); } } } } array_push( $standings, $standing ); } foreach ( $standings as $key => $row ) { $percent[ $key ] = $row[ 'win_percentage' ]; $wins[ $key ] = $row[ 'wins' ]; $losses[ $key ] = $row[ 'losses' ]; } array_multisort( $percent, SORT_DESC, $wins, SORT_DESC, $losses, SORT_ASC, $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 = 0; } 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', '', 0 ); $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; if ( $items ) { foreach ( $items as $item ) { if ( $item['sports_bench_standings_items'] == 'runs-for' or $item['sports_bench_standings_items'] == 'points-for' ) { if ( get_option( 'sports-bench-sport' ) == 'baseball' ) { $html .= ''; } else { $html .= ''; } } if ( $item['sports_bench_standings_items'] == 'runs-against' or $item['sports_bench_standings_items'] == 'points-against' ) { if ( get_option( 'sports-bench-sport' ) == 'baseball' ) { $html .= ''; continue; } else { $html .= ''; continue; } } if ( $item['sports_bench_standings_items'] == 'run-differential' or $item['sports_bench_standings_items'] == 'points-differential' ) { if ( get_option( 'sports-bench-sport' ) == 'baseball' ) { $html .= ''; continue; } else { $html .= ''; continue; } } if ( $item['sports_bench_standings_items'] == 'home-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'away-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'division-record' ) { $html .= ''; continue; } if ( $item['sports_bench_standings_items'] == 'conference-record' ) { $html .= ''; continue; } } } $html .= ''; $html .= ''; $html .= ''; foreach ( $standings as $team ) { $table_team_styles = apply_filters( 'sports_bench_standings_team_row', '', $team[ 'team_id' ] ); $html .= ''; $html .= ''; $html .= ''; $html .= ''; if ( $team[ 'games_back' ] == 0 ) { $html .= ''; } else { $html .= ''; } $html .= ''; if ( get_option( 'sports-bench-sport' ) == 'baseball' ) { if ( isset( $team[ 'runs-for' ] ) ) { $html .= ''; } if ( isset( $team[ 'runs-against' ] ) ) { $html .= ''; } if ( isset( $team[ 'run-differential' ] ) ) { $html .= ''; } } else { if ( isset( $team[ 'points-for' ] ) ) { $html .= ''; } if ( isset( $team[ 'points-against' ] ) ) { $html .= ''; } if ( isset( $team[ 'points-differential' ] ) ) { $html .= ''; } } if ( isset( $team[ 'home-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'away-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'division-record' ] ) ) { $html .= ''; } if ( isset( $team[ 'conference-record' ] ) ) { $html .= ''; } $html .= ''; } $html .= ''; $html .= '
' . __( 'W', 'sports-bench' ) . '' . __( 'L', 'sports-bench' ) . '' . __( 'GB', 'sports-bench' ) . '' . __( 'PCT', 'sports-bench' ) . '' . __( 'RF', 'sports-bench' ) . '' . __( 'PF', 'sports-bench' ) . '' . __( 'RA', 'sports-bench' ) . '' . __( 'PF', 'sports-bench' ) . '' . __( 'RD', 'sports-bench' ) . '' . __( 'PD', 'sports-bench' ) . '' . __( 'HOME', 'sports-bench' ) . '' . __( 'AWAY', 'sports-bench' ) . '' . __( 'DIV', 'sports-bench' ) . '' . __( 'CONF', 'sports-bench' ) . '
' . $team[ 'team_name' ] . '' . $team[ 'wins' ] . '' . $team[ 'losses' ] . '' . '—' . '' . $team[ 'games_back' ] . '' . $team['win_percentage'] . '' . $team[ 'runs-for' ] . '' . $team[ 'runs-against' ] . '' . $team[ 'run-differential' ] . '' . $team[ 'points-for' ] . '' . $team[ 'points-against' ] . '' . $team[ 'points-differential' ] . '' . $team[ 'home-record' ][ 0 ] . '-' . $team[ 'home-record' ][ 1 ] . '-' . $team[ 'home-record' ][ 2 ] . '' . $team[ 'away-record' ][ 0 ] . '-' . $team[ 'away-record' ][ 1 ] . '-' . $team[ 'away-record' ][ 2 ] . '' . $team[ 'division-record' ][ 0 ] . '-' . $team[ 'division-record' ][ 1 ] . '-' . $team[ 'division-record' ][ 2 ] . '' . $team[ 'conference-record' ][ 0 ] . '-' . $team[ 'conference-record' ][ 1 ] . '-' . $team[ 'conference-record' ][ 2 ] . '
'; } } return $html; } add_filter( 'sports_bench_standings_table', 'sports_bench_do_standings_table', 10, 6 );