Add substitution times
This commit is contained in:
@@ -425,8 +425,18 @@ class SP_Meta_Box_Event_Performance {
|
||||
<?php endforeach; ?>
|
||||
<?php if ( apply_filters( 'sportspress_event_performance_show_status', $status, $section ) ) { ?>
|
||||
<td class="sp-status-selector">
|
||||
<?php
|
||||
// Get substitute times
|
||||
if ( is_array( $player_timeline ) ) {
|
||||
$times = sp_array_value( $player_timeline, 'sub', array() );
|
||||
} else {
|
||||
$times = false;
|
||||
}
|
||||
?>
|
||||
<?php echo self::status_select( $team_id, $player_id, sp_array_value( $player_performance, 'status', null ) ); ?>
|
||||
<?php echo self::sub_select( $team_id, $player_id, sp_array_value( $player_performance, 'sub', null ), $data ); ?>
|
||||
<input class="sp-sync-input small-text" type="text" name="sp_timeline[<?php echo $team_id; ?>][<?php echo $player_id; ?>][sub][]" value="<?php echo esc_attr( sp_array_value( $times, 0, '' ) ); ?>" placeholder="-" />
|
||||
<span class="description"><?php _e( 'mins', 'sportspress' ); ?></span>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
|
||||
@@ -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>';
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user