diff --git a/modules/sportspress-individual-mode.php b/modules/sportspress-individual-mode.php index fa453ffe..245d306b 100644 --- a/modules/sportspress-individual-mode.php +++ b/modules/sportspress-individual-mode.php @@ -5,7 +5,7 @@ Plugin URI: http://themeboy.com/ Description: Modify SportsPress to work with individual (player vs player) sports. Author: ThemeBoy Author URI: http://themeboy.com/ -Version: 1.6 +Version: 1.7 */ // Exit if accessed directly @@ -17,7 +17,7 @@ if ( ! class_exists( 'SportsPress_Individual_Mode' ) ) : * Main SportsPress Individual Mode Class * * @class SportsPress_Individual_Mode - * @version 1.6 + * @version 1.7 */ class SportsPress_Individual_Mode { @@ -38,6 +38,7 @@ class SportsPress_Individual_Mode { add_filter( 'sportspress_register_post_type_table', array( $this, 'move_table_post_type' ), 99 ); add_filter( 'sportspress_settings_tabs_array', array( $this, 'remove_team_settings_tab' ), 99 ); add_filter( 'sportspress_get_settings_pages', array( $this, 'remove_team_settings' ), 99 ); + add_filter( 'sportspress_performance_options', array( $this, 'remove_performance_options' ), 99 ); add_filter( 'sportspress_player_options', array( $this, 'add_player_options' ), 99 ); add_filter( 'sportspress_player_settings', array( $this, 'add_player_settings' ), 99 ); add_filter( 'sportspress_next_steps', array( $this, 'remove_team_step' ), 99 ); @@ -67,7 +68,7 @@ class SportsPress_Individual_Mode { */ private function define_constants() { if ( !defined( 'SP_INDIVIDUAL_MODE_VERSION' ) ) - define( 'SP_INDIVIDUAL_MODE_VERSION', '1.6' ); + define( 'SP_INDIVIDUAL_MODE_VERSION', '1.7' ); if ( !defined( 'SP_INDIVIDUAL_MODE_URL' ) ) define( 'SP_INDIVIDUAL_MODE_URL', plugin_dir_url( __FILE__ ) ); @@ -171,6 +172,18 @@ class SportsPress_Individual_Mode { return $settings; } + /** + * Remove option to split players by team. + */ + public function remove_performance_options( $options ) { + foreach ( $options as $index => $option ) { + if ( 'sportspress_event_split_players_by_team' == sp_array_value( $option, 'id' ) ) { + unset( $options[ $index ] ); + } + } + return $options; + } + /** * Add options from teams to players tab. */ diff --git a/templates/event-performance-table-combined.php b/templates/event-performance-table-combined.php new file mode 100644 index 00000000..dc49923d --- /dev/null +++ b/templates/event-performance-table-combined.php @@ -0,0 +1,155 @@ + +
| # | + ++ $label ): ?> + + | + + | + + |
|---|---|---|---|
| ' . $number . ' | '; + endif; + + if ( $link_posts ): + $permalink = get_post_permalink( $player_id ); + $name = '' . $name . ''; + endif; + + echo '' . $name . ' | '; + + if ( $mode == 'icons' ) echo ''; + + foreach ( $labels as $key => $label ): + if ( in_array( $key, array( 'number', 'name' ) ) ) + continue; + $value = '—'; + if ( $key == 'position' ): + if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): + $positions = array(); + $position_ids = (array) $row[ $key ]; + foreach ( $position_ids as $position_id ) { + $player_position = get_term_by( 'id', $position_id, 'sp_position' ); + if ( $player_position ) $positions[] = $player_position->name; + } + $value = implode( ', ', $positions ); + endif; + else: + if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): + $value = $row[ $key ]; + else: + $value = 0; + endif; + endif; + if ( ! array_key_exists( $key, $totals ) ): + $totals[ $key ] = 0; + endif; + $totals[ $key ] += $value; + + if ( $mode == 'values' ): + echo ' | ' . $value . ' | '; + elseif ( intval( $value ) && $mode == 'icons' ): + $performance_id = sp_array_value( $performance_ids, $key, null ); + if ( $performance_id && has_post_thumbnail( $performance_id ) ): + echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value ); + endif; + endif; + endforeach; + + if ( $mode == 'icons' ) echo ''; + + echo '
| ' . __( 'Total', 'sportspress' ) . ' | '; + + $row = sp_array_value( $data, 0, array() ); + + if ( $mode == 'icons' ) echo ''; + + foreach ( $labels as $key => $label ): + if ( in_array( $key, array( 'number', 'name' ) ) ) + continue; + if ( $key == 'position' ): + $value = '—'; + elseif ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): + $value = $row[ $key ]; + else: + $value = sp_array_value( $totals, $key, 0 ); + endif; + + if ( $mode == 'values' ): + echo ' | ' . $value . ' | '; + elseif ( intval( $value ) && $mode == 'icons' ): + $performance_id = sp_array_value( $performance_ids, $key, null ); + if ( $performance_id && has_post_thumbnail( $performance_id ) ): + echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value ); + endif; + endif; + endforeach; + + if ( $mode == 'icons' ) echo ''; + ?> +
| # | @@ -37,7 +40,7 @@ $totals = array();
|---|
| # | - -- $label ): ?> - - | - - | - - |
|---|---|---|---|
| ' . $number . ' | '; - endif; - - if ( $link_posts ): - $permalink = get_post_permalink( $player_id ); - $name = '' . $name . ''; - endif; - - echo '' . $name . ' | '; - - if ( $mode == 'icons' ) echo ''; - - foreach ( $labels as $key => $label ): - if ( in_array( $key, array( 'number', 'name' ) ) ) - continue; - $value = '—'; - if ( $key == 'position' ): - if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): - $positions = array(); - $position_ids = (array) $row[ $key ]; - foreach ( $position_ids as $position_id ) { - $player_position = get_term_by( 'id', $position_id, 'sp_position' ); - if ( $player_position ) $positions[] = $player_position->name; - } - $value = implode( ', ', $positions ); - endif; - else: - if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): - $value = $row[ $key ]; - else: - $value = 0; - endif; - endif; - if ( ! array_key_exists( $key, $totals ) ): - $totals[ $key ] = 0; - endif; - $totals[ $key ] += $value; - - if ( $mode == 'values' ): - echo ' | ' . $value . ' | '; - elseif ( intval( $value ) && $mode == 'icons' ): - $performance_id = sp_array_value( $performance_ids, $key, null ); - if ( $performance_id && has_post_thumbnail( $performance_id ) ): - echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value ); - endif; - endif; - endforeach; - - if ( $mode == 'icons' ) echo ''; - - echo '
| ' . __( 'Total', 'sportspress' ) . ' | '; - - $row = sp_array_value( $data, 0, array() ); - - if ( $mode == 'icons' ) echo ''; - - foreach ( $labels as $key => $label ): - if ( in_array( $key, array( 'number', 'name' ) ) ) - continue; - if ( $key == 'position' ): - $value = '—'; - elseif ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): - $value = $row[ $key ]; - else: - $value = sp_array_value( $totals, $key, 0 ); - endif; - - if ( $mode == 'values' ): - echo ' | ' . $value . ' | '; - elseif ( intval( $value ) && $mode == 'icons' ): - $performance_id = sp_array_value( $performance_ids, $key, null ); - if ( $performance_id && has_post_thumbnail( $performance_id ) ): - echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value ); - endif; - endif; - endforeach; - - if ( $mode == 'icons' ) echo ''; - ?> -