Move SportsPress to top-level page

This commit is contained in:
Brian Miyaji
2014-04-10 13:24:22 +10:00
parent 6e1f8e88e6
commit c9709948ce
22 changed files with 127 additions and 88 deletions

View File

@@ -24,6 +24,9 @@
-moz-osx-font-smoothing: grayscale;
}
.sp-icon-sportspress:before {
content: "\f111";
}
.sp-icon-calendar:before {
content: "\f145";
}

Binary file not shown.

View File

@@ -7,7 +7,7 @@
<font-face units-per-em="512" ascent="480" descent="-32" />
<missing-glyph horiz-adv-x="512" />
<glyph unicode="&#x20;" d="" horiz-adv-x="256" />
<glyph unicode="&#xe600;" d="M256 177.177c61.184 0 112.409 20.787 115.507 47.949-9.088 25.523-19.021 53.35-28.774 80.717-6.759-19.507-44.16-33.28-86.733-33.28s-79.949 13.747-86.758 33.255c-9.754-27.366-19.635-55.168-28.749-80.717 3.097-27.136 54.298-47.923 115.507-47.923zM256 348.826c28.749 0 55.475 8.909 63.309 22.733-10.777 30.285-20.045 56.243-25.907 72.627-3.865 10.931-21.504 16.615-37.401 16.615s-33.536-5.683-37.401-16.589c-5.863-16.384-15.104-42.368-25.907-72.627 7.833-13.849 34.56-22.758 63.309-22.758zM480.768 151.91l-96.128 38.733 11.085-30.899c-0.563-32.717-64.128-58.829-139.725-58.829s-139.161 26.112-139.699 58.829l11.059 30.899-96.128-38.733c-26.957-10.88-28.083-30.976-2.535-44.672l180.787-96.947c25.575-13.696 67.43-13.696 93.005 0l180.787 96.947c25.6 13.696 24.448 33.792-2.509 44.672z" />
<glyph unicode="&#xf111;" d="M51.2 102.4h102.4v204.8h-102.4v-204.8zM204.8 102.4h102.4v307.2h-102.4v-307.2zM358.4 307.2v-204.8h102.4v204.8h-102.4z" />
<glyph unicode="&#xf145;" d="M384 435.2h-51.2v-51.2h51.2v51.2zM435.2 435.2h-25.6v-76.8h-102.4v76.8h-102.4v-76.8h-102.4v76.8h-25.6c-14.16 0-25.6-11.44-25.6-25.6v-358.4c0-14.16 11.44-25.6 25.6-25.6h358.4c14.16 0 25.6 11.44 25.6 25.6v358.4c0 14.16-11.44 25.6-25.6 25.6zM409.6 76.8h-307.2v230.4h307.2v-230.4zM179.2 435.2h-51.2v-51.2h51.2v51.2zM281.6 256h-51.2v-51.2h51.2v51.2zM358.4 256h-51.2v-51.2h51.2v51.2zM204.8 179.2h-51.2v-51.2h51.2v51.2zM204.8 256h-51.2v-51.2h51.2v51.2zM281.6 179.2h-51.2v-51.2h51.2v51.2zM358.4 179.2h-51.2v-51.2h51.2v51.2z" />
<glyph unicode="&#xf163;" d="M153.6 332.8h51.2v-51.2h-51.2v51.2zM153.6 256h51.2v-51.2h-51.2v51.2zM153.6 179.2h51.2v-51.2h-51.2v51.2zM256 179.2h102.4v-51.2h-102.4v51.2zM435.2 435.2h-358.4c-14.16 0-25.6-11.44-25.6-25.6v-358.4c0-14.16 11.44-25.6 25.6-25.6h358.4c14.16 0 25.6 11.44 25.6 25.6v358.4c0 14.16-11.44 25.6-25.6 25.6zM409.6 76.8h-307.2v307.2h307.2v-307.2zM256 256h102.4v-51.2h-102.4v51.2zM256 332.8h102.4v-51.2h-102.4v51.2z" />
<glyph unicode="&#xf307;" d="M384 102.4h-256v179.2h-76.8v102.4l130.4 25.6c8.56-33.12 38.56-57.6 74.4-57.6s65.84 24.48 74.4 57.6l130.4-25.6v-102.4h-76.8v-179.2zM384 76.8v-51.2h-256v51.2h256z" />

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Binary file not shown.

View File

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

View File

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

View File

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

View File

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

View File

