Sports Bench comes in two parts — a plugin and a theme. Both the plugin and theme work on their own; however, it’s suggested that you use both to get the most out of both products.

Plugin

Creating and keeping up with sports league stats on the internet can be a hassle. Fortunately, the Sports Bench plugin takes all of the hard work away from you. After a simple five-minute (or less) setup, you’re ready to start entering teams, players, games and even division and then watch the plugin do all of the other stuff for you. Sports Bench takes care of accumulating the stats you enter as well as the standings and schedules.

The plugin has the ability to display the standings, a scoreboard of all game for the current season and statistical leaderboards. Show off game stats next to a recap of a game. Easily create pages for teams and players. And shortcodes allow you to show game, player or team information in any post. And if you use the theme, all of this comes with minimal front-end coding work for you. You have enough to worry about with managing your sports league; let us take care of the hard part.

Theme

The Sports Bench theme is the perfect way to use the Sports Bench plugin out of the box with no need to add any code to make the core functionality work. The Sports Bench theme includes page templates for the standings, scoreboard, stats leaderboards, teams and players. It also includes the scoreboard bar, a featured post slideshow, infinite scrolling posts on the homepage and implements the longform post feature included in the Sports Bench plugin.

Sports Supported:

  • Baseball
  • Basketball
  • Football
  • Hockey
  • Rugby
  • Soccer
  • Volleyball

Details

Requires at least: 4.7
Tested up to: 4.9
Stable tag: 1.4

Features

Team Page

Plugin

Sports Bench makes it easy for you to have a centralized location for each team in the league with team pages. If you’re using the Sports Bench theme, this requires no setup. But even if you’re not, our functions and guides will have you setup with a team page template that will match your theme in no time.

Player Page

Plugin

This plugin also makes it easy for you to have a centralized location for each player in the league with player pages. If you’re using the Sports Bench theme, this requires no setup. But even if you’re not, our functions and guides will have you setup with a player page template that will match your theme in no time.

Playoffs

Plugin

You can now easily create playoff brackets to show who your league’s champion is. Create a 2, 4, 6, 8, 12, 16, 32 or 64 team single elimination bracket or a four-team double elimination bracket. And the front end display is easy. Just select the playoff shortcode, select the bracket and watch it do its work. The display is written to work with any size screen, so all of your readers will be able to see who the true champion is.

Divisions

Plugin

Sports Bench makes it easy to organize teams via conferences and/or divisions. Simply add the division or conference and then sort the teams into them.

Standings

Plugin

Show where teams are in the standings with ease. The plugin keeps track of the standings with minimal need for user input. You can show league, conference or division standings, whichever works for you.

Scoreboard

Plugin

Display upcoming, current or completed games with an easy-to-use scoreboard. You can create a separate scoreboard page with only the need to call one function, or you can add a scoreboard bar to the top of your header.

Stats Leaderboard

Plugin

Show who’s the best in different statistical categories with Sports Bench’s stats leaderboard. Simply select which stats you wish to show and they’ll show up on the page. The stats show the top ten players, but users can load more for each stat with a simple click.

Game Recaps

Plugin

Show off stats from a game in a nice sidebar area to go along with a post. It’s perfect for a game recap, where the text or even video recap can be in the main area with the stats off to the side. The recap stats are made to be used with any sidebar to match the theme you are using.

Widgets

Plugin

Sports Bench comes with three ready-to-go widgets to display in the sidebar. You can display standings, the scoreboard and the leaderboard for a stat in the sidebar. The widgets are also created to blend with you sidebar to match the theme.

Shortcodes

Plugin

The plugin also comes with 11 different shortcodes that you can use to display information in a post. In the post editor, click the ‘SB’ logo to open up a modal where you can select between a game, team, player, scoreboard, standings, stats, playoff bracket, rivalry, player page, team page or game recap shortcode to display information to add to your posts.

WP REST API Integration

Plugin

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.

CSV Upload

Plugin

Already have a database set up for your league? Well we make it easy for you to bring it over and set up with Sports Bench. Simply export each table you need – divisions, games, game info, game stats, players, brackets, series and teams – and use our CSV uploaded to add the information. The CSV import page will walk you through the process to make sure you’re all set.

Sports Bench Plugin Integration

Theme

The Sports Bench theme is designed and coded with the Sports Bench plugin in mind. While the theme works on its own like any other WordPress theme, it works best with the plugin. This is perfect for users with no coding experience as everything has already been taken care of. Simply activate the theme and plugin, setup the plugin options and you’re on your way.

Homepage Slider

Theme

Show off your best or most important stories with the featured post slider on the homepage. Simply select a category in the theme options and add posts to that category to see them displayed in the full-width slider. You can control how many posts are shown on the slider. The preferred image ratio is 2.56:1, with a relatively large image so that it stretches across the page.

Customizable Homepage

Theme

Readers won’t have to go very far to find your stories when they come to your website. In addition to showing your latest posts, you can also add tabs for selected categories so readers can peruse them without leaving the homepage.

Infinite Scroll

Theme

Your readers won’t have to worry about the hassle of navigating through pages of posts to find their favorite stories thanks to infinite scroll. Readers will just have to keep scrolling down in order to load more posts rather than wait for a new page to load, saving them time and frustration. This works on the home and archive pages.

Custom Header

Theme

Add your personal branding to the website with a custom logo. The logo displays on the left side of the top menu. The suggested size for the header is 200px by 40px.

Site Logo

Theme

In addition to the site header, you can also add branding with a custom site logo. The logo will appear down in the footer and can also be added into templates wherever you need it. WordPress advises that the site logo be 512px by 512px.

Social Media Links

Theme

Show off links to your social media sites in the header with ease. Simply enter the URL for the desired social media platform in the theme options and the image and links will automatically appear in the header.

Longform Template

Theme

Have a special story that you want to tell in a special way? Sports Bench makes that easy with the longform feature. Select the longform post template in the “Post Attributes” section of the post editor to see your story displayed in a unique way.

Home Page
Single Post
Single Recap Template
Single Preview Template
Playoffs
Standings Page
Scoreboard Page
Stats Page
Teams Page
Single Team Page
Players Page
Single Player Page
Admin Divisions Page
A screenshot of a cell phone
Admin Teams Page
Admin Single Team
A screenshot of a cell phone
Admin Players Page
A screenshot of a cell phone
Admin Single Player
Admin Games Page
Admin Single Game
A screenshot of a cell phone
A screenshot of a cell phone
A screenshot of a cell phone

How To's

Installation

Plugin

Via WordPress Dashboard
  1. If you purchased the plugin/theme package, unzip the “sports-bench” directory that comes with the download. If you purchased the plugin only, ignore this step.
  2. In the WordPress admin area, go to Plugins->Add New. Then hit “Upload Plugin” at the top of the subsequent page.
  3. Select the zipped plugin directory (i.e. sports-bench-1.0.zip) and hit “Install Now”.
  4. After the plugin is installed, click “Activate” to start using the theme.
  5. Go to the “Setup” section of this ReadMe file to get the plugin rolling for your use.
VIia FTP Upload
  1. If you purchased the plugin/theme package, unzip the “sports-bench” directory that comes with the download. If you purchased the plugin only, ignore this step.
  2. Unzip the zipped plugin directory (i.e. sports-bench-1.0.zip).
  3. Upload the sports-bench directory inside the now-unzipped directory to the plugin directory on your site (located inside of the wp-content directory).
  4. In the WordPress admin area, go to the Plugins page and hit “Activate” underneath the Sports Bench listing on the page to begin using the theme.
  5. Go to the “Setup” section of this ReadMe file to get the plugin rolling for your use.

Theme

Via WordPress Dashboard
  1. If you purchased the plugin/theme package, unzip the “sports-bench” directory that comes with the download. If you purchased the theme only, ignore this step.
  2. In the WordPress admin area, go to Appearance->Themes. Click the “Add New” button at the top of the page and then hit “Upload Theme” at the top of the subsequent page.
  3. Select the zipped theme directory (i.e. sports-bench-1.0.zip) and hit Install now.
  4. After the theme is installed, click “Activate” to start using the theme.
Via FTP Upload
  1. If you purchased the plugin/theme package, unzip the “sports-bench” directory that comes with the download. If you purchased the theme only, ignore this step.
  2. Unzip the zipped theme directory (i.e. sports-bench-1.0.zip).
  3. Upload the sports-bench directory inside the now-unzipped directory to the themes directory on your site (located inside of the wp-content directory).
  4. In the WordPress admin area, go to Appearance->Theme and hit “Activate” underneath the Sports Bench listing on the page to begin using the theme.

Setting Up Sports Bench

So now you’ve got the plugin installed and activated. Before we get too far along, we need to set up a few plugin settings so that you’re ready to go.

  1. Go to the Sports Bench Options page after activating the plugin. The link can be found in the admin menu on the left side.
  2. First, select a sport. Currently, baseball, basketball, (American) Football, Hockey and Soccer (Football) are supported. Please note that if you select a sport, comeback to the option and change it, all games will be lost.
  3. Add the current season. The default is the current year. Please make note of how you format the year(s) here. You’ll need it when you start to create games later on. Make sure to update this setting when you start a new season.
  4. Determine whether or not you want to display games by week or not. This option determines how games are shown on the scoreboard. If you don’t select this option, you can disregard the “Week” field when creating games. Otherwise, next enter the current week of the season. You’ll update this setting a lot.
  5. If you have a or want a page to show team pages, select the page that is using the team page template. This will direct team links to this page. If you haven’t created the page for the teams, you can come back to this later. We’ll get into more detail later on in the guide.
  6. If you have a or want a page to show player pages, select the page that is using the player page template. This will direct player links to this page. If you haven’t created the page for the players, you can come back to this later. We’ll get into more detail later on in the guide.

Creating a Division

All right, now we’ve got our settings taken care of we can start adding some data. At first you’ll probably be tempted to create teams right now, but most leagues divide their teams up into divisions, conferences or leagues, so let’s start there first. This way it will be much easier once we start adding teams.

  1. To start adding divisions, hover over the “Teams” item in the menu in the admin area of your site. Then click on “Divisions” in the submenu that appears.
  2. The divisions page is set up nearly identical to the categories page in WordPress where the divisions are listed on the right and you can add divisions or conferences on the left.
  3. To add a division or conference, first fill out the name of the division or conference.
  4. Then select if this is a division or a conference.
  5. If this is a conference, select the color for the conference. This is optional, but the color appears a border between the table head and table body wherever the standings appear.
  6. If this is a division, select the conference the division belongs to. The recommended practice is to add conferences first and then add divisions, if that is your set up.
  7. Then hit save. The page will reload and your new item will show up on the left. Repeat this process until all of your divisions and conferences are added.

