Tidy up player edit screen and add custom menu icons
This commit is contained in:
@@ -1,38 +1,4 @@
|
||||
<?php
|
||||
function sportspress_team_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/team-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new SP_Team_Importer();
|
||||
$importer->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 <strong>teams</strong> from a csv file.', 'sportspress'), 'sportspress_team_importer' );
|
||||
register_importer( 'sportspress_player_csv', __( 'SportsPress Players (CSV)', 'sportspress' ), __( 'Import <strong>players</strong> from a csv file.', 'sportspress'), 'sportspress_player_importer' );
|
||||
}
|
||||
add_action( 'admin_init', 'sportspress_admin_init' );
|
||||
|
||||
@@ -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' );
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
function sportspress_admin_notices_styles() {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( $screen->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' );
|
||||
}
|
||||
|
||||
@@ -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', '' ) );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user