/**
     * Output the metabox
     */
    public static function output($post)
    {
        $limit = get_option('prosports_event_teams', 2);
        $teams = (array) get_post_meta($post->ID, 'sp_team', false);
        $league_id = sp_get_the_term_id($post->ID, 'sp_league', 0);
        $season_id = sp_get_the_term_id($post->ID, 'sp_season', 0);
        for ($i = 0; $i < $limit; $i++) {
            $team = array_shift($teams);
            ?>
			<div class="sp-instance">
				<p class="sp-tab-select sp-tab-select-dummy">
					<?php 
            $args = array('taxonomy' => 'sp_league', 'name' => 'sp_league_dummy', 'class' => 'sp-dummy sp_league-dummy', 'show_option_all' => __('All', 'prosports'), 'selected' => $league_id, 'values' => 'term_id');
            sp_dropdown_taxonomies($args);
            ?>
				</p>
				<p class="sp-tab-select sp-tab-select-dummy">
					<?php 
            $args = array('taxonomy' => 'sp_season', 'name' => 'sp_season_dummy', 'class' => 'sp-dummy sp_season-dummy', 'show_option_all' => __('All', 'prosports'), 'selected' => $season_id, 'values' => 'term_id');
            sp_dropdown_taxonomies($args);
            ?>
				</p>
				<p class="sp-tab-select sp-title-generator">
				<?php 
            $args = array('post_type' => 'sp_team', 'name' => 'sp_team[]', 'class' => 'prosports-pages', 'show_option_none' => __('&mdash; None &mdash;', 'prosports'), 'show_option_all' => __('&mdash; Individual &mdash;', 'prosports'), 'values' => 'ID', 'selected' => $team);
            sp_dropdown_pages($args);
            ?>
				</p>
				<ul id="sp_team-tabs" class="wp-tab-bar sp-tab-bar">
					<li class="wp-tab-active"><a href="#sp_player-all"><?php 
            _e('Players', 'prosports');
            ?>
</a></li>
					<li class="wp-tab"><a href="#sp_staff-all"><?php 
            _e('Staff', 'prosports');
            ?>
</a></li>
				</ul>
				<?php 
            sp_post_checklist($post->ID, 'sp_player', 'block', array('sp_league', 'sp_season', 'sp_current_team'), $i);
            sp_post_checklist($post->ID, 'sp_staff', 'none', array('sp_league', 'sp_season', 'sp_current_team'), $i);
            ?>
			</div>
			<?php 
        }
    }
    function form($instance)
    {
        $instance = wp_parse_args((array) $instance, array('title' => '', 'id' => ''));
        $title = strip_tags($instance['title']);
        $id = intval($instance['id']);
        // Action to hook into
        do_action('sportspress_before_widget_template_form', $this, $instance, 'staff');
        ?>
		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'sportspress');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" /></p>

		<p><label for="<?php 
        echo $this->get_field_id('id');
        ?>
"><?php 
        printf(__('Select %s:', 'sportspress'), __('Staff', 'sportspress'));
        ?>
</label>
		<?php 
        $args = array('post_type' => 'sp_staff', 'name' => $this->get_field_name('id'), 'id' => $this->get_field_id('id'), 'selected' => $id, 'values' => 'ID', 'class' => 'widefat');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_staff', __('Add New', 'sportspress'));
        }
        ?>
		</p>

		<?php 
        // Action to hook into
        do_action('sportspress_after_widget_template_form', $this, $instance, 'staff');
    }
    /**
     * Output the details metabox
     */
    public static function details($post)
    {
        wp_nonce_field('prosports_save_data', 'prosports_meta_nonce');
        $league_id = sp_get_the_term_id($post->ID, 'sp_league', 0);
        $season_id = sp_get_the_term_id($post->ID, 'sp_season', 0);
        $rounds = get_post_meta($post->ID, 'sp_rounds', true);
        if ($rounds === '') {
            $rounds = 3;
        }
        $winner = get_post_meta($post->ID, 'sp_winner', true);
        ?>
		<div>
			<p><strong><?php 
        _e('Competition', 'prosports');
        ?>
</strong></p>
			<p>
				<?php 
        $args = array('show_option_all' => __('All', 'prosports'), 'taxonomy' => 'sp_league', 'name' => 'sp_league', 'selected' => $league_id, 'values' => 'term_id');
        if (!sp_dropdown_taxonomies($args)) {
            sp_taxonomy_adder('sp_league', 'sp_team', __('Add New', 'prosports'));
        }
        ?>
			</p>
			<p><strong><?php 
        _e('Season', 'prosports');
        ?>
</strong></p>
			<p class="sp-tab-select">
				<?php 
        $args = array('show_option_all' => __('All', 'prosports'), 'taxonomy' => 'sp_season', 'name' => 'sp_season', 'selected' => $season_id, 'values' => 'term_id');
        if (!sp_dropdown_taxonomies($args)) {
            sp_taxonomy_adder('sp_season', 'sp_team', __('Add New', 'prosports'));
        }
        ?>
			</p>
			<p><strong><?php 
        _e('Rounds', 'prosports');
        ?>
</strong></p>
			<p><input name="sp_rounds" type="number" min="1" max="6" value="<?php 
        echo $rounds;
        ?>
" placeholder="0" class="small-text sp-autosave"></p>
			<p><strong><?php 
        _e('Winner', 'prosports');
        ?>
</strong></p>
			<p>
				<?php 
        $args = array('show_option_none' => __('-- Not set --', 'prosports'), 'post_type' => 'sp_team', 'name' => 'sp_winner', 'selected' => $winner, 'values' => 'ID');
        sp_dropdown_pages($args);
        ?>
			</p>
		</div>
		<?php 
    }
    /**
     * Admin edit table
     */
    public static function table($columns = array(), $usecolumns = array(), $data = array(), $has_checkboxes = false)
    {
        // Get results with equations
        $args = array('post_type' => 'sp_result', 'numberposts' => -1, 'posts_per_page' => -1, 'meta_query' => array(array('key' => 'sp_equation', 'compare' => 'NOT IN', 'value' => null)));
        $dynamic_results = get_posts($args);
        $auto_columns = wp_list_pluck($dynamic_results, 'post_name');
        ?>
		<div class="sp-data-table-container">
			<table class="widefat sp-data-table">
				<thead>
					<tr>
						<th class="column-team">
							<?php 
        _e('Team', 'sportspress');
        ?>
						</th>
						<?php 
        foreach ($columns as $key => $label) {
            ?>
							<th class="column-<?php 
            echo $key;
            ?>
">
								<?php 
            if ($has_checkboxes) {
                ?>
									<label for="sp_result_columns_<?php 
                echo $key;
                ?>
">
										<input type="checkbox" name="sp_result_columns[]" value="<?php 
                echo $key;
                ?>
" id="sp_result_columns_<?php 
                echo $key;
                ?>
" <?php 
                checked(!is_array($usecolumns) || in_array($key, $usecolumns));
                ?>
>
										<?php 
                echo $label;
                ?>
									</label>
								<?php 
            } else {
                ?>
									<?php 
                echo $label;
                ?>
								<?php 
            }
            ?>
							</th>
						<?php 
        }
        ?>
						<th class="column-outcome">
							<?php 
        _e('Outcome', 'sportspress');
        ?>
						</th>
					</tr>
				</thead>
				<tbody>
					<?php 
        $i = 0;
        foreach ($data as $team_id => $team_results) {
            if (!$team_id || -1 == $team_id) {
                continue;
            }
            ?>
						<tr class="sp-row sp-post<?php 
            if ($i % 2 == 0) {
                echo ' alternate';
            }
            ?>
">
							<td>
								<?php 
            echo get_the_title($team_id);
            ?>
							</td>
							<?php 
            foreach ($columns as $column => $label) {
                $value = sp_array_value($team_results, $column, '');
                ?>
								<td><input type="text" name="sp_results[<?php 
                echo $team_id;
                ?>
][<?php 
                echo $column;
                ?>
]" value="<?php 
                echo esc_attr($value);
                ?>
"<?php 
                if (in_array($column, $auto_columns)) {
                    ?>
 placeholder="<?php 
                    _e('(Auto)', 'sportspress');
                    ?>
"<?php 
                }
                ?>
 /></td>
							<?php 
            }
            ?>
							<td>
								<?php 
            $values = sp_array_value($team_results, 'outcome', '');
            if (!is_array($values)) {
                $values = array($values);
            }
            $args = array('post_type' => 'sp_outcome', 'name' => 'sp_results[' . $team_id . '][outcome][]', 'option_none_value' => '', 'sort_order' => 'ASC', 'sort_column' => 'menu_order', 'selected' => $values, 'class' => 'sp-outcome', 'property' => 'multiple', 'chosen' => true, 'placeholder' => __('(Auto)', 'sportspress'));
            sp_dropdown_pages($args);
            ?>
							</td>
						</tr>
						<?php 
            $i++;
        }
        ?>
				</tbody>
			</table>
		</div>
		<?php 
    }
    function form($instance)
    {
        $instance = wp_parse_args((array) $instance, array('title' => '', 'id' => '', 'number' => 5, 'show_all_staff_link' => true));
        $title = strip_tags($instance['title']);
        $id = intval($instance['id']);
        $number = intval($instance['number']);
        $show_all_staff_link = $instance['show_all_staff_link'];
        // Action to hook into
        do_action('sportspress_before_widget_template_form', $this, $instance, 'staff-list');
        ?>
		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'sportspress');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" /></p>

		<p><label for="<?php 
        echo $this->get_field_id('id');
        ?>
"><?php 
        printf(__('Select %s:', 'sportspress'), __('Staff Directory', 'sportspress'));
        ?>
</label>
		<?php 
        $args = array('post_type' => 'sp_directory', 'name' => $this->get_field_name('id'), 'id' => $this->get_field_id('id'), 'selected' => $id, 'values' => 'ID', 'class' => 'widefat');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_directory', __('Add New', 'sportspress'));
        }
        ?>
		</p>

		<p><label for="<?php 
        echo $this->get_field_id('number');
        ?>
"><?php 
        _e('Number of staff to show:', 'sportspress');
        ?>
</label>
		<input id="<?php 
        echo $this->get_field_id('number');
        ?>
" name="<?php 
        echo $this->get_field_name('number');
        ?>
" type="text" value="<?php 
        echo esc_attr($number);
        ?>
" size="3"></p>

		<p><input class="checkbox" type="checkbox" id="<?php 
        echo $this->get_field_id('show_all_staff_link');
        ?>
" name="<?php 
        echo $this->get_field_name('show_all_staff_link');
        ?>
" value="1" <?php 
        checked($show_all_staff_link, 1);
        ?>
>
		<label for="<?php 
        echo $this->get_field_id('show_all_staff_link');
        ?>
"><?php 
        _e('Display link to view all staff', 'sportspress');
        ?>
