Add Time/Results column to event list

This commit is contained in:
Brian Miyaji
2014-04-29 16:48:34 +10:00
parent c84cd1dda1
commit 6c603768d5
3 changed files with 25 additions and 5 deletions

View File

@@ -61,7 +61,7 @@ class SP_Meta_Box_Calendar_Data {
<th class="column-time"> <th class="column-time">
<label for="sp_columns_time"> <label for="sp_columns_time">
<input type="checkbox" name="sp_columns[]" value="time" id="sp_columns_time" <?php checked( ! is_array( $usecolumns ) || in_array( 'time', $usecolumns ) ); ?>> <input type="checkbox" name="sp_columns[]" value="time" id="sp_columns_time" <?php checked( ! is_array( $usecolumns ) || in_array( 'time', $usecolumns ) ); ?>>
<?php _e( 'Time', 'sportspress' ); ?> <?php _e( 'Time/Results', 'sportspress' ); ?>
</label> </label>
</th> </th>
<th class="column-venue"> <th class="column-venue">
@@ -86,6 +86,7 @@ class SP_Meta_Box_Calendar_Data {
foreach ( $data as $event ): foreach ( $data as $event ):
$teams = get_post_meta( $event->ID, 'sp_team' ); $teams = get_post_meta( $event->ID, 'sp_team' );
$results = get_post_meta( $event->ID, 'sp_results', true ); $results = get_post_meta( $event->ID, 'sp_results', true );
$main_results = array();
$video = get_post_meta( $event->ID, 'sp_video', true ); $video = get_post_meta( $event->ID, 'sp_video', true );
?> ?>
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>"> <tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
@@ -110,6 +111,7 @@ class SP_Meta_Box_Calendar_Data {
endif; endif;
if ( $team_result != null ): if ( $team_result != null ):
$main_results[] = $team_result;
unset( $team_results['outcome'] ); unset( $team_results['outcome'] );
$team_results = implode( ' | ', $team_results ); $team_results = implode( ' | ', $team_results );
echo '<a class="result tips" title="' . $team_results . '" href="' . get_edit_post_link( $event->ID ) . '">' . $team_result . '</a> '; echo '<a class="result tips" title="' . $team_results . '" href="' . get_edit_post_link( $event->ID ) . '">' . $team_result . '</a> ';
@@ -120,7 +122,15 @@ class SP_Meta_Box_Calendar_Data {
endforeach; endforeach;
?> ?>
</td> </td>
<td><?php echo get_post_time( get_option( 'time_format' ), false, $event ); ?></td> <td>
<?php
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo get_post_time( get_option( 'time_format' ), false, $event );
endif;
?>
</td>
<td><?php the_terms( $event->ID, 'sp_venue' ); ?></td> <td><?php the_terms( $event->ID, 'sp_venue' ); ?></td>
<td> <td>
<a href="<?php echo get_edit_post_link( $event->ID ); ?>#sp_articlediv"> <a href="<?php echo get_edit_post_link( $event->ID ); ?>#sp_articlediv">

View File

@@ -3231,6 +3231,7 @@ function sp_get_text_options() {
'team' => __( 'Team', 'sportspress' ), 'team' => __( 'Team', 'sportspress' ),
'teams' => __( 'Teams', 'sportspress' ), 'teams' => __( 'Teams', 'sportspress' ),
'time' => __( 'Time', 'sportspress' ), 'time' => __( 'Time', 'sportspress' ),
'timeresults' => __( 'Time/Results', 'sportspress' ),
'total' => __( 'Total', 'sportspress' ), 'total' => __( 'Total', 'sportspress' ),
'venue' => __( 'Venue', 'sportspress' ), 'venue' => __( 'Venue', 'sportspress' ),
'view_all_events' => __( 'View all events', 'sportspress' ), 'view_all_events' => __( 'View all events', 'sportspress' ),

View File

@@ -49,7 +49,7 @@ if ( isset( $columns ) )
echo '<th class="data-teams">' . SP()->text->string('Teams') . '</th>'; echo '<th class="data-teams">' . SP()->text->string('Teams') . '</th>';
if ( $usecolumns == null || in_array( 'time', $usecolumns ) ) if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
echo '<th class="data-time">' . SP()->text->string('Time') . '</th>'; echo '<th class="data-time">' . SP()->text->string('Time/Results') . '</th>';
if ( $usecolumns == null || in_array( 'venue', $usecolumns ) ) if ( $usecolumns == null || in_array( 'venue', $usecolumns ) )
echo '<th class="data-venue">' . SP()->text->string('Venue') . '</th>'; echo '<th class="data-venue">' . SP()->text->string('Venue') . '</th>';
@@ -71,6 +71,7 @@ if ( isset( $columns ) )
$teams = get_post_meta( $event->ID, 'sp_team' ); $teams = get_post_meta( $event->ID, 'sp_team' );
$results = get_post_meta( $event->ID, 'sp_results', true ); $results = get_post_meta( $event->ID, 'sp_results', true );
$main_results = array();
$video = get_post_meta( $event->ID, 'sp_video', true ); $video = get_post_meta( $event->ID, 'sp_video', true );
echo '<tr class="sp-row sp-post' . ( $i % 2 == 0 ? ' alternate' : '' ) . '">'; echo '<tr class="sp-row sp-post' . ( $i % 2 == 0 ? ' alternate' : '' ) . '">';
@@ -104,6 +105,7 @@ if ( isset( $columns ) )
echo $name; echo $name;
if ( $team_result != null ): if ( $team_result != null ):
$main_results[] = $team_result;
echo ' (' . $team_result . ')'; echo ' (' . $team_result . ')';
endif; endif;
@@ -117,8 +119,15 @@ if ( isset( $columns ) )
echo '</td>'; echo '</td>';
endif; endif;
if ( $usecolumns == null || in_array( 'time', $usecolumns ) ) if ( $usecolumns == null || in_array( 'time', $usecolumns ) ):
echo '<td class="data-time">' . get_post_time( get_option( 'time_format' ), false, $event ) . '</td>'; echo '<td class="data-time">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo get_post_time( get_option( 'time_format' ), false, $event );
endif;
echo '</td>';
endif;
if ( $usecolumns == null || in_array( 'venue', $usecolumns ) ): if ( $usecolumns == null || in_array( 'venue', $usecolumns ) ):
echo '<td class="data-venue">'; echo '<td class="data-venue">';