Display staff in event performance section

This commit is contained in:
Brian Miyaji
2014-06-18 13:29:41 +10:00
parent 6333025646
commit fedbdb72e4
8 changed files with 239 additions and 112 deletions

View File

@@ -4,7 +4,7 @@
* *
* @author ThemeBoy * @author ThemeBoy
* @category Admin * @category Admin
* @package SportsPress/Admin/Meta Boxes * @package SportsPress/Admin/Meta_Boxes
* @version 0.8 * @version 0.8
*/ */
@@ -19,11 +19,10 @@ class SP_Meta_Box_Event_Performance {
* Output the metabox * Output the metabox
*/ */
public static function output( $post ) { public static function output( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false ); $event = new SP_Event( $post );
$stats = (array)get_post_meta( $post->ID, 'sp_players', true ); list( $labels, $columns, $stats, $teams ) = $event->performance( true );
// Get columns from performance variables $i = 0;
$columns = sp_get_var_labels( 'sp_performance' );
foreach ( $teams as $key => $team_id ): foreach ( $teams as $key => $team_id ):
if ( ! $team_id ) continue; if ( ! $team_id ) continue;
@@ -35,10 +34,10 @@ 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( $columns, $data, $team_id ); ?> <?php self::table( $labels, $columns, $data, $team_id, $i == 0 ); ?>
</div> </div>
<?php <?php
$i ++;
endforeach; endforeach;
} }
@@ -47,12 +46,13 @@ class SP_Meta_Box_Event_Performance {
*/ */
public static function save( $post_id, $post ) { 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_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 * 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"> <div class="sp-data-table-container">
<table class="widefat sp-data-table sp-performance-table"> <table class="widefat sp-data-table sp-performance-table">
@@ -60,8 +60,17 @@ class SP_Meta_Box_Event_Performance {
<tr> <tr>
<th>#</th> <th>#</th>
<th><?php _e( 'Player', 'sportspress' ); ?></th> <th><?php _e( 'Player', 'sportspress' ); ?></th>
<?php foreach ( $columns as $label ): ?> <?php foreach ( $labels as $key => $label ): ?>
<th><?php echo $label; ?></th> <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; ?> <?php endforeach; ?>
<th><?php _e( 'Status', 'sportspress' ); ?></th> <th><?php _e( 'Status', 'sportspress' ); ?></th>
</tr> </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; ?>"> <tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>" data-player="<?php echo $player_id; ?>">
<td><?php echo ( $number ? $number : '&nbsp;' ); ?></td> <td><?php echo ( $number ? $number : '&nbsp;' ); ?></td>
<td><?php echo get_the_title( $player_id ); ?></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, '' ); $value = sp_array_value( $player_performance, $column, '' );
?> ?>
<td> <td>
@@ -95,7 +104,7 @@ class SP_Meta_Box_Event_Performance {
<tr class="sp-row sp-total<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>"> <tr class="sp-row sp-total<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td>&nbsp;</td> <td>&nbsp;</td>
<td><strong><?php _e( 'Total', 'sportspress' ); ?></strong></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_id = 0;
$player_performance = sp_array_value( $data, 0, array() ); $player_performance = sp_array_value( $data, 0, array() );
$value = sp_array_value( $player_performance, $column, '' ); $value = sp_array_value( $player_performance, $column, '' );

View File

@@ -4,7 +4,7 @@
* *
* @author ThemeBoy * @author ThemeBoy
* @category Admin * @category Admin
* @package SportsPress/Admin/Meta Boxes * @package SportsPress/Admin/Meta_Boxes
* @version 0.8 * @version 0.8
*/ */
@@ -19,21 +19,9 @@ class SP_Meta_Box_Event_Results {
* Output the metabox * Output the metabox
*/ */
public static function output( $post ) { public static function output( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false ); $event = new SP_Event( $post );
list( $columns, $usecolumns, $data ) = $event->results( true );
$results = (array)get_post_meta( $post->ID, 'sp_results', true ); self::table( $columns, $usecolumns, $data );
// 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
} }
/** /**
@@ -42,12 +30,13 @@ class SP_Meta_Box_Event_Results {
public static function save( $post_id, $post ) { public static function save( $post_id, $post ) {
$results = (array)sp_array_value( $_POST, 'sp_results', array() ); $results = (array)sp_array_value( $_POST, 'sp_results', array() );
update_post_meta( $post_id, 'sp_results', $results ); 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 * 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"> <div class="sp-data-table-container">
<table class="widefat sp-data-table"> <table class="widefat sp-data-table">
@@ -55,9 +44,19 @@ class SP_Meta_Box_Event_Results {
<tr> <tr>
<th class="column-team"><?php _e( 'Team', 'sportspress' ); ?></th> <th class="column-team"><?php _e( 'Team', 'sportspress' ); ?></th>
<?php foreach ( $columns as $key => $label ): ?> <?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; ?> <?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> </tr>
</thead> </thead>
<tbody> <tbody>

View File

@@ -97,6 +97,23 @@ class SP_Settings_Events extends SP_Settings_Page {
'type' => 'checkbox', '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( 'type' => 'sectionend', 'id' => 'event_options' ),
array( 'title' => __( 'Calendars', 'sportspress' ), 'type' => 'title', 'id' => 'calendar_options' ), array( 'title' => __( 'Calendars', 'sportspress' ), 'type' => 'title', 'id' => 'calendar_options' ),

View File

@@ -23,22 +23,53 @@ class SP_Event extends SP_Custom_Post{
return $post_status; return $post_status;
} }
public function performance() { public function results( $admin = false ) {
$teams = (array)get_post_meta( $this->ID, 'sp_team', false );
$results = (array)get_post_meta( $this->ID, 'sp_results', true );
// Get columns from result variables
$columns = sp_get_var_labels( 'sp_result' );
// Get result columns to display
$usecolumns = get_post_meta( $this->ID, 'sp_result_columns', true );
// Get results for all teams
$data = sp_array_combine( $teams, $results );
if ( $admin ):
return array( $columns, $usecolumns, $data );
else:
// Add outcome to result columns
$columns['outcome'] = __( 'Outcome', 'sportspress' );
if ( ! is_array( $usecolumns ) )
$usecolumns = array();
foreach ( $columns as $key => $label ):
if ( ! in_array( $key, $usecolumns ) ):
unset( $columns[ $key ] );
endif;
endforeach;
$data[0] = $columns;
return $data;
endif;
}
public function performance( $admin = false ) {
$teams = (array)get_post_meta( $this->ID, 'sp_team', false ); $teams = (array)get_post_meta( $this->ID, 'sp_team', false );
$performance = (array)get_post_meta( $this->ID, 'sp_players', true ); $performance = (array)get_post_meta( $this->ID, 'sp_players', true );
$performance_labels = sp_get_var_labels( 'sp_performance' ); $labels = sp_get_var_labels( 'sp_performance' );
$columns = get_post_meta( $this->ID, 'sp_columns', true );
$output = array(); $output = array();
foreach( $teams as $i => $team_id ): foreach( $teams as $i => $team_id ):
$players = sp_array_between( (array)get_post_meta( $this->ID, 'sp_player', false ), 0, $i ); $players = sp_array_between( (array)get_post_meta( $this->ID, 'sp_player', false ), 0, $i );
$data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) ); $data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
$totals = array(); $totals = array();
foreach( $performance_labels as $key => $label ): foreach( $labels as $key => $label ):
$totals[ $key ] = 0; $totals[ $key ] = 0;
endforeach; endforeach;
foreach( $data as $player_id => $player_performance ): foreach( $data as $player_id => $player_performance ):
foreach( $performance_labels as $key => $label ): foreach( $labels as $key => $label ):
if ( array_key_exists( $key, $totals ) ): if ( array_key_exists( $key, $totals ) ):
$totals[ $key ] += sp_array_value( $player_performance, $key, 0 ); $totals[ $key ] += sp_array_value( $player_performance, $key, 0 );
endif; endif;
@@ -74,7 +105,21 @@ class SP_Event extends SP_Custom_Post{
); );
endforeach; endforeach;
return $output; if ( $admin ):
return array( $labels, $columns, $performance, $teams );
else:
// Add status to performance labels
$labels['status'] = __( 'Status', 'sportspress' );
if ( ! is_array( $columns ) )
$columns = array();
foreach ( $labels as $key => $label ):
if ( ! in_array( $key, $columns ) ):
unset( $labels[ $key ] );
endif;
endforeach;
$performance[0] = $labels;
return $performance;
endif;
} }
public function lineup_filter( $v ) { public function lineup_filter( $v ) {

View File

@@ -7,7 +7,7 @@
* @author ThemeBoy * @author ThemeBoy
* @category Core * @category Core
* @package SportsPress/Functions * @package SportsPress/Functions
* @version 0.8.4 * @version 1.1
*/ */
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -107,6 +107,7 @@ function sportspress_the_title( $title, $id = null ) {
endif; endif;
elseif ( is_singular( 'sp_event' ) && get_option( 'sportspress_event_show_logos', 'yes' ) == 'yes' ): elseif ( is_singular( 'sp_event' ) && get_option( 'sportspress_event_show_logos', 'yes' ) == 'yes' ):
$teams = get_post_meta( $id, 'sp_team' ); $teams = get_post_meta( $id, 'sp_team' );
$teams = array_filter( $teams );
if ( $teams ): if ( $teams ):
$title .= '<div class="sp-event-teams">'; $title .= '<div class="sp-event-teams">';
$delimiter = get_option( 'sportspress_event_teams_delimiter', 'vs' ); $delimiter = get_option( 'sportspress_event_teams_delimiter', 'vs' );

View File

@@ -13,32 +13,35 @@ if ( ! isset( $id ) )
$id = get_the_ID(); $id = get_the_ID();
$event = new SP_Event( $id ); $event = new SP_Event( $id );
$data = $event->performance();
// The first row should be column labels
$labels = $data[0];
// Remove the first row to leave us with the actual data
unset( $data[0] );
$data = array_filter( $data );
$teams = (array)get_post_meta( $id, 'sp_team', false ); $teams = (array)get_post_meta( $id, 'sp_team', false );
$staff = (array)get_post_meta( $id, 'sp_staff', false );
$status = $event->status(); $status = $event->status();
$stats = (array)get_post_meta( $id, 'sp_players', true );
if ( $status == 'results' ):
$performance_labels = sp_get_var_labels( 'sp_performance' );
else:
$performance_labels = array();
endif;
$link_posts = get_option( 'sportspress_event_link_players', 'yes' ) == 'yes' ? true : false; $link_posts = get_option( 'sportspress_event_link_players', 'yes' ) == 'yes' ? true : false;
$sortable = get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false; $sortable = get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false;
$responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false; $responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false;
foreach( $teams as $key => $team_id ): foreach( $teams as $index => $team_id ):
if ( ! $team_id ) continue; if ( ! $team_id ) continue;
// Get results for players in the team
$players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index );
$has_players = sizeof( $players ) > 1;
if ( ! $has_players && $status != 'results' ) continue;
$totals = array(); $totals = array();
// Get results for players in the team $data = sp_array_combine( $players, sp_array_value( $data, $team_id, array() ) );
$players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $key );
$has_players = sizeof( $players ) > 1;
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
?> ?>
<h3><?php echo get_the_title( $team_id ); ?></h3> <h3><?php echo get_the_title( $team_id ); ?></h3>
<div class="sp-table-wrapper sp-scrollable-table-wrapper"> <div class="sp-table-wrapper sp-scrollable-table-wrapper">
@@ -47,8 +50,8 @@ foreach( $teams as $key => $team_id ):
<tr> <tr>
<?php if ( $has_players ): ?> <?php if ( $has_players ): ?>
<th class="data-number">#</th> <th class="data-number">#</th>
<th class="data-name"><?php echo __( 'Player'), 'sportspress' ; ?></th> <th class="data-name"><?php _e( 'Player', 'sportspress' ); ?></th>
<?php endif; foreach( $performance_labels as $key => $label ): ?> <?php endif; foreach( $labels as $key => $label ): ?>
<th class="data-<?php echo $key; ?>"><?php echo $label; ?></th> <th class="data-<?php echo $key; ?>"><?php echo $label; ?></th>
<?php endforeach; ?> <?php endforeach; ?>
</tr> </tr>
@@ -101,7 +104,7 @@ foreach( $teams as $key => $team_id ):
echo '<td class="data-name">' . $name . '</td>'; echo '<td class="data-name">' . $name . '</td>';
foreach( $performance_labels as $key => $label ): foreach( $labels as $key => $label ):
if ( $key == 'name' ) if ( $key == 'name' )
continue; continue;
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
@@ -135,7 +138,7 @@ foreach( $teams as $key => $team_id ):
$row = $data[0]; $row = $data[0];
foreach( $performance_labels as $key => $label ): foreach( $labels as $key => $label ):
if ( $key == 'name' ): if ( $key == 'name' ):
continue; continue;
endif; endif;
@@ -152,4 +155,5 @@ foreach( $teams as $key => $team_id ):
<?php endif; ?> <?php endif; ?>
</table> </table>
</div> </div>
<?php if ( get_option( 'sportspress_event_show_staff', 'yes' ) == 'yes' ) sp_get_template( 'event-staff.php', array( 'id' => $id, 'index' => $index ) ); ?>
<?php endforeach; <?php endforeach;

View File

@@ -4,7 +4,7 @@
* *
* @author ThemeBoy * @author ThemeBoy
* @package SportsPress/Templates * @package SportsPress/Templates
* @version 0.8 * @version 1.1
*/ */
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -12,35 +12,39 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $id ) ) if ( ! isset( $id ) )
$id = get_the_ID(); $id = get_the_ID();
$defaults = array( $event = new SP_Event( $id );
'show_outcomes' => get_option( 'sportspress_event_show_outcomes', 'yes' ) == 'yes' ? true : false, $status = $event->status();
);
extract( $defaults, EXTR_SKIP ); if ( 'results' != $status ) return;
$teams = (array)get_post_meta( $id, 'sp_team', false ); // Get event result data
$results = array_filter( sp_array_combine( $teams, (array)get_post_meta( $id, 'sp_results', true ) ), 'array_filter' ); $data = $event->results();
$result_labels = sp_get_var_labels( 'sp_result' );
$output = ''; // The first row should be column labels
$labels = $data[0];
// Initialize and check // Remove the first row to leave us with the actual data
$table_rows = ''; unset( $data[0] );
$i = 0; $data = array_filter( $data );
if ( empty( $results ) ) if ( empty( $data ) )
return false; return false;
foreach( $results as $team_id => $result ): $show_outcomes = array_key_exists( 'outcome', $labels );
if ( count( array_filter( $results ) ) ):
if ( $show_outcomes ): // Initialize
$outcomes = array(); $output = '';
$result_outcome = $result['outcome']; $table_rows = '';
if ( ! is_array( $result_outcome ) ): $i = 0;
$result_outcome = (array) $result_outcome;
endif; foreach( $data as $team_id => $result ):
if ( $show_outcomes ):
$outcomes = array();
$result_outcome = sp_array_value( $result, 'outcome' );
if ( ! is_array( $result_outcome ) ):
$outcomes = array( '&mdash;' );
else:
foreach( $result_outcome as $outcome ): foreach( $result_outcome as $outcome ):
$the_outcome = get_page_by_path( $outcome, OBJECT, 'sp_outcome' ); $the_outcome = get_page_by_path( $outcome, OBJECT, 'sp_outcome' );
if ( is_object( $the_outcome ) ): if ( is_object( $the_outcome ) ):
@@ -48,33 +52,32 @@ foreach( $results as $team_id => $result ):
endif; endif;
endforeach; endforeach;
endif; endif;
unset( $result['outcome'] );
$table_rows .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
$table_rows .= '<td class="data-name">' . get_the_title( $team_id ) . '</td>';
foreach( $result_labels as $key => $label ):
if ( $key == 'name' )
continue;
if ( array_key_exists( $key, $result ) && $result[ $key ] != '' ):
$value = $result[ $key ];
else:
$value = '&mdash;';
endif;
$table_rows .= '<td class="data-' . $key . '">' . $value . '</td>';
endforeach;
if ( $show_outcomes ):
$table_rows .= '<td class="data-outcome">' . implode( ', ', $outcomes ) . '</td>';
endif;
$table_rows .= '</tr>';
$i++;
endif; endif;
unset( $result['outcome'] );
$table_rows .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
$table_rows .= '<td class="data-name">' . get_the_title( $team_id ) . '</td>';
foreach( $labels as $key => $label ):
if ( in_array( $key, array( 'name', 'outcome' ) ) )
continue;
if ( array_key_exists( $key, $result ) && $result[ $key ] != '' ):
$value = $result[ $key ];
else:
$value = '&mdash;';
endif;
$table_rows .= '<td class="data-' . $key . '">' . $value . '</td>';
endforeach;
if ( $show_outcomes ):
$table_rows .= '<td class="data-outcome">' . implode( ', ', $outcomes ) . '</td>';
endif;
$table_rows .= '</tr>';
$i++;
endforeach; endforeach;
if ( empty( $table_rows ) ): if ( empty( $table_rows ) ):
@@ -88,12 +91,9 @@ else:
$output .= '<div class="sp-table-wrapper sp-scrollable-table-wrapper">' . $output .= '<div class="sp-table-wrapper sp-scrollable-table-wrapper">' .
'<table class="sp-event-results sp-data-table sp-responsive-table"><thead>' . '<table class="sp-event-results sp-data-table sp-responsive-table"><thead>' .
'<th class="data-name">' . __( 'Team', 'sportspress' ) . '</th>'; '<th class="data-name">' . __( 'Team', 'sportspress' ) . '</th>';
foreach( $result_labels as $key => $label ): foreach( $labels as $key => $label ):
$output .= '<th class="data-' . $key . '">' . $label . '</th>'; $output .= '<th class="data-' . $key . '">' . $label . '</th>';
endforeach; endforeach;
if ( $show_outcomes ):
$output .= '<th class="data-outcome">' . __( 'Outcome', 'sportspress' ) . '</th>';
endif;
$output .= '</tr>' . '</thead>' . '<tbody>'; $output .= '</tr>' . '</thead>' . '<tbody>';
$output .= $table_rows; $output .= $table_rows;
$output .= '</tbody>' . '</table>' . '</div>'; $output .= '</tbody>' . '</table>' . '</div>';

