/**
         * Ajax checklist.
         */
        public function checklist($post_id = null, $post_type = 'post', $display = 'block', $team = null, $index = null, $slug = null)
        {
            if (!isset($slug)) {
                $slug = $post_type;
            }
            $selected = (array) get_post_meta($post_id, $slug, false);
            if (sizeof($selected)) {
                $selected = sp_array_between($selected, 0, $index);
            } else {
                $selected = sp_array_between((array) get_post_meta($post_id, $post_type, false), 0, $index);
            }
            if ('yes' == get_option('sportspress_event_filter_teams_by_league', 'no')) {
                $leagues = get_the_terms($post_id, 'sp_league');
            } else {
                $leagues = false;
            }
            if ('yes' == get_option('sportspress_event_filter_teams_by_season', 'no')) {
                $seasons = get_the_terms($post_id, 'sp_season');
            } else {
                $seasons = false;
            }
            $args = array('orderby' => 'menu_order');
            if ('sp_player' == $post_type) {
                $args['meta_key'] = 'sp_number';
                $args['orderby'] = 'meta_value_num';
                $args['order'] = 'ASC';
            }
            $args['meta_query'] = array(array('key' => 'sp_current_team', 'value' => $team));
            if ($leagues || $seasons) {
                $args['tax_query'] = array('relation' => 'AND');
                if ($leagues) {
                    $args['tax_query'][] = array('taxonomy' => 'sp_league', 'field' => 'id', 'terms' => wp_list_pluck($leagues, 'term_id'));
                }
                if ($seasons) {
                    $args['tax_query'][] = array('taxonomy' => 'sp_season', 'field' => 'id', 'terms' => wp_list_pluck($seasons, 'term_id'));
                }
            }
            $posts = sp_get_posts($post_type, $args);
            $post_ids = wp_list_pluck($posts, 'ID');
            $diff = array_diff($post_ids, $selected);
            $selected = array_flip($selected);
            ?>
		<div id="<?php 
            echo $slug;
            ?>
-all" class="posttypediv wp-tab-panel sp-tab-panel sp-ajax-checklist sp-select-all-range" style="display: <?php 
            echo $display;
            ?>
;">
			<input type="hidden" value="0" name="<?php 
            echo $slug;
            if (isset($index)) {
                echo '[' . $index . ']';
            }
            ?>
[]" />
			<ul class="categorychecklist form-no-clear">
				<?php 
            if (is_array($posts) && sizeof($posts)) {
                ?>
					<li class="sp-select-all-container">
						<label class="selectit">
							<input type="checkbox" class="sp-select-all" <?php 
                checked(empty($diff));
                ?>
>
							<strong><?php 
                _e('Select All', 'sportspress');
                ?>
</strong>
						</label>
					</li>
					<?php 
                foreach ($posts as $post) {
                    ?>
						<li>
							<label class="selectit">
								<input type="checkbox" value="<?php 
                    echo $post->ID;
                    ?>
" name="<?php 
                    echo $slug;
                    if (isset($index)) {
                        echo '[' . $index . ']';
                    }
                    ?>
[]" <?php 
                    checked(array_key_exists($post->ID, $selected));
                    ?>
>
								<?php 
                    echo sp_get_player_name_with_number($post->ID);
                    ?>
							</label>
						</li>
						<?php 
                    unset($selected[$post->ID]);
                    ?>
					<?php 
                }
                ?>
					<?php 
                if (is_array($selected) && sizeof($selected)) {
                    foreach ($selected as $post_id => $post) {
                        ?>
						<?php 
                        if (!$post_id) {
                            continue;
                        }
                        ?>
						<li>
							<label class="selectit">
								<input type="checkbox" value="<?php 
                        echo $post_id;
                        ?>
" name="<?php 
                        echo $slug;
                        if (isset($index)) {
                            echo '[' . $index . ']';
                        }
                        ?>
[]" <?php 
                        checked(true);
                        ?>
>
								<?php 
                        echo sp_get_player_name_with_number($post_id);
                        ?>
							</label>
						</li>
					<?php 
                    }
                }
                ?>
					<li class="sp-ajax-show-all-container"><a class="sp-ajax-show-all" href="#show-all-<?php 
                echo $slug;
                ?>
s"><?php 
                _e('Show all', 'sportspress');
                ?>
</a></li>
				<?php 
            } else {
                ?>
					<li class="sp-ajax-show-all-container"><?php 
                _e('No results found.', 'sportspress');
                ?>
					<a class="sp-ajax-show-all" href="#show-all-<?php 
                echo $slug;
                ?>
s"><?php 
                _e('Show all', 'sportspress');
                ?>
</a></li>
				<?php 
            }
            ?>
			</ul>
		</div>
		<?php 
        }
    function sp_post_checklist($post_id = null, $meta = 'post', $display = 'block', $filters = null, $index = null, $slug = null)
    {
        if (!isset($post_id)) {
            global $post_id;
        }
        if (!isset($slug)) {
            $slug = $meta;
        }
        ?>
		<div id="<?php 
        echo $slug;
        ?>
-all" class="posttypediv tabs-panel wp-tab-panel sp-tab-panel sp-tab-filter-panel sp-select-all-range" style="display: <?php 
        echo $display;
        ?>
;">
			<input type="hidden" value="0" name="<?php 
        echo $slug;
        if (isset($index)) {
            echo '[' . $index . ']';
        }
        ?>
[]" />
			<ul class="categorychecklist form-no-clear">
				<li class="sp-select-all-container"><label class="selectit"><input type="checkbox" class="sp-select-all"> <strong><?php 
        _e('Select All', 'sportspress');
        ?>
</strong></label></li>
				<?php 
        $selected = (array) get_post_meta($post_id, $slug, false);
        if (!sizeof($selected)) {
            $selected = (array) get_post_meta($post_id, $meta, false);
        }
        $selected = sp_array_between($selected, 0, $index);
        if (empty($posts)) {
            $query = array('post_type' => $meta, 'numberposts' => -1, 'post_per_page' => -1, 'orderby' => 'menu_order');
            if ($meta == 'sp_player') {
                $query['meta_key'] = 'sp_number';
                $query['orderby'] = 'meta_value_num';
                $query['order'] = 'ASC';
            }
            $posts = get_posts($query);
        }
        foreach ($posts as $post) {
            $parents = get_post_ancestors($post);
            if ($filters) {
                if (is_array($filters)) {
                    $filter_values = array();
                    foreach ($filters as $filter) {
                        if (get_taxonomy($filter)) {
                            $terms = (array) get_the_terms($post->ID, $filter);
                            foreach ($terms as $term) {
                                if (is_object($term) && property_exists($term, 'term_id')) {
                                    $filter_values[] = $term->term_id;
                                }
                            }
                        } else {
                            $filter_values = array_merge($filter_values, (array) get_post_meta($post->ID, $filter, false));
                        }
                    }
                } else {
                    $filter = $filters;
                    if (get_taxonomy($filter)) {
                        $terms = (array) get_the_terms($post->ID, $filter);
                        foreach ($terms as $term) {
                            if (is_object($term) && property_exists($term, 'term_id')) {
                                $filter_values[] = $term->term_id;
                            }
                        }
                    } else {
                        $filter_values = (array) get_post_meta($post->ID, $filter, false);
                    }
                }
            }
            ?>
					<li class="sp-post sp-filter-0<?php 
            if ($filters) {
                foreach ($filter_values as $filter_value) {
                    echo ' sp-filter-' . $filter_value;
                }
            }
            ?>
">
						<?php 
            echo str_repeat('<ul><li>', sizeof($parents));
            ?>
						<label class="selectit">
							<input type="checkbox" value="<?php 
            echo $post->ID;
            ?>
" name="<?php 
            echo $slug;
            if (isset($index)) {
                echo '[' . $index . ']';
            }
            ?>
[]"<?php 
            if (in_array($post->ID, $selected)) {
                echo ' checked="checked"';
            }
            ?>
>
							<?php 
            echo sp_get_player_name_with_number($post->ID);
            ?>
						</label>
						<?php 
            echo str_repeat('</li></ul>', sizeof($parents));
            ?>
					</li>
					<?php 
        }
        ?>
				<li class="sp-not-found-container">
					<?php 
        _e('No results found.', 'sportspress');
        ?>
					<?php 
        if (sizeof($posts)) {
            ?>
<a class="sp-show-all" href="#show-all-<?php 
            echo $slug;
            ?>
s"><?php 
            _e('Show all', 'sportspress');
            ?>
</a><?php 
        }
        ?>
				</li>
				<?php 
        if (sizeof($posts)) {
            ?>
					<li class="sp-show-all-container"><a class="sp-show-all" href="#show-all-<?php 
            echo $slug;
            ?>
s"><?php 
            _e('Show all', 'sportspress');
            ?>
</a></li>
				<?php 
        }
        ?>
			</ul>
		</div>
		<?php 
    }