Enable individual player performance and statistics
This commit is contained in:
@@ -481,7 +481,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'values' => 'slug',
|
||||
'show_option_none' => __( '-- Not set --', 'sportspress' ),
|
||||
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
||||
);
|
||||
if ( ! sp_dropdown_taxonomies( $args ) ):
|
||||
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
||||
@@ -496,7 +496,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'values' => 'slug',
|
||||
'show_option_none' => __( '-- Not set --', 'sportspress' ),
|
||||
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
||||
);
|
||||
if ( ! sp_dropdown_taxonomies( $args ) ):
|
||||
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
||||
|
||||
@@ -43,7 +43,8 @@ class SP_Meta_Box_Event_Details {
|
||||
'class' => 'sp-has-dummy',
|
||||
'selected' => sp_get_the_term_id_or_meta( $post->ID, $taxonomy ),
|
||||
'values' => 'term_id',
|
||||
'show_option_none' => __( '-- Not set --', 'sportspress' ),
|
||||
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
||||
'chosen' => true,
|
||||
);
|
||||
if ( in_array( $taxonomy, apply_filters( 'sportspress_event_auto_taxonomies', array( 'sp_venue' ) ) ) ) {
|
||||
$args['show_option_all'] = __( '(Auto)', 'sportspress' );
|
||||
|
||||
@@ -19,22 +19,23 @@ class SP_Meta_Box_Event_Shortcode {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$shortcodes = apply_filters( 'sportspress_event_shortcodes', array(
|
||||
'event_results' => __( 'Event Results', 'sportspress' ),
|
||||
'event_details' => __( 'Details', 'sportspress' ),
|
||||
'event_performance' => __( 'Player Performance', 'sportspress' ),
|
||||
) );
|
||||
if ( $shortcodes ) {
|
||||
?>
|
||||
<p class="howto">
|
||||
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
|
||||
</p>
|
||||
<?php foreach ( $shortcodes as $id => $label ) { ?>
|
||||
<p>
|
||||
<strong><?php _e( 'Event Results', 'sportspress' ); ?></strong>
|
||||
<strong><?php echo $label; ?></strong>
|
||||
</p>
|
||||
<p><input type="text" value="[event_results <?php echo $post->ID; ?>]" readonly="readonly" class="code widefat"></p>
|
||||
<p>
|
||||
<strong><?php _e( 'Details', 'sportspress' ); ?></strong>
|
||||
</p>
|
||||
<p><input type="text" value="[event_details <?php echo $post->ID; ?>]" readonly="readonly" class="code widefat"></p>
|
||||
<p>
|
||||
<strong><?php _e( 'Player Performance', 'sportspress' ); ?></strong>
|
||||
</p>
|
||||
<p><input type="text" value="[event_performance <?php echo $post->ID; ?>]" readonly="readonly" class="code widefat"></p>
|
||||
<p><input type="text" value="[<?php echo $id; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="code widefat"></p>
|
||||
<?php } ?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,17 +19,22 @@ class SP_Meta_Box_Player_Columns {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$selected = (array) get_post_meta( $post->ID, 'sp_columns', true );
|
||||
$tabs = apply_filters( 'sportspress_player_column_tabs', array( 'sp_performance', 'sp_statistic' ) );
|
||||
?>
|
||||
<div class="sp-instance">
|
||||
<?php if ( $tabs ) { ?>
|
||||
<ul id="sp_column-tabs" class="wp-tab-bar sp-tab-bar">
|
||||
<li class="wp-tab-active"><a href="#sp_performance-all"><?php _e( 'Performance', 'sportspress' ); ?></a></li>
|
||||
<li class="wp-tab"><a href="#sp_statistic-all"><?php _e( 'Statistics', 'sportspress' ); ?></a></li>
|
||||
<?php foreach ( $tabs as $index => $post_type ) { $object = get_post_type_object( $post_type ); ?>
|
||||
<li class="wp-tab<?php if ( 0 == $index ) { ?>-active<?php } ?>"><a href="#<?php echo $post_type; ?>-all"><?php echo $object->labels->name; ?></a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php
|
||||
$selected = (array)get_post_meta( $post->ID, 'sp_columns', true );
|
||||
sp_column_checklist( $post->ID, 'sp_performance', 'block', $selected );
|
||||
sp_column_checklist( $post->ID, 'sp_statistic', 'none', $selected );
|
||||
foreach ( $tabs as $index => $post_type ) {
|
||||
sp_column_checklist( $post->ID, $post_type, ( 0 == $index ? 'block' : 'none' ), $selected );
|
||||
}
|
||||
?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 1.5
|
||||
* @version 1.6
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
@@ -61,7 +61,7 @@ class SP_Meta_Box_Player_Statistics {
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _e( 'Season', 'sportspress' ); ?></th>
|
||||
<?php if ( $league_id ): ?>
|
||||
<?php if ( apply_filters( 'sportspress_player_team_statistics', $league_id ) ): ?>
|
||||
<th>
|
||||
<?php if ( $has_checkboxes ): ?>
|
||||
<label for="sp_columns_team">
|
||||
@@ -89,8 +89,11 @@ class SP_Meta_Box_Player_Statistics {
|
||||
<td>
|
||||
<?php if ( 0 !== $div_id ): ?>
|
||||
<label>
|
||||
<?php $value = sp_array_value( $leagues, $div_id, '-1' ); ?>
|
||||
<input type="checkbox" name="sp_leagues[<?php echo $league_id; ?>][<?php echo $div_id; ?>]" value="1" <?php checked( $value ); ?>>
|
||||
<?php if ( ! apply_filters( 'sportspress_player_team_statistics', $league_id ) ): ?>
|
||||
<?php $value = sp_array_value( $leagues, $div_id, '-1' ); ?>
|
||||
<input type="hidden" name="sp_leagues[<?php echo $league_id; ?>][<?php echo $div_id; ?>]" value="-1">
|
||||
<input type="checkbox" name="sp_leagues[<?php echo $league_id; ?>][<?php echo $div_id; ?>]" value="1" <?php checked( $value ); ?>>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if ( 'WP_Error' == get_class( $div ) ) _e( 'Total', 'sportspress' );
|
||||
else echo $div->name;
|
||||
@@ -103,7 +106,7 @@ class SP_Meta_Box_Player_Statistics {
|
||||
?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php if ( $league_id ): ?>
|
||||
<?php if ( apply_filters( 'sportspress_player_team_statistics', $league_id ) ): ?>
|
||||
<?php if ( $div_id == 0 ): ?>
|
||||
<td> </td>
|
||||
<?php else: ?>
|
||||
|
||||
@@ -338,7 +338,7 @@ class SP_Player extends SP_Custom_Post {
|
||||
$team_name = '<a href="' . $team_permalink . '">' . $team_name . '</a>';
|
||||
endif;
|
||||
else:
|
||||
continue;
|
||||
$team_name = __( 'Total', 'sportspress' );
|
||||
endif;
|
||||
|
||||
// Add season name to row
|
||||
|
||||
@@ -1159,6 +1159,7 @@ function sp_get_text_options() {
|
||||
__( 'Nationality', 'sportspress' ),
|
||||
__( 'Outcome', 'sportspress' ),
|
||||
__( 'Past Teams', 'sportspress' ),
|
||||
__( 'Performance', 'sportspress' ),
|
||||
__( 'Played', 'sportspress' ),
|
||||
__( 'Player', 'sportspress' ),
|
||||
__( 'Pos', 'sportspress' ),
|
||||
|
||||
@@ -28,9 +28,14 @@ class SportsPress_Individual_Mode {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Actions
|
||||
add_action( 'sportspress_process_sp_event_meta', array( $this, 'save_player_meta' ), 99, 2 );
|
||||
|
||||
// Filters
|
||||
add_filter( 'gettext', array( $this, 'gettext' ), 99, 3 );
|
||||
add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
|
||||
//add_filter( 'option_sportspress_event_show_total', '__return_false', 99 );
|
||||
//add_action( 'sportspress_meta_boxes', array( $this, 'remove_meta_boxes' ), 99 );
|
||||
add_filter( 'sportspress_register_post_type_team', array( $this, 'hide_post_type' ), 99 );
|
||||
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 );
|
||||
@@ -41,14 +46,18 @@ class SportsPress_Individual_Mode {
|
||||
add_filter( 'sportspress_modules', array( $this, 'rearrange_modules' ), 99 );
|
||||
add_filter( 'sportspress_glance_items', array( $this, 'remove_glance_item' ), 99 );
|
||||
add_filter( 'sportspress_shortcodes', array( $this, 'remove_shortcodes' ), 99 );
|
||||
add_filter( 'sportspress_event_shortcodes', array( $this, 'remove_event_shortcodes' ), 99 );
|
||||
add_filter( 'sportspress_list_admin_columns', array( $this, 'remove_team_column' ), 99 );
|
||||
add_filter( 'sportspress_importers', array( $this, 'remove_teams_importer' ), 99 );
|
||||
add_filter( 'sportspress_permalink_slugs', array( $this, 'remove_team_permalink_slug' ), 99 );
|
||||
//add_filter( 'sportspress_player_column_tabs', array( $this, 'player_column_tabs' ), 99 );
|
||||
add_filter( 'sportspress_event_team_tabs', '__return_false' );
|
||||
add_filter( 'sportspress_player_team_statistics', '__return_false' );
|
||||
add_filter( 'sportspress_list_team_selector', '__return_false' );
|
||||
add_filter( 'sportspress_split_performance_tables', '__return_false' );
|
||||
|
||||
// Remove templates
|
||||
remove_action( 'sportspress_single_event_content', 'sportspress_output_event_performance', 50 );
|
||||
//remove_action( 'sportspress_single_event_content', 'sportspress_output_event_performance', 50 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,6 +74,16 @@ class SportsPress_Individual_Mode {
|
||||
define( 'SP_INDIVIDUAL_MODE_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
public function save_player_meta( $post_id, $post ) {
|
||||
if ( isset( $_POST['sp_team'] ) && is_array( $_POST['sp_team'] ) ) {
|
||||
$players = array();
|
||||
foreach ( $_POST['sp_team'] as $player ) {
|
||||
$players[] = array( 0, $player );
|
||||
}
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_player', $players );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify all team-related strings for players.
|
||||
*/
|
||||
@@ -97,6 +116,14 @@ class SportsPress_Individual_Mode {
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove meta boxes.
|
||||
*/
|
||||
public function remove_meta_boxes( $meta_boxes ) {
|
||||
unset( $meta_boxes['sp_event']['performance'] );
|
||||
return $meta_boxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide post types.
|
||||
*/
|
||||
@@ -198,6 +225,14 @@ class SportsPress_Individual_Mode {
|
||||
return $shortcodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove shortcodes from event meta box.
|
||||
*/
|
||||
public function remove_event_shortcodes( $shortcodes ) {
|
||||
unset( $shortcodes['event_performance'] );
|
||||
return $shortcodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove team column from player list admin.
|
||||
*/
|
||||
@@ -223,6 +258,16 @@ class SportsPress_Individual_Mode {
|
||||
}
|
||||
return $slugs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify player column tabs.
|
||||
*/
|
||||
public function player_column_tabs( $tabs ) {
|
||||
if ( ( $index = array_search ( 'sp_performance', $tabs ) ) !== false ) {
|
||||
$tabs[ $index ] = 'sp_column';
|
||||
}
|
||||
return $tabs;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
@@ -12,6 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
$show_players = get_option( 'sportspress_event_show_players', 'yes' ) === 'yes' ? true : false;
|
||||
$show_staff = get_option( 'sportspress_event_show_staff', 'yes' ) === 'yes' ? true : false;
|
||||
$show_total = get_option( 'sportspress_event_show_total', 'yes' ) === 'yes' ? true : false;
|
||||
$split_tables = apply_filters( 'sportspress_split_performance_tables', true );
|
||||
|
||||
if ( ! $show_players && ! $show_staff && ! $show_total ) return;
|
||||
|
||||
@@ -50,70 +51,241 @@ if ( is_array( $teams ) ):
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
foreach( $teams as $index => $team_id ):
|
||||
if ( -1 == $team_id ) continue;
|
||||
if ( $split_tables ) {
|
||||
// Split tables
|
||||
foreach( $teams as $index => $team_id ):
|
||||
if ( -1 == $team_id ) continue;
|
||||
|
||||
// Get results for players in the team
|
||||
$players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index );
|
||||
$has_players = sizeof( $players ) > 1;
|
||||
// Get results for players in the team
|
||||
$players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index );
|
||||
$has_players = sizeof( $players ) > 1;
|
||||
|
||||
$show_team_players = $show_players && $has_players;
|
||||
$show_team_players = $show_players && $has_players;
|
||||
|
||||
$totals = array();
|
||||
$totals = array();
|
||||
|
||||
if ( 0 < $team_id ) {
|
||||
$data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
|
||||
} elseif ( 0 == $team_id ) {
|
||||
$data = array();
|
||||
foreach ( $players as $player_id ) {
|
||||
if ( isset( $performance[ $player_id ][ $player_id ] ) ) {
|
||||
$data[ $player_id ] = $performance[ $player_id ][ $player_id ];
|
||||
if ( 0 < $team_id ) {
|
||||
$data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
|
||||
} elseif ( 0 == $team_id ) {
|
||||
$data = array();
|
||||
foreach ( $players as $player_id ) {
|
||||
if ( isset( $performance[ $player_id ][ $player_id ] ) ) {
|
||||
$data[ $player_id ] = $performance[ $player_id ][ $player_id ];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$data = sp_array_value( array_values( $performance ), $index );
|
||||
}
|
||||
} else {
|
||||
$data = sp_array_value( array_values( $performance ), $index );
|
||||
}
|
||||
|
||||
if ( ! $show_team_players && ! $show_staff && ! $show_total ) continue;
|
||||
if ( ! $show_team_players && ! $show_staff && ! $show_total ) continue;
|
||||
?>
|
||||
<div class="sp-template sp-template-event-performance sp-template-event-performance-<?php echo $mode; ?>">
|
||||
<?php if ( $team_id ): ?>
|
||||
<h4 class="sp-table-caption"><?php echo get_the_title( $team_id ); ?></h4>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if ( $show_staff ):
|
||||
sp_get_template( 'event-staff.php', array( 'id' => $id, 'index' => $index ) );
|
||||
endif;
|
||||
?>
|
||||
<?php if ( $show_team_players || $show_total ): ?>
|
||||
<div class="sp-table-wrapper">
|
||||
<table class="sp-event-performance sp-data-table <?php if ( $responsive ) { ?> sp-responsive-table<?php } if ( $scrollable ) { ?> sp-scrollable-table<?php } ?>">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php if ( $show_team_players ): ?>
|
||||
<th class="data-number">#</th>
|
||||
<th class="data-name"><?php _e( 'Player', 'sportspress' ); ?></th>
|
||||
<?php endif; ?>
|
||||
<?php if ( $mode == 'values' ): foreach( $labels as $key => $label ): ?>
|
||||
<th class="data-<?php echo $key; ?>"><?php echo $label; ?></th>
|
||||
<?php endforeach; else: ?>
|
||||
<th class="sp-performance-icons"> </th>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php if ( $show_team_players ): ?>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
$lineups = array_filter( $data, array( $event, 'lineup_filter' ) );
|
||||
$subs = array_filter( $data, array( $event, 'sub_filter' ) );
|
||||
|
||||
$lineup_sub_relation = array();
|
||||
foreach ( $subs as $sub_id => $sub ):
|
||||
if ( ! $sub_id )
|
||||
continue;
|
||||
$lineup_sub_relation[ sp_array_value( $sub, 'sub', 0 ) ] = $sub_id;
|
||||
endforeach;
|
||||
|
||||
$i = 0;
|
||||
foreach( $data as $player_id => $row ):
|
||||
|
||||
if ( ! $player_id )
|
||||
continue;
|
||||
|
||||
$name = get_the_title( $player_id );
|
||||
|
||||
if ( ! $name )
|
||||
continue;
|
||||
|
||||
echo '<tr class="' . sp_array_value( $row, 'status', 'lineup' ) . ' ' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
$number = sp_array_value( $row, 'number', ' ' );
|
||||
|
||||
// Player number
|
||||
echo '<td class="data-number">' . $number . '</td>';
|
||||
|
||||
if ( $link_posts ):
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
if ( isset( $row['status'] ) && $row['status'] == 'sub' ):
|
||||
$name = '(' . $name . ')';
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( array_key_exists( $player_id, $lineup_sub_relation ) ):
|
||||
$name .= ' <span class="sub-in" title="' . get_the_title( $lineup_sub_relation[ $player_id ] ) . '">' . sp_array_value( sp_array_value( $data, $lineup_sub_relation[ $player_id ], array() ), 'number', null ) . '</span>';
|
||||
elseif ( isset( $row['sub'] ) && $row['sub'] ):
|
||||
$name .= ' <span class="sub-out" title="' . get_the_title( $row[ 'sub' ] ) . '">' . sp_array_value( sp_array_value( $data, $row['sub'], array() ), 'number', null ) . '</span>';
|
||||
endif;
|
||||
|
||||
echo '<td class="data-name">' . $name . '</td>';
|
||||
|
||||
if ( $mode == 'icons' ) echo '<td class="sp-performance-icons">';
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
$value = '—';
|
||||
if ( $key == 'position' ):
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
|
||||
$position = get_term_by( 'id', $row[ $key ], 'sp_position' );
|
||||
if ( $position ) $value = $position->name;
|
||||
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 '<td class="data-' . $key . '">' . $value . '</td>';
|
||||
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 '</td>';
|
||||
|
||||
echo '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
?>
|
||||
</tbody>
|
||||
<?php endif; ?>
|
||||
<?php if ( $show_total ): ?>
|
||||
<<?php echo ( $show_team_players ? 'tfoot' : 'tbody' ); ?>>
|
||||
<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">
|
||||
<?php
|
||||
if ( $show_team_players ):
|
||||
echo '<td class="data-number"> </td>';
|
||||
echo '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>';
|
||||
endif;
|
||||
|
||||
$row = sp_array_value( $data, 0, array() );
|
||||
|
||||
if ( $mode == 'icons' ) echo '<td class="sp-performance-icons">';
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
if ( $key == '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 '<td class="data-' . $key . '">' . $value . '</td>';
|
||||
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 '</td>';
|
||||
?>
|
||||
</tr>
|
||||
</<?php echo ( $show_team_players ? 'tfoot' : 'tbody' ); ?>>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
} else {
|
||||
// Combined table
|
||||
?>
|
||||
<div class="sp-template sp-template-event-performance sp-template-event-performance-<?php echo $mode; ?>">
|
||||
<?php if ( $team_id ): ?>
|
||||
<h4 class="sp-table-caption"><?php echo get_the_title( $team_id ); ?></h4>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if ( $show_staff ):
|
||||
sp_get_template( 'event-staff.php', array( 'id' => $id, 'index' => $index ) );
|
||||
endif;
|
||||
?>
|
||||
<?php if ( $show_team_players || $show_total ): ?>
|
||||
<div class="sp-table-wrapper">
|
||||
<table class="sp-event-performance sp-data-table <?php if ( $responsive ) { ?> sp-responsive-table<?php } if ( $scrollable ) { ?> sp-scrollable-table<?php } ?>">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php if ( $show_team_players ): ?>
|
||||
<th class="data-number">#</th>
|
||||
<th class="data-name"><?php _e( 'Player', 'sportspress' ); ?></th>
|
||||
<?php endif; ?>
|
||||
<?php if ( $mode == 'values' ): foreach( $labels as $key => $label ): ?>
|
||||
<th class="data-<?php echo $key; ?>"><?php echo $label; ?></th>
|
||||
<?php endforeach; else: ?>
|
||||
<th class="sp-performance-icons"> </th>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php if ( $show_team_players ): ?>
|
||||
<tbody>
|
||||
<?php
|
||||
<h4 class="sp-table-caption"><?php _e( 'Performance', 'sportspress' ); ?></h4>
|
||||
<div class="sp-table-wrapper">
|
||||
<table class="sp-event-performance sp-data-table <?php if ( $responsive ) { ?> sp-responsive-table<?php } if ( $scrollable ) { ?> sp-scrollable-table<?php } ?>">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="data-number">#</th>
|
||||
<th class="data-name"><?php _e( 'Player', 'sportspress' ); ?></th>
|
||||
<?php if ( $mode == 'values' ): foreach( $labels as $key => $label ): ?>
|
||||
<th class="data-<?php echo $key; ?>"><?php echo $label; ?></th>
|
||||
<?php endforeach; else: ?>
|
||||
<th class="sp-performance-icons"> </th>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ( $teams as $index => $team_id ) {
|
||||
if ( -1 == $team_id ) continue;
|
||||
|
||||
$lineups = array_filter( $data, array( $event, 'lineup_filter' ) );
|
||||
$subs = array_filter( $data, array( $event, 'sub_filter' ) );
|
||||
// Get results for players in the team
|
||||
$players = sp_array_between( (array) get_post_meta( $id, 'sp_player', false ), 0, $index );
|
||||
$has_players = sizeof( $players ) > 1;
|
||||
|
||||
$lineup_sub_relation = array();
|
||||
foreach ( $subs as $sub_id => $sub ):
|
||||
if ( ! $sub_id )
|
||||
continue;
|
||||
$lineup_sub_relation[ sp_array_value( $sub, 'sub', 0 ) ] = $sub_id;
|
||||
endforeach;
|
||||
$show_team_players = $show_players && $has_players;
|
||||
if ( ! $show_team_players && ! $show_total ) continue;
|
||||
|
||||
$totals = array();
|
||||
|
||||
if ( 0 < $team_id ) {
|
||||
$data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
|
||||
} elseif ( 0 == $team_id ) {
|
||||
$data = array();
|
||||
foreach ( $players as $player_id ) {
|
||||
if ( isset( $performance[ $player_id ][ $player_id ] ) ) {
|
||||
$data[ $player_id ] = $performance[ $player_id ][ $player_id ];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$data = sp_array_value( array_values( $performance ), $index );
|
||||
}
|
||||
|
||||
if ( $show_team_players ) {
|
||||
|
||||
$i = 0;
|
||||
foreach( $data as $player_id => $row ):
|
||||
@@ -136,15 +308,6 @@ if ( is_array( $teams ) ):
|
||||
if ( $link_posts ):
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
if ( isset( $row['status'] ) && $row['status'] == 'sub' ):
|
||||
$name = '(' . $name . ')';
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( array_key_exists( $player_id, $lineup_sub_relation ) ):
|
||||
$name .= ' <span class="sub-in" title="' . get_the_title( $lineup_sub_relation[ $player_id ] ) . '">' . sp_array_value( sp_array_value( $data, $lineup_sub_relation[ $player_id ], array() ), 'number', null ) . '</span>';
|
||||
elseif ( isset( $row['sub'] ) && $row['sub'] ):
|
||||
$name .= ' <span class="sub-out" title="' . get_the_title( $row[ 'sub' ] ) . '">' . sp_array_value( sp_array_value( $data, $row['sub'], array() ), 'number', null ) . '</span>';
|
||||
endif;
|
||||
|
||||
echo '<td class="data-name">' . $name . '</td>';
|
||||
@@ -189,17 +352,17 @@ if ( is_array( $teams ) ):
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
?>
|
||||
</tbody>
|
||||
<?php endif; ?>
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<?php if ( $show_total ): ?>
|
||||
<<?php echo ( $show_team_players ? 'tfoot' : 'tbody' ); ?>>
|
||||
<tfoot>
|
||||
<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">
|
||||
<?php
|
||||
if ( $show_team_players ):
|
||||
echo '<td class="data-number"> </td>';
|
||||
echo '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>';
|
||||
endif;
|
||||
echo '<td class="data-number"> </td>';
|
||||
echo '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>';
|
||||
|
||||
$row = sp_array_value( $data, 0, array() );
|
||||
|
||||
@@ -229,12 +392,11 @@ if ( is_array( $teams ) ):
|
||||
if ( $mode == 'icons' ) echo '</td>';
|
||||
?>
|
||||
</tr>
|
||||
</<?php echo ( $show_team_players ? 'tfoot' : 'tbody' ); ?>>
|
||||
</tfoot>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
}
|
||||
endif;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<key name="Nationality"/>
|
||||
<key name="Outcome"/>
|
||||
<key name="Past Teams"/>
|
||||
<key name="Performance"/>
|
||||
<key name="Played"/>
|
||||
<key name="Player"/>
|
||||
<key name="Pos"/>
|
||||
|
||||
Reference in New Issue
Block a user