/**
  * Get settings array
  *
  * @return array
  */
 public function get_settings()
 {
     $settings = array(array('title' => __('Player Profile Options', 'wp-club-manager'), 'type' => 'title', 'desc' => __('<p>Choose which fields to display on player profile pages.</p>', 'wp-club-manager'), 'id' => 'players_options'), array('title' => __('Number', 'wp-club-manager'), 'desc' => '', 'id' => 'wpcm_player_profile_show_number', 'default' => 'yes', 'type' => 'checkbox'), array('title' => __('Date of Birth', 'wp-club-manager'), 'desc' => '', 'id' => 'wpcm_player_profile_show_dob', 'default' => 'yes', 'type' => 'checkbox'), array('title' => __('Age', 'wp-club-manager'), 'desc' => '', 'id' => 'wpcm_player_profile_show_age', 'default' => 'yes', 'type' => 'checkbox'), array('title' => __('Height', 'wp-club-manager'), 'desc' => '', 'id' => 'wpcm_player_profile_show_height', 'default' => 'yes', 'type' => 'checkbox'), array('title' => __('Weight', 'wp-club-manager'), 'desc' => '', 'id' => 'wpcm_player_profile_show_weight', 'default' => 'yes', 'type' => 'checkbox'), array('title' => __('Season', 'wp-club-manager'), 'desc' => '', 'id' => 'wpcm_player_profile_show_season', 'default' => 'yes', 'type' => 'checkbox'), array('title' => __('Team', 'wp-club-manager'), 'desc' => '', 'id' => 'wpcm_player_profile_show_team', 'default' => 'yes', 'type' => 'checkbox'), array('title' => __('Position', 'wp-club-manager'), 'desc' => '', 'id' => 'wpcm_player_profile_show_position', 'default' => 'yes', 'type' => 'checkbox'), array('title' => __('Date Joined', 'wp-club-manager'), 'desc' => '', 'id' => 'wpcm_player_profile_show_joined', 'default' => 'no', 'type' => 'checkbox'), array('title' => __('Experience', 'wp-club-manager'), 'desc' => '', 'id' => 'wpcm_player_profile_show_exp', 'default' => 'no', 'type' => 'checkbox'), array('title' => __('Birthplace', 'wp-club-manager'), 'desc' => '', 'id' => 'wpcm_player_profile_show_hometown', 'default' => 'yes', 'type' => 'checkbox'), array('title' => __('Previous Clubs', 'wp-club-manager'), 'desc' => '', 'id' => 'wpcm_player_profile_show_prevclubs', 'default' => 'yes', 'type' => 'checkbox'), array('type' => 'sectionend', 'id' => 'players_options'), array('title' => __('Player Image Sizes', 'wp-club-manager'), 'type' => 'title', 'desc' => sprintf(__('<p>These settings affect the actual dimensions of images in player and staff profiles - the display on the front-end will still be affected by CSS styles. After changing these settings you may need to <a href="%s">regenerate your thumbnails</a>.</p>', 'wp-club-manager'), 'http://wordpress.org/extend/plugins/regenerate-thumbnails/'), 'id' => 'image_options'), array('title' => __('Player Profile Image', 'wp-club-manager'), 'desc' => '', 'id' => 'player_single_image_size', 'css' => '', 'type' => 'image_width', 'default' => array('width' => '300', 'height' => '300', 'crop' => 1), 'desc_tip' => true), array('title' => __('Player Thumbnails', 'wp-club-manager'), 'desc' => '', 'id' => 'player_thumbnail_image_size', 'css' => '', 'type' => 'image_width', 'default' => array('width' => '25', 'height' => '25', 'crop' => 1), 'desc_tip' => true), array('type' => 'sectionend', 'id' => 'image_options'), array('title' => __('Display Player Stats', 'wp-club-manager'), 'type' => 'title', 'desc' => __('<p>Choose which player stats to display throughout the site.</p>', 'wp-club-manager'), 'id' => 'players_stats'));
     $wpcm_player_stats_labels = wpcm_get_sports_stats_labels();
     $stats_labels = array('appearances' => __('Games Played', 'wp-club-manager'), 'subs' => __('Substitute Appearances', 'wp-club-manager'));
     $stats_labels = array_merge($stats_labels, $wpcm_player_stats_labels);
     foreach ($stats_labels as $key => $value) {
         $settings[] = array('title' => __(strip_tags($value), 'wp-club-manager'), 'desc' => '', 'id' => 'wpcm_show_stats_' . $key, 'default' => 'no', 'type' => 'checkbox');
     }
     $settings[] = array('type' => 'sectionend', 'id' => 'players_stats');
     return apply_filters('wpclubmanager_players_settings', $settings);
 }
