From 87e0c574f44f5c5e2603a7fef6a6cb90f5066910 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Sun, 30 Mar 2014 12:49:23 +1100 Subject: [PATCH] Admin notice to configure sport --- assets/css/activation.css | 30 ++++ assets/css/admin.css | 31 ---- includes/admin/class-sp-admin-notices.php | 138 ++++++++++++++++++ includes/admin/class-sp-admin.php | 2 +- .../settings/class-sp-settings-config.php | 4 + .../settings/class-sp-settings-general.php | 2 +- includes/admin/views/html-notice-install.php | 4 +- includes/class-sp-install.php | 5 + includes/sp-template-hooks.php | 11 +- templates/player.php | 6 + 10 files changed, 192 insertions(+), 41 deletions(-) create mode 100644 assets/css/activation.css create mode 100644 includes/admin/class-sp-admin-notices.php create mode 100644 templates/player.php diff --git a/assets/css/activation.css b/assets/css/activation.css new file mode 100644 index 00000000..ba609291 --- /dev/null +++ b/assets/css/activation.css @@ -0,0 +1,30 @@ +/* Messages */ +.sportspress-message { + border-left-color: #6bc2a5 !important; +} + +.sportspress-message a.button-primary, +.sportspress-message a.button-secondary { + background: #6bc2a5; + border-color: #409e7f; + -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15); + box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15); + color: #fff; + text-decoration: none; +} + +.sportspress-message a.button-primary:hover, +.sportspress-message a.button-secondary:hover { + background: #3bad87; + border-color: #338a6d; + -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15); + box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15); + color: #fff; + text-decoration: none; +} + +.sportspress-message a.button-secondary { + -moz-opacity: 0.7; + opacity: 0.7; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; +} \ No newline at end of file diff --git a/assets/css/admin.css b/assets/css/admin.css index 997a234c..fe277d49 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -122,37 +122,6 @@ margin: 15px 0 0 -7px; } -/* Messages */ -.sportspress-message { - border-left-color: #6bc2a5 !important; -} - -.sportspress-message a.button-primary, -.sportspress-message a.button-secondary { - background: #6bc2a5; - border-color: #409e7f; - -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15); - box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15); - color: #fff; - text-decoration: none; -} - -.sportspress-message a.button-primary:hover, -.sportspress-message a.button-secondary:hover { - background: #3bad87; - border-color: #338a6d; - -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15); - box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15); - color: #fff; - text-decoration: none; -} - -.sportspress-message a.button-secondary { - -moz-opacity: 0.7; - opacity: 0.7; - -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; -} - .wp-media-buttons .button.sp-insert { padding-left: 5px; } diff --git a/includes/admin/class-sp-admin-notices.php b/includes/admin/class-sp-admin-notices.php new file mode 100644 index 00000000..06617321 --- /dev/null +++ b/includes/admin/class-sp-admin-notices.php @@ -0,0 +1,138 @@ +id != 'settings_page_sportspress' ) { + include( 'views/html-notice-install.php' ); + } + } + + /** + * Show the Theme Check notice + */ + public function theme_check_notice() { +// include( 'views/html-notice-theme-support.php' ); + } + + /** + * Show a notice highlighting bad template files + */ + public function template_file_check_notice() { + if ( isset( $_GET['page'] ) && 'sp-status' == $_GET['page'] ) { + return; + } + + $status = include( 'class-sp-admin-status.php' ); + $core_templates = $status->scan_template_files( SP()->plugin_path() . '/templates' ); + $outdated = false; + + foreach ( $core_templates as $file ) { + $theme_file = false; + if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { + $theme_file = get_stylesheet_directory() . '/' . $file; + } elseif ( file_exists( get_stylesheet_directory() . '/sportspress/' . $file ) ) { + $theme_file = get_stylesheet_directory() . '/sportspress/' . $file; + } elseif ( file_exists( get_template_directory() . '/' . $file ) ) { + $theme_file = get_template_directory() . '/' . $file; + } elseif( file_exists( get_template_directory() . '/sportspress/' . $file ) ) { + $theme_file = get_template_directory() . '/sportspress/' . $file; + } + + if ( $theme_file ) { + $core_version = $status->get_file_version( SP()->plugin_path() . '/templates/' . $file ); + $theme_version = $status->get_file_version( $theme_file ); + + if ( $core_version && $theme_version && version_compare( $theme_version, $core_version, '<' ) ) { + $outdated = true; + break; + } + } + } + + if ( $outdated ) { + include( 'views/html-notice-template-check.php' ); + } + } +} + +endif; + +return new SP_Admin_Notices(); \ No newline at end of file diff --git a/includes/admin/class-sp-admin.php b/includes/admin/class-sp-admin.php index f735a88e..0465db9e 100644 --- a/includes/admin/class-sp-admin.php +++ b/includes/admin/class-sp-admin.php @@ -39,7 +39,7 @@ class SP_Admin { if ( ! is_ajax() ) { include( 'class-sp-admin-menus.php' ); // include( 'class-sp-admin-welcome.php' ); -// include( 'class-sp-admin-notices.php' ); + include( 'class-sp-admin-notices.php' ); include( 'class-sp-admin-assets.php' ); include( 'class-sp-admin-permalink-settings.php' ); // include( 'class-sp-admin-editor.php' ); diff --git a/includes/admin/settings/class-sp-settings-config.php b/includes/admin/settings/class-sp-settings-config.php index 6260835b..69d004a9 100644 --- a/includes/admin/settings/class-sp-settings-config.php +++ b/includes/admin/settings/class-sp-settings-config.php @@ -46,6 +46,9 @@ class SP_Settings_Config extends SP_Settings_Page { $sport_options[ $slug ] = $data['name']; endforeach; + if ( ! get_option( 'sportspress_sport' ) ) + $sport_options = array_merge( array( 0 => __( '— Select —', 'sportspress' ) ), $sport_options ); + return apply_filters('sportspress_event_settings', array( array( 'title' => __( 'Configure SportsPress', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'config_options' ), @@ -163,6 +166,7 @@ class SP_Settings_Config extends SP_Settings_Page { endforeach; endforeach; update_option( 'sportspress_primary_result', 0 ); + update_option( '_sp_needs_config', 0 ); elseif ( isset( $_POST['sportspress_primary_result'] ) ): update_option( 'sportspress_primary_result', $_POST['sportspress_primary_result'] ); endif; diff --git a/includes/admin/settings/class-sp-settings-general.php b/includes/admin/settings/class-sp-settings-general.php index 97e4a4c2..d7edf834 100644 --- a/includes/admin/settings/class-sp-settings-general.php +++ b/includes/admin/settings/class-sp-settings-general.php @@ -51,7 +51,7 @@ class SP_Settings_General extends SP_Settings_Page { array( 'type' => 'frontend_styles' ), array( - 'title' => __( 'Custom CSS', 'woocommerce' ), + 'title' => __( 'Custom CSS', 'sportspress' ), 'id' => 'sportspress_custom_css', 'css' => 'width:100%; height: 130px;', 'type' => 'textarea', diff --git a/includes/admin/views/html-notice-install.php b/includes/admin/views/html-notice-install.php index 1dfb64ef..2f5348c6 100644 --- a/includes/admin/views/html-notice-install.php +++ b/includes/admin/views/html-notice-install.php @@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

Welcome to SportsPress – Get Started', 'sportspress' ); ?>

- - + +

\ No newline at end of file diff --git a/includes/class-sp-install.php b/includes/class-sp-install.php index 0ffeacb2..a590bf23 100644 --- a/includes/class-sp-install.php +++ b/includes/class-sp-install.php @@ -99,6 +99,11 @@ class SP_Install { // Update version update_option( 'sportspress_version', SP()->version ); + // Check if pages are needed + if ( ! get_option( 'sportspress_sport' ) ) { + update_option( '_sp_needs_config', 1 ); + } + // Flush rules after install flush_rewrite_rules(); diff --git a/includes/sp-template-hooks.php b/includes/sp-template-hooks.php index 9235b2d9..01058baf 100644 --- a/includes/sp-template-hooks.php +++ b/includes/sp-template-hooks.php @@ -48,8 +48,8 @@ function sportspress_admin_notices_styles() { $screen = get_current_screen(); if ( $screen->id != 'settings_page_sportspress' ): - if ( isset( $_REQUEST['sportspress_installed'] ) ): - update_option( 'sportspress_installed', $_REQUEST['sportspress_installed'] ); + if ( isset( $_REQUEST['skip_install_sportspress'] ) ): + update_option( '_sp_needs_config', $_REQUEST['_sp_needs_config'] ); endif; if ( ! get_option( 'sportspress_installed' ) ): @@ -70,7 +70,7 @@ function sportspress_admin_notices_styles() { endif; endif; } -add_action( 'admin_print_styles', 'sportspress_admin_notices_styles' ); +//add_action( 'admin_print_styles', 'sportspress_admin_notices_styles' ); /** * sportspress_admin_install_notices function. @@ -79,7 +79,7 @@ add_action( 'admin_print_styles', 'sportspress_admin_notices_styles' ); * @return void */ function sportspress_admin_install_notices() { -// include( dirname( SP_PLUGIN_FILE ) . '/includes/admin/views/notice-install.php' ); + include( dirname( SP_PLUGIN_FILE ) . '/includes/admin/views/notice-install.php' ); } /** @@ -290,8 +290,7 @@ add_filter( 'the_content', 'sportspress_default_table_content' ); function sportspress_default_player_content( $content ) { if ( is_singular( 'sp_player' ) && in_the_loop() ): - sp_get_template( 'player-metrics.php' ); - sp_get_template( 'player-performance.php' ); + sp_get_template( 'player.php' ); endif; return $content; } diff --git a/templates/player.php b/templates/player.php new file mode 100644 index 00000000..4039a139 --- /dev/null +++ b/templates/player.php @@ -0,0 +1,6 @@ + $id ) ); +sp_get_template( 'player-performance.php', array( 'id' => $id ) );