View File

@@ -4,15 +4,67 @@
* *
* @author ThemeBoy * @author ThemeBoy
* @package SportsPress/Templates * @package SportsPress/Templates
* @version 0.8 * @version 1.1
*/ */
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $id ) ) $defaults = array(
$id = get_the_ID(); 'id' => get_the_ID(),
$staff = (array)get_post_meta( $id, 'sp_staff', false ); 'index' => 0,
'number' => -1,
'link_posts' => get_option( 'sportspress_event_link_staff', 'yes' ) == 'yes' ? true : false,
'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false,
'responsive' => get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false,
);
$output = ''; $staff = array_filter( sp_array_between( (array)get_post_meta( $id, 'sp_staff', false ), 0, $index ) );
echo apply_filters( 'sportspress_event_staff', $output ); if ( ! $staff ) return;
extract( $defaults, EXTR_SKIP );
?>
<div class="sp-table-wrapper sp-scrollable-table-wrapper">
<table class="sp-event-performance sp-data-table <?php if ( $responsive ) { ?> sp-responsive-table<?php } if ( $sortable ) { ?> sp-sortable-table<?php } ?>">
<thead>
<tr>
<th class="data-name"><?php _e( 'Staff', 'sportspress' ); ?></th>
<th class="data-role"><?php _e( 'Role', 'sportspress' ); ?></th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach( $staff as $staff_id ):
if ( ! $staff_id )
continue;
$name = get_the_title( $staff_id );
if ( ! $name )
continue;
echo '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
if ( $link_posts ):
$permalink = get_post_permalink( $staff_id );
$name = '<a href="' . $permalink . '">' . $name . '</a>';
endif;
echo '<td class="data-name">' . $name . '</td>';
$role = get_post_meta( $staff_id, 'sp_role', true );
// Staff role
echo '<td class="data-role">' . $role . '</td>';
echo '</tr>';
$i++;
endforeach;
?>
</tbody>
</table>
</div>