From 1b30d3a4ce75fb2b5ea3f85a5b86e93631259652 Mon Sep 17 00:00:00 2001
From: Brian Miyaji
Date: Tue, 18 Feb 2014 19:33:06 +1100
Subject: [PATCH] Tidy up player edit screen and add custom menu icons
---
admin/hooks/admin-init.php | 38 ----
admin/hooks/admin-menu.php | 16 +-
admin/hooks/admin-print-styles.php | 8 +-
admin/hooks/save-post.php | 11 +-
admin/includes/notice-theme-support.php | 6 +-
admin/post-types/player.php | 92 +++++-----
admin/settings/settings.php | 165 +++++++++---------
admin/templates/player-metrics.php | 23 ++-
admin/tools/importers.php | 40 +++++
.../{importers => tools}/player-importer.php | 0
admin/{importers => tools}/team-importer.php | 0
assets/css/admin.css | 66 ++++++-
assets/fonts/sportspress.eot | Bin 0 -> 2276 bytes
assets/fonts/sportspress.svg | 14 ++
assets/fonts/sportspress.ttf | Bin 0 -> 2096 bytes
assets/fonts/sportspress.woff | Bin 0 -> 1828 bytes
assets/js/admin.js | 4 +-
functions.php | 16 +-
sportspress.php | 3 +
19 files changed, 293 insertions(+), 209 deletions(-)
create mode 100644 admin/tools/importers.php
rename admin/{importers => tools}/player-importer.php (100%)
rename admin/{importers => tools}/team-importer.php (100%)
create mode 100755 assets/fonts/sportspress.eot
create mode 100755 assets/fonts/sportspress.svg
create mode 100755 assets/fonts/sportspress.ttf
create mode 100755 assets/fonts/sportspress.woff
diff --git a/admin/hooks/admin-init.php b/admin/hooks/admin-init.php
index 1dc3c75c..5f39597e 100644
--- a/admin/hooks/admin-init.php
+++ b/admin/hooks/admin-init.php
@@ -1,38 +1,4 @@
dispatch();
-}
-
-function sportspress_player_importer() {
- require_once ABSPATH . 'wp-admin/includes/import.php';
-
- if ( ! class_exists( 'WP_Importer' ) ) {
- $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
- if ( file_exists( $class_wp_importer ) )
- require $class_wp_importer;
- }
-
- // includes
- require dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/importers/player-importer.php';
-
- // Dispatch
- $importer = new SP_Player_Importer();
- $importer->dispatch();
-}
-
function sportspress_admin_init() {
$post_types = array(
'sp_event',
@@ -69,9 +35,5 @@ function sportspress_admin_init() {
$administrator->add_cap( $cap . '_' . $post_type . 's' );
endforeach;
endforeach;
-
- // Importers
- register_importer( 'sportspress_team_csv', __( 'SportsPress Teams (CSV)', 'sportspress' ), __( 'Import teams from a csv file.', 'sportspress'), 'sportspress_team_importer' );
- register_importer( 'sportspress_player_csv', __( 'SportsPress Players (CSV)', 'sportspress' ), __( 'Import players from a csv file.', 'sportspress'), 'sportspress_player_importer' );
}
add_action( 'admin_init', 'sportspress_admin_init' );
diff --git a/admin/hooks/admin-menu.php b/admin/hooks/admin-menu.php
index d4872485..49bb94ca 100644
--- a/admin/hooks/admin-menu.php
+++ b/admin/hooks/admin-menu.php
@@ -3,15 +3,15 @@ function sportspress_admin_menu( $position ) {
global $menu, $submenu;
- // Find where our placeholder is in the menu
+ // Find where our separator is in the menu
foreach( $menu as $key => $data ):
if ( is_array( $data ) && array_key_exists( 2, $data ) && $data[2] == 'edit.php?post_type=sp_separator' )
- $seperator_position = $key;
+ $separator_position = $key;
endforeach;
- // Swap our placeholder post type with a menu separator
- if ( $seperator_position ):
- $menu[ $seperator_position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
+ // Swap our separator post type with a menu separator
+ if ( isset( $separator_position ) ):
+ $menu[ $separator_position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
endif;
// Remove "Venues" and "Positions" links from Media submenu
@@ -41,6 +41,12 @@ function sportspress_admin_menu( $position ) {
}
add_action( 'admin_menu', 'sportspress_admin_menu' );
+if ( ! function_exists( 'sportspress_admin_menu_remove_add_new' ) ) {
+ function sportspress_admin_menu_remove_add_new( $arr = array() ) {
+ return $arr[0] != __( 'Add New', 'sportspress' );
+ }
+}
+
if ( ! function_exists( 'sportspress_admin_menu_remove_leagues' ) ) {
function sportspress_admin_menu_remove_leagues( $arr = array() ) {
return $arr[0] != __( 'Leagues', 'sportspress' );
diff --git a/admin/hooks/admin-print-styles.php b/admin/hooks/admin-print-styles.php
index a234803b..20f848be 100644
--- a/admin/hooks/admin-print-styles.php
+++ b/admin/hooks/admin-print-styles.php
@@ -1,10 +1,8 @@
id != 'settings_page_sportspress' ):
-
if ( isset( $_REQUEST['sportspress_installed'] ) ):
update_option( 'sportspress_installed', $_REQUEST['sportspress_installed'] );
endif;
@@ -12,13 +10,11 @@ function sportspress_admin_notices_styles() {
if ( ! get_option( 'sportspress_installed' ) ):
add_action( 'admin_notices', 'sportspress_admin_install_notices' );
endif;
-
endif;
$template = get_option( 'template' );
if ( ! current_theme_supports( 'sportspress' ) && ! in_array( $template, array( 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ):
-
if ( ! empty( $_GET['hide_sportspress_theme_support_check'] ) ):
update_option( 'sportspress_theme_support_check', $template );
return;
@@ -27,9 +23,7 @@ function sportspress_admin_notices_styles() {
if ( get_option( 'sportspress_theme_support_check' ) !== $template ):
add_action( 'admin_notices', 'sportspress_theme_check_notice' );
endif;
-
endif;
-
}
add_action( 'admin_print_styles', 'sportspress_admin_notices_styles' );
@@ -50,5 +44,5 @@ function sportspress_admin_install_notices() {
* @return void
*/
function sportspress_theme_check_notice() {
- include( dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/includes/notice-theme-support.php' );
+// include( dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/includes/notice-theme-support.php' );
}
diff --git a/admin/hooks/save-post.php b/admin/hooks/save-post.php
index 6b6bda34..046798fb 100644
--- a/admin/hooks/save-post.php
+++ b/admin/hooks/save-post.php
@@ -95,15 +95,18 @@ function sportspress_save_post( $post_id ) {
// Update seasons teams to show
update_post_meta( $post_id, 'sp_leagues', sportspress_array_value( $_POST, 'sp_leagues', array() ) );
+ // Update current team
+ update_post_meta( $post_id, 'sp_current_team', sportspress_array_value( $_POST, 'sp_current_team', null ) );
+
+ // Update past team array
+ sportspress_update_post_meta_recursive( $post_id, 'sp_past_team', sportspress_array_value( $_POST, 'sp_past_team', array() ) );
+
// Update team array
- sportspress_update_post_meta_recursive( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
+ sportspress_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sportspress_array_value( $_POST, 'sp_current_team', null ) ), sportspress_array_value( $_POST, 'sp_past_team', array() ) ) );
// Update player number
update_post_meta( $post_id, 'sp_number', sportspress_array_value( $_POST, 'sp_number', '' ) );
- // Update current team
- update_post_meta( $post_id, 'sp_current_team', sportspress_array_value( $_POST, 'sp_current_team', '' ) );
-
// Update nationality
update_post_meta( $post_id, 'sp_nationality', sportspress_array_value( $_POST, 'sp_nationality', '' ) );
diff --git a/admin/includes/notice-theme-support.php b/admin/includes/notice-theme-support.php
index cbeb37e2..ccf9d3be 100644
--- a/admin/includes/notice-theme-support.php
+++ b/admin/includes/notice-theme-support.php
@@ -1,12 +1,10 @@
-
-
Your theme does not declare SportsPress support – if you encounter layout issues please read our integration guide or choose a SportsPress theme :)', 'sportspress' ); ?>
+
Your theme does not declare SportsPress support – if you encounter layout issues please read our integration guide or choose a SportsPress theme :)', 'sportspress' ); ?>
-
-
\ No newline at end of file
diff --git a/admin/post-types/player.php b/admin/post-types/player.php
index ad38d66b..110d151e 100644
--- a/admin/post-types/player.php
+++ b/admin/post-types/player.php
@@ -96,7 +96,7 @@ function sportspress_player_details_meta( $post ) {
endif;
$teams = get_posts( array( 'post_type' => 'sp_team', 'posts_per_page' => -1 ) );
- $the_teams = array_filter( get_post_meta( $post->ID, 'sp_team', false ) );
+ $past_teams = array_filter( get_post_meta( $post->ID, 'sp_past_team', false ) );
$current_team = get_post_meta( $post->ID, 'sp_current_team', true );
?>
@@ -114,6 +114,51 @@ function sportspress_player_details_meta( $post ) {
+
+ 'sp_position',
+ 'name' => 'tax_input[sp_position][]',
+ 'selected' => $position_ids,
+ 'values' => 'term_id',
+ 'placeholder' => __( 'Select Positions', 'sportspress' ),
+ 'class' => 'widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
+ );
+ sportspress_dropdown_taxonomies( $args );
+ ?>
+
+
+ 'sp_team',
+ 'name' => 'sp_current_team',
+ 'show_option_blank' => true,
+ 'selected' => $current_team,
+ 'values' => 'ID',
+ 'placeholder' => __( 'Select Team', 'sportspress' ),
+ 'class' => 'sp-current-team widefat',
+ 'chosen' => true,
+ );
+ sportspress_dropdown_pages( $args );
+ ?>
+
+
+ 'sp_team',
+ 'name' => 'sp_past_team[]',
+ 'selected' => $past_teams,
+ 'values' => 'ID',
+ 'placeholder' => __( 'Select Teams', 'sportspress' ),
+ 'class' => 'sp-past-teams widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
+ );
+ sportspress_dropdown_pages( $args );
+ ?>
+
-
-
- 'sp_team',
- 'name' => 'sp_team[]',
- 'selected' => $the_teams,
- 'values' => 'ID',
- 'placeholder' => __( 'Select Teams', 'sportspress' ),
- 'class' => 'sp-team widefat',
- 'property' => 'multiple',
- 'chosen' => true,
- );
- sportspress_dropdown_pages( $args );
- ?>
-
-
- 'sp_team',
- 'name' => 'sp_current_team',
- 'show_option_blank' => true,
- 'selected' => $current_team,
- 'values' => 'ID',
- 'placeholder' => __( 'Select Team', 'sportspress' ),
- 'class' => 'sp-current-team widefat',
- 'chosen' => true,
- );
- sportspress_dropdown_pages( $args );
- ?>
-
-
- 'sp_position',
- 'name' => 'tax_input[sp_position][]',
- 'selected' => $position_ids,
- 'values' => 'term_id',
- 'placeholder' => __( 'Select Positions', 'sportspress' ),
- 'class' => 'widefat',
- 'property' => 'multiple',
- 'chosen' => true,
- );
- sportspress_dropdown_taxonomies( $args );
- ?>
-
-
-
-
+
+
+
+