コード例 #2
0
/**
 * Single Player - Stats Table
 *
 * @author 		ClubPress
 * @package 	WPClubManager/Templates
 * @version     1.3.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
global $post, $wpclubmanager;
$teams = get_the_terms($post->ID, 'wpcm_team');
$stats = get_wpcm_player_stats($post);
$seasons = get_the_terms($post->ID, 'wpcm_season');
$wpcm_player_stats_labels = wpcm_get_sports_stats_labels();
$stats_labels = array_merge(array('appearances' => __('Apps', 'wp-club-manager')), $wpcm_player_stats_labels);
if (is_array($teams)) {
    foreach ($teams as $team) {
        $rand = rand(1, 99999);
        $name = $team->name;
        if ($team->parent) {
            $parent_team = get_term($team->parent, 'wpcm_team');
            $name .= ' (' . $parent_team->name . ')';
        }
        ?>

		<div class="wpcm-profile-stats-block">

			<h4><?php 
        echo $name;
/**
 * Player profile stats table.
 *
 * @access public
 * @param array
 * @param string $team
 * @param string $season
 * @return void
 */
function wpcm_profile_stats_table($stats = array(), $team = 0, $season = 0)
{
    $id = get_the_ID();
    if (array_key_exists($team, $stats)) {
        if (array_key_exists($season, $stats[$team])) {
            $stats = $stats[$team][$season];
        }
    }
    $wpcm_player_stats_labels = wpcm_get_sports_stats_labels();
    $stats_labels = array('appearances' => '<a title="' . __('Games Played', 'wp-club-manager') . '">' . __('GP', 'wp-club-manager') . '</a>');
    $stats_labels = array_merge($stats_labels, $wpcm_player_stats_labels);
    ?>

	<table>
		<thead>
			<tr>
				<?php 
    foreach ($stats_labels as $key => $val) {
        if (get_option('wpcm_show_stats_' . $key) == 'yes') {
            ?>

						<th><?php 
            echo $val;
            ?>
</th>
					<?php 
        }
    }
    ?>
			</tr>
		</thead>
		<tbody>
			<tr>
				<?php 
    foreach ($stats_labels as $key => $val) {
        if ($key == 'appearances') {
            if (get_option('wpcm_show_stats_appearances') == 'yes') {
                if (get_option('wpcm_show_stats_subs') == 'yes') {
                    $subs = get_player_subs_total($id, $season, $team);
                    if ($subs > 0) {
                        $sub = ' <span class="sub-appearances">(' . $subs . ')</span>';
                    } else {
                        $sub = '';
                    }
                }
                ?>
					
							<td><span data-index="appearances"><?php 
                wpcm_stats_value($stats, 'total', 'appearances');
                echo get_option('wpcm_show_stats_subs') == 'yes' ? $sub : '';
                ?>
</span></td>

						<?php 
            }
        } elseif ($key == 'rating') {
            $rating = get_wpcm_stats_value($stats, 'total', 'rating');
            $apps = get_wpcm_stats_value($stats, 'total', 'appearances');
            $avrating = wpcm_divide($rating, $apps);
            if (get_option('wpcm_show_stats_rating') == 'yes') {
                ?>
					
							<td><span data-index="rating"><?php 
                echo sprintf("%01.2f", round($avrating, 2));
                ?>
</span></td>

						<?php 
            }
        } else {
            if (get_option('wpcm_show_stats_' . $key) == 'yes') {
                ?>

							<td><span data-index="<?php 
                echo $key;
                ?>
"><?php 
                wpcm_stats_value($stats, 'total', $key);
                ?>
</span></td>
						<?php 
            }
        }
    }
    ?>
				
			</tr>
		</tbody>
	</table>
<?php 
}
/**
 * Player stats table.
 *
 * @access public
 * @param array
 * @param string $club
 * @param string $type
 * @param bool $keyarray = false
 * @return void
 */
