Add ability to display positions in event performance tables

This commit is contained in:
Brian Miyaji
2015-03-16 22:36:41 +11:00
parent 820b44cae8
commit 8922ff07e4
3 changed files with 18 additions and 13 deletions

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 1.7
* @version 1.7.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -85,14 +85,7 @@ class SP_Meta_Box_Event_Performance {
<th>#</th>
<th><?php _e( 'Player', 'sportspress' ); ?></th>
<th class="column-position">
<?php if ( $has_checkboxes ): ?>
<label for="sp_columns_position">
<input type="checkbox" name="sp_columns[]" value="position" id="sp_columns_position" <?php checked( ! is_array( $columns ) || in_array( 'position', $columns ) ); ?>>
<?php _e( 'Position', 'sportspress' ); ?>
</label>
<?php else: ?>
<?php _e( 'Position', 'sportspress' ); ?>
<?php endif; ?>
<?php _e( 'Position', 'sportspress' ); ?>
</th>
<?php foreach ( $labels as $key => $label ): ?>
<th>

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 1.7
* @version 1.7.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -241,6 +241,14 @@ class SP_Settings_Events extends SP_Settings_Page {
'manual' => __( 'Manual', 'sportspress' ),
),
),
array(
'title' => __( 'Position', 'sportspress' ),
'desc' => __( 'Display position', 'sportspress' ),
'id' => 'sportspress_event_show_position',
'default' => 'yes',
'type' => 'checkbox',
),
array(
'title' => __( 'Mode', 'sportspress' ),

View File

@@ -5,7 +5,7 @@
* The SportsPress event class handles individual event data.
*
* @class SP_Event
* @version 1.7
* @version 1.7.2
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy
@@ -64,7 +64,7 @@ class SP_Event extends SP_Custom_Post{
endif;
if ( 'yes' == get_option( 'sportspress_event_show_outcome', 'no' ) ):
$columns[ 'outcome' ] = __( 'Outcome', 'sportspress' );
$columns['outcome'] = __( 'Outcome', 'sportspress' );
endif;
endif;
$data[0] = $columns;
@@ -97,7 +97,7 @@ class SP_Event extends SP_Custom_Post{
$performance[ $team_id ][ $player_id ]['number'] = get_post_meta( $player_id, 'sp_number', true );
endif;
if ( ! array_key_exists( 'position', $player_performance ) || $player_performance['position'] == null ):
$performance[ $team_id ][ $player_id ]['position'] = get_post_meta( $player_id, 'sp_position', true );
$performance[ $team_id ][ $player_id ]['position'] = sp_get_the_term_id( $player_id, 'sp_position', null );
endif;
endforeach;
@@ -122,6 +122,10 @@ class SP_Event extends SP_Custom_Post{
endif;
endforeach;
endif;
if ( 'no' == get_option( 'sportspress_event_show_position', 'yes' ) ):
unset( $labels['position'] );
endif;
$performance[0] = $labels;
return $performance;
endif;