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 * @author ThemeBoy
* @category Admin * @category Admin
* @package SportsPress/Admin/Meta_Boxes * @package SportsPress/Admin/Meta_Boxes
* @version 1.7 * @version 1.7.2
*/ */
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -85,14 +85,7 @@ class SP_Meta_Box_Event_Performance {
<th>#</th> <th>#</th>
<th><?php _e( 'Player', 'sportspress' ); ?></th> <th><?php _e( 'Player', 'sportspress' ); ?></th>
<th class="column-position"> <th class="column-position">
<?php if ( $has_checkboxes ): ?> <?php _e( 'Position', 'sportspress' ); ?>
<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; ?>
</th> </th>
<?php foreach ( $labels as $key => $label ): ?> <?php foreach ( $labels as $key => $label ): ?>
<th> <th>

View File

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

View File

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