/**
  * 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 
    }
예제 #3
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 
    }
예제 #4
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 
    }