Add date selector to calendars
This commit is contained in:
@@ -80,82 +80,92 @@ class SP_Meta_Box_Calendar_Data {
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if ( is_array( $data ) && sizeof( $data ) > 0 ):
|
||||
$main_result = get_option( 'sportspress_primary_result', null );
|
||||
$i = 0;
|
||||
foreach ( $data as $event ):
|
||||
$teams = get_post_meta( $event->ID, 'sp_team' );
|
||||
$results = get_post_meta( $event->ID, 'sp_results', true );
|
||||
$video = get_post_meta( $event->ID, 'sp_video', true );
|
||||
$main_results = array();
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<td><?php echo get_post_time( get_option( 'date_format' ), false, $event ); ?></td>
|
||||
<td><?php echo $event->post_title; ?></td>
|
||||
<td>
|
||||
<?php
|
||||
if ( $teams ): foreach ( $teams as $team ):
|
||||
$name = get_the_title( $team );
|
||||
if ( $name ):
|
||||
$team_results = sp_array_value( $results, $team, null );
|
||||
|
||||
if ( $main_result ):
|
||||
$team_result = sp_array_value( $team_results, $main_result, null );
|
||||
else:
|
||||
if ( is_array( $team_results ) ):
|
||||
end( $team_results );
|
||||
$team_result = prev( $team_results );
|
||||
else:
|
||||
$team_result = null;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( $team_result != null ):
|
||||
$main_results[] = $team_result;
|
||||
unset( $team_results['outcome'] );
|
||||
$team_results = implode( ' | ', $team_results );
|
||||
echo '<a class="result tips" title="' . $team_results . '" href="' . get_edit_post_link( $event->ID ) . '">' . $team_result . '</a> ';
|
||||
endif;
|
||||
|
||||
echo $name . '<br>';
|
||||
endif;
|
||||
endforeach; else:
|
||||
echo '—';
|
||||
endif;
|
||||
?>
|
||||
</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>
|
||||
<a href="<?php echo get_edit_post_link( $event->ID ); ?>#sp_articlediv">
|
||||
<?php if ( $video ): ?>
|
||||
<div class="dashicons dashicons-video-alt"></div>
|
||||
<?php elseif ( has_post_thumbnail( $event->ID ) ): ?>
|
||||
<div class="dashicons dashicons-camera"></div>
|
||||
<?php endif; ?>
|
||||
if ( is_array( $data ) ):
|
||||
if ( sizeof( $data ) > 0 ):
|
||||
$main_result = get_option( 'sportspress_primary_result', null );
|
||||
$i = 0;
|
||||
foreach ( $data as $event ):
|
||||
$teams = get_post_meta( $event->ID, 'sp_team' );
|
||||
$results = get_post_meta( $event->ID, 'sp_results', true );
|
||||
$video = get_post_meta( $event->ID, 'sp_video', true );
|
||||
$main_results = array();
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<td><?php echo get_post_time( get_option( 'date_format' ), false, $event ); ?></td>
|
||||
<td><?php echo $event->post_title; ?></td>
|
||||
<td>
|
||||
<?php
|
||||
if ( $event->post_content == null ):
|
||||
_e( 'None', 'sportspress' );
|
||||
elseif ( $event->post_status == 'publish' ):
|
||||
_e( 'Recap', 'sportspress' );
|
||||
else:
|
||||
_e( 'Preview', 'sportspress' );
|
||||
if ( $teams ): foreach ( $teams as $team ):
|
||||
$name = get_the_title( $team );
|
||||
if ( $name ):
|
||||
$team_results = sp_array_value( $results, $team, null );
|
||||
|
||||
if ( $main_result ):
|
||||
$team_result = sp_array_value( $team_results, $main_result, null );
|
||||
else:
|
||||
if ( is_array( $team_results ) ):
|
||||
end( $team_results );
|
||||
$team_result = prev( $team_results );
|
||||
else:
|
||||
$team_result = null;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( $team_result != null ):
|
||||
$main_results[] = $team_result;
|
||||
unset( $team_results['outcome'] );
|
||||
$team_results = implode( ' | ', $team_results );
|
||||
echo '<a class="result tips" title="' . $team_results . '" href="' . get_edit_post_link( $event->ID ) . '">' . $team_result . '</a> ';
|
||||
endif;
|
||||
|
||||
echo $name . '<br>';
|
||||
endif;
|
||||
endforeach; else:
|
||||
echo '—';
|
||||
endif;
|
||||
?>
|
||||
</a>
|
||||
</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>
|
||||
<a href="<?php echo get_edit_post_link( $event->ID ); ?>#sp_articlediv">
|
||||
<?php if ( $video ): ?>
|
||||
<div class="dashicons dashicons-video-alt"></div>
|
||||
<?php elseif ( has_post_thumbnail( $event->ID ) ): ?>
|
||||
<div class="dashicons dashicons-camera"></div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if ( $event->post_content == null ):
|
||||
_e( 'None', 'sportspress' );
|
||||
elseif ( $event->post_status == 'publish' ):
|
||||
_e( 'Recap', 'sportspress' );
|
||||
else:
|
||||
_e( 'Preview', 'sportspress' );
|
||||
endif;
|
||||
?>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
else:
|
||||
?>
|
||||
<tr class="sp-row alternate">
|
||||
<td colspan="6">
|
||||
<?php _e( 'No results found.', 'sportspress' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
endif;
|
||||
else:
|
||||
?>
|
||||
<tr class="sp-row alternate">
|
||||
|
||||
@@ -20,6 +20,7 @@ class SP_Meta_Box_Calendar_Details {
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$status = get_post_meta( $post->ID, 'sp_status', true );
|
||||
$date = get_post_meta( $post->ID, 'sp_date', true );
|
||||
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
|
||||
$season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 );
|
||||
$venue_id = sp_get_the_term_id( $post->ID, 'sp_venue', 0 );
|
||||
@@ -38,6 +39,17 @@ class SP_Meta_Box_Calendar_Details {
|
||||
sp_dropdown_statuses( $args );
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Date', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'name' => 'sp_date',
|
||||
'id' => 'sp_date',
|
||||
'selected' => $date,
|
||||
);
|
||||
sp_dropdown_dates( $args );
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
@@ -117,6 +129,7 @@ class SP_Meta_Box_Calendar_Details {
|
||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
|
||||
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 0 ) );
|
||||
update_post_meta( $post_id, 'sp_date', sp_array_value( $_POST, 'sp_date', 0 ) );
|
||||
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', 0 ) );
|
||||
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user