function wpcm_match_player_stats_table($selected_players = array(), $type = 'lineup', $keyarray = false)
{
    global $post, $player;
    $teams = get_the_terms($post->ID, 'wpcm_team');
    $seasons = get_the_terms($post->ID, 'wpcm_season');
    if (is_array($teams)) {
        $match_teams = array();
        foreach ($teams as $team) {
            $match_teams[] = $team->term_id;
        }
    } else {
        $match_teams = array();
    }
    if (is_array($seasons)) {
        $match_seasons = array();
        foreach ($seasons as $season) {
            $match_seasons[] = $season->term_id;
        }
    } else {
        $match_seasons = array();
    }
    $args = array('post_type' => 'wpcm_player', 'meta_key' => 'wpcm_number', 'orderby' => 'menu_order meta_value_num', 'order' => 'ASC', 'showposts' => -1);
    if ($teams) {
        $args['tax_query'] = array('relation' => 'AND', array('taxonomy' => 'wpcm_team', 'field' => 'term_id', 'terms' => $match_teams), array('taxonomy' => 'wpcm_season', 'field' => 'term_id', 'terms' => $match_seasons));
    }
    $players = get_posts($args);
    if (empty($players)) {
        ?>

		<div class="wpcm-notice-block">
			<p>
				<?php 
        _e('No players found!', 'wp-club-manager');
        ?>
			</p>
		</div>
	<?php 
    } else {
        if (!is_array($selected_players)) {
            $selected_players = array();
        }
        $selected_players = array_merge(array('lineup' => array(), 'subs' => array()), $selected_players);
        $wpcm_player_stats_labels = wpcm_get_sports_stats_labels();
        ?>

		<p class="">
			<?php 
        _e('Click and drag players to reorder', 'wp-club-manager');
        ?>
			<img src="<?php 
        bloginfo('url');
        ?>
/wp-admin/images/loading.gif" id="loading-animation" />
		</p>
		<table class="wpcm-match-players-table">
			<thead>
				<tr class="player-stats-list-labels">
					<th>&nbsp;</th>

					<?php 
        foreach ($wpcm_player_stats_labels as $key => $val) {
            if (get_option('wpcm_show_stats_' . $key) == 'yes') {
                ?>
							<th<?php 
                if ($key == 'greencards' || $key == 'yellowcards' || $key == 'blackcards' || $key == 'redcards') {
                    echo ' class="th-checkbox"';
                }
                if ($key == 'mvp') {
                    echo ' class="th-radio"';
                }
                ?>
><?php 
                echo $val;
                ?>
</th>
						<?php 
            }
        }
        if ($type == 'subs') {
            ?>
						<th><?php 
            _e('Player Off', 'wp-club-manager');
            ?>
</th>
					<?php 
        }
        ?>

				</tr>
			</thead>
			<tbody class="wpcm-sortable">
				<?php 
        foreach ($players as $player) {
            ?>
					<?php 
            $played = is_array($selected_players) && array_key_exists($type, $selected_players) && is_array($selected_players[$type]) && array_key_exists($player->ID, $selected_players[$type]) && is_array($selected_players[$type][$player->ID]);
            $teams = get_the_terms($player->ID, 'wpcm_team');
            $seasons = get_the_terms($player->ID, 'wpcm_season');
            if ($teams) {
                $teamclass = array();
                foreach ($teams as $team) {
                    $teamclass[] = 'team_' . $team->term_id . ' ';
                }
            } else {
                $teamclass = array();
            }
            $player_teams = implode('', $teamclass);
            if ($seasons > 0) {
                foreach ($seasons as $season) {
                    $seasonclass = 'season_' . $season->term_id . ' ';
                }
            } else {
                $seasonclass = 'season_0 ';
            }
            $number = get_post_meta($player->ID, 'wpcm_number', true);
            if ($number) {
                $squad_number = $number . '. ';
            } else {
                $squad_number = '';
            }
            ?>

					<tr id="<?php 
            echo $player->ID;
            ?>
" data-player="<?php 
            echo $player->ID;
            ?>
" class="player-stats-list <?php 
            echo $player_teams;
            ?>
 <?php 
            echo $seasonclass;
            ?>
 sortable sorted">
						<td class="names">
							<label class="selectit">
								<input type="checkbox" data-player="<?php 
            echo $player->ID;
            ?>
" name="wpcm_players[<?php 
            echo $type;
            ?>
][<?php 
            echo $player->ID;
            ?>
][checked]" class="player-select" value="1" <?php 
            checked(true, $played);
            ?>
 /><span class="name">
								<?php 
            echo $squad_number;
            ?>
 <?php 
            echo $player->post_title;
            ?>
</span>
							</label>
						</td>
						<?php 
            foreach ($wpcm_player_stats_labels as $key => $val) {
                $keyarray = is_array($selected_players) && array_key_exists($type, $selected_players) && is_array($selected_players[$type]) && array_key_exists($player->ID, $selected_players[$type]) && is_array($selected_players[$type][$player->ID]) && array_key_exists($key, $selected_players[$type][$player->ID]);
                if (get_option('wpcm_show_stats_' . $key) == 'yes') {
                    if ($key == 'greencards') {
                        ?>

									<td class="<?php 
                        echo $key;
                        ?>
">
										<input type="checkbox" data-card="green" data-player="<?php 
                        echo $player->ID;
                        ?>
" name="wpcm_players[<?php 
                        echo $type;
                        ?>
][<?php 
                        echo $player->ID;
                        ?>
][<?php 
                        echo $key;
                        ?>
]" value="1" <?php 
                        checked(true, $keyarray);
                        if (!$played) {
                            echo ' disabled';
                        }
                        ?>
/>
									</td>

								<?php 
                    } elseif ($key == 'yellowcards') {
                        ?>

									<td class="<?php 
                        echo $key;
                        ?>
">
										<input type="checkbox" data-card="yellow" data-player="<?php 
                        echo $player->ID;
                        ?>
" name="wpcm_players[<?php 
                        echo $type;
                        ?>
][<?php 
                        echo $player->ID;
                        ?>
][<?php 
                        echo $key;
                        ?>
]" value="1" <?php 
                        checked(true, $keyarray);
                        if (!$played) {
                            echo ' disabled';
                        }
                        ?>
/>
									</td>

								<?php 
                    } elseif ($key == 'blackcards') {
                        ?>

									<td class="<?php 
                        echo $key;
                        ?>
">
										<input type="checkbox" data-card="black" data-player="<?php 
                        echo $player->ID;
                        ?>
" name="wpcm_players[<?php 
                        echo $type;
                        ?>
][<?php 
                        echo $player->ID;
                        ?>
][<?php 
                        echo $key;
                        ?>
]" value="1" <?php 
                        checked(true, $keyarray);
                        if (!$played) {
                            echo ' disabled';
                        }
                        ?>
/>
									</td>

								<?php 
                    } elseif ($key == 'redcards') {
                        ?>

									<td class="<?php 
                        echo $key;
                        ?>
">
										<input type="checkbox" data-card="red" data-player="<?php 
                        echo $player->ID;
                        ?>
" name="wpcm_players[<?php 
                        echo $type;
                        ?>
][<?php 
                        echo $player->ID;
                        ?>
][<?php 
                        echo $key;
                        ?>
]" value="1" <?php 
                        checked(true, $keyarray);
                        if (!$played) {
                            echo ' disabled';
                        }
                        ?>
/>
									</td>

								<?php 
                    } elseif ($key == 'rating') {
                        ?>

									<td class="<?php 
                        echo $key;
                        ?>
">
										<input type="number" data-player="<?php 
                        echo $player->ID;
                        ?>
" name="wpcm_players[<?php 
                        echo $type;
                        ?>
][<?php 
                        echo $player->ID;
                        ?>
][<?php 
                        echo $key;
                        ?>
]" value="<?php 
                        wpcm_stats_value($selected_players[$type], $player->ID, $key);
                        ?>
" min="0" max="10"<?php 
                        if (!$played) {
                            echo ' disabled';
                        }
                        ?>
/>
									</td>

								<?php 
                    } elseif ($key == 'mvp') {
                        ?>

									<td class="mvp">
										<input type="radio" data-player="<?php 
                        echo $player->ID;
                        ?>
" name="wpcm_players[<?php 
                        echo $type;
                        ?>
][<?php 
                        echo $player->ID;
                        ?>
][<?php 
                        echo $key;
                        ?>
]" value="1" <?php 
                        checked(true, $keyarray);
                        if (!$played) {
                            echo ' disabled';
                        }
                        ?>
 />
									</td>

								<?php 
                    } else {
                        ?>

									<td class="<?php 
                        echo $key;
                        ?>
">
										<input type="number" data-player="<?php 
                        echo $player->ID;
                        ?>
" name="wpcm_players[<?php 
                        echo $type;
                        ?>
][<?php 
                        echo $player->ID;
                        ?>
][<?php 
                        echo $key;
                        ?>
]" value="<?php 
                        wpcm_stats_value($selected_players[$type], $player->ID, $key);
                        ?>
"<?php 
                        if (!$played) {
                            echo ' disabled';
                        }
                        ?>
/>
									</td>

								<?php 
                    }
                }
            }
            if ($type == 'subs') {
                wpcm_player_subs_dropdown($selected_players, $player->ID, !$played);
            }
            ?>
					</tr>
				<?php 
        }
        ?>
			</tbody>
		</table>
	<?php 
    }
}
    /**
     * Output the metabox
     */
    public static function output($post)
    {
        $teams = get_the_terms($post->ID, 'wpcm_team');
        $stats = get_wpcm_player_stats($post);
        $seasons = get_the_terms($post->ID, 'wpcm_season');
        $wpcm_player_stats_labels = wpcm_get_sports_stats_labels();
        $stats_labels = array('appearances' => __('Apps', 'wp-club-manager'));
        $stats_labels = array_merge($stats_labels, $wpcm_player_stats_labels);
        if (is_array($teams)) {
            ?>

			<p><?php 
            _e('Choose a team and season to edit the manual stats.', 'wp-club-manager');
            ?>
</p>

			<?php 
            foreach ($teams as $team) {
                $rand = rand(1, 99999);
                $name = $team->name;
                if ($team->parent) {
                    $parent_team = get_term($team->parent, 'wpcm_team');
                    $name .= ' (' . $parent_team->name . ')';
                }
                ?>

				<div class="wpcm-profile-stats-block">

					<h4><?php 
                echo $name;
                ?>
</h4>

					<ul class="stats-tabs-<?php 
                echo $rand;
                ?>
 stats-tabs-multi">
								
						<li class="tabs-multi"><a href="#wpcm_team-0_season-0-<?php 
                echo $rand;
                ?>
"><?php 
                printf(__('All %s', 'wp-club-manager'), __('Seasons', 'wp-club-manager'));
                ?>
</a></li>

						<?php 
                if (is_array($seasons)) {
                    foreach ($seasons as $season) {
                        ?>

							<li><a href="#wpcm_team-<?php 
                        echo $team->term_id;
                        ?>
_season-<?php 
                        echo $season->term_id;
                        ?>
"><?php 
                        echo $season->name;
                        ?>
</a></li>

						<?php 
                    }
                }
                ?>
						
					</ul>

					<div id="wpcm_team-0_season-0-<?php 
                echo $rand;
                ?>
" class="tabs-panel-<?php 
                echo $rand;
                ?>
 tabs-panel-multi">
									
						<?php 
                wpcm_player_stats_table($stats, $team->term_id, 0);
                ?>

						<script type="text/javascript">
							(function($) {
								<?php 
                foreach ($stats_labels as $key => $val) {
                    ?>

									var sum = 0;
									$('.stats-table-season-<?php 
                    echo $rand;
                    ?>
 .player-stats-manual-<?php 
                    echo $key;
                    ?>
').each(function(){
										sum += Number($(this).val());
									});
									$('#wpcm_team-0_season-0-<?php 
                    echo $rand;
                    ?>
 .player-stats-manual-<?php 
                    echo $key;
                    ?>
').val(sum);

									var sum = 0;
									$('.stats-table-season-<?php 
                    echo $rand;
                    ?>
 .player-stats-auto-<?php 
                    echo $key;
                    ?>
').each(function(){
										sum += Number($(this).val());
									});
									$('#wpcm_team-0_season-0-<?php 
                    echo $rand;
                    ?>
 .player-stats-auto-<?php 
                    echo $key;
                    ?>
').val(sum);

									var a = +$('#wpcm_team-0_season-0-<?php 
                    echo $rand;
                    ?>
 .player-stats-auto-<?php 
                    echo $key;
                    ?>
').val();
									var b = +$('#wpcm_team-0_season-0-<?php 
                    echo $rand;
                    ?>
 .player-stats-manual-<?php 
                    echo $key;
                    ?>
').val();
									var total = a+b;
									$('#wpcm_team-0_season-0-<?php 
                    echo $rand;
                    ?>
 .player-stats-total-<?php 
                    echo $key;
                    ?>
').val(total);

								<?php 
                }
                ?>
							})(jQuery);
						</script>
								
					</div>
							
					<?php 
                if (is_array($seasons)) {
                    foreach ($seasons as $season) {
                        ?>
									
						<div id="wpcm_team-<?php 
                        echo $team->term_id;
                        ?>
_season-<?php 
                        echo $season->term_id;
                        ?>
" class="tabs-panel-<?php 
                        echo $rand;
                        ?>
 tabs-panel-multi stats-table-season-<?php 
                        echo $rand;
                        ?>
" style="display: none;">
										
							<?php 
                        wpcm_player_stats_table($stats, $team->term_id, $season->term_id);
                        ?>

							<script type="text/javascript">
								(function($) {
									<?php 
                        foreach ($stats_labels as $key => $val) {
                            ?>

										var sum = 0;
										$('.stats-table-season-<?php 
                            echo $rand;
                            ?>
 .player-stats-manual-<?php 
                            echo $key;
                            ?>
').each(function(){
											sum += Number($(this).val());
										});
										$('#wpcm_team-0_season-0-<?php 
                            echo $rand;
                            ?>
 .player-stats-manual-<?php 
                            echo $key;
                            ?>
').val(sum);

										var sum = 0;
										$('.stats-table-season-<?php 
                            echo $rand;
                            ?>
 .player-stats-auto-<?php 
                            echo $key;
                            ?>
').each(function(){
											sum += Number($(this).val());
										});
										$('#wpcm_team-0_season-0-<?php 
                            echo $rand;
                            ?>
 .player-stats-auto-<?php 
                            echo $key;
                            ?>
').val(sum);

										var a = +$('#wpcm_team-0_season-0-<?php 
                            echo $rand;
                            ?>
 .player-stats-auto-<?php 
                            echo $key;
                            ?>
').val();
										var b = +$('#wpcm_team-0_season-0-<?php 
                            echo $rand;
                            ?>
 .player-stats-manual-<?php 
                            echo $key;
                            ?>
').val();
										var total = a+b;
										$('#wpcm_team-0_season-0-<?php 
                            echo $rand;
                            ?>
 .player-stats-total-<?php 
                            echo $key;
                            ?>
').val(total);

									<?php 
                        }
                        ?>
								})(jQuery);
							</script>
									
						</div>
						
					<?php 
                    }
                }
                ?>

				</div>

				<script type="text/javascript">
					(function($) {
						$('.stats-tabs-<?php 
                echo $rand;
                ?>
 a').click(function(){
							var t = $(this).attr('href');
							
							$(this).parent().addClass('tabs-multi <?php 
                echo $rand;
                ?>
').siblings('li').removeClass('tabs-multi <?php 
                echo $rand;
                ?>
');
							$(this).parent().parent().parent().find('.tabs-panel-<?php 
                echo $rand;
                ?>
').hide();
							$(t).show();

							return false;
						});
					})(jQuery);
				</script>
			<?php 
            }
        } else {
            ?>

			<div class="statsdiv">
				<ul class="wpcm_stats-tabs">
					<li class="tabs"><a href="#wpcm_team-0_season-0" tabindex="3"><?php 
            printf(__('All %s', 'wp-club-manager'), __('Seasons', 'wp-club-manager'));
            ?>
</a></li>
					<?php 
            if (is_array($seasons)) {
                foreach ($seasons as $season) {
                    ?>
						<li class="hide-if-no-js22"><a href="#wpcm_team-0_season-<?php 
                    echo $season->term_id;
                    ?>
" tabindex="3"><?php 
                    echo $season->name;
                    ?>
</a></li>
					<?php 
                }
            }
            ?>
				</ul>
				<?php 
            if (is_array($seasons)) {
                foreach ($seasons as $season) {
                    ?>
					<div id="wpcm_team-0_season-<?php 
                    echo $season->term_id;
                    ?>
" class="tabs-panel stats-table-season" style="display: none;">
						<?php 
                    wpcm_player_stats_table($stats, 0, $season->term_id);
                    ?>
					</div>
				<?php 
                }
            }
            ?>
				<div id="wpcm_team-0_season-0" class="tabs-panel">
					<?php 
            wpcm_player_stats_table($stats, 0, 0);
            ?>
				</div>
			</div>
			<div class="clear"></div>

		<?php 
        }
    }
    /**
     * wpcm_club_buttons_ajax function.
     */
    public function players_shortcode_ajax()
    {
        $defaults = array('limit' => 0, 'season' => null, 'team' => null, 'position' => null, 'orderby' => 'number', 'order' => 'ASC', 'linktext' => __('View all players', 'wp-club-manager'), 'linkpage' => null, 'stats' => 'flag,number,name,position,age', 'title' => __('Players', 'wp-club-manager'));
        $args = array_merge($defaults, $_GET);
        $wpcm_player_stats_labels = wpcm_get_sports_stats_labels();
        $player_stats_labels = array_merge(array('appearances' => __('Appearances', 'wp-club-manager'), 'subs' => __('Sub Appearances', 'wp-club-manager')), $wpcm_player_stats_labels);
        $stats_labels = array_merge(array('thumb' => __('Thumbnail', 'wp-club-manager'), 'flag' => __('Flag', 'wp-club-manager'), 'number' => __('Number', 'wp-club-manager'), 'name' => __('Name', 'wp-club-manager'), 'position' => __('Position', 'wp-club-manager'), 'age' => __('Age', 'wp-club-manager'), 'team' => __('Team', 'wp-club-manager'), 'season' => __('Season', 'wp-club-manager'), 'dob' => __('Date of Birth', 'wp-club-manager'), 'height' => __('Height', 'wp-club-manager'), 'weight' => __('Weight', 'wp-club-manager'), 'hometown' => __('Hometown', 'wp-club-manager'), 'joined' => __('Joined', 'wp-club-manager')), $player_stats_labels);
        $stats = explode(',', $args['stats']);
        ?>
			<div id="wpcm_players-form">
				<table id="wpcm_players-table" class="form-table">
					<tr>
						<?php 
        $field = 'title';
        ?>
						<th><label for="option-<?php 
        echo $field;
        ?>
"><?php 
        _e('Title', 'wp-club-manager');
        ?>
</label></th>
						<td><input type="text" id="option-<?php 
        echo $field;
        ?>
" name="<?php 
        echo $field;
        ?>
" value="<?php 
        echo $args[$field];
        ?>
" class="widefat" /></td>
					</tr>
					<tr>
						<?php 
        $field = 'limit';
        ?>
						<th><label for="option-<?php 
        echo $field;
        ?>
"><?php 
        _e('Limit', 'wp-club-manager');
        ?>
</label></th>
						<td><input type="text" id="option-<?php 
        echo $field;
        ?>
" name="<?php 
        echo $field;
        ?>
" value="<?php 
        echo $args[$field];
        ?>
" size="3" /> (<?php 
        _e('0 = no limit', 'wp-club-manager');
        ?>
)</td>
					</tr>
					<tr>
						<?php 
        $field = 'season';
        ?>
						<th><label for="option-<?php 
        echo $field;
        ?>
"><?php 
        _e('Season', 'wp-club-manager');
        ?>
</label></th>
						<td>
							<?php 
        wp_dropdown_categories(array('show_option_none' => __('All', 'wp-club-manager'), 'hide_empty' => 0, 'orderby' => 'title', 'taxonomy' => 'wpcm_season', 'selected' => $args[$field], 'name' => $field, 'id' => 'option-' . $field));
        ?>
						</td>
					</tr>
					<tr>
						<?php 
        $field = 'team';
        ?>
						<th><label for="option-<?php 
        echo $field;
        ?>
"><?php 
        _e('Team', 'wp-club-manager');
        ?>
</label></th>
						<td>
							<?php 
        wp_dropdown_categories(array('show_option_none' => __('All', 'wp-club-manager'), 'hide_empty' => 0, 'orderby' => 'title', 'taxonomy' => 'wpcm_team', 'selected' => $args[$field], 'name' => $field, 'id' => 'option-' . $field));
        ?>
						</td>
					</tr>
					<tr>
						<?php 
        $field = 'position';
        ?>
						<th><label for="option-<?php 
        echo $field;
        ?>
"><?php 
        _e('Position', 'wp-club-manager');
        ?>
</label></th>
						<td>
							<?php 
        wp_dropdown_categories(array('show_option_none' => __('All', 'wp-club-manager'), 'hide_empty' => 0, 'orderby' => 'title', 'taxonomy' => 'wpcm_position', 'selected' => $args[$field], 'name' => $field, 'id' => 'option-' . $field));
        ?>
						</td>
					</tr>
					<tr>
						<?php 
        $field = 'orderby';
        ?>
						<th><label for="option-<?php 
        echo $field;
        ?>
"><?php 
        _e('Order by', 'wp-club-manager');
        ?>
</label></th>
						<td>
							<select id="option-<?php 
        echo $field;
        ?>
" name="<?php 
        echo $field;
        ?>
">
								<option id="number" value="number"<?php 
        if ($args[$field] == 'number') {
            echo ' selected';
        }
        ?>
><?php 
        _e('Number', 'wp-club-manager');
        ?>
</option>
								<option id="menu_order" value="menu_order"<?php 
        if ($args[$field] == 'menu_order') {
            echo ' selected';
        }
        ?>
><?php 
        _e('Page order');
        ?>
</option>
								<option id="name" value="name"<?php 
        if ($args[$field] == 'name') {
            echo ' selected';
        }
        ?>
><?php 
        _e('Alphabetical');
        ?>
</option>
								<?php 
        foreach ($player_stats_labels as $key => $val) {
            ?>
									<option id="<?php 
            echo $key;
            ?>
" value="<?php 
            echo $key;
            ?>
"<?php 
            if ($args[$field] == $key) {
                echo ' selected';
            }
            ?>
><?php 
            echo $val;
            ?>
</option>
								<?php 
        }
        ?>
							</select>
						</td>
					</tr>
					<tr>
						<?php 
        $field = 'order';
        ?>
						<th><label for="option-<?php 
        echo $field;
        ?>
"><?php 
        _e('Order', 'wp-club-manager');
        ?>
</label></th>
						<td>
							<?php 
        $wpcm_order_options = array('ASC' => __('Lowest to highest', 'wp-club-manager'), 'DESC' => __('Highest to lowest', 'wp-club-manager'));
        ?>
							<select id="option-<?php 
        echo $field;
        ?>
" name="<?php 
        echo $field;
        ?>
">
								<?php 
        foreach ($wpcm_order_options as $key => $val) {
            ?>
									<option id="<?php 
            echo $key;
            ?>
" value="<?php 
            echo $key;
            ?>
"<?php 
            if ($args[$field] == $key) {
                echo ' selected';
            }
            ?>
><?php 
            echo $val;
            ?>
</option>
								<?php 
        }
        ?>
							</select>
						</td>
					</tr>
					<tr>
						<?php 
        $field = 'linktext';
        ?>
						<th><label for="option-<?php 
        echo $field;
        ?>
"><?php 
        _e('Link text', 'wp-club-manager');
        ?>
</label></th>
						<td><input type="text" id="option-<?php 
        echo $field;
        ?>
" name="<?php 
        echo $field;
        ?>
" value="<?php 
        echo $args[$field];
        ?>
" /></td>
					</tr>
					<tr>
						<?php 
        $field = 'linkpage';
        ?>
						<th><label for="option-<?php 
        echo $field;
        ?>
"><?php 
        _e('Link page', 'wp-club-manager');
        ?>
</label></th>
						<td>
							<?php 
        wp_dropdown_pages(array('show_option_none' => __('None', 'wp-club-manager'), 'selected' => $args[$field], 'name' => $field, 'id' => 'option-' . $field));
        ?>
						</td>
					</tr>
					<tr>
						<?php 
        $field = 'stats';
        ?>
						<th><label><?php 
        _e('Display options', 'wp-club-manager');
        ?>
</label></th>
						<td>
							<table>
								<tr>
									<?php 
        $count = 0;
        foreach ($stats_labels as $key => $value) {
            $count++;
            if ($count > 3) {
                $count = 1;
                echo '</tr><tr>';
            }
            ?>
										<td>
											<label class="selectit" for="option-<?php 
            echo $field;
            ?>
-<?php 
            echo $key;
            ?>
">
												<input type="checkbox" id="option-<?php 
            echo $field;
            ?>
-<?php 
            echo $key;
            ?>
" name="<?php 
            echo $field;
            ?>
[]" value="<?php 
            echo $key;
            ?>
" <?php 
            checked(in_array($key, $stats));
            ?>
 />
												<?php 
            echo $value;
            ?>
											</label>
										</td>
									<?php 
        }
        ?>
								</tr
							></table>
						</td>
					</tr>
				</table>
				<p class="submit">
					<input type="button" id="option-submit" class="button-primary" value="<?php 
        printf(__('Insert %s', 'wp-club-manager'), __('Players', 'wp-club-manager'));
        ?>
" name="submit" />
				</p>
			</div>
		
		<?php 
        die;
    }