From 0e380bfa4a5ef5a5a9848316aaf1e79d6bada586 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Mon, 14 Apr 2014 23:48:37 +1000 Subject: [PATCH] Adjust for theme support --- includes/admin/class-sp-admin-notices.php | 14 ++++------- .../settings/class-sp-settings-general.php | 4 ++- includes/class-sp-frontend-scripts.php | 25 ++++++++++++++++--- includes/sp-template-hooks.php | 20 --------------- readme.txt | 4 +-- sportspress.php | 6 ++--- 6 files changed, 35 insertions(+), 38 deletions(-) diff --git a/includes/admin/class-sp-admin-notices.php b/includes/admin/class-sp-admin-notices.php index 0685b7f2..b3a3efa6 100644 --- a/includes/admin/class-sp-admin-notices.php +++ b/includes/admin/class-sp-admin-notices.php @@ -37,13 +37,14 @@ class SP_Admin_Notices { * Add notices + styles if needed. */ public function add_notices() { - if ( get_option( '_sp_needs_welcome' ) == 1 ) { + $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' ) ); } - $notices = get_option( 'sportspress_admin_notices', array() ); - if ( ! empty( $_GET['hide_theme_support_notice'] ) ) { $notices = array_diff( $notices, array( 'theme_support' ) ); update_option( 'sportspress_admin_notices', $notices ); @@ -73,12 +74,7 @@ class SP_Admin_Notices { * Show the install notices */ public function install_notice() { - $screen = get_current_screen(); - - // If we have just installed, show a message with the install pages button - if ( get_option( '_sp_needs_welcome' ) == 1 && $screen->id != 'toplevel_page_sportspress' ) { - include( 'views/html-notice-install.php' ); - } + include( 'views/html-notice-install.php' ); } /** diff --git a/includes/admin/settings/class-sp-settings-general.php b/includes/admin/settings/class-sp-settings-general.php index c404ceef..8db6438b 100644 --- a/includes/admin/settings/class-sp-settings-general.php +++ b/includes/admin/settings/class-sp-settings-general.php @@ -27,8 +27,10 @@ class SP_Settings_General extends SP_Settings_Page { add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) ); add_action( 'sportspress_admin_field_country', array( $this, 'country_setting' ) ); - add_action( 'sportspress_admin_field_frontend_styles', array( $this, 'frontend_styles_setting' ) ); add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) ); + + if ( ( $styles = SP_Frontend_Scripts::get_styles() ) && array_key_exists( 'sportspress-general', $styles ) ) + add_action( 'sportspress_admin_field_frontend_styles', array( $this, 'frontend_styles_setting' ) ); } /** diff --git a/includes/class-sp-frontend-scripts.php b/includes/class-sp-frontend-scripts.php index e91b8b78..6780a895 100644 --- a/includes/class-sp-frontend-scripts.php +++ b/includes/class-sp-frontend-scripts.php @@ -19,6 +19,21 @@ class SP_Frontend_Scripts { add_action( 'wp_print_scripts', array( $this, 'custom_css' ), 30 );; } + /** + * Get styles for the frontend + * @return array + */ + public static function get_styles() { + return apply_filters( 'sportspress_enqueue_styles', array( + 'sportspress-general' => array( + 'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/sportspress.css', + 'deps' => '', + 'version' => SP_VERSION, + 'media' => 'all' + ), + ) ); + } + /** * Register/queue frontend scripts. * @@ -26,9 +41,6 @@ class SP_Frontend_Scripts { * @return void */ public function load_scripts() { - // Styles - wp_enqueue_style( 'sportspress', plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/css/sportspress.css', array( 'dashicons' ), time() ); - // Scripts wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '3.exp', true ); @@ -38,6 +50,13 @@ class SP_Frontend_Scripts { // Localize scripts. wp_localize_script( 'sportspress', 'localized_strings', array( 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ), 'previous' => __( 'Previous', 'sportspress' ), 'next' => __( 'Next', 'sportspress' ) ) ); + + // CSS Styles + $enqueue_styles = $this->get_styles(); + + if ( $enqueue_styles ) + foreach ( $enqueue_styles as $handle => $args ) + wp_enqueue_style( $handle, $args['src'], $args['deps'], $args['version'], $args['media'] ); } /** diff --git a/includes/sp-template-hooks.php b/includes/sp-template-hooks.php index ae4df3e7..a8b9683d 100644 --- a/includes/sp-template-hooks.php +++ b/includes/sp-template-hooks.php @@ -44,26 +44,6 @@ function sportspress_the_title( $title, $id ) { } add_filter( 'the_title', 'sportspress_the_title', 10, 2 ); -/** - * sportspress_admin_install_notices function. - * - * @access public - * @return void - */ -function sportspress_admin_install_notices() { - include( dirname( SP_PLUGIN_FILE ) . '/includes/admin/views/notice-install.php' ); -} - -/** - * sportspress_theme_check_notice function. - * - * @access public - * @return void - */ -function sportspress_theme_check_notice() { -// include( dirname( SP_PLUGIN_FILE ) . '/includes/admin/views/notice-theme-support.php' ); -} - function sportspress_gettext( $translated_text, $untranslated_text, $domain ) { global $typenow; diff --git a/readme.txt b/readme.txt index 14352bd5..1290a950 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: sports, press, sports journalism, teams, team management, fixtures, result Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=support@themeboy.com&item_name=Donation+for+SportsPress Requires at least: 3.8 Tested up to: 3.8.2 -Stable tag: 0.7.5 +Stable tag: 0.8 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -158,7 +158,7 @@ Yes, CSV importers are included with the plugin. Go to Tools > Import and choose == Changelog == -= 0.7.5 = += 0.8 = * Localization - Portuguese (Brazil) translation by rochester. * Localization - Update Swedish translation by JensZ. diff --git a/sportspress.php b/sportspress.php index 87692dae..99c247f3 100644 --- a/sportspress.php +++ b/sportspress.php @@ -3,7 +3,7 @@ * Plugin Name: SportsPress * Plugin URI: http://wordpress.org/plugins/sportspress * Description: Manage your club and its players, staff, events, league tables, and player lists. - * Version: 0.7.5 + * Version: 0.8 * Author: ThemeBoy * Author URI: http://themeboy.com * Requires at least: 3.8 @@ -26,14 +26,14 @@ if ( ! class_exists( 'SportsPress' ) ) : * Main SportsPress Class * * @class SportsPress - * @version 0.7.5 + * @version 0.8 */ final class SportsPress { /** * @var string */ - public $version = '0.7.5'; + public $version = '0.8'; /** * @var SporsPress The single instance of the class