Enable dropdown selector for player list teams
This commit is contained in:
@@ -66,7 +66,7 @@ class SP_Meta_Box_List_Data {
|
||||
$i = 0;
|
||||
foreach ( $data as $player_id => $player_stats ):
|
||||
if ( !$player_id ) continue;
|
||||
$team = get_post_meta( $player_id, 'sp_team', true );
|
||||
$teams = get_post_meta( $player_id, 'sp_team', false );
|
||||
$div = get_term( $player_id, 'sp_season' );
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
|
||||
@@ -87,7 +87,21 @@ class SP_Meta_Box_List_Data {
|
||||
<a class="button button-primary sp-save"><?php _e( 'Save', 'sportspress' ); ?></a>
|
||||
</span>
|
||||
</td>
|
||||
<td><?php echo get_the_title( $team ); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
$selected = sp_array_value( $player_stats, 'team', get_post_meta( get_the_ID(), 'sp_team', true ) );
|
||||
if ( ! $selected ) $selected = get_post_meta( $player_id, 'sp_team', true );
|
||||
$include = get_post_meta( $player_id, 'sp_team' );
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_players[' . $player_id . '][team]',
|
||||
'include' => $include,
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
?>
|
||||
</td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
if ( $column == 'team' ) continue;
|
||||
$value = sp_array_value( $player_stats, $column, '' );
|
||||
@@ -118,7 +132,7 @@ class SP_Meta_Box_List_Data {
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th><?php _e( 'Player', 'sportspress' ); ?></th>
|
||||
<?php foreach ( $columns as $key => $label ): ?>
|
||||
<?php foreach ( $columns as $key => $label ): if ( $key == 'team' ) continue; ?>
|
||||
<th><?php echo $label; ?></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
@@ -138,6 +152,7 @@ class SP_Meta_Box_List_Data {
|
||||
<?php echo get_the_title( $player_id ); ?>
|
||||
</td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
if ( $column == 'team' ) continue;
|
||||
$value = sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $column, '' );
|
||||
?>
|
||||
<td><input type="text" name="sp_adjustments[<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="0" data-matrix="<?php echo $player_id; ?>_<?php echo $column; ?>" /></td>
|
||||
|
||||
@@ -24,6 +24,7 @@ class SP_Player_List extends SP_Custom_Post {
|
||||
public function __construct( $post ) {
|
||||
parent::__construct( $post );
|
||||
$this->columns = get_post_meta( $this->ID, 'sp_columns', true );
|
||||
if ( ! is_array( $this->columns ) ) $this->columns = array();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -313,6 +314,7 @@ class SP_Player_List extends SP_Custom_Post {
|
||||
$merged[ $player_id ] = array();
|
||||
$player_data['number'] = get_post_meta( $player_id, 'sp_number', true );
|
||||
$player_data['name'] = get_the_title( $player_id );
|
||||
$player_data['team'] = get_post_meta( $player_id, 'sp_team', true );
|
||||
|
||||
foreach( $player_data as $key => $value ):
|
||||
|
||||
|
||||
@@ -125,16 +125,12 @@ foreach ( $groups as $group ):
|
||||
$output .= '<td class="data-name">' . $name . '</td>';
|
||||
|
||||
if ( array_key_exists( 'team', $labels ) ):
|
||||
$teams = get_post_meta( $player_id, 'sp_current_team' );
|
||||
$team_names = array();
|
||||
foreach ( $teams as $team ):
|
||||
$team_name = get_the_title( $team );
|
||||
if ( $link_teams ):
|
||||
$team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
|
||||
endif;
|
||||
$team_names[] = $team_name;
|
||||
endforeach;
|
||||
$output .= '<td class="data-team">' . implode( ', ', $team_names ) . '</td>';
|
||||
$team = sp_array_value( $row, 'team', get_post_meta( $id, 'sp_team', true ) );
|
||||
$team_name = get_the_title( $team );
|
||||
if ( $link_teams ):
|
||||
$team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
|
||||
endif;
|
||||
$output .= '<td class="data-team">' . $team_name . '</td>';
|
||||
endif;
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
|
||||
Reference in New Issue
Block a user