Adjust for theme support

This commit is contained in:
Brian Miyaji
2014-04-14 23:48:37 +10:00
parent f9f114f2a5
commit 0e380bfa4a
6 changed files with 35 additions and 38 deletions

View File

@@ -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' );
}
/**

View File

@@ -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' ) );
}
/**

View File

@@ -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'] );
}
/**

View File

@@ -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;