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 @@ -
- \ 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 ); - ?>