</label></p>

		<?php 
        // Action to hook into
        do_action('sportspress_after_widget_template_form', $this, $instance, 'staff-list');
    }
    /**
     * Output the metabox
     */
    public static function output($post)
    {
        $status = get_post_meta($post->ID, 'sp_status', true);
        $date = get_post_meta($post->ID, 'sp_date', true);
        $date_from = get_post_meta($post->ID, 'sp_date_from', true);
        $date_to = get_post_meta($post->ID, 'sp_date_to', true);
        $league_id = sp_get_the_term_id($post->ID, 'sp_league', 0);
        $season_id = sp_get_the_term_id($post->ID, 'sp_season', 0);
        $venue_id = sp_get_the_term_id($post->ID, 'sp_venue', 0);
        $team_id = get_post_meta($post->ID, 'sp_team', true);
        $order = get_post_meta($post->ID, 'sp_order', true);
        ?>
		<div>
			<p><strong><?php 
        _e('Status', 'prosports');
        ?>
</strong></p>
			<p>
				<?php 
        $args = array('name' => 'sp_status', 'id' => 'sp_status', 'selected' => $status);
        sp_dropdown_statuses($args);
        ?>
			</p>
			<div class="sp-date-selector">
				<p><strong><?php 
        _e('Date', 'prosports');
        ?>
</strong></p>
				<p>
					<?php 
        $args = array('name' => 'sp_date', 'id' => 'sp_date', 'selected' => $date);
        sp_dropdown_dates($args);
        ?>
				</p>
				<p class="sp-date-range">
					<input type="text" class="sp-datepicker-from" name="sp_date_from" value="<?php 
        echo $date_from ? $date_from : date_i18n('Y-m-d');
        ?>
" size="10">
					:
					<input type="text" class="sp-datepicker-to" name="sp_date_to" value="<?php 
        echo $date_to ? $date_to : date_i18n('Y-m-d');
        ?>
" size="10">
				</p>
			</div>
			<p><strong><?php 
        _e('Competition', 'prosports');
        ?>
</strong></p>
			<p>
				<?php 
        $args = array('show_option_all' => __('All', 'prosports'), 'taxonomy' => 'sp_league', 'name' => 'sp_league', 'selected' => $league_id, 'values' => 'term_id');
        if (!sp_dropdown_taxonomies($args)) {
            sp_taxonomy_adder('sp_league', 'sp_team', __('Add New', 'prosports'));
        }
        ?>
			</p>
			<p><strong><?php 
        _e('Season', 'prosports');
        ?>
</strong></p>
			<p class="sp-tab-select">
				<?php 
        $args = array('show_option_all' => __('All', 'prosports'), 'taxonomy' => 'sp_season', 'name' => 'sp_season', 'selected' => $season_id, 'values' => 'term_id');
        if (!sp_dropdown_taxonomies($args)) {
            sp_taxonomy_adder('sp_season', 'sp_team', __('Add New', 'prosports'));
        }
        ?>
			</p>
			<p><strong><?php 
        _e('Venue', 'prosports');
        ?>
</strong></p>
			<p>
				<?php 
        $args = array('show_option_all' => __('All', 'prosports'), 'taxonomy' => 'sp_venue', 'name' => 'sp_venue', 'selected' => $venue_id, 'values' => 'term_id');
        if (!sp_dropdown_taxonomies($args)) {
            sp_taxonomy_adder('sp_season', 'sp_team', __('Add New', 'prosports'));
        }
        ?>
			</p>
			<p><strong><?php 
        _e('Team', 'prosports');
        ?>
</strong></p>
			<p>
				<?php 
        $args = array('show_option_all' => __('All', 'prosports'), 'post_type' => 'sp_team', 'name' => 'sp_team', 'selected' => $team_id, 'values' => 'ID');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_team', __('Add New', 'prosports'));
        }
        ?>
			</p>
			<p><strong><?php 
        _e('Sort Order', 'prosports');
        ?>
</strong></p>
			<p>
				<select name="sp_order">
					<option value="ASC" <?php 
        selected('ASC', $order);
        ?>
><?php 
        _e('Ascending', 'prosports');
        ?>
</option>
					<option value="DESC" <?php 
        selected('DESC', $order);
        ?>
><?php 
        _e('Descending', 'prosports');
        ?>
</option>
				</select>
			</p>
		</div>
		<?php 
    }
    /**
     * Admin edit table
     */
    public static function table($id = null, $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $leagues = array(), $has_checkboxes = false, $readonly = false)
    {
        $teams = array_filter(get_post_meta($id, 'sp_team', false));
        ?>
		<div class="sp-data-table-container">
			<table class="widefat sp-data-table">
				<thead>
					<tr>
						<th><?php 
        _e('Season', 'sportspress');
        ?>
</th>
						<?php 
        if (apply_filters('sportspress_player_team_statistics', $league_id)) {
            ?>
							<th>
								<?php 
            if ($has_checkboxes) {
                ?>
									<label for="sp_columns_team">
										<input type="checkbox" name="sp_columns[]" value="team" id="sp_columns_team" <?php 
                checked(!is_array($columns) || array_key_exists('team', $columns));
                ?>
>
										<?php 
                _e('Team', 'sportspress');
                ?>
									</label>
								<?php 
            } else {
                ?>
									<?php 
                _e('Team', 'sportspress');
                ?>
								<?php 
            }
            ?>
							</th>
						<?php 
        }
        ?>
						<?php 
        foreach ($columns as $key => $label) {
            if ($key == 'team') {
                continue;
            }
            ?>
							<th><?php 
            echo $label;
            ?>
</th>
						<?php 
        }
        ?>
					</tr>
				</thead>
				<tbody>
					<?php 
        $i = 0;
        foreach ($data as $div_id => $div_stats) {
            if ($div_id === 'statistics') {
                continue;
            }
            $div = get_term($div_id, 'sp_season');
            ?>
						<tr class="sp-row sp-post<?php 
            if ($i % 2 == 0) {
                echo ' alternate';
            }
            ?>
">
							<td>
								<?php 
            if (0 !== $div_id) {
                ?>
									<label>
										<?php 
                if (!apply_filters('sportspress_player_team_statistics', $league_id)) {
                    ?>
											<?php 
                    $value = sp_array_value($leagues, $div_id, '-1');
                    ?>
											<input type="hidden" name="sp_leagues[<?php 
                    echo $league_id;
                    ?>
][<?php 
                    echo $div_id;
                    ?>
]" value="-1">
											<input type="checkbox" name="sp_leagues[<?php 
                    echo $league_id;
                    ?>
][<?php 
                    echo $div_id;
                    ?>
]" value="1" <?php 
                    checked($value);
                    ?>
>
										<?php 
                }
                ?>
										<?php 
                if ('WP_Error' == get_class($div)) {
                    _e('Total', 'sportspress');
                } else {
                    echo $div->name;
                }
                ?>
									</label>
								<?php 
            } else {
                ?>
									<?php 
                if ('WP_Error' == get_class($div)) {
                    _e('Total', 'sportspress');
                } else {
                    echo $div->name;
                }
                ?>
								<?php 
            }
            ?>
							</td>
							<?php 
            if (apply_filters('sportspress_player_team_statistics', $league_id)) {
                ?>
								<?php 
                if ($div_id == 0) {
                    ?>
									<td>&nbsp;</td>
								<?php 
                } else {
                    ?>
									<td>
										<?php 
                    $value = sp_array_value($leagues, $div_id, '-1');
                    ?>
										<?php 
                    $args = array('post_type' => 'sp_team', 'name' => 'sp_leagues[' . $league_id . '][' . $div_id . ']', 'show_option_none' => __('&mdash; None &mdash;', 'sportspress'), 'sort_order' => 'ASC', 'sort_column' => 'menu_order', 'selected' => $value, 'values' => 'ID', 'include' => $teams, 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'sp_league', 'terms' => $league_id, 'field' => 'id'), array('taxonomy' => 'sp_season', 'terms' => $div_id, 'field' => 'id')));
                    if (!sp_dropdown_pages($args)) {
                        _e('&mdash; None &mdash;', 'sportspress');
                    }
                    ?>
									</td>
								<?php 
                }
                ?>
							<?php 
            }
            ?>
							<?php 
            foreach ($columns as $column => $label) {
                if ($column == 'team') {
                    continue;
                }
                ?>
								<td><?php 
                $value = sp_array_value(sp_array_value($data, $div_id, array()), $column, null);
                $placeholder = sp_array_value(sp_array_value($placeholders, $div_id, array()), $column, 0);
                if ($readonly) {
                    echo $value ? $value : $placeholder;
                } else {
                    echo '<input type="text" name="sp_statistics[' . $league_id . '][' . $div_id . '][' . $column . ']" value="' . $value . '" placeholder="' . $placeholder . '"' . ($readonly ? ' disabled="disabled"' : '') . '  />';
                }
                ?>
</td>
							<?php 
            }
            ?>
						</tr>
						<?php 
            $i++;
        }
        ?>
				</tbody>
			</table>
		</div>
		<?php 
    }
    function form($instance)
    {
        $instance = wp_parse_args((array) $instance, array('title' => '', 'id' => '', 'number' => 5, 'columns' => null, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true));
        $title = strip_tags($instance['title']);
        $id = intval($instance['id']);
        $number = intval($instance['number']);
        $columns = $instance['columns'];
        $orderby = strip_tags($instance['orderby']);
        $order = strip_tags($instance['order']);
        $show_all_players_link = $instance['show_all_players_link'];
        // Action to hook into
        do_action('prosports_before_widget_template_form', $this, $instance, 'player-list');
        ?>
		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'prosports');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" /></p>

		<p><label for="<?php 
        echo $this->get_field_id('id');
        ?>
"><?php 
        printf(__('Select %s:', 'prosports'), __('Player List', 'prosports'));
        ?>
</label>
		<?php 
        $args = array('post_type' => 'sp_list', 'name' => $this->get_field_name('id'), 'id' => $this->get_field_id('id'), 'selected' => $id, 'values' => 'ID', 'class' => 'widefat');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_list', __('Add New', 'prosports'));
        }
        ?>
		</p>

		<p><label for="<?php 
        echo $this->get_field_id('number');
        ?>
"><?php 
        _e('Number of players to show:', 'prosports');
        ?>
</label>
		<input id="<?php 
        echo $this->get_field_id('number');
        ?>
" name="<?php 
        echo $this->get_field_name('number');
        ?>
" type="text" value="<?php 
        echo esc_attr($number);
        ?>
" size="3"></p>

		<p class="sp-prefs">
			<?php 
        _e('Performance:', 'prosports');
        ?>
<br>
			<?php 
        $args = array('post_type' => array('sp_metric', 'sp_performance', 'sp_statistic'), 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC');
        $the_columns = get_posts($args);
        $field_name = $this->get_field_name('columns') . '[]';
        $field_id = $this->get_field_id('columns');
        ?>
			<?php 
        foreach ($the_columns as $column) {
            ?>
				<label class="button"><input name="<?php 
            echo $field_name;
            ?>
" type="checkbox" id="<?php 
            echo $field_id . '-' . $column->post_name;
            ?>
" value="<?php 
            echo $column->post_name;
            ?>
" <?php 
            if ($columns === null || in_array($column->post_name, $columns)) {
                ?>
checked="checked"<?php 
            }
            ?>
><?php 
            echo $column->post_title;
            ?>
</label>
			<?php 
        }
        ?>
		</p>

		<p><label for="<?php 
        echo $this->get_field_id('orderby');
        ?>
"><?php 
        _e('Sort by:', 'prosports');
        ?>
</label>
		<?php 
        $args = array('prepend_options' => array('default' => __('Default', 'prosports'), 'number' => __('Number', 'prosports'), 'name' => __('Name', 'prosports'), 'eventsplayed' => __('Played', 'prosports')), 'post_type' => array('sp_metric', 'sp_performance', 'sp_statistic'), 'name' => $this->get_field_name('orderby'), 'id' => $this->get_field_id('orderby'), 'selected' => $orderby, 'values' => 'slug', 'class' => 'sp-select-orderby widefat');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_list', __('Add New', 'prosports'));
        }
        ?>
		</p>

		<p><label for="<?php 
        echo $this->get_field_id('order');
        ?>
