function wpcm_get_sports_stats_labels()
{
    $sport = get_option('wpcm_sport');
    $data = wpcm_get_sport_presets();
    $wpcm_player_stats_labels = $data[$sport]['stats_labels'];
    return $wpcm_player_stats_labels;
}
    /**
     * form function.
     *
     * @see WP_Widget->form
     * @access public
     * @param array $instance
     * @return void
     */
    function form($instance)
    {
        $defaults = array('limit' => 10, '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'));
        $sport = get_option('wpcm_sport');
        $data = wpcm_get_sport_presets();
        $wpcm_player_stats_labels = $data[$sport]['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' => __('Image', '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'), 'height' => __('Height', 'wp-club-manager'), 'weight' => __('Weight', 'wp-club-manager'), 'team' => __('Team', 'wp-club-manager'), 'season' => __('Season', 'wp-club-manager'), 'dob' => __('Date of Birth', 'wp-club-manager'), 'hometown' => __('Hometown', 'wp-club-manager'), 'joined' => __('Joined', 'wp-club-manager')), $player_stats_labels);
        $instance = wp_parse_args((array) $instance, $defaults);
        $stats = explode(',', $instance['stats']);
        ?>
		
		<?php 
        $field = 'title';
        ?>
		<p>
			<label for="<?php 
        echo $this->get_field_id($field);
        ?>
"><?php 
        _e('Title', 'wp-club-manager');
        ?>
:</label>
			<input class="widefat" id="<?php 
        echo $this->get_field_id($field);
        ?>
" name="<?php 
        echo $this->get_field_name($field);
        ?>
" value="<?php 
        echo $instance[$field];
        ?>
" type="text" />
		</p>
		
		<?php 
        $field = 'limit';
        ?>
		<p>
			<label for="<?php 
        echo $this->get_field_id($field);
        ?>
"><?php 
        _e('Limit', 'wp-club-manager');
        ?>
:</label>
			<input id="<?php 
        echo $this->get_field_id($field);
        ?>
" name="<?php 
        echo $this->get_field_name($field);
        ?>
" value="<?php 
        echo $instance[$field];
        ?>
" type="number" size="3" />
		</p>
		
		<?php 
        $field = 'season';
        ?>
		<p>
			<label for="<?php 
        echo $this->get_field_id($field);
        ?>
"><?php 
        _e('Season', 'wp-club-manager');
        ?>
:</label>
			<?php 
        wp_dropdown_categories(array('show_option_none' => __('All'), 'hide_empty' => 0, 'orderby' => 'title', 'taxonomy' => 'wpcm_season', 'selected' => $instance[$field], 'name' => $this->get_field_name($field), 'id' => $this->get_field_id($field)));
        ?>
		</p>
		
		<?php 
        $field = 'team';
        ?>
		<p>
			<label for="<?php 
        echo $this->get_field_id($field);
        ?>
"><?php 
        _e('Team', 'wp-club-manager');
        ?>
:</label>
			<?php 
        wp_dropdown_categories(array('show_option_none' => __('All'), 'hide_empty' => 0, 'orderby' => 'title', 'taxonomy' => 'wpcm_team', 'selected' => $instance[$field], 'name' => $this->get_field_name($field), 'id' => $this->get_field_id($field)));
        ?>
		</p>
		
		<?php 
        $field = 'position';
        ?>
		<p>
			<label for="<?php 
        echo $this->get_field_id($field);
        ?>
"><?php 
        _e('Position', 'wp-club-manager');
        ?>
:</label>
			<?php 
        wp_dropdown_categories(array('show_option_none' => __('All'), 'hide_empty' => 0, 'orderby' => 'title', 'taxonomy' => 'wpcm_position', 'selected' => $instance[$field], 'name' => $this->get_field_name($field), 'id' => $this->get_field_id($field)));
        ?>
		</p>
				
		<?php 
        $field = 'orderby';
        ?>
		<p>
			<label for="<?php 
        echo $this->get_field_id($field);
        ?>
"><?php 
        _e('Order by', 'wp-club-manager');
        ?>
:</label>
			<select id="<?php 
        echo $this->get_field_id($field);
        ?>
" name="<?php 
        echo $this->get_field_name($field);
        ?>
">
				<option id="number" value="number"<?php 
        if ($instance[$field] == 'number') {
            echo ' selected';
        }
        ?>
><?php 
        _e('Number', 'wp-club-manager');
        ?>
</option>
				<option id="menu_order" value="menu_order"<?php 
        if ($instance[$field] == 'menu_order') {
            echo ' selected';
        }
        ?>
