Recover numbers option in event edit screen

This commit is contained in:
Brian Miyaji
2016-02-25 20:27:39 +11:00
parent 9f6508c649
commit 134cd5775b
2 changed files with 15 additions and 12 deletions

View File

@@ -33,6 +33,9 @@ class SP_Meta_Box_Event_Performance {
$has_checkboxes = true; $has_checkboxes = true;
else else
$has_checkboxes = false; $has_checkboxes = false;
// Get player number option
$numbers = 'yes' == get_option( 'sportspress_event_show_player_numbers', 'yes' ) ? true : false;
// Get positions // Get positions
$positions = array(); $positions = array();
@@ -57,7 +60,7 @@ class SP_Meta_Box_Event_Performance {
// Check if individual mode // Check if individual mode
$is_individual = get_option( 'sportspress_load_individual_mode_module', 'no' ) === 'yes' ? true : false; $is_individual = get_option( 'sportspress_load_individual_mode_module', 'no' ) === 'yes' ? true : false;
self::tables( $post->ID, $stats, $labels, $columns, $teams, $has_checkboxes, $positions, $status, $formats, $order, $is_individual ); self::tables( $post->ID, $stats, $labels, $columns, $teams, $has_checkboxes, $positions, $status, $formats, $order, $numbers, $is_individual );
} }
/** /**
@@ -72,15 +75,15 @@ class SP_Meta_Box_Event_Performance {
/** /**
* Admin edit tables * Admin edit tables
*/ */
public static function tables( $post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $positions = array(), $status = true, $formats = array(), $order = array(), $is_individual = false ) { public static function tables( $post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $positions = array(), $status = true, $formats = array(), $order = array(), $numbers = true, $is_individual = false ) {
$sections = get_option( 'sportspress_event_performance_sections', -1 ); $sections = get_option( 'sportspress_event_performance_sections', -1 );
if ( $is_individual ) { if ( $is_individual ) {
?> ?>
<div class="sp-data-table-container"> <div class="sp-data-table-container">
<table class="widefat sp-data-table sp-performance-table sp-sortable-table"> <table class="widefat sp-data-table sp-performance-table sp-sortable-table">
<?php self::header( $columns, $labels, $positions, $has_checkboxes, $status, false, false, -1, $formats ); ?> <?php self::header( $columns, $labels, $positions, $has_checkboxes, $status, false, $numbers, -1, $formats ); ?>
<?php self::footer( sp_array_value( $stats, -1 ), $labels, 0, $positions, $status, false, false, -1, $formats ); ?> <?php self::footer( sp_array_value( $stats, -1 ), $labels, 0, $positions, $status, false, $numbers, -1, $formats ); ?>
<tbody> <tbody>
<?php <?php
foreach ( $teams as $key => $team_id ): foreach ( $teams as $key => $team_id ):
@@ -92,7 +95,7 @@ class SP_Meta_Box_Event_Performance {
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) ); $data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
foreach ( $data as $player_id => $player_performance ): foreach ( $data as $player_id => $player_performance ):
self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, false, false, -1, $formats ); self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, false, $numbers, -1, $formats );
endforeach; endforeach;
endforeach; endforeach;
?> ?>
@@ -114,7 +117,7 @@ class SP_Meta_Box_Event_Performance {
?> ?>
<div> <div>
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p> <p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
<?php self::table( $labels, $columns, $data, $team_id, $has_checkboxes, $positions, $status, -1, $formats, $order ); ?> <?php self::table( $labels, $columns, $data, $team_id, $has_checkboxes, $positions, $status, -1, $formats, $order, $numbers ); ?>
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels, $columns, $data, $team_id ); ?> <?php do_action( 'sportspress_after_event_performance_table_admin', $labels, $columns, $data, $team_id ); ?>
</div> </div>
<?php } else { ?> <?php } else { ?>
@@ -176,7 +179,7 @@ class SP_Meta_Box_Event_Performance {
?> ?>
<div> <div>
<p><strong><?php echo get_the_title( $team_id ); ?> &mdash; <?php echo $section_label; ?></strong></p> <p><strong><?php echo get_the_title( $team_id ); ?> &mdash; <?php echo $section_label; ?></strong></p>
<?php self::table( $labels[ $section_id ], $columns, $data[ $section_id ], $team_id, $has_checkboxes, $positions, $status, $section_id, $formats, $order ); ?> <?php self::table( $labels[ $section_id ], $columns, $data[ $section_id ], $team_id, $has_checkboxes, $positions, $status, $section_id, $formats, $order, $numbers ); ?>
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels[ $section_id ], $columns, $data[ $section_id ], $team_id ); ?> <?php do_action( 'sportspress_after_event_performance_table_admin', $labels[ $section_id ], $columns, $data[ $section_id ], $team_id ); ?>
</div> </div>
<?php <?php
@@ -190,12 +193,12 @@ class SP_Meta_Box_Event_Performance {
/** /**
* Admin edit table * Admin edit table
*/ */
public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false, $positions = array(), $status = true, $section = -1, $formats = array(), $order = array() ) { public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false, $positions = array(), $status = true, $section = -1, $formats = array(), $order = array(), $numbers = true ) {
?> ?>
<div class="sp-data-table-container"> <div class="sp-data-table-container">
<table class="widefat sp-data-table sp-performance-table sp-sortable-table"> <table class="widefat sp-data-table sp-performance-table sp-sortable-table">
<?php self::header( $columns, $labels, $positions, $has_checkboxes, $status, true, true, $section, $formats ); ?> <?php self::header( $columns, $labels, $positions, $has_checkboxes, $status, true, $numbers, $section, $formats ); ?>
<?php self::footer( $data, $labels, $team_id, $positions, $status, true, true, $section, $formats ); ?> <?php self::footer( $data, $labels, $team_id, $positions, $status, true, $numbers, $section, $formats ); ?>
<tbody> <tbody>
<?php <?php
if ( 1 == $section && is_array( $order ) && sizeof( $order ) ) { if ( 1 == $section && is_array( $order ) && sizeof( $order ) ) {
@@ -205,7 +208,7 @@ class SP_Meta_Box_Event_Performance {
} }
} }
foreach ( $data as $player_id => $player_performance ): foreach ( $data as $player_id => $player_performance ):
self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, true, true, $section, $formats ); self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, true, $numbers, $section, $formats );
endforeach; endforeach;
?> ?>
</tbody> </tbody>

View File

@@ -86,7 +86,7 @@ class SP_Event extends SP_Custom_Post{
$vars = get_posts( $args ); $vars = get_posts( $args );
$labels = array( 'number' => '#' ); $labels = array();
foreach ( $vars as $var ) { foreach ( $vars as $var ) {
$labels[ $var->post_name ] = $var->post_title; $labels[ $var->post_name ] = $var->post_title;
$format = get_post_meta( $var->ID, 'sp_format', true ); $format = get_post_meta( $var->ID, 'sp_format', true );