/**
  * Install WPCM
  */
 public static function install()
 {
     if (!defined('WPCM_INSTALLING')) {
         define('WPCM_INSTALLING', true);
     }
     // Ensure needed classes are loaded
     include_once 'admin/class-wpcm-admin-notices.php';
     self::create_options();
     self::create_roles();
     // Register post types
     WPCM_Post_Types::register_post_types();
     WPCM_Post_Types::register_taxonomies();
     // Queue upgrades
     $current_version = get_option('wpclubmanager_version', null);
     if ($current_version) {
         update_option('wpcm_version_upgraded_from', $current_version);
     }
     // Update version
     delete_option('wpclubmanager_version');
     add_option('wpclubmanager_version', WPCM()->version);
     // Flush rules after install
     flush_rewrite_rules();
     // Redirect to welcome screen
     if (!is_network_admin() && !isset($_GET['activate-multi'])) {
         set_transient('_wpcm_activation_redirect', 1, 30);
     }
     // Trigger action
     do_action('wpclubmanager_installed');
 }
 /**
  * Loads the scripts for the backend.
  *
  * @since  1.1
  * @access public
  * @return void
  */
 public function admin_scripts()
 {
     global $wp_query, $post;
     $screen = get_current_screen();
     $wpcm_screen_id = strtolower(__('WPClubManager', 'wp-club-manager'));
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     // Register scripts
     wp_register_script('wpclubmanager_admin', WPCM()->plugin_url() . '/assets/js/admin/wpclubmanager_admin' . $suffix . '.js', array('jquery', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip', 'jquery-ui-sortable'), WPCM_VERSION);
     wp_register_script('jquery-tiptip', WPCM()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array('jquery'), WPCM_VERSION, true);
     wp_register_script('wpclubmanager_admin_meta_boxes', WPCM()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array('jquery'), WPCM_VERSION);
     wp_register_script('ajax-chosen', WPCM()->plugin_url() . '/assets/js/jquery-chosen/ajax-chosen.jquery' . $suffix . '.js', array('jquery', 'chosen'), WPCM_VERSION);
     wp_register_script('chosen', WPCM()->plugin_url() . '/assets/js/jquery-chosen/chosen.jquery' . $suffix . '.js', array('jquery'), WPCM_VERSION);
     // WPlubManager admin pages
     if (in_array($screen->id, wpcm_get_screen_ids())) {
         wp_enqueue_script('jquery');
         wp_enqueue_script('ajax-chosen');
         wp_enqueue_script('chosen');
         wp_enqueue_script('wpclubmanager_admin');
     }
     if (in_array($screen->id, array('wpcm_player', 'wpcm_club', 'wpcm_staff', 'wpcm_sponsor', 'wpcm_match', 'edit-wpcm_player', 'edit-wpcm_club', 'edit-wpcm_staff', 'edit-wpcm_sponsor', 'edit-wpcm_match'))) {
         wp_enqueue_script('wpclubmanager_admin_meta_boxes');
         wp_enqueue_script('ajax-chosen');
         wp_enqueue_script('chosen');
     }
     // System status
     if ('club-manager_page_wpcm-status' === $screen->id) {
         wp_enqueue_script('zeroclipboard', WPCM()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array('jquery'), WPCM_VERSION);
     }
 }
 /**
  * Add the shortcode buttons to TinyMCE.
  *
  * @param array $plugin_array
  * @return array
  */
 public function add_shortcode_tinymce_plugin($plugin_array)
 {
     $plugin_array['matches'] = WPCM()->plugin_url() . '/assets/js/admin/editor-matches.js';
     $plugin_array['standings'] = WPCM()->plugin_url() . '/assets/js/admin/editor-standings.js';
     $plugin_array['players'] = WPCM()->plugin_url() . '/assets/js/admin/editor-players.js';
     $plugin_array['staff'] = WPCM()->plugin_url() . '/assets/js/admin/editor-staff.js';
     $plugin_array['map'] = WPCM()->plugin_url() . '/assets/js/admin/editor-map.js';
     return $plugin_array;
 }
 /**
  * Add menu items
  */
 public function admin_menu()
 {
     global $menu, $wpclubmanager;
     if (current_user_can('manage_wpclubmanager')) {
         $menu[] = array('', 'read', 'separator-wpclubmanager', '', 'wp-menu-separator wpclubmanager');
     }
     $main_page = add_menu_page(__('Club Manager', 'wp-club-manager'), __('Club Manager', 'wp-club-manager'), 'manage_wpclubmanager', 'wpcm-settings', array($this, 'settings_page'), WPCM()->plugin_url() . '/assets/images/logo.png', '55.4');
     remove_submenu_page('edit.php?post_type=wpcm_player', 'edit-tags.php?taxonomy=wpcm_season&post_type=wpcm_player');
     //remove_submenu_page('edit.php?post_type=wpcm_player', 'edit-tags.php?taxonomy=wpcm_team&post_type=wpcm_player');
     remove_submenu_page('edit.php?post_type=wpcm_staff', 'edit-tags.php?taxonomy=wpcm_season&post_type=wpcm_staff');
     remove_submenu_page('edit.php?post_type=wpcm_staff', 'edit-tags.php?taxonomy=wpcm_team&post_type=wpcm_staff');
 }
 /**
  * Save settings
  */
 public function save()
 {
     if (isset($_POST['wpcm_sport']) && !empty($_POST['wpcm_sport']) && get_option('wpcm_sport', null) != $_POST['wpcm_sport']) {
         $sport = WPCM()->sports->{$_POST}['wpcm_sport'];
         WPCM_Admin_Settings::configure_sport($sport);
         update_option('_wpcm_needs_welcome', 0);
     } elseif (isset($_POST['wpcm_primary_result'])) {
         update_option('wpcm_primary_result', $_POST['wpcm_primary_result']);
     }
     $settings = $this->get_settings();
     WPCM_Admin_Settings::save_fields($settings);
 }
 /**
  * Loads the scripts for the plugin.
  *
  * @since  0.1.0
  * @access public
  * @return void
  */
 public function load_scripts()
 {
     global $post, $wp;
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     $assets_path = str_replace(array('http:', 'https:'), '', WPCM()->plugin_url()) . '/assets/';
     $frontend_script_path = $assets_path . 'js/frontend/';
     wp_register_script('google-maps-api', '//maps.google.com/maps/api/js?sensor=false');
     // Global frontend scripts
     wp_enqueue_script('wpclubmanager', $frontend_script_path . 'wpclubmanager' . $suffix . '.js', array('jquery'), WPCM_VERSION, true);
     // CSS Styles
     $enqueue_styles = $this->get_styles();
     if ($enqueue_styles) {
         foreach ($enqueue_styles as $handle => $args) {
             wp_enqueue_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']);
         }
     }
 }
 /**
  * Load a template.
  *
  * Handles template usage so that we can use our own templates instead of the themes.
  *
  * Templates are in the 'templates' folder. wpclubmanager looks for theme
  * overrides in /theme/wpclubmanager/ by default
  *
  * For beginners, it also looks for a wpclubmanager.php template first. If the user adds
  * this to the theme (containing a wpclubmanager() inside) this will be used for all
  * wpclubmanager templates.
  *
  * @access public
  * @param mixed $template
  * @return string
  */
 public function template_loader($template)
 {
     $find = array('wpclubmanager.php');
     $file = '';
     if (is_single() && get_post_type() == 'wpcm_club') {
         $file = 'single-club.php';
         $find[] = $file;
         $find[] = WPCM_TEMPLATE_PATH . $file;
     }
     if (is_single() && get_post_type() == 'wpcm_player') {
         $file = 'single-player.php';
         $find[] = $file;
         $find[] = WPCM_TEMPLATE_PATH . $file;
     }
     if (is_single() && get_post_type() == 'wpcm_staff') {
         $file = 'single-staff.php';
         $find[] = $file;
         $find[] = WPCM_TEMPLATE_PATH . $file;
     }
     if (is_single() && get_post_type() == 'wpcm_match') {
         $file = 'single-match.php';
         $find[] = $file;
         $find[] = WPCM_TEMPLATE_PATH . $file;
     }
     if (is_single() && get_post_type() == 'wpcm_sponsor') {
         $file = 'single-sponsor.php';
         $find[] = $file;
         $find[] = WPCM_TEMPLATE_PATH . $file;
     }
     if ($file) {
         $template = locate_template($find);
         if (!$template) {
             $template = WPCM()->plugin_path() . '/templates/' . $file;
         }
     }
     return $template;
 }
}
foreach ($scanned_files as $plugin_name => $files) {
    foreach ($files as $file) {
        if (file_exists(get_stylesheet_directory() . '/' . $file)) {
            $theme_file = get_stylesheet_directory() . '/' . $file;
        } elseif (file_exists(get_stylesheet_directory() . '/wpclubmanager/' . $file)) {
            $theme_file = get_stylesheet_directory() . '/wpclubmanager/' . $file;
        } elseif (file_exists(get_template_directory() . '/' . $file)) {
            $theme_file = get_template_directory() . '/' . $file;
        } elseif (file_exists(get_template_directory() . '/wpclubmanager/' . $file)) {
            $theme_file = get_template_directory() . '/wpclubmanager/' . $file;
        } else {
            $theme_file = false;
        }
        if ($theme_file) {
            $core_version = WPCM_Admin_Status::get_file_version(WPCM()->plugin_path() . '/templates/' . $file);
            $theme_version = WPCM_Admin_Status::get_file_version($theme_file);
            if ($core_version && (empty($theme_version) || version_compare($theme_version, $core_version, '<'))) {
                if (!$outdated_templates) {
                    $outdated_templates = true;
                }
                $found_files[$plugin_name][] = sprintf(__('<code>%s</code> version <strong style="color:red">%s</strong> is out of date. The core version is %s', 'wp-club-manager'), str_replace(WP_CONTENT_DIR . '/themes/', '', $theme_file), $theme_version ? $theme_version : '-', $core_version);
            } else {
                $found_files[$plugin_name][] = sprintf('<code>%s</code>', str_replace(WP_CONTENT_DIR . '/themes/', '', $theme_file));
            }
        }
    }
}
if ($found_files) {
    foreach ($found_files as $plugin_name => $found_plugin_files) {
        ?>
        /**
         * Output admin fields.
         *
         * Loops though the wpclubmanager options array and outputs each field.
         *
         * @access public
         * @param array $options Opens array to output
         */
        public static function output_fields($options)
        {
            foreach ($options as $value) {
                if (!isset($value['type'])) {
                    continue;
                }
                if (!isset($value['id'])) {
                    $value['id'] = '';
                }
                if (!isset($value['title'])) {
                    $value['title'] = isset($value['name']) ? $value['name'] : '';
                }
                if (!isset($value['class'])) {
                    $value['class'] = '';
                }
                if (!isset($value['css'])) {
                    $value['css'] = '';
                }
                if (!isset($value['default'])) {
                    $value['default'] = '';
                }
                if (!isset($value['desc'])) {
                    $value['desc'] = '';
                }
                if (!isset($value['desc_tip'])) {
                    $value['desc_tip'] = false;
                }
                if (!isset($value['options'])) {
                    $value['options'] = '';
                }
                // Custom attribute handling
                $custom_attributes = array();
                if (!empty($value['custom_attributes']) && is_array($value['custom_attributes'])) {
                    foreach ($value['custom_attributes'] as $attribute => $attribute_value) {
                        $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
                    }
                }
                // Description handling
                if ($value['desc_tip'] === true) {
                    $description = '';
                    $tip = $value['desc'];
                } elseif (!empty($value['desc_tip'])) {
                    $description = $value['desc'];
                    $tip = $value['desc_tip'];
                } elseif (!empty($value['desc'])) {
                    $description = $value['desc'];
                    $tip = '';
                } else {
                    $description = $tip = '';
                }
                if ($description && in_array($value['type'], array('textarea', 'radio'))) {
                    $description = '<p style="margin-top:0">' . wp_kses_post($description) . '</p>';
                } elseif ($description && in_array($value['type'], array('checkbox'))) {
                    $description = wp_kses_post($description);
                } elseif ($description) {
                    $description = '<span class="description">' . wp_kses_post($description) . '</span>';
                }
                if ($tip && in_array($value['type'], array('checkbox'))) {
                    $tip = '<p class="description">' . $tip . '</p>';
                } elseif ($tip) {
                    $tip = '<img class="help_tip" data-tip="' . esc_attr($tip) . '" src="' . WPCM()->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
                }
                // Switch based on type
                switch ($value['type']) {
                    // Section Titles
                    case 'title':
                        if (!empty($value['title'])) {
                            echo '<div class="stuffbox"><h3>' . esc_html($value['title']) . '</h3><div class="inside">';
                        }
                        if (!empty($value['desc'])) {
                            echo wpautop(wptexturize(wp_kses_post($value['desc'])));
                        }
                        echo '<table class="form-table">' . "\n\n";
                        if (!empty($value['id'])) {
                            do_action('wpclubmanager_settings_' . sanitize_title($value['id']));
                        }
                        break;
                        // Section Ends
                    // Section Ends
                    case 'sectionend':
                        if (!empty($value['id'])) {
                            do_action('wpclubmanager_settings_' . sanitize_title($value['id']) . '_end');
                        }
                        echo '</table></div></div>';
                        if (!empty($value['id'])) {
                            do_action('wpclubmanager_settings_' . sanitize_title($value['id']) . '_after');
                        }
                        break;
                        // Standard text inputs and subtypes like 'number'
                    // Standard text inputs and subtypes like 'number'
                    case 'text':
                    case 'email':
                    case 'number':
                    case 'color':
                    case 'password':
                        $type = $value['type'];
                        $class = '';
                        $option_value = self::get_option($value['id'], $value['default']);
                        ?>

	            	<tr>
						<th scope="row" class="titledesc">
							<label for="<?php 
                        echo esc_attr($value['id']);
                        ?>
"><?php 
                        echo esc_html($value['title']);
                        ?>
</label>
							<?php 
                        echo $tip;
                        ?>
						</th>
	                    <td class="forminp forminp-<?php 
                        echo sanitize_title($value['type']);
                        ?>
">
	                    	<input
	                    		name="<?php 
                        echo esc_attr($value['id']);
                        ?>
"
	                    		id="<?php 
                        echo esc_attr($value['id']);
                        ?>
"
	                    		type="<?php 
                        echo esc_attr($type);
                        ?>
"
	                    		style="<?php 
                        echo esc_attr($value['css']);
                        ?>
"
	                    		value="<?php 
                        echo esc_attr($option_value);
                        ?>
"
	                    		class="<?php 
                        echo esc_attr($value['class']);
                        ?>
"
	                    		<?php 
                        echo implode(' ', $custom_attributes);
                        ?>
	                    		/> <?php 
                        echo $description;
                        ?>
	                    </td>
	                </tr><?php 
                        break;
                        // Textarea
                    // Textarea
                    case 'textarea':
                        $option_value = self::get_option($value['id'], $value['default']);
                        ?>
<tr>
						<th scope="row" class="titledesc">
							<label for="<?php 
                        echo esc_attr($value['id']);
                        ?>
"><?php 
                        echo esc_html($value['title']);
                        ?>
</label>
							<?php 
                        echo $tip;
                        ?>
						</th>
	                    <td class="forminp forminp-<?php 
                        echo sanitize_title($value['type']);
                        ?>
">
	                    	<?php 
                        echo $description;
                        ?>

	                        <textarea
	                        	name="<?php 
                        echo esc_attr($value['id']);
                        ?>
"
	                        	id="<?php 
                        echo esc_attr($value['id']);
                        ?>
"
	                        	style="<?php 
                        echo esc_attr($value['css']);
                        ?>
"
	                        	class="<?php 
                        echo esc_attr($value['class']);
                        ?>
"
	                        	<?php 
                        echo implode(' ', $custom_attributes);
                        ?>
	                        	><?php 
                        echo esc_textarea($option_value);
                        ?>
</textarea>
	                    </td>
	                </tr><?php 
                        break;
                        // Select boxes
                    // Select boxes
                    case 'select':
                    case 'multiselect':
                        $option_value = self::get_option($value['id'], $value['default']);
                        ?>
<tr>
						<th scope="row" class="titledesc">
							<label for="<?php 
                        echo esc_attr($value['id']);
                        ?>
"><?php 
                        echo esc_html($value['title']);
                        ?>
 <?php 
                        echo $tip;
                        ?>
</label>
							
						</th>
	                    <td class="forminp forminp-<?php 
                        echo sanitize_title($value['type']);
                        ?>
">
	                    	<select
	                    		name="<?php 
                        echo esc_attr($value['id']);
                        if ($value['type'] == 'multiselect') {
                            echo '[]';
                        }
                        ?>
"
	                    		id="<?php 
                        echo esc_attr($value['id']);
                        ?>
"
	                    		style="<?php 
                        echo esc_attr($value['css']);
                        ?>
"
	                    		class="<?php 
                        echo esc_attr($value['class']);
                        ?>
"
	                    		<?php 
                        echo implode(' ', $custom_attributes);
                        ?>
	                    		<?php 
                        if ($value['type'] == 'multiselect') {
                            echo 'multiple="multiple"';
                        }
                        ?>
	                    		>
		                    	<?php 
                        foreach ($value['options'] as $key => $val) {
                            ?>
			                        	<option value="<?php 
                            echo esc_attr($key);
                            ?>
" <?php 
                            if (is_array($option_value)) {
                                selected(in_array($key, $option_value), true);
                            } else {
                                selected($option_value, $key);
                            }
                            ?>
><?php 
                            echo $val;
                            ?>
</option>
			                        	<?php 
                        }
                        ?>
	                       </select> <?php 
                        echo $description;
                        ?>
	                    </td>
	                </tr><?php 
                        break;
                        // Radio inputs
                    // Radio inputs
                    case 'radio':
                        $option_value = self::get_option($value['id'], $value['default']);
                        ?>
<tr>
						<th scope="row" class="titledesc">
							<label for="<?php 
                        echo esc_attr($value['id']);
                        ?>
"><?php 
                        echo esc_html($value['title']);
                        ?>
</label>
							<?php 
                        echo $tip;
                        ?>
						</th>
	                    <td class="forminp forminp-<?php 
                        echo sanitize_title($value['type']);
                        ?>
">
	                    	<fieldset>
	                    		<?php 
                        echo $description;
                        ?>
	                    		<ul>
	                    		<?php 
                        foreach ($value['options'] as $key => $val) {
                            ?>
			                        	<li>
			                        		<label><input
				                        		name="<?php 
                            echo esc_attr($value['id']);
                            ?>
"
				                        		value="<?php 
                            echo $key;
                            ?>
"
				                        		type="radio"
					                    		style="<?php 
                            echo esc_attr($value['css']);
                            ?>
"
					                    		class="<?php 
                            echo esc_attr($value['class']);
                            ?>
"
					                    		<?php 
                            echo implode(' ', $custom_attributes);
                            ?>
					                    		<?php 
                            checked($key, $option_value);
                            ?>
				                        		/> <?php 
                            echo $val;
                            ?>
</label>
			                        	</li>
			                        	<?php 
                        }
                        ?>
	                    		</ul>
	                    	</fieldset>
	                    </td>
	                </tr>
	                <?php 
                        break;
                        // Checkbox input
                    // Checkbox input
                    case 'checkbox':
                        $option_value = self::get_option($value['id'], $value['default']);
                        $visbility_class = array();
                        if (!isset($value['hide_if_checked'])) {
                            $value['hide_if_checked'] = false;
                        }
                        if (!isset($value['show_if_checked'])) {
                            $value['show_if_checked'] = false;
                        }
                        if ($value['hide_if_checked'] == 'yes' || $value['show_if_checked'] == 'yes') {
                            $visbility_class[] = 'hidden_option';
                        }
                        if ($value['hide_if_checked'] == 'option') {
                            $visbility_class[] = 'hide_options_if_checked';
                        }
                        if ($value['show_if_checked'] == 'option') {
                            $visbility_class[] = 'show_options_if_checked';
                        }
                        if (!isset($value['checkboxgroup']) || 'start' == $value['checkboxgroup']) {
                            ?>
		            		<tr class="<?php 
                            echo esc_attr(implode(' ', $visbility_class));
                            ?>
">
								<th scope="row" class="titledesc"><?php 
                            echo esc_html($value['title']);
                            ?>
</th>
								<td class="forminp forminp-checkbox">
									<fieldset>
						<?php 
                        } else {
                            ?>
		            		<fieldset class="<?php 
                            echo esc_attr(implode(' ', $visbility_class));
                            ?>
">
	            		<?php 
                        }
                        if (!empty($value['title'])) {
                            ?>
	            			<legend class="screen-reader-text"><span><?php 
                            echo esc_html($value['title']);
                            ?>
</span></legend>
	            		<?php 
                        }
                        ?>
						<label for="<?php 
                        echo $value['id'];
                        ?>
">
							<input
								name="<?php 
                        echo esc_attr($value['id']);
                        ?>
"
								id="<?php 
                        echo esc_attr($value['id']);
                        ?>
"
								type="checkbox"
								value="1"
								<?php 
                        checked($option_value, 'yes');
                        ?>
								<?php 
                        echo implode(' ', $custom_attributes);
                        ?>
							/> <?php 
                        echo $description;
                        ?>
						</label> <?php 
                        echo $tip;
                        ?>
					<?php 
                        if (!isset($value['checkboxgroup']) || 'end' == $value['checkboxgroup']) {
                            ?>
									</fieldset>
								</td>
							</tr>
						<?php 
                        } else {
                            ?>
							</fieldset>
						<?php 
                        }
                        break;
                        // Image width settings
                    // Image width settings
                    case 'image_width':
                        $width = self::get_option($value['id'] . '[width]', $value['default']['width']);
                        $height = self::get_option($value['id'] . '[height]', $value['default']['height']);
                        $crop = checked(1, self::get_option($value['id'] . '[crop]', $value['default']['crop']), false);
                        ?>
<tr>
						<th scope="row" class="titledesc"><?php 
                        echo esc_html($value['title']);
                        ?>
 <?php 
                        echo $tip;
                        ?>
</th>
	                    <td class="forminp image_width_settings">

	                    	<input name="<?php 
                        echo esc_attr($value['id']);
                        ?>
[width]" id="<?php 
                        echo esc_attr($value['id']);
                        ?>
-width" type="text" size="3" value="<?php 
                        echo $width;
                        ?>
" /> &times; <input name="<?php 
                        echo esc_attr($value['id']);
                        ?>
[height]" id="<?php 
                        echo esc_attr($value['id']);
                        ?>
-height" type="text" size="3" value="<?php 
                        echo $height;
                        ?>
" />px

	                    	<label><input name="<?php 
                        echo esc_attr($value['id']);
                        ?>
[crop]" id="<?php 
                        echo esc_attr($value['id']);
                        ?>
-crop" type="checkbox" <?php 
                        echo $crop;
                        ?>
 /> <?php 
                        _e('Hard Crop?', 'wp-club-manager');
                        ?>
</label>

	                    	</td>
	                </tr><?php 
                        break;
                        // Single page selects
                    // Single page selects
                    case 'default_club':
                        $args = array('name' => $value['id'], 'id' => $value['id'], 'post_type' => 'wpcm_club', 'limit' => -1, 'show_option_none' => __('None'), 'class' => $value['class'], 'echo' => false, 'selected' => absint(self::get_option($value['id'])));
                        if (isset($value['args'])) {
                            $args = wp_parse_args($value['args'], $args);
                        }
                        ?>
<tr>
	                    <th scope="row" class="titledesc"><label for="<?php 
                        echo esc_attr($value['id']);
                        ?>
"><?php 
                        echo esc_html($value['title']);
                        ?>
 <?php 
                        echo $tip;
                        ?>
</label></th>
	                    <td class="forminp">
				        	<?php 
                        wpcm_dropdown_posts($args);
                        ?>
 <?php 
                        echo $description;
                        ?>
				        </td>
	               	</tr><?php 
                        break;
                        // Single page selects
                    // Single page selects
                    case 'single_select_page':
                        $args = array('name' => $value['id'], 'id' => $value['id'], 'sort_column' => 'menu_order', 'sort_order' => 'ASC', 'show_option_none' => ' ', 'class' => $value['class'], 'echo' => false, 'selected' => absint(self::get_option($value['id'])));
                        if (isset($value['args'])) {
                            $args = wp_parse_args($value['args'], $args);
                        }
                        ?>
<tr class="single_select_page">
	                    <th scope="row" class="titledesc"><?php 
                        echo esc_html($value['title']);
                        ?>
 <?php 
                        echo $tip;
                        ?>
</th>
	                    <td class="forminp">
				        	<?php 
                        echo str_replace(' id=', " data-placeholder='" . __('Select a page&hellip;', 'wp-club-manager') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages($args));
                        ?>
 <?php 
                        echo $description;
                        ?>
				        </td>
	               	</tr><?php 
                        break;
                        // Single country selects
                    // Single country selects
                    case 'single_select_country':
                        $country_setting = (string) self::get_option($value['id']);
                        $countries = WPCM()->countries->countries;
                        if (strstr($country_setting, ':')) {
                            $country_setting = explode(':', $country_setting);
                            $country = current($country_setting);
                        } else {
                            $country = $country_setting;
                        }
                        ?>
<tr>
						<th scope="row" class="titledesc">
							<label for="<?php 
                        echo esc_attr($value['id']);
                        ?>
"><?php 
                        echo esc_html($value['title']);
                        ?>
</label>
							<?php 
                        echo $tip;
                        ?>
						</th>
	                    <td class="forminp"><select name="<?php 
                        echo esc_attr($value['id']);
                        ?>
" style="<?php 
                        echo esc_attr($value['css']);
                        ?>
" data-placeholder="<?php 
                        _e('Choose a country&hellip;', 'wp-club-manager');
                        ?>
" title="Country" class="chosen_select">
				        	<?php 
                        WPCM()->countries->country_dropdown_options($country);
                        ?>
				        </select> <?php 
                        echo $description;
                        ?>
	               		</td>
	               	</tr><?php 
                        break;
                    case 'license_key':
                        $option_value = self::get_option($value['id'], $value['default']);
                        ?>

					<div class="wpcm-license-keys">
						<label for="<?php 
                        echo esc_attr($value['id']);
                        ?>
"><?php 
                        echo esc_html($value['title']);
                        ?>
</label>
	                    <input name="<?php 
                        echo esc_attr($value['id']);
                        ?>
" id="<?php 
                        echo esc_attr($value['id']);
                        ?>
" value="<?php 
                        echo esc_attr($option_value);
                        ?>
"
	                    		class="regular-text" />
                    	<?php 
                        if ('valid' == get_option($value['options']['is_valid_license_option'])) {
                            ?>
							<input type="submit" class="button-secondary" name="<?php 
                            echo esc_attr($value['id']);
                            ?>
_deactivate" value="<?php 
                            _e('Deactivate License', 'wp-club-manager');
                            ?>
"/>
						<?php 
                        }
                        ?>
	                </div><?php 
                        wp_nonce_field($value['id'] . '-nonce', $value['id'] . '-nonce');
                        break;
                        // Default: run an action
                    // Default: run an action
                    default:
                        do_action('wpclubmanager_admin_field_' . $value['type'], $value);
                        break;
                }
            }
        }
 /**
  * Show a notice highlighting bad template files
  */
 public function template_file_check_notice()
 {
     $core_templates = WPCM_Admin_Status::scan_template_files(WPCM()->plugin_path() . '/templates');
     $outdated = false;
     foreach ($core_templates as $file) {
         $theme_file = false;
         if (file_exists(get_stylesheet_directory() . '/' . $file)) {
             $theme_file = get_stylesheet_directory() . '/' . $file;
         } elseif (file_exists(get_stylesheet_directory() . '/wpclubmanager/' . $file)) {
             $theme_file = get_stylesheet_directory() . '/wpclubmanager/' . $file;
         } elseif (file_exists(get_template_directory() . '/' . $file)) {
             $theme_file = get_template_directory() . '/' . $file;
         } elseif (file_exists(get_template_directory() . '/wpclubmanager/' . $file)) {
             $theme_file = get_template_directory() . '/wpclubmanager/' . $file;
         }
         if ($theme_file) {
             $core_version = WPCM_Admin_Status::get_file_version(WPCM()->plugin_path() . '/templates/' . $file);
             $theme_version = WPCM_Admin_Status::get_file_version($theme_file);
             if ($core_version && $theme_version && version_compare($theme_version, $core_version, '<')) {
                 $outdated = true;
                 break;
             }
         }
     }
     if ($outdated) {
         include 'views/html-notice-template-check.php';
     } else {
         self::remove_notice('template_files');
     }
 }
    /**
     * Output the getting started screen
     */
    public function getting_started_screen()
    {
        // Save settings
        if (isset($_POST['wpcm_sport']) && !empty($_POST['wpcm_sport']) && get_option('wpcm_sport', null) != $_POST['wpcm_sport']) {
            $sport = WPCM()->sports->{$_POST}['wpcm_sport'];
            WPCM_Admin_Settings::configure_sport($sport);
            update_option('wpcm_sport', $_POST['wpcm_sport']);
        }
        if (isset($_POST['wpcm_default_club']) && !empty($_POST['wpcm_default_club']) && get_option('wpcm_default_club', null) != $_POST['wpcm_default_club']) {
            update_option('wpcm_default_club', $_POST['wpcm_default_club']);
        }
        ?>
		<div class="wrap about-wrap">

			<?php 
        $this->intro();
        ?>

			<?php 
        $this->tabs();
        ?>

			<p class="about-description"><?php 
        _e('WP Club Manager has been built with the focus on simplicity and ease of use so it won\'t be long before your club website is up and ready for action.', 'wp-club-manager');
        ?>
</p>

			<div id="message" class="updated wpclubmanager-message">
				<p><strong><?php 
        _e('Your settings have been saved.', 'wp-club-manager');
        ?>
</strong></p>
			</div>

			<div class="changelog">
				<form method="post" id="mainform" action="" enctype="multipart/form-data">
					<h3><?php 
        _e('Quick and Easy Setup', 'wp-club-manager');
        ?>
</h3>

					<div class="feature-section">

						<img src="<?php 
        echo WPCM_URL . 'assets/images/welcome/12-wpcm-settings.png';
        ?>
" class="wpcm-welcome-screenshots"/>

						<h4><?php 
        _e('1. Choose Your Sport', 'wp-club-manager');
        ?>
</h4>
						<p><?php 
        printf(__('Take your pick from 13 supported team sports. Each sport has preset player positions and statistics so it\'s a good idea to set this up before anything else. To select your default sport goto <a href="%s">General Settings</a> or use the form below.', 'wp-club-manager'), admin_url('admin.php?page=wpcm-settings'));
        ?>
</p>
						<p>
							<?php 
        $sport_options = wpcm_get_sport_options();
        $class = 'chosen_select' . (is_rtl() ? ' chosen-rtl' : '');
        $settings = array(array('id' => 'wpcm_sport', 'default' => 'soccer', 'type' => 'select', 'class' => $class, 'options' => $sport_options));
        WPCM_Admin_Settings::output_fields($settings);
        ?>
							<input name="save" class="button-primary" type="submit" value="<?php 
        _e('Save changes', 'wp-club-manager');
        ?>
" />
			        		<input type="hidden" name="subtab" id="last_tab" />
				        	<?php 
        wp_nonce_field('wpclubmanager-settings');
        ?>
						</p>

						<h4><?php 
        _e('2. Create Your Club', 'wp-club-manager');
        ?>
</h4>
						<p><?php 
        printf(__('The Clubs menu is where you create and edit clubs, including your own and create Competitions, Seasons, Teams and Venues. To create a club, click <em><a href="%s">Add New</a></em> and then fill out the club details. <strong>Your club will need to be set as the Default Club in <a href="%s">General Settings</a>.</strong> Alternatively, you can enter your default club in the box below.', 'wp-club-manager'), admin_url('post-new.php?post_type=wpcm_club'), admin_url('admin.php?page=wpcm-settings'));
        ?>
</p>
						<?php 
        if (isset($_POST['wpcm_default_club'])) {
            $title = $_POST['wpcm_default_club'];
            $post = array('post_title' => $title, 'post_type' => 'wpcm_club', 'post_status' => 'publish');
            $wpcm_default_club = wp_insert_post($post);
            update_option('wpcm_default_club', $wpcm_default_club);
        } else {
            $title = '';
        }
        if (get_option('wpcm_default_club') == null) {
            ?>

							<p>
								<?php 
            $settings = array(array('id' => 'wpcm_default_club', 'default' => '', 'type' => 'text'));
            WPCM_Admin_Settings::output_fields($settings);
            ?>
								<input name="save" class="button-primary" type="submit" value="<?php 
            _e('Save changes', 'wp-club-manager');
            ?>
" />
								<input type="hidden" name="subtab" id="last_tab" />
								<?php 
            wp_nonce_field('wpclubmanager-settings');
            ?>
							</p>
						<?php 
        }
        ?>

						<h4><?php 
        _e('3. Seasons, Competitions and Teams', 'wp-club-manager');
        ?>
</h4>
						<p><?php 
        printf(__('Before adding your players and opposition clubs you should create <a href="%s">Competitions</a> and <a href="%s">Seasons</a>. If your club has more than one team, for example, firsts, reserves, youth team etc. you will need to create <a href="%s">Teams</a> for each one. When creating players or adding more clubs you will need to choose the competitions, seasons and teams which they compete in.', 'wp-club-manager'), admin_url('edit-tags.php?taxonomy=wpcm_comp&post_type=wpcm_club'), admin_url('edit-tags.php?taxonomy=wpcm_season&post_type=wpcm_club'), admin_url('edit-tags.php?taxonomy=wpcm_team&post_type=wpcm_club'));
        ?>
</p>
						<p><?php 
        _e('<strong>If you have already created your default club you will need to edit your club to add competitions, seasons and teams.</strong>', 'wp-club-manager');
        ?>
</p>

						<img src="<?php 
        echo WPCM_URL . 'assets/images/welcome/12-create-players.png';
        ?>
" class="wpcm-welcome-screenshots"/>

						<h4><?php 
        _e('4. Add Your Players', 'wp-club-manager');
        ?>
</h4>
						<p><?php 
        printf(__('Now you should be ready to add your clubs players. The Players Menu is where you can create and edit your clubs players and player positions. To create a player, simply click <em><a href="%s">Add New</a></em> and then fill out the player details, including competitions, seasons and teams.', 'wp-club-manager'), admin_url('post-new.php?post_type=wpcm_player'));
        ?>
</p>

						<h4><?php 
        _e('5. Play A Match', 'wp-club-manager');
        ?>
</h4>
						<p><?php 
        printf(__('Now you should be ready to add your clubs players. The Players Menu is where you can create and edit your clubs players and player positions. To create a player, simply click <em><a href="%s">Add New</a></em> and then fill out the player details, including competitions, seasons and teams.', 'wp-club-manager'), admin_url('post-new.php?post_type=wpcm_match'));
        ?>
</p>
						<p><?php 
        printf(__('Don\'t forget to run through the <a href="%s">WP Club Manager settings</a> where you can set visibility options for player stats, set league standing options and loads more.', 'wp-club-manager'), admin_url('admin.php?page=wpcm-settings'));
        ?>
</p>

					</div>
				</form>
			</div>

			<div class="changelog">
				<h3><?php 
        _e('Need Help?', 'wp-club-manager');
        ?>
</h3>

				<div class="feature-section">

					<h4><?php 
        _e('Plugin Documentation', 'wp-club-manager');
        ?>
</h4>
					<p><?php 
        _e('If you need more help setting up WP Club Manager, using the shortcodes and widgets or customizing the plugin templates then visit our <a href="https://wpclubmanager.com/docs/">documentation</a>.', 'wp-club-manager');
        ?>
</p>

					<h4><?php 
        _e('Friendly Support', 'wpclubmanager');
        ?>
</h4>
					<p><?php 
        _e('We do our best to provide the best support we can. If you encounter a problem or have a question, post a question in the <a href="https://wpclubmanager.com/support">support forums</a>.', 'wp-club-manager');
        ?>
</p>

				</div>
			</div>

			<div class="changelog">
				<h3><?php 
        _e('Stay Up to Date', 'wp-club-manager');
        ?>
</h3>

				<div class="feature-section">

					<h4><?php 
        _e('Get Notified of New Extensions and Plugin Updates', 'wpclubmanager');
        ?>
</h4>
					<p><?php 
        _e('WP Club Manager is getting better every day with new features, extensions and themes being created. Stay in touch with the latest developments, newest extensions and get special offers by subscribing to our newsletter.', 'wp-club-manager');
        ?>
</p>
					<!-- Begin MailChimp Signup Form -->
					<div id="mc_embed_signup">
					<form action="//wpclubmanager.us1.list-manage.com/subscribe/post?u=5af3e709ddae81bdc7aa50610&amp;id=909adae053" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
						
						<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="Enter your email address" required>
					    <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
					    <div style="position: absolute; left: -5000px;"><input type="text" name="b_5af3e709ddae81bdc7aa50610_909adae053" tabindex="-1" value=""></div>
					    <div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
					</form>
					</div>

					<!--End mc_embed_signup-->

				</div>
			</div>

			<div class="return-to-dashboard">
				<a href="<?php 
        echo esc_url(admin_url(add_query_arg(array('page' => 'wpcm-settings'), 'admin.php')));
        ?>
"><?php 
        _e('Go to WP Club Manager Settings', 'wp-club-manager');
        ?>
</a>
			</div>
		</div>
		<?php 
    }
/**
 * Get the placeholder image URL for player, staff and club badges
 *
 * @access public
 * @return string
 */
function wpcm_placeholder_img_src()
{
    return apply_filters('wpclubmanager_placeholder_img_src', WPCM()->plugin_url() . '/assets/images/placeholder.png');
}
/**
 * Output a radio input box.
 *
 * @access public
 * @param array $field
 * @return void
 */
function wpclubmanager_wp_country_select($field)
{
    global $thepostid, $post, $wpclubmanager;
    $country_setting = get_post_meta($post->ID, 'wpcm_natl', true);
    if ($country_setting) {
        $country = $country_setting;
    } else {
        $country = get_option('wpcm_default_country');
    }
    $countries = WPCM()->countries->countries;
    $thepostid = empty($thepostid) ? $post->ID : $thepostid;
    $field['class'] = isset($field['class']) ? $field['class'] : 'chosen_select';
    $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
    $field['value'] = isset($field['value']) ? $field['value'] : get_post_meta($thepostid, $field['id'], true);
    echo '<p class="form-field ' . esc_attr($field['id']) . '_field ' . esc_attr($field['wrapper_class']) . '"><label for="' . esc_attr($field['id']) . '">' . wp_kses_post($field['label']) . '</label>';
    echo '<select name="' . esc_attr($field['id']) . '" data-placeholder="' . __('Choose a country&hellip;', 'wp-club-manager') . '" title="Country" class="' . esc_attr($field['class']) . '">';
    WPCM()->countries->country_dropdown_options($country = $country);
    echo '</select>';
    if (!empty($field['description'])) {
        if (isset($field['desc_tip']) && false !== $field['desc_tip']) {
            echo '<img class="help_tip" data-tip="' . esc_attr($field['description']) . '" src="' . esc_url(WPCM()->plugin_url()) . '/assets/images/help.png" height="16" width="16" />';
        } else {
            echo '<span class="description">' . wp_kses_post($field['description']) . '</span>';
        }
    }
    echo '</p>';
}
 /**
  * Custom quick edit - form
  *
  * @param mixed $column_name
  * @param mixed $post_type
  */
 public function quick_edit($column_name, $post_type)
 {
     if ('wpcm_match' != $post_type) {
         return;
     }
     if (did_action('quick_edit_custom_box') !== 1) {
         return;
     }
     $teams = get_terms('wpcm_team', array('hide_empty' => false));
     include WPCM()->plugin_path() . '/includes/admin/views/html-quick-edit-match.php';
 }
         * Get the template path.
         *
         * @return string
         */
        public function template_path()
        {
            return apply_filters('WPCM_TEMPLATE_PATH', 'wpclubmanager/');
        }
        /**
         * Get Ajax URL.
         *
         * @return string
         */
        public function ajax_url()
        {
            return admin_url('admin-ajax.php', 'relative');
        }
    }
}
/**
 * Returns the main instance of WPCM to prevent the need to use globals.
 *
 * @since  1.0.0
 * @return WPClubManager
 */
function WPCM()
{
    return WPClubManager::instance();
}
$GLOBALS['wpclubmanager'] = WPCM();
 /**
  * Add rating links to the admin dashboard
  *
  * @since	    1.3.2
  * @param       string $footer_text
  * @return      string
  */
 public function wpclubmanager_admin_rate_us($footer_text)
 {
     if (!current_user_can('manage_wpclubmanager')) {
         return;
     }
     $current_screen = get_current_screen();
     $wpcm_pages = wpcm_get_screen_ids();
     if (isset($current_screen->id) && apply_filters('wpclubmanager_display_admin_footer_text', in_array($current_screen->id, $wpcm_pages))) {
         if (!get_option('wpclubmanager_admin_footer_text_rated')) {
             $footer_text = sprintf(__('If you like <strong>WP Club Manager</strong> please leave us a %s&#9733;&#9733;&#9733;&#9733;&#9733;%s rating. A huge thank you in advance!', 'wp-club-manager'), '<a href="https://wordpress.org/support/view/plugin-reviews/wp-club-manager?filter=5#postform" target="_blank" class="wpcm-rating-link" data-rated="' . esc_attr__('Many thanks :)', 'wp-club-manager') . '">', '</a>');
             wpclubmanager_enqueue_js("\n\t\t\t\t\tjQuery( 'a.wpcm-rating-link' ).click( function() {\n\t\t\t\t\t\tjQuery.post( '" . WPCM()->ajax_url() . "', { action: 'wpclubmanager_rated' } );\n\t\t\t\t\t\tjQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );\n\t\t\t\t\t});\n\t\t\t\t");
         } else {
             $footer_text = __('Thank you for managing your club with WP Club Manager, your support is much appreciated.', 'wp-club-manager');
         }
     }
     return $footer_text;
 }