Creating a Team

At this point we’ve installed the plugin, got the settings taken care of and added our conferences and divisions. Now it’s finally time to add in the teams.

  1. To start adding teams, hover over the “Teams” item in the admin area of your site. Then click “Add New” in the submenu that appears.
  2. Starting at the top, add the full team name (i.e. Texas Rangers, Seattle Seahawks, FC Dallas).
  3. Then enter the team location. If the team has a location and nickname, put just the city or state (i.e. Texas, Seattle). If the team has no nickname, like FC Dallas or D.C. United, put the full name here again and leave the nickname field next blank.
  4. Enter in the nickname of the team if there is one (i.e. Ranger, Seahawks).
  5. Next enter the three or four letter abbreviation of the team (i.e. TEX, SEA, FCD).
  6. Next select whether the team is active or inactive. The default setting is always active. This only changes to inactive if the team takes a hiatus or folds.
  7. Then enter the city and the state where the team is located.
  8. Next enter the stadium name and the capacity of the stadium.
  9. Then enter the name of the head coach.
  10. Next select what division or conference the team is placed in.
  11. Then enter the primary and secondary colors for the team.
  12. Next, on the right hand side, upload the team’s logo.
  13. Then you can add a photo of the team below the logo. This is an optional item.
  14. Finally, hit save at the bottom. You’ve now created your first team. Congrats! Now repeat these steps to add your remaining teams.

Creating a Player

So we’ve added our teams. Now it’s time to add our players to these teams.

  1. To start adding players, hover over the “Players” item in the admin area of your site. Then click “Add New” in the submenu that appears.
  2. Enter in the first and last name of the player.
  3. Then select the team the player plays for, or select “Free Agent” if the player has no team.
  4. Next use the date picker to select the player’s birthday.
  5. Then either enter or select the position the player page.
  6. Next add the height and weight of the player if you want to.
  7. Then enter the city and state name of the player’s hometown if you so wish.
  8. Add a photo of the player on the right side of the page, if you wish.
  9. Finally, hit save at the bottom. You’ve now created your first player. Congrats. Now repeat these steps to add your remaining players.

Creating a Game

So we’ve added our teams and their players. Now it’s time to add games to the schedule. This is the most complicated of the admin pages associated with the plugin, but if you follow these steps, you’ll have no issue adding games and game stats.

  1. To start adding games, hover over the “Games” item in the admin area of your site. Then click “Add New” in the submenu that appears.
  2. Select the home and away teams for the game.
  3. Then select whether this game is a scheduled game, a game in progress or a game that is final.
  4. If this is a game that’s in progress, another section will appear below. Here you’ll enter the current score for the home and away teams and the current time and period (or minute of the match for soccer or inning for baseball) of the game.
  5. In the game information row, enter the season the game is taking place in. If you’re sorting your games by week, add the week number. Then add the date and time of the game and the attendance of the game (if applicable).
    • If this game is listed as a scheduled game, you don’t need to go any further. Hit save right here and you’re done! You’ve added your first game. Otherwise, continue on.
  6. In this next section, add the scoreline for the game. If this is a baseball game, enter in the runs, hits, errors and men/women left on base. Otherwise, enter the scoring by quarter, period or half. The final column on the right will automatically add up the total for each team.
  7. Next add the game/match events for the game. This differs from sport to sport, but the column headings wil point you in the right direction. You can add as many game events as needed with the button at the bottom. You can also remove game events with the remove button at the end of each row.
    • Note: Basketball games do not have this section.
    • If this game is listed as an in-progress game, you don’t need to go any further. Hit save right here and you’re done! You’ve added your first game. Otherwise, continue on.
  8. Then add in the team stats for the game. Again, this differs depending on the sport, but the titles in the center will help you along.
  9. Next add in the individual player stats for the home and away teams. The players will be loaded in a dropdown on the left when you select the teams at the top. Again, the stats you’ll need to enter differ depending on the sport, but the column headings will guide you along. You can add as many players as you need with the button at the bottom of each section. You can also remove players with the remove button at the end of each row.
  10. Finally, hit the save button at the bottom of the page. You’ve now created your first game complete with all of the stats. Congrats! Now just repeat the process whenever you need to add or edit games.

Creating a Playoff Bracket

Okay so now an entire season has gone by and it’s time for playoffs. (And yes Jim Mora, we’re talking about playoffs). Sports Bench makes it easy for you to create playoff brackets to show off who your one true champion really is.

  • To add a playoff bracket, hover over the “Playoffs” item in the admin area of your site. Then click “Add New” in the submenu that appears.
  • Next give the bracket a name. Then select the number of teams that will be in the tournament, select whether it’s a single or double elimination tournament and then select the season the bracket takes place in.
  • For each playoff match up, select both teams from the dropdowns provided. Give each of them their seeding (if applicable). Then select whether this is a one, two, three, five or seven game series. Finally, select the game that applies to each game in the series from the dropdowns below.
  • Repeat the previous step until the bracket is filled out as much as it can be. The score section on the right will update automatically, but you will have to select the winners by hand like the previous step.
  • When you’re done, hit save. And that’s it. You’ve created your first playoff bracket!

Adding Scoreboard, Standings and Stats Pages

All right, so we’ve got the plugin installed and setup. We have our divisions, teams, players and some games. Now how will we display this data. Fortunately, Sports Bench makes it easy for you to display standings, scoreboards and stats leaderboards on pages (and even posts) thanks to shortcodes. This section will take you through how to do that.

  • First start a new page or post. Then click the “SB” logo near the top of the visual editor. This will open up a modal where you can select a number of different shortcodes.
  • If you want to add a scoreboard, select “Scoreboard” and then hit insert. Now when you view the page or post, a scoreboard will be displayed.
  • If you want to add standings, select “Standings” and then hit insert. Then a few options will appear below the editor. If it doesn’t appear right away, give it a few seconds. In the options, you can show league, conference and division standings and show home, away, division and conference records and points for and against and points differential. You can add and remove items if you need to using the buttons in the options.
  • If you want to add a stats leaderboard, select “Stats” and then hit insert. Then an options panel will appear below the editor. Here, you can chose which stats show up on the page. You can add as many stats as you like to the page.
  • That’s it. You can create pages that show a scoreboard, standings and stats without writing a single line of code!

Using the Shortcodes

But your shortcode options aren’t just limited to standings, you can also use shortcodes to show playoff brackets, game information, players and teams.

  • To begin using a shortcodes, first start a new page or post. Then click the “SB” logo near the top of the visual editor. This will open up a modal where you can select a number of different shortcodes.
  • If you want to add a game shortcode, select “Game” and then select a season. From there, select a game from that season. The shortcode will then show the teams competing in the game as well as the time, date and location of the game. If the game is finished and has a recap, a link to the recap will show as well.
  • If you want to add a player shortcode, select “Player” and then select a player from the list that appears. The shortcode will display the player’s photo and information and their recent stats.
  • If you want to add a team shortcode, select “Team” and then select a team from the list that appears. The shortcode will display the team’s logo and information and their recent games and upcoming schedule.
  • If you want to add a playoff shortcode, select “Playoff Brackets” and then select a playoff bracket from the list that appears. This will display the bracket in table form on the front end.
  • If you want to add a rivalry shortcode, select “Rivalry” and then select the two teams that you want to display stats for. This will display the series records between the two teams and their recent results against each other.
  • If you want to add a team page shortcode, select “Team Page”. Next, please find the “Creating a Team Page” section of the guide and follow those instructions.
  • If you want to add a player page shortcode, select “Player Page”. Next, please find the “Creating a Player Page” section of the guide and follow those instructions.
  • If you want to add a game recap shortcode, select “Game Recap” and then select the game you want to show a recap for.
  • That’s it. You can now display a lot of cool information in your posts and pages without writing a single line of code!

Using the Widgets

Want to display information that appears in the sidebar wherever your viewers go? Sports Bench has widgets so you can display a scoreboard, standings and stats on every page with a widget area.

  • Navigate to the Widgets page in the admin area.
  • To add a scoreboard widget, click and drag the “Sports Bench Scoreboard” widget to the desired widget area. Give it a title and hit “Save”. That’s it.
  • To add a standings widget, click and drag the “Sports Bench Standings” widget to the desired widget area. Give it a title, select whether it will show the league, conference or division standings and then hit “Save”. That’s it.
  • To add a stats widget, click and drag the “Sports Bench Statistic” widget to the desired widget area. Give it a title, select which statistic to show and then hit “Save”. That’s it.

Setting Up the Teams Page Template

Okay so you’ve created a new page template and shown player information. Now we’re going to do the same for teams, but the level of difficulty is going to go up a bit. But don’t worry. Once again, if you follow these directions, you’ll be feeling like a real programmer by the time it’s over. And if you want, there’s a shortcode you can use to create the team page instead.

Using the Team Page Shortcode

  1. First, create a new page. Then in the new page create a new shortcode. To do this, click the “SB” button in the TinyMCE editor at the top.
  2. In the window that now appears, select “Team Page” and then insert. Then hit “Publish”.
  3. Next, navigate to the Sports Bench Options page. It should be in the menu on the left in the admin.
  4. In the options page, select your new page for the Team Page option and then hit save.
  5. After that, go to the permalinks page. This can be found under the Settings section in the admin. Don’t tough your permalinks, but hit save at the bottom. This will reset the necessary redirects to make the page work.
  6. And that’s it. Your team page is ready to go. And you didn’t even need to write a single line of code.

Using a Team Page Template

Introducing the Team Class

Before we get going too far, let’s introduce the Sports_Bench_Team class.

Once again, if you’re not too familiar with PHP or object-oriented programming, just know that adding the following to your code essentially calls the team from the database and populates it attributes without you having to write more code.

<?php $team = new Sports_Bench_Team( (int){{team_id}} ); ?>

Note that the team id will need to be an actual integer number.

From here, you can get the team name, location and so much more. In fact, here’s a list of the available attributes you can call, plus one function we’ll use to set up this page.

  • $team->team_id
  • $team->team_name
  • $team->team_location
  • $team->team_nickname
  • $team->team_abbreviation
  • $team->team_active
  • $team->team_city
  • $team->team_state
  • $team->team_stadium
  • $team->team_stadium_capacity
  • $team->team_head_coach
  • $team->team_logo
  • $team->team_photo
  • $team->team_division
  • $team->team_primary_color
  • $team->team_secondary_color
  • $team->player_slug
  • $team->team_slug
  • $team->get_schedule()
  • $team->get_roster()
  • $team->get_team_photo()
  • $team->get_division_name()

