Enqueue admin scripts and styles in class
This commit is contained in:
@@ -53,16 +53,6 @@
|
||||
content: "\f328";
|
||||
}
|
||||
|
||||
#adminmenu #toplevel_page_sportspress .menu-icon-generic div.wp-menu-image:before,
|
||||
#adminmenu #menu-posts-sp_event .menu-icon-sp_event div.wp-menu-image:before,
|
||||
#adminmenu #menu-posts-sp_team .menu-icon-sp_team div.wp-menu-image:before,
|
||||
#adminmenu #menu-posts-sp_player .menu-icon-sp_player div.wp-menu-image:before,
|
||||
#sp_formatdiv #post-formats-select .post-format-icon:before {
|
||||
font-family: sportspress, dashicons !important;
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.post-state-format.post-format-calendar:before, .post-format-icon.post-format-calendar:before, a.post-state-format.format-calendar:before {
|
||||
content: "\f145";
|
||||
}
|
||||
@@ -128,108 +118,6 @@
|
||||
color: #888;
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .inside {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .sp_status_list {
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .sp_status_list li {
|
||||
width: 50%;
|
||||
float: left;
|
||||
padding: 0;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
border-top: 1px solid #ececec;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .sp_status_list li:first-child {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .sp_status_list li.countdown {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .sp_status_list li.events-scheduled {
|
||||
border-right: 1px solid #ececec;
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .sp_status_list li a {
|
||||
display: block;
|
||||
color: #aaa;
|
||||
padding: 9px 12px;
|
||||
-webkit-transition: all ease .5s;
|
||||
position: relative;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .sp_status_list li a:before {
|
||||
font-family: sportspress, dashicons;
|
||||
speak: none;
|
||||
font-weight: 400;
|
||||
font-variant: normal;
|
||||
text-transform: none;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
margin: 0;
|
||||
text-indent: 0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
content: "\f145";
|
||||
font-size: 2em;
|
||||
position: relative;
|
||||
width: auto;
|
||||
line-height: 1.2em;
|
||||
color: #464646;
|
||||
float: left;
|
||||
margin-right: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .sp_status_list li.countdown a:before {
|
||||
content: "\f469";
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .sp_status_list li.events-scheduled a:before,
|
||||
#sportspress_dashboard_status .sp_status_list li.events-published a:before {
|
||||
color: #999;
|
||||
font-size: 2.5em;
|
||||
line-height: 1em;
|
||||
margin-left: -3px;
|
||||
margin-right: 9px;
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .sp_status_list li.events-scheduled a:before {
|
||||
color: #ffba00;
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .sp_status_list li.events-published a:before {
|
||||
color: #21759b;
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .sp_status_list li strong {
|
||||
font-size: 18px;
|
||||
line-height: 1.2em;
|
||||
font-weight: 400;
|
||||
display: block;
|
||||
color: #21759b;
|
||||
}
|
||||
|
||||
#sportspress_dashboard_status .sp_status_list li a:hover,
|
||||
#sportspress_dashboard_status .sp_status_list li a:hover strong,
|
||||
#sportspress_dashboard_status .sp_status_list li a:hover:before {
|
||||
color: #2ea2cc;
|
||||
}
|
||||
|
||||
.sportspress-message {
|
||||
border-left-color: #6bc2a5 !important;
|
||||
}
|
||||
|
||||
115
includes/admin/class-sp-admin-assets.php
Normal file
115
includes/admin/class-sp-admin-assets.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Load assets.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 0.7
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_Assets' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_Assets Class
|
||||
*/
|
||||
class SP_Admin_Assets {
|
||||
|
||||
/**
|
||||
* Hook in tabs.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue styles
|
||||
*/
|
||||
public function admin_styles() {
|
||||
global $wp_scripts;
|
||||
|
||||
// Sitewide menu CSS
|
||||
wp_enqueue_style( 'sportspress-admin-menu-styles', SP()->plugin_url() . '/assets/css/menu.css', array(), SP_VERSION );
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
|
||||
|
||||
// Admin styles for SP pages only
|
||||
wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . 'assets/css/admin.css', array(), SP_VERSION );
|
||||
wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . 'assets/css/chosen.css', array(), '1.1.0' );
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
}
|
||||
|
||||
if ( in_array( $screen->id, array( 'dashboard' ) ) ) {
|
||||
wp_enqueue_style( 'sportspress-admin-dashboard-styles', SP()->plugin_url() . '/assets/css/dashboard.css', array(), SP_VERSION );
|
||||
}
|
||||
|
||||
do_action( 'sportspress_admin_css' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue scripts
|
||||
*/
|
||||
public function admin_scripts() {
|
||||
global $wp_query, $post;
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
// Register scripts
|
||||
wp_register_script( 'jquery-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( 'jquery-caret', SP()->plugin_url() .'assets/js/jquery.caret.min.js', array( 'jquery' ), '1.02', true );
|
||||
|
||||
wp_register_script( 'jquery-countdown', SP()->plugin_url() .'assets/js/jquery.countdown.min.js', array( 'jquery' ), '2.0.2', true );
|
||||
|
||||
wp_register_script( 'google-maps', 'http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places' );
|
||||
|
||||
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', 'google-maps', 'jquery-locationpicker' ), SP_VERSION, true );
|
||||
|
||||
wp_register_script( 'sportspress-admin', SP()->plugin_url() .'assets/js/admin.js', array( 'jquery', 'jquery-chosen', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown' ), SP_VERSION, true );
|
||||
|
||||
// SportsPress admin pages
|
||||
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
|
||||
|
||||
wp_enqueue_script( 'jquery' );
|
||||
wp_enqueue_script( 'jquery-chosen' );
|
||||
wp_enqueue_script( 'jquery-tiptip' );
|
||||
wp_enqueue_script( 'jquery-caret' );
|
||||
wp_enqueue_script( 'jquery-countdown' );
|
||||
wp_enqueue_script( 'sportspress-admin' );
|
||||
|
||||
$params = array(
|
||||
'none' => __( 'None', 'sportspress' ),
|
||||
'remove_text' => __( '— Remove —', 'sportspress' ),
|
||||
'days' => __( 'days', 'sportspress' ),
|
||||
'hrs' => __( 'hrs', 'sportspress' ),
|
||||
'mins' => __( 'mins', 'sportspress' ),
|
||||
'secs' => __( 'secs', 'sportspress' )
|
||||
);
|
||||
|
||||
// Localize scripts
|
||||
wp_localize_script( 'sportspress-admin', 'localized_strings', $params );
|
||||
}
|
||||
|
||||
// Edit venue pages
|
||||
if ( in_array( $screen->id, array( 'edit-sp_venue' ) ) ) {
|
||||
|
||||
wp_enqueue_script( 'google-maps' );
|
||||
wp_enqueue_script( 'jquery-locationpicker' );
|
||||
wp_enqueue_script( 'sportspress-admin-locationpicker' );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_Assets();
|
||||
@@ -30,7 +30,7 @@ class SP_Admin {
|
||||
*/
|
||||
public function includes() {
|
||||
// Functions
|
||||
// include_once( 'sp-admin-functions.php' );
|
||||
include_once( 'sp-admin-functions.php' );
|
||||
// include_once( 'sp-meta-box-functions.php' );
|
||||
|
||||
// Classes
|
||||
@@ -42,7 +42,7 @@ class SP_Admin {
|
||||
// include( 'class-sp-admin-menus.php' );
|
||||
// include( 'class-sp-admin-welcome.php' );
|
||||
// include( 'class-sp-admin-notices.php' );
|
||||
// include( 'class-sp-admin-assets.php' );
|
||||
include( 'class-sp-admin-assets.php' );
|
||||
// include( 'class-sp-admin-permalink-settings.php' );
|
||||
// include( 'class-sp-admin-editor.php' );
|
||||
|
||||
|
||||
51
includes/admin/sp-admin-functions.php
Normal file
51
includes/admin/sp-admin-functions.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* SportsPress Admin Functions
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Core
|
||||
* @package SportsPress/Admin/Functions
|
||||
* @version 0.7
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/**
|
||||
* Get all SportsPress screen ids
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function sp_get_screen_ids() {
|
||||
return apply_filters( 'sportspress_screen_ids', array(
|
||||
'edit-sp_result',
|
||||
'sp_result',
|
||||
'edit-sp_outcome',
|
||||
'sp_outcome',
|
||||
'edit-sp_performance',
|
||||
'sp_performance',
|
||||
'edit-sp_column',
|
||||
'sp_column',
|
||||
'edit-sp_metric',
|
||||
'sp_metric',
|
||||
'edit-sp_statistic',
|
||||
'sp_statistic',
|
||||
'edit-sp_event',
|
||||
'sp_event',
|
||||
'edit-sp_calendar',
|
||||
'sp_calendar',
|
||||
'edit-sp_team',
|
||||
'sp_team',
|
||||
'edit-sp_table',
|
||||
'sp_table',
|
||||
'edit-sp_player',
|
||||
'sp_player',
|
||||
'edit-sp_list',
|
||||
'sp_list',
|
||||
'edit-sp_staff',
|
||||
'sp_staff',
|
||||
'edit-sp_venue',
|
||||
'edit-sp_league',
|
||||
'edit-sp_season',
|
||||
'edit-sp_position',
|
||||
) );
|
||||
}
|
||||
Reference in New Issue
Block a user