/**
  * Include the preset classes
  */
 public static function get_presets()
 {
     if (empty(self::$presets)) {
         $presets = array();
         self::$options = array('team-sports' => array(), 'racket-sports' => array(), 'water-sports' => array(), 'target-sports' => array(), 'esports' => array(), 'other' => array());
         foreach (self::$options as $slug => $options) {
             $dir = scandir(SP()->plugin_path() . '/presets/' . $slug);
             $files = array();
             if ($dir) {
                 foreach ($dir as $key => $value) {
                     if (substr($value, 0, 1) !== '.' && strpos($value, '.') !== false) {
                         $files[] = $value;
                     }
                 }
             }
             foreach ($files as $file) {
                 $json_data = file_get_contents(SP()->plugin_path() . '/presets/' . $slug . '/' . $file);
                 $data = json_decode($json_data, true);
                 if (!is_array($data)) {
                     continue;
                 }
                 $id = preg_replace('/\\.[^.\\s]{3,4}$/', '', $file);
                 $presets[$id] = $data;
                 $name = array_key_exists('name', $data) ? __($data['name'], 'sportspress') : $id;
                 self::$options[$slug][$id] = $name;
             }
             asort(self::$options[$slug]);
         }
         self::$presets = apply_filters('sportspress_get_presets', $presets);
     }
     return self::$presets;
 }
