One of the best parts of Sports Bench is the ways in which you can customize what appears where on your website and how it looks. Of course, with a plugin that does a lot, there are a lot of different functions, variables, classes and database columns at your disposal. To help you do awesome things with the plugin, I’ve created this codex to define every available class, function and database column at your disposal. That way you spend more time being creative and less time worrying about what does what. Have fun customizing!

Classes

Sports Bench comes with three classes that do the heavy lifting: games, players and teams. Below you’ll find all of the attributes and functions each class comes with.

Games

Class Attributes

  • game_id – int, public, the id of the game
  • game_week – int, public, the week of the game
  • game_season – string, public, the season the game is in
  • game_day – string, public, the date of the game
  • game_home_id – int, public, the id of home team
  • game_home_final – int, public, the final score for the home team
  • game_away_id – int, public, the id of the away team
  • game_away_final – int, public, the final score for the away team
  • game_attendance – int, public, the attendance of the game
  • game_preview_link – string, public, the link to the preview of the game
  • game_recap_link – string, public, the link to the recap of the game
  • game_status – string, public, the current status of the game
  • game_current_time – string, public, the current time in the game
  • game_current_period – string, public, the current period/quarter/inning the game is currently in
  • game_current_home_score – string, public, the current score for the home team
  • game_current_away_score – string, public, the current score for the away team

Constructor – Sports_Bench_Game( $game_id )

  • Takes the id of the game you give it and populates the attributes based on that game’s information.

Players

Class Attributes

  • player_id** – int, public, the id of the player
  • player_first_name** – string, public, the player’s first name
  • player_last_name** – string, public, the player’s last name
  • player_photo** – string, public, the url to the player’s photo
  • player_position** – string, public, the position the player plays
  • player_home_city** – string, public, the player’s hometown
  • player_home_state** – string, public, the player’s home state
  • player_date_of_birth** – string, public, the player’s date of birth
  • team_id** – int, public, the team id for the team the player currently plays for
  • player_weight** – int, public, the weight of the player
  • player_height** – string, public, the height of the player
  • player_slug** – string, public, the slug for the player for url purposes

Constructor – Sports_Bench_Player( $player_id )

  • Takes the id or slug of the player you give it and populates the attributes based on that player’s information.

Function – get_age()

  • Public
  • Returns the current age of the player as an integer

Function get_teams_played_for()

  • Public
  • Returns an array of ids of teams that the player has played for

Function get_seasons_played()

  • Public
  • Returns the number of seasons the player has played as an integer

Function get_permalink()

  • Public
  • Returns the URL to the player’s page as a string
  • The returned string does not include the a tag
  • Place the call to this function inside the href attribute of the a tag

Function get_player_photo()

  • Public
  • Returns the img tag with source to the player’s photo for display

Teams

Class Attributes

  • team_id** – int, public, the id of the team
  • team_name** – string, public, the team’s name
  • team_location** – string, public, the location of the team
    • This is not necessarily the city the team plays in, but the state or city at the start of the team name (i.e. **Texas** Rangers, **Chicago** Cubs).
    • If the team does not have a formal nickname, like FC Dallas or Real Salt Lake, put the entire team name here as well.
  • team_nickname** – string, public, the team’s nickname
  • team_abbreviation** – string, public, the team’s abbreviation
  • team_city** – string, public, the city the team plays in
  • team_state** – string, public, the state the team plays in
  • team_stadium** – string, public, the stadium the team plays in
  • team_stadium_capacity** – int, public, the capacity of the team’s stadium
  • team_head_coach** – string, public, the current head coach of the team
  • team_logo** – string, public, the url for the team’s logo
  • team_photo** – string, public, the url for the team’s photo
  • team_division** – int, public, the id of the division or conference the team plays in
  • team_primary_color** – string, public, the hexadecimal color value for the team’s primary color
  • team_secondary_color** – string, public, the hexadecimal color value for the team’s secondary color
  • team_slug** – string, public, the slug for the team for url purposes

Constructor – Sports_Bench_Team( $team_id )

  • Takes the id or slug of the team you give it and populates the attributes based on that team’s information.