"><?php 
        _e('Sort Order:', 'prosports');
        ?>
</label>
		<select name="<?php 
        echo $this->get_field_name('order');
        ?>
" id="<?php 
        echo $this->get_field_id('order');
        ?>
" class="sp-select-order widefat" <?php 
        disabled($orderby, 'default');
        ?>
>
			<option value="ASC" <?php 
        selected('ASC', $order);
        ?>
><?php 
        _e('Ascending', 'prosports');
        ?>
</option>
			<option value="DESC" <?php 
        selected('DESC', $order);
        ?>
><?php 
        _e('Descending', 'prosports');
        ?>
</option>
		</select></p>

		<p><input class="checkbox" type="checkbox" id="<?php 
        echo $this->get_field_id('show_all_players_link');
        ?>
" name="<?php 
        echo $this->get_field_name('show_all_players_link');
        ?>
" value="1" <?php 
        checked($show_all_players_link, 1);
        ?>
>
		<label for="<?php 
        echo $this->get_field_id('show_all_players_link');
        ?>
"><?php 
        _e('Display link to view all players', 'prosports');
        ?>
</label></p>

		<?php 
        // Action to hook into
        do_action('prosports_after_widget_template_form', $this, $instance, 'player-list');
    }
    /**
     * Output the metabox
     */
    public static function output($post)
    {
        $league_id = sp_get_the_term_id($post->ID, 'sp_league', 0);
        $season_id = sp_get_the_term_id($post->ID, 'sp_season', 0);
        $team_id = get_post_meta($post->ID, 'sp_team', true);
        $grouping = get_post_meta($post->ID, 'sp_grouping', true);
        $orderby = get_post_meta($post->ID, 'sp_orderby', true);
        $order = get_post_meta($post->ID, 'sp_order', true);
        ?>
		<div>
			<p><strong><?php 
        _e('Competition', 'prosports');
        ?>
</strong></p>
			<p class="sp-tab-select">
				<?php 
        $args = array('taxonomy' => 'sp_league', 'name' => 'sp_league', 'show_option_all' => __('All', 'prosports'), 'selected' => $league_id, 'values' => 'term_id');
        if (!sp_dropdown_taxonomies($args)) {
            sp_taxonomy_adder('sp_league', 'sp_team', __('Add New', 'prosports'));
        }
        ?>
			</p>
			<p><strong><?php 
        _e('Season', 'prosports');
        ?>
</strong></p>
			<p class="sp-tab-select">
				<?php 
        $args = array('taxonomy' => 'sp_season', 'name' => 'sp_season', 'show_option_all' => __('All', 'prosports'), 'selected' => $season_id, 'values' => 'term_id');
        if (!sp_dropdown_taxonomies($args)) {
            sp_taxonomy_adder('sp_season', 'sp_team', __('Add New', 'prosports'));
        }
        ?>
			</p>
			<p><strong><?php 
        _e('Team', 'prosports');
        ?>
</strong></p>
			<p class="sp-tab-select">
				<?php 
        $args = array('post_type' => 'sp_team', 'name' => 'sp_team', 'show_option_all' => __('All', 'prosports'), 'selected' => $team_id, 'values' => 'ID');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_team', __('Add New', 'prosports'));
        }
        ?>
			</p>
			<p><strong><?php 
        _e('Grouping', 'prosports');
        ?>
</strong></p>
			<p>
			<select name="sp_grouping">
				<option value="0"><?php 
        _e('None', 'prosports');
        ?>
</option>
				<option value="position" <?php 
        selected($grouping, 'position');
        ?>
><?php 
        _e('Position', 'prosports');
        ?>
</option>
			</select>
			</p>
			<p><strong><?php 
        _e('Sort by', 'prosports');
        ?>
</strong></p>
			<p>
			<?php 
        $args = array('prepend_options' => array('number' => __('Number', 'prosports'), 'name' => __('Name', 'prosports')), 'post_type' => array('sp_performance', 'sp_metric', 'sp_statistic'), 'name' => 'sp_orderby', 'selected' => $orderby, 'values' => 'slug');
        sp_dropdown_pages($args);
        ?>
			</p>
			<p><strong><?php 
        _e('Sort Order', 'prosports');
        ?>
</strong></p>
			<p>
				<select name="sp_order">
					<option value="ASC" <?php 
        selected('ASC', $order);
        ?>
><?php 
        _e('Ascending', 'prosports');
        ?>
</option>
					<option value="DESC" <?php 
        selected('DESC', $order);
        ?>
><?php 
        _e('Descending', 'prosports');
        ?>
</option>
				</select>
			</p>
			<p><strong><?php 
        _e('Players', 'prosports');
        ?>
</strong></p>
			<?php 
        sp_post_checklist($post->ID, 'sp_player', 'block', array('sp_league', 'sp_season', 'sp_current_team'));
        sp_post_adder('sp_player', __('Add New', 'prosports'));
        ?>
		</div>
		<?php 
    }
    /**
     * Output the metabox
     */
    public static function output($post)
    {
        $taxonomies = get_object_taxonomies('sp_calendar');
        $caption = get_post_meta($post->ID, 'sp_caption', true);
        $status = get_post_meta($post->ID, 'sp_status', true);
        $date = get_post_meta($post->ID, 'sp_date', true);
        $date_from = get_post_meta($post->ID, 'sp_date_from', true);
        $date_to = get_post_meta($post->ID, 'sp_date_to', true);
        $day = get_post_meta($post->ID, 'sp_day', true);
        $teams = get_post_meta($post->ID, 'sp_team', false);
        $table_id = get_post_meta($post->ID, 'sp_table', true);
        $orderby = get_post_meta($post->ID, 'sp_orderby', true);
        $order = get_post_meta($post->ID, 'sp_order', true);
        ?>
		<div>
			<p><strong><?php 
        _e('Heading', 'sportspress');
        ?>
</strong></p>
			<p><input type="text" id="sp_caption" name="sp_caption" value="<?php 
        echo esc_attr($caption);
        ?>
" placeholder="<?php 
        echo esc_attr(get_the_title());
        ?>
"></p>

			<p><strong><?php 
        _e('Status', 'sportspress');
        ?>
</strong></p>
			<p>
				<?php 
        $args = array('name' => 'sp_status', 'id' => 'sp_status', 'selected' => $status);
        sp_dropdown_statuses($args);
        ?>
			</p>
			<div class="sp-date-selector">
				<p><strong><?php 
        _e('Date', 'sportspress');
        ?>
</strong></p>
				<p>
					<?php 
        $args = array('name' => 'sp_date', 'id' => 'sp_date', 'selected' => $date);
        sp_dropdown_dates($args);
        ?>
				</p>
				<p class="sp-date-range">
					<input type="text" class="sp-datepicker-from" name="sp_date_from" value="<?php 
        echo $date_from ? $date_from : date_i18n('Y-m-d');
        ?>
" size="10">
					:
					<input type="text" class="sp-datepicker-to" name="sp_date_to" value="<?php 
        echo $date_to ? $date_to : date_i18n('Y-m-d');
        ?>
" size="10">
				</p>
			</div>
			<div class="sp-event-day-field">
				<p><strong><?php 
        _e('Match Day', 'sportspress');
        ?>
</strong></p>
				<p>
					<input name="sp_day" type="text" class="medium-text" placeholder="<?php 
        _e('All', 'sportspress');
        ?>
" value="<?php 
        echo esc_attr($day);
        ?>
">
				</p>
			</div>
			<?php 
        foreach ($taxonomies as $taxonomy) {
            sp_taxonomy_field($taxonomy, $post, true);
        }
        ?>
			<p><strong><?php 
        _e('Team', 'sportspress');
        ?>
</strong></p>
			<p>
				<?php 
        $args = array('post_type' => 'sp_team', 'name' => 'sp_team[]', 'selected' => $teams, 'values' => 'ID', 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true, 'placeholder' => __('All', 'sportspress'));
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_team', __('Add New', 'sportspress'));
        }
        ?>
			</p>
			<p><strong><?php 
        _e('Sort by', 'sportspress');
        ?>
</strong></p>
			<p>
				<select name="sp_orderby">
					<option value="date" <?php 
        selected('date', $orderby);
        ?>
><?php 
        _e('Date', 'sportspress');
        ?>
</option>
					<option value="day" <?php 
        selected('day', $orderby);
        ?>
><?php 
        _e('Match Day', 'sportspress');
        ?>
</option>
				</select>
			</p>
			<p><strong><?php 
        _e('Sort Order', 'sportspress');
        ?>
</strong></p>
			<p>
				<select name="sp_order">
					<option value="ASC" <?php 
        selected('ASC', $order);
        ?>
><?php 
        _e('Ascending', 'sportspress');
        ?>
</option>
					<option value="DESC" <?php 
        selected('DESC', $order);
        ?>
><?php 
        _e('Descending', 'sportspress');
        ?>
