Move player list column checkboxes and add position option
This commit is contained in:
@@ -19,7 +19,37 @@ class SP_Meta_Box_List_Columns {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$selected = (array)get_post_meta( $post->ID, 'sp_columns', true );
|
||||
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
|
||||
?>
|
||||
<p><strong><?php _e( 'General', 'sportspress' ); ?></strong></p>
|
||||
<ul class="categorychecklist form-no-clear">
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input value="number" type="checkbox" name="sp_columns[]" id="sp_columns_number" <?php checked( in_array( 'number', $selected ) ); ?>>
|
||||
<?php
|
||||
if ( in_array( $orderby, array( 'number', 'name' ) ) ) {
|
||||
_e( 'Squad Number', 'sportspress' );
|
||||
} else {
|
||||
_e( 'Rank', 'sportspress' );
|
||||
}
|
||||
?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input value="team" type="checkbox" name="sp_columns[]" id="sp_columns_team" <?php checked( in_array( 'team', $selected ) ); ?>>
|
||||
<?php _e( 'Team', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input value="position" type="checkbox" name="sp_columns[]" id="sp_columns_position" <?php checked( in_array( 'position', $selected ) ); ?>>
|
||||
<?php _e( 'Position', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
<p><strong><?php _e( 'Data', 'sportspress' ); ?></strong></p>
|
||||
<div class="sp-instance">
|
||||
<ul id="sp_column-tabs" class="wp-tab-bar sp-tab-bar">
|
||||
<li class="wp-tab-active"><a href="#sp_performance-all"><?php _e( 'Performance', 'sportspress' ); ?></a></li>
|
||||
@@ -27,7 +57,6 @@ class SP_Meta_Box_List_Columns {
|
||||
<li class="wp-tab"><a href="#sp_statistic-all"><?php _e( 'Statistics', 'sportspress' ); ?></a></li>
|
||||
</ul>
|
||||
<?php
|
||||
$selected = (array)get_post_meta( $post->ID, 'sp_columns', true );
|
||||
sp_column_checklist( $post->ID, 'sp_performance', 'block', $selected );
|
||||
sp_column_checklist( $post->ID, 'sp_metric', 'none', $selected );
|
||||
sp_column_checklist( $post->ID, 'sp_statistic', 'none', $selected );
|
||||
|
||||
@@ -47,19 +47,18 @@ class SP_Meta_Box_List_Data {
|
||||
<table class="widefat sp-data-table sp-player-list-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><label for="sp_columns_number">
|
||||
<input type="checkbox" name="sp_columns[]" value="number" id="sp_columns_number" <?php checked( ! is_array( $columns ) || array_key_exists( 'number', $columns ) ); ?>>
|
||||
<?php echo 'number' == $orderby ? '#' : __( 'Rank', 'sportspress' ); ?>
|
||||
</label></th>
|
||||
<?php if ( array_key_exists( 'number', $columns ) ) { ?>
|
||||
<th><?php echo in_array( $orderby, array( 'number', 'name' ) ) ? '#' : __( 'Rank', 'sportspress' ); ?></th>
|
||||
<?php } ?>
|
||||
<th><?php _e( 'Player', 'sportspress' ); ?></th>
|
||||
<?php if ( apply_filters( 'sportspress_has_teams', true ) ) { ?>
|
||||
<th><label for="sp_columns_team">
|
||||
<input type="checkbox" name="sp_columns[]" value="team" id="sp_columns_team" <?php checked( ! is_array( $columns ) || array_key_exists( 'team', $columns ) ); ?>>
|
||||
<?php _e( 'Team', 'sportspress' ); ?>
|
||||
</label></th>
|
||||
<?php if ( array_key_exists( 'team', $columns ) && apply_filters( 'sportspress_has_teams', true ) ) { ?>
|
||||
<th><?php _e( 'Team', 'sportspress' ); ?></th>
|
||||
<?php } ?>
|
||||
<?php if ( array_key_exists( 'position', $columns ) ) { ?>
|
||||
<th><?php _e( 'Position', 'sportspress' ); ?></th>
|
||||
<?php } ?>
|
||||
<?php foreach ( $columns as $key => $label ): ?>
|
||||
<?php if ( in_array( $key, array( 'number', 'team' ) ) ) continue; ?>
|
||||
<?php if ( in_array( $key, array( 'number', 'team', 'position' ) ) ) continue; ?>
|
||||
<th><label for="sp_columns_<?php echo $key; ?>">
|
||||
<?php echo $label; ?>
|
||||
</label></th>
|
||||
@@ -81,15 +80,17 @@ class SP_Meta_Box_List_Data {
|
||||
$default_name = get_the_title( $player_id );
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<td>
|
||||
<?php
|
||||
if ( 'number' == $orderby ) {
|
||||
echo ( $number ? $number : ' ' );
|
||||
} else {
|
||||
echo $i + 1;
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<?php if ( array_key_exists( 'number', $columns ) ) { ?>
|
||||
<td>
|
||||
<?php
|
||||
if ( 'number' == $orderby ) {
|
||||
echo ( $number ? $number : ' ' );
|
||||
} else {
|
||||
echo $i + 1;
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<td>
|
||||
<?php if ( $show_player_photo ) echo get_the_post_thumbnail( $player_id, 'sportspress-fit-mini' ); ?>
|
||||
<span class="sp-default-value">
|
||||
@@ -102,7 +103,7 @@ class SP_Meta_Box_List_Data {
|
||||
<a class="button button-primary sp-save"><?php _e( 'Save', 'sportspress' ); ?></a>
|
||||
</span>
|
||||
</td>
|
||||
<?php if ( apply_filters( 'sportspress_has_teams', true ) ) { ?>
|
||||
<?php if ( array_key_exists( 'team', $columns ) && apply_filters( 'sportspress_has_teams', true ) ) { ?>
|
||||
<td>
|
||||
<?php
|
||||
$selected = sp_array_value( $player_stats, 'team', get_post_meta( get_the_ID(), 'sp_team', true ) );
|
||||
@@ -119,8 +120,25 @@ class SP_Meta_Box_List_Data {
|
||||
?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?php if ( array_key_exists( 'position', $columns ) ) { ?>
|
||||
<td>
|
||||
<?php
|
||||
$selected = sp_array_value( $player_stats, 'position', null );
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_position',
|
||||
'name' => 'sp_players[' . $player_id . '][position]',
|
||||
'show_option_blank' => __( '(Auto)', 'sportspress' ),
|
||||
'values' => 'term_id',
|
||||
'orderby' => 'slug',
|
||||
'selected' => $selected,
|
||||
'include_children' => ( 'no' == get_option( 'sportspress_event_hide_child_positions', 'no' ) ),
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
if ( in_array( $column, array( 'number', 'team' ) ) ) continue;
|
||||
if ( in_array( $column, array( 'number', 'team', 'position' ) ) ) continue;
|
||||
$value = sp_array_value( $player_stats, $column, '' );
|
||||
$placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 );
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user