Function get_games_played( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the games played from
  • Returns the number of games played for a team for a season
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_wins( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the wins from
  • Returns the number of wins for a team for a season
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_losses( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the losses from
  • Returns the number of losses for a team for a season
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_draws( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the draws from
  • Returns the number of draws for a team for a season
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_record( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the record from
  • Returns an array of wins, losses and draws for a team for a season
  • The returned array will have the wins as the first item, losses as the second item and draws as the third item
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_win_percentage( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the win percentage from
  • Returns the winning percentage for a team for a given season as a float value with three digits after the decimal point
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_home_record( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the home record from
  • Returns an array of the home wins, home losses and home draws for a team for a season
  • The returned array will have the wins as the first item, losses as the second item and draws as the third item
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_away_record( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the away record from
  • Returns an array of the away wins, away losses and away draws for a team for a season
  • The returned array will have the wins as the first item, losses as the second item and draws as the third item
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_points_for( $season )

  • Public
  • Accepts a string parameter which is the season you want to grab the points/runs/goals scored from
  • Returns the number of points/runs/goals the team has scored for a season as an integer
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_points_against( $season )

  • Public
  • Accepts a string parameter which is the season you want to grab the points/runs/goals given up from
  • Returns the number of points/runs/goals the team has given up for a season as an integer
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_point_differential( $season )

  • Public
  • Accepts a string parameter which is the season you want to grab the points/runs/goals differential from
  • Returns the number of points/runs/goals differential for a team for a season as an integer
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_division_wins( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the divisional wins from
  • Returns the number of divisional wins for a team for a season
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_division_losses( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the divisional losses from
  • Returns the number of divisional losses for a team for a season
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_division_draws( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the divisional draws from
  • Returns the number of divisional draws for a team for a season
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_division_record( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the divisional record from
  • Returns an array of divisional wins, divisional losses and divisional draws for a team for a season
  • The returned array will have the wins as the first item, losses as the second item and draws as the third item
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_conference_wins( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the conference wins from
  • Returns the number of conference wins for a team for a season
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_conference_losses( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the conference losses from
  • Returns the number of conference losses for a team for a season
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_conference_draws( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the conference draws from
  • Returns the number of conference draws for a team for a season
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_conference_record( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the conference record from
  • Returns an array of conference wins, conference losses and conference draws for a team for a season
  • The returned array will have the wins as the first item, losses as the second item and draws as the third item
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_season( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the schedule from
  • Returns an array of games, which has its own array of information
  • Indexes available for each game: date, week, opponent, location, result, team_score, opponent_score, recap
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_recent_result( $limit = 5, $season )

  • Public
  • Accepts an optional integer parameter that is the number of games to grab
  • Accepts a string parameter which is the season to which to grab the schedule from
  • Returns an array of the most recent games that have been completed, which has its own array of information
  • Indexes available for each game: date, week, opponent, location, result, team_score, opponent_score, recap
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_upcoming_schedule ( $limit = 5, $season )

  • Public
  • Accepts an optional integer parameter that is the number of games to grab
  • Accepts a string parameter which is the season to which to grab the schedule from
  • Returns an array of a number of upcoming games that are scheduled, which has its own array of information
  • Indexes available for each game: date, week, opponent, location, result, recap
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_alltime_wins()

  • Public
  • Returns the number of all-time wins a team has

Function get_alltime_losses()

  • Public
  • Returns the number of all-time losses a team has

Function get_alltime_draws()

  • Public
  • Returns the number of all-time draws a team has

Function get_alltime_record()

  • Public
  • Returns an array of all-time wins, all-time losses and all-time draws for a team for a season
  • The returned array will have the wins as the first item, losses as the second item and draws as the third item

Function get_roster()

  • Public
  • Returns an array of players, which has its own array of information for that player
  • Indexes available for each player: first_name, last_name, player_page, position, age, home_city, home_state, height, weight, photo

Function get_team_photo( $image )

  • Public
  • Accepts a string parameter, either team-logo or team-photo, which indicates which image to return
  • If the parameter is team-logo, the team’s logo will be returned
  • If the parameter is team-photo, the team’s photo will be returned
  • If the parameter is not team-logo or team-photo, null will be returned
  • The returned string includes the img tag with the url in the src attribute

Function get_average_attendance( $season )

  • Public
  • Accepts a string parameter which is the season to which to grab the average attendance from
  • Returns the average attendance for a given season as an float
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function get_permalink()

  • Public
  • Returns the URL to the team’s page as a string
  • The returned string does not include the a tag
  • Place the call to this function inside the href attribute of the a tag

Function get_division_name()

  • Public
  • Returns the name of the division the team is in as a string

Brackets

Class Attributes

  • bracket_id – string, public, the id of the bracket
  • num_teams – string, public, the number of teams in the bracket
  • bracket_format – string, public, the format of the bracket
  • bracket_title – string, public, the title of the bracket
  • bracket_season – string, public, the season of the bracket

Constructor – Sports_Bench_Bracket( $bracket_id )

  • Takes the id of the bracket you give it and populates the attributes based on that bracket’s information.

Function get_round( $round )

  • Public
  • Accepts a string parameter which is the round to grab the series
  • Acceptable round names: first, second, third, fourth, fifth, sixth
  • Returns an array of series ids of series in that round

Series

Class Attributes

  • series_id – string, public, the id of the series
  • bracket_id – string, public, the id of the bracket the series is associated with
  • series_format – string, public, the format of the series
  • playoff_round – string, public, the round the series is in
  • team_one_id – string, public, the id of the first team
  • team_one_seed – string, public, the seed for the first team
  • team_two_id – string, public, the id of the second team
  • team_two_seed – string, public, the seed of the second team
  • game_ids – string, public, list of game ids for the series

Constructor – Sports_Bench_Series( $series_id )

  • Takes the id of the series you give it and populates the attributes based on that series’s information.

Function get_series_score()

  • Public
  • Returns the score of the series or false if there is no score

Function get_series_winner()

  • Public
  • Returns the winner of the series or false if there is no winner

Function get_team_score( $team )

  • Public
  • Accepts a string parameter which is the team to grab the score from
  • Acceptable strings: team-one, team-two
  • Returns the score for the entered team
Show Codex Section

Display Functions

These functions control how things are displayed. For example, you’ll find functions that show the color or colors of a team in the border top of a div. Or, you’ll see a function that display’s a label head for a story.

Function sports_bench_border_top_colors( $team_one_id, $team_two_id = null, $div = null )

  • Accepts a required integer parameter, an id of a team
  • Accepts a second, optional integer parameter, an id of another team
  • Accepts an optional string parameter, the id of the div the style affects
  • Returns the border color(s) as either inline styles or embedded style tags for a div based on team ids passed to the function
  • If only one team id is passed to the function, the function will return a style attribute with a 2px solid border-top with the team’s primary color to be added in the div tag
  • If only one team id and the div parameter are passed to the function, the function will return a 2px solid border-top with the team’s primary color in an embedded style tag to be used before the div tag
  • If all three parameters are passed, the function will return an embedded style tag that will make the selected div have a 2px border that’s half the first team’s primary color and half the second team’s primary color

Function sports_bench_division_color( $division_id )

  • Accepts a required integer parameter, an id of a division
  • If the division is listed as a conference, it will return the its color as a hexidecimal value including the # at the beginning
  • If the division is listed as a division, it will return the color of the conference it’s listed under as a hexidecimal value including the # at the beginning

Function sports_bench_team_horizontal_gradient( $team_color )

  • Accepts a required string parameter, the hexidecimal value of a team’s primary or secondary color
  • Returns a string that adds in a background gradient from the color passed to the function to black
  • Place this inside of a style attribute of the div you want to affect

Function sports_bench_show_longform_header()

  • Use if using the longform feature included with the plugin
  • Returns a special header for a longform story
  • Featured image will go full width with the title, author photo and info and date will be in the middle of the image

Function sports_bench_show_team_border_colors()

  • Use only when dealing with a post
  • Returns the border colors in a similar fashion to the border_top_colors based on teams involved in the post
  • If the post is a game preview or recap, the function will return an embedded style tag that will make the selected div have a 2px border that’s half the home team’s primary color and half the away team’s primary color
  • If the post tags one team, the function will return a style attribute with a 2px solid border-top with the team’s primary color to be added in the div tag

Function sports_bench_show_label_head()

  • Use only when dealing with a post
  • If the post is a game preview, the function returns a string as “Away team at Home team”
  • If the post is a game recap, the function returns a string as “Winner score, Loser score”
  • If the post is not a game preview or recap, the function returns the category name as a string

Function sports_bench_show_slider_game_info()

  • Use only when dealing with a post
  • Returns a div section to show game information with the teams’ logos and background gradients
  • Used in the homepage slider in the Sports Bench theme

Function sports_bench_show_google_maps()

  • Returns a Google Map with the location for a game
  • Needs a Google Maps API Key entered into the Sports Bench options

Function sports_bench_show_recap_abbreviation_guide()

  • Returns the abbreviation guide for stats in the game recap
  • Needs the abbreviation guide option in the Sports Bench options to be checked

Function sports_bench_show_stats_abbreviation_guide()

  • Returns the abbreviation guide for stats on the team and player pages
  • Needs the abbreviation guide option in the Sports Bench options to be checked
Show Codex Section

Game Preview Functions

These functions control how the game preview section looks on a post that’s marked as a preview for a game.

Function sports_bench_show_game_preview_info()

  • Use only when dealing with a post
  • Returns an aside for a post that is a game preview, displaying the teams, their logos and their records
  • Once the game is finished, the section with display the final score and a link to the recap if there is one
  • Works best if used in a widget area
Show Codex Section

Game Recap Functions

These functions control how the game recap section looks on a post that’s marked as a recap for a game.

Function sports_bench_show_game_stats_info()

  • Use only when dealing with a post
  • Returns html that outputs the line score, scoring summary (if applicable), team stats (if applicable), home and away individual stats
  • Works best if used in a sidebar

Function sports_bench_show_game_info( $game_id )

  • Accepts a required integer parameter, the id of the game
  • Returns the attendance, time and date and location (stadium, city, state) for the game
  • Each item is wrapped in an h3 tag
Show Codex Section

Playoff Functions

These functions deal with playoff brackets and how to display them.

Function sports_bench_show_playoff_bracket( $bracket_id )

  • Accepts a required integer parameter, the id of the bracket
  • Returns the html to show the bracket anywhere
Show Codex Section

Standings Functions

These functions deal with the standings and how they are displayed. You’ll find the ability to show the league standings all together or standings for a specific conference or division.

Function sports_bench_team_division_standings( $division_id )

  • Accepts a required integer parameter, the id of the division
  • Grabs the standings for a division with the basic information (games played, record, points (if applicable))
  • Typically, this is best used if you are creating a team page template

Function sports_bench_all_team_standings()

  • Returns the league standings with no divisions or conference
  • Also shows the details (like home and away records, points/runs/goals scored, etc.) chosen in the custom fields for the standings page template

Function conference_division_standings( $division_id )

  • Accepts a required integer parameter, the id of the division
  • Returns the standings for a division or conference
  • Also shows the details (like home and away records, points/runs/goals scored, etc.) chosen in the custom fields for the standings page template

Function sports_bench_widget_standings( $division_id = null )

  • Accepts an optional integer parameter, the id of the division
  • Returns standings, either league, conference or division, with just the basic information (games played, record, points (if applicable))
  • If no division id is given, the league standings will be shown, otherwise, the given division will be shown

Function sports_bench_standings_page_template()

  • Returns the necessary html to display the standings in a page template
  • Makes creating a standings page template for a custom theme easier
Show Codex Section

Scoreboard Functions

These functions deal with how the scoreboard and scoreboard bar (if you want to use one) look on the page.

Function sports_bench_scoreboard_bar( $class = null )

  • Accepts an optional string parameter, a class to add to the scoreboard bar
  • Returns the scoreboard bar to be placed anywhere on the site
  • Works best if placed in the header for every page

Function sports_bench_scoreboard_page_template()

  • Returns the necessary html to display the scoreboard in a page template
  • Makes creating a scoreboard page template for a custom theme easier
Show Codex Section

Stats Functions

These functions deal with how stats leaders are found and displayed on the page.

Function sports_bench_get_stats_leaders( $stat, $season )

  • Accepts a required string parameter, a stat to grab
  • Accepts a required string parameter, the season to grab the stats leaders from
  • Returns the top ten leaders for the given stat, as well as a button to load more
  • A list of available stats is located in the get_stat_title function
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function sports_bench_get_more_stats_leaders( $stat, $season, $offset = 0 )

  • Accepts a required string parameter, a stat to grab
  • Accepts a required string parameter, the season to grab the stats leaders from
  • Accepts an optional integer parameter, the number of players to skip
  • Returns the next ten leaders after the number requested to skip for the given stat
  • A list of available stats is located in the get_stat_title function
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string

Function sports_bench_get_stat_title( $stat )

  • Accepts a required string parameter, a stat to get it’s name
  • Returns the name of a stat based off of its slug
  • A list of available stats is located in this function

Function sports_bench_stats_page_template()

  • Returns the necessary html to display the stats in a page template
  • Makes creating a stats page template for a custom theme easier
Show Codex Section

Player Functions

These functions deal with how player information is grabbed and displayed on the page.

Function sports_bench_show_team_player_select()

  • Returns a select menu of teams to pick from
  • Used in the player template to select a player to view
  • Works best when trying to set up a way for users to switch teams easily

Function sports_bench_show_player_info( $player_id )

  • Accepts a required integer parameter, the id of a player
  • Returns the photo, information and stats for a player
  • Used in the player template
  • Makes creating a player page template for a custom theme easier
Show Codex Section

Team Functions

These functions deal with how teams and their information are grabbed and displayed on the page.

Function sports_bench_get_teams( $alphabetical = false )

  • Accepts an optional boolean parameter, whether or not the list is alphabetical
  • Returns an array of the teams in the order desired
  • For each team, the team_id is the key in the array and the team name is the value

Function sports_bench_show_roster( $team_id )

  • Accepts a required integer parameter, the id of the team
  • Returns the html to show a team’s roster

Function sports_bench_show_team_schedule( $team_id )

  • Accepts a required integer parameter, the id of the team
  • Returns the html to display a team’s schedule
  • Works best in a sidebar area on a team page template

Function sports_bench_show_team_listing()

  • Returns the html to show the teams with team name, logo, location, head coach and division for each team
  • Works best on the team page template

Function sports_bench_show_team_info( $team_id )

  • Accepts a required integer parameter, the id of the team
  • Returns an aside of basic information for a team as well as the team’s logo
  • Works best in a sidebar on a team page
Show Codex Section

Sport-Specific Functions

There are a number of functions inside the plugin that are create for a specific sport or sports. These are functions that get a pitcher’s ERA, a batter’s batting average or a player’s shooting percentage. Each function lists what sport or sports it’s used for.

Function sports_bench_get_linescore( $game_id )

  • Accepts a required integer parameter, the id of a game
  • Returns an array of the line score for a baseball game
  • Used with baseball only

Function sports_bench_get_linescore_display( $game_id )

  • Accepts a required integer parameter, the id of a game
  • Returns the line score for a game
  • Used with baseball, basketball, football, hockey and soccer

Function sports_bench_get_game_stat( $game, $home_away, $stat )

  • Accepts a required integer parameter, the id of a game
  • Accepts a required string parameter, whether it’s a home or away stat
  • Accepts a required string parameter, the team stat to grab
  • Returns a the team stat requested
  • Used with baseball

Function sports_bench_get_score_info( $game_id )

  • Accepts a required integer parameter, the id of a game
  • Returns the scoring summary for a game
  • Used with baseball, football, hockey and soccer

Function sports_bench_get_team_stats_info( $game_id )

  • Accepts a required integer parameter, the id of a game
  • Returns the team stats for a game
  • Used with basketball, football, hockey and soccer

Function sports_bench_get_away_individual_stats( $game_id )

  • Accepts a required integer parameter, the id of a game
  • Returns the individual stats for the away team for a game
  • Used with baseball, basketball, football, hockey and soccer

Function sports_bench_get_home_individual_stats( $game_id )

  • Accepts a required integer parameter, the id of a game
  • Returns the individual stats for the home team for a game
  • Used with baseball, basketball, football, hockey and soccer

Function sports_bench_get_ERA( $earned_runs, $innings_pitched, $innings_per_game )

  • Accepts a required integer parameter, the earned runs given up
  • Accepts a required integer parameter, the innings pitched
  • Accepts a required integer parameter, the number of innings per game
  • Returns the ERA for a pitcher as a float value
  • Used with baseball only

Function sports_bench_get_batting_average( $at_bats, $hits )

  • Accepts a required integer parameter, the at bats taken
  • Accepts a required integer parameter, the hits for a batter
  • Returns the batting average for a batter as a float value
  • Used by baseball only

Function sports_bench_stat_exists( $player, $stat )

  • Accepts a required array parameter, an array of a player’s stats
  • Accepts a required integer parameter, a stat to look for
  • Returns whether or not a player has a specific stat
  • Used by baseball and football

Function sports_bench_get_season_stats( $player )

  • Accepts a required stdClass parameter, an instance of the player class
  • Returns the html for the stats by season for a specific player
  • Used by baseball, basketball, football, hockey, soccer

Function sports_bench_get_pitcher_wins( $player_id, $season )

  • Accepts a required integer parameter, the id of the player
  • Accepts a required string parameter, the season to pull the wins from
  • Returns the number of wins for a pitcher as an integer
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string
  • Used by baseball only

Function sports_bench_get_pitcher_losses( $player_id, $season )

  • Accepts a required integer parameter, the id of the player
  • Accepts a required string parameter, the season to pull the wins from
  • Returns the number of losses for a pitcher as an integer
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string
  • Used by baseball only

Function sports_bench_get_pitcher_record( $player_id, $season )

  • Accepts a required integer parameter, the id of the player
  • Accepts a required string parameter, the season to pull the record from
  • Returns an array of the record for a pitcher for a season
  • Access wins with the ‘wins’ key
  • Access losses with the ‘losses’ key
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string
  • Used by baseball only

Function sports_bench_get_pitcher_saves( $player_id, $season )

  • Accepts a required integer parameter, the id of the player
  • Accepts a required string parameter, the season to pull the saves from
  • Returns the number of saves for a pitcher as an integer
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string
  • Used by baseball only

Function sports_bench_get_players_stats( $team_id, $season )

  • Accepts a required integer parameter, the id of the team
  • Accepts a required string parameter, the season to pull the stats from
  • Returns an array of stats for players from a team for the given season
  • Make sure the season passed to this function is a string, as the SQL will not work without the season being a string
  • Used by baseball, basketball, football, hockey, soccer

Function sports_bench_get_players_stats_table( $player_stats_array )

  • Accepts a required array parameter, the array of player stats
  • Returns the html to show the player stats for a team for a season
  • Used by baseball, basketball, football, hockey, soccer

Function sports_bench_get_points_average( $points, $games )

  • Accepts a required integer parameter, the points scored
  • Accepts a required integer parameter, the games played
  • Returns the points per game for a player as a float value
  • Used by basketball only

Function sports_bench_get_shooting_average( $made, $attempts )

  • Accepts a required integer parameter, the number of made shots
  • Accepts a required integer parameter, the number of attempted shots
  • Returns the shooting average for a player as a float value
  • Used by basketball only

Function sports_bench_get_goals_against_average( $goals_allowed, $games_played )

  • Accepts a required integer parameter, the number of goals allowed
  • Accepts a required integer parameter, the number of games played
  • Returns the goals against average for a player as a float value
  • Used by hockey and soccer

Function sports_bench_get_points( $team_id )

  • Accepts a required integer parameter, the id of the team
  • Returns the number of points the team has accumulated in the current season
  • Used by hockey and soccer

Function sports_bench_get_hitting_percentage( $attacks, $kills, $errors )

  • Accepts a required integer parameter, the attacks attempted
  • Accepts a required integer parameter, the number of kills
  • Accepts a required integer parameter, the number of hitting errors
  • Returns the hitting percentage for a player as a float value
  • Used by volleyball only
Show Codex Section

WP REST API Integration

JavaScript frameworks and the WP REST API are the hot thing in web development. If you’re creating a site that uses the REST API and any of the popular frameworks, Sports Bench has the tools to help you. Below you’ll find the available endpoints you can use to access players, teams and games hook up the plugin to your website.

JavaScript frameworks and the WP REST API are the hot thing in web development. If you’re creating a site that uses the REST API and any of the popular frameworks, Sports Bench has the tools to help you. Below you’ll find the available endpoints you can use to access players, teams and games hook up the plugin to your website.

Brackets

URLs: /sportsbench/brackets, /sportsbench/brackets/id
Accepted Parameters: bracket_id, num_teams, bracket_format, bracket_title, bracket_season
Outputs: JSON array of all of the brackets that match the parameters with all of the columns in the brackets table (see “Available Columns” section below)

Divisions

URLs: /sportsbench/divisions, /sportsbench/divisions/id
Accepted Parameters: division_id, division_name, division_conference, division_conference_id, division_color
Outputs: JSON array of all of the divisions that match the parameters with all of the columns in the divisions table (see “Available Columns” section below)

Games

URLs: /sportsbench/games, /sportsbench/games/id
Accepted Parameters: game_id, game_week, game_season, game_day, game_home_id, game_away_id, game_attendance, game_status
Outputs: JSON array of all of the games that match the parameters with all of the columns in the game table depending on the sport (see “Available Columns” section below)

Game Info

URLs: /sportsbench/game_info, /sportsbench/game_info/id
Accepted Paramenters: game_info_id, game_id, game_info_inning (if baseball), game_info_quarter (if football), game_info_period (if hockey)
Outputs: JSON array of all of the game info rows that match the parameters with all of the columns in the game_info table depending on the sport (see “Available Columns” section below)

Game Stats

URLs: /sportsbench/game_stats, /sportsbench/game_stats/id
Accepted Parameters: game_stats_player_id, game_id, game_team_id, game_player_id
Outputs: JSON array of all of the game stats rows that match the parameters with all of the columns in the game_stats table depending on the sport (see “Available Columns” section below)

Players

URLs: /sportsbench/players, /sportsbench/players/id
Accepted Parameters: player_id, player_first_name, player_last_name, player_position, player_home_city, player_home_state, player_date_of_birth, team_id, player_weight, player_height, player_slug
Outputs: JSON array of all of the players that match the parameters with all of the columns in the players table (see “Available Columns” section below)

Series

URLs: /sportsbench/series, /sportsbench/series/id
Accepted Parameters: series_id, bracket_id, series_format, playoff_round, team_one_id, team_one_seed, team_two_id, team_two_seed, game_ids
Outputs: JSON array of all of the playoff series that match the parameters with all of the columns in the series table (see “Available Columns” section below)

Teams

URLs: /sportsbench/teams, /sportsbench/teams/id
Accepted Parameters: team_id, team_name, team_location, team_nickname, team_abbreviation, team_city, team_state, team_stadium, team_stadium_capacity, team_head_coach, team_division, team_name, team_primary_color, team_secondary_color, team_slug
Outputs: JSON array of all of the teams that match the parameters with all of the columns in the teams table (see “Available Columns” section below)

Show Codex Section

Available Columns

Sometimes, the best solution to accomplish what you’re trying to do is to just call the table columns themselves directly. Below are the names of the tables used, the table column names and their data type.

Team Columns

  • team_id, integer
  • team_name, text
  • team_location, text
  • team_nickname, text
  • team_abbreviation
  • team_city, text
  • team_state, text
  • team_stadium, text
  • team_stadium_capacity, integer
  • team_head_coach, text
  • team_division, integer
  • team_primary_color, text
  • team_secondary_color, text
  • team_logo, text
  • team_photo, text
  • team_slug, text

Player Columns

  • player_id, integer
  • player_first_name, text
  • player_last_name, text
  • player_birth_day, text
  • player_photo, text
  • player_position, text
  • player_home_city, text
  • player_home_state, text
  • team_id, integer
  • player_weight, integer
  • player_height, text
  • player_slug, text

Division Columns

  • division_id, integer
  • division_name, text
  • division_conference, text
  • division_conference_id, integer
  • division_color, text

Bracket Columns

  • bracket_id, integer
  • num_teams, integer
  • bracket_format, text
  • bracket_title, text
  • bracket_season, text

Series Columns

  • series_id, integer
  • bracket_id, integer
  • series_format, text
  • playoff_round, text
  • team_one_id, integer
  • team_one_seed, integer
  • team_two_id, integer
  • team_two_seed, integer
  • game_ids, text

Basic Game Columns

  • game_id, integer
  • game_week, integer
  • game_day, datetime
  • game_season, text
  • game_home_id, integer
  • game_away_id, integer
  • game_home_final, integer
  • game_away_final, integer
  • game_attendance, integer
  • game_status, text
  • game_current_period, text
  • game_current_time, text
  • game_current_home_score, integer
  • game_current_away_score, integer
  • game_recap, text
  • game_preview, text

Basic Game Info Columns

  • game_info_id, integer
  • game_id, integer

Basic Game Player Stats Columns

  • game_stats_player_id, integer
  • game_id, integer
  • game_team_id, integer
  • game_player_id, integer

Baseball Game Columns

  • game_home_doubles, text
  • game_home_triples, text
  • game_home_homeruns, text
  • game_home_hits, integer
  • game_home_errors, integer
  • game_home_lob, integer
  • game_away_doubles, text
  • game_away_triples, text
  • game_away_homeruns, text
  • game_away_hits, integer, integer
  • game_away_errors, integer, integer
  • game_away_lob, integer, integer

Baseball Game Info Columns

  • game_info_inning, text
  • game_info_top_bottom, text
  • game_info_home_score, integer
  • game_info_away_score, integer
  • game_info_runs_scored, integer
  • game_info_score_play, text

Baseball Game Stats Columns

  • game_player_at_bats, integer
  • game_player_hits, integer
  • game_player_runs, integer
  • game_player_rbis, integer
  • game_player_doubles, integer
  • game_player_triples, integer
  • game_player_homeruns, integer
  • game_player_strikeouts, integer
  • game_player_walks, integer
  • game_player_hit_by_pitch, integer
  • game_player_fielders_choice, integer
  • game_player_position, text
  • game_player_innings_pitched, float
  • game_player_pitcher_strikeouts, integer
  • game_player_pitcher_walks, integer
  • game_player_hit_batters, integer
  • game_player_runs_allowed, integer
  • game_player_earned_runs, integer
  • game_player_hits_allowed, integer
  • game_player_homeruns_allowed, integer
  • game_player_pitch_count, integer
  • game_player_decision, text

Basketball Game Columns

  • game_home_first_quarter, integer
  • game_home_second_quarter, integer
  • game_home_third_quarter, integer
  • game_home_fourth_quarter, integer
  • game_home_overtime, integer
  • game_home_fgm, integer
  • game_home_fga, integer
  • game_home_3pm, integer
  • game_home_3pa, integer
  • game_home_ftm, integer
  • game_home_fta, integer
  • game_home_off_rebound, integer
  • game_home_def_rebound, integer
  • game_home_assists, integer
  • game_home_steals, integer
  • game_home_blocks, integer
  • game_home_pip, integer
  • game_home_to, integer
  • game_home_pot, integer
  • game_home_fast_break, integer
  • game_home_fouls, integer
  • game_away_first_quarter, integer
  • game_away_second_quarter, integer
  • game_away_third_quarter, integer
  • game_away_fourth_quarter, integer
  • game_away_overtime, integer
  • game_away_fgm, integer
  • game_away_fga, integer
  • game_away_3pm, integer
  • game_away_3pa, integer
  • game_away_ftm, integer
  • game_away_fta, integer
  • game_away_off_rebound, integer
  • game_away_def_rebound, integer
  • game_away_assists, integer
  • game_away_steals, integer
  • game_away_blocks, integer
  • game_away_pip, integer
  • game_away_to, integer
  • game_away_pot, integer
  • game_away_fast_break, integer
  • game_away_fouls, integer

Basketball Game Info Columns

  • game_info_referees, text
  • game_info_techs, text

Basketball Game Stats Columns

  • game_player_started, text
  • game_player_minutes, integer
  • game_player_fgm, time
  • game_player_fga, integer
  • game_player_3pm, integer
  • game_player_3pa, integer
  • game_player_ftm, integer
  • game_player_fta, integer
  • game_player_points, integer
  • game_player_off_rebound, integer
  • game_player_def_rebound, integer
  • game_player_assists, integer
  • game_player_steals, integer
  • game_player_blocks, integer
  • game_player_to, integer
  • game_player_plus_minus, double

Football Game Columns

  • game_home_first_quarter, integer
  • game_home_second_quarter, integer
  • game_home_third_quarter, integer
  • game_home_fourth_quarter, integer
  • game_home_overtime, integer
  • game_home_total, integer
  • game_home_pass, integer
  • game_home_rush, integer
  • game_home_to, integer
  • game_home_ints, integer
  • game_home_fumbles, integer
  • game_home_fumbles_lost, integer
  • game_home_possession, text
  • game_home_kick_returns, integer
  • game_home_kick_return_yards, integer
  • game_home_penalties, integer
  • game_home_penalty_yards, integer
  • game_home_first_downs, integer
  • game_away_first_quarter, integer
  • game_away_second_quarter, integer
  • game_away_third_quarter, integer
  • game_away_fourth_quarter, integer
  • game_away_overtime, integer
  • game_away_total, integer
  • game_away_pass, integer
  • game_away_rush, integer
  • game_away_to, integer
  • game_away_ints, integer
  • game_away_fumbles, integer
  • game_away_fumbles_lost, integer
  • game_away_possession, text
  • game_away_kick_returns, integer
  • game_away_kick_return_yards, integer
  • game_away_penalties, integer
  • game_away_penalty_yards, integer
  • game_away_first_downs, integer

Football Game Info Columns

  • game_info_quarter, integer
  • game_info_time, integer
  • game_info_scoring_team_id, integer
  • game_info_home_score, integer
  • game_info_away_score, integer
  • game_info_play, text

Football Game Stats Columns

  • game_player_completions, integer
  • game_player_attempts, integer
  • game_player_pass_yards, integer
  • game_player_pass_tds, integer
  • game_player_pass_ints, integer
  • game_player_rushes, integer
  • game_player_rush_yards, integer
  • game_player_rush_tds, integer
  • game_player_rush_fumbles, integer
  • game_player_catches, integer
  • game_player_receiving_yards, integer
  • game_player_receiving_tds, integer
  • game_player_receiving_fumbles, integer
  • game_player_tackles, float
  • game_player_tfl, float
  • game_player_sacks, float
  • game_player_pbu, integer
  • game_player_ints, integer
  • game_player_tds, integer
  • game_player_ff, integer
  • game_player_fr, integer
  • game_player_blocked, integer
  • game_player_yards, integer
  • game_player_fga, integer
  • game_player_fgm, integer
  • game_player_xpa, integer
  • game_player_xpm, integer
  • game_player_touchbacks, integer
  • game_player_returns, integer
  • game_player_return_yards, integer
  • game_player_return_tds, integer
  • game_player_return_fumbles, integer

Hockey Game Columns

  • game_home_first_period, integer
  • game_home_first_sog, integer
  • game_home_second_period, integer
  • game_home_second_sog, integer
  • game_home_third_period, integer
  • game_home_third_sog, integer
  • game_home_overtime, integer
  • game_home_overtime_sog, integer
  • game_home_shootout, integer
  • game_home_power_plays, integer
  • game_home_pp_goals, integer
  • game_home_pen_minutes, integer
  • game_away_first_period, integer
  • game_away_first_sog, integer
  • game_away_second_period, integer
  • game_away_second_sog, integer
  • game_away_third_period, integer
  • game_away_third_sog, integer
  • game_away_overtime, integer
  • game_away_overtime_sog, integer
  • game_away_shootout, integer
  • game_away_power_plays, integer
  • game_away_pp_goals, integer
  • game_away_pen_minutes, integer

Hockey Game Info Columns

  • game_info_event, text
  • game_info_period, integer
  • game_info_time, text
  • player_id, integer
  • game_info_assist_one_id, integer
  • game_info_assist_two_id, integer
  • game_info_penalty, text
  • team_id, integer

Hockey Game Stats Columns

  • game_player_goals, integer
  • game_player_assists, integer
  • game_player_plus_minus, integer
  • game_player_penalties, integer
  • game_player_pen_minutes, integer
  • game_player_hits, integer
  • game_player_shifts, integer
  • game_player_time_on_ice, time
  • game_player_faceoffs, integer
  • game_player_faceoff_wins, integer
  • game_player_shots_faced, integer
  • game_player_saves, integer
  • game_player_goals_allowed, integer

Rugby Game Columns

  • game_home_first_half, integer
  • game_home_second_half, integer
  • game_home_extratime, integer
  • game_home_shootout, integer
  • game_home_tries, integer
  • game_home_conversions, integer
  • game_home_penalty_goals, integer
  • game_home_kick_percentage, integer
  • game_home_meters_runs, integer
  • game_home_meters_hand, integer
  • game_home_meters_pass, integer
  • game_home_possession, integer
  • game_home_clean_breaks, integer
  • game_home_defenders_beaten, integer
  • game_home_offload, integer
  • game_home_rucks, integer
  • game_home_mauls, integer
  • game_home_turnovers_conceeded, integer
  • game_home_scrums, integer
  • game_home_lineouts, integer
  • game_home_penalties_conceeded, integer
  • game_home_red_cards, integer
  • game_home_yellow_cards, integer
  • game_home_free_kicks_conceeded, integer
  • game_away_first_half, integer
  • game_away_second_half, integer
  • game_away_extratime, integer
  • game_away_shootout, integer
  • game_away_tries, integer
  • game_away_conversions, integer
  • game_away_penalty_goals, integer
  • game_away_kick_percentage, integer
  • game_away_meters_runs, integer
  • game_away_meters_hand, integer
  • game_away_meters_pass, integer
  • game_away_possession, integer
  • game_away_clean_breaks, integer
  • game_away_defenders_beaten, integer
  • game_away_offload, integer
  • game_away_rucks, integer
  • game_away_mauls, integer
  • game_away_turnovers_conceeded, integer
  • game_away_scrums, integer
  • game_away_lineouts, integer
  • game_away_penalties_conceeded, integer
  • game_away_red_cards, integer
  • game_away_yellow_cards, integer
  • game_away_free_kicks_conceeded, integer

Rugby Game Info Columns

  • team_id, integer
  • game_info_home_score, integer
  • game_info_away_score, integer
  • game_info_event, text
  • game_info_time, integer
  • player_id, integer

Rugby Game Stats Columns

  • game_player_tries, integer
  • game_player_assists, integer
  • game_player_conversions, integer
  • game_player_penalty_goals, integer
  • game_player_drop_kicks, integer
  • game_player_points, integer
  • game_player_penalties_conceeded, integer
  • game_player_meters_run, integer
  • game_player_red_cards, integer
  • game_player_yellow_cards, integer

Soccer Game Columns

  • game_home_first_half, integer
  • game_home_second_half, integer
  • game_home_extratime, integer
  • game_home_pks, integer
  • game_home_possession, integer
  • game_home_shots, integer
  • game_home_sog, integer
  • game_home_corners, integer
  • game_home_offsides, integer
  • game_home_fouls, integer
  • game_home_saves, integer
  • game_home_yellow, integer
  • game_home_red, integer
  • game_away_first_half, integer
  • game_away_second_half, integer
  • game_away_extratime, integer
  • game_away_pks, integer
  • game_away_possession, integer
  • game_away_shots, integer
  • game_away_sog, integer
  • game_away_corners, integer
  • game_away_offsides, integer
  • game_away_fouls, integer
  • game_away_saves, integer
  • game_away_yellow, integer
  • game_away_red, integer

Soccer Game Info Columns

  • team_id, integer
  • game_info_home_score, integer
  • game_info_away_score, integer
  • game_info_event, text
  • game_info_time, integer
  • player_id, integer
  • game_player_name, text
  • game_info_assists, text

Soccer Game Stats Columns

  • game_player_minutes, integer
  • game_player_goals, integer
  • game_player_assists, integer
  • game_player_shots, integer
  • game_player_sog, integer
  • game_player_fouls, integer
  • game_player_fouls_suffered, integer
  • game_player_shots_faced, integer
  • game_player_shots_saved, integer
  • game_player_goals_allowed, integer

Volleyball Game Columns

  • game_home_first_set, integer
  • game_home_second_set, integer
  • game_home_third_set, integer
  • game_home_fourth_set, integer
  • game_home_fifth_set, integer
  • game_home_kills, integer
  • game_home_blocks, integer
  • game_home_aces, integer
  • game_home_assists, integer
  • game_home_digs, integer
  • game_home_attacks, integer
  • game_home_hitting_errors, integer
  • game_away_first_set, integer
  • game_away_second_set, integer
  • game_away_third_set, integer
  • game_away_fourth_set, integer
  • game_away_fifth_set, integer
  • game_away_kills, integer
  • game_away_blocks, integer
  • game_away_aces, integer
  • game_away_assists, integer
  • game_away_digs, integer
  • game_away_attacks, integer
  • game_away_hitting_errors, integer

Volleyball Game Stats Columns

  • game_player_sets_played, integer
  • game_player_points, integer
  • game_player_kills, integer
  • game_player_hitting_errors, integer
  • game_player_attacks, integer
  • game_player_set_attempts, integer
  • game_player_set_errors, integer
  • game_player_serves, integer
  • game_player_serve_errors, integer
  • game_player_aces, integer
  • game_player_blocks, integer
  • game_player_block_attempts, integer
  • game_player_block_errors, integer
  • game_player_digs, integer
  • game_player_receiving_errors, integer
Show Codex Section