Team Rosters Update

Team Rosters version 4.0 is on schedule for a late spring release. This update has a few front end enhancements, but the focus is on ‘admin issues’, specifically integration other MSTW plugins and increased customization options.

I am making the following tutorials available to the MSTW mailing list as pre-release peek at version 4.0. They are a bit long, so you may want to read the text, save the email, and come back to the videos when you are upgrading to Team Rosters version 4.0. They will also be available to Gold Support Members on the shoalsummitsolutions.com Support -> Tutorials page.

Customizing Team Colors

There are three ways to customize the colors in the Team Rosters v4.0 plugin: the colors tab on the Settings admin page, writing custom CSS rules where the stylesheet can now be in the theme/child theme directory, and a new setting to automatically set the table colors from the MSTW Schedules & Scoreboards teams database.

Customizing Team Logos

There are three ways to customize the team logos (and default images when no player photo is found) in Team Rosters v4.0: use the logos in the MSTW Schedules & Scoreboards database, set the default logos in the plugin’s /images/default-images/ directory, or set the default logos in the theme or child theme’s /mstw-team-rosters-images/ directory (which you create).

Customizing the Single Player & Player Gallery Templates

The default Single Player and Player Gallery templates are located in the plugin’s /theme-templates/ directory. Usually, only some CSS modifications are required to make these templates “fit” in a theme. Occasionally, these templates require code modifications to meet a sites requirements. In version 4.0, the plugin’s default templates never need to be modified. Rather, one should create custom templates in the theme’s (or child theme’s) main directory. By doing so, the customizations are not overwritten when a plugin update is loaded. If a child theme is used, they are not overwritten by a theme update either.

Controling Admin Access

New in version 4.0 is the ability for developers to control admin user access to the plugin’s admin menus via a WordPress Filter. The default capability is ‘edit_others_posts’, a capability of Editors, Admins, and Super Admins. Only those roles can access the plugin’s admin menus by default. To change that capability, in your functions.php file (or wherever) add a hook to the mstw_gs_user_capability filter as follows:

add_filter( ‘mstw_gs_user_capability’, ‘my_user_capability_callback’, 10, 2 );

where 10 is the priority of the filter call to my_user_capability_callback and 2 is the number of arguments the callback will receive (see below). PLEASE DO NOT SET THE PRIORITY HIGHER THAN 10, which is the default. That is, use 10 and above, 1-9 are reserved for the MSTW Framework and your code may produce unexpected results if you use them.

Your callback will look something like this:

	function my_user_capability_callback( $capability, $filter4 ) {
		// Only allow the admin role to access the display settings menu 
		if ( $filter4 == 'display_settings_menu_item' )
			return 'manage_options';
		// For everything else, just pass the $capability back unchanged
		else 	
			return $capability;  
	}

The ‘filter for’ values for the `mstw_gs_user_capability` hook (as of version 4.0 ) are:

  • scheduled_games_menu_item – called before registering the games, schedules, and teams custom post types
  • display_settings_menu_item – called before displaying the Display Settings submenu
  • csv_import_menu_item – called before displaying the CSV Import submenu

scheduled_games_menu_item controls the display of the entire MSTW Game Schedules menu and all submenus. display_settings_menu_item controls the display of the Display Settings submenu, and csv_import_menu_item controls the display of the CSV Import submenu.

Adding Schedules to Menus

1. You don’t need to create any pages.

2. Create schedules using Game Schedules. I recommend that you use schedule IDs that are a¬†single word rather than multiple word schedule IDs. For example, ‘2013-varsity-football’ rather than ‘2013 Varsity Football’.

3. Add menu items for your schedules using the Appearance->Menus screen. Menu items should be entered as CUSTOM LINKS  using the following format

http://your-site-url/schedule?sched=sched-id&title=My%20Team%20Schedule

Note that you cannot use spaces in the sched and title arguments (due to some vagaries of WordPress security, I guess). So I used the %20 code to add spaces to “My Team Schedule” above. The same method will work for the sched argument should you decide to have spaces in your schedule IDs.

If sched is not provided, it will default to ID 1. If title is not provided, it will default to “Schedule”. If sched is not a valid schedule ID, a “No scheduled Games Found” message will be displayed.

Of course if you want fancier customizations on your schedule pages you can always create a page for each schedule, add the Game Schedules shortcode, and fancy it up to your heart’s delight with custom HTML, PHP, and CSS.

Team Rosters

Craig MortonThe Team Rosters plugin creates a custom post type (player), installs an editor for this post type, and provides a shortcode to display rosters as simple html tables. Players are assigned to team rosters using a custom taxonomy for teams. The plugin supports as many players and team rosters as you need.

A shortcode adds team rosters to your site in three tabular formats. A custom ‘single-player’ template displays an individual player in a ‘player bio’ format. The look of roster tables and player bios can be customized using the plugin’s settings or by editting the plugin’s stylesheet.

The plugin now supports a ‘gallery view’ of a team. Check out the Team Rosters plugin on the MSTW Development Site.

The next version will include the ability to upload teams from CSV formatted files, as well as a Spanish translation. The goal is to have these enhancements in place before the end of 2012. You can downloaded the Spanish translation files now. (Many thanks to Roberto in Madrid!)

Get the Team Rosters Plugin from WordPress.org.

View the Team Rosters Plugin Support Forum on WordPress.org