diff --git a/assets/css/setup.css b/assets/css/setup.css new file mode 100644 index 00000000..cd8b754f --- /dev/null +++ b/assets/css/setup.css @@ -0,0 +1,414 @@ +.sp-setup-content p, +.sp-setup-content table { + font-size: 1em; + line-height: 1.75em; + color: #666; +} + +body { + margin: 100px auto 24px; + box-shadow: none; + background: #f1f1f1; + padding: 0; +} + +#sp-logo { + border: 0; + margin: 0 0 24px; + padding: 0; + text-align: center; +} + +#sp-logo img { + width: auto; + height: auto; + max-width: 100%; + max-height: 50px; +} + +.sp-setup-content { + box-shadow: 0 1px 3px rgba(0, 0, 0, .13); + padding: 24px 24px 0; + background: #fff; + zoom: 1; +} + +.sp-setup-content:after { + content: ""; + display: table; + clear: both; +} + +.sp-setup-content h1, +.sp-setup-content h2, +.sp-setup-content h3, +.sp-setup-content table { + margin: 0 0 24px; + border: 0; + padding: 0; + color: #666; + clear: none; +} + +.sp-setup-content p { + margin: 0 0 24px; +} + +.sp-setup-content a { + color: #00a69c; +} + +.sp-setup-content a:focus, +.sp-setup-content a:hover { + color: #111; +} + +.sp-setup-content .form-table { + width: 100%; + border-top: 1px solid #eee; +} + +.sp-setup-content .form-table th { + width: 30%; + vertical-align: top; + font-weight: 700; +} + +.sp-setup-content .form-table td { + vertical-align: top; +} + +.sp-setup-content .form-table td input, +.sp-setup-content .form-table td select { + width: 100%; + box-sizing: border-box; +} + +.sp-setup-content .form-table td input[size] { + width: auto; +} + +.sp-setup-content .form-table td ol, +.sp-setup-content .form-table td ul { + margin: 0; + padding: 0; +} + +.sp-setup-content .form-table td ul { + list-style: none; +} + +.sp-setup-content .form-table td li { + margin-bottom: 10px; +} + +.sp-setup-content .form-table td li:last-child { + margin-bottom: 0; +} + +.sp-setup-content .form-table td .description { + line-height: 1.5em; + display: block; + margin: .25em 0 0; + color: #999; + font-style: italic; +} + +.sp-setup-content .form-table td .input-checkbox, +.sp-setup-content .form-table td .input-radio { + width: auto; + box-sizing: inherit; + padding: inherit; + margin: 0 .5em 0 0; + box-shadow: none; +} + +.sp-setup-content .form-table .section_title td { + padding: 0; +} + +.sp-setup-content .form-table .section_title td h2, +.sp-setup-content .form-table .section_title td p { + margin: 12px 0 0; +} + +.sp-setup-content .form-table td, +.sp-setup-content .form-table th { + padding: 14px 0; + margin: 0; + border: 0; + border-bottom: 1px solid #eee; +} + +.sp-setup-content .form-table td:first-child, +.sp-setup-content .form-table th:first-child { + padding-right: 9px; +} + +.sp-setup-content .form-table th .sp-desc-tip { + line-height: 1.4; +} + +.sp-setup-content .form-table .sp-chosen-container { + display: block; +} + +.sp-setup-content .form-table .sp-location-picker { + width: 100%; + height: 320px; + margin: 0.5em 0 0; +} + +.sp-setup-content .twitter-share-button { + float: right; +} + +.sp-setup-content .sp-banner { + margin: 0 -24px 24px; +} + +.sp-setup-content .sp-banner img { + display: block; + width: auto; + height: auto; + max-width: 100%; +} + +.sp-setup-content .sp-setup-next-steps { + overflow: hidden; + margin: 0 0 24px; +} + +.sp-setup-content .sp-setup-next-steps h2 { + margin-bottom: 12px; +} + +.sp-setup-content .sp-setup-next-steps .sp-setup-next-steps-first { + float: left; + width: 50%; + box-sizing: border-box; +} + +.sp-setup-content .sp-setup-next-steps .sp-setup-next-steps-last { + float: right; + width: 50%; + box-sizing: border-box; +} + +.sp-setup-content .sp-setup-next-steps ul { + padding: 0 2em 0 0; + list-style: none; + margin: 0; +} + +.sp-setup-content .sp-setup-next-steps ul li .button { + display: block; + padding: 0 0 .75em; +} + +.sp-setup-content .sp-setup-next-steps ul .setup-product a { + background-color: #3bbab3; + border-color: #15a29a; + -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a; + box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a; + text-shadow: 0 -1px 1px #15a29a, 1px 0 1px #15a29a, 0 1px 1px #15a29a, -1px 0 1px #15a29a; + font-size: 1em; + height: auto; + line-height: 1.75em; + margin: 0 0 .75em; + opacity: 1; + padding: 1em; + text-align: center; +} + +.sp-setup-content .sp-setup-next-steps ul .setup-product a:active, +.sp-setup-content .sp-setup-next-steps ul .setup-product a:focus, +.sp-setup-content .sp-setup-next-steps ul .setup-product a:hover { + background: #15a29a; + border-color: #15a29a; + -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a; + box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a; +} + +.sp-setup-content .sp-setup-next-steps ul li a:before { + color: #82878c; + font: 400 20px/1 dashicons; + speak: none; + display: inline-block; + padding: 0 10px 0 0; + top: 1px; + position: relative; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none!important; + vertical-align: top; +} + +.sp-setup-content .sp-setup-next-steps ul .learn-more a:before { + content: "\f105"; +} + +.sp-setup-content .sp-setup-next-steps ul .video-walkthrough a:before { + content: "\f126"; +} + +.sp-setup-content .sp-setup-next-steps ul .newsletter a:before { + content: "\f465"; +} + +.sp-setup-content .updated { + padding: 24px 24px 0; + margin: 0 0 24px; + overflow: hidden; + background: #f5f5f5; +} + +.sp-setup-content .updated p { + padding: 0; + margin: 0 0 12px; +} + +.sp-setup-content .updated p:last-child { + margin: 0 0 24px; +} + +.sp-setup-steps { + padding: 0 0 24px; + margin: 0; + list-style: none; + overflow: hidden; + color: #ccc; + width: 100%; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; +} + +.sp-setup-steps li { + width: 20%; + float: left; + padding: 0 0 .8em; + margin: 0; + text-align: center; + position: relative; + border-bottom: 4px solid #ccc; + line-height: 1.4em; +} + +.sp-setup-steps li:before { + content: ""; + border: 4px solid #ccc; + border-radius: 100%; + width: 4px; + height: 4px; + position: absolute; + bottom: 0; + left: 50%; + margin-left: -6px; + margin-bottom: -8px; + background: #fff; +} + +.sp-setup-steps li.active { + border-color: #00a69c; + color: #00a69c; +} + +.sp-setup-steps li.active:before { + border-color: #00a69c; +} + +.sp-setup-steps li.done { + border-color: #00a69c; + color: #00a69c; +} + +.sp-setup-steps li.done:before { + border-color: #00a69c; + background: #00a69c; +} + +.sp-setup .sp-setup-actions:after { + content: ""; + display: table; + clear: both; +} + +.sp-setup .sp-setup-actions .button { + float: right; + font-size: 1.25em; + padding: .5em 1em; + line-height: 1em; + margin-right: .5em; + margin-bottom: 2px; + height: auto; + border-radius: 4px; +} + +.sp-setup .sp-setup-actions .button-primary { + background-color: #3bbab3; + border-color: #15a29a; + -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a; + box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a; + text-shadow: 0 -1px 1px #15a29a, 1px 0 1px #15a29a, 0 1px 1px #15a29a, -1px 0 1px #15a29a; + float: right; + margin: 0 0 0 1em; + opacity: 1; +} + +.sp-setup .sp-setup-actions .button-primary:active, +.sp-setup .sp-setup-actions .button-primary:focus, +.sp-setup .sp-setup-actions .button-primary:hover { + background: #15a29a; + border-color: #15a29a; + -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a; + box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a; +} + +.sp-setup .sp-setup-actions .button-muted { + border: none; + background: transparent; + -webkit-box-shadow: none; + box-shadow: none; + padding: 0; + margin: .55em 0.05em 0.65em; + color: #ccc; +} + +.sp-setup .sp-setup-actions .button-muted:hover { + color: #999; +} + +.sp-return-to-dashboard { + font-size: .85em; + color: #b5b5b5; + margin: 1.18em 0; + display: block; + text-align: center; +} + +/* Media Queries */ + +@media screen and (max-width: 782px) { + .sp-setup-content .form-table tbody th { + width: auto + }; +} + +@media screen and (min-width: 783px) { + .sp-setup-content .form-table td li input { + width: 40%; + } + + .sp-setup-content .form-table td .player input { + width: 40%; + } + + .sp-setup-content .form-table td .player .player-number { + width: 11%; + } + + .sp-setup-content .form-table td .staff .staff-name { + width: 52%; + } +} \ No newline at end of file diff --git a/assets/js/admin/sportspress-setup.js b/assets/js/admin/sportspress-setup.js new file mode 100644 index 00000000..74573e3d --- /dev/null +++ b/assets/js/admin/sportspress-setup.js @@ -0,0 +1,24 @@ +jQuery(document).ready(function($){ + + // Tiptip + $(".sp-tip").tipTip({ + delay: 200, + fadeIn: 100, + fadeOut: 100 + }); + $(".sp-desc-tip").tipTip({ + delay: 200, + fadeIn: 100, + fadeOut: 100, + defaultPosition: 'right' + }); + + // Chosen select + $(".chosen-select, #poststuff #post_author_override").chosen({ + allow_single_deselect: true, + search_contains: true, + single_backstroke_delete: false, + disable_search_threshold: 10, + placeholder_text_multiple: localized_strings.none + }); +}); \ No newline at end of file diff --git a/includes/admin/class-sp-admin-notices.php b/includes/admin/class-sp-admin-notices.php index 4975077b..020a0ac3 100644 --- a/includes/admin/class-sp-admin-notices.php +++ b/includes/admin/class-sp-admin-notices.php @@ -40,9 +40,9 @@ class SP_Admin_Notices { $screen = get_current_screen(); $notices = get_option( 'sportspress_admin_notices', array() ); - if ( get_option( '_sp_needs_welcome' ) == 1 && $screen->id != 'toplevel_page_sportspress' ) { - wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) ); - add_action( 'admin_notices', array( $this, 'install_notice' ) ); + if ( ! get_option( 'sportspress_completed_setup' ) ) { + 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 ) { @@ -62,7 +62,7 @@ class SP_Admin_Notices { update_option( 'sportspress_admin_notices', $notices ); } - 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' ) ) ) { + 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' ) ) ) { $template = get_option( 'template' ); if ( ! in_array( $template, array( 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ) { @@ -78,9 +78,9 @@ class SP_Admin_Notices { } /** - * Show the install notices + * Show the setup notices */ - public function install_notice() { + public function setup_notice() { include( 'views/html-notice-install.php' ); } diff --git a/includes/admin/class-sp-admin-setup-wizard.php b/includes/admin/class-sp-admin-setup-wizard.php new file mode 100644 index 00000000..ec19ee9f --- /dev/null +++ b/includes/admin/class-sp-admin-setup-wizard.php @@ -0,0 +1,694 @@ +steps = array( + 'introduction' => array( + 'name' => __( 'Introduction', 'sportspress' ), + 'view' => array( $this, 'sp_setup_introduction' ), + 'handler' => '' + ), + 'basics' => array( + 'name' => __( 'Basic Setup', 'sportspress' ), + 'view' => array( $this, 'sp_setup_basics' ), + 'handler' => array( $this, 'sp_setup_basics_save' ) + ), + 'teams' => array( + 'name' => __( 'Teams', 'sportspress' ), + 'view' => array( $this, 'sp_setup_teams' ), + 'handler' => array( $this, 'sp_setup_teams_save' ) + ), + 'players_staff' => array( + 'name' => __( 'Players', 'sportspress' ) . ' & ' . __( 'Staff', 'sportspress' ), + 'view' => array( $this, 'sp_setup_players_staff' ), + 'handler' => array( $this, 'sp_setup_players_staff_save' ), + ), + 'venue' => array( + 'name' => __( 'Venue', 'sportspress' ), + 'view' => array( $this, 'sp_venue' ), + 'handler' => array( $this, 'sp_venue_save' ), + ), + 'next_steps' => array( + 'name' => __( 'Ready!', 'sportspress' ), + 'view' => array( $this, 'sp_setup_ready' ), + 'handler' => '' + ) + ); + $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) ); + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; + + wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . '/assets/css/chosen.css', array(), '1.1.0' ); + wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION ); + wp_enqueue_style( 'sportspress-setup', SP()->plugin_url() . '/assets/css/setup.css', array( 'dashicons', 'install' ), SP_VERSION ); + + wp_register_script( 'chosen', SP()->plugin_url() . '/assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true ); + wp_register_script( 'jquery-tiptip', SP()->plugin_url() . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true ); + wp_register_script( 'google-maps', '//maps.googleapis.com/maps/api/js?key=AIzaSyAWyt_AG0k_Pgz4LuegtHwesA_OMRnSSAE&libraries=places' ); + wp_register_script( 'sportspress-setup', SP()->plugin_url() . '/assets/js/admin/sportspress-setup.js', array( 'jquery', 'chosen', 'jquery-tiptip' ), SP_VERSION, true ); + + wp_register_script( 'jquery-locationpicker', SP()->plugin_url() . '/assets/js/locationpicker.jquery.js', array( 'jquery', 'google-maps' ), '0.1.6', true ); + wp_register_script( 'sportspress-admin-locationpicker', SP()->plugin_url() . '/assets/js/admin/locationpicker.js', array( 'jquery', 'jquery-locationpicker' ), SP_VERSION, true ); + + $strings = apply_filters( 'sportspress_localized_strings', array( + 'none' => __( 'None', 'sportspress' ), + 'remove_text' => __( '— Remove —', 'sportspress' ), + ) ); + + // Localize scripts + wp_localize_script( 'sportspress-setup', 'localized_strings', $strings ); + + wp_enqueue_script( 'google-maps' ); + + if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) { + call_user_func( $this->steps[ $this->step ]['handler'] ); + } + + ob_start(); + $this->setup_wizard_header(); + $this->setup_wizard_steps(); + $this->setup_wizard_content(); + $this->setup_wizard_footer(); + exit; + } + + public function get_next_step_link() { + $keys = array_keys( $this->steps ); + return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ) ) + 1 ] ); + } + + /** + * Setup Wizard Header. + */ + public function setup_wizard_header() { + ?> + + > +
+ + +->plugin_url(); ?>/assets/images/modules/sportspress<?php if ( class_exists( 'SportsPress_Pro' ) ) echo '-pro'; ?>.png)
It’s completely optional and shouldn’t take longer than five minutes.', 'sportspress' ); ?>
+ + + + + + get_next_step_link() ) ); + exit; + } + + /** + * Team Setup. + */ + public function sp_setup_teams() { + $class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' ); + ?> + + + 0, 'fields' => 'ids' ) ); + }; + wp_insert_post( $post ); + + // Add home team + $post['post_title'] = $_POST['home_team']; + wp_insert_post( $post ); + + wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); + exit; + } + + /** + * Players & Staff Setup. + */ + public function sp_setup_players_staff() { + $positions = get_terms( 'sp_position', array( 'hide_empty' => 0, 'orderby' => 'slug', 'fields' => 'names' ) ) + ?> + + + 1, 'post_type' => 'sp_team', 'fields' => 'ids' ) ); + $team = reset( $teams ); + + // Add players + $post['post_type'] = 'sp_player'; + $post['post_status'] = 'publish'; + $post['tax_input'] = array(); + $taxonomies = array( 'sp_league', 'sp_season' ); + foreach ( $taxonomies as $taxonomy ) { + $post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids' ) ); + }; + if ( is_array( $_POST['players'] ) ) { + foreach ( $_POST['players'] as $i => $player ) { + if ( empty( $player['name'] ) ) continue; + + $post['post_title'] = $player['name']; + $id = wp_insert_post( $post ); + + // Add squad number + $number = sp_array_value( $player, 'number' ); + update_post_meta( $id, 'sp_number', $number ); + + // Add position + wp_set_object_terms( $id, sp_array_value( $player, 'position', __( 'Position', 'sportspress' ) ), 'sp_position', false ); + + // Add team + if ( $team ) { + update_post_meta( $id, 'sp_team', $team ); + update_post_meta( $id, 'sp_current_team', $team ); + } + } + } + + // Add staff + if ( ! empty( $_POST['staff'] ) ) { + + $post['post_type'] = 'sp_staff'; + $post['post_title'] = $_POST['staff']; + $id = wp_insert_post( $post ); + + // Add role + wp_set_object_terms( $id, sp_array_value( $_POST, 'role', 'Coach' ), 'sp_role', false ); + + // Add team + if ( $team ) { + update_post_meta( $id, 'sp_team', $team ); + update_post_meta( $id, 'sp_current_team', $team ); + } + } + + wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); + exit; + } + + /** + * Venue Step. + */ + public function sp_venue() { + ?> + + + + 1, 'post_type' => 'sp_team', 'fields' => 'ids' ) ); + $team = reset( $teams ); + + // Insert venue + $venue = sanitize_text_field( $_POST['venue'] ); + if ( ! is_string( $venue ) || empty( $venue ) ) { + $venue = sp_array_value( $_POST, 'address', __( 'Venue', 'sportspress' ) ); + } + $inserted = wp_insert_term( $venue, 'sp_venue' ); + + // Add address and coordinates to venue + if ( ! is_wp_error( $inserted ) ) { + $t_id = sp_array_value( $inserted, 'term_id', 1 ); + + wp_set_object_terms( $team, $t_id, 'sp_venue', true ); + + $meta = array( + 'sp_address' => sp_array_value( $_POST, 'address' ), + 'sp_latitude' => sp_array_value( $_POST, 'latitude' ), + 'sp_longitude' => sp_array_value( $_POST, 'longitude' ), + ); + update_option( "taxonomy_$t_id", $meta ); + } + + wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); + exit; + } + + /** + * Actions on the final step. + */ + private function sp_setup_ready_actions() { + delete_option( '_sp_needs_welcome' ); + update_option( 'sportspress_installed', 1 ); + update_option( 'sportspress_completed_setup', 1 ); + delete_transient( '_sp_activation_redirect' ); + + // Check if first event already exists + $events = get_posts( + array( + 'post_type' => 'sp_event', + 'posts_per_page' => 11, + 'post_status' => 'draft', + 'meta_query' => array( + array( + 'key' => '_sp_first', + 'value' => 1 + ) + ) + ) + ); + + if ( $events ) { + $event = reset( $events ); + return $event->ID; + } + + // Get teams + $teams = get_posts( array( 'posts_per_page' => 2, 'post_type' => 'sp_team' ) ); + + // Get players + $players = (array) get_posts( array( 'posts_per_page' => 3, 'post_type' => 'sp_player', 'fields' => 'ids' ) ); + + // Get staff + $staff = (array) get_posts( array( 'posts_per_page' => 1, 'post_type' => 'sp_staff', 'fields' => 'ids' ) ); + + // Initialize post + $post['post_type'] = 'sp_event'; + $post['post_status'] = 'draft'; + $post['tax_input'] = array(); + + // Add taxonomies + $taxonomies = array( 'sp_league', 'sp_season', 'sp_venue' ); + foreach ( $taxonomies as $taxonomy ) { + $post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids', 'number' => 1 ) ); + }; + + // Add post title + if ( is_array( $teams ) && sizeof( $teams ) ) { + $team_names = array(); + foreach ( $teams as $team ) { + if ( ! $team ) continue; + $team_names[] = $team->post_title; + } + $post['post_title'] = implode( ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ', $team_names ); + } else { + $post['post_title'] = __( 'Event', 'sportspress' ); + } + + // Insert event + $id = wp_insert_post( $post ); + + // Add teams + if ( is_array( $teams ) && sizeof( $teams ) ) { + foreach ( $teams as $team ) { + if ( ! $team ) continue; + add_post_meta( $id, 'sp_team', $team->ID ); + } + } + + // Add players + add_post_meta( $id, 'sp_player', 0 ); + foreach ( $players as $player ) { + if ( ! $player ) continue; + add_post_meta( $id, 'sp_player', $player ); + } + add_post_meta( $id, 'sp_player', 0 ); + + update_post_meta( $id, '_sp_first', 1 ); + + return $id; + } + + /** + * Final step. + */ + public function sp_setup_ready() { + $id = $this->sp_setup_ready_actions(); + shuffle( $this->tweets ); + ?> + Tweet + + + + + + + + 'sportspress_sport', - 'default' => get_option( 'sportspress_sport', 'custom' ), + 'default' => get_option( 'sportspress_sport', 'soccer' ), 'type' => 'sport', 'title' => __( 'Sport', 'sportspress' ), 'welcome' => true, @@ -723,7 +723,7 @@ class SP_Admin_Welcome { if ( ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] ) && ( isset( $_GET['plugin'] ) && strstr( $_GET['plugin'], 'sportspress.php' ) ) ) return; - wp_redirect( admin_url( 'index.php?page=sp-about' ) ); + wp_redirect( admin_url( 'admin.php?page=sp-setup' ) ); exit; } } diff --git a/includes/admin/class-sp-admin.php b/includes/admin/class-sp-admin.php index 864d3d6e..858a63b4 100644 --- a/includes/admin/class-sp-admin.php +++ b/includes/admin/class-sp-admin.php @@ -55,6 +55,15 @@ class SP_Admin { include( 'class-sp-admin-editor.php' ); endif; } + + // Setup/welcome + if ( ! empty( $_GET['page'] ) ) { + switch ( $_GET['page'] ) { + case 'sp-setup' : + include_once( 'class-sp-admin-setup-wizard.php' ); + break; + } + } } /** diff --git a/includes/admin/settings/class-sp-settings-modules.php b/includes/admin/settings/class-sp-settings-modules.php index 21bb65ed..d7265c0f 100644 --- a/includes/admin/settings/class-sp-settings-modules.php +++ b/includes/admin/settings/class-sp-settings-modules.php @@ -122,7 +122,7 @@ class SP_Settings_Modules extends SP_Settings_Page {
+
diff --git a/includes/admin/views/html-notice-install.php b/includes/admin/views/html-notice-install.php index dde91010..ae250260 100644 --- a/includes/admin/views/html-notice-install.php +++ b/includes/admin/views/html-notice-install.php @@ -2,9 +2,9 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
\ No newline at end of file diff --git a/includes/class-sp-install.php b/includes/class-sp-install.php index e8c131ec..f90628d3 100644 --- a/includes/class-sp-install.php +++ b/includes/class-sp-install.php @@ -46,33 +46,16 @@ class SP_Install { } /** - * Install actions such as installing pages when a button is clicked. + * Basic setup when a button is clicked. */ public function install_actions() { - // Install - Add pages button - if ( ! empty( $_GET['install_sportspress'] ) ) { - - // We no longer need to install pages - delete_option( '_sp_needs_welcome' ); - update_option( 'sportspress_installed', 1 ); - delete_transient( '_sp_activation_redirect' ); - - // What's new redirect - //wp_redirect( admin_url( 'index.php?page=sp-about&sp-installed=true' ) ); - //exit; - - // Skip button - } elseif ( ! empty( $_GET['skip_install_sportspress'] ) ) { + if ( ! empty( $_GET['skip_install_sportspress'] ) ) { // We no longer need to install configs delete_option( '_sp_needs_welcome' ); update_option( 'sportspress_installed', 1 ); + update_option( 'sportspress_completed_setup', 1 ); delete_transient( '_sp_activation_redirect' ); - - // What's new redirect - wp_redirect( admin_url( 'index.php?page=sp-about' ) ); - exit; - } } @@ -401,7 +384,7 @@ class SP_Install { * @return void */ public function upgrades( $version = null ) { - if ( null === $version ) return; + if ( empty( $version ) ) return; if ( version_compare( $version, '2.0', '<' ) ) { update_option( 'sportspress_player_columns', 'manual' ); @@ -436,6 +419,10 @@ class SP_Install { $option = get_option( 'sportspress_player_show_total', 'no' ); update_option( 'sportspress_player_show_career_total', $option ); } + + if ( version_compare( $version, '2.2.11', '<' ) ) { + update_option( 'sportspress_completed_setup', 1 ); + } } /** diff --git a/uninstall.php b/uninstall.php index 9bd0cbb0..d7875026 100644 --- a/uninstall.php +++ b/uninstall.php @@ -23,4 +23,5 @@ $installer->remove_roles(); // Delete options $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'sportspress_%';"); -delete_option( 'sportspress_installed' ); \ No newline at end of file +delete_option( 'sportspress_installed' ); +delete_option( 'sportspress_completed_setup' );