예제 #2
0
 /**
  * Include the preset classes
  */
 public static function get_presets()
 {
     if (empty(self::$presets)) {
         $presets = array();
         self::$options = array(__('Sports', 'prosports') => array(), __('Esports', 'prosports') => array(), __('Other', 'prosports') => array('custom' => __('Custom', 'prosports')));
         $dir = scandir(SP()->plugin_path() . '/presets');
         $files = array();
         if ($dir) {
             foreach ($dir as $key => $value) {
                 if (substr($value, 0, 1) !== '.' && strpos($value, '.') !== false) {
                     $files[] = $value;
                 }
             }
         }
         foreach ($files as $file) {
             $json_data = file_get_contents(SP()->plugin_path() . '/presets/' . $file);
             $data = json_decode($json_data, true);
             if (!is_array($data)) {
                 continue;
             }
             $id = preg_replace('/\\.[^.\\s]{3,4}$/', '', $file);
             $presets[$id] = $data;
             $name = array_key_exists('name', $data) ? __($data['name'], 'prosports') : $id;
             self::$options[__('Sports', 'prosports')][$id] = $name;
         }
         asort(self::$options[__('Sports', 'prosports')]);
         $dir = scandir(SP()->plugin_path() . '/presets/esports');
         $files = array();
         if ($dir) {
             foreach ($dir as $key => $value) {
                 if (substr($value, 0, 1) !== '.' && strpos($value, '.') !== false) {
                     $files[] = $value;
                 }
             }
         }
         foreach ($files as $file) {
             $json_data = file_get_contents(SP()->plugin_path() . '/presets/esports/' . $file);
             $data = json_decode($json_data, true);
             if (!is_array($data)) {
                 continue;
             }
             $id = preg_replace('/\\.[^.\\s]{3,4}$/', '', $file);
             $presets[$id] = $data;
             $name = array_key_exists('name', $data) ? __($data['name'], 'prosports') : $id;
             self::$options[__('Esports', 'prosports')][$id] = $name;
         }
         asort(self::$options[__('Esports', 'prosports')]);
         self::$presets = apply_filters('prosports_get_presets', $presets);
     }
     return self::$presets;
 }
 /**
  * Save settings
  */
 public function save()
 {
     if (isset($_POST['sportspress_sport']) && !empty($_POST['sportspress_sport']) && get_option('sportspress_sport', null) != $_POST['sportspress_sport']) {
         $sport = $_POST['sportspress_sport'];
         SP_Admin_Sports::apply_preset($sport);
         update_option('_sp_needs_welcome', 0);
     }
     if (isset($_POST['add_sample_data'])) {
         SP_Admin_Sample_Data::delete_posts();
         SP_Admin_Sample_Data::insert_posts();
     }
     $settings = $this->get_settings();
     SP_Admin_Settings::save_fields($settings);
     // Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
     if (!empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string'])) {
         $_POST['gmt_offset'] = $_POST['timezone_string'];
         $_POST['gmt_offset'] = preg_replace('/UTC\\+?/', '', $_POST['gmt_offset']);
         $_POST['timezone_string'] = '';
     }
     if (isset($_POST['timezone_string'])) {
         update_option('timezone_string', $_POST['timezone_string']);
     }
     if (isset($_POST['gmt_offset'])) {
         update_option('gmt_offset', $_POST['gmt_offset']);
     }
     if (isset($_POST['sportspress_frontend_css_primary'])) {
         // Save settings
         $primary = !empty($_POST['sportspress_frontend_css_primary']) ? sp_format_hex($_POST['sportspress_frontend_css_primary']) : '';
         $background = !empty($_POST['sportspress_frontend_css_background']) ? sp_format_hex($_POST['sportspress_frontend_css_background']) : '';
         $text = !empty($_POST['sportspress_frontend_css_text']) ? sp_format_hex($_POST['sportspress_frontend_css_text']) : '';
         $heading = !empty($_POST['sportspress_frontend_css_heading']) ? sp_format_hex($_POST['sportspress_frontend_css_heading']) : '';
         $link = !empty($_POST['sportspress_frontend_css_link']) ? sp_format_hex($_POST['sportspress_frontend_css_link']) : '';
         $customize = !empty($_POST['sportspress_frontend_css_customize']) ? 1 : '';
         $colors = array('primary' => $primary, 'background' => $background, 'text' => $text, 'heading' => $heading, 'link' => $link, 'customize' => $customize);
         // Merge with existing options if available
         $options = get_option('themeboy');
         if (is_array($options)) {
             $colors = array_merge($options, $colors);
         }
         update_option('themeboy', $colors);
     }
 }
    /**
     * Output the about screen.
     */
    public function about_screen()
    {
        include_once 'class-sp-admin-settings.php';
        $class = 'chosen-select' . (is_rtl() ? ' chosen-rtl' : '');
        ?>
		<div class="wrap about-wrap about-sportspress-wrap">

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

			<?php 
        // Save settings
        if (isset($_POST['timezone_string'])) {
            update_option('timezone_string', $_POST['timezone_string']);
            update_option('sportspress_basic_setup', 1);
        }
        if (isset($_POST['sportspress_sport']) && !empty($_POST['sportspress_sport'])) {
            $sport = $_POST['sportspress_sport'];
            SP_Admin_Sports::apply_preset($sport);
            update_option('sportspress_sport', $_POST['sportspress_sport']);
            update_option('_sportspress_needs_welcome', 1);
            ?>
				<div id="message" class="updated sportspress-message">
					<p><strong><?php 
            _e('Your settings have been saved.', 'sportspress');
            ?>
</strong></p>
				</div>
			<?php 
        }
        if (isset($_POST['add_sample_data'])) {
            SP_Admin_Sample_Data::delete_posts();
            SP_Admin_Sample_Data::insert_posts();
        }
        ?>
			<div class="sp-feature feature-section col two-col">
				<div>
					<?php 
        if (get_option('sportspress_basic_setup')) {
            ?>
						<h4><?php 
            _e('Sport', 'sportspress');
            ?>
</h4>
						<?php 
            $sport = get_option('sportspress_sport');
            $sport_options = SP_Admin_Sports::get_preset_options();
            foreach ($sport_options as $options) {
                foreach ($options as $slug => $name) {
                    if ($sport === $slug) {
                        $sport = $name;
                        break;
                    }
                }
            }
            echo $sport;
            ?>
						<a href="<?php 
            echo esc_url(admin_url(add_query_arg(array('page' => 'sportspress', 'tab' => 'general'), 'admin.php')));
            ?>
"><i class="dashicons dashicons-edit"></i> <?php 
            _e('Change', 'sportspress');
            ?>
</a>

						<h4><?php 
            _e('Next Steps', 'sportspress');
            ?>
</h4>
						<p><?php 
            _e('We&#8217;ve assembled some links to get you started:', 'sportspress');
            ?>
</p>
						<?php 
            $steps = apply_filters('sportspress_next_steps', array('teams' => array('link' => admin_url(add_query_arg(array('post_type' => 'sp_team'), 'edit.php')), 'icon' => 'sp-icon-shield', 'label' => __('Add New Team', 'sportspress')), 'players' => array('link' => admin_url(add_query_arg(array('post_type' => 'sp_player'), 'edit.php')), 'icon' => 'sp-icon-tshirt', 'label' => __('Add New Player', 'sportspress')), 'events' => array('link' => admin_url(add_query_arg(array('post_type' => 'sp_event'), 'edit.php')), 'icon' => 'sp-icon-calendar', 'label' => __('Add New Event', 'sportspress'))));
            ?>
						<?php 
            if (sizeof($steps)) {
                ?>
						<div class="sportspress-steps">
							<ul>
								<?php 
                foreach ($steps as $step) {
                    ?>
									<li><a href="<?php 
                    echo esc_url($step['link']);
                    ?>
" class="welcome-icon sp-welcome-icon"><i class="<?php 
                    echo sp_array_value($step, 'icon');
                    ?>
"></i> <?php 
                    echo $step['label'];
                    ?>
</a></li>
								<?php 
                }
                ?>
							</ul>
						</div>
						<?php 
            }
            ?>

						<h4><?php 
            _e('Settings', 'sportspress');
            ?>
</h4>
						<a href="<?php 
            echo esc_url(admin_url(add_query_arg(array('page' => 'sportspress', 'tab' => 'general'), 'admin.php')));
            ?>
"><?php 
            _e('Go to SportsPress Settings', 'sportspress');
            ?>
</a>
					<?php 
        } else {
            ?>
						<form method="post" id="mainform" action="" enctype="multipart/form-data">
							<h4><?php 
            _e('Basic Setup', 'sportspress');
            ?>
</h4>
							<p><?php 
            _e('Select your timezone and sport to get started.', 'sportspress');
            ?>
</p>
							<table class="form-table">
								<tbody>
									<tr valign="top">
										<th scope="row" class="titledesc">
											<label for="timezone_string"><?php 
            _e('Timezone', 'sportspress');
            ?>
 <i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php 
            _e('Choose a city in the same timezone as you.', 'sportspress');
            ?>
"></i></label>
										</th>
										<td>
											<select id="timezone_string" name="timezone_string" class="<?php 
            echo $class;
            ?>
">
												<?php 
            $current_offset = get_option('gmt_offset');
            $tzstring = get_option('timezone_string');
            $check_zone_info = true;
            // Remove old Etc mappings. Fallback to gmt_offset.
            if (false !== strpos($tzstring, 'Etc/GMT')) {
                $tzstring = '';
            }
            if (empty($tzstring)) {
                // Create a UTC+- zone if no timezone string exists
                $check_zone_info = false;
                if (0 == $current_offset) {
                    $tzstring = 'UTC+0';
                } elseif ($current_offset < 0) {
                    $tzstring = 'UTC' . $current_offset;
                } else {
                    $tzstring = 'UTC+' . $current_offset;
                }
            }
            echo wp_timezone_choice($tzstring);
            ?>
											</select>
										</td>
									</tr>
									<?php 
            $sport_options = SP_Admin_Sports::get_preset_options();
            $settings = array(array('id' => 'sportspress_sport', 'default' => 'custom', 'type' => 'sport', 'title' => __('Sport', 'sportspress'), 'welcome' => true, 'class' => $class, 'options' => $sport_options));
            SP_Admin_Settings::output_fields($settings);
            ?>
								</tbody>
							</table>
					        <p class="submit sportspress-actions">
					        	<input name="save" class="button-primary" type="submit" value="<?php 
            _e('Save Changes', 'sportspress');
            ?>
" />
					        	<input type="hidden" name="subtab" id="last_tab" />
					        	<?php 
            wp_nonce_field('sportspress-settings');
            ?>
					        </p>
						</form>
					<?php 
        }
        ?>
				</div>
				<?php 
        if (current_user_can('install_themes') && !current_theme_supports('sportspress')) {
            ?>
					<div class="last-feature">
						<h4><?php 
            _e('Free SportsPress Theme', 'sportspress');
            ?>
</h4>
						<a href="<?php 
            echo add_query_arg(array('theme' => 'rookie'), network_admin_url('theme-install.php'));
            ?>
" class="sp-theme-screenshot"><img src="<?php 
            echo plugin_dir_url(SP_PLUGIN_FILE);
            ?>
/assets/images/modules/rookie.png"></a>
						<p><?php 
            _e('Have you tried the free Rookie theme yet?', 'sportspress');
            ?>
</p>
						<p><?php 
            _e('Rookie is a free starter theme for SportsPress designed by ThemeBoy.', 'sportspress');
            ?>
</p>
						<p class="sp-module-actions">
							<a class="button button-large" href="<?php 
            echo add_query_arg(array('theme' => 'rookie'), network_admin_url('theme-install.php'));
            ?>
"><?php 
            _e('Install Now', 'sportspress');
            ?>
</a>
						</p>
					</div>
				<?php 
        }
        ?>
			</div>
		</div>
		<?php 
    }