@@ -160,7 +160,7 @@ class SP_Admin_Welcome {
<div class="sp-badge"><?php printf( __( 'Version %s', 'sportspress' ), SP()->version ); ?></div>
<p class="sportspress-actions">
<?php if ( false ): ?><a href="<?php echo admin_url( add_query_arg( array( 'page' => 'sportspress' ), 'options-general.php' ) ); ?>" class="button button-primary"><?php _e( 'Settings', 'sportspress' ); ?></a><?php endif; ?>
<?php if ( false ): ?><a href="<?php echo admin_url( add_query_arg( array( 'page' => 'sportspress' ), 'admin.php' ) ); ?>" class="button button-primary"><?php _e( 'Settings', 'sportspress' ); ?></a><?php endif; ?>
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://ow.ly/vaGUv" data-text="An open-source (free) #WordPress plugin that helps you build professional league websites." data-via="ThemeBoy" data-size="large" data-hashtags="SportsPress">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</p>
@@ -266,7 +266,7 @@ class SP_Admin_Welcome {
</div>
<div class="return-to-dashboard">
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress' ), 'options-general.php' ) ) ); ?>"><?php _e( 'Go to SportsPress Settings', 'sportspress' ); ?></a>
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress' ), 'admin.php' ) ) ); ?>"><?php _e( 'Go to SportsPress Settings', 'sportspress' ); ?></a>
</div>
</div>
<?php

View File

@@ -125,8 +125,6 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
if ( $typenow != 'sp_calendar' )
return;
sp_highlight_admin_menu();
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
$args = array(
'show_option_all' => __( 'Show all leagues', 'sportspress' ),

View File

@@ -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',

View File

@@ -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' ),

View File

@@ -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',

View File

@@ -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',

View File

@@ -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' ),

View File

@@ -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' ),

View File

@@ -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',

View File

@@ -3,7 +3,7 @@
<div class="icon32 icon32-sportspress-settings" id="icon-sportspress"><br /></div><h2 class="nav-tab-wrapper sp-nav-tab-wrapper">
<?php
foreach ( $tabs as $name => $label )
echo '<a href="' . admin_url( 'options-general.php?page=sportspress&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
echo '<a href="' . admin_url( 'admin.php?page=sportspress&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
do_action( 'sportspress_settings_tabs' );
?>

View File

@@ -152,18 +152,6 @@ class SP_Post_types {
* Register core post types
*/
public static function register_post_types() {
register_post_type( 'sp_separator',
array(
'label' => '',
'public' => false,
'show_ui' => true,
'show_in_nav_menus' => false,
'show_in_admin_bar' => false,
'can_export' => false,
)
);
do_action( 'sportspress_register_post_type' );
register_post_type( 'sp_result',
@@ -189,9 +177,9 @@ class SP_Post_types {
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'has_archive' => false,
'show_in_menu' => false,
'show_in_nav_menus' => false,
'can_export' => false,
'show_in_menu' => 'sportspress',
)
)
);
@@ -219,39 +207,9 @@ class SP_Post_types {
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'has_archive' => false,
'show_in_menu' => false,
'show_in_nav_menus' => false,
'can_export' => false,
)
)
);
register_post_type( 'sp_performance',
apply_filters( 'sportspress_register_post_type_performance',
array(
'labels' => array(
'name' => __( 'Performance', 'sportspress' ),
'singular_name' => __( 'Performance', 'sportspress' ),
'add_new_item' => __( 'Add New Performance', 'sportspress' ),
'edit_item' => __( 'Edit Performance', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
),
'public' => false,
'show_ui' => true,
'capability_type' => 'sp_config',
'map_meta_cap' => true,
'publicly_queryable' => false,
'exclude_from_search' => true,
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'has_archive' => false,
'show_in_menu' => false,
'show_in_nav_menus' => false,
'can_export' => false,
'show_in_menu' => 'sportspress',
)
)
);
@@ -279,9 +237,39 @@ class SP_Post_types {
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'has_archive' => false,
'show_in_menu' => false,
'show_in_nav_menus' => false,
'can_export' => false,
'show_in_menu' => 'sportspress',
)
)
);
register_post_type( 'sp_performance',
apply_filters( 'sportspress_register_post_type_performance',
array(
'labels' => array(
'name' => __( 'Performance', 'sportspress' ),
'singular_name' => __( 'Performance', 'sportspress' ),
'add_new_item' => __( 'Add New Performance', 'sportspress' ),
'edit_item' => __( 'Edit Performance', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
),
'public' => false,
'show_ui' => true,
'capability_type' => 'sp_config',
'map_meta_cap' => true,
'publicly_queryable' => false,
'exclude_from_search' => true,
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'has_archive' => false,
'show_in_nav_menus' => false,
'can_export' => false,
'show_in_menu' => 'sportspress',
)
)
);
@@ -309,9 +297,9 @@ class SP_Post_types {
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'has_archive' => false,
'show_in_menu' => false,
'show_in_nav_menus' => false,
'can_export' => false,
'show_in_menu' => 'sportspress',
)
)
);
@@ -339,9 +327,9 @@ class SP_Post_types {
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'has_archive' => false,
'show_in_menu' => false,
'show_in_nav_menus' => false,
'can_export' => false,
'show_in_menu' => 'sportspress',
)
)
);

View File

@@ -2986,14 +2986,6 @@ if ( !function_exists( 'sp_delete_duplicate_post' ) ) {
}
}
if ( !function_exists( 'sp_highlight_admin_menu' ) ) {
function sp_highlight_admin_menu( $p = 'options-general.php', $s = 'sportspress' ) {
global $parent_file, $submenu_file;
$parent_file = $p;
$submenu_file = $s;
}
}
/**
* Get an array of sport options and settings.
* @return array

View File

@@ -134,7 +134,7 @@ final class SportsPress {
*/
public function action_links( $links ) {
return array_merge( array(
'<a href="' . admin_url( 'options-general.php?page=sportspress' ) . '">' . __( 'Settings', 'sportspress' ) . '</a>',
'<a href="' . admin_url( 'admin.php?page=sportspress' ) . '">' . __( 'Settings', 'sportspress' ) . '</a>',
), $links );
}