diff --git a/assets/css/dashboard.css b/assets/css/dashboard.css index f35f99bb..e5134b9b 100644 --- a/assets/css/dashboard.css +++ b/assets/css/dashboard.css @@ -6,30 +6,37 @@ } -#dashboard_right_now .sp-event-count a:before, -#dashboard_right_now .sp-event-count span:before, -#dashboard_right_now .sp-team-count a:before, -#dashboard_right_now .sp-team-count span:before, -#dashboard_right_now .sp-player-count a:before, -#dashboard_right_now .sp-player-count span:before { +#dashboard_right_now .sp_event-count a:before, +#dashboard_right_now .sp_event-count span:before, +#dashboard_right_now .sp_team-count a:before, +#dashboard_right_now .sp_team-count span:before, +#dashboard_right_now .sp_player-count a:before, +#dashboard_right_now .sp_player-count span:before, +#dashboard_right_now .sp_staff-count a:before, +#dashboard_right_now .sp_staff-count span:before { font-family: 'sportspress'; } -#dashboard_right_now .sp-event-count a:before, -#dashboard_right_now .sp-event-count span:before { +#dashboard_right_now .sp_event-count a:before, +#dashboard_right_now .sp_event-count span:before { content: "\f145"; } -#dashboard_right_now .sp-team-count a:before, -#dashboard_right_now .sp-team-count span:before { +#dashboard_right_now .sp_team-count a:before, +#dashboard_right_now .sp_team-count span:before { content: "\f334"; } -#dashboard_right_now .sp-player-count a:before, -#dashboard_right_now .sp-player-count span:before { +#dashboard_right_now .sp_player-count a:before, +#dashboard_right_now .sp_player-count span:before { content: "\f307"; } +#dashboard_right_now .sp_staff-count a:before, +#dashboard_right_now .sp_staff-count span:before { + content: "\f338"; +} + #sportspress_dashboard_status .sp_status_list { overflow: hidden; margin: 0; diff --git a/assets/js/admin/editor-lang.php b/assets/js/admin/editor-lang.php index 182dd70e..447e12ef 100644 --- a/assets/js/admin/editor-lang.php +++ b/assets/js/admin/editor-lang.php @@ -11,12 +11,6 @@ $options = array( ), ); -if ( 'yes' == get_option( 'sportspress_load_calendars_module', 'yes' ) ) { - $options['event'][] = 'calendar'; - $options['event'][] = 'list'; - $options['event'][] = 'blocks'; -} - if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) { $options['table'] = array( 'table' ); } diff --git a/includes/admin/class-sp-admin-dashboard.php b/includes/admin/class-sp-admin-dashboard.php index a8f4d264..213ddc58 100644 --- a/includes/admin/class-sp-admin-dashboard.php +++ b/includes/admin/class-sp-admin-dashboard.php @@ -39,7 +39,7 @@ class SP_Admin_Dashboard { * Add links to At a Glance */ function glance_items( $items = array() ) { - $post_types = array( 'sp_event', 'sp_team', 'sp_player' ); + $post_types = apply_filters( 'sportspress_glance_items', array( 'sp_event', 'sp_team', 'sp_player', 'sp_staff' ) ); foreach ( $post_types as $type ): if ( ! post_type_exists( $type ) ) continue; $num_posts = wp_count_posts( $type ); @@ -49,12 +49,11 @@ class SP_Admin_Dashboard { $text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'sportspress' ); $text = sprintf( $text, number_format_i18n( $published ) ); if ( current_user_can( $post_type->cap->edit_posts ) ): - $output = '' . $text . ''; - echo '
  • ' . $output . '
  • '; + $output = '' . $text . ''; else: - $output = '' . $text . ''; - echo '
  • ' . $output . '
  • '; + $output = '' . $text . ''; endif; + echo '
  • ' . $output . '
  • '; endif; endforeach; return $items; diff --git a/includes/admin/class-sp-admin-importers.php b/includes/admin/class-sp-admin-importers.php index e6aced70..539cf4b2 100644 --- a/includes/admin/class-sp-admin-importers.php +++ b/includes/admin/class-sp-admin-importers.php @@ -28,12 +28,32 @@ class SP_Admin_Importers { * Add menu items */ public function register_importers() { - if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { - register_importer( 'sp_event_csv', __( 'SportsPress Events (CSV)', 'sportspress' ), __( 'Import events from a csv file.', 'sportspress'), array( $this, 'events_importer' ) ); - register_importer( 'sp_team_csv', __( 'SportsPress Teams (CSV)', 'sportspress' ), __( 'Import teams from a csv file.', 'sportspress'), array( $this, 'teams_importer' ) ); + $importers = apply_filters( 'sportspress_importers', array( + 'sp_event_csv' => array( + 'name' => __( 'SportsPress Events (CSV)', 'sportspress' ), + 'description' => __( 'Import events from a csv file.', 'sportspress'), + 'callback' => array( $this, 'events_importer' ), + ), + 'sp_team_csv' => array( + 'name' => __( 'SportsPress Teams (CSV)', 'sportspress' ), + 'description' => __( 'Import teams from a csv file.', 'sportspress'), + 'callback' => array( $this, 'teams_importer' ), + ), + 'sp_player_csv' => array( + 'name' => __( 'SportsPress Players (CSV)', 'sportspress' ), + 'description' => __( 'Import players from a csv file.', 'sportspress'), + 'callback' => array( $this, 'players_importer' ), + ), + 'sp_staff_csv' => array( + 'name' => __( 'SportsPress Staff (CSV)', 'sportspress' ), + 'description' => __( 'Import staff from a csv file.', 'sportspress'), + 'callback' => array( $this, 'staff_importer' ), + ), + ) ); + + foreach ( $importers as $id => $importer ) { + register_importer( $id, $importer['name'], $importer['description'], $importer['callback'] ); } - register_importer( 'sp_player_csv', __( 'SportsPress Players (CSV)', 'sportspress' ), __( 'Import players from a csv file.', 'sportspress'), array( $this, 'players_importer' ) ); - register_importer( 'sp_staff_csv', __( 'SportsPress Staff (CSV)', 'sportspress' ), __( 'Import staff from a csv file.', 'sportspress'), array( $this, 'staff_importer' ) ); } /** diff --git a/includes/admin/class-sp-admin-menus.php b/includes/admin/class-sp-admin-menus.php index 05c4771d..27fef654 100755 --- a/includes/admin/class-sp-admin-menus.php +++ b/includes/admin/class-sp-admin-menus.php @@ -85,16 +85,17 @@ class SP_Admin_Menus { public function menu_highlight() { global $typenow; $screen = get_current_screen(); - if ( $screen->id == 'sp_role' ) + if ( $screen->id == 'sp_role' ) { $this->highlight_admin_menu( 'edit.php?post_type=sp_staff', 'edit-tags.php?taxonomy=sp_role&post_type=sp_staff' ); - elseif ( is_sp_config_type( $typenow ) ) + } elseif ( is_sp_config_type( $typenow ) ) { $this->highlight_admin_menu( 'sportspress', 'sportspress-config' ); - elseif ( $typenow == 'sp_calendar' ) + } elseif ( $typenow == 'sp_calendar' ) { $this->highlight_admin_menu( 'edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar' ); - elseif ( $typenow == 'sp_table' ) + } elseif ( $typenow == 'sp_table' ) { $this->highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' ); - elseif ( $typenow == 'sp_list' ) + } elseif ( $typenow == 'sp_list' ) { $this->highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_list' ); + } } /** diff --git a/includes/admin/class-sp-admin-post-types.php b/includes/admin/class-sp-admin-post-types.php index 6e15ab32..0ac98f81 100644 --- a/includes/admin/class-sp-admin-post-types.php +++ b/includes/admin/class-sp-admin-post-types.php @@ -30,23 +30,21 @@ class SP_Admin_Post_Types { * Conditonally load classes and functions only needed when viewing a post type. */ public function include_post_type_handlers() { - include( 'post-types/class-sp-admin-meta-boxes.php' ); - include( 'post-types/class-sp-admin-cpt-result.php' ); - include( 'post-types/class-sp-admin-cpt-outcome.php' ); - include( 'post-types/class-sp-admin-cpt-performance.php' ); - include( 'post-types/class-sp-admin-cpt-column.php' ); - include( 'post-types/class-sp-admin-cpt-metric.php' ); - include( 'post-types/class-sp-admin-cpt-statistic.php' ); - include( 'post-types/class-sp-admin-cpt-event.php' ); - if ( 'yes' == get_option( 'sportspress_load_calendars_module', 'yes' ) ) - include( 'post-types/class-sp-admin-cpt-calendar.php' ); - include( 'post-types/class-sp-admin-cpt-team.php' ); + include_once( 'post-types/class-sp-admin-meta-boxes.php' ); + include_once( 'post-types/class-sp-admin-cpt-result.php' ); + include_once( 'post-types/class-sp-admin-cpt-outcome.php' ); + include_once( 'post-types/class-sp-admin-cpt-performance.php' ); + include_once( 'post-types/class-sp-admin-cpt-column.php' ); + include_once( 'post-types/class-sp-admin-cpt-metric.php' ); + include_once( 'post-types/class-sp-admin-cpt-statistic.php' ); + include_once( 'post-types/class-sp-admin-cpt-event.php' ); + include_once( 'post-types/class-sp-admin-cpt-team.php' ); if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) - include( 'post-types/class-sp-admin-cpt-table.php' ); - include( 'post-types/class-sp-admin-cpt-player.php' ); + include_once( 'post-types/class-sp-admin-cpt-table.php' ); + include_once( 'post-types/class-sp-admin-cpt-player.php' ); if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) ) - include( 'post-types/class-sp-admin-cpt-list.php' ); - include( 'post-types/class-sp-admin-cpt-staff.php' ); + include_once( 'post-types/class-sp-admin-cpt-list.php' ); + include_once( 'post-types/class-sp-admin-cpt-staff.php' ); do_action( 'sportspress_include_post_type_handlers' ); } diff --git a/includes/admin/class-sp-admin-sample-data.php b/includes/admin/class-sp-admin-sample-data.php index d7db3ff7..65ac63ba 100644 --- a/includes/admin/class-sp-admin-sample-data.php +++ b/includes/admin/class-sp-admin-sample-data.php @@ -128,40 +128,6 @@ class SP_Admin_Sample_Data { ), ); - /* - * Insert teams - */ - if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { - foreach ( $teams as $index => $team ) { - $post['post_title'] = $team['name']; - $post['post_type'] = 'sp_team'; - $post['post_status'] = 'publish'; - $post['post_content'] = sprintf( $sample_content, __( 'Team', 'sportspress' ), __( 'Teams', 'sportspress' ), admin_url() ); - - // Terms - $post['tax_input'] = array(); - $taxonomies = array( 'sp_league', 'sp_season' ); - foreach ( $taxonomies as $taxonomy ) { - $post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids' ) ); - }; - - $post['tax_input']['sp_venue'] = get_terms( 'sp_venue', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1, 'offset' => $index ) ); - - // Insert post - $id = wp_insert_post( $post ); - - // Add to inserted ids array - $inserted_ids['sp_team'][] = $id; - - // Flag as sample - update_post_meta( $id, '_sp_sample', 1 ); - - // Update meta - update_post_meta( $id, 'sp_abbreviation', $team['abbreviation'] ); - update_post_meta( $id, 'sp_url', $team['url'] ); - } - } - // Define players $players = array( 'Mario Bellucci', @@ -193,6 +159,38 @@ class SP_Admin_Sample_Data { // Get countries $countries = new SP_Countries(); + /* + * Insert teams + */ + foreach ( $teams as $index => $team ) { + $post['post_title'] = $team['name']; + $post['post_type'] = 'sp_team'; + $post['post_status'] = 'publish'; + $post['post_content'] = sprintf( $sample_content, __( 'Team', 'sportspress' ), __( 'Teams', 'sportspress' ), admin_url() ); + + // Terms + $post['tax_input'] = array(); + $taxonomies = array( 'sp_league', 'sp_season' ); + foreach ( $taxonomies as $taxonomy ) { + $post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids' ) ); + }; + + $post['tax_input']['sp_venue'] = get_terms( 'sp_venue', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1, 'offset' => $index ) ); + + // Insert post + $id = wp_insert_post( $post ); + + // Add to inserted ids array + $inserted_ids['sp_team'][] = $id; + + // Flag as sample + update_post_meta( $id, '_sp_sample', 1 ); + + // Update meta + update_post_meta( $id, 'sp_abbreviation', $team['abbreviation'] ); + update_post_meta( $id, 'sp_url', $team['url'] ); + } + // Get columns $columns = array( 'team' ); $args = array( @@ -347,175 +345,31 @@ class SP_Admin_Sample_Data { /* * Insert events */ - if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { - for ( $index = 0; $index < 6; $index ++ ) { - // Determine team index and post status - $i = $index % 3; - if ( $index < 3 ) { - $post_status = 'publish'; - $post_year = $current_year - 1; - $event_season = get_terms( 'sp_season', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) ); - } else { - $post_status = 'future'; - $post_year = $current_year + 1; - $event_season = get_terms( 'sp_season', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'DESC', 'number' => 1 ) ); - } - // The away team should be the next inserted team, or the first if this is the last event - if ( $i == 2 ) $away_index = 0; - else $away_index = $i + 1; - $post = array( - 'post_title' => $teams[ $i ]['name'] . ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ' . $teams[ $away_index ]['name'], - 'post_type' => 'sp_event', - 'post_status' => $post_status, - 'post_content' => sprintf( $sample_content, __( 'Event', 'sportspress' ), __( 'Events', 'sportspress' ), admin_url() ), - 'post_date' => $post_year . '-' . sprintf( '%02d', 3 + $i * 3 ) . '-' . sprintf( '%02d', 5 + $i * 10 ) . ' ' . ( 18 + $i ) . ':00:00', - 'tax_input' => array( - 'sp_league' => get_terms( 'sp_league', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) ), - 'sp_season' => $event_season, - 'sp_venue' => get_terms( 'sp_venue', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1, 'offset' => $i ) ), - ), - ); - - // Insert post - $id = wp_insert_post( $post ); - - // Add to inserted ids array - $inserted_ids['sp_event'][] = $id; - - // Flag as sample - update_post_meta( $id, '_sp_sample', 1 ); - - // Calculate home and away team ids - $home_team_index = ( $i ) % 3; - $away_team_index = ( $i + 1 ) % 3; - $home_team_id = sp_array_value( $inserted_ids['sp_team'], $home_team_index, 0 ); - $away_team_id = sp_array_value( $inserted_ids['sp_team'], $away_team_index, 0 ); - $event_teams = array( - $home_team_id, - $away_team_id, - ); - - // Initialize meta - $event_players = array( 0 ); - $performance = $results = array(); - - if ( $home_team_id ) { - // Add home team player performance - $performance[ $home_team_id ] = array(); - for ( $j = 0; $j < 4; $j ++ ) { - $player_id = sp_array_value( $inserted_ids['sp_player'], $home_team_index * 4 + $j ); - $event_players[] = $player_id; - $player_performance = array(); - foreach ( $performance_posts as $performance_post ) { - $player_performance[ $performance_post->post_name ] = rand( 0, 1 ); - } - $performance[ $home_team_id ][ $player_id ] = $player_performance; - } - - // Add home team results - $results[ $home_team_id ] = array(); - foreach ( $result_posts as $result_post_index => $result_post ) { - $results[ $home_team_id ][ $result_post->post_name ] = 1 + $result_post_index; - } - $outcome = reset( $outcome_posts ); - if ( is_object( $outcome ) ) $results[ $home_team_id ]['outcome'] = array( $outcome->post_name ); - } - - // Separate teams with zero - $event_players[] = 0; - - if ( $away_team_id ) { - $performance[ $away_team_id ] = array(); - for ( $j = 0; $j < 4; $j ++ ) { - $player_id = sp_array_value( $inserted_ids['sp_player'], $away_team_index * 4 + $j ); - $event_players[] = $player_id; - $player_performance = array(); - foreach ( $performance_posts as $performance_post ) { - $player_performance[ $performance_post->post_name ] = rand( 0, 1 ); - } - $performance[ $away_team_id ][ $player_id ] = $player_performance; - } - - // Add away team results - $results[ $away_team_id ] = array(); - foreach ( $result_posts as $result_post ) { - $results[ $away_team_id ][ $result_post->post_name ] = '0'; - } - $outcome = next( $outcome_posts ); - if ( is_object( $outcome ) ) $results[ $away_team_id ]['outcome'] = array( $outcome->post_name ); - } - - if ( 'publish' === $post_status ) { - // Swap results for last event only - if ( $i == 2 ) { - $k = array_keys( $results ); - $v = array_values( $results ); - $rv = array_reverse( $v ); - $results = array_combine( $k, $rv ); - } - - // Update future post meta - update_post_meta( $id, 'sp_players', $performance ); - update_post_meta( $id, 'sp_results', $results ); - } - - // Update general meta - sp_update_post_meta_recursive( $id, 'sp_team', $event_teams ); - sp_update_post_meta_recursive( $id, 'sp_player', $event_players ); - update_post_meta( $id, 'sp_columns', $columns ); - update_post_meta( $id, 'sp_format', 'league' ); - update_post_meta( $id, 'sp_video', $event_videos[ $i ] ); + for ( $index = 0; $index < 6; $index ++ ) { + // Determine team index and post status + $i = $index % 3; + if ( $index < 3 ) { + $post_status = 'publish'; + $post_year = $current_year - 1; + $event_season = get_terms( 'sp_season', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) ); + } else { + $post_status = 'future'; + $post_year = $current_year + 1; + $event_season = get_terms( 'sp_season', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'DESC', 'number' => 1 ) ); } - } - - /* - * Insert calendar - */ - if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { + // The away team should be the next inserted team, or the first if this is the last event + if ( $i == 2 ) $away_index = 0; + else $away_index = $i + 1; $post = array( - 'post_title' => _x( 'Fixtures & Results', 'example', 'sportspress' ), - 'post_type' => 'sp_calendar', - 'post_status' => 'publish', - 'post_content' => sprintf( $sample_content, __( 'Calendar', 'sportspress' ), __( 'Calendars', 'sportspress' ), admin_url() ) - ); - - // Insert post - $id = wp_insert_post( $post ); - - // Add to inserted ids array - $inserted_ids['sp_calendar'][] = $id; - - // Flag as sample - update_post_meta( $id, '_sp_sample', 1 ); - - // Define columns - $columns = array( 'event', 'time', 'article' ); - - // Update meta - update_post_meta( $id, 'sp_format', 'list' ); - update_post_meta( $id, 'sp_status', 'any' ); - update_post_meta( $id, 'sp_date', 0 ); - update_post_meta( $id, 'sp_team', 0 ); - update_post_meta( $id, 'sp_order', 'ASC' ); - update_post_meta( $id, 'sp_columns', $columns ); - } - - /* - * Insert league table - */ - if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { - $leagues = get_terms( 'sp_league', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) ); - $league = reset( $leagues ); - $seasons = get_terms( 'sp_season', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) ); - $season = reset( $seasons ); - $post = array( - 'post_title' => $league->name . ' ' . $season->name, - 'post_type' => 'sp_table', - 'post_status' => 'publish', - 'post_content' => sprintf( $sample_content, __( 'League Table', 'sportspress' ), __( 'League Tables', 'sportspress' ), admin_url() ), + 'post_title' => $teams[ $i ]['name'] . ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ' . $teams[ $away_index ]['name'], + 'post_type' => 'sp_event', + 'post_status' => $post_status, + 'post_content' => sprintf( $sample_content, __( 'Event', 'sportspress' ), __( 'Events', 'sportspress' ), admin_url() ), + 'post_date' => $post_year . '-' . sprintf( '%02d', 3 + $i * 3 ) . '-' . sprintf( '%02d', 5 + $i * 10 ) . ' ' . ( 18 + $i ) . ':00:00', 'tax_input' => array( - 'sp_league' => $league->term_id, - 'sp_season' => $season->term_id, + 'sp_league' => get_terms( 'sp_league', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) ), + 'sp_season' => $event_season, + 'sp_venue' => get_terms( 'sp_venue', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1, 'offset' => $i ) ), ), ); @@ -523,16 +377,196 @@ class SP_Admin_Sample_Data { $id = wp_insert_post( $post ); // Add to inserted ids array - $inserted_ids['sp_table'][] = $id; + $inserted_ids['sp_event'][] = $id; // Flag as sample update_post_meta( $id, '_sp_sample', 1 ); + // Calculate home and away team ids + $home_team_index = ( $i ) % 3; + $away_team_index = ( $i + 1 ) % 3; + $home_team_id = sp_array_value( $inserted_ids['sp_team'], $home_team_index, 0 ); + $away_team_id = sp_array_value( $inserted_ids['sp_team'], $away_team_index, 0 ); + $event_teams = array( + $home_team_id, + $away_team_id, + ); + + // Initialize meta + $event_players = array( 0 ); + $performance = $results = array(); + + if ( $home_team_id ) { + // Add home team player performance + $performance[ $home_team_id ] = array(); + for ( $j = 0; $j < 4; $j ++ ) { + $player_id = sp_array_value( $inserted_ids['sp_player'], $home_team_index * 4 + $j ); + $event_players[] = $player_id; + $player_performance = array(); + foreach ( $performance_posts as $performance_post ) { + $player_performance[ $performance_post->post_name ] = rand( 0, 1 ); + } + $performance[ $home_team_id ][ $player_id ] = $player_performance; + } + + // Add home team results + $results[ $home_team_id ] = array(); + foreach ( $result_posts as $result_post_index => $result_post ) { + $results[ $home_team_id ][ $result_post->post_name ] = 1 + $result_post_index; + } + $outcome = reset( $outcome_posts ); + if ( is_object( $outcome ) ) $results[ $home_team_id ]['outcome'] = array( $outcome->post_name ); + } + + // Separate teams with zero + $event_players[] = 0; + + if ( $away_team_id ) { + $performance[ $away_team_id ] = array(); + for ( $j = 0; $j < 4; $j ++ ) { + $player_id = sp_array_value( $inserted_ids['sp_player'], $away_team_index * 4 + $j ); + $event_players[] = $player_id; + $player_performance = array(); + foreach ( $performance_posts as $performance_post ) { + $player_performance[ $performance_post->post_name ] = rand( 0, 1 ); + } + $performance[ $away_team_id ][ $player_id ] = $player_performance; + } + + // Add away team results + $results[ $away_team_id ] = array(); + foreach ( $result_posts as $result_post ) { + $results[ $away_team_id ][ $result_post->post_name ] = '0'; + } + $outcome = next( $outcome_posts ); + if ( is_object( $outcome ) ) $results[ $away_team_id ]['outcome'] = array( $outcome->post_name ); + } + + if ( 'publish' === $post_status ) { + // Swap results for last event only + if ( $i == 2 ) { + $k = array_keys( $results ); + $v = array_values( $results ); + $rv = array_reverse( $v ); + $results = array_combine( $k, $rv ); + } + + // Update future post meta + update_post_meta( $id, 'sp_players', $performance ); + update_post_meta( $id, 'sp_results', $results ); + } + + // Update general meta + sp_update_post_meta_recursive( $id, 'sp_team', $event_teams ); + sp_update_post_meta_recursive( $id, 'sp_player', $event_players ); + update_post_meta( $id, 'sp_columns', $columns ); + update_post_meta( $id, 'sp_format', 'league' ); + update_post_meta( $id, 'sp_video', $event_videos[ $i ] ); + } + + /* + * Insert calendar + */ + $post = array( + 'post_title' => _x( 'Fixtures & Results', 'example', 'sportspress' ), + 'post_type' => 'sp_calendar', + 'post_status' => 'publish', + 'post_content' => sprintf( $sample_content, __( 'Calendar', 'sportspress' ), __( 'Calendars', 'sportspress' ), admin_url() ) + ); + + // Insert post + $id = wp_insert_post( $post ); + + // Add to inserted ids array + $inserted_ids['sp_calendar'][] = $id; + + // Flag as sample + update_post_meta( $id, '_sp_sample', 1 ); + + // Define columns + $columns = array( 'event', 'time', 'article' ); + + // Update meta + update_post_meta( $id, 'sp_format', 'list' ); + update_post_meta( $id, 'sp_status', 'any' ); + update_post_meta( $id, 'sp_date', 0 ); + update_post_meta( $id, 'sp_team', 0 ); + update_post_meta( $id, 'sp_order', 'ASC' ); + update_post_meta( $id, 'sp_columns', $columns ); + + /* + * Insert league table + */ + $leagues = get_terms( 'sp_league', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) ); + $league = reset( $leagues ); + $seasons = get_terms( 'sp_season', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) ); + $season = reset( $seasons ); + $post = array( + 'post_title' => $league->name . ' ' . $season->name, + 'post_type' => 'sp_table', + 'post_status' => 'publish', + 'post_content' => sprintf( $sample_content, __( 'League Table', 'sportspress' ), __( 'League Tables', 'sportspress' ), admin_url() ), + 'tax_input' => array( + 'sp_league' => $league->term_id, + 'sp_season' => $season->term_id, + ), + ); + + // Insert post + $id = wp_insert_post( $post ); + + // Add to inserted ids array + $inserted_ids['sp_table'][] = $id; + + // Flag as sample + update_post_meta( $id, '_sp_sample', 1 ); + + // Get columns + $columns = array(); + $args = array( + 'post_type' => 'sp_column', + 'posts_per_page' => 8, + 'orderby' => 'menu_order', + 'order' => 'ASC', + ); + $column_posts = get_posts( $args ); + foreach ( $column_posts as $column_post ) { + $columns[] = $column_post->post_name; + } + + // Update meta + sp_update_post_meta_recursive( $id, 'sp_team', $inserted_ids['sp_team'] ); + update_post_meta( $id, 'sp_columns', $columns ); + update_post_meta( $id, 'sp_highlight', reset( $inserted_ids['sp_team'] ) ); + + /* + * Insert player list for each team + */ + foreach ( $inserted_ids['sp_team'] as $index => $team_id ) { + $post = array( + 'post_title' => get_the_title( $team_id ) . ' ' . _x( 'Roster', 'example', 'sportspress' ), + 'post_type' => 'sp_list', + 'post_status' => 'publish', + 'post_content' => sprintf( $sample_content, __( 'Player List', 'sportspress' ), __( 'Player Lists', 'sportspress' ), admin_url() ), + ); + + // Insert post + $id = wp_insert_post( $post ); + + // Add to inserted ids array + $inserted_ids['sp_list'][] = $id; + + // Flag as sample + update_post_meta( $id, '_sp_sample', 1 ); + + // Get players from team + $list_players = array_slice( $inserted_ids['sp_player'], $index * 4, 4 ); + // Get columns $columns = array(); $args = array( - 'post_type' => 'sp_column', - 'posts_per_page' => 8, + 'post_type' => array( 'sp_metric' ), + 'posts_per_page' => 2, 'orderby' => 'menu_order', 'order' => 'ASC', ); @@ -542,57 +576,13 @@ class SP_Admin_Sample_Data { } // Update meta - sp_update_post_meta_recursive( $id, 'sp_team', $inserted_ids['sp_team'] ); + update_post_meta( $id, 'sp_format', 'list' ); + sp_update_post_meta_recursive( $id, 'sp_player', $list_players ); update_post_meta( $id, 'sp_columns', $columns ); - update_post_meta( $id, 'sp_highlight', reset( $inserted_ids['sp_team'] ) ); - } - - /* - * Insert player list for each team - */ - if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { - foreach ( $inserted_ids['sp_team'] as $index => $team_id ) { - $post = array( - 'post_title' => get_the_title( $team_id ) . ' ' . _x( 'Roster', 'example', 'sportspress' ), - 'post_type' => 'sp_list', - 'post_status' => 'publish', - 'post_content' => sprintf( $sample_content, __( 'Player List', 'sportspress' ), __( 'Player Lists', 'sportspress' ), admin_url() ), - ); - - // Insert post - $id = wp_insert_post( $post ); - - // Add to inserted ids array - $inserted_ids['sp_list'][] = $id; - - // Flag as sample - update_post_meta( $id, '_sp_sample', 1 ); - - // Get players from team - $list_players = array_slice( $inserted_ids['sp_player'], $index * 4, 4 ); - - // Get columns - $columns = array(); - $args = array( - 'post_type' => array( 'sp_metric' ), - 'posts_per_page' => 2, - 'orderby' => 'menu_order', - 'order' => 'ASC', - ); - $column_posts = get_posts( $args ); - foreach ( $column_posts as $column_post ) { - $columns[] = $column_post->post_name; - } - - // Update meta - update_post_meta( $id, 'sp_format', 'list' ); - sp_update_post_meta_recursive( $id, 'sp_player', $list_players ); - update_post_meta( $id, 'sp_columns', $columns ); - update_post_meta( $id, 'sp_grouping', 'position' ); - update_post_meta( $id, 'sp_orderby', 'name' ); - update_post_meta( $id, 'sp_order', 'ASC' ); - update_post_meta( $id, 'sp_team', $team_id ); - } + update_post_meta( $id, 'sp_grouping', 'position' ); + update_post_meta( $id, 'sp_orderby', 'name' ); + update_post_meta( $id, 'sp_order', 'ASC' ); + update_post_meta( $id, 'sp_team', $team_id ); } /* @@ -630,11 +620,9 @@ class SP_Admin_Sample_Data { /* * Update player list and league table per team */ - if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { - foreach ( $inserted_ids['sp_team'] as $index => $team_id ) { - update_post_meta( $team_id, 'sp_list', sp_array_value( $inserted_ids['sp_list'], $index, 0 ) ); - update_post_meta( $team_id, 'sp_table', sp_array_value( $inserted_ids['sp_table'], 0 ) ); - } + foreach ( $inserted_ids['sp_team'] as $index => $team_id ) { + update_post_meta( $team_id, 'sp_list', sp_array_value( $inserted_ids['sp_list'], $index, 0 ) ); + update_post_meta( $team_id, 'sp_table', sp_array_value( $inserted_ids['sp_table'], 0 ) ); } } diff --git a/includes/admin/class-sp-admin-settings.php b/includes/admin/class-sp-admin-settings.php index 775e2cd9..937921b6 100644 --- a/includes/admin/class-sp-admin-settings.php +++ b/includes/admin/class-sp-admin-settings.php @@ -34,10 +34,7 @@ class SP_Admin_Settings { $settings[] = include( 'settings/class-sp-settings-modules.php' ); $settings[] = include( 'settings/class-sp-settings-general.php' ); $settings[] = include( 'settings/class-sp-settings-events.php' ); - - if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) - $settings[] = include( 'settings/class-sp-settings-teams.php' ); - + $settings[] = include( 'settings/class-sp-settings-teams.php' ); $settings[] = include( 'settings/class-sp-settings-players.php' ); $settings[] = include( 'settings/class-sp-settings-staff.php' ); diff --git a/includes/admin/class-sp-admin-welcome.php b/includes/admin/class-sp-admin-welcome.php index 5285618b..35f2e04e 100644 --- a/includes/admin/class-sp-admin-welcome.php +++ b/includes/admin/class-sp-admin-welcome.php @@ -166,8 +166,8 @@ class SP_Admin_Welcome { 'sportspress', 'tab' => 'general' ), 'admin.php' ) ) ); ?>">

    - +

    + array( + 'link' => admin_url( add_query_arg( array( 'post_type' => 'sp_team' ), 'edit.php' ) ), + 'icon' => 'dashicons-shield-alt', + 'label' => __( 'Add New Team', 'sportspress' ), + ), + 'players' => array( + 'link' => admin_url( add_query_arg( array( 'post_type' => 'sp_player' ), 'edit.php' ) ), + 'icon' => 'dashicons-groups', + 'label' => __( 'Add New Player', 'sportspress' ), + ), + 'events' => array( + 'link' => admin_url( add_query_arg( array( 'post_type' => 'sp_event' ), 'edit.php' ) ), + 'icon' => 'dashicons-calendar', + 'label' => __( 'Add New Event', 'sportspress' ), + ), + ) ); + ?> +
    +
    @@ -262,12 +281,12 @@ class SP_Admin_Welcome { array( 'title' => __( 'Mode', 'sportspress' ), - 'id' => 'sportspress_mode', - 'default' => 'team', + 'id' => 'sportspress_load_individual_mode_module', + 'default' => 'no', 'type' => 'radio', 'options' => array( - 'team' => __( 'Teams', 'sportspress' ), - 'player' => __( 'Players', 'sportspress' ) . ' ' . __( '(Beta)', 'sportspress' ), + 'no' => __( 'Team vs team', 'sportspress' ), + 'yes' => __( 'Player vs player', 'sportspress' ), ), 'desc_tip' => _x( 'Who competes in events?', 'mode setting description', 'sportspress' ), ), diff --git a/includes/admin/post-types/class-sp-admin-meta-boxes.php b/includes/admin/post-types/class-sp-admin-meta-boxes.php index e91fc340..c1200ccb 100644 --- a/includes/admin/post-types/class-sp-admin-meta-boxes.php +++ b/includes/admin/post-types/class-sp-admin-meta-boxes.php @@ -17,40 +17,148 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly */ class SP_Admin_Meta_Boxes { + /** + * @var array + */ + public $meta_boxes = null; + /** * Constructor */ public function __construct() { + $meta_boxes = array( + 'sp_result' => array( + 'details' => array( + 'title' => __( 'Details', 'sportspress' ), + 'save' => 'SP_Meta_Box_Result_Details::save', + 'output' => 'SP_Meta_Box_Result_Details::output', + 'context' => 'normal', + 'priority' => 'high', + ), + ), + 'sp_outcome' => array( + 'details' => array( + 'title' => __( 'Details', 'sportspress' ), + 'save' => 'SP_Meta_Box_Outcome_Details::save', + 'output' => 'SP_Meta_Box_Outcome_Details::output', + 'context' => 'normal', + 'priority' => 'high', + ), + ), + 'sp_metric' => array( + 'details' => array( + 'title' => __( 'Details', 'sportspress' ), + 'save' => 'SP_Meta_Box_Metric_Details::save', + 'output' => 'SP_Meta_Box_Metric_Details::output', + 'context' => 'normal', + 'priority' => 'high', + ), + ), + 'sp_outcome' => array( + 'details' => array( + 'title' => __( 'Details', 'sportspress' ), + 'save' => 'SP_Meta_Box_Metric_Details::save', + 'output' => 'SP_Meta_Box_Metric_Details::output', + 'context' => 'normal', + 'priority' => 'high', + ), + ), + 'sp_performance' => array( + 'details' => array( + 'title' => __( 'Details', 'sportspress' ), + 'save' => 'SP_Meta_Box_Performance_Details::save', + 'output' => 'SP_Meta_Box_Performance_Details::output', + 'context' => 'normal', + 'priority' => 'high', + ), + ), + 'sp_statistic' => array( + 'details' => array( + 'title' => __( 'Details', 'sportspress' ), + 'save' => 'SP_Meta_Box_Statistic_Details::save', + 'output' => 'SP_Meta_Box_Statistic_Details::output', + 'context' => 'side', + 'priority' => 'default', + ), + 'equation' => array( + 'title' => __( 'Equation', 'sportspress' ), + 'save' => 'SP_Meta_Box_Statistic_Equation::save', + 'output' => 'SP_Meta_Box_Statistic_Equation::output', + 'context' => 'normal', + 'priority' => 'high', + ), + ), + 'sp_column' => array( + 'details' => array( + 'title' => __( 'Details', 'sportspress' ), + 'save' => 'SP_Meta_Box_Column_Details::save', + 'output' => 'SP_Meta_Box_Column_Details::output', + 'context' => 'side', + 'priority' => 'default', + ), + 'equation' => array( + 'title' => __( 'Equation', 'sportspress' ), + 'save' => 'SP_Meta_Box_Column_Equation::save', + 'output' => 'SP_Meta_Box_Column_Equation::output', + 'context' => 'normal', + 'priority' => 'high', + ), + ), + 'sp_event' => array( + 'shortcode' => array( + 'title' => __( 'Shortcodes', 'sportspress' ), + 'output' => 'SP_Meta_Box_Event_Shortcode::output', + 'context' => 'side', + 'priority' => 'default', + ), + 'format' => array( + 'title' => __( 'Format', 'sportspress' ), + 'save' => 'SP_Meta_Box_Event_Format::save', + 'output' => 'SP_Meta_Box_Event_Format::output', + 'context' => 'side', + 'priority' => 'default', + ), + 'details' => array( + 'title' => __( 'Details', 'sportspress' ), + 'save' => 'SP_Meta_Box_Event_Details::save', + 'output' => 'SP_Meta_Box_Event_Details::output', + 'context' => 'side', + 'priority' => 'default', + ), + 'team' => array( + 'title' => __( 'Teams', 'sportspress' ), + 'save' => 'SP_Meta_Box_Event_Teams::save', + 'output' => 'SP_Meta_Box_Event_Teams::output', + 'context' => 'side', + 'priority' => 'default', + ), + 'editor' => array( + 'title' => __( 'Article', 'sportspress' ), + 'output' => 'SP_Meta_Box_Event_Editor::output', + 'context' => 'normal', + 'priority' => 'low', + ), + ), + ); + + $this->meta_boxes = apply_filters( 'sportspress_meta_boxes', $meta_boxes ); + + foreach ( $this->meta_boxes as $post_type => $meta_boxes ) { + $i = 0; + foreach ( $meta_boxes as $id => $meta_box ) { + if ( array_key_exists( 'save', $meta_box ) ) { + add_action( 'sportspress_process_' . $post_type . '_meta', $meta_box['save'], ( $i + 1 ) * 10, 2 ); + } + $i++; + } + } + add_action( 'add_meta_boxes', array( $this, 'remove_meta_boxes' ), 10 ); add_action( 'add_meta_boxes', array( $this, 'rename_meta_boxes' ), 20 ); add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 30 ); add_action( 'save_post', array( $this, 'save_meta_boxes' ), 1, 2 ); - // Save Result Meta Boxes - add_action( 'sportspress_process_sp_result_meta', 'SP_Meta_Box_Result_Details::save', 10, 2 ); - - // Save Outcome Meta Boxes - add_action( 'sportspress_process_sp_outcome_meta', 'SP_Meta_Box_Outcome_Details::save', 10, 2 ); - - // Save Metric Meta Boxes - add_action( 'sportspress_process_sp_metric_meta', 'SP_Meta_Box_Metric_Details::save', 10, 2 ); - - // Save Performance Meta Boxes - add_action( 'sportspress_process_sp_performance_meta', 'SP_Meta_Box_Performance_Details::save', 10, 2 ); - - // Save Statistic Meta Boxes - add_action( 'sportspress_process_sp_statistic_meta', 'SP_Meta_Box_Statistic_Details::save', 10, 2 ); - add_action( 'sportspress_process_sp_statistic_meta', 'SP_Meta_Box_Statistic_Equation::save', 20, 2 ); - - // Save Column Meta Boxes - add_action( 'sportspress_process_sp_column_meta', 'SP_Meta_Box_Column_Details::save', 10, 2 ); - add_action( 'sportspress_process_sp_column_meta', 'SP_Meta_Box_Column_Equation::save', 20, 2 ); - // Save Event Meta Boxes - add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Format::save', 10, 2 ); - add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Details::save', 20, 2 ); - add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Teams::save', 30, 2 ); - add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Video::save', 40, 2 ); add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Results::save', 50, 2 ); add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Performance::save', 60, 2 ); @@ -95,61 +203,29 @@ class SP_Admin_Meta_Boxes { public function add_meta_boxes() { global $post; + foreach ( $this->meta_boxes as $post_type => $meta_boxes ) { + foreach ( $meta_boxes as $id => $meta_box ) { + if ( array_key_exists( 'output', $meta_box ) ) { + add_meta_box( 'sp_' . $id . 'div', $meta_box['title'], $meta_box['output'], $post_type, $meta_box['context'], $meta_box['priority'] ); + } + } + } + // Get post meta array if ( isset( $post ) && isset( $post->ID ) ) $post_meta = get_post_meta( $post->ID ); else $post_meta = array(); - // Results - add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Result_Details::output', 'sp_result', 'normal', 'high' ); - - // Outcomes - add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Outcome_Details::output', 'sp_outcome', 'normal', 'high' ); - - // Columns - add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Column_Details::output', 'sp_column', 'side', 'default' ); - add_meta_box( 'sp_equationdiv', __( 'Equation', 'sportspress' ), 'SP_Meta_Box_Column_Equation::output', 'sp_column', 'normal', 'high' ); - - // Metrics - add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Metric_Details::output', 'sp_metric', 'normal', 'high' ); - - // Performance - add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Performance_Details::output', 'sp_performance', 'normal', 'high' ); - - // Statistics - add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Statistic_Details::output', 'sp_statistic', 'side', 'default' ); - add_meta_box( 'sp_equationdiv', __( 'Equation', 'sportspress' ), 'SP_Meta_Box_Statistic_Equation::output', 'sp_statistic', 'normal', 'high' ); - // Events - add_meta_box( 'sp_shortcodediv', __( 'Shortcodes', 'sportspress' ), 'SP_Meta_Box_Event_Shortcode::output', 'sp_event', 'side', 'default' ); - add_meta_box( 'sp_formatdiv', __( 'Format', 'sportspress' ), 'SP_Meta_Box_Event_Format::output', 'sp_event', 'side', 'default' ); - add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Event_Details::output', 'sp_event', 'side', 'default' ); - add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'SP_Meta_Box_Event_Teams::output', 'sp_event', 'side', 'default' ); - if ( 'yes' == get_option( 'sportspress_load_videos_module', 'yes' ) ) { - add_meta_box( 'sp_videodiv', __( 'Video', 'sportspress' ), 'SP_Meta_Box_Event_Video::output', 'sp_event', 'side', 'low' ); - } - $teams = array_filter( sp_array_value( $post_meta, 'sp_team', array() ), array( $this, 'positive' ) ); + $teams = array_filter( sp_array_value( $post_meta, 'sp_team', array() ), 'sp_filter_positive' ); if ( ! empty( $teams ) ) { - add_meta_box( 'sp_resultsdiv', __( 'Team Results', 'sportspress' ), 'SP_Meta_Box_Event_Results::output', 'sp_event', 'normal', 'high' ); + add_meta_box( 'sp_resultsdiv', __( 'Event Results', 'sportspress' ), 'SP_Meta_Box_Event_Results::output', 'sp_event', 'normal', 'high' ); } - $players = array_filter( sp_array_value( $post_meta, 'sp_player', array() ), array( $this, 'positive' ) ); + $players = array_filter( sp_array_value( $post_meta, 'sp_player', array() ), 'sp_filter_positive' ); if ( ! empty( $players ) ) { add_meta_box( 'sp_performancediv', __( 'Player Performance', 'sportspress' ), 'SP_Meta_Box_Event_Performance::output', 'sp_event', 'normal', 'high' ); } - add_meta_box( 'sp_editordiv', __( 'Article', 'sportspress' ), 'SP_Meta_Box_Event_Editor::output', 'sp_event', 'normal', 'low' ); - - if ( 'yes' == get_option( 'sportspress_load_calendars_module', 'yes' ) ) { - // Calendars - add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_Calendar_Shortcode::output', 'sp_calendar', 'side', 'default' ); - if ( isset( $post ) && 'publish' == $post->post_status ): - add_meta_box( 'sp_feedsdiv', __( 'Feeds', 'sportspress' ), 'SP_Meta_Box_Calendar_Feeds::output', 'sp_calendar', 'side', 'default' ); - endif; - add_meta_box( 'sp_formatdiv', __( 'Layout', 'sportspress' ), 'SP_Meta_Box_Calendar_Format::output', 'sp_calendar', 'side', 'default' ); - add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Calendar_Details::output', 'sp_calendar', 'side', 'default' ); - add_meta_box( 'sp_datadiv', __( 'Events', 'sportspress' ), 'SP_Meta_Box_Calendar_Data::output', 'sp_calendar', 'normal', 'high' ); - add_meta_box( 'sp_editordiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_Calendar_Editor::output', 'sp_calendar', 'normal', 'low' ); - } // Teams add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Team_Details::output', 'sp_team', 'side', 'default' ); @@ -269,13 +345,6 @@ class SP_Admin_Meta_Boxes { do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post ); } - /* - * Array filter removes values that are not positive. - */ - public function positive( $var = 0 ) { - return $var > 0; - } - } new SP_Admin_Meta_Boxes(); diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php index 8766c92a..088c511b 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php @@ -104,23 +104,21 @@ class SP_Meta_Box_Calendar_Details { endif; ?>

    - -

    -

    - __( 'All', 'sportspress' ), - 'post_type' => 'sp_team', - 'name' => 'sp_team', - 'selected' => $team_id, - 'values' => 'ID' - ); - if ( ! sp_dropdown_pages( $args ) ): - sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) ); - endif; - ?> -

    - +

    +

    + __( 'All', 'sportspress' ), + 'post_type' => 'sp_team', + 'name' => 'sp_team', + 'selected' => $team_id, + 'values' => 'ID' + ); + if ( ! sp_dropdown_pages( $args ) ): + sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) ); + endif; + ?> +

    - +

    + 'sp_team', + 'name' => 'sp_team[]', + 'class' => 'sportspress-pages', + 'show_option_none' => __( '— None —', 'sportspress' ), + 'values' => 'ID', + 'selected' => $team, + ); + sp_dropdown_pages( $args ); + ?> +

    + + ID, 'sp_player', 'block', array( 'sp_league', 'sp_season', 'sp_current_team' ), $i ); - sp_post_checklist( $post->ID, 'sp_staff', 'none', array( 'sp_league', 'sp_season', 'sp_current_team' ), $i ); + foreach ( $tabs as $index => $post_type ) { + sp_post_checklist( $post->ID, $post_type, ( 0 == $index ? 'block' : 'none' ), array( 'sp_league', 'sp_season', 'sp_current_team' ), $i ); + } ?> + - - - + $label ): ?>