diff --git a/assets/css/menu.css b/assets/css/menu.css index e4f44ff9..444ce19d 100644 --- a/assets/css/menu.css +++ b/assets/css/menu.css @@ -24,6 +24,9 @@ -moz-osx-font-smoothing: grayscale; } +.sp-icon-sportspress:before { + content: "\f111"; +} .sp-icon-calendar:before { content: "\f145"; } diff --git a/assets/fonts/sportspress.eot b/assets/fonts/sportspress.eot index bc3da08b..253b7f8f 100755 Binary files a/assets/fonts/sportspress.eot and b/assets/fonts/sportspress.eot differ diff --git a/assets/fonts/sportspress.svg b/assets/fonts/sportspress.svg index d5ddb4fd..8d13ca9a 100755 --- a/assets/fonts/sportspress.svg +++ b/assets/fonts/sportspress.svg @@ -7,7 +7,7 @@ - + diff --git a/assets/fonts/sportspress.ttf b/assets/fonts/sportspress.ttf index 82bd8ba2..8ea112aa 100755 Binary files a/assets/fonts/sportspress.ttf and b/assets/fonts/sportspress.ttf differ diff --git a/assets/fonts/sportspress.woff b/assets/fonts/sportspress.woff index 8e00ac5f..1e3f885c 100755 Binary files a/assets/fonts/sportspress.woff and b/assets/fonts/sportspress.woff differ diff --git a/assets/js/admin/settings.js b/assets/js/admin/settings.js index ebea452e..647ca0fc 100644 --- a/assets/js/admin/settings.js +++ b/assets/js/admin/settings.js @@ -1,7 +1,7 @@ jQuery(document).ready(function($){ // Display custom sport name field as needed - $("body.settings_page_sportspress #sportspress_sport").change(function() { + $("body.toplevel_page_sportspress #sportspress_sport").change(function() { $target = $("#sportspress_custom_sport_name"); if ( $(this).val() == "custom" ) $target.show(); diff --git a/assets/js/admin/sportspress-admin.js b/assets/js/admin/sportspress-admin.js index 0c049b83..62572a25 100644 --- a/assets/js/admin/sportspress-admin.js +++ b/assets/js/admin/sportspress-admin.js @@ -1,7 +1,7 @@ jQuery(document).ready(function($){ // Display custom sport name field as needed - $("body.settings_page_sportspress #sportspress_sport").change(function() { + $("body.toplevel_page_sportspress #sportspress_sport").change(function() { $target = $("#sportspress_custom_sport_name"); if ( $(this).val() == "custom" ) $target.show(); diff --git a/includes/admin/class-sp-admin-menus.php b/includes/admin/class-sp-admin-menus.php index 6f3fb3aa..fb0dd389 100644 --- a/includes/admin/class-sp-admin-menus.php +++ b/includes/admin/class-sp-admin-menus.php @@ -21,16 +21,22 @@ class SP_Admin_Menus { * Hook in tabs. */ public function __construct() { - add_filter( 'admin_menu', array( $this, 'menu_clean' ) ); - add_action( 'admin_menu', array( $this, 'settings_menu' ), 50 ); + add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 ); add_action( 'admin_head', array( $this, 'menu_highlight' ) ); + add_filter( 'menu_order', array( $this, 'menu_order' ) ); + add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) ); } /** * Add menu item */ - public function settings_menu() { - $settings_page = add_options_page( __( 'SportsPress', 'sportspress' ), __( 'SportsPress', 'sportspress' ), 'manage_options', 'sportspress', array( $this, 'settings_page' ) ); + public function admin_menu() { + global $menu; + + if ( current_user_can( 'manage_sportspress' ) ) + $menu[] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' ); + + $main_page = add_menu_page( __( 'SportsPress Settings', 'sportspress' ), __( 'SportsPress', 'sportspress' ), 'manage_sportspress', 'sportspress', array( $this, 'settings_page' ), null, '51.5' ); } /** @@ -40,17 +46,75 @@ class SP_Admin_Menus { * @return void */ public function menu_highlight() { - global $typenow; + global $typenow, $submenu; if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance', 'sp_metric' ) ) ) - sp_highlight_admin_menu(); + $this->highlight_admin_menu( 'sportspress', 'edit.php?post_type=' . $typenow ); elseif ( $typenow == 'sp_calendar' ) - sp_highlight_admin_menu( 'edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar' ); + $this->highlight_admin_menu( 'edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar' ); elseif ( $typenow == 'sp_table' ) - sp_highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' ); + $this->highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' ); elseif ( $typenow == 'sp_list' ) - sp_highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_list' ); + $this->highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_list' ); elseif ( $typenow == 'sp_directory' ) - sp_highlight_admin_menu( 'edit.php?post_type=sp_staff', 'edit.php?post_type=sp_directory' ); + $this->highlight_admin_menu( 'edit.php?post_type=sp_staff', 'edit.php?post_type=sp_directory' ); + + if ( isset( $submenu['sportspress'] ) && isset( $submenu['sportspress'][0] ) && isset( $submenu['sportspress'][0][0] ) ) { + $submenu['sportspress'][0][0] = __( 'Settings', 'sportspress' ); + } + } + + /** + * Reorder the SP menu items in admin. + * + * @param mixed $menu_order + * @return array + */ + public function menu_order( $menu_order ) { + // Initialize our custom order array + $sportspress_menu_order = array(); + + // Get the index of our custom separator + $sportspress_separator = array_search( 'separator-sportspress', $menu_order ); + + // Get index of menu items + $sportspress_event = array_search( 'edit.php?post_type=sp_event', $menu_order ); + $sportspress_team = array_search( 'edit.php?post_type=sp_team', $menu_order ); + $sportspress_player = array_search( 'edit.php?post_type=sp_player', $menu_order ); + $sportspress_staff = array_search( 'edit.php?post_type=sp_staff', $menu_order ); + + // Loop through menu order and do some rearranging + foreach ( $menu_order as $index => $item ) : + + if ( ( ( 'sportspress' ) == $item ) ) : + $sportspress_menu_order[] = 'separator-sportspress'; + $sportspress_menu_order[] = $item; + $sportspress_menu_order[] = 'edit.php?post_type=sp_event'; + $sportspress_menu_order[] = 'edit.php?post_type=sp_team'; + $sportspress_menu_order[] = 'edit.php?post_type=sp_player'; + $sportspress_menu_order[] = 'edit.php?post_type=sp_staff'; + unset( $menu_order[$sportspress_separator] ); + unset( $menu_order[$sportspress_event] ); + unset( $menu_order[$sportspress_team] ); + unset( $menu_order[$sportspress_player] ); + unset( $menu_order[$sportspress_staff] ); + elseif ( !in_array( $item, array( 'separator-sportspress' ) ) ) : + $sportspress_menu_order[] = $item; + endif; + + endforeach; + + // Return order + return $sportspress_menu_order; + } + + /** + * custom_menu_order + * @return bool + */ + public function custom_menu_order() { + if ( ! current_user_can( 'manage_sportspress' ) ) + return false; + return true; } /** @@ -122,6 +186,12 @@ class SP_Admin_Menus { public function remove_venues( $arr = array() ) { return $arr[0] != __( 'Venues', 'sportspress' ); } + + public static function highlight_admin_menu( $p = 'sportspress', $s = 'sportspress' ) { + global $parent_file, $submenu_file; + $parent_file = $p; + $submenu_file = $s; + } } endif; diff --git a/includes/admin/class-sp-admin-notices.php b/includes/admin/class-sp-admin-notices.php index e2f7bb5a..0685b7f2 100644 --- a/includes/admin/class-sp-admin-notices.php +++ b/includes/admin/class-sp-admin-notices.php @@ -76,7 +76,7 @@ class SP_Admin_Notices { $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 != 'settings_page_sportspress' ) { + if ( get_option( '_sp_needs_welcome' ) == 1 && $screen->id != 'toplevel_page_sportspress' ) { include( 'views/html-notice-install.php' ); } } diff --git a/includes/admin/class-sp-admin-welcome.php b/includes/admin/class-sp-admin-welcome.php index 70771a28..b9715686 100644 --- a/includes/admin/class-sp-admin-welcome.php +++ b/includes/admin/class-sp-admin-welcome.php @@ -160,7 +160,7 @@ class SP_Admin_Welcome {
version ); ?>

- +

@@ -266,7 +266,7 @@ class SP_Admin_Welcome {
- +
__( 'Show all leagues', 'sportspress' ), diff --git a/includes/admin/post-types/class-sp-admin-cpt-event.php b/includes/admin/post-types/class-sp-admin-cpt-event.php index 4ccca680..69047430 100644 --- a/includes/admin/post-types/class-sp-admin-cpt-event.php +++ b/includes/admin/post-types/class-sp-admin-cpt-event.php @@ -180,8 +180,6 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT { if ( $typenow != 'sp_event' ) return; - sp_highlight_admin_menu(); - $selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null; $args = array( 'post_type' => 'sp_team', diff --git a/includes/admin/post-types/class-sp-admin-cpt-list.php b/includes/admin/post-types/class-sp-admin-cpt-list.php index 5ed52345..28e1ed7b 100644 --- a/includes/admin/post-types/class-sp-admin-cpt-list.php +++ b/includes/admin/post-types/class-sp-admin-cpt-list.php @@ -114,8 +114,6 @@ class SP_Admin_CPT_List extends SP_Admin_CPT { if ( $typenow != 'sp_list' ) return; - sp_highlight_admin_menu(); - $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; $args = array( 'show_option_all' => __( 'Show all leagues', 'sportspress' ), diff --git a/includes/admin/post-types/class-sp-admin-cpt-player.php b/includes/admin/post-types/class-sp-admin-cpt-player.php index 95297235..6c19b57e 100644 --- a/includes/admin/post-types/class-sp-admin-cpt-player.php +++ b/includes/admin/post-types/class-sp-admin-cpt-player.php @@ -163,8 +163,6 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT { if ( $typenow != 'sp_player' ) return; - sp_highlight_admin_menu(); - $selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null; $args = array( 'post_type' => 'sp_team', diff --git a/includes/admin/post-types/class-sp-admin-cpt-staff.php b/includes/admin/post-types/class-sp-admin-cpt-staff.php index c44991b8..58838e6d 100644 --- a/includes/admin/post-types/class-sp-admin-cpt-staff.php +++ b/includes/admin/post-types/class-sp-admin-cpt-staff.php @@ -138,8 +138,6 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT { if ( $typenow != 'sp_staff' ) return; - sp_highlight_admin_menu(); - $selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null; $args = array( 'post_type' => 'sp_team', diff --git a/includes/admin/post-types/class-sp-admin-cpt-table.php b/includes/admin/post-types/class-sp-admin-cpt-table.php index 8502078d..7ac04f52 100644 --- a/includes/admin/post-types/class-sp-admin-cpt-table.php +++ b/includes/admin/post-types/class-sp-admin-cpt-table.php @@ -100,8 +100,6 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT { if ( $typenow != 'sp_table' ) return; - sp_highlight_admin_menu(); - $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; $args = array( 'show_option_all' => __( 'Show all leagues', 'sportspress' ), diff --git a/includes/admin/post-types/class-sp-admin-cpt-team.php b/includes/admin/post-types/class-sp-admin-cpt-team.php index 3b887d73..690e3c4c 100644 --- a/includes/admin/post-types/class-sp-admin-cpt-team.php +++ b/includes/admin/post-types/class-sp-admin-cpt-team.php @@ -112,8 +112,6 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT { if ( $typenow != 'sp_team' ) return; - sp_highlight_admin_menu(); - $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; $args = array( 'show_option_all' => __( 'Show all leagues', 'sportspress' ), diff --git a/includes/admin/sp-admin-functions.php b/includes/admin/sp-admin-functions.php index 6e39f3bc..dcc607a4 100644 --- a/includes/admin/sp-admin-functions.php +++ b/includes/admin/sp-admin-functions.php @@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly function sp_get_screen_ids() { return apply_filters( 'sportspress_screen_ids', array( 'dashboard_page_sp-about', - 'settings_page_sportspress', + 'toplevel_page_sportspress', 'edit-sp_result', 'sp_result', 'edit-sp_outcome', diff --git a/includes/admin/views/html-admin-settings.php b/includes/admin/views/html-admin-settings.php index 8dcda03c..110ff411 100644 --- a/includes/admin/views/html-admin-settings.php +++ b/includes/admin/views/html-admin-settings.php @@ -3,7 +3,7 @@