Route existing users to welcome screen instead of setup
This commit is contained in:
@@ -40,12 +40,14 @@ class SP_Admin_Notices {
|
||||
$screen = get_current_screen();
|
||||
$notices = get_option( 'sportspress_admin_notices', array() );
|
||||
|
||||
if ( ! get_option( 'sportspress_completed_setup' ) ) {
|
||||
if ( ! is_object( $screen ) ) return;
|
||||
|
||||
if ( ! get_option( 'sportspress_completed_setup' ) && ! in_array( $screen->id, array( 'dashboard_page_sp-about', 'dashboard_page_sp-credits', 'dashboard_page_sp-translators' ) ) ) {
|
||||
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
|
||||
add_action( 'admin_notices', array( $this, 'setup_notice' ) );
|
||||
}
|
||||
|
||||
if ( is_object( $screen ) && 'post' == $screen->base ) {
|
||||
if ( 'post' == $screen->base ) {
|
||||
$post_id = get_the_ID();
|
||||
if ( ! apply_filters( 'sportspress_user_can', current_user_can( 'edit_post', $post_id ), $post_id ) ) {
|
||||
add_action( 'admin_notices', array( $this, 'no_access_notice' ) );
|
||||
@@ -62,7 +64,7 @@ class SP_Admin_Notices {
|
||||
update_option( 'sportspress_admin_notices', $notices );
|
||||
}
|
||||
|
||||
if ( is_object( $screen ) && in_array( 'theme_support', $notices ) && ! current_theme_supports( 'sportspress' ) && ! in_array( $screen->id, array( 'toplevel_page_sportspress', 'dashboard_page_sp-about', 'dashboard_page_sp-credits', 'dashboard_page_sp-translators' ) ) ) {
|
||||
if ( in_array( 'theme_support', $notices ) && ! current_theme_supports( 'sportspress' ) && ! in_array( $screen->id, array( 'toplevel_page_sportspress', 'dashboard_page_sp-about', 'dashboard_page_sp-credits', 'dashboard_page_sp-translators' ) ) ) {
|
||||
$template = get_option( 'template' );
|
||||
|
||||
if ( ! in_array( $template, array( 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ) {
|
||||
|
||||
@@ -443,6 +443,8 @@ class SP_Admin_Settings {
|
||||
case 'sport' :
|
||||
|
||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
||||
if ( 'none' === $option_value ) $option_value = 'soccer';
|
||||
|
||||
$categories = SP_Admin_Sports::sport_category_names();
|
||||
|
||||
?><tr valign="top">
|
||||
|
||||
@@ -28,8 +28,7 @@ class WC_Admin_Setup_Wizard {
|
||||
|
||||
/** @var array Tweets user can optionally send after install */
|
||||
private $tweets = array(
|
||||
'Someone give me woo-t, I just set up a new store with #WordPress and @SportsPress!',
|
||||
'Someone give me high five, I just set up a new store with #WordPress and @SportsPress!'
|
||||
'Someone give me high five, I just set up a new sports data website with #WordPress and @SportsPress!'
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -155,7 +154,7 @@ class WC_Admin_Setup_Wizard {
|
||||
public function setup_wizard_footer() {
|
||||
?>
|
||||
<?php if ( 'next_steps' === $this->step ) : ?>
|
||||
<a class="sp-return-to-dashboard" href="<?php echo esc_url( admin_url() ); ?>"><?php _e( 'Return to the WordPress Dashboard', 'sportspress' ); ?></a>
|
||||
<a class="sp-return-to-dashboard" href="<?php echo esc_url( admin_url( 'index.php?page=sp-about' ) ); ?>"><?php _e( 'Return to the WordPress Dashboard', 'sportspress' ); ?></a>
|
||||
<?php endif; ?>
|
||||
<?php wp_print_scripts( 'sportspress-setup' ); ?>
|
||||
</body>
|
||||
@@ -203,7 +202,7 @@ class WC_Admin_Setup_Wizard {
|
||||
<p><?php _e( 'No time right now? If you don’t want to go through the wizard, you can skip and return to the WordPress dashboard. Come back anytime if you change your mind!', 'sportspress' ); ?></p>
|
||||
<p class="sp-setup-actions step">
|
||||
<a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button-primary button button-large button-next"><?php _e( 'Let\'s Go!', 'sportspress' ); ?></a>
|
||||
<a href="<?php echo esc_url( admin_url() ); ?>" class="button button-large button-muted"><?php _e( 'Not right now', 'sportspress' ); ?></a>
|
||||
<a href="<?php echo esc_url( admin_url( 'index.php?page=sp-about' ) ); ?>" class="button button-large button-muted"><?php _e( 'Not right now', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
@@ -252,6 +251,7 @@ class WC_Admin_Setup_Wizard {
|
||||
<?php
|
||||
$options = SP_Admin_Sports::get_preset_options();
|
||||
$default = get_option( 'sportspress_sport', 'soccer' );
|
||||
if ( 'none' === $default ) $default = 'soccer';
|
||||
$categories = SP_Admin_Sports::sport_category_names();
|
||||
?>
|
||||
<select name="sport" id="sport" class="sp-select-sport <?php echo esc_attr( $class ); ?>">
|
||||
@@ -665,7 +665,7 @@ class WC_Admin_Setup_Wizard {
|
||||
$id = $this->sp_setup_ready_actions();
|
||||
shuffle( $this->tweets );
|
||||
?>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-url="https://sportspress.com/" data-text="<?php echo esc_attr( $this->tweets[0] ); ?>" data-via="SportsPress" data-size="large">Tweet</a>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://tboy.co/sp" data-text="<?php echo esc_attr( $this->tweets[0] ); ?>" data-via="ThemeBoy" data-size="large">Tweet</a>
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
|
||||
|
||||
<h1><?php _e( 'Thanks for installing!', 'sportspress' ); ?></h1>
|
||||
|
||||
@@ -173,10 +173,9 @@ class SP_Admin_Welcome {
|
||||
SP_Admin_Sample_Data::delete_posts();
|
||||
SP_Admin_Sample_Data::insert_posts();
|
||||
endif;
|
||||
?>
|
||||
<?php if ( get_option( 'sportspress_installed' ) ) { ?>
|
||||
|
||||
<?php do_action( 'sportspress_before_welcome_features' ); ?>
|
||||
do_action( 'sportspress_before_welcome_features' );
|
||||
?>
|
||||
|
||||
<?php if ( ! current_theme_supports( 'sportspress' ) ) { ?>
|
||||
|
||||
@@ -291,85 +290,6 @@ class SP_Admin_Welcome {
|
||||
<?php do_action( 'sportspress_after_welcome_features' ); ?>
|
||||
|
||||
<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' => get_option( 'sportspress_sport', 'soccer' ),
|
||||
'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/welcome/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
|
||||
}
|
||||
@@ -723,9 +643,14 @@ class SP_Admin_Welcome {
|
||||
if ( ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] ) && ( isset( $_GET['plugin'] ) && strstr( $_GET['plugin'], 'sportspress.php' ) ) )
|
||||
return;
|
||||
|
||||
if ( ! get_option( 'sportspress_completed_setup' ) ) {
|
||||
wp_redirect( admin_url( 'admin.php?page=sp-setup' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
wp_redirect( admin_url( 'index.php?page=sp-about' ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
new SP_Admin_Welcome();
|
||||
|
||||
@@ -52,7 +52,7 @@ class SP_Settings_General extends SP_Settings_Page {
|
||||
array(
|
||||
'title' => __( 'Sport', 'sportspress' ),
|
||||
'id' => 'sportspress_sport',
|
||||
'default' => 'custom',
|
||||
'default' => 'none',
|
||||
'type' => 'sport',
|
||||
'options' => $presets,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user