예제 #5
0
    /**
     * Output the about screen.
     */
    public function about_screen()
    {
        include_once 'class-sp-admin-settings.php';
        $class = 'chosen-select' . (is_rtl() ? ' chosen-rtl' : '');
        ?>
		<div class="wrap about-wrap about-prosports-wrap">

			<h1>Welcome to ProSports1.0</h1>
			<div class="about-text sp-about-text">
			Thanks for installing! ProSports 1.0 has lots of refinements we think you’ll love.
		</div>

			<?php 
        // Save settings
        if (isset($_POST['timezone_string'])) {
            update_option('timezone_string', $_POST['timezone_string']);
            update_option('prosports_basic_setup', 1);
        }
        if (isset($_POST['prosports_sport']) && !empty($_POST['prosports_sport'])) {
            $sport = $_POST['prosports_sport'];
            SP_Admin_Sports::apply_preset($sport);
            update_option('prosports_sport', $_POST['prosports_sport']);
            update_option('_prosports_needs_welcome', 1);
            ?>
				<div id="message" class="updated prosports-message">
					<p><strong><?php 
            _e('Your settings have been saved.', 'prosports');
            ?>
</strong></p>
				</div>
			<?php 
        }
        if (isset($_POST['add_sample_data'])) {
            SP_Admin_Sample_Data::delete_posts();
            SP_Admin_Sample_Data::insert_posts();
        }
        ?>
			<div class="sp-feature feature-section col two-col">
				<div>
					<?php 
        if (get_option('prosports_basic_setup')) {
            ?>
						<h4><?php 
            _e('Sport', 'prosports');
            ?>
</h4>
						<?php 
            $sport = get_option('prosports_sport');
            $sport_options = SP_Admin_Sports::get_preset_options();
            foreach ($sport_options as $options) {
                foreach ($options as $slug => $name) {
                    if ($sport === $slug) {
                        $sport = $name;
                        break;
                    }
                }
            }
            echo $sport;
            ?>
						<a href="<?php 
            echo esc_url(admin_url(add_query_arg(array('page' => 'prosports'), 'admin.php')));
            ?>
"><div class="dashicons dashicons-edit"></div><?php 
            _e('Change', 'prosports');
            ?>
</a>
						<h4><?php 
            _e('Next Steps', 'prosports');
            ?>
</h4>
						<p><?php 
            _e('We&#8217;ve assembled some links to get you started:', 'prosports');
            ?>
</p>
						<div class="prosports-steps">
							<ul>
								<li><a href="<?php 
            echo esc_url(admin_url(add_query_arg(array('post_type' => 'sp_team'), 'edit.php')));
            ?>
" class="welcome-icon sp-welcome-icon dashicons-shield-alt"><?php 
            _e('Add New Team', 'prosports');
            ?>
</a></li>
								<li><a href="<?php 
            echo esc_url(admin_url(add_query_arg(array('post_type' => 'sp_player'), 'edit.php')));
            ?>
" class="welcome-icon sp-welcome-icon dashicons-groups"><?php 
            _e('Add New Player', 'prosports');
            ?>
</a></li>
								<li><a href="<?php 
            echo esc_url(admin_url(add_query_arg(array('post_type' => 'sp_event'), 'edit.php')));
            ?>
" class="welcome-icon sp-welcome-icon dashicons-calendar"><?php 
            _e('Add New Event', 'prosports');
            ?>
</a></li>
							</ul>
						</div>
						<div class="return-to-dashboard">
							<a href="<?php 
            echo esc_url(admin_url(add_query_arg(array('page' => 'prosports'), 'admin.php')));
            ?>
"><?php 
            _e('Go to ProSports Settings', 'prosports');
            ?>
</a>
						</div>
					<?php 
        } else {
            ?>
						<form method="post" id="mainform" action="" enctype="multipart/form-data">
							<h4><?php 
            _e('Basic Setup', 'prosports');
            ?>
</h4>
							<p><?php 
            _e('Select your timezone and sport to get started.', 'prosports');
            ?>
</p>
							<table class="form-table">
								<tbody>
									<tr valign="top">
										<th scope="row" class="titledesc">
											<label for="timezone_string"><?php 
            _e('Timezone', 'prosports');
            ?>
</label>
										</th>
										<td>
											<select id="timezone_string" name="timezone_string" class="<?php 
            echo $class;
            ?>
">
												<?php 
            $current_offset = get_option('gmt_offset');
            $tzstring = get_option('timezone_string');
            $check_zone_info = true;
            // Remove old Etc mappings. Fallback to gmt_offset.
            if (false !== strpos($tzstring, 'Etc/GMT')) {
                $tzstring = '';
            }
            if (empty($tzstring)) {
                // Create a UTC+- zone if no timezone string exists
                $check_zone_info = false;
                if (0 == $current_offset) {
                    $tzstring = 'UTC+0';
                } elseif ($current_offset < 0) {
                    $tzstring = 'UTC' . $current_offset;
                } else {
                    $tzstring = 'UTC+' . $current_offset;
                }
            }
            echo wp_timezone_choice($tzstring);
            ?>
											</select>
										</td>
									</tr>
									
								</tbody>
							</table>
					        <p class="submit prosports-actions">
					        	<input name="save" class="button-primary" type="submit" value="<?php 
            _e('Save changes', 'prosports');
            ?>
" />
					        	<input type="hidden" name="subtab" id="last_tab" />
					        	<?php 
            wp_nonce_field('prosports-settings');
            ?>
					        </p>
						</form>
					<?php 
        }
        ?>
				</div>
				
			</div>
		</div>
		<?php 
    }
        /**
         * Output admin fields.
         *
         * Loops though the sportspress 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['placeholder'])) {
                    $value['placeholder'] = '';
                }
                // 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 && in_array($value['type'], array('select'))) {
                    $description = '<p class="description">' . wp_kses_post($description) . '</p>';
                } 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 = '<i class="dashicons dashicons-editor-help sp-desc-tip" title="' . esc_attr($tip) . '" />';
                }
                // Switch based on type
                switch ($value['type']) {
                    // Section Titles
                    case 'title':
                        echo '<div class="sp-settings-section sp-settings-section-' . sanitize_title(sp_array_value($value, 'id')) . '">';
                        echo '<a name="sp-settings-section-' . sanitize_title(sp_array_value($value, 'id')) . '"></a>';
                        if (!empty($value['title'])) {
                            echo '<h3>' . esc_html($value['title']) . '</h3>';
                        }
                        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('sportspress_settings_' . sanitize_title($value['id']));
                        }
                        break;
                        // Section Ends
                    // Section Ends
                    case 'sectionend':
                        if (!empty($value['id'])) {
                            do_action('sportspress_settings_' . sanitize_title($value['id']) . '_end');
                        }
                        echo '</table>';
                        if (!empty($value['id'])) {
                            do_action('sportspress_settings_' . sanitize_title($value['id']) . '_after');
                        }
                        echo '</div>';
                        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']);
                        if ($value['type'] == 'color') {
                            $type = 'text';
                            $value['class'] .= 'colorpick';
                            $description .= '<div id="colorPickerDiv_' . esc_attr($value['id']) . '" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>';
                        }
                        ?>
<tr valign="top">
						<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);
                        ?>
"
	                    		placeholder="<?php 
                        echo esc_attr($value['placeholder']);
                        ?>
"
	                    		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 valign="top">
						<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 valign="top">
						<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']);
                        ?>
">
	                    	<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="chosen-select<?php 
                        if (is_rtl()) {
                            ?>
 chosen-rtl<?php 
                        }
                        ?>
 <?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;
                        // Select boxes with optgroup
                    // Select boxes with optgroup
                    case 'groupselect':
                        $option_value = self::get_option($value['id'], $value['default']);
                        ?>
<tr valign="top">
						<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']);
                        ?>
">
	                    	<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="chosen-select<?php 
                        if (is_rtl()) {
                            ?>
 chosen-rtl<?php 
                        }
                        ?>
 <?php 
                        echo esc_attr($value['class']);
                        ?>
"
	                    		<?php 
                        echo implode(' ', $custom_attributes);
                        ?>
	                    		<?php 
                        if ($value['type'] == 'multiselect') {
                            echo 'multiple="multiple"';
                        }
                        ?>
	                    		>
		                    	<?php 
                        foreach ($value['options'] as $group => $options) {
                            ?>
	                    			<optgroup label="<?php 
                            _e($group, 'sportspress');
                            ?>
">
	                    				<?php 
                            foreach ($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 
                            }
                            ?>
				                    </optgroup>
				                  	<?php 
                        }
                        ?>
	                       </select> <?php 
                        echo $description;
                        ?>
	                    </td>
	                </tr><?php 
                        break;
                        // Select sport
                    // Select sport
                    case 'sport':
                        $option_value = self::get_option($value['id'], $value['default']);
                        $categories = SP_Admin_Sports::sport_category_names();
                        ?>
<tr valign="top">
						<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']);
                        ?>
">
	                    	<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="sp-select-sport chosen-select<?php 
                        if (is_rtl()) {
                            ?>
 chosen-rtl<?php 
                        }
                        ?>
 <?php 
                        echo esc_attr($value['class']);
                        ?>
"
	                    		<?php 
                        echo implode(' ', $custom_attributes);
                        ?>
	                    		<?php 
                        if ($value['type'] == 'multiselect') {
                            echo 'multiple="multiple"';
                        }
                        ?>
	                    		>
		                    	<?php 
                        foreach ($value['options'] as $group => $options) {
                            ?>
	                    			<optgroup label="<?php 
                            echo sp_array_value($categories, $group, $group);
                            ?>
">
	                    				<?php 
                            foreach ($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 
                            }
                            ?>
				                    </optgroup>
				                  	<?php 
                        }
                        ?>
							</select> <?php 
                        echo $description;
                        ?>
 <a class="button button-small sp-configure-sport" href="<?php 
                        echo esc_url(admin_url(add_query_arg(array('page' => 'sportspress-config'), 'admin.php')));
                        ?>
"><?php 
                        _e('Configure', 'sportspress');
                        ?>
</a>
							<p>
								<label>
									<input type="checkbox" name="add_sample_data" id="add_sample_data" <?php 
                        checked(sp_array_value($value, 'welcome'));
                        ?>
>
									<?php 
                        _e('Install demo content', 'sportspress');
                        ?>
								</label>
							</p>
	                    </td>
	                </tr><?php 
                        break;
                        // Radio inputs
                    // Radio inputs
                    case 'radio':
                        $option_value = self::get_option($value['id'], $value['default']);
                        ?>
<tr valign="top">
						<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 valign="top" 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;
                        // Default: run an action
                    // Default: run an action
                    default:
                        do_action('sportspress_admin_field_' . $value['type'], $value);
                        break;
                }
            }
        }
예제 #7
0
    /**
     * Output the about screen.
     */
    public function about_screen()
    {
        include_once 'class-sp-admin-settings.php';
        $class = 'chosen-select' . (is_rtl() ? ' chosen-rtl' : '');
        ?>
		<div class="wrap about-wrap about-sportspress-wrap">

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

			<?php 
        // Save settings
        if (isset($_POST['timezone_string'])) {
            update_option('timezone_string', $_POST['timezone_string']);
            update_option('sportspress_basic_setup', 1);
        }
        if (isset($_POST['sportspress_sport']) && !empty($_POST['sportspress_sport'])) {
            $sport = $_POST['sportspress_sport'];
            SP_Admin_Sports::apply_preset($sport);
            update_option('sportspress_sport', $_POST['sportspress_sport']);
            update_option('sportspress_installed', 1);
            ?>
				<div id="message" class="updated sportspress-message">
					<p><strong><?php 
            _e('Your settings have been saved.', 'sportspress');
            ?>
</strong></p>
				</div>
			<?php 
        }
        if (isset($_POST['add_sample_data'])) {
            SP_Admin_Sample_Data::delete_posts();
            SP_Admin_Sample_Data::insert_posts();
        }
        ?>
			<?php 
        if (get_option('sportspress_installed')) {
            ?>

				<div class="headline-feature feature-video sp-fitvids" style="background-color:#191E23;">
					<iframe width="990" height="557" src="https://www.youtube.com/embed/KQyga_C5a6M?rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
				</div>

				<hr>

				<div class="feature-section three-col">
					<h2>Event Organization</h2>
					<div class="col">
						<img src="https://cdn-themeboy.netdna-ssl.com/wp-content/uploads/match-days.png" alt="Match Days"/>
						<h3>Match Days</h3>
						<p>A match day can be added to any event and displayed directly inside the event details section. It can also be used as a filter for shortcodes and widgets.</p>
					</div>
					<div class="col">
						<img src="https://cdn-themeboy.netdna-ssl.com/wp-content/uploads/event-status.gif" alt="Event Status"/>
						<h3>Event Status</h3>
						<p>For undecided, postponed, and cancelled events, a status can be displayed in place of the time. Leave the status alone to display the actual time of the event.</p>
					</div>
					<div class="col">
						<img src="https://cdn-themeboy.netdna-ssl.com/wp-content/uploads/box-score-minutes.png" alt="Box Score Minutes"/>
						<h3>Box Score Minutes</h3>
						<p>You can now can enter the time of goals or any other statistic for each player, and display them directly within the box score section of event pages.</p>
					</div>
				</div>

				<hr>

				<div class="feature-section three-col">
					<h2>Layout Enhancements</h2>
					<div class="col">
						<img src="https://cdn-themeboy.netdna-ssl.com/wp-content/uploads/template-tabs.gif" alt=""/>
						<h3>Template Tabs</h3>
						<p>Simply drag and drop any of the layout items to automatically group them into tabs. This will make your templates more compact and intuitive.</p>
					</div>
					<div class="col">
						<img src="https://cdn-themeboy.netdna-ssl.com/wp-content/uploads/event-logo-options.png" alt=""/>
						<h3>Event Logo Options</h3>
						<p>Display the teams playing using an inline layout or as a block section, with logos on either side and the date and time/results in the middle.</p>
					</div>
					<div class="col">
						<img src="https://cdn-themeboy.netdna-ssl.com/wp-content/uploads/player-profile-switching.png" alt=""/>
						<h3>Player Profile Switching</h3>
						<p>We also added a dropdown above the player details box which allows your visitors to quickly switch to another player's profile.</p>
					</div>
				</div>

				<hr />

				<div class="changelog">
					<h2>Under the Hood</h2>
					<div class="under-the-hood three-col">
						<div class="col">
							<h3>Fixtures Importer</h3>
							<p>A new, simpler importer has been added for quickly scheduling events. Supports CSV files generated by <a href="http://tboy.co/leaguelobster" target="_blank">LeagueLobster</a>.</p>
						</div>
						<div class="col">
							<h3>Tutorials for Everyone</h3>
							<p>If you've enabled the Tutorials module, all SportsPress users will now be able to access them from the dashboard.</p>
						</div>
						<div class="col">
							<h3>REST API Improvements</h3>
							<p>The REST API has been updated to support meta query vars, allowing you to retrieve data for a specific team or player.</p>
						</div>
					</div>
				</div>

				<a href="<?php 
            echo esc_url(admin_url(add_query_arg(array('page' => 'sportspress', 'tab' => 'general'), 'admin.php')));
            ?>
"><?php 
            _e('Go to SportsPress Settings', 'sportspress');
            ?>
</a>

			<?php 
        } else {
            ?>

				<div class="sp-feature feature-section col two-col">
					<div>
						<form method="post" id="mainform" action="" enctype="multipart/form-data">
							<h4><?php 
            _e('Basic Setup', 'sportspress');
            ?>
</h4>
							<p><?php 
            _e('Select your timezone and sport to get started.', 'sportspress');
            ?>
</p>
							<table class="form-table">
								<tbody>
									<tr valign="top">
										<th scope="row" class="titledesc">
											<label for="timezone_string"><?php 
            _e('Timezone', 'sportspress');
            ?>
 <i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php 
            _e('Choose a city in the same timezone as you.', 'sportspress');
            ?>
"></i></label>
										</th>
										<td>
											<select id="timezone_string" name="timezone_string" class="<?php 
            echo $class;
            ?>
">
												<?php 
            $current_offset = get_option('gmt_offset');
            $tzstring = get_option('timezone_string');
            $check_zone_info = true;
            // Remove old Etc mappings. Fallback to gmt_offset.
            if (false !== strpos($tzstring, 'Etc/GMT')) {
                $tzstring = '';
            }
            if (empty($tzstring)) {
                // Create a UTC+- zone if no timezone string exists
                $check_zone_info = false;
                if (0 == $current_offset) {
                    $tzstring = 'UTC+0';
                } elseif ($current_offset < 0) {
                    $tzstring = 'UTC' . $current_offset;
                } else {
                    $tzstring = 'UTC+' . $current_offset;
                }
            }
            echo wp_timezone_choice($tzstring);
            ?>
											</select>
										</td>
									</tr>
									<?php 
            $sport_options = SP_Admin_Sports::get_preset_options();
            $settings = array(array('id' => 'sportspress_sport', 'default' => 'custom', 'type' => 'sport', 'title' => __('Sport', 'sportspress'), 'welcome' => true, 'class' => $class, 'options' => $sport_options));
            SP_Admin_Settings::output_fields($settings);
            ?>
								</tbody>
							</table>
					        <p class="submit sportspress-actions">
					        	<input name="save" class="button-primary" type="submit" value="<?php 
            _e('Save Changes', 'sportspress');
            ?>
" />
					        	<input type="hidden" name="subtab" id="last_tab" />
					        	<?php 
            wp_nonce_field('sportspress-settings');
            ?>
					        </p>
						</form>
					</div>
					<?php 
            if (current_user_can('install_themes') && !current_theme_supports('sportspress')) {
                ?>
						<div class="last-feature">
							<h4><?php 
                _e('Free SportsPress Theme', 'sportspress');
                ?>
</h4>
							<a href="<?php 
                echo add_query_arg(array('theme' => 'rookie'), network_admin_url('theme-install.php'));
                ?>
" class="sp-theme-screenshot"><img src="<?php 
                echo plugin_dir_url(SP_PLUGIN_FILE);
                ?>
/assets/images/modules/rookie.png"></a>
							<p><?php 
                _e('Have you tried the free Rookie theme yet?', 'sportspress');
                ?>
</p>
							<p><?php 
                _e('Rookie is a free starter theme for SportsPress designed by ThemeBoy.', 'sportspress');
                ?>
</p>
							<p class="sp-module-actions">
								<a class="button button-large" href="<?php 
                echo add_query_arg(array('theme' => 'rookie'), network_admin_url('theme-install.php'));
                ?>
"><?php 
                _e('Install Now', 'sportspress');
                ?>
</a>
							</p>
						</div>
					<?php 
            }
            ?>
				</div>
			
			<?php 
        }
        ?>

		</div>
		<?php 
    }