><?php 
        _e('Page order');
        ?>
</option>
				<?php 
        foreach ($player_stats_labels as $key => $val) {
            ?>

					<option id="<?php 
            echo $key;
            ?>
" value="<?php 
            echo $key;
            ?>
"<?php 
            if ($instance[$field] == $key) {
                echo ' selected';
            }
            ?>
><?php 
            echo $val;
            ?>
</option>

				<?php 
        }
        ?>
			</select>
		</p>
			
		<?php 
        $field = 'order';
        ?>
		<p>
			<label for="<?php 
        echo $this->get_field_id($field);
        ?>
"><?php 
        _e('Order', 'wp-club-manager');
        ?>
:</label>
			<?php 
        $wpcm_order_options = array('ASC' => __('Lowest to highest', 'wp-club-manager'), 'DESC' => __('Highest to lowest', 'wp-club-manager'));
        ?>
			<select id="<?php 
        echo $this->get_field_id($field);
        ?>
" name="<?php 
        echo $this->get_field_name($field);
        ?>
">
				<?php 
        foreach ($wpcm_order_options as $key => $val) {
            ?>

					<option id="<?php 
            echo $key;
            ?>
" value="<?php 
            echo $key;
            ?>
"<?php 
            if ($instance[$field] == $key) {
                echo ' selected';
            }
            ?>
><?php 
            echo $val;
            ?>
</option>

				<?php 
        }
        ?>
			</select>
		</p>
			
		<?php 
        $field = 'stats';
        ?>
		<p>
			<label><?php 
        _e('Statistics', 'wp-club-manager');
        ?>
</label>
			<table>
				<tr>
					<?php 
        $count = 0;
        foreach ($stats_labels as $key => $value) {
            $count++;
            if ($count > 2) {
                $count = 1;
                echo '</tr><tr>';
            }
            ?>
					<td>
						<label class="selectit" for="<?php 
            echo $this->get_field_id($field);
            ?>
-<?php 
            echo $key;
            ?>
">
							<input type="checkbox" id="<?php 
            echo $this->get_field_id($field);
            ?>
-<?php 
            echo $key;
            ?>
" name="<?php 
            echo $this->get_field_name($field);
            ?>
[]" value="<?php 
            echo $key;
            ?>
" <?php 
            checked(in_array($key, $stats));
            ?>
 />
							<?php 
            echo $value;
            ?>
						</label>
					</td>
				<?php 
        }
        ?>
				</tr>
			</table>
		</p>
			
		<?php 
        $field = 'linktext';
        ?>
		<p>
			<label for="<?php 
        echo $this->get_field_id($field);
        ?>
"><?php 
        _e('Link text', 'wp-club-manager');
        ?>
:</label>
			<input class="widefat" id="<?php 
        echo $this->get_field_id($field);
        ?>
" name="<?php 
        echo $this->get_field_name($field);
        ?>
" value="<?php 
        echo $instance[$field];
        ?>
" type="text" />
		</p>
			
		<?php 
        $field = 'linkpage';
        ?>
		<p>
			<label for="<?php 
        echo $this->get_field_id($field);
        ?>
"><?php 
        _e('Link page', 'wp-club-manager');
        ?>
:</label>
			<?php 
        wp_dropdown_pages(array('show_option_none' => __('None'), 'selected' => $instance[$field], 'name' => $this->get_field_name($field), 'id' => $this->get_field_id($field)));
        ?>
		</p>

	<?php 
    }
 /**
  * Default options
  *
  * Sets up the default options used on the settings page
  *
  * @access public
  */
 private static function create_options()
 {
     // Include settings so that we can run through defaults
     include_once 'admin/class-wpcm-admin-settings.php';
     $settings = WPCM_Admin_Settings::get_settings_pages();
     foreach ($settings as $section) {
         foreach ($section->get_settings() as $value) {
             if (isset($value['default']) && isset($value['id'])) {
                 $autoload = isset($value['autoload']) ? (bool) $value['autoload'] : true;
                 add_option($value['id'], $value['default'], '', $autoload ? 'yes' : 'no');
             }
         }
     }
     if (!get_option('wpclubmanager_installed')) {
         // Configure default sport
         $sport = 'soccer';
         $options = wpcm_get_sport_presets();
         WPCM_Admin_Settings::configure_sport($options[$sport]);
         update_option('wpcm_sport', $sport);
         update_option('wpclubmanager_installed', 1);
     }
 }
 /**
  * Constructor for the sports class - defines all preset sports.
  *
  * @access public
  * @return void
  */
 public function __construct()
 {
     $this->data = wpcm_get_sport_presets();
 }