Replace event time with status when not on time
This commit is contained in:
@@ -144,7 +144,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
|||||||
endif;
|
endif;
|
||||||
break;
|
break;
|
||||||
case 'sp_time':
|
case 'sp_time':
|
||||||
echo get_post_time( 'H:i', false, $post_id, true );
|
echo apply_filters( 'sportspress_event_time_admin', get_post_time( 'H:i', false, $post_id, true ) );
|
||||||
break;
|
break;
|
||||||
case 'sp_team':
|
case 'sp_team':
|
||||||
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
|
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
</td>
|
</td>
|
||||||
<?php if ( 'separate' == $time_format ) { ?>
|
<?php if ( 'separate' == $time_format ) { ?>
|
||||||
<td>
|
<td>
|
||||||
<?php echo get_post_time( get_option( 'time_format' ), false, $event, true ); ?>
|
<?php echo apply_filters( 'sportspress_event_time_admin', get_post_time( get_option( 'time_format' ), false, $event, true ), $event->ID ); ?>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
@@ -180,7 +180,7 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
if ( ! empty( $main_results ) ):
|
if ( ! empty( $main_results ) ):
|
||||||
echo implode( ' - ', $main_results );
|
echo implode( ' - ', $main_results );
|
||||||
else:
|
else:
|
||||||
echo get_post_time( get_option( 'time_format' ), false, $event, true );
|
echo apply_filters( 'sportspress_event_time_admin', get_post_time( get_option( 'time_format' ), false, $event, true ), $event->ID );
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ class SportsPress_Event_Status {
|
|||||||
add_action( 'init', array( $this, 'get_statuses' ) );
|
add_action( 'init', array( $this, 'get_statuses' ) );
|
||||||
add_action( 'post_submitbox_misc_actions', array( $this, 'section' ) );
|
add_action( 'post_submitbox_misc_actions', array( $this, 'section' ) );
|
||||||
add_action( 'sportspress_process_sp_event_meta', array( $this, 'save' ), 10, 1 );
|
add_action( 'sportspress_process_sp_event_meta', array( $this, 'save' ), 10, 1 );
|
||||||
|
add_filter( 'sportspress_event_time', array( $this, 'filter' ), 10, 2 );
|
||||||
|
add_filter( 'sportspress_event_time_admin', array( $this, 'filter' ), 10, 2 );
|
||||||
|
add_filter( 'sportspress_main_results_or_time', array( $this, 'filter_array' ), 10, 2 );
|
||||||
|
add_filter( 'sportspress_event_blocks_team_result_or_time', array( $this, 'filter_array' ), 10, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,9 +62,9 @@ class SportsPress_Event_Status {
|
|||||||
public function get_statuses() {
|
public function get_statuses() {
|
||||||
$this->statuses = apply_filters( 'sportspress_event_statuses', array(
|
$this->statuses = apply_filters( 'sportspress_event_statuses', array(
|
||||||
'ok' => __( 'On time', 'sportspress' ),
|
'ok' => __( 'On time', 'sportspress' ),
|
||||||
'tbd' => __( 'To be determined', 'sportspress' ) . ' (' . __( 'TBD', 'sportspress' ) . ')',
|
'tbd' => __( 'TBD', 'sportspress' ),
|
||||||
'cancelled' => __( 'Cancelled', 'sportspress' ),
|
|
||||||
'postponed' => __( 'Postponed', 'sportspress' ),
|
'postponed' => __( 'Postponed', 'sportspress' ),
|
||||||
|
'cancelled' => __( 'Cancelled', 'sportspress' ),
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,12 +88,6 @@ class SportsPress_Event_Status {
|
|||||||
<a href="#" class="sp-cancel-event-status hide-if-no-js button-cancel">Cancel</a>
|
<a href="#" class="sp-cancel-event-status hide-if-no-js button-cancel">Cancel</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<?php if ( false ) { ?>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" name="sp_tbd" value="1" <?php checked( $checked ); ?>></input>
|
|
||||||
<?php _e( 'To be determined', 'sportspress' ); ?> (<?php _e( 'TBD', 'sportspress' ); ?>)
|
|
||||||
</label>
|
|
||||||
<?php } ?>
|
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -100,6 +98,26 @@ class SportsPress_Event_Status {
|
|||||||
public function save( $post_id ) {
|
public function save( $post_id ) {
|
||||||
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 'ok' ) );
|
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 'ok' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event time filter.
|
||||||
|
*/
|
||||||
|
public function filter( $time, $post_id = 0 ) {
|
||||||
|
if ( ! $post_id ) $post_id = get_the_ID();
|
||||||
|
$status = get_post_meta( $post_id, 'sp_status', true );
|
||||||
|
if ( ! $status || 'ok' === $status || ! array_key_exists( $status, $this->statuses ) ) return $time;
|
||||||
|
return $this->statuses[ $status ];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event time array filter.
|
||||||
|
*/
|
||||||
|
public function filter_array( $array, $post_id = 0 ) {
|
||||||
|
if ( ! $post_id ) $post_id = get_the_ID();
|
||||||
|
$status = get_post_meta( $post_id, 'sp_status', true );
|
||||||
|
if ( ! $status || 'ok' === $status || ! array_key_exists( $status, $this->statuses ) ) return $array;
|
||||||
|
return array( $this->statuses[ $status ] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ if ( $ak_post_titles ) {
|
|||||||
foreach ( (array) $ak_post_titles as $ak_post_title ) {
|
foreach ( (array) $ak_post_titles as $ak_post_title ) {
|
||||||
|
|
||||||
/** This filter is documented in wp-includes/post-template.php */
|
/** This filter is documented in wp-includes/post-template.php */
|
||||||
$post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) . ' @ ' . date_i18n( get_option( 'time_format' ), strtotime( $ak_post_title->post_date ) ) );
|
$post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) . ' @ ' . apply_filters( 'sportspress_event_time', date_i18n( get_option( 'time_format' ), strtotime( $ak_post_title->post_date ) ), $ak_post_title->ID ) );
|
||||||
|
|
||||||
if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
|
if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
|
||||||
$ak_titles_for_day['day_'.$ak_post_title->dom] = '';
|
$ak_titles_for_day['day_'.$ak_post_title->dom] = '';
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ if ( 'yes' === get_option( 'sportspress_event_show_date', 'yes' ) ) {
|
|||||||
|
|
||||||
if ( 'yes' === get_option( 'sportspress_event_show_time', 'yes' ) ) {
|
if ( 'yes' === get_option( 'sportspress_event_show_time', 'yes' ) ) {
|
||||||
$time = get_the_time( get_option('time_format'), $id );
|
$time = get_the_time( get_option('time_format'), $id );
|
||||||
$data[ __( 'Time', 'sportspress' ) ] = $time;
|
$data[ __( 'Time', 'sportspress' ) ] = apply_filters( 'sportspress_event_time', $time, $id );
|
||||||
}
|
}
|
||||||
|
|
||||||
$taxonomies = apply_filters( 'sportspress_event_taxonomies', array( 'sp_league' => null, 'sp_season' => null ) );
|
$taxonomies = apply_filters( 'sportspress_event_taxonomies', array( 'sp_league' => null, 'sp_season' => null ) );
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ endif;
|
|||||||
|
|
||||||
echo '<tr class="sp-row sp-post' . ( $i % 2 == 0 ? ' alternate' : '' ) . ' sp-row-no-' . $i . '">';
|
echo '<tr class="sp-row sp-post' . ( $i % 2 == 0 ? ' alternate' : '' ) . ' sp-row-no-' . $i . '">';
|
||||||
|
|
||||||
$date_html = '<date>' . get_post_time( 'Y-m-d H:i:s', false, $event ) . '</date>' . get_post_time( get_option( 'date_format' ), false, $event, true );
|
$date_html = '<date>' . get_post_time( 'Y-m-d H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', get_post_time( get_option( 'date_format' ), false, $event, true ), $event->ID );
|
||||||
|
|
||||||
if ( $link_events ) $date_html = '<a href="' . get_post_permalink( $event->ID, false, true ) . '">' . $date_html . '</a>';
|
if ( $link_events ) $date_html = '<a href="' . get_post_permalink( $event->ID, false, true ) . '">' . $date_html . '</a>';
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ endif;
|
|||||||
if ( ! empty( $main_results ) ):
|
if ( ! empty( $main_results ) ):
|
||||||
echo implode( ' - ', $main_results );
|
echo implode( ' - ', $main_results );
|
||||||
else:
|
else:
|
||||||
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
|
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID );
|
||||||
endif;
|
endif;
|
||||||
if ( $link_events ) echo '</a>';
|
if ( $link_events ) echo '</a>';
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
@@ -249,7 +249,7 @@ endif;
|
|||||||
if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) {
|
if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) {
|
||||||
echo '<td class="data-time">';
|
echo '<td class="data-time">';
|
||||||
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
|
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
|
||||||
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
|
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID );
|
||||||
if ( $link_events ) echo '</a>';
|
if ( $link_events ) echo '</a>';
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
}
|
}
|
||||||
@@ -271,7 +271,7 @@ endif;
|
|||||||
if ( sp_column_active( $usecolumns, 'time' ) ) {
|
if ( sp_column_active( $usecolumns, 'time' ) ) {
|
||||||
echo '<td class="data-time">';
|
echo '<td class="data-time">';
|
||||||
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
|
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
|
||||||
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
|
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID );
|
||||||
if ( $link_events ) echo '</a>';
|
if ( $link_events ) echo '</a>';
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
}
|
}
|
||||||
@@ -291,7 +291,7 @@ endif;
|
|||||||
if ( sp_column_active( $usecolumns, 'time' ) ) {
|
if ( sp_column_active( $usecolumns, 'time' ) ) {
|
||||||
echo '<td class="data-time">';
|
echo '<td class="data-time">';
|
||||||
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
|
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
|
||||||
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
|
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID );
|
||||||
if ( $link_events ) echo '</a>';
|
if ( $link_events ) echo '</a>';
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
}
|
}
|
||||||
@@ -316,7 +316,7 @@ endif;
|
|||||||
if ( ! empty( $main_results ) ):
|
if ( ! empty( $main_results ) ):
|
||||||
echo implode( ' - ', $main_results );
|
echo implode( ' - ', $main_results );
|
||||||
else:
|
else:
|
||||||
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
|
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID );
|
||||||
endif;
|
endif;
|
||||||
if ( $link_events ) echo '</a>';
|
if ( $link_events ) echo '</a>';
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
if ( $show_time ) {
|
if ( $show_time ) {
|
||||||
?>
|
?>
|
||||||
<h5 class="sp-event-results">
|
<h5 class="sp-event-results">
|
||||||
<?php echo '<span class="sp-result">' . apply_filters( 'sportspress_event_blocks_team_result_or_time', sp_get_time( $id ), $id ) . '</span>'; ?>
|
<?php echo '<span class="sp-result">' . apply_filters( 'sportspress_event_time', sp_get_time( $id ), $id ) . '</span>'; ?>
|
||||||
</h5>
|
</h5>
|
||||||
<span class="sp-event-status">
|
<span class="sp-event-status">
|
||||||
<?php _e( 'Preview', 'sportspress' ); ?>
|
<?php _e( 'Preview', 'sportspress' ); ?>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ if ( ! empty( $team_logos ) ):
|
|||||||
|
|
||||||
// Assign delimiter
|
// Assign delimiter
|
||||||
if ( $show_time && sizeof( $teams ) <= 2 ) {
|
if ( $show_time && sizeof( $teams ) <= 2 ) {
|
||||||
$delimiter = '<strong class="sp-event-logos-time sp-team-result">' . get_the_time( get_option('time_format'), $id ) . '</strong>';
|
$delimiter = '<strong class="sp-event-logos-time sp-team-result">' . apply_filters( 'sportspress_event_time', get_the_time( get_option('time_format'), $id ), $id ) . '</strong>';
|
||||||
} else {
|
} else {
|
||||||
$delimiter = get_option( 'sportspress_event_teams_delimiter', 'vs' );
|
$delimiter = get_option( 'sportspress_event_teams_delimiter', 'vs' );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user