Add combined table for individual mode
This commit is contained in:
@@ -53,8 +53,11 @@ class SP_Meta_Box_Event_Performance {
|
||||
|
||||
// Apply filters to labels
|
||||
$labels = apply_filters( 'sportspress_event_performance_labels_admin', $labels );
|
||||
|
||||
// Check if individual mode
|
||||
$is_individual = get_option( 'sportspress_load_individual_mode_module', 'no' ) === 'yes' ? true : false;
|
||||
|
||||
self::tables( $post->ID, $stats, $labels, $columns, $teams, $has_checkboxes, $positions, $status, $formats, $order );
|
||||
self::tables( $post->ID, $stats, $labels, $columns, $teams, $has_checkboxes, $positions, $status, $formats, $order, $is_individual );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,96 +72,123 @@ class SP_Meta_Box_Event_Performance {
|
||||
/**
|
||||
* Admin edit tables
|
||||
*/
|
||||
public static function tables( $post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $positions = array(), $status = true, $formats = array(), $order = array() ) {
|
||||
public static function tables( $post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $positions = array(), $status = true, $formats = array(), $order = array(), $is_individual = false ) {
|
||||
$sections = get_option( 'sportspress_event_performance_sections', -1 );
|
||||
|
||||
$i = 0;
|
||||
if ( $is_individual ) {
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table sp-performance-table sp-sortable-table">
|
||||
<?php self::header( $columns, $labels, $positions, $has_checkboxes, $status, false, false, -1, $formats ); ?>
|
||||
<?php self::footer( sp_array_value( $stats, -1 ), $labels, 0, $positions, $status, false, false, -1, $formats ); ?>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ( $teams as $key => $team_id ):
|
||||
if ( -1 == $team_id ) continue;
|
||||
|
||||
foreach ( $teams as $key => $team_id ):
|
||||
if ( -1 == $team_id ) continue;
|
||||
|
||||
if ( -1 == $sections ) {
|
||||
// Get results for players in the team
|
||||
$players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
||||
$players[] = -1;
|
||||
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
|
||||
<?php self::table( $labels, $columns, $data, $team_id, $has_checkboxes, $positions, $status, -1, $formats, $order ); ?>
|
||||
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels, $columns, $data, $team_id ); ?>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<?php
|
||||
// Get labels by section
|
||||
$args = array(
|
||||
'post_type' => 'sp_performance',
|
||||
'numberposts' => 100,
|
||||
'posts_per_page' => 100,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
// Get results for players in the team
|
||||
$players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
||||
$players[] = -1;
|
||||
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||
|
||||
$columns = get_posts( $args );
|
||||
|
||||
$labels = array( array(), array() );
|
||||
foreach ( $columns as $column ):
|
||||
$section = get_post_meta( $column->ID, 'sp_section', true );
|
||||
if ( '' === $section ) {
|
||||
$section = -1;
|
||||
}
|
||||
switch ( $section ):
|
||||
case 1:
|
||||
$labels[1][ $column->post_name ] = $column->post_title;
|
||||
break;
|
||||
case 0:
|
||||
$labels[0][ $column->post_name ] = $column->post_title;
|
||||
break;
|
||||
default:
|
||||
$labels[1][ $column->post_name ] = $column->post_title;
|
||||
$labels[0][ $column->post_name ] = $column->post_title;
|
||||
endswitch;
|
||||
endforeach;
|
||||
foreach ( $data as $player_id => $player_performance ):
|
||||
self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, false, false, -1, $formats );
|
||||
endforeach;
|
||||
endforeach;
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
$i = 0;
|
||||
|
||||
foreach ( $teams as $key => $team_id ):
|
||||
if ( -1 == $team_id ) continue;
|
||||
|
||||
$offense = (array)get_post_meta( $post_id, 'sp_offense', false );
|
||||
$defense = (array)get_post_meta( $post_id, 'sp_defense', false );
|
||||
$data = array();
|
||||
if ( sizeof( $offense ) || sizeof( $defense ) ) {
|
||||
// Get results for offensive players in the team
|
||||
$offense = sp_array_between( $offense, 0, $key );
|
||||
$offense[] = -1;
|
||||
$data[0] = sp_array_combine( $offense, sp_array_value( $stats, $team_id, array() ) );
|
||||
|
||||
// Get results for defensive players in the team
|
||||
$defense = sp_array_between( $defense, 0, $key );
|
||||
$defense[] = -1;
|
||||
$data[1] = sp_array_combine( $defense, sp_array_value( $stats, $team_id, array() ) );
|
||||
} else {
|
||||
// Get results for all players in the team
|
||||
if ( -1 == $sections ) {
|
||||
// Get results for players in the team
|
||||
$players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
||||
$players[] = -1;
|
||||
$data[0] = $data[1] = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||
}
|
||||
|
||||
// Determine order of sections
|
||||
if ( 1 == $sections ) {
|
||||
$section_order = array( 1 => __( 'Defense', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ) );
|
||||
} else {
|
||||
$section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) );
|
||||
}
|
||||
|
||||
foreach ( $section_order as $section_id => $section_label ) {
|
||||
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php echo get_the_title( $team_id ); ?> — <?php echo $section_label; ?></strong></p>
|
||||
<?php self::table( $labels[ $section_id ], $columns, $data[ $section_id ], $team_id, $has_checkboxes, $positions, $status, $section_id, $formats, $order ); ?>
|
||||
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels[ $section_id ], $columns, $data[ $section_id ], $team_id ); ?>
|
||||
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
|
||||
<?php self::table( $labels, $columns, $data, $team_id, $has_checkboxes, $positions, $status, -1, $formats, $order ); ?>
|
||||
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels, $columns, $data, $team_id ); ?>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<?php
|
||||
// Get labels by section
|
||||
$args = array(
|
||||
'post_type' => 'sp_performance',
|
||||
'numberposts' => 100,
|
||||
'posts_per_page' => 100,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
|
||||
$columns = get_posts( $args );
|
||||
|
||||
$labels = array( array(), array() );
|
||||
foreach ( $columns as $column ):
|
||||
$section = get_post_meta( $column->ID, 'sp_section', true );
|
||||
if ( '' === $section ) {
|
||||
$section = -1;
|
||||
}
|
||||
switch ( $section ):
|
||||
case 1:
|
||||
$labels[1][ $column->post_name ] = $column->post_title;
|
||||
break;
|
||||
case 0:
|
||||
$labels[0][ $column->post_name ] = $column->post_title;
|
||||
break;
|
||||
default:
|
||||
$labels[1][ $column->post_name ] = $column->post_title;
|
||||
$labels[0][ $column->post_name ] = $column->post_title;
|
||||
endswitch;
|
||||
endforeach;
|
||||
|
||||
$offense = (array)get_post_meta( $post_id, 'sp_offense', false );
|
||||
$defense = (array)get_post_meta( $post_id, 'sp_defense', false );
|
||||
$data = array();
|
||||
if ( sizeof( $offense ) || sizeof( $defense ) ) {
|
||||
// Get results for offensive players in the team
|
||||
$offense = sp_array_between( $offense, 0, $key );
|
||||
$offense[] = -1;
|
||||
$data[0] = sp_array_combine( $offense, sp_array_value( $stats, $team_id, array() ) );
|
||||
|
||||
// Get results for defensive players in the team
|
||||
$defense = sp_array_between( $defense, 0, $key );
|
||||
$defense[] = -1;
|
||||
$data[1] = sp_array_combine( $defense, sp_array_value( $stats, $team_id, array() ) );
|
||||
} else {
|
||||
// Get results for all players in the team
|
||||
$players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
||||
$players[] = -1;
|
||||
$data[0] = $data[1] = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||
}
|
||||
|
||||
// Determine order of sections
|
||||
if ( 1 == $sections ) {
|
||||
$section_order = array( 1 => __( 'Defense', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ) );
|
||||
} else {
|
||||
$section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) );
|
||||
}
|
||||
|
||||
foreach ( $section_order as $section_id => $section_label ) {
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php echo get_the_title( $team_id ); ?> — <?php echo $section_label; ?></strong></p>
|
||||
<?php self::table( $labels[ $section_id ], $columns, $data[ $section_id ], $team_id, $has_checkboxes, $positions, $status, $section_id, $formats, $order ); ?>
|
||||
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels[ $section_id ], $columns, $data[ $section_id ], $team_id ); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
$i ++;
|
||||
endforeach;
|
||||
$i ++;
|
||||
endforeach;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,6 +74,10 @@ if ( ! isset( $class ) ) $class = null;
|
||||
foreach ( $labels as $key => $label ):
|
||||
if ( in_array( $key, array( 'number', 'name' ) ) )
|
||||
continue;
|
||||
|
||||
$format = sp_array_value( $formats, $key, 'number' );
|
||||
$placeholder = sp_get_format_placeholder( $format );
|
||||
|
||||
$value = '—';
|
||||
if ( $key == 'position' ):
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
|
||||
@@ -89,13 +93,16 @@ if ( ! isset( $class ) ) $class = null;
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
|
||||
$value = $row[ $key ];
|
||||
else:
|
||||
$value = 0;
|
||||
$value = $placeholder;
|
||||
endif;
|
||||
endif;
|
||||
if ( ! array_key_exists( $key, $totals ) ):
|
||||
$totals[ $key ] = 0;
|
||||
$totals[ $key ] = $placeholder;
|
||||
endif;
|
||||
$totals[ $key ] += $value;
|
||||
|
||||
if ( 'text' !== $format ) {
|
||||
$totals[ $key ] += $value;
|
||||
}
|
||||
|
||||
if ( $mode == 'values' ):
|
||||
echo '<td class="data-' . $key . '">' . $value . '</td>';
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
$is_individual = get_option( 'sportspress_load_individual_mode_module', 'no' ) === 'yes' ? true : false;
|
||||
$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;
|
||||
@@ -83,155 +84,185 @@ if ( is_array( $teams ) ):
|
||||
}
|
||||
$formats[ $column->post_name ] = $format;
|
||||
}
|
||||
|
||||
// Prepare for offense and defense sections
|
||||
if ( -1 != $sections ) {
|
||||
|
||||
// Determine order of sections
|
||||
if ( 1 == $sections ) {
|
||||
$section_order = array( 1 => __( 'Defense', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ) );
|
||||
} else {
|
||||
$section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) );
|
||||
}
|
||||
|
||||
// Initialize labels
|
||||
$labels = array( array(), array() );
|
||||
|
||||
// Add positions if applicable
|
||||
if ( 'yes' == get_option( 'sportspress_event_show_position', 'yes' ) ) {
|
||||
$labels[0]['position'] = $labels[1]['position'] = __( 'Position', 'sportspress' );
|
||||
}
|
||||
|
||||
// Get labels by section
|
||||
foreach ( $columns as $column ):
|
||||
$section = get_post_meta( $column->ID, 'sp_section', true );
|
||||
if ( '' === $section ) {
|
||||
$section = -1;
|
||||
|
||||
if ( $is_individual ) {
|
||||
// Combined table
|
||||
$data = array();
|
||||
foreach ( $performance as $players ) {
|
||||
foreach ( $players as $player_id => $player ) {
|
||||
if ( $player_id == 0 ) continue;
|
||||
$data[ $player_id ] = $player;
|
||||
}
|
||||
switch ( $section ):
|
||||
case 1:
|
||||
$labels[1][ $column->post_name ] = $column->post_title;
|
||||
break;
|
||||
case 0:
|
||||
$labels[0][ $column->post_name ] = $column->post_title;
|
||||
break;
|
||||
default:
|
||||
$labels[0][ $column->post_name ] = $column->post_title;
|
||||
$labels[1][ $column->post_name ] = $column->post_title;
|
||||
endswitch;
|
||||
endforeach;
|
||||
}
|
||||
}
|
||||
|
||||
sp_get_template( 'event-performance-table-combined.php', array(
|
||||
'scrollable' => $scrollable,
|
||||
'sortable' => $sortable,
|
||||
'show_players' => $show_players,
|
||||
'show_numbers' => $show_numbers,
|
||||
'show_total' => $show_total,
|
||||
'caption' => __( 'Scorecard', 'sportspress' ),
|
||||
'labels' => $labels,
|
||||
'formats' => $formats,
|
||||
'mode' => $mode,
|
||||
'data' => $data,
|
||||
'event' => $event,
|
||||
'link_posts' => $link_posts,
|
||||
'performance_ids' => isset( $performance_ids ) ? $performance_ids : null,
|
||||
'primary' => 'primary' == $total ? $primary : null,
|
||||
) );
|
||||
} else {
|
||||
|
||||
foreach( $teams as $index => $team_id ):
|
||||
if ( -1 == $team_id ) continue;
|
||||
// Prepare for offense and defense sections
|
||||
if ( -1 != $sections ) {
|
||||
|
||||
// Determine order of sections
|
||||
if ( 1 == $sections ) {
|
||||
$section_order = array( 1 => __( 'Defense', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ) );
|
||||
} else {
|
||||
$section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) );
|
||||
}
|
||||
|
||||
// Initialize labels
|
||||
$labels = array( array(), array() );
|
||||
|
||||
// Add positions if applicable
|
||||
if ( 'yes' == get_option( 'sportspress_event_show_position', 'yes' ) ) {
|
||||
$labels[0]['position'] = $labels[1]['position'] = __( 'Position', 'sportspress' );
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
$players = apply_filters( 'sportspress_event_performance_split_team_players', $players );
|
||||
|
||||
$show_team_players = $show_players && $has_players;
|
||||
|
||||
if ( ! $show_team_players && ! $show_staff && ! $show_total ) continue;
|
||||
|
||||
if ( $show_team_players || $show_total ) {
|
||||
if ( -1 != $sections ) {
|
||||
|
||||
$data = array();
|
||||
|
||||
$offense = (array)get_post_meta( $id, 'sp_offense', false );
|
||||
$defense = (array)get_post_meta( $id, 'sp_defense', false );
|
||||
|
||||
if ( sizeof( $offense ) || sizeof( $defense ) ) {
|
||||
// Get results for offensive players in the team
|
||||
$offense = sp_array_between( $offense, 0, $index );
|
||||
$data[0] = sp_array_combine( $offense, sp_array_value( $performance, $team_id, array() ) );
|
||||
|
||||
// Get results for defensive players in the team
|
||||
$defense = sp_array_between( $defense, 0, $index );
|
||||
$data[1] = sp_array_combine( $defense, sp_array_value( $performance, $team_id, array() ) );
|
||||
} else {
|
||||
// Get results for all players in the team
|
||||
$players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index );
|
||||
$data[0] = $data[1] = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
|
||||
// Get labels by section
|
||||
foreach ( $columns as $column ):
|
||||
$section = get_post_meta( $column->ID, 'sp_section', true );
|
||||
if ( '' === $section ) {
|
||||
$section = -1;
|
||||
}
|
||||
|
||||
$s = 0;
|
||||
switch ( $section ):
|
||||
case 1:
|
||||
$labels[1][ $column->post_name ] = $column->post_title;
|
||||
break;
|
||||
case 0:
|
||||
$labels[0][ $column->post_name ] = $column->post_title;
|
||||
break;
|
||||
default:
|
||||
$labels[0][ $column->post_name ] = $column->post_title;
|
||||
$labels[1][ $column->post_name ] = $column->post_title;
|
||||
endswitch;
|
||||
endforeach;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
$players = apply_filters( 'sportspress_event_performance_split_team_players', $players );
|
||||
|
||||
$show_team_players = $show_players && $has_players;
|
||||
|
||||
if ( ! $show_team_players && ! $show_staff && ! $show_total ) continue;
|
||||
|
||||
if ( $show_team_players || $show_total ) {
|
||||
if ( -1 != $sections ) {
|
||||
|
||||
foreach ( $section_order as $section_id => $section_label ) {
|
||||
if ( sizeof( $data[ $section_id ] ) ) {
|
||||
if ( 1 == $section_id ) {
|
||||
$order = (array)get_post_meta( $id, 'sp_order', true );
|
||||
if ( is_array( $order ) && sizeof( $order ) ) {
|
||||
$player_order = sp_array_value( $order, $team_id, array() );
|
||||
if ( is_array( $player_order ) && sizeof( $player_order ) ) {
|
||||
$data[1] = sp_array_combine( $player_order, $data[1], true );
|
||||
$data = array();
|
||||
|
||||
$offense = (array)get_post_meta( $id, 'sp_offense', false );
|
||||
$defense = (array)get_post_meta( $id, 'sp_defense', false );
|
||||
|
||||
if ( sizeof( $offense ) || sizeof( $defense ) ) {
|
||||
// Get results for offensive players in the team
|
||||
$offense = sp_array_between( $offense, 0, $index );
|
||||
$data[0] = sp_array_combine( $offense, sp_array_value( $performance, $team_id, array() ) );
|
||||
|
||||
// Get results for defensive players in the team
|
||||
$defense = sp_array_between( $defense, 0, $index );
|
||||
$data[1] = sp_array_combine( $defense, sp_array_value( $performance, $team_id, array() ) );
|
||||
} else {
|
||||
// Get results for all players in the team
|
||||
$players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index );
|
||||
$data[0] = $data[1] = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
|
||||
}
|
||||
|
||||
$s = 0;
|
||||
|
||||
foreach ( $section_order as $section_id => $section_label ) {
|
||||
if ( sizeof( $data[ $section_id ] ) ) {
|
||||
if ( 1 == $section_id ) {
|
||||
$order = (array)get_post_meta( $id, 'sp_order', true );
|
||||
if ( is_array( $order ) && sizeof( $order ) ) {
|
||||
$player_order = sp_array_value( $order, $team_id, array() );
|
||||
if ( is_array( $player_order ) && sizeof( $player_order ) ) {
|
||||
$data[1] = sp_array_combine( $player_order, $data[1], true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sp_get_template( 'event-performance-table.php', array(
|
||||
'section' => $section_label,
|
||||
'scrollable' => $scrollable,
|
||||
'sortable' => $sortable,
|
||||
'show_players' => $show_team_players,
|
||||
'show_numbers' => $show_numbers,
|
||||
'show_total' => $show_total,
|
||||
'caption' => 0 == $s && $team_id ? get_the_title( $team_id ) : null,
|
||||
'labels' => $labels[ $section_id ],
|
||||
'formats' => $formats,
|
||||
'mode' => $mode,
|
||||
'data' => $data[ $section_id ],
|
||||
'event' => $event,
|
||||
'link_posts' => $link_posts,
|
||||
'performance_ids' => isset( $performance_ids ) ? $performance_ids : null,
|
||||
'primary' => 'primary' == $total ? $primary : null,
|
||||
'class' => 'sp-template-event-performance-team-' . $index . '-section-' . $section_id,
|
||||
) );
|
||||
}
|
||||
|
||||
sp_get_template( 'event-performance-table.php', array(
|
||||
'section' => $section_label,
|
||||
'scrollable' => $scrollable,
|
||||
'sortable' => $sortable,
|
||||
'show_players' => $show_team_players,
|
||||
'show_numbers' => $show_numbers,
|
||||
'show_total' => $show_total,
|
||||
'caption' => 0 == $s && $team_id ? get_the_title( $team_id ) : null,
|
||||
'labels' => $labels[ $section_id ],
|
||||
'formats' => $formats,
|
||||
'mode' => $mode,
|
||||
'data' => $data[ $section_id ],
|
||||
'event' => $event,
|
||||
'link_posts' => $link_posts,
|
||||
'performance_ids' => isset( $performance_ids ) ? $performance_ids : null,
|
||||
'primary' => 'primary' == $total ? $primary : null,
|
||||
'class' => 'sp-template-event-performance-team-' . $index . '-section-' . $section_id,
|
||||
) );
|
||||
}
|
||||
|
||||
$s++;
|
||||
}
|
||||
} else {
|
||||
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 ];
|
||||
}
|
||||
$s++;
|
||||
}
|
||||
} else {
|
||||
$data = sp_array_value( array_values( $performance ), $index );
|
||||
}
|
||||
|
||||
sp_get_template( 'event-performance-table.php', array(
|
||||
'scrollable' => $scrollable,
|
||||
'sortable' => $sortable,
|
||||
'show_players' => $show_team_players,
|
||||
'show_numbers' => $show_numbers,
|
||||
'show_total' => $show_total,
|
||||
'caption' => $team_id ? get_the_title( $team_id ) : null,
|
||||
'labels' => $labels,
|
||||
'formats' => $formats,
|
||||
'mode' => $mode,
|
||||
'data' => $data,
|
||||
'event' => $event,
|
||||
'link_posts' => $link_posts,
|
||||
'performance_ids' => isset( $performance_ids ) ? $performance_ids : null,
|
||||
'primary' => 'primary' == $total ? $primary : null,
|
||||
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 );
|
||||
}
|
||||
|
||||
sp_get_template( 'event-performance-table.php', array(
|
||||
'scrollable' => $scrollable,
|
||||
'sortable' => $sortable,
|
||||
'show_players' => $show_team_players,
|
||||
'show_numbers' => $show_numbers,
|
||||
'show_total' => $show_total,
|
||||
'caption' => $team_id ? get_the_title( $team_id ) : null,
|
||||
'labels' => $labels,
|
||||
'formats' => $formats,
|
||||
'mode' => $mode,
|
||||
'data' => $data,
|
||||
'event' => $event,
|
||||
'link_posts' => $link_posts,
|
||||
'performance_ids' => isset( $performance_ids ) ? $performance_ids : null,
|
||||
'primary' => 'primary' == $total ? $primary : null,
|
||||
|
||||
) );
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $show_staff ):
|
||||
sp_get_template( 'event-staff.php', array( 'id' => $id, 'index' => $index ) );
|
||||
endif;
|
||||
?>
|
||||
<?php
|
||||
endforeach;
|
||||
}
|
||||
|
||||
do_action( 'sportspress_event_performance' );
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user