</option>
				</select>
			</p>
		</div>
		<?php 
    }
    /**
     * Output the metabox
     */
    public static function output($post)
    {
        $limit = get_option('sportspress_event_teams', 2);
        $teams = (array) get_post_meta($post->ID, 'sp_team', false);
        if ($limit) {
            for ($i = 0; $i < $limit; $i++) {
                $team = array_shift($teams);
                ?>
				<div class="sp-instance">
					<p class="sp-tab-select sp-title-generator">
					<?php 
                $args = array('post_type' => 'sp_team', 'name' => 'sp_team[]', 'class' => 'sportspress-pages', 'show_option_none' => __('&mdash; None &mdash;', 'sportspress'), 'values' => 'ID', 'selected' => $team, 'chosen' => true, 'tax_query' => array());
                if ('yes' == get_option('sportspress_event_filter_teams_by_league', 'no')) {
                    $league_id = sp_get_the_term_id($post->ID, 'sp_league', 0);
                    if ($league_id) {
                        $args['tax_query'][] = array('taxonomy' => 'sp_league', 'terms' => $league_id);
                    }
                }
                if ('yes' == get_option('sportspress_event_filter_teams_by_season', 'no')) {
                    $season_id = sp_get_the_term_id($post->ID, 'sp_season', 0);
                    if ($season_id) {
                        $args['tax_query'][] = array('taxonomy' => 'sp_season', 'terms' => $season_id);
                    }
                }
                if (!sp_dropdown_pages($args)) {
                    unset($args['tax_query']);
                    sp_dropdown_pages($args);
                }
                ?>
					</p>
					<?php 
                $tabs = array();
                $sections = get_option('sportspress_event_performance_sections', -1);
                if (0 == $sections) {
                    $tabs['sp_offense'] = array('label' => __('Offense', 'sportspress'), 'post_type' => 'sp_player');
                    $tabs['sp_defense'] = array('label' => __('Defense', 'sportspress'), 'post_type' => 'sp_player');
                } elseif (1 == $sections) {
                    $tabs['sp_defense'] = array('label' => __('Defense', 'sportspress'), 'post_type' => 'sp_player');
                    $tabs['sp_offense'] = array('label' => __('Offense', 'sportspress'), 'post_type' => 'sp_player');
                } else {
                    $tabs['sp_player'] = array('label' => __('Players', 'sportspress'), 'post_type' => 'sp_player');
                }
                $tabs['sp_staff'] = array('label' => __('Staff', 'sportspress'), 'post_type' => 'sp_staff');
                ?>
					<?php 
                if ($tabs) {
                    ?>
					<ul id="sp_team-tabs" class="wp-tab-bar sp-tab-bar">
						<?php 
                    $j = 0;
                    foreach ($tabs as $slug => $tab) {
                        ?>
								<li class="wp-tab<?php 
                        if (0 == $j) {
                            ?>
-active<?php 
                        }
                        ?>
"><a href="#<?php 
                        echo $slug;
                        ?>
-all"><?php 
                        echo $tab['label'];
                        ?>
</a></li>
								<?php 
                        $j++;
                    }
                    ?>
					</ul>
					<?php 
                    $j = 0;
                    foreach ($tabs as $slug => $tab) {
                        do_action('sportspress_event_teams_meta_box_checklist', $post->ID, $tab['post_type'], 0 == $j ? 'block' : 'none', $team, $i, $slug);
                        $j++;
                    }
                    ?>
					<?php 
                }
                ?>
				</div>
				<?php 
            }
        } else {
            ?>
			<p><strong><?php 
            printf(__('Select %s:', 'sportspress'), __('Teams', 'sportspress'));
            ?>
</strong></p>
			<?php 
            $args = array('post_type' => 'sp_team', 'name' => 'sp_team[]', 'selected' => $teams, 'values' => 'ID', 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true, 'placeholder' => __('None', 'sportspress'));
            if (!sp_dropdown_pages($args)) {
                sp_post_adder('sp_team', __('Add New', 'sportspress'));
            }
        }
        wp_nonce_field('sp-get-players', 'sp-get-players-nonce', false);
    }
    /**
     * AJAX staff_gallery shortcode
     */
    public function staff_gallery_shortcode()
    {
        ?>
		<div class="wrap sp-thickbox-content" id="sp-thickbox-staff_gallery">
			<p>
				<label>
					<?php 
        _e('Title:', 'sportspress');
        ?>
					<input class="regular-text" type="text" name="title">
				</label>
			</p>
			<p>
				<label>
					<?php 
        printf(__('Select %s:', 'sportspress'), __('Directory', 'sportspress'));
        ?>
					<?php 
        $args = array('post_type' => 'sp_directory', 'name' => 'id', 'values' => 'ID');
        sp_dropdown_pages($args);
        ?>
				</label>
			</p>
			<p>
				<label>
					<?php 
        _e('Number of staff to show:', 'sportspress');
        ?>
					<input type="text" size="3" name="number" id="number" value="5">
				</label>
			</p>
			<p>
				<label>
					<input type="checkbox" name="show_all_staff_link" id="show_all_staff_link">
					<?php 
        _e('Display link to view all staff', 'sportspress');
        ?>
				</label>
			</p>
			<?php 
        do_action('sportspress_ajax_shortcode_form', 'staff-gallery');
        ?>
			<p class="submit">
				<input type="button" class="button-primary" value="<?php 
        _e('Insert Shortcode', 'sportspress');
        ?>
" onclick="insertSportsPress('staff_gallery');" />
				<a class="button-secondary" onclick="tb_remove();" title="<?php 
        _e('Cancel', 'sportspress');
        ?>
"><?php 
        _e('Cancel', 'sportspress');
        ?>
</a>
			</p>
		</div>
		<?php 
        self::scripts();
        die;
    }
    /**
     * Output the details metabox
     */
    public static function details($post)
    {
        wp_nonce_field('sportspress_save_data', 'sportspress_meta_nonce');
        $limit = get_option('sportspress_tournament_rounds', '6');
        $taxonomies = get_object_taxonomies('sp_tournament');
        $rounds = get_post_meta($post->ID, 'sp_rounds', true);
        if ($rounds === '') {
            $rounds = 3;
        }
        $winner = get_post_meta($post->ID, 'sp_winner', true);
        ?>
		<div>
			<?php 
        foreach ($taxonomies as $taxonomy) {
            sp_taxonomy_field($taxonomy, $post, true);
        }
        ?>
			<p><strong><?php 
        _e('Rounds', 'sportspress');
        ?>
</strong></p>
			<p><input name="sp_rounds" type="number" min="1" max="<?php 
        echo esc_attr($limit);
        ?>
" value="<?php 
        echo $rounds;
        ?>
" placeholder="0" class="small-text sp-autosave"></p>
			<p><strong><?php 
        _e('Winner', 'sportspress');
        ?>
</strong></p>
			<p>
				<?php 
        $args = array('show_option_none' => __('&mdash; Not set &mdash;', 'sportspress'), 'post_type' => 'sp_team', 'name' => 'sp_winner', 'selected' => $winner, 'values' => 'ID');
        sp_dropdown_pages($args);
        ?>
			</p>
		</div>
		<?php 
    }
        /**
         * Add team selector to user profile.
         */
        public function profile($user)
        {
            $roles = $user->roles;
            $role = array_shift($roles);
            if (!$this->role_is_limited($role)) {
                return;
            }
            $teams = get_user_meta($user->ID, 'sp_team', false);
            ?>
		<h3><?php 
            _e('Team Access', 'sportspress');
            ?>
</h3>
		<table class="form-table">
			<tr>
				<th>
					<?php 
            _e('Team', 'sportspress');
            ?>
				</th>
				<td>
					<?php 
            $args = array('post_type' => 'sp_team', 'name' => 'sp_team[]', 'selected' => $teams, 'values' => 'ID', 'class' => 'widefat', 'placeholder' => __('All', 'sportspress'), 'property' => 'multiple', 'chosen' => true);
            sp_dropdown_pages($args);
            ?>
				</td>
			</tr>
		</table>
		<?php 
        }
    /**
     * Output the metabox
     */
    public static function output($post)
    {
        $limit = get_option('sportspress_event_teams', 2);
        $teams = (array) get_post_meta($post->ID, 'sp_team', false);
        for ($i = 0; $i < $limit; $i++) {
            $team = array_shift($teams);
            ?>
			<div class="sp-instance">
				<p class="sp-tab-select sp-title-generator">
				<?php 
            $args = array('post_type' => 'sp_team', 'name' => 'sp_team[]', 'class' => 'sportspress-pages', 'show_option_none' => __('&mdash; None &mdash;', 'sportspress'), 'values' => 'ID', 'selected' => $team, 'chosen' => true, 'tax_query' => array());
            if ('yes' == get_option('sportspress_event_filter_teams_by_league', 'no')) {
                $league_id = sp_get_the_term_id($post->ID, 'sp_league', 0);
                if ($league_id) {
                    $args['tax_query'][] = array('taxonomy' => 'sp_league', 'terms' => $league_id);
                }
            }
            if ('yes' == get_option('sportspress_event_filter_teams_by_season', 'no')) {
                $season_id = sp_get_the_term_id($post->ID, 'sp_season', 0);
                if ($season_id) {
                    $args['tax_query'][] = array('taxonomy' => 'sp_season', 'terms' => $season_id);
                }
            }
            if (!sp_dropdown_pages($args)) {
                unset($args['tax_query']);
                sp_dropdown_pages($args);
            }
            ?>
				</p>
				<?php 
            $tabs = apply_filters('sportspress_event_team_tabs', array('sp_player', 'sp_staff'));
            ?>
				<?php 
            if ($tabs) {
                ?>
				<ul id="sp_team-tabs" class="wp-tab-bar sp-tab-bar">
					<?php 
                foreach ($tabs as $index => $post_type) {
                    $object = get_post_type_object($post_type);
                    ?>
					<li class="wp-tab<?php 
                    if (0 == $index) {
                        ?>
-active<?php 
                    }
                    ?>
"><a href="#<?php 
                    echo $post_type;
                    ?>
-all"><?php 
                    echo $object->labels->name;
                    ?>
</a></li>
					<?php 
                }
                ?>
				</ul>
				<?php 
                foreach ($tabs as $index => $post_type) {
                    sp_post_checklist($post->ID, $post_type, 0 == $index ? 'block' : 'none', array('sp_league', 'sp_season', 'sp_current_team'), $i);
                }
                ?>
				<?php 
            }
            ?>
			</div>
			<?php 
        }
    }
    /**
     * Output the metabox
     */
    public static function output($post)
    {
        wp_nonce_field('sportspress_save_data', 'sportspress_meta_nonce');
        $continents = SP()->countries->continents;
        $number = get_post_meta($post->ID, 'sp_number', true);
        $nationality = get_post_meta($post->ID, 'sp_nationality', true);
        if (2 == strlen($nationality)) {
            $legacy = SP()->countries->legacy;
            $nationality = strtolower($nationality);
            $nationality = sp_array_value($legacy, $nationality, null);
        }
        $leagues = get_the_terms($post->ID, 'sp_league');
        $league_ids = array();
        if ($leagues) {
            foreach ($leagues as $league) {
                $league_ids[] = $league->term_id;
            }
        }
        $seasons = get_the_terms($post->ID, 'sp_season');
        $season_ids = array();
        if ($seasons) {
            foreach ($seasons as $season) {
                $season_ids[] = $season->term_id;
            }
        }
        $positions = get_the_terms($post->ID, 'sp_position');
        $position_ids = array();
        if ($positions) {
            foreach ($positions as $position) {
                $position_ids[] = $position->term_id;
            }
        }
        $teams = get_posts(array('post_type' => 'sp_team', 'posts_per_page' => -1));
        $past_teams = array_filter(get_post_meta($post->ID, 'sp_past_team', false));
        $current_teams = array_filter(get_post_meta($post->ID, 'sp_current_team', false));
        ?>
		<p><strong><?php 
        _e('Squad Number', 'sportspress');
        ?>
</strong></p>
		<p><input type="text" size="4" id="sp_number" name="sp_number" value="<?php 
        echo $number;
        ?>
"></p>

		<p><strong><?php 
        _e('Nationality', 'sportspress');
        ?>
</strong></p>
		<p><select id="sp_nationality" name="sp_nationality" data-placeholder="<?php 
        printf(__('Select %s', 'sportspress'), __('Nationality', 'sportspress'));
        ?>
" class="widefat chosen-select<?php 
        if (is_rtl()) {
            ?>
 chosen-rtl<?php 
        }
        ?>
">
			<option value=""></option>
			<?php 
        foreach ($continents as $continent => $countries) {
            ?>
				<optgroup label="<?php 
            echo $continent;
            ?>
">
					<?php 
            foreach ($countries as $code => $country) {
                ?>
						<option value="<?php 
                echo $code;
                ?>
" <?php 
                selected($nationality, $code);
                ?>
><?php 
                echo $country;
                ?>
</option>
					<?php 
            }
            ?>
				</optgroup>
			<?php 
        }
        ?>
		</select></p>

		<p><strong><?php 
        _e('Positions', 'sportspress');
        ?>
</strong></p>
		<p><?php 
        $args = array('taxonomy' => 'sp_position', 'name' => 'tax_input[sp_position][]', 'selected' => $position_ids, 'values' => 'term_id', 'placeholder' => sprintf(__('Select %s', 'sportspress'), __('Positions', 'sportspress')), 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true);
        sp_dropdown_taxonomies($args);
        ?>
</p>

		<?php 
        if (apply_filters('sportspress_player_teams', true)) {
            ?>
		<p><strong><?php 
            _e('Current Teams', 'sportspress');
            ?>
</strong></p>
		<p><?php 
            $args = array('post_type' => 'sp_team', 'name' => 'sp_current_team[]', 'selected' => $current_teams, 'values' => 'ID', 'placeholder' => sprintf(__('Select %s', 'sportspress'), __('Teams', 'sportspress')), 'class' => 'sp-current-teams widefat', 'property' => 'multiple', 'chosen' => true);
            sp_dropdown_pages($args);
            ?>
</p>

		<p><strong><?php 
            _e('Past Teams', 'sportspress');
            ?>
</strong></p>
		<p><?php 
            $args = array('post_type' => 'sp_team', 'name' => 'sp_past_team[]', 'selected' => $past_teams, 'values' => 'ID', 'placeholder' => sprintf(__('Select %s', 'sportspress'), __('Teams', 'sportspress')), 'class' => 'sp-past-teams widefat', 'property' => 'multiple', 'chosen' => true);
            sp_dropdown_pages($args);
            ?>
</p>
		<?php 
        }
        ?>

		<p><strong><?php 
        _e('Competitions', 'sportspress');
        ?>
</strong></p>
		<p><?php 
        $args = array('taxonomy' => 'sp_league', 'name' => 'tax_input[sp_league][]', 'selected' => $league_ids, 'values' => 'term_id', 'placeholder' => sprintf(__('Select %s', 'sportspress'), __('Competitions', 'sportspress')), 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true);
        sp_dropdown_taxonomies($args);
        ?>
</p>

		<p><strong><?php 
        _e('Seasons', 'sportspress');
        ?>
</strong></p>
		<p><?php 
        $args = array('taxonomy' => 'sp_season', 'name' => 'tax_input[sp_season][]', 'selected' => $season_ids, 'values' => 'term_id', 'placeholder' => sprintf(__('Select %s', 'sportspress'), __('Seasons', 'sportspress')), 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true);
        sp_dropdown_taxonomies($args);
        ?>
</p>
		<?php 
    }
    /**
     * Admin edit table
     */
    public static function table($labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false)
    {
        ?>
		<div class="sp-data-table-container">
			<table class="widefat sp-data-table sp-performance-table sp-sortable-table">
				<thead>
					<tr>
						<th class="icon">&nbsp;</th>
						<th>#</th>
						<th><?php 
        _e('Player', 'prosports');
        ?>
</th>
						<th>
							<?php 
        if ($has_checkboxes) {
            ?>
								<label for="sp_columns_position">
									<input type="checkbox" name="sp_columns[]" value="position" id="sp_columns_position" <?php 
            checked(!is_array($columns) || in_array('position', $columns));
            ?>
>
									<?php 
            _e('Position', 'prosports');
            ?>
								</label>
							<?php 
        } else {
            ?>
								<?php 
            _e('Position', 'prosports');
            ?>
							<?php 
        }
        ?>
						</th>
						<?php 
        foreach ($labels as $key => $label) {
            ?>
							<th>
								<?php 
            if ($has_checkboxes) {
                ?>
									<label for="sp_columns_<?php 
                echo $key;
                ?>
">
										<input type="checkbox" name="sp_columns[]" value="<?php 
                echo $key;
                ?>
" id="sp_columns_<?php 
                echo $key;
                ?>
" <?php 
                checked(!is_array($columns) || in_array($key, $columns));
                ?>
>
										<?php 
                echo $label;
                ?>
									</label>
								<?php 
            } else {
                ?>
									<?php 
                echo $label;
                ?>
								<?php 
            }
            ?>
							</th>
						<?php 
        }
        ?>
						<?php 
        if ($team_id) {
            ?>
							<th>
								<?php 
            _e('Status', 'prosports');
            ?>
							</th>
						<?php 
        } else {
            ?>
							<th>
								<?php 
            _e('Outcome', 'prosports');
            ?>
							</th>
						<?php 
        }
        ?>
					</tr>
				</thead>
				<tfoot>
					<tr class="sp-row sp-total">
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td><strong><?php 
        _e('Total', 'prosports');
        ?>
</strong></td>
						<td>&nbsp;</td>
						<?php 
        foreach ($labels as $column => $label) {
            $player_id = 0;
            $player_performance = sp_array_value($data, 0, array());
            $value = sp_array_value($player_performance, $column, '');
            ?>
							<td><input type="text" name="sp_players[<?php 
            echo $team_id;
            ?>
][<?php 
            echo $player_id;
            ?>
][<?php 
            echo $column;
            ?>
]" value="<?php 
            echo $value;
            ?>
" placeholder="0" /></td>
						<?php 
        }
        ?>
						<td>&nbsp;</td>
					</tr>
				</tfoot>
				<tbody>
					<?php 
        foreach ($data as $player_id => $player_performance) {
            if (!$player_id) {
                continue;
            }
            $number = get_post_meta($player_id, 'sp_number', true);
            $value = sp_array_value($player_performance, 'number', '');
            ?>
						<tr class="sp-row sp-post" data-player="<?php 
            echo $player_id;
            ?>
">
							<td class="icon"><span class="dashicons dashicons-menu post-state-format"></span></td>
							<td>
								<input class="small-text sp-player-number-input" type="text" name="sp_players[<?php 
            echo $team_id;
            ?>
][<?php 
            echo $player_id;
            ?>
][number]" value="<?php 
            echo $value;
            ?>