So now that we’ve gone over something we’ll be using here, let’s start building the player page, shall we? If you want to learn more about the Player class and the other classes, please visit the codex page on the Sports Bench website.

Building the Team Page

Like the player page, creating the team page involves creating a new page template. It’s a simple concept in WordPress, but if you’re unfamiliar with it, you can read this, this and this tutorial on how to do that. Otherwise, let’s get started.

  1. So first off, create a new page template in your theme’s main directory. Name it page-team.php
  2. Next, copy the contents of your theme’s page.php file and paste it into this new page template file.
  3. At the top underneath the opening php tag, paste the following:
    Template Name: Team
  4. Now, this is where things get a bit trickier. In this file, look for the get_sidebar() function. If this is wrapped in a div tag that has a class or id of “widget” or sidebar, then don’t do anything with it. Otherwise, find your theme’s sidebar.php In this file look for a div tag with a class or id of “widget” or “sidebar”. Copy this div and paste it in the new template file above the get_sidebar function. Make sure the closing </div> tag is there as well.
  5. Once you’ve done that, take a quick breather. We’re going to divide the rest of this into two parts: the main body and the sidebar.

Building the Main Body of the Page

  1. Like the player page, find the loop and delete everything within either a main or article div. Then inside of that, paste the following lines of code:
    					<?php if ( class_exists( 'Sports_Bench_Team' ) ) { ?>
    						<?php if ( get_query_var( 'team_slug' ) ) { ?>
    						<?php } else { ?>
    						<?php } ?>
    					<?php } ?>
    
  2. Then inside the else part of the statement, paste the following code: <?php echo sports_bench_show_team_listing(); ?>.
  3. The rest of this section will deal with code going inside the <?php if ( class_exists( 'Sports_Bench_Team' ) ) { ?> section.
  4. To show the team photo, insert the following lines:
    				<div class="team-photo">
                    	<?php echo $team->get_team_photo( 'team-photo' ); ?>
    				</div>
    
  5. To show the team logo, insert the following lines:
    					<div class="team-logo">
    						<?php echo $team->get_team_photo( 'team-logo' ); ?>
    					</div>
    
  6. To show the team name, insert the following lines:
    					<div class="team-name">
    						<h1 class="team-title" style="color:<?php echo $team->team_primary_color; ?>"><?php echo $team->team_name ?></h1>
    					</div>
    
  7. Then, to show the team stats, insert the following lines:
    				<div id="team-stats" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
    					<h4><?php echo get_option( 'sports-bench-season-year' ) . ' ' . __( 'Stats', 'sports-bench' ); ?></h4>
    					<?php echo sports_bench_get_players_stats_table( sports_bench_get_players_stats( $team->team_id,  '"' . get_option( 'sports-bench-season-year' ) . '"' ) ); ?>
    				</div>
    
  8. Finally, to show the team’s roster, insert the following lines:
    				<div id="team-roster" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
    					<h4><?php _e( 'Roster', 'sports-bench' ); ?></h4>
    					<?php echo sports_bench_show_roster( $team->team_id ); ?>
    				</div>
    
  9. All right, that’s it for the main body of the page template. Now let’s finish off the template with the sidebar.

Adding in the Sidebar

This part will be a bit challenging, but again, if you follow the directions here, you’ll do just fine. If you want, you can use this code to sort of give you a guide through what it should look like.

  1. First we need to add a conditional to see if this is a page for a single team or not. So where the get_sidebar function is in your page template, place the lines of code below. If the function is wrapped in a div with a class of “widgets” or “sidebar”, place this code inside that div and disregard that same div in the following code.
    				<?php if ( isset( $team ) ) { ?>
    					<div id="sidebar1" class="sidebar">
    					</div>
    				<?php } else { ?>
    					<?php get_sidebar(); ?>
    				<?php } ?>
    

    It should go without saying that this will replace the original get_sidebar function in your template file.

  2. The remainder of the code will go inside the <?php if ( isset( $team ) ) { ?> section. Now, to show the schedule, place the following lines of code:
    				<aside id="schedule-info" class="widget" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
                    	<h4 class="widgettitle"><?php echo $team->team_name . ' ' . get_theme_mod( 'sports-bench-season-year' ) . ' ' . __( 'Schedule', 'sports-bench' ); ?></h4>
    					<?php echo sports_bench_show_team_schedule( $team->team_id ); ?>
                    </aside>
    
  3. To show the division or conference standings for the team, place the following lines of code:
    				<aside id="standings" class="widget" style="border-top: 2px solid <?php echo $team->team_secondary_color; ?>">
                        <?php global $wpdb;
                        $table = $wpdb->prefix . 'sb_divisions';
                        $querystr = "SELECT * FROM $table WHERE division_id = $team->team_division;";
                        $division = $wpdb->get_results($querystr);
                        $division_title = $division[ 0 ]->division_name . ' ' . __( 'Standings', 'sports-bench' ); ?>
                        <h4 class="widgettitle"><?php echo $division_title; ?></h4>
    					<?php echo sports_bench_team_division_standings( $team->team_division ); ?>
                    </aside>
    
  4. Finally, to show some more team information, add the following lines of code:
    				<aside id="team-info" class="widget clearfix" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
                        <h4 class="widgettitle"><?php _e( 'Team Info', 'sports-bench' ); ?></h4>
    					<?php echo sports_bench_show_team_info( $team->team_id ); ?>
                    </aside>
    

Setting up the Team Template

Okay, we’re almost done with the team page template, but now we need to add the actual page to the site.

  1. Create a new page and name it “Teams”.
  2. On the right-hand side, look for “Page Attributes”. Then select “Team”. Then hit publish.
  3. Next, go to Sports Bench Settings. Find the Team Page setting and then select this newly created page. Hit “Publish”.
  4. After that, go to the permalinks page. This can be found under the Settings section in the admin. Don’t tough your permalinks, but hit save at the bottom. This will reset the necessary redirects to make the page work.
  5. Now navigate to your newly created team page and enjoy your hard work. You deserve it.

That’s it! You’ve now completed creating a template for the teams in your league. It’s now a one-stop-shop for all team information. Confidence in your coding skills continuing to go up? Great! We’re about to take another step up in difficulty. But you’ll do fine.

Setting Up the Players Page Template

Okay, so you’re almost complete getting everything going with your website and Sports Bench. But now we’re getting into the challenging part. However, there’s good news. With Sports Bench 1.3, you can add a player page template with a simple shortcode. Or you can learn and dig into the code and do it that way. Both ways will be shown here.

Using the Player Page Shortcode

  1. First, create a new page. Then in the new page create a new shortcode. To do this, click the “SB” button in the TinyMCE editor at the top.
  2. In the window that now appears, select “Player Page” and then insert. Then hit “Publish”.
  3. Next, navigate to the Sports Bench Options page. It should be in the menu on the left in the admin.
  4. In the options page, select your new page for the Player Page option and then hit save.
  5. After that, go to the permalinks page. This can be found under the Settings section in the admin. Don’t tough your permalinks, but hit save at the bottom. This will reset the necessary redirects to make the page work.
  6. And that’s it. Your player page is ready to go. And you didn’t even need to write a single line of code.

Using a Player Page Template

Introducing the Player Class

Before we get going too far, let’s introduce a simple concept that you’ll use here and elsewhere if you want to customize your site even further. Sports Bench comes with three classes: Sports_Bench_Game, Sports_Bench_Player and Sports_Bench_Teams. Here we’ll just look at the player class.

If you’re not too familiar with PHP or object-oriented programming, just know that adding the following to your code essentially calls the player from the database and populates it attributes without you having to write more code.

<?php $player = new Sports_Bench_Player( (int){{player_id}} ); ?>

Note that the player id will need to be an actual integer number.

From here, you can get the player’s first name, last name and so much more. In fact, here’s a list of the available attributes you can call, plus one function we’ll use to set up this page.

  • $player->player_id
  • $player->player_first_name
  • $player->player_last_name
  • $player->player_photo
  • $player->player_position
  • $player->player_home_city
  • $player->player_home_state
  • $player->player_date_of_birth
  • $player->team_id
  • $player->player_weight
  • $player->player_height
  • $player->player_slug
  • $player->get_player_photo()

So now that we’ve gone over something we’ll be using here, let’s start building the player page, shall we? If you want to learn more about the Player class and the other classes, please visit the codex page on the Sports Bench website.

Building the Player Page

So creating the player page involves creating a new page template. It’s a simple concept in WordPress, but if you’re unfamiliar with it, you can read this, this and this tutorial on how to do that. Otherwise, let’s get started.

  1. So first off, create a new page template in your theme’s main directory. Name it page-player.php
  2. Next, copy the contents of your theme’s page.php file and paste it into this new page template file.
  3. At the top underneath the opening php tag, paste the following:
    Template Name: Player
  4. Look at the body of your new page template’s contents. First find the Loop. If you’re unfamiliar with the loop, look for a section that looks like if ( have_posts() ) : while( have_posts() ) : the_post();. Inside of that, look for a <main> or <article> tag and delete everything inside of that.
  5. Replace the now-deleted code with the following:
    				<?php if ( class_exists( 'Sports_Bench_Player' ) ) { ?>
    					<?php if ( get_query_var( 'player_slug' ) ) { ?>
    					<?php } else { ?>
    					<?php } ?>
    				<?php } ?>
    
  6. From here, let’s get the simple part out of the way first. Inside the else statement, place the following line of code:
    <?php echo sports_bench_show_team_player_select(); ?>
    This will show a dropdown of teams to pick players from if there’s no player slug in the url. For a live look at what this does, click here.
  7. With that out of the way, let’s get to the fun part. Inside of the if ( get_query_var( 'player_slug' ) ) statement, first add the following:
    				<? if ( get_query_var( 'player_slug' ) ) {
    				$player = new Sports_Bench_Player(get_query_var('player_slug'));
    				$team = new Sports_Bench_Team((int)$player->team_id);
    				} ?>
    
    				<div class="player-info">
    					<?php echo sports_bench_show_player_info( $player->player_id ); ?>
    				</div>
    

    This will display the player’s photo and his/her name, height, weight, position, age and hometown if those are entered. You might have to do some styling to get the section to match your theme’s style.

  8. Finally, below the code you just pasted, place the following lines of code:
    				<div id="player-stats" class="widget" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
    					<h4 class="widgettitle"><?php echo __( 'Career Stats', 'sports-bench' ); ?></h4>
    					<?php echo sports_bench_get_season_stats( $player ); ?>
    				</div>
    

    This will show a table of the player’s career stats by season. And if you click on a season, you’ll see the game-by-game stats. And the best part, that functionality requires no code from you.

  9. Now, go create a new page. Title it “Players”. Then go down on the right side of the editor to the “Page Attributes” section and select “Player” from the page template dropdown.
  10. Next, go to the Sports Bench Settings page inside the Customizer. Then find the Player Page option and select the page you’ve just created. Then hit publish.
  11. After that, go to the permalinks page. This can be found under the Settings section in the admin. Don’t tough your permalinks, but hit save at the bottom. This will reset the necessary redirects to make the page work.
  12. Then navigate to that page. You should now see the dropdown. Pick a team and then click on a player. And now you should see his/her player page.

And that’s it! You’ve survived some intermediate coding and you’ve created a really cool player page that you can show off. You’re harnessing the power of Sports Bench. Confidence going up? Good. We’re going to take another step higher in the next section. But for now, admire your work.

Adding Game Recaps and Previews

We are so close to the finish line. You’re doing great, but now we’ve reached our toughest challenge yet. However, with this as your guide, you’ll be done with it in no time.

This section deals with post templates. Introduced in WordPress 4.7, post templates work the same as page template, but obviously with post types and an extra line of code. This is also why WordPress 4.7 is required for this plugin.

This section will cover creating game preview and game recap post templates. We’ll start easy first with game previews.

Creating the Game Preview Template

There are two ways you can create game previews. The easiest is to use the “Game” shortcode. To do this, add a new post and then hit the “SB” at the top of the editor. Then select game and then the game you want to show. And that’s all you need. If you want to create a custom post template for previews, use the directions below.

  1. Like the player and team templates, create a new php file and name it page-game-preview.php. But now, copy the contents of your theme’s single.php file. And we’re also going to leave the loop untouched. Our focus is on the sidebar.
  2. Again, like the player team templates, add the following lines of code to right after the opening php tag. Note the extra line which helps WordPress realize that this is intended for posts and not pages.
    				Template Name: Game Preview
    				Template Post Type: post
    
  3. Now that that’s taken care of, let’s turn our attention to the sidebar. Again, locate where the get_sidebar function. If it’s wrapped in a div with a class of “sidebar” or “widgets” or something of the like, you have nothing to worry about. The lines of code we’ll write later on will go right before this function. Otherwise, locate your theme’s sidebar.php file. Copy the lines of code that control the primary sidebar and replace the get_sidebar function in the template with the copied code. It might look something like this:
    				<div id="sidebar1" class="sidebar>
    					<?php if ( is_active_sidebar( 'sidebar1' ) ) : ?>
    						<?php dynamic_sidebar( 'sidebar1' ); ?>
    					<?php endif; ?>
    				</div>
    

    Note: Your sidebar.php file probably won’t look exactly like this. This is more a guide. It should, however, at least look something like it if it’s up to WordPress standards.

  4. Now, right before either the code you just pasted or the get_sidebar functions, add in the following lines of code to add a game preview “widget”. This will show the teams’ records, names and logos as well as the date, time and location of the game. If the game is final, the score will show. And if the game has a recap, a link to the recap will show as well.
    				<?php echo sports_bench_show_game_preview_info(); ?>
    
  5. So that’s all of the coding we have to do for the preview template. Now let’s add a preview. To start, add a new page. Then type a preview into the main post editor.
  6. Once you are done, go the “Post Attributes” section on the right-hand side. Select “Game Preview” from the post template dropdown. next, find the custom fields for Sports Bench. It’ll be below the main editor somewhere, depending on what plugins you have installed. There, select “Preview” and then select which game this is a preview for.
  7. Now hit “Publish” and then hit “View Post”. And that’s it. You’ve created a really cool game preview post template that adds necessary info with minimal effort from you in the future. Congrats! Now let’s move on to game recaps.

Creating the Game Recap Template

There are two ways you can create game recap areas. The easiest is to use the game recap shortcode. To do this, add a new post and then hit the “SB” at the top of the editor. Then select “Game Recap” and then the game you want to show. And that’s all you need. If you want to create a custom post template for recaps, use the directions below.

  1. Like the game preview template, create a new php file and name it page-game-recap.php and copy the contents of your theme’s single.php file into the new template.
  2. Like the game preview template, add the following lines of code right after the opening php tag:
    				Template Name: Game Recap
    				Template Post Type: post
    
  3. Again, let’s turn our attention to where the get_sidebar function is located. If it’s inside a div with the class “sidebar” or “widgets” or the like, simply delete the function since we’re overriding the default sidebar here. Otherwise, go to the sidebar.php file and copy the div that contains the actual sidebar. You don’t need any inside that div, just the outer shell. Then paste that over the get_sidebar function in the recap template.
  4. Now, inside the sidebar container that was either already there or just pasted, place the following line of code:
    				<?php echo sports_bench_show_game_stats_info(); ?>
    
  5. So that’s all the coding you have to do. But let’s add a recap just to test it out. To start go add add a new post and put some text into the main text editor.
  6. Next, scroll down on the right-hand side and find the “Post Attributes” section. Select “Game Recap” as the post template.
  7. Then find the Sports Bench custom fields. This will be somewhere below the main post editor depending on what plugins you have on your site. There select “Recap” and then select the game the recap is for.
  8. Finally, hit publish and then view the post. Congrats! You’ve now created a recap template that will show off all sorts of information from the scoreline to the team stats to the individual stats. It looks awesome.

And that’s all the code you need to get started. The best part is now, when you create a preview or a recap for a game, the link to that post will automatically show up on the team page and where the game is located on the scoreboard. It adds that extra functionality that takes your site to the next level.

Customizations

It is possible to make customization, both in the code in style. The recommended way is to make your own customization plugin so that your changes aren’t overwritten by an update. Here’s how to do that:

  1. Find the plugins directory on your web hosting and create a new directory inside of it. Call the new file ‘sports-bench-customizations’.
  2. Inside of the new directory, create a php file name sports-bench-customizations.php.
  3. Inside of the file, paste the following at the top:
    • <?php
                         /*
                         Plugin Name: Sports Bench Customizations
                         Plugin URI:
                         Description: A place to put customizations for the Sports Bench plugin
                         Version:     1.0
                         Author:
                         Author URI:
                         License:     GPL3
                         License URI: https://www.gnu.org/licenses/gpl-3.0.html
                         */
                         ?>
  4. Inside of this directory, you can include JavaScript, CSS, and other items and then call them from the php file. You can also create custom functions as well.
  5. Make sure to activate the plugin as you would any other plugin.

Setting Up the Homepage

Setting up the homepage to run as it should is a fairly quick process.

  1. Navigate to the “Customize” page in the admin. Then click “Theme Settings”.
  2. Determine if you want to hide sticky posts in the slider and home page.
  3. Determine the category to show in the slider. The suggested practice is to create a “top story” category and use that.
  4. Determine the categories to show below the slider. Each category will show up as a tab, as well as a tab with all of the latest posts.

That’s it. The theme is all set up to run as you like.

Creating a Longform Post

Creating a longform story is simple with WordPress 4.7 and the Sports Bench theme; however, for this to work, you must be using WordPress 4.7.

  • Create a post like you normally would. Typically, longform stories are over 1,000 words long, but any length will do for you.
  • Before hitting publish, scroll down to the “Post Attributes” box in the right sidebar of the page and select “Longform”.
  • Make sure you upload a large featured image as it will display across the top of the page.
  • Installation

    Plugin

    Via WordPress Dashboard
    1. If you purchased the plugin/theme package, unzip the “sports-bench” directory that comes with the download. If you purchased the plugin only, ignore this step.
    2. In the WordPress admin area, go to Plugins->Add New. Then hit “Upload Plugin” at the top of the subsequent page.
    3. Select the zipped plugin directory (i.e. sports-bench-1.0.zip) and hit “Install Now”.
    4. After the plugin is installed, click “Activate” to start using the theme.
    5. Go to the “Setup” section of this ReadMe file to get the plugin rolling for your use.
    VIia FTP Upload
    1. If you purchased the plugin/theme package, unzip the “sports-bench” directory that comes with the download. If you purchased the plugin only, ignore this step.
    2. Unzip the zipped plugin directory (i.e. sports-bench-1.0.zip).
    3. Upload the sports-bench directory inside the now-unzipped directory to the plugin directory on your site (located inside of the wp-content directory).
    4. In the WordPress admin area, go to the Plugins page and hit “Activate” underneath the Sports Bench listing on the page to begin using the theme.
    5. Go to the “Setup” section of this ReadMe file to get the plugin rolling for your use.

    Theme

    Via WordPress Dashboard
    1. If you purchased the plugin/theme package, unzip the “sports-bench” directory that comes with the download. If you purchased the theme only, ignore this step.
    2. In the WordPress admin area, go to Appearance->Themes. Click the “Add New” button at the top of the page and then hit “Upload Theme” at the top of the subsequent page.
    3. Select the zipped theme directory (i.e. sports-bench-1.0.zip) and hit Install now.
    4. After the theme is installed, click “Activate” to start using the theme.
    Via FTP Upload
    1. If you purchased the plugin/theme package, unzip the “sports-bench” directory that comes with the download. If you purchased the theme only, ignore this step.
    2. Unzip the zipped theme directory (i.e. sports-bench-1.0.zip).
    3. Upload the sports-bench directory inside the now-unzipped directory to the themes directory on your site (located inside of the wp-content directory).
    4. In the WordPress admin area, go to Appearance->Theme and hit “Activate” underneath the Sports Bench listing on the page to begin using the theme.
  • Setting Up Sports Bench

    So now you’ve got the plugin installed and activated. Before we get too far along, we need to set up a few plugin settings so that you’re ready to go.

    1. Go to the Sports Bench Options page after activating the plugin. The link can be found in the admin menu on the left side.
    2. First, select a sport. Currently, baseball, basketball, (American) Football, Hockey and Soccer (Football) are supported. Please note that if you select a sport, comeback to the option and change it, all games will be lost.
    3. Add the current season. The default is the current year. Please make note of how you format the year(s) here. You’ll need it when you start to create games later on. Make sure to update this setting when you start a new season.
    4. Determine whether or not you want to display games by week or not. This option determines how games are shown on the scoreboard. If you don’t select this option, you can disregard the “Week” field when creating games. Otherwise, next enter the current week of the season. You’ll update this setting a lot.
    5. If you have a or want a page to show team pages, select the page that is using the team page template. This will direct team links to this page. If you haven’t created the page for the teams, you can come back to this later. We’ll get into more detail later on in the guide.
    6. If you have a or want a page to show player pages, select the page that is using the player page template. This will direct player links to this page. If you haven’t created the page for the players, you can come back to this later. We’ll get into more detail later on in the guide.
  • Creating a Division

    All right, now we’ve got our settings taken care of we can start adding some data. At first you’ll probably be tempted to create teams right now, but most leagues divide their teams up into divisions, conferences or leagues, so let’s start there first. This way it will be much easier once we start adding teams.

    1. To start adding divisions, hover over the “Teams” item in the menu in the admin area of your site. Then click on “Divisions” in the submenu that appears.
    2. The divisions page is set up nearly identical to the categories page in WordPress where the divisions are listed on the right and you can add divisions or conferences on the left.
    3. To add a division or conference, first fill out the name of the division or conference.
    4. Then select if this is a division or a conference.
    5. If this is a conference, select the color for the conference. This is optional, but the color appears a border between the table head and table body wherever the standings appear.
    6. If this is a division, select the conference the division belongs to. The recommended practice is to add conferences first and then add divisions, if that is your set up.
    7. Then hit save. The page will reload and your new item will show up on the left. Repeat this process until all of your divisions and conferences are added.
  • Creating a Team

    At this point we’ve installed the plugin, got the settings taken care of and added our conferences and divisions. Now it’s finally time to add in the teams.

    1. To start adding teams, hover over the “Teams” item in the admin area of your site. Then click “Add New” in the submenu that appears.
    2. Starting at the top, add the full team name (i.e. Texas Rangers, Seattle Seahawks, FC Dallas).
    3. Then enter the team location. If the team has a location and nickname, put just the city or state (i.e. Texas, Seattle). If the team has no nickname, like FC Dallas or D.C. United, put the full name here again and leave the nickname field next blank.
    4. Enter in the nickname of the team if there is one (i.e. Ranger, Seahawks).
    5. Next enter the three or four letter abbreviation of the team (i.e. TEX, SEA, FCD).
    6. Next select whether the team is active or inactive. The default setting is always active. This only changes to inactive if the team takes a hiatus or folds.
    7. Then enter the city and the state where the team is located.
    8. Next enter the stadium name and the capacity of the stadium.
    9. Then enter the name of the head coach.
    10. Next select what division or conference the team is placed in.
    11. Then enter the primary and secondary colors for the team.
    12. Next, on the right hand side, upload the team’s logo.
    13. Then you can add a photo of the team below the logo. This is an optional item.
    14. Finally, hit save at the bottom. You’ve now created your first team. Congrats! Now repeat these steps to add your remaining teams.
  • Creating a Player

    So we’ve added our teams. Now it’s time to add our players to these teams.

    1. To start adding players, hover over the “Players” item in the admin area of your site. Then click “Add New” in the submenu that appears.
    2. Enter in the first and last name of the player.
    3. Then select the team the player plays for, or select “Free Agent” if the player has no team.
    4. Next use the date picker to select the player’s birthday.
    5. Then either enter or select the position the player page.
    6. Next add the height and weight of the player if you want to.
    7. Then enter the city and state name of the player’s hometown if you so wish.
    8. Add a photo of the player on the right side of the page, if you wish.
    9. Finally, hit save at the bottom. You’ve now created your first player. Congrats. Now repeat these steps to add your remaining players.
  • Creating a Game

    So we’ve added our teams and their players. Now it’s time to add games to the schedule. This is the most complicated of the admin pages associated with the plugin, but if you follow these steps, you’ll have no issue adding games and game stats.

    1. To start adding games, hover over the “Games” item in the admin area of your site. Then click “Add New” in the submenu that appears.
    2. Select the home and away teams for the game.
    3. Then select whether this game is a scheduled game, a game in progress or a game that is final.
    4. If this is a game that’s in progress, another section will appear below. Here you’ll enter the current score for the home and away teams and the current time and period (or minute of the match for soccer or inning for baseball) of the game.
    5. In the game information row, enter the season the game is taking place in. If you’re sorting your games by week, add the week number. Then add the date and time of the game and the attendance of the game (if applicable).
      • If this game is listed as a scheduled game, you don’t need to go any further. Hit save right here and you’re done! You’ve added your first game. Otherwise, continue on.
    6. In this next section, add the scoreline for the game. If this is a baseball game, enter in the runs, hits, errors and men/women left on base. Otherwise, enter the scoring by quarter, period or half. The final column on the right will automatically add up the total for each team.
    7. Next add the game/match events for the game. This differs from sport to sport, but the column headings wil point you in the right direction. You can add as many game events as needed with the button at the bottom. You can also remove game events with the remove button at the end of each row.
      • Note: Basketball games do not have this section.
      • If this game is listed as an in-progress game, you don’t need to go any further. Hit save right here and you’re done! You’ve added your first game. Otherwise, continue on.
    8. Then add in the team stats for the game. Again, this differs depending on the sport, but the titles in the center will help you along.
    9. Next add in the individual player stats for the home and away teams. The players will be loaded in a dropdown on the left when you select the teams at the top. Again, the stats you’ll need to enter differ depending on the sport, but the column headings will guide you along. You can add as many players as you need with the button at the bottom of each section. You can also remove players with the remove button at the end of each row.
    10. Finally, hit the save button at the bottom of the page. You’ve now created your first game complete with all of the stats. Congrats! Now just repeat the process whenever you need to add or edit games.
  • Creating a Playoff Bracket

    Okay so now an entire season has gone by and it’s time for playoffs. (And yes Jim Mora, we’re talking about playoffs). Sports Bench makes it easy for you to create playoff brackets to show off who your one true champion really is.

    • To add a playoff bracket, hover over the “Playoffs” item in the admin area of your site. Then click “Add New” in the submenu that appears.
    • Next give the bracket a name. Then select the number of teams that will be in the tournament, select whether it’s a single or double elimination tournament and then select the season the bracket takes place in.
    • For each playoff match up, select both teams from the dropdowns provided. Give each of them their seeding (if applicable). Then select whether this is a one, two, three, five or seven game series. Finally, select the game that applies to each game in the series from the dropdowns below.
    • Repeat the previous step until the bracket is filled out as much as it can be. The score section on the right will update automatically, but you will have to select the winners by hand like the previous step.
    • When you’re done, hit save. And that’s it. You’ve created your first playoff bracket!
  • Adding Scoreboard, Standings and Stats Pages

    All right, so we’ve got the plugin installed and setup. We have our divisions, teams, players and some games. Now how will we display this data. Fortunately, Sports Bench makes it easy for you to display standings, scoreboards and stats leaderboards on pages (and even posts) thanks to shortcodes. This section will take you through how to do that.

    • First start a new page or post. Then click the “SB” logo near the top of the visual editor. This will open up a modal where you can select a number of different shortcodes.
    • If you want to add a scoreboard, select “Scoreboard” and then hit insert. Now when you view the page or post, a scoreboard will be displayed.
    • If you want to add standings, select “Standings” and then hit insert. Then a few options will appear below the editor. If it doesn’t appear right away, give it a few seconds. In the options, you can show league, conference and division standings and show home, away, division and conference records and points for and against and points differential. You can add and remove items if you need to using the buttons in the options.
    • If you want to add a stats leaderboard, select “Stats” and then hit insert. Then an options panel will appear below the editor. Here, you can chose which stats show up on the page. You can add as many stats as you like to the page.
    • That’s it. You can create pages that show a scoreboard, standings and stats without writing a single line of code!
  • Using the Shortcodes

    But your shortcode options aren’t just limited to standings, you can also use shortcodes to show playoff brackets, game information, players and teams.

    • To begin using a shortcodes, first start a new page or post. Then click the “SB” logo near the top of the visual editor. This will open up a modal where you can select a number of different shortcodes.
    • If you want to add a game shortcode, select “Game” and then select a season. From there, select a game from that season. The shortcode will then show the teams competing in the game as well as the time, date and location of the game. If the game is finished and has a recap, a link to the recap will show as well.
    • If you want to add a player shortcode, select “Player” and then select a player from the list that appears. The shortcode will display the player’s photo and information and their recent stats.
    • If you want to add a team shortcode, select “Team” and then select a team from the list that appears. The shortcode will display the team’s logo and information and their recent games and upcoming schedule.
    • If you want to add a playoff shortcode, select “Playoff Brackets” and then select a playoff bracket from the list that appears. This will display the bracket in table form on the front end.
    • If you want to add a rivalry shortcode, select “Rivalry” and then select the two teams that you want to display stats for. This will display the series records between the two teams and their recent results against each other.
    • If you want to add a team page shortcode, select “Team Page”. Next, please find the “Creating a Team Page” section of the guide and follow those instructions.
    • If you want to add a player page shortcode, select “Player Page”. Next, please find the “Creating a Player Page” section of the guide and follow those instructions.
    • If you want to add a game recap shortcode, select “Game Recap” and then select the game you want to show a recap for.
    • That’s it. You can now display a lot of cool information in your posts and pages without writing a single line of code!
  • Using the Widgets

    Want to display information that appears in the sidebar wherever your viewers go? Sports Bench has widgets so you can display a scoreboard, standings and stats on every page with a widget area.

    • Navigate to the Widgets page in the admin area.
    • To add a scoreboard widget, click and drag the “Sports Bench Scoreboard” widget to the desired widget area. Give it a title and hit “Save”. That’s it.
    • To add a standings widget, click and drag the “Sports Bench Standings” widget to the desired widget area. Give it a title, select whether it will show the league, conference or division standings and then hit “Save”. That’s it.
    • To add a stats widget, click and drag the “Sports Bench Statistic” widget to the desired widget area. Give it a title, select which statistic to show and then hit “Save”. That’s it.
  • Setting Up the Teams Page Template

    Okay so you’ve created a new page template and shown player information. Now we’re going to do the same for teams, but the level of difficulty is going to go up a bit. But don’t worry. Once again, if you follow these directions, you’ll be feeling like a real programmer by the time it’s over. And if you want, there’s a shortcode you can use to create the team page instead.

    Using the Team Page Shortcode

    1. First, create a new page. Then in the new page create a new shortcode. To do this, click the “SB” button in the TinyMCE editor at the top.
    2. In the window that now appears, select “Team Page” and then insert. Then hit “Publish”.
    3. Next, navigate to the Sports Bench Options page. It should be in the menu on the left in the admin.
    4. In the options page, select your new page for the Team Page option and then hit save.
    5. After that, go to the permalinks page. This can be found under the Settings section in the admin. Don’t tough your permalinks, but hit save at the bottom. This will reset the necessary redirects to make the page work.
    6. And that’s it. Your team page is ready to go. And you didn’t even need to write a single line of code.

    Using a Team Page Template

    Introducing the Team Class

    Before we get going too far, let’s introduce the Sports_Bench_Team class.

    Once again, if you’re not too familiar with PHP or object-oriented programming, just know that adding the following to your code essentially calls the team from the database and populates it attributes without you having to write more code.

    <?php $team = new Sports_Bench_Team( (int){{team_id}} ); ?>

    Note that the team id will need to be an actual integer number.

    From here, you can get the team name, location and so much more. In fact, here’s a list of the available attributes you can call, plus one function we’ll use to set up this page.

    • $team->team_id
    • $team->team_name
    • $team->team_location
    • $team->team_nickname
    • $team->team_abbreviation
    • $team->team_active
    • $team->team_city
    • $team->team_state
    • $team->team_stadium
    • $team->team_stadium_capacity
    • $team->team_head_coach
    • $team->team_logo
    • $team->team_photo
    • $team->team_division
    • $team->team_primary_color
    • $team->team_secondary_color
    • $team->player_slug
    • $team->team_slug
    • $team->get_schedule()
    • $team->get_roster()
    • $team->get_team_photo()
    • $team->get_division_name()

    So now that we’ve gone over something we’ll be using here, let’s start building the player page, shall we? If you want to learn more about the Player class and the other classes, please visit the codex page on the Sports Bench website.

    Building the Team Page

    Like the player page, creating the team page involves creating a new page template. It’s a simple concept in WordPress, but if you’re unfamiliar with it, you can read this, this and this tutorial on how to do that. Otherwise, let’s get started.

    1. So first off, create a new page template in your theme’s main directory. Name it page-team.php
    2. Next, copy the contents of your theme’s page.php file and paste it into this new page template file.
    3. At the top underneath the opening php tag, paste the following:
      Template Name: Team
    4. Now, this is where things get a bit trickier. In this file, look for the get_sidebar() function. If this is wrapped in a div tag that has a class or id of “widget” or sidebar, then don’t do anything with it. Otherwise, find your theme’s sidebar.php In this file look for a div tag with a class or id of “widget” or “sidebar”. Copy this div and paste it in the new template file above the get_sidebar function. Make sure the closing </div> tag is there as well.
    5. Once you’ve done that, take a quick breather. We’re going to divide the rest of this into two parts: the main body and the sidebar.

    Building the Main Body of the Page

    1. Like the player page, find the loop and delete everything within either a main or article div. Then inside of that, paste the following lines of code:
      					<?php if ( class_exists( 'Sports_Bench_Team' ) ) { ?>
      						<?php if ( get_query_var( 'team_slug' ) ) { ?>
      						<?php } else { ?>
      						<?php } ?>
      					<?php } ?>
      
    2. Then inside the else part of the statement, paste the following code: <?php echo sports_bench_show_team_listing(); ?>.
    3. The rest of this section will deal with code going inside the <?php if ( class_exists( 'Sports_Bench_Team' ) ) { ?> section.
    4. To show the team photo, insert the following lines:
      				<div class="team-photo">
                      	<?php echo $team->get_team_photo( 'team-photo' ); ?>
      				</div>
      
    5. To show the team logo, insert the following lines:
      					<div class="team-logo">
      						<?php echo $team->get_team_photo( 'team-logo' ); ?>
      					</div>
      
    6. To show the team name, insert the following lines:
      					<div class="team-name">
      						<h1 class="team-title" style="color:<?php echo $team->team_primary_color; ?>"><?php echo $team->team_name ?></h1>
      					</div>
      
    7. Then, to show the team stats, insert the following lines:
      				<div id="team-stats" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
      					<h4><?php echo get_option( 'sports-bench-season-year' ) . ' ' . __( 'Stats', 'sports-bench' ); ?></h4>
      					<?php echo sports_bench_get_players_stats_table( sports_bench_get_players_stats( $team->team_id,  '"' . get_option( 'sports-bench-season-year' ) . '"' ) ); ?>
      				</div>
      
    8. Finally, to show the team’s roster, insert the following lines:
      				<div id="team-roster" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
      					<h4><?php _e( 'Roster', 'sports-bench' ); ?></h4>
      					<?php echo sports_bench_show_roster( $team->team_id ); ?>
      				</div>
      
    9. All right, that’s it for the main body of the page template. Now let’s finish off the template with the sidebar.

    Adding in the Sidebar

    This part will be a bit challenging, but again, if you follow the directions here, you’ll do just fine. If you want, you can use this code to sort of give you a guide through what it should look like.

    1. First we need to add a conditional to see if this is a page for a single team or not. So where the get_sidebar function is in your page template, place the lines of code below. If the function is wrapped in a div with a class of “widgets” or “sidebar”, place this code inside that div and disregard that same div in the following code.
      				<?php if ( isset( $team ) ) { ?>
      					<div id="sidebar1" class="sidebar">
      					</div>
      				<?php } else { ?>
      					<?php get_sidebar(); ?>
      				<?php } ?>
      

      It should go without saying that this will replace the original get_sidebar function in your template file.

    2. The remainder of the code will go inside the <?php if ( isset( $team ) ) { ?> section. Now, to show the schedule, place the following lines of code:
      				<aside id="schedule-info" class="widget" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
                      	<h4 class="widgettitle"><?php echo $team->team_name . ' ' . get_theme_mod( 'sports-bench-season-year' ) . ' ' . __( 'Schedule', 'sports-bench' ); ?></h4>
      					<?php echo sports_bench_show_team_schedule( $team->team_id ); ?>
                      </aside>
      
    3. To show the division or conference standings for the team, place the following lines of code:
      				<aside id="standings" class="widget" style="border-top: 2px solid <?php echo $team->team_secondary_color; ?>">
                          <?php global $wpdb;
                          $table = $wpdb->prefix . 'sb_divisions';
                          $querystr = "SELECT * FROM $table WHERE division_id = $team->team_division;";
                          $division = $wpdb->get_results($querystr);
                          $division_title = $division[ 0 ]->division_name . ' ' . __( 'Standings', 'sports-bench' ); ?>
                          <h4 class="widgettitle"><?php echo $division_title; ?></h4>
      					<?php echo sports_bench_team_division_standings( $team->team_division ); ?>
                      </aside>
      
    4. Finally, to show some more team information, add the following lines of code:
      				<aside id="team-info" class="widget clearfix" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
                          <h4 class="widgettitle"><?php _e( 'Team Info', 'sports-bench' ); ?></h4>
      					<?php echo sports_bench_show_team_info( $team->team_id ); ?>
                      </aside>
      

    Setting up the Team Template

    Okay, we’re almost done with the team page template, but now we need to add the actual page to the site.

    1. Create a new page and name it “Teams”.
    2. On the right-hand side, look for “Page Attributes”. Then select “Team”. Then hit publish.
    3. Next, go to Sports Bench Settings. Find the Team Page setting and then select this newly created page. Hit “Publish”.
    4. After that, go to the permalinks page. This can be found under the Settings section in the admin. Don’t tough your permalinks, but hit save at the bottom. This will reset the necessary redirects to make the page work.
    5. Now navigate to your newly created team page and enjoy your hard work. You deserve it.

    That’s it! You’ve now completed creating a template for the teams in your league. It’s now a one-stop-shop for all team information. Confidence in your coding skills continuing to go up? Great! We’re about to take another step up in difficulty. But you’ll do fine.

  • Setting Up the Players Page Template

    Okay, so you’re almost complete getting everything going with your website and Sports Bench. But now we’re getting into the challenging part. However, there’s good news. With Sports Bench 1.3, you can add a player page template with a simple shortcode. Or you can learn and dig into the code and do it that way. Both ways will be shown here.

    Using the Player Page Shortcode

    1. First, create a new page. Then in the new page create a new shortcode. To do this, click the “SB” button in the TinyMCE editor at the top.
    2. In the window that now appears, select “Player Page” and then insert. Then hit “Publish”.
    3. Next, navigate to the Sports Bench Options page. It should be in the menu on the left in the admin.
    4. In the options page, select your new page for the Player Page option and then hit save.
    5. After that, go to the permalinks page. This can be found under the Settings section in the admin. Don’t tough your permalinks, but hit save at the bottom. This will reset the necessary redirects to make the page work.
    6. And that’s it. Your player page is ready to go. And you didn’t even need to write a single line of code.

    Using a Player Page Template

    Introducing the Player Class

    Before we get going too far, let’s introduce a simple concept that you’ll use here and elsewhere if you want to customize your site even further. Sports Bench comes with three classes: Sports_Bench_Game, Sports_Bench_Player and Sports_Bench_Teams. Here we’ll just look at the player class.

    If you’re not too familiar with PHP or object-oriented programming, just know that adding the following to your code essentially calls the player from the database and populates it attributes without you having to write more code.

    <?php $player = new Sports_Bench_Player( (int){{player_id}} ); ?>

    Note that the player id will need to be an actual integer number.

    From here, you can get the player’s first name, last name and so much more. In fact, here’s a list of the available attributes you can call, plus one function we’ll use to set up this page.

    • $player->player_id
    • $player->player_first_name
    • $player->player_last_name
    • $player->player_photo
    • $player->player_position
    • $player->player_home_city
    • $player->player_home_state
    • $player->player_date_of_birth
    • $player->team_id
    • $player->player_weight
    • $player->player_height
    • $player->player_slug
    • $player->get_player_photo()

    So now that we’ve gone over something we’ll be using here, let’s start building the player page, shall we? If you want to learn more about the Player class and the other classes, please visit the codex page on the Sports Bench website.

    Building the Player Page

    So creating the player page involves creating a new page template. It’s a simple concept in WordPress, but if you’re unfamiliar with it, you can read this, this and this tutorial on how to do that. Otherwise, let’s get started.

    1. So first off, create a new page template in your theme’s main directory. Name it page-player.php
    2. Next, copy the contents of your theme’s page.php file and paste it into this new page template file.
    3. At the top underneath the opening php tag, paste the following:
      Template Name: Player
    4. Look at the body of your new page template’s contents. First find the Loop. If you’re unfamiliar with the loop, look for a section that looks like if ( have_posts() ) : while( have_posts() ) : the_post();. Inside of that, look for a <main> or <article> tag and delete everything inside of that.
    5. Replace the now-deleted code with the following:
      				<?php if ( class_exists( 'Sports_Bench_Player' ) ) { ?>
      					<?php if ( get_query_var( 'player_slug' ) ) { ?>
      					<?php } else { ?>
      					<?php } ?>
      				<?php } ?>
      
    6. From here, let’s get the simple part out of the way first. Inside the else statement, place the following line of code:
      <?php echo sports_bench_show_team_player_select(); ?>
      This will show a dropdown of teams to pick players from if there’s no player slug in the url. For a live look at what this does, click here.
    7. With that out of the way, let’s get to the fun part. Inside of the if ( get_query_var( 'player_slug' ) ) statement, first add the following:
      				<? if ( get_query_var( 'player_slug' ) ) {
      				$player = new Sports_Bench_Player(get_query_var('player_slug'));
      				$team = new Sports_Bench_Team((int)$player->team_id);
      				} ?>
      
      				<div class="player-info">
      					<?php echo sports_bench_show_player_info( $player->player_id ); ?>
      				</div>
      

      This will display the player’s photo and his/her name, height, weight, position, age and hometown if those are entered. You might have to do some styling to get the section to match your theme’s style.

    8. Finally, below the code you just pasted, place the following lines of code:
      				<div id="player-stats" class="widget" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
      					<h4 class="widgettitle"><?php echo __( 'Career Stats', 'sports-bench' ); ?></h4>
      					<?php echo sports_bench_get_season_stats( $player ); ?>
      				</div>
      

      This will show a table of the player’s career stats by season. And if you click on a season, you’ll see the game-by-game stats. And the best part, that functionality requires no code from you.

    9. Now, go create a new page. Title it “Players”. Then go down on the right side of the editor to the “Page Attributes” section and select “Player” from the page template dropdown.
    10. Next, go to the Sports Bench Settings page inside the Customizer. Then find the Player Page option and select the page you’ve just created. Then hit publish.
    11. After that, go to the permalinks page. This can be found under the Settings section in the admin. Don’t tough your permalinks, but hit save at the bottom. This will reset the necessary redirects to make the page work.
    12. Then navigate to that page. You should now see the dropdown. Pick a team and then click on a player. And now you should see his/her player page.

    And that’s it! You’ve survived some intermediate coding and you’ve created a really cool player page that you can show off. You’re harnessing the power of Sports Bench. Confidence going up? Good. We’re going to take another step higher in the next section. But for now, admire your work.

  • Adding Game Recaps and Previews

    We are so close to the finish line. You’re doing great, but now we’ve reached our toughest challenge yet. However, with this as your guide, you’ll be done with it in no time.

    This section deals with post templates. Introduced in WordPress 4.7, post templates work the same as page template, but obviously with post types and an extra line of code. This is also why WordPress 4.7 is required for this plugin.

    This section will cover creating game preview and game recap post templates. We’ll start easy first with game previews.

    Creating the Game Preview Template

    There are two ways you can create game previews. The easiest is to use the “Game” shortcode. To do this, add a new post and then hit the “SB” at the top of the editor. Then select game and then the game you want to show. And that’s all you need. If you want to create a custom post template for previews, use the directions below.

    1. Like the player and team templates, create a new php file and name it page-game-preview.php. But now, copy the contents of your theme’s single.php file. And we’re also going to leave the loop untouched. Our focus is on the sidebar.
    2. Again, like the player team templates, add the following lines of code to right after the opening php tag. Note the extra line which helps WordPress realize that this is intended for posts and not pages.
      				Template Name: Game Preview
      				Template Post Type: post
      
    3. Now that that’s taken care of, let’s turn our attention to the sidebar. Again, locate where the get_sidebar function. If it’s wrapped in a div with a class of “sidebar” or “widgets” or something of the like, you have nothing to worry about. The lines of code we’ll write later on will go right before this function. Otherwise, locate your theme’s sidebar.php file. Copy the lines of code that control the primary sidebar and replace the get_sidebar function in the template with the copied code. It might look something like this:
      				<div id="sidebar1" class="sidebar>
      					<?php if ( is_active_sidebar( 'sidebar1' ) ) : ?>
      						<?php dynamic_sidebar( 'sidebar1' ); ?>
      					<?php endif; ?>
      				</div>
      

      Note: Your sidebar.php file probably won’t look exactly like this. This is more a guide. It should, however, at least look something like it if it’s up to WordPress standards.

    4. Now, right before either the code you just pasted or the get_sidebar functions, add in the following lines of code to add a game preview “widget”. This will show the teams’ records, names and logos as well as the date, time and location of the game. If the game is final, the score will show. And if the game has a recap, a link to the recap will show as well.
      				<?php echo sports_bench_show_game_preview_info(); ?>
      
    5. So that’s all of the coding we have to do for the preview template. Now let’s add a preview. To start, add a new page. Then type a preview into the main post editor.
    6. Once you are done, go the “Post Attributes” section on the right-hand side. Select “Game Preview” from the post template dropdown. next, find the custom fields for Sports Bench. It’ll be below the main editor somewhere, depending on what plugins you have installed. There, select “Preview” and then select which game this is a preview for.
    7. Now hit “Publish” and then hit “View Post”. And that’s it. You’ve created a really cool game preview post template that adds necessary info with minimal effort from you in the future. Congrats! Now let’s move on to game recaps.

    Creating the Game Recap Template

    There are two ways you can create game recap areas. The easiest is to use the game recap shortcode. To do this, add a new post and then hit the “SB” at the top of the editor. Then select “Game Recap” and then the game you want to show. And that’s all you need. If you want to create a custom post template for recaps, use the directions below.

    1. Like the game preview template, create a new php file and name it page-game-recap.php and copy the contents of your theme’s single.php file into the new template.
    2. Like the game preview template, add the following lines of code right after the opening php tag:
      				Template Name: Game Recap
      				Template Post Type: post
      
    3. Again, let’s turn our attention to where the get_sidebar function is located. If it’s inside a div with the class “sidebar” or “widgets” or the like, simply delete the function since we’re overriding the default sidebar here. Otherwise, go to the sidebar.php file and copy the div that contains the actual sidebar. You don’t need any inside that div, just the outer shell. Then paste that over the get_sidebar function in the recap template.
    4. Now, inside the sidebar container that was either already there or just pasted, place the following line of code:
      				<?php echo sports_bench_show_game_stats_info(); ?>
      
    5. So that’s all the coding you have to do. But let’s add a recap just to test it out. To start go add add a new post and put some text into the main text editor.
    6. Next, scroll down on the right-hand side and find the “Post Attributes” section. Select “Game Recap” as the post template.
    7. Then find the Sports Bench custom fields. This will be somewhere below the main post editor depending on what plugins you have on your site. There select “Recap” and then select the game the recap is for.
    8. Finally, hit publish and then view the post. Congrats! You’ve now created a recap template that will show off all sorts of information from the scoreline to the team stats to the individual stats. It looks awesome.

    And that’s all the code you need to get started. The best part is now, when you create a preview or a recap for a game, the link to that post will automatically show up on the team page and where the game is located on the scoreboard. It adds that extra functionality that takes your site to the next level.

  • Customizations

    It is possible to make customization, both in the code in style. The recommended way is to make your own customization plugin so that your changes aren’t overwritten by an update. Here’s how to do that:

    1. Find the plugins directory on your web hosting and create a new directory inside of it. Call the new file ‘sports-bench-customizations’.
    2. Inside of the new directory, create a php file name sports-bench-customizations.php.
    3. Inside of the file, paste the following at the top:
      • <?php
                           /*
                           Plugin Name: Sports Bench Customizations
                           Plugin URI:
                           Description: A place to put customizations for the Sports Bench plugin
                           Version:     1.0
                           Author:
                           Author URI:
                           License:     GPL3
                           License URI: https://www.gnu.org/licenses/gpl-3.0.html
                           */
                           ?>
    4. Inside of this directory, you can include JavaScript, CSS, and other items and then call them from the php file. You can also create custom functions as well.
    5. Make sure to activate the plugin as you would any other plugin.
  • Setting Up the Homepage

    Setting up the homepage to run as it should is a fairly quick process.

    1. Navigate to the “Customize” page in the admin. Then click “Theme Settings”.
    2. Determine if you want to hide sticky posts in the slider and home page.
    3. Determine the category to show in the slider. The suggested practice is to create a “top story” category and use that.
    4. Determine the categories to show below the slider. Each category will show up as a tab, as well as a tab with all of the latest posts.

    That’s it. The theme is all set up to run as you like.

  • Creating a Longform Post

    Creating a longform story is simple with WordPress 4.7 and the Sports Bench theme; however, for this to work, you must be using WordPress 4.7.

    • Create a post like you normally would. Typically, longform stories are over 1,000 words long, but any length will do for you.
    • Before hitting publish, scroll down to the “Post Attributes” box in the right sidebar of the page and select “Longform”.
    • Make sure you upload a large featured image as it will display across the top of the page.

Codex

Already have the plugin? Want to know how to do cool and different stuff with it? Click the button below to explore the Codex section to customize your copy of the plugin.

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

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

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

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

Playoff Functions

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

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

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

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

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

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

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

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.

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)

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
  • 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
  • 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
  • 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
  • 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
  • Playoff Functions

    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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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.

    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)

  • 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
View Codex

See Sports Bench in Action

Want to see Sports Bench in action before deciding whether to purchase it or not? Click the link below to see the demo, where you can see all of the features the plugin and theme combo has to offer.

View Demo

Pricing Information

Plugin Only

  • Ability to integrate the plugin into a theme you’re already using.
  • Complete codex to customize usage of the plugin with the theme you already use.
  • Ability to add more functions and other customizations to the plugin.
$25.00

Plugin and Theme

  • Full integration between the theme and plugin with no extra work needed.
  • Comes with page templates for standings, scoreboards, stats, teams and players already created.
  • Complete codex to customize the theme and plugin to your liking.
  • Ability to add more functions and other customizations to the plugin.
$35.00

Theme Only

  • Nice, clean and modern WordPress theme.
  • Full-width featured post slider on the home page.
  • Tabbed post home page.
  • Social media options.
$10.00
Purchase

Other Documentation

Changelog

1.4 – December 6, 2017

Plugin
  • Added support for rugby and volleyball.
  • Added links to opposing teams from the team schedule.
  • Hid game time if it’s set to midnight. This helps for games with a TBA or TBD game time.
  • Added a shortcode to list teams by division or conference.
  • Added support for neutral site games.
  • Added the ability to include a Google Map with game previews.
  • Added an options endpoint for Sports Bench options.
  • Added the ability to display a link to a page in the scoreboard, standings and stats widgets.
  • Changed row class from “row” to “sports-bench-row” to eliminate conflicts with Bootstrap.
  • Added a team schedule widget.
  • Added the ability to add, create, update and delete items for brackets, divisions, games, game events, game stats, players, playoff series and teams with the WP REST API.
  • Other fixes to make Sports Bench better.
  • Tested with WordPress 4.9.
Theme
  • Added an option to show the homepage slider full-width or at a max-width of 1200px.
  • Tested with WordPress 4.9.

1.3 – September 6, 2017

Plugin
  • Changed some AJAX functions to use the WP REST API.
  • Added rivalry, team page, player page and game recap shortcodes.
  • Added Sports Bench Options page and removed the options from the Customizer.
  • Added a CSV import function.
Theme
  • Changed the sidebar on the player page template to show team information.

1.2.3 – August 3, 2017

Plugin
  • Fixed issue with date picker not showing up on add/edit player page.

1.2.2 – August 3, 2017

Plugin
  • Fixed issue with players not saving.
  • Fixed issue with games not saving because of difference in initial sport in ‘Add Game’ and the database.

1.2.1 – June 21, 2017

Plugin
  • Added better functionality for WP REST API routes, including the ability to group stats by players.
  • Fixed strip slashes issue with player’s height.

1.2 – June 7, 2017

Plugin
  • Fixed error that shows up in the standings widget and standings dashboard widget when there are no teams in the database.
  • Fixed issue with keepers not showing up in the right spot in the game recaps.
  • Changed the style of the teams adn players admin listing and edit pages to match the style of the games admin pages.
  • Added the ability to create playoff brackets.
  • Added an active/inactive option for teams.
  • Made “Free Agent” a team choice for players.
  • Redesigned the games dashboard widget to match the style of the games listing page.
  • Added shortcodes to show the scoreboard, standings or stats.
  • Fixed other minor issues with the plugin.
  • Tested to work with WordPress 4.8.
Theme
  • Fixed issue slider arrows not showing up and centered them vertically.
  • Fixed issue with header covering up top part of post title in the slider.
  • Centered the post title, details and excerpt vertically inside the slider.
  • Tested to work with WordPress 4.8.

1.1- January 7, 2017

Plugin
  • Added custom routes to the WP REST API for all tables.
  • Added standings and games dashboard widgets.
  • Changed the style of the game list page and add/edit game page to make adding game stats much easier.
Theme
  • Vertically centered the post title and information on the longform template.

1.0

  • Initial release to the world.

Licenses

GNU General Public License

http://www.gnu.org/licenses/gpl.html

Photo License

Except where otherwise noted, all photos in the screenshot are also licensed under the GNU General Public License. Copyright 2015 Jacob Martella

Social Media Icons License

All of the social media icons are licensed under the GNU General Public License (http://www.gnu.org/licenses/gpl.html).

Scripts License

All of the scripts used in this theme are licensed under the GNU General Public License (http://www.gnu.org/licenses/gpl.html).

Fonts License

PlayfairDisplay-Regular.ttf: Copyright (c) 2010-2012 by Claus Eggers Sørensen (es@forthehearts.net), with Reserved Font Name ‘Playfair’

PlayfairDisplay-Italic.ttf: Copyright (c) 2010-2012 by Claus Eggers Sørensen (es@forthehearts.net), with Reserved Font Name ‘Playfair’

PlayfairDisplay-Bold.ttf: Copyright (c) 2010-2012 by Claus Eggers Sørensen (es@forthehearts.net), with Reserved Font Name ‘Playfair’

Roboto-Light.ttf: Copyright 2011 Google Inc. All Rights Reserved.

Roboto-LightItalic.ttf: Copyright 2011 Google Inc. All Rights Reserved.

Roboto-Regular.ttf: Copyright 2011 Google Inc. All Rights Reserved.

Roboto-Italic.ttf: Copyright 2011 Google Inc. All Rights Reserved.

Roboto-Bold.ttf: Copyright 2011 Google Inc. All Rights Reserved.

Oswald-Regular.ttf: Copyright (c) 2011-2012, Vernon Adams (vern@newtypography.co.uk), with Reserved Font Names ‘Oswald’

Oswald-Bold.ttf: Copyright (c) 2011-2012, Vernon Adams (vern@newtypography.co.uk), with Reserved Font Names ‘Oswald’

Foundation License

Foundation is licensed under the MIT license. http://www.opensource.org/licenses/mit-license.php

JointsWP License

JointsWP is licensed under the GNU General Public License. http://www.gnu.org/licenses/gpl.html

  • Changelog

    1.4 – December 6, 2017

    Plugin
    • Added support for rugby and volleyball.
    • Added links to opposing teams from the team schedule.
    • Hid game time if it’s set to midnight. This helps for games with a TBA or TBD game time.
    • Added a shortcode to list teams by division or conference.
    • Added support for neutral site games.
    • Added the ability to include a Google Map with game previews.
    • Added an options endpoint for Sports Bench options.
    • Added the ability to display a link to a page in the scoreboard, standings and stats widgets.
    • Changed row class from “row” to “sports-bench-row” to eliminate conflicts with Bootstrap.
    • Added a team schedule widget.
    • Added the ability to add, create, update and delete items for brackets, divisions, games, game events, game stats, players, playoff series and teams with the WP REST API.
    • Other fixes to make Sports Bench better.
    • Tested with WordPress 4.9.
    Theme
    • Added an option to show the homepage slider full-width or at a max-width of 1200px.
    • Tested with WordPress 4.9.

    1.3 – September 6, 2017

    Plugin
    • Changed some AJAX functions to use the WP REST API.
    • Added rivalry, team page, player page and game recap shortcodes.
    • Added Sports Bench Options page and removed the options from the Customizer.
    • Added a CSV import function.
    Theme
    • Changed the sidebar on the player page template to show team information.

    1.2.3 – August 3, 2017

    Plugin
    • Fixed issue with date picker not showing up on add/edit player page.

    1.2.2 – August 3, 2017

    Plugin
    • Fixed issue with players not saving.
    • Fixed issue with games not saving because of difference in initial sport in ‘Add Game’ and the database.

    1.2.1 – June 21, 2017

    Plugin
    • Added better functionality for WP REST API routes, including the ability to group stats by players.
    • Fixed strip slashes issue with player’s height.

    1.2 – June 7, 2017

    Plugin
    • Fixed error that shows up in the standings widget and standings dashboard widget when there are no teams in the database.
    • Fixed issue with keepers not showing up in the right spot in the game recaps.
    • Changed the style of the teams adn players admin listing and edit pages to match the style of the games admin pages.
    • Added the ability to create playoff brackets.
    • Added an active/inactive option for teams.
    • Made “Free Agent” a team choice for players.
    • Redesigned the games dashboard widget to match the style of the games listing page.
    • Added shortcodes to show the scoreboard, standings or stats.
    • Fixed other minor issues with the plugin.
    • Tested to work with WordPress 4.8.
    Theme
    • Fixed issue slider arrows not showing up and centered them vertically.
    • Fixed issue with header covering up top part of post title in the slider.
    • Centered the post title, details and excerpt vertically inside the slider.
    • Tested to work with WordPress 4.8.

    1.1- January 7, 2017

    Plugin
    • Added custom routes to the WP REST API for all tables.
    • Added standings and games dashboard widgets.
    • Changed the style of the game list page and add/edit game page to make adding game stats much easier.
    Theme
    • Vertically centered the post title and information on the longform template.

    1.0

    • Initial release to the world.
  • Licenses

    GNU General Public License

    http://www.gnu.org/licenses/gpl.html

    Photo License

    Except where otherwise noted, all photos in the screenshot are also licensed under the GNU General Public License. Copyright 2015 Jacob Martella

    Social Media Icons License

    All of the social media icons are licensed under the GNU General Public License (http://www.gnu.org/licenses/gpl.html).

    Scripts License

    All of the scripts used in this theme are licensed under the GNU General Public License (http://www.gnu.org/licenses/gpl.html).

    Fonts License

    PlayfairDisplay-Regular.ttf: Copyright (c) 2010-2012 by Claus Eggers Sørensen (es@forthehearts.net), with Reserved Font Name ‘Playfair’

    PlayfairDisplay-Italic.ttf: Copyright (c) 2010-2012 by Claus Eggers Sørensen (es@forthehearts.net), with Reserved Font Name ‘Playfair’

    PlayfairDisplay-Bold.ttf: Copyright (c) 2010-2012 by Claus Eggers Sørensen (es@forthehearts.net), with Reserved Font Name ‘Playfair’

    Roboto-Light.ttf: Copyright 2011 Google Inc. All Rights Reserved.

    Roboto-LightItalic.ttf: Copyright 2011 Google Inc. All Rights Reserved.

    Roboto-Regular.ttf: Copyright 2011 Google Inc. All Rights Reserved.

    Roboto-Italic.ttf: Copyright 2011 Google Inc. All Rights Reserved.

    Roboto-Bold.ttf: Copyright 2011 Google Inc. All Rights Reserved.

    Oswald-Regular.ttf: Copyright (c) 2011-2012, Vernon Adams (vern@newtypography.co.uk), with Reserved Font Names ‘Oswald’

    Oswald-Bold.ttf: Copyright (c) 2011-2012, Vernon Adams (vern@newtypography.co.uk), with Reserved Font Names ‘Oswald’

    Foundation License

    Foundation is licensed under the MIT license. http://www.opensource.org/licenses/mit-license.php

    JointsWP License

    JointsWP is licensed under the GNU General Public License. http://www.gnu.org/licenses/gpl.html

Get In Contact

If you have an issue with the item, a feature you wish to see in a later release or want me to customize your version of the item, use the conact form below to get in touch with me. Please note that customizations will cost extra depending on what you wish to customize.

Sports Bench Blog Posts

View All

Other WordPress Plugins & Themes