Add substitution times

This commit is contained in:
Brian Miyaji
2016-09-12 11:23:55 +10:00
parent 9483e54294
commit c4eb3d7640
3 changed files with 30 additions and 1 deletions

View File

@@ -59,7 +59,9 @@ if ( ! isset( $subs ) ) $subs = array();
foreach ( $subs as $sub_id => $sub ):
if ( ! $sub_id )
continue;
$lineup_sub_relation[ sp_array_value( $sub, 'sub', 0 ) ] = $sub_id;
$index = sp_array_value( $sub, 'sub', 0 );
$index = substr( $index, 0, strpos( $index, ' ' ) );
$lineup_sub_relation[ $index ] = $sub_id;
endforeach;
$data = apply_filters( 'sportspress_event_performance_players', $data, $lineups, $subs, $mode );
@@ -91,8 +93,21 @@ if ( ! isset( $subs ) ) $subs = array();
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>';
$sub = sp_array_value( sp_array_value( $data, $lineup_sub_relation[ $player_id ], array() ), 'sub', null );
if ( $show_minutes && ! empty( $sub ) ):
preg_match( '#\((.*?)\)#', $data[ $lineup_sub_relation[ $player_id ] ]['sub'], $match );
if ( ! empty( $match ) && isset( $match[1] ) ):
$name .= $match[1];
endif;
endif;
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>';
if ( $show_minutes && ! empty( $row['sub'] ) ):
preg_match( '#\((.*?)\)#', $row['sub'], $match );
if ( ! empty( $match ) && isset( $match[1] ) ):
$name .= $match[1];
endif;
endif;
endif;
echo '<td class="data-name">' . $name . '</td>';

View File

@@ -14,6 +14,7 @@ $show_players = get_option( 'sportspress_event_show_players', 'yes' ) === 'yes'
$show_staff = get_option( 'sportspress_event_show_staff', 'yes' ) === 'yes' ? true : false;
$show_total = get_option( 'sportspress_event_show_total', 'yes' ) === 'yes' ? true : false;
$show_numbers = get_option( 'sportspress_event_show_player_numbers', 'yes' ) === 'yes' ? true : false;
$show_minutes = get_option( 'sportspress_event_performance_show_minutes', 'yes' ) === 'yes' ? true : false;
$sections = get_option( 'sportspress_event_performance_sections', -1 );
$abbreviate_teams = get_option( 'sportspress_abbreviate_teams', 'yes' ) === 'yes' ? true : false;
$reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
@@ -105,6 +106,7 @@ if ( is_array( $teams ) ):
'sortable' => $sortable,
'show_players' => $show_players,
'show_numbers' => $show_numbers,
'show_minutes' => $show_minutes,
'show_total' => $show_total,
'caption' => __( 'Box Score', 'sportspress' ),
'labels' => $labels,
@@ -212,6 +214,7 @@ if ( is_array( $teams ) ):
'sortable' => $sortable,
'show_players' => $show_team_players,
'show_numbers' => $show_numbers,
'show_minutes' => $show_minutes,
'show_total' => $show_total,
'caption' => 0 == $s && $team_id ? sp_get_team_name( $team_id, $abbreviate_teams ) : null,
'labels' => $labels[ $section_id ],
@@ -247,6 +250,7 @@ if ( is_array( $teams ) ):
'sortable' => $sortable,
'show_players' => $show_team_players,
'show_numbers' => $show_numbers,
'show_minutes' => $show_minutes,
'show_total' => $show_total,
'caption' => $team_id ? sp_get_team_name( $team_id, $abbreviate_teams ) : null,
'labels' => $labels,