" />
							</td>
							<td><?php 
            echo get_the_title($player_id);
            ?>
</td>
							<td>
								<?php 
            $selected = sp_array_value($player_performance, 'position', null);
            if ($selected == null) {
                $selected = sp_get_the_term_id($player_id, 'sp_position', 0);
            }
            $args = array('taxonomy' => 'sp_position', 'name' => 'sp_players[' . $team_id . '][' . $player_id . '][position]', 'values' => 'term_id', 'orderby' => 'slug', 'selected' => $selected);
            sp_dropdown_taxonomies($args);
            ?>
							</td>
							<?php 
            foreach ($labels as $column => $label) {
                $value = sp_array_value($player_performance, $column, '');
                ?>
								<td>
									<input class="sp-player-<?php 
                echo $column;
                ?>
-input" type="text" name="sp_players[<?php 
                echo $team_id;
                ?>
][<?php 
                echo $player_id;
                ?>
][<?php 
                echo $column;
                ?>
]" value="<?php 
                echo $value;
                ?>
" placeholder="0" />
								</td>
							<?php 
            }
            ?>
							<?php 
            if ($team_id) {
                ?>
								<td class="sp-status-selector">
									<?php 
                echo self::status_select($team_id, $player_id, sp_array_value($player_performance, 'status', null));
                ?>
									<?php 
                echo self::sub_select($team_id, $player_id, sp_array_value($player_performance, 'sub', null), $data);
                ?>
								</td>
							<?php 
            } else {
                ?>
								<td>
									<?php 
                $values = sp_array_value($player_performance, 'outcome', '');
                if (!is_array($values)) {
                    $values = array($values);
                }
                $args = array('post_type' => 'sp_outcome', 'name' => 'sp_players[' . $team_id . '][' . $player_id . '][outcome][]', 'option_none_value' => '', 'sort_order' => 'ASC', 'sort_column' => 'menu_order', 'selected' => $values, 'class' => 'sp-outcome', 'property' => 'multiple', 'chosen' => true, 'placeholder' => __('None', 'prosports'));
                sp_dropdown_pages($args);
                ?>
								</td>
							<?php 
            }
            ?>
						</tr>
						<?php 
        }
        ?>
				</tbody>
			</table>
		</div>
		<?php 
    }
Exemplo n.º 18
0
    /**
     * AJAX player_gallery shortcode
     */
    public function player_gallery_shortcode()
    {
        ?>
		<div class="wrap sp-thickbox-content" id="sp-thickbox-player_gallery">
			<p>
				<label>
					<?php 
        printf(__('Select %s:', 'sportspress'), __('Player List', 'sportspress'));
        ?>
					<?php 
        $args = array('post_type' => 'sp_list', 'name' => 'id', 'values' => 'ID');
        sp_dropdown_pages($args);
        ?>
				</label>
			</p>
			<p>
				<label>
					<?php 
        _e('Number of players to show:', 'sportspress');
        ?>
					<input type="text" size="3" name="number" id="number" value="5">
				</label>
			</p>
			<p>
				<label>
					<?php 
        _e('Sort by:', 'sportspress');
        ?>
					<?php 
        $args = array('prepend_options' => array('default' => __('Default', 'sportspress'), 'number' => __('Squad Number', 'sportspress'), 'name' => __('Name', 'sportspress'), 'eventsplayed' => __('Played', 'sportspress')), 'post_type' => array('sp_metric', 'sp_performance', 'sp_statistic'), 'name' => 'orderby', 'id' => 'orderby', 'values' => 'slug');
        sp_dropdown_pages($args);
        ?>
				</label>
			</p>
			<p>
				<label>
					<?php 
        _e('Sort Order:', 'sportspress');
        ?>
					<select id="order" name="order">
						<option value=""><?php 
        _e('Default', 'sportspress');
        ?>
</option>
						<option value="ASC"><?php 
        _e('Ascending', 'sportspress');
        ?>
</option>
						<option value="DESC"><?php 
        _e('Descending', 'sportspress');
        ?>
</option>
					</select>
				</label>
			</p>
			<p>
				<label>
					<input type="checkbox" name="show_all_players_link" id="show_all_players_link">
					<?php 
        _e('Display link to view all players', 'sportspress');
        ?>
				</label>
			</p>
			<p>
				<label>
					<input type="checkbox" name="show_names_on_hover" id="show_names_on_hover">
					<?php 
        _e('Display player names on hover', 'sportspress');
        ?>
				</label>
			</p>
			<p class="submit">
				<input type="button" class="button-primary" value="<?php 
        echo sprintf(__('Insert %s', 'sportspress'), __('Shortcode', 'sportspress'));
        ?>
" onclick="insertSportsPress('player_gallery');" />
				<a class="button-secondary" onclick="tb_remove();" title="<?php 
        _e('Cancel', 'sportspress');
        ?>
"><?php 
        _e('Cancel', 'sportspress');
        ?>
</a>
			</p>
		</div>
		<?php 
        self::scripts();
        die;
    }
    /**
     * Output the details metabox
     */
    public static function details($post)
    {
        $taxonomies = get_object_taxonomies('sp_directory');
        $team_id = get_post_meta($post->ID, 'sp_team', true);
        ?>
		<div>
			<?php 
        foreach ($taxonomies as $taxonomy) {
            sp_taxonomy_field($taxonomy, $post, true);
        }
        ?>
			<p><strong><?php 
        _e('Team', 'sportspress');
        ?>
</strong></p>
			<p class="sp-tab-select">
				<?php 
        $args = array('post_type' => 'sp_team', 'name' => 'sp_team', 'show_option_all' => __('All', 'sportspress'), 'selected' => $team_id, 'values' => 'ID');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_team', __('Add New', 'sportspress'));
        }
        ?>
			</p>
		</div>
		<?php 
    }
    function form($instance)
    {
        $instance = wp_parse_args((array) $instance, array('title' => '', 'id' => null, 'status' => 'default', 'date' => 'default', 'date_from' => date_i18n('Y-m-d'), 'date_to' => date_i18n('Y-m-d'), 'show_all_events_link' => false));
        $title = strip_tags($instance['title']);
        $id = intval($instance['id']);
        $status = $instance['status'];
        $date = $instance['date'];
        $date_from = $instance['date_from'];
        $date_to = $instance['date_to'];
        $show_all_events_link = $instance['show_all_events_link'];
        // Action to hook into
        do_action('prosports_before_widget_template_form', $this, $instance, 'event-calendar');
        ?>
		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'prosports');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" /></p>

		<p><label for="<?php 
        echo $this->get_field_id('id');
        ?>
