Move leagues and seasons to SP submenu

This commit is contained in:
Brian Miyaji
2014-05-12 22:33:54 +10:00
parent 948ad04f08
commit 23a2ac29db
2 changed files with 77 additions and 4 deletions

View File

@@ -22,13 +22,16 @@ class SP_Admin_Menus {
*/
public function __construct() {
add_filter( 'admin_menu', array( $this, 'menu_clean' ), 5 );
add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
add_action( 'admin_menu', array( $this, 'status_menu' ), 60 );
add_action( 'admin_menu', array( $this, 'admin_menu' ), 6 );
add_action( 'admin_menu', array( $this, 'status_menu' ), 7 );
add_action( 'admin_menu', array( $this, 'leagues_menu' ), 8 );
add_action( 'admin_menu', array( $this, 'seasons_menu' ), 9 );
if ( apply_filters( 'sportspress_show_addons_page', false ) ) // Make true to display by default
add_action( 'admin_menu', array( $this, 'addons_menu' ), 70 );
add_action( 'admin_head', array( $this, 'menu_highlight' ) );
add_action( 'parent_file', array( $this, 'parent_file' ) );
add_filter( 'menu_order', array( $this, 'menu_order' ) );
add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) );
}
@@ -45,6 +48,20 @@ class SP_Admin_Menus {
$main_page = add_menu_page( __( 'SportsPress Settings', 'sportspress' ), __( 'SportsPress', 'sportspress' ), 'manage_sportspress', 'sportspress', array( $this, 'settings_page' ), null, '51.5' );
}
/**
* Add menu item
*/
public function leagues_menu() {
add_submenu_page( 'sportspress', __( 'Leagues', 'sportspress' ), __( 'Leagues', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_league');
}
/**
* Add menu item
*/
public function seasons_menu() {
add_submenu_page( 'sportspress', __( 'Seasons', 'sportspress' ), __( 'Seasons', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_season');
}
/**
* Add menu item
*/
@@ -82,6 +99,14 @@ class SP_Admin_Menus {
}
}
public function parent_file( $parent_file ) {
global $current_screen;
$taxonomy = $current_screen->taxonomy;
if ( in_array( $taxonomy, array( 'sp_league', 'sp_season' ) ) )
$parent_file = 'sportspress';
return $parent_file;
}
/**
* Reorder the SP menu items in admin.
*
@@ -175,6 +200,12 @@ class SP_Admin_Menus {
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], array( $this, 'remove_seasons' ) );
endif;
// Remove "Leagues" and "Seasons" links from Teams submenu
if ( isset( $submenu['edit.php?post_type=sp_team'] ) ):
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_leagues' ) );
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_seasons' ) );
endif;
// Remove "Leagues" and "Seasons" links from Players submenu
if ( isset( $submenu['edit.php?post_type=sp_player'] ) ):
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], array( $this, 'remove_leagues' ) );

View File

@@ -7,7 +7,7 @@
* @author ThemeBoy
* @category Core
* @package SportsPress/Functions
* @version 0.8
* @version 0.9
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -22,6 +22,48 @@ function is_sportspress() {
return apply_filters( 'is_sportspress', ( is_singular( array( 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ) ? true : false );
}
/**
* sp_post_types - Returns array of SP post types
*
* @access public
* @return array
*/
if ( ! function_exists( 'sp_post_types' ) ) {
function sp_post_types() {
return apply_filters( 'sportspress_post_types', array( 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) );
}
}
/**
* sp_config_types - Returns array of SP config types
*
* @access public
* @return array
*/
if ( ! function_exists( 'sp_config_types' ) ) {
function sp_config_types() {
return apply_filters( 'sportspress_config_types', array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance', 'sp_metric', 'sp_statistic' ) );
}
}
/**
* is_sp_post_type - Returns true if post is SportsPress post type
*
* @access public
* @return bool
*/
if ( ! function_exists( 'is_sp_post_type' ) ) {
function is_sp_post_type( $typenow = null ) {
if ( $typenow == null ) global $typenow;
$post_types = sp_post_types();
if ( in_array( $typenow, $post_types ) )
return true;
return false;
}
}
/**
* is_sp_config_type - Returns true if post is SportsPress config type
*
@@ -32,7 +74,7 @@ if ( ! function_exists( 'is_sp_config_type' ) ) {
function is_sp_config_type( $typenow = null ) {
if ( $typenow == null ) global $typenow;
$post_types = array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance', 'sp_metric', 'sp_statistic' );
$post_types = sp_config_types();
if ( in_array( $typenow, $post_types ) )
return true;