Adjust player meta box for auto columns and split statistics
This commit is contained in:
@@ -32,8 +32,8 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
?>
|
?>
|
||||||
<p><strong><?php echo $league->name; ?></strong></p>
|
<p><strong><?php echo $league->name; ?></strong></p>
|
||||||
<?php
|
<?php
|
||||||
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = $player->data( $league->term_id, true );
|
list( $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes ) = $player->data( $league->term_id, true );
|
||||||
self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $i == 0 );
|
self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes && $i == 0 );
|
||||||
$i ++;
|
$i ++;
|
||||||
endforeach;
|
endforeach;
|
||||||
} else {
|
} else {
|
||||||
@@ -52,8 +52,8 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
?>
|
?>
|
||||||
<p><strong><?php echo $league->name; ?> — <?php echo $section_label; ?></strong></p>
|
<p><strong><?php echo $league->name; ?> — <?php echo $section_label; ?></strong></p>
|
||||||
<?php
|
<?php
|
||||||
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = $player->data( $league->term_id, true, $section_id );
|
list( $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes ) = $player->data( $league->term_id, true, $section_id );
|
||||||
self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $i == 0 && $s == 0 );
|
self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes && $i == 0 && $s == 0, $s == 0 );
|
||||||
$i ++;
|
$i ++;
|
||||||
endforeach;
|
endforeach;
|
||||||
$s ++;
|
$s ++;
|
||||||
@@ -73,7 +73,8 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
/**
|
/**
|
||||||
* Admin edit table
|
* Admin edit table
|
||||||
*/
|
*/
|
||||||
public static function table( $id = null, $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $leagues = array(), $has_checkboxes = false, $readonly = false ) {
|
public static function table( $id = null, $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $leagues = array(), $has_checkboxes = false, $team_select = false ) {
|
||||||
|
$readonly = false;
|
||||||
$teams = array_filter( get_post_meta( $id, 'sp_team', false ) );
|
$teams = array_filter( get_post_meta( $id, 'sp_team', false ) );
|
||||||
?>
|
?>
|
||||||
<div class="sp-data-table-container">
|
<div class="sp-data-table-container">
|
||||||
@@ -81,7 +82,7 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php _e( 'Season', 'sportspress' ); ?></th>
|
<th><?php _e( 'Season', 'sportspress' ); ?></th>
|
||||||
<?php if ( apply_filters( 'sportspress_player_team_statistics', $league_id ) ): ?>
|
<?php if ( $team_select && apply_filters( 'sportspress_player_team_statistics', $league_id ) ): ?>
|
||||||
<th>
|
<th>
|
||||||
<?php if ( $has_checkboxes ): ?>
|
<?php if ( $has_checkboxes ): ?>
|
||||||
<label for="sp_columns_team">
|
<label for="sp_columns_team">
|
||||||
@@ -104,7 +105,9 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
<td>
|
<td>
|
||||||
<label><strong><?php _e( 'Total', 'sportspress' ); ?></strong></label>
|
<label><strong><?php _e( 'Total', 'sportspress' ); ?></strong></label>
|
||||||
</td>
|
</td>
|
||||||
<td> </td>
|
<?php if ( $team_select ) { ?>
|
||||||
|
<td> </td>
|
||||||
|
<?php } ?>
|
||||||
<?php foreach ( $columns as $column => $label ): if ( $column == 'team' ) continue;
|
<?php foreach ( $columns as $column => $label ): if ( $column == 'team' ) continue;
|
||||||
?>
|
?>
|
||||||
<td><?php
|
<td><?php
|
||||||
@@ -140,7 +143,7 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
?>
|
?>
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
<?php if ( apply_filters( 'sportspress_player_team_statistics', $league_id ) ): ?>
|
<?php if ( $team_select && apply_filters( 'sportspress_player_team_statistics', $league_id ) ): ?>
|
||||||
<?php if ( $div_id == 0 ): ?>
|
<?php if ( $div_id == 0 ): ?>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ class SP_Player extends SP_Custom_Post {
|
|||||||
|
|
||||||
if ( 'manual' == get_option( 'sportspress_player_columns', 'auto' ) ) {
|
if ( 'manual' == get_option( 'sportspress_player_columns', 'auto' ) ) {
|
||||||
$usecolumns = get_post_meta( $this->ID, 'sp_columns', true );
|
$usecolumns = get_post_meta( $this->ID, 'sp_columns', true );
|
||||||
|
$has_checkboxes = true;
|
||||||
} else {
|
} else {
|
||||||
$usecolumns = array();
|
$usecolumns = array();
|
||||||
if ( is_array( $posts ) ) {
|
if ( is_array( $posts ) ) {
|
||||||
@@ -139,6 +140,7 @@ class SP_Player extends SP_Custom_Post {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$has_checkboxes = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get labels by section
|
// Get labels by section
|
||||||
@@ -536,7 +538,7 @@ class SP_Player extends SP_Custom_Post {
|
|||||||
$labels[ $key ] = $columns[ $key ];
|
$labels[ $key ] = $columns[ $key ];
|
||||||
endif;
|
endif;
|
||||||
endforeach; endif;
|
endforeach; endif;
|
||||||
return array( $labels, $data, $placeholders, $merged, $leagues );
|
return array( $labels, $data, $placeholders, $merged, $leagues, $has_checkboxes );
|
||||||
else:
|
else:
|
||||||
if ( is_array( $usecolumns ) ):
|
if ( is_array( $usecolumns ) ):
|
||||||
foreach ( $columns as $key => $label ):
|
foreach ( $columns as $key => $label ):
|
||||||
@@ -552,9 +554,7 @@ class SP_Player extends SP_Custom_Post {
|
|||||||
$merged = array();
|
$merged = array();
|
||||||
} else {
|
} else {
|
||||||
$labels['name'] = __( 'Season', 'sportspress' );
|
$labels['name'] = __( 'Season', 'sportspress' );
|
||||||
if ( in_array( 'team', $this->columns ) ) {
|
$labels['team'] = __( 'Team', 'sportspress' );
|
||||||
$labels['team'] = __( 'Team', 'sportspress' );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'yes' === get_option( 'sportspress_player_show_total', 'no' ) ) {
|
if ( 'yes' === get_option( 'sportspress_player_show_total', 'no' ) ) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ foreach( $data as $season_id => $row ):
|
|||||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||||
|
|
||||||
foreach( $labels as $key => $value ):
|
foreach( $labels as $key => $value ):
|
||||||
$output .= '<td class="data-' . $key . ( -1 === $season_id ? ' sp-highlight' : '' ) . '">' . sp_array_value( $row, $key, '—' ) . '</td>';
|
$output .= '<td class="data-' . $key . ( -1 === $season_id ? ' sp-highlight' : '' ) . '">' . sp_array_value( $row, $key, '' ) . '</td>';
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
$output .= '</tr>';
|
$output .= '</tr>';
|
||||||
|
|||||||
Reference in New Issue
Block a user