"><?php 
        printf(__('Select %s:', 'prosports'), __('Calendar', 'prosports'));
        ?>
</label>
		<?php 
        $args = array('post_type' => 'sp_calendar', 'show_option_all' => __('All', 'prosports'), 'name' => $this->get_field_name('id'), 'id' => $this->get_field_id('id'), 'selected' => $id, 'values' => 'ID', 'class' => 'sp-event-calendar-select widefat');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_calendar', __('Add New', 'prosports'));
        }
        ?>
		</p>

		<p><label for="<?php 
        echo $this->get_field_id('status');
        ?>
"><?php 
        _e('Status:', 'prosports');
        ?>
</label>
			<?php 
        $args = array('show_option_default' => __('Default', 'prosports'), 'name' => $this->get_field_name('status'), 'id' => $this->get_field_id('status'), 'selected' => $status, 'class' => 'sp-event-status-select widefat');
        sp_dropdown_statuses($args);
        ?>
		</p>

		<div class="sp-date-selector sp-event-calendar-show-all-toggle<?php 
        if (!$id) {
            ?>
 hidden<?php 
        }
        ?>
">
			<p><label for="<?php 
        echo $this->get_field_id('date');
        ?>
"><?php 
        _e('Date:', 'prosports');
        ?>
</label>
				<?php 
        $args = array('show_option_default' => __('Default', 'prosports'), 'name' => $this->get_field_name('date'), 'id' => $this->get_field_id('date'), 'selected' => $date, 'class' => 'sp-event-date-select widefat');
        sp_dropdown_dates($args);
        ?>
			</p>
			<p class="sp-date-range<?php 
        if ('range' !== $date) {
            ?>
 hidden<?php 
        }
        ?>
">
				<input type="text" name="<?php 
        echo $this->get_field_name('date_from');
        ?>
" value="<?php 
        echo $date_from;
        ?>
" placeholder="yyyy-mm-dd" size="10">
				:
				<input type="text" name="<?php 
        echo $this->get_field_name('date_to');
        ?>
" value="<?php 
        echo $date_to;
        ?>
" placeholder="yyyy-mm-dd" size="10">
			</p>
		</div>

		<p class="sp-event-calendar-show-all-toggle<?php 
        if (!$id) {
            ?>
 hidden<?php 
        }
        ?>
"><input class="checkbox" type="checkbox" id="<?php 
        echo $this->get_field_id('show_all_events_link');
        ?>
" name="<?php 
        echo $this->get_field_name('show_all_events_link');
        ?>
" value="1" <?php 
        checked($show_all_events_link, 1);
        ?>
>
		<label for="<?php 
        echo $this->get_field_id('show_all_events_link');
        ?>
"><?php 
        _e('Display link to view all events', 'prosports');
        ?>
</label></p>

		<?php 
        // Action to hook into
        do_action('prosports_after_widget_template_form', $this, $instance, 'event-calendar');
    }
    /**
     * Output the metabox
     */
    public static function output($post)
    {
        $taxonomies = get_object_taxonomies('sp_list');
        $team_id = get_post_meta($post->ID, 'sp_team', true);
        $grouping = get_post_meta($post->ID, 'sp_grouping', true);
        $orderby = get_post_meta($post->ID, 'sp_orderby', true);
        $order = get_post_meta($post->ID, 'sp_order', true);
        $select = get_post_meta($post->ID, 'sp_select', true);
        if (!$select) {
            global $pagenow;
            $select = 'post-new.php' == $pagenow ? 'auto' : 'manual';
        }
        ?>
		<div>
			<?php 
        foreach ($taxonomies as $taxonomy) {
            sp_taxonomy_field($taxonomy, $post, true);
        }
        ?>
			<?php 
        if (apply_filters('sportspress_list_team_selector', true)) {
            ?>
			<p><strong><?php 
            _e('Team', 'sportspress');
            ?>
</strong></p>
			<p class="sp-tab-select">
				<?php 
            $args = array('post_type' => 'sp_team', 'name' => 'sp_team', 'show_option_all' => __('All', 'sportspress'), 'selected' => $team_id, 'values' => 'ID');
            if (!sp_dropdown_pages($args)) {
                sp_post_adder('sp_team', __('Add New', 'sportspress'));
            }
            ?>
			</p>
			<?php 
        }
        ?>
			<p><strong><?php 
        _e('Grouping', 'sportspress');
        ?>
</strong></p>
			<p>
			<select name="sp_grouping">
				<option value="0"><?php 
        _e('None', 'sportspress');
        ?>
</option>
				<option value="position" <?php 
        selected($grouping, 'position');
        ?>
><?php 
        _e('Position', 'sportspress');
        ?>
</option>
			</select>
			</p>
			<p><strong><?php 
        _e('Sort by', 'sportspress');
        ?>
</strong></p>
			<p>
			<?php 
        $args = array('prepend_options' => array('number' => __('Squad Number', 'sportspress'), 'name' => __('Name', 'sportspress')), 'post_type' => array('sp_performance', 'sp_metric', 'sp_statistic'), 'name' => 'sp_orderby', 'selected' => $orderby, 'values' => 'slug');
        sp_dropdown_pages($args);
        ?>
			</p>
			<p><strong><?php 
        _e('Sort Order', 'sportspress');
        ?>
</strong></p>
			<p>
				<select name="sp_order">
					<option value="ASC" <?php 
        selected('ASC', $order);
        ?>
><?php 
        _e('Ascending', 'sportspress');
        ?>
</option>
					<option value="DESC" <?php 
        selected('DESC', $order);
        ?>
><?php 
        _e('Descending', 'sportspress');
        ?>
</option>
				</select>
			</p>
			<p><strong><?php 
        _e('Players', 'sportspress');
        ?>
</strong></p>
			<p class="sp-select-setting">
				<select name="sp_select">
					<option value="auto" <?php 
        selected('auto', $select);
        ?>
><?php 
        _e('Auto', 'sportspress');
        ?>
</option>
					<option value="manual" <?php 
        selected('manual', $select);
        ?>
><?php 
        _e('Manual', 'sportspress');
        ?>
</option>
				</select>
			</p>
			<?php 
        sp_post_checklist($post->ID, 'sp_player', 'auto' == $select ? 'none' : 'block', array('sp_league', 'sp_season', 'sp_current_team'));
        sp_post_adder('sp_player', __('Add New', 'sportspress'));
        ?>
		</div>
		<?php 
    }
    function form($instance)
    {
        $defaults = apply_filters('sportspress_widget_defaults', array('title' => '', 'id' => '', 'caption' => '', 'number' => 5, 'columns' => null, 'show_team_logo' => false, 'show_full_table_link' => true));
        $instance = wp_parse_args((array) $instance, $defaults);
        $title = strip_tags($instance['title']);
        $id = intval($instance['id']);
        $caption = strip_tags($instance['caption']);
        $number = intval($instance['number']);
        $columns = $instance['columns'];
        $show_team_logo = $instance['show_team_logo'];
        $show_full_table_link = $instance['show_full_table_link'];
        // Action to hook into
        do_action('sportspress_before_widget_template_form', $this, $instance, 'league-table');
        ?>
		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'sportspress');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" /></p>

		<p><label for="<?php 
        echo $this->get_field_id('caption');
        ?>
"><?php 
        _e('Heading:', 'sportspress');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('caption');
        ?>
" name="<?php 
        echo $this->get_field_name('caption');
        ?>
" type="text" value="<?php 
        echo esc_attr($caption);
        ?>
" /></p>

		<p><label for="<?php 
        echo $this->get_field_id('id');
        ?>
"><?php 
        printf(__('Select %s:', 'sportspress'), __('League Table', 'sportspress'));
        ?>
</label>
		<?php 
        $args = array('post_type' => 'sp_table', 'name' => $this->get_field_name('id'), 'id' => $this->get_field_id('id'), 'show_option_none' => __('&mdash; Select &mdash;', 'sportspress'), 'selected' => $id, 'values' => 'ID', 'class' => 'widefat');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_table', __('Add New', 'sportspress'));
        }
        ?>
		</p>

		<p><label for="<?php 
        echo $this->get_field_id('number');
        ?>
"><?php 
        _e('Number of teams to show:', 'sportspress');
        ?>
</label>
		<input id="<?php 
        echo $this->get_field_id('number');
        ?>
" name="<?php 
        echo $this->get_field_name('number');
        ?>
" type="text" value="<?php 
        echo esc_attr($number);
        ?>
" size="3"></p>

		<p class="sp-prefs">
			<?php 
        _e('Columns:', 'sportspress');
        ?>
