diff --git a/includes/admin/class-sp-admin-sports.php b/includes/admin/class-sp-admin-sports.php index a7aae40f..c329636b 100644 --- a/includes/admin/class-sp-admin-sports.php +++ b/includes/admin/class-sp-admin-sports.php @@ -166,6 +166,7 @@ class SP_Admin_Sports { } update_post_meta( $id, 'sp_icon', sp_array_value( $performance, 'icon', null ) ); update_post_meta( $id, 'sp_color', sp_array_value( $performance, 'color', null ) ); + update_post_meta( $id, 'sp_section', sp_array_value( $performance, 'section', -1 ) ); $i ++; } diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-teams.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-teams.php index 19d44ef2..798f9cdd 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-teams.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-teams.php @@ -62,19 +62,58 @@ class SP_Meta_Box_Event_Teams { } ?>
- + __( 'Offense', 'sportspress' ), + 'post_type' => 'sp_player', + ); + $tabs['sp_defense'] = array( + 'label' => __( 'Defense', 'sportspress' ), + 'post_type' => 'sp_player', + ); + } elseif ( 1 == $sections ) { + $tabs['sp_defense'] = array( + 'label' => __( 'Defense', 'sportspress' ), + 'post_type' => 'sp_player', + ); + $tabs['sp_offense'] = array( + 'label' => __( 'Offense', 'sportspress' ), + 'post_type' => 'sp_player', + ); + } else { + $tabs['sp_player'] = array( + 'label' => __( 'Players', 'sportspress' ), + 'post_type' => 'sp_player', + ); + } + $tabs['sp_staff'] = array( + 'label' => __( 'Staff', 'sportspress' ), + 'post_type' => 'sp_staff', + ); + ?> $post_type ) { - do_action( 'sportspress_event_teams_meta_box_checklist', $post->ID, $post_type, ( 0 == $index ? 'block' : 'none' ), $team, $i ); + $j = 0; + foreach ( $tabs as $slug => $tab ) { + do_action( 'sportspress_event_teams_meta_box_checklist', $post->ID, $tab['post_type'], ( 0 == $j ? 'block' : 'none' ), $team, $i, $slug ); if ( apply_filters( 'sportspress_event_teams_meta_box_default_checklist', true ) ) { - sp_post_checklist( $post->ID, $post_type, ( 0 == $index ? 'block' : 'none' ), array( 'sp_league', 'sp_season', 'sp_current_team' ), $i ); + sp_post_checklist( $post->ID, $tab['post_type'], ( 0 == $j ? 'block' : 'none' ), array( 'sp_league', 'sp_season', 'sp_current_team' ), $i, $slug ); } + $j++; } ?> @@ -107,11 +146,16 @@ class SP_Meta_Box_Event_Teams { */ public static function save( $post_id, $post ) { sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); - $tabs = apply_filters( 'sportspress_event_team_tabs', array( 'sp_player', 'sp_staff' ) ); - if ( $tabs ) { - foreach ( $tabs as $post_type ) { - sp_update_post_meta_recursive( $post_id, $post_type, sp_array_value( $_POST, $post_type, array() ) ); - } + $tabs = array(); + $sections = get_option( 'sportspress_event_performance_sections', -1 ); + if ( -1 == $sections ) { + sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) ); + } else { + $players = array_merge( sp_array_value( $_POST, 'sp_offense', array() ), sp_array_value( $_POST, 'sp_defense', array() ) ); + sp_update_post_meta_recursive( $post_id, 'sp_offense', sp_array_value( $_POST, 'sp_offense', array() ) ); + sp_update_post_meta_recursive( $post_id, 'sp_defense', sp_array_value( $_POST, 'sp_defense', array() ) ); + sp_update_post_meta_recursive( $post_id, 'sp_player', $players ); } + sp_update_post_meta_recursive( $post_id, 'sp_staff', sp_array_value( $_POST, 'sp_staff', array() ) ); } } diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-details.php index efeb8b87..71b13d22 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-details.php @@ -29,12 +29,51 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config { } else { $readonly = false; } + $section = get_post_meta( $post->ID, 'sp_section', true ); + if ( '' === $section ) { + $section = -1; + } + $format = get_post_meta( $post->ID, 'sp_format', true ); + if ( '' === $format ) { + $format = 'number'; + } ?>
readonly="readonly">
++
+ +
++
+ +
__( 'Split players by team', 'sportspress' ), - 'id' => 'sportspress_event_split_players_by_team', - 'default' => 'yes', - 'type' => 'checkbox', - 'checkboxgroup' => '', - ), - - array( - 'desc' => __( 'Split players by position', 'sportspress' ), - 'id' => 'sportspress_event_split_players_by_position', - 'default' => 'no', - 'type' => 'checkbox', - 'checkboxgroup' => 'end', + 'title' => __( 'Performance', 'sportspress' ), + 'id' => 'sportspress_event_performance_sections', + 'default' => -1, + 'type' => 'radio', + 'options' => array( + -1 => __( 'Combined', 'sportspress' ), + 0 => __( 'Offense', 'sportspress' ) . ' → ' . __( 'Defense', 'sportspress' ), + 1 => __( 'Defense', 'sportspress' ) . ' → ' . __( 'Offense', 'sportspress' ), + ), ), array( diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index d999e304..e891aee1 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -449,6 +449,41 @@ if ( !function_exists( 'sp_get_post_order' ) ) { } } +if ( !function_exists( 'sp_get_post_section' ) ) { + function sp_get_post_section( $post_id ) { + $section = get_post_meta ( $post_id, 'sp_section', true ); + if ( isset( $section ) ): + $options = apply_filters( 'sportspress_performance_sections', array( -1 => __( 'All', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) ); + return sp_array_value( $options, $section, __( 'All', 'sportspress' ) ); + else: + return __( 'All', 'sportspress' ); + endif; + } +} + +if ( !function_exists( 'sp_get_post_format' ) ) { + function sp_get_post_format( $post_id ) { + $format = get_post_meta ( $post_id, 'sp_format', true ); + if ( isset( $format ) ): + $options = apply_filters( 'sportspress_performance_formats', array( 'number' => __( 'Number', 'sportspress' ), 'time' => __( 'Time', 'sportspress' ), 'text' => __( 'Text', 'sportspress' ) ) ); + return sp_array_value( $options, $format, __( 'Number', 'sportspress' ) ); + else: + return __( 'Number', 'sportspress' ); + endif; + } +} + +if ( !function_exists( 'sp_get_format_placeholder' ) ) { + function sp_get_format_placeholder( $key = 'number' ) { + $placeholders = apply_filters( 'sportspress_format_placeholders', array( + 'number' => 0, + 'time' => '0:00', + 'text' => '', + ) ); + return sp_array_value( $placeholders, $key, 0 ); + } +} + if ( !function_exists( 'sp_dropdown_statuses' ) ) { function sp_dropdown_statuses( $args = array() ) { $defaults = array( @@ -786,12 +821,14 @@ if ( !function_exists( 'sp_posts' ) ) { } if ( !function_exists( 'sp_post_checklist' ) ) { - function sp_post_checklist( $post_id = null, $meta = 'post', $display = 'block', $filters = null, $index = null ) { + function sp_post_checklist( $post_id = null, $meta = 'post', $display = 'block', $filters = null, $index = null, $slug = null ) { if ( ! isset( $post_id ) ) global $post_id; + if ( ! isset( $slug ) ) + $slug = $meta; ?> -