Display staff in event performance section
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta Boxes
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 0.8
|
||||
*/
|
||||
|
||||
@@ -19,11 +19,10 @@ class SP_Meta_Box_Event_Performance {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
|
||||
$stats = (array)get_post_meta( $post->ID, 'sp_players', true );
|
||||
$event = new SP_Event( $post );
|
||||
list( $labels, $columns, $stats, $teams ) = $event->performance( true );
|
||||
|
||||
// Get columns from performance variables
|
||||
$columns = sp_get_var_labels( 'sp_performance' );
|
||||
$i = 0;
|
||||
|
||||
foreach ( $teams as $key => $team_id ):
|
||||
if ( ! $team_id ) continue;
|
||||
@@ -35,10 +34,10 @@ class SP_Meta_Box_Event_Performance {
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
|
||||
<?php self::table( $columns, $data, $team_id ); ?>
|
||||
<?php self::table( $labels, $columns, $data, $team_id, $i == 0 ); ?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
$i ++;
|
||||
endforeach;
|
||||
}
|
||||
|
||||
@@ -47,12 +46,13 @@ class SP_Meta_Box_Event_Performance {
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_players', sp_array_value( $_POST, 'sp_players', array() ) );
|
||||
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin edit table
|
||||
*/
|
||||
public static function table( $columns = array(), $data = array(), $team_id ) {
|
||||
public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false ) {
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table sp-performance-table">
|
||||
@@ -60,8 +60,17 @@ class SP_Meta_Box_Event_Performance {
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th><?php _e( 'Player', 'sportspress' ); ?></th>
|
||||
<?php foreach ( $columns as $label ): ?>
|
||||
<th><?php echo $label; ?></th>
|
||||
<?php foreach ( $labels as $key => $label ): ?>
|
||||
<th>
|
||||
<?php if ( $has_checkboxes ): ?>
|
||||
<label for="sp_columns_<?php echo $key; ?>">
|
||||
<input type="checkbox" name="sp_columns[]" value="<?php echo $key; ?>" id="sp_columns_<?php echo $key; ?>" <?php checked( ! is_array( $columns ) || in_array( $key, $columns ) ); ?>>
|
||||
<?php echo $label; ?>
|
||||
</label>
|
||||
<?php else: ?>
|
||||
<?php echo $label; ?>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<?php endforeach; ?>
|
||||
<th><?php _e( 'Status', 'sportspress' ); ?></th>
|
||||
</tr>
|
||||
@@ -76,7 +85,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>" data-player="<?php echo $player_id; ?>">
|
||||
<td><?php echo ( $number ? $number : ' ' ); ?></td>
|
||||
<td><?php echo get_the_title( $player_id ); ?></td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
<?php foreach( $labels as $column => $label ):
|
||||
$value = sp_array_value( $player_performance, $column, '' );
|
||||
?>
|
||||
<td>
|
||||
@@ -95,7 +104,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
<tr class="sp-row sp-total<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<td> </td>
|
||||
<td><strong><?php _e( 'Total', 'sportspress' ); ?></strong></td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
<?php foreach( $labels as $column => $label ):
|
||||
$player_id = 0;
|
||||
$player_performance = sp_array_value( $data, 0, array() );
|
||||
$value = sp_array_value( $player_performance, $column, '' );
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta Boxes
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 0.8
|
||||
*/
|
||||
|
||||
@@ -19,21 +19,9 @@ class SP_Meta_Box_Event_Results {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
|
||||
|
||||
$results = (array)get_post_meta( $post->ID, 'sp_results', true );
|
||||
|
||||
// Get columns from result variables
|
||||
$columns = sp_get_var_labels( 'sp_result' );
|
||||
|
||||
// Get results for all teams
|
||||
$data = sp_array_combine( $teams, $results );
|
||||
|
||||
?>
|
||||
<div>
|
||||
<?php self::table( $columns, $data ); ?>
|
||||
</div>
|
||||
<?php
|
||||
$event = new SP_Event( $post );
|
||||
list( $columns, $usecolumns, $data ) = $event->results( true );
|
||||
self::table( $columns, $usecolumns, $data );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,12 +30,13 @@ class SP_Meta_Box_Event_Results {
|
||||
public static function save( $post_id, $post ) {
|
||||
$results = (array)sp_array_value( $_POST, 'sp_results', array() );
|
||||
update_post_meta( $post_id, 'sp_results', $results );
|
||||
update_post_meta( $post_id, 'sp_result_columns', sp_array_value( $_POST, 'sp_result_columns', array() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin edit table
|
||||
*/
|
||||
public static function table( $columns = array(), $data = array() ) {
|
||||
public static function table( $columns = array(), $usecolumns = array(), $data = array() ) {
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table">
|
||||
@@ -55,9 +44,19 @@ class SP_Meta_Box_Event_Results {
|
||||
<tr>
|
||||
<th class="column-team"><?php _e( 'Team', 'sportspress' ); ?></th>
|
||||
<?php foreach ( $columns as $key => $label ): ?>
|
||||
<th class="outcome-<?php echo $key; ?>"><?php echo $label; ?></th>
|
||||
<th class="column-<?php echo $key; ?>">
|
||||
<label for="sp_result_columns_<?php echo $key; ?>">
|
||||
<input type="checkbox" name="sp_result_columns[]" value="<?php echo $key; ?>" id="sp_result_columns_<?php echo $key; ?>" <?php checked( ! is_array( $usecolumns ) || in_array( $key, $usecolumns ) ); ?>>
|
||||
<?php echo $label; ?>
|
||||
</label>
|
||||
</th>
|
||||
<?php endforeach; ?>
|
||||
<th class="column-outcome"><?php _e( 'Outcome', 'sportspress' ); ?></th>
|
||||
<th class="column-outcome">
|
||||
<label for="sp_result_columns_outcome">
|
||||
<input type="checkbox" name="sp_result_columns[]" value="outcome" id="sp_result_columns_outcome" <?php checked( ! is_array( $usecolumns ) || in_array( 'outcome', $usecolumns ) ); ?>>
|
||||
<?php _e( 'Outcome', 'sportspress' ); ?>
|
||||
</label>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@@ -97,6 +97,23 @@ class SP_Settings_Events extends SP_Settings_Page {
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Staff', 'sportspress' ),
|
||||
'desc' => __( 'Display staff', 'sportspress' ),
|
||||
'id' => 'sportspress_event_show_staff',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Link staff', 'sportspress' ),
|
||||
'id' => 'sportspress_event_link_staff',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
),
|
||||
|
||||
array( 'type' => 'sectionend', 'id' => 'event_options' ),
|
||||
|
||||
array( 'title' => __( 'Calendars', 'sportspress' ), 'type' => 'title', 'id' => 'calendar_options' ),
|
||||
|
||||
Reference in New Issue
Block a user