<br>
			<?php 
        $args = array('post_type' => 'sp_column', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC');
        $the_columns = get_posts($args);
        $field_name = $this->get_field_name('columns') . '[]';
        $field_id = $this->get_field_id('columns');
        ?>
			<?php 
        foreach ($the_columns as $column) {
            ?>
				<label class="button"><input name="<?php 
            echo $field_name;
            ?>
" type="checkbox" id="<?php 
            echo $field_id . '-' . $column->post_name;
            ?>
" value="<?php 
            echo $column->post_name;
            ?>
" <?php 
            if ($columns === null || in_array($column->post_name, $columns)) {
                ?>
checked="checked"<?php 
            }
            ?>
><?php 
            echo $column->post_title;
            ?>
</label>
			<?php 
        }
        ?>
		</p>

		<p><input class="checkbox" type="checkbox" id="<?php 
        echo $this->get_field_id('show_team_logo');
        ?>
" name="<?php 
        echo $this->get_field_name('show_team_logo');
        ?>
" value="1" <?php 
        checked($show_team_logo, 1);
        ?>
>
		<label for="<?php 
        echo $this->get_field_id('show_team_logo');
        ?>
"><?php 
        _e('Display logos', 'sportspress');
        ?>
</label><br>

		<input class="checkbox" type="checkbox" id="<?php 
        echo $this->get_field_id('show_full_table_link');
        ?>
" name="<?php 
        echo $this->get_field_name('show_full_table_link');
        ?>
" value="1" <?php 
        checked($show_full_table_link, 1);
        ?>
>
		<label for="<?php 
        echo $this->get_field_id('show_full_table_link');
        ?>
"><?php 
        _e('Display link to view full table', 'sportspress');
        ?>
</label></p>

		<?php 
        // Action to hook into
        do_action('sportspress_after_widget_template_form', $this, $instance, 'league-table');
    }
    /**
     * Output the details metabox
     */
    public static function details($post)
    {
        $league_id = sp_get_the_term_id($post->ID, 'sp_league', 0);
        $season_id = sp_get_the_term_id($post->ID, 'sp_season', 0);
        $team_id = get_post_meta($post->ID, 'sp_team', true);
        ?>
		<div>
			<p><strong><?php 
        _e('Competition', 'prosports');
        ?>
</strong></p>
			<p>
				<?php 
        $args = array('taxonomy' => 'sp_league', 'name' => 'sp_league', 'show_option_all' => __('All', 'prosports'), 'selected' => $league_id, 'values' => 'term_id');
        if (!sp_dropdown_taxonomies($args)) {
            sp_taxonomy_adder('sp_league', 'sp_team', __('Add New', 'prosports'));
        }
        ?>
			</p>
			<p><strong><?php 
        _e('Season', 'prosports');
        ?>
</strong></p>
			<p class="sp-tab-select">
				<?php 
        $args = array('taxonomy' => 'sp_season', 'name' => 'sp_season', 'show_option_all' => __('All', 'prosports'), 'selected' => $season_id, 'values' => 'term_id');
        if (!sp_dropdown_taxonomies($args)) {
            sp_taxonomy_adder('sp_season', 'sp_team', __('Add New', 'prosports'));
        }
        ?>
			</p>
			<p><strong><?php 
        _e('Team', 'prosports');
        ?>
</strong></p>
			<p class="sp-tab-select">
				<?php 
        $args = array('post_type' => 'sp_team', 'name' => 'sp_team', 'show_option_all' => __('All', 'prosports'), 'selected' => $team_id, 'values' => 'ID');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_team', __('Add New', 'prosports'));
        }
        ?>
			</p>
		</div>
		<?php 
    }
    function form($instance)
    {
        $instance = wp_parse_args((array) $instance, array('title' => '', 'id' => null, 'caption' => '', 'status' => 'default', 'date' => 'default', 'date_from' => date_i18n('Y-m-d'), 'date_to' => date_i18n('Y-m-d'), 'day' => '', 'number' => 5, 'order' => 'default', 'show_all_events_link' => true));
        $title = strip_tags($instance['title']);
        $id = intval($instance['id']);
        $caption = strip_tags($instance['caption']);
        $status = $instance['status'];
        $date = $instance['date'];
        $date_from = $instance['date_from'];
        $date_to = $instance['date_to'];
        $day = $instance['day'];
        $number = intval($instance['number']);
        $order = strip_tags($instance['order']);
        $show_all_events_link = $instance['show_all_events_link'];
        // Action to hook into
        do_action('sportspress_before_widget_template_form', $this, $instance, 'event-blocks');
        ?>
		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'sportspress');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" /></p>

		<p><label for="<?php 
        echo $this->get_field_id('caption');
        ?>
"><?php 
        _e('Heading:', 'sportspress');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('caption');
        ?>
" name="<?php 
        echo $this->get_field_name('caption');
        ?>
" type="text" value="<?php 
        echo esc_attr($caption);
        ?>
" /></p>

		<p><label for="<?php 
        echo $this->get_field_id('id');
        ?>
"><?php 
        printf(__('Select %s:', 'sportspress'), __('Calendar', 'sportspress'));
        ?>
</label>
		<?php 
        $args = array('post_type' => 'sp_calendar', 'show_option_all' => __('All', 'sportspress'), 'name' => $this->get_field_name('id'), 'id' => $this->get_field_id('id'), 'selected' => $id, 'values' => 'ID', 'class' => 'sp-event-calendar-select widefat');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_calendar', __('Add New', 'sportspress'));
        }
        ?>
		</p>

		<p><label for="<?php 
        echo $this->get_field_id('status');
        ?>
"><?php 
        _e('Status:', 'sportspress');
        ?>
</label>
			<?php 
        $args = array('show_option_default' => __('Default', 'sportspress'), 'name' => $this->get_field_name('status'), 'id' => $this->get_field_id('status'), 'selected' => $status, 'class' => 'sp-event-status-select widefat');
        sp_dropdown_statuses($args);
        ?>
		</p>

		<div class="sp-date-selector">
			<p><label for="<?php 
        echo $this->get_field_id('date');
        ?>
"><?php 
        _e('Date:', 'sportspress');
        ?>
</label>
				<?php 
        $args = array('show_option_default' => __('Default', 'sportspress'), 'name' => $this->get_field_name('date'), 'id' => $this->get_field_id('date'), 'selected' => $date, 'class' => 'sp-event-date-select widefat');
        sp_dropdown_dates($args);
        ?>
			</p>
			<p class="sp-date-range<?php 
        if ('range' !== $date) {
            ?>
 hidden<?php 
        }
        ?>
">
				<input type="text" name="<?php 
        echo $this->get_field_name('date_from');
        ?>
" value="<?php 
        echo $date_from;
        ?>
" placeholder="yyyy-mm-dd" size="10">
				:
				<input type="text" name="<?php 
        echo $this->get_field_name('date_to');
        ?>
" value="<?php 
        echo $date_to;
        ?>
" placeholder="yyyy-mm-dd" size="10">
			</p>
		</div>

		<p><label for="<?php 
        echo $this->get_field_id('day');
        ?>
"><?php 
        _e('Match Day:', 'sportspress');
        ?>
</label>
		<input id="<?php 
        echo $this->get_field_id('day');
        ?>
" name="<?php 
        echo $this->get_field_name('day');
        ?>
" type="text" placeholder="<?php 
        _e('All', 'sportspress');
        ?>
" value="<?php 
        echo esc_attr($day);
        ?>
" size="10"></p>

		<p><label for="<?php 
        echo $this->get_field_id('number');
        ?>
"><?php 
        _e('Number of events to show:', 'sportspress');
        ?>
</label>
		<input id="<?php 
        echo $this->get_field_id('number');
        ?>
" name="<?php 
        echo $this->get_field_name('number');
        ?>
" type="text" value="<?php 
        echo esc_attr($number);
        ?>
" size="3"></p>

		<p><label for="<?php 
        echo $this->get_field_id('order');
        ?>
"><?php 
        _e('Sort Order:', 'sportspress');
        ?>
</label>
		<select name="<?php 
        echo $this->get_field_name('order');
        ?>
" id="<?php 
        echo $this->get_field_id('order');
        ?>
" class="sp-select-order widefat">
			<option value="default" <?php 
        selected('default', $order);
        ?>
><?php 
        _e('Default', 'sportspress');
        ?>
</option>
			<option value="ASC" <?php 
        selected('ASC', $order);
        ?>
><?php 
        _e('Ascending', 'sportspress');
        ?>
</option>
			<option value="DESC" <?php 
        selected('DESC', $order);
        ?>
><?php 
        _e('Descending', 'sportspress');
        ?>
</option>
		</select></p>

		<p class="sp-event-calendar-show-all-toggle<?php 
        if (!$id) {
            ?>
 hidden<?php 
        }
        ?>
"><input class="checkbox" type="checkbox" id="<?php 
        echo $this->get_field_id('show_all_events_link');
        ?>
" name="<?php 
        echo $this->get_field_name('show_all_events_link');
        ?>
" value="1" <?php 
        checked($show_all_events_link, 1);
        ?>
>
		<label for="<?php 
        echo $this->get_field_id('show_all_events_link');
        ?>
"><?php 
        _e('Display link to view all events', 'sportspress');
        ?>
</label></p>

		<?php 
        // Action to hook into
        do_action('sportspress_after_widget_template_form', $this, $instance, 'event-blocks');
    }
    /**
     * Output the metabox
     */
    public static function output($post)
    {
        wp_nonce_field('prosports_save_data', 'prosports_meta_nonce');
        $continents = SP()->countries->continents;
        $nationality = get_post_meta($post->ID, 'sp_nationality', true);
        $leagues = get_the_terms($post->ID, 'sp_league');
        $league_ids = array();
        if ($leagues) {
            foreach ($leagues as $league) {
                $league_ids[] = $league->term_id;
            }
        }
        $seasons = get_the_terms($post->ID, 'sp_season');
        $season_ids = array();
        if ($seasons) {
            foreach ($seasons as $season) {
                $season_ids[] = $season->term_id;
            }
        }
        $roles = get_the_terms($post->ID, 'sp_role');
        if ($roles) {
            $term = array_shift($roles);
            $role = $term->term_id;
        } else {
            $role = null;
        }
        $teams = get_posts(array('post_type' => 'sp_team', 'posts_per_page' => -1));
        $past_teams = array_filter(get_post_meta($post->ID, 'sp_past_team', false));
        $current_teams = array_filter(get_post_meta($post->ID, 'sp_current_team', false));
        ?>
		<p><strong><?php 
        _e('Job', 'prosports');
        ?>
</strong></p>
		<p><?php 
        $args = array('taxonomy' => 'sp_role', 'name' => 'sp_role', 'selected' => $role, 'values' => 'term_id', 'show_option_blank' => true, 'placeholder' => sprintf(__('Select %s', 'prosports'), __('Job', 'prosports')), 'class' => 'widefat', 'chosen' => true);
        if (!sp_dropdown_taxonomies($args)) {
            sp_taxonomy_adder('sp_role', 'sp_player', __('Add New', 'prosports'));
        }
        ?>
</p>

		<p><strong><?php 
        _e('Nationality', 'prosports');
        ?>
</strong></p>
		<p><select id="sp_nationality" name="sp_nationality" data-placeholder="<?php 
        printf(__('Select %s', 'prosports'), __('Nationality', 'prosports'));
        ?>
" class="widefat chosen-select<?php 
        if (is_rtl()) {
            ?>
 chosen-rtl<?php 
        }
        ?>
">
			<option value=""></option>
			<?php 
        foreach ($continents as $continent => $countries) {
            ?>
				<optgroup label="<?php 
            echo $continent;
            ?>
">
					<?php 
            foreach ($countries as $code => $country) {
                ?>
						<option value="<?php 
                echo $code;
                ?>
" <?php 
                selected($nationality, $code);
                ?>
><?php 
                echo $country;
                ?>
</option>
					<?php 
            }
            ?>
				</optgroup>
			<?php 
        }
        ?>
		</select></p>

		<p><strong><?php 
        _e('Current Teams', 'prosports');
        ?>
</strong></p>
		<p><?php 
        $args = array('post_type' => 'sp_team', 'name' => 'sp_current_team[]', 'selected' => $current_teams, 'values' => 'ID', 'placeholder' => sprintf(__('Select %s', 'prosports'), __('Teams', 'prosports')), 'class' => 'sp-current-teams widefat', 'property' => 'multiple', 'chosen' => true);
        sp_dropdown_pages($args);
        ?>
</p>

		<p><strong><?php 
        _e('Past Teams', 'prosports');
        ?>
</strong></p>
		<p><?php 
        $args = array('post_type' => 'sp_team', 'name' => 'sp_past_team[]', 'selected' => $past_teams, 'values' => 'ID', 'placeholder' => sprintf(__('Select %s', 'prosports'), __('Teams', 'prosports')), 'class' => 'sp-past-teams widefat', 'property' => 'multiple', 'chosen' => true);
        sp_dropdown_pages($args);
        ?>
</p>

		<p><strong><?php 
        _e('Competitions', 'prosports');
        ?>
</strong></p>
		<p><?php 
        $args = array('taxonomy' => 'sp_league', 'name' => 'tax_input[sp_league][]', 'selected' => $league_ids, 'values' => 'term_id', 'placeholder' => sprintf(__('Select %s', 'prosports'), __('Competitions', 'prosports')), 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true);
        sp_dropdown_taxonomies($args);
        ?>
</p>

		<p><strong><?php 
        _e('Seasons', 'prosports');
        ?>
</strong></p>
		<p><?php 
        $args = array('taxonomy' => 'sp_season', 'name' => 'tax_input[sp_season][]', 'selected' => $season_ids, 'values' => 'term_id', 'placeholder' => sprintf(__('Select %s', 'prosports'), __('Seasons', 'prosports')), 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true);
        sp_dropdown_taxonomies($args);
        ?>
</p>
		<?php 
    }
Exemplo n.º 26
0
function prosports_dropdown_pages($args = array())
{
    return sp_dropdown_pages($args);
}
    function form($instance)
    {
        $instance = wp_parse_args((array) $instance, array('title' => '', 'id' => '', 'caption' => '', 'number' => 5, 'columns' => 2, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true));
        $title = strip_tags($instance['title']);
        $id = intval($instance['id']);
        $caption = strip_tags($instance['caption']);
        $number = intval($instance['number']);
        $columns = intval($instance['columns']);
        $orderby = strip_tags($instance['orderby']);
        $order = strip_tags($instance['order']);
        $show_all_players_link = $instance['show_all_players_link'];
        // Action to hook into
        do_action('sportspress_before_widget_template_form', $this, $instance, 'player-gallery');
        ?>
		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'sportspress');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" /></p>

		<p><label for="<?php 
        echo $this->get_field_id('caption');
        ?>
"><?php 
        _e('Heading:', 'sportspress');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('caption');
        ?>
" name="<?php 
        echo $this->get_field_name('caption');
        ?>
" type="text" value="<?php 
        echo esc_attr($caption);
        ?>
" /></p>

		<p><label for="<?php 
        echo $this->get_field_id('id');
        ?>
"><?php 
        printf(__('Select %s:', 'sportspress'), __('Player List', 'sportspress'));
        ?>
</label>
		<?php 
        $args = array('post_type' => 'sp_list', 'name' => $this->get_field_name('id'), 'id' => $this->get_field_id('id'), 'selected' => $id, 'values' => 'ID', 'class' => 'widefat');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_list', __('Add New', 'sportspress'));
        }
        ?>
		</p>

		<p><label for="<?php 
        echo $this->get_field_id('number');
        ?>
"><?php 
        _e('Number of players to show:', 'sportspress');
        ?>
</label>
		<input id="<?php 
        echo $this->get_field_id('number');
        ?>
" name="<?php 
        echo $this->get_field_name('number');
        ?>
" type="text" value="<?php 
        echo esc_attr($number);
        ?>
" size="3"></p>

		<p><label for="<?php 
        echo $this->get_field_id('columns');
        ?>
"><?php 
        _e('Columns:', 'sportspress');
        ?>
</label>
		<input id="<?php 
        echo $this->get_field_id('columns');
        ?>
" name="<?php 
        echo $this->get_field_name('columns');
        ?>
" type="text" value="<?php 
        echo esc_attr($columns);
        ?>
" size="3"></p>

		<p><label for="<?php 
        echo $this->get_field_id('orderby');
        ?>
"><?php 
        _e('Sort by:', 'sportspress');
        ?>
</label>
		<?php 
        $args = array('prepend_options' => array('default' => __('Default', 'sportspress'), 'number' => __('Squad Number', 'sportspress'), 'name' => __('Name', 'sportspress'), 'eventsplayed' => __('Played', 'sportspress')), 'append_options' => array('rand' => __('Random', 'sportspress')), 'post_type' => 'sp_performance', 'name' => $this->get_field_name('orderby'), 'id' => $this->get_field_id('orderby'), 'selected' => $orderby, 'values' => 'slug', 'class' => 'sp-select-orderby widefat');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_list', __('Add New', 'sportspress'));
        }
        ?>
		</p>

		<p><label for="<?php 
        echo $this->get_field_id('order');
        ?>
"><?php 
        _e('Sort Order:', 'sportspress');
        ?>
</label>
		<select name="<?php 
        echo $this->get_field_name('order');
        ?>
" id="<?php 
        echo $this->get_field_id('order');
        ?>
" class="sp-select-order widefat" <?php 
        disabled($orderby, 'default');
        ?>
>
			<option value="ASC" <?php 
        selected('ASC', $order);
        ?>
><?php 
        _e('Ascending', 'sportspress');
        ?>
</option>
			<option value="DESC" <?php 
        selected('DESC', $order);
        ?>
><?php 
        _e('Descending', 'sportspress');
        ?>
</option>
		</select></p>

		<p><input class="checkbox" type="checkbox" id="<?php 
        echo $this->get_field_id('show_all_players_link');
        ?>
" name="<?php 
        echo $this->get_field_name('show_all_players_link');
        ?>
" value="1" <?php 
        checked($show_all_players_link, 1);
        ?>
>
		<label for="<?php 
        echo $this->get_field_id('show_all_players_link');
        ?>
"><?php 
        _e('Display link to view all players', 'sportspress');
        ?>
</label></p>

		<?php 
        // Action to hook into
        do_action('sportspress_after_widget_template_form', $this, $instance, 'player-gallery');
    }
    function form($instance)
    {
        $instance = wp_parse_args((array) $instance, array('title' => '', 'team' => '', 'id' => '', 'caption' => '', 'show_venue' => false, 'show_league' => false));
        $title = strip_tags($instance['title']);
        $caption = strip_tags($instance['caption']);
        $team = intval($instance['team']);
        $id = intval($instance['id']);
        $show_venue = intval($instance['show_venue']);
        $show_league = intval($instance['show_league']);
        // Action to hook into
        do_action('sportspress_before_widget_template_form', $this, $instance, 'countdown');
        ?>
		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'sportspress');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" /></p>

		<p><label for="<?php 
        echo $this->get_field_id('caption');
        ?>
"><?php 
        _e('Heading:', 'sportspress');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('caption');
        ?>
" name="<?php 
        echo $this->get_field_name('caption');
        ?>
" type="text" value="<?php 
        echo esc_attr($caption);
        ?>
" /></p>

		<p class="sp-dropdown-filter"><label for="<?php 
        echo $this->get_field_id('team');
        ?>
"><?php 
        printf(__('Select %s:', 'sportspress'), __('Team', 'sportspress'));
        ?>
</label>
		<?php 
        $args = array('post_type' => 'sp_team', 'name' => $this->get_field_name('team'), 'id' => $this->get_field_id('team'), 'selected' => $team, 'show_option_all' => __('All', 'sportspress'), 'values' => 'ID', 'class' => 'widefat');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_team', __('Add New', 'sportspress'));
        }
        ?>
		</p>

		<p class="sp-dropdown-target"><label for="<?php 
        echo $this->get_field_id('id');
        ?>
"><?php 
        printf(__('Select %s:', 'sportspress'), __('Event', 'sportspress'));
        ?>
</label>
		<?php 
        $args = array('post_type' => 'sp_event', 'name' => $this->get_field_name('id'), 'id' => $this->get_field_id('id'), 'selected' => $id, 'show_option_all' => __('(Auto)', 'sportspress'), 'values' => 'ID', 'class' => 'widefat', 'show_dates' => true, 'post_status' => 'future', 'filter' => 'sp_team');
        if (!sp_dropdown_pages($args)) {
            sp_post_adder('sp_event', __('Add New', 'sportspress'));
        }
        ?>
		</p>

		<p><input class="checkbox" type="checkbox" id="<?php 
        echo $this->get_field_id('show_venue');
        ?>
" name="<?php 
        echo $this->get_field_name('show_venue');
        ?>
" value="1" <?php 
        checked($show_venue, 1);
        ?>
>
		<label for="<?php 
        echo $this->get_field_id('show_venue');
        ?>
"><?php 
        _e('Display venue', 'sportspress');
        ?>
</label></p>

		<p><input class="checkbox" type="checkbox" id="<?php 
        echo $this->get_field_id('show_league');
        ?>
" name="<?php 
        echo $this->get_field_name('show_league');
        ?>
" value="1" <?php 
        checked($show_league, 1);
        ?>
>
		<label for="<?php 
        echo $this->get_field_id('show_league');
        ?>
"><?php 
        _e('Display competition', 'sportspress');
        ?>
</label></p>
		
		<?php 
        // Action to hook into
        do_action('sportspress_after_widget_template_form', $this, $instance, 'countdown');
    }
    /**
     * Admin edit table
     */
    public static function table($columns = array(), $usecolumns = array(), $data = array())
    {
        ?>
		<div class="sp-data-table-container">
			<table class="widefat sp-data-table">
				<thead>
					<tr>
						<th class="column-team"><?php 
        _e('Team', 'prosports');
        ?>
</th>
						<?php 
        foreach ($columns as $key => $label) {
            ?>
							<th class="column-<?php 
            echo $key;
            ?>
">
								<label for="sp_result_columns_<?php 
            echo $key;
            ?>
">
									<input type="checkbox" name="sp_result_columns[]" value="<?php 
            echo $key;
            ?>
" id="sp_result_columns_<?php 
            echo $key;
            ?>
" <?php 
            checked(!is_array($usecolumns) || in_array($key, $usecolumns));
            ?>
>
									<?php 
            echo $label;
            ?>
								</label>
							</th>
						<?php 
        }
        ?>
						<th class="column-outcome">
							<label for="sp_result_columns_outcome">
								<input type="checkbox" name="sp_result_columns[]" value="outcome" id="sp_result_columns_outcome" <?php 
        checked(!is_array($usecolumns) || in_array('outcome', $usecolumns));
        ?>
>
								<?php 
        _e('Outcome', 'prosports');
        ?>
							</label>
						</th>
					</tr>
				</thead>
				<tbody>
					<?php 
        $i = 0;
        foreach ($data as $team_id => $team_results) {
            if (!$team_id) {
                continue;
            }
            ?>
						<tr class="sp-row sp-post<?php 
            if ($i % 2 == 0) {
                echo ' alternate';
            }
            ?>
">
							<td>
								<?php 
            echo get_the_title($team_id);
            ?>
							</td>
							<?php 
            foreach ($columns as $column => $label) {
                $value = sp_array_value($team_results, $column, '');
                ?>
								<td><input type="text" name="sp_results[<?php 
                echo $team_id;
                ?>
][<?php 
                echo $column;
                ?>
]" value="<?php 
                echo $value;
                ?>
" /></td>
							<?php 
            }
            ?>
							<td>
								<?php 
            $values = sp_array_value($team_results, 'outcome', '');
            if (!is_array($values)) {
                $values = array($values);
            }
            $args = array('post_type' => 'sp_outcome', 'name' => 'sp_results[' . $team_id . '][outcome][]', 'option_none_value' => '', 'sort_order' => 'ASC', 'sort_column' => 'menu_order', 'selected' => $values, 'class' => 'sp-outcome', 'property' => 'multiple', 'chosen' => true, 'placeholder' => __('(Auto)', 'prosports'));
            sp_dropdown_pages($args);
            ?>
							</td>
						</tr>
						<?php 
            $i++;
        }
        ?>
				</tbody>
			</table>
		</div>
		<?php 
    }