Countdown widget options

This commit is contained in:
Brian Miyaji
2014-02-13 20:29:30 +11:00
parent c886b143bc
commit 30348d8a72
6 changed files with 39 additions and 23 deletions

View File

@@ -2,7 +2,8 @@
if ( !function_exists( 'sportspress_countdown' ) ) {
function sportspress_countdown( $args = array() ) {
$id = sportspress_array_value( $args, 'id', null );
$id = sportspress_array_value( $args, 'event', null );
$show_league = sportspress_array_value( $args, 'show_league', null );
if ( $id ):
$post = get_post( $id );
@@ -27,24 +28,26 @@ if ( !function_exists( 'sportspress_countdown' ) ) {
$output .= '<div id="sp_countdown_wrap">';
$output .= '<h3 class="event-name"><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h3>';
$leagues = get_the_terms( $post->ID, 'sp_league' );
if ( $leagues ):
foreach( $leagues as $league ):
$term = get_term( $league->term_id, 'sp_league' );
$output .= '<h5 class="event-league">' . $term->name . '</h5>';
endforeach;
if ( $show_league ):
$leagues = get_the_terms( $post->ID, 'sp_league' );
if ( $leagues ):
foreach( $leagues as $league ):
$term = get_term( $league->term_id, 'sp_league' );
$output .= '<h5 class="event-league">' . $term->name . '</h5>';
endforeach;
endif;
endif;
$now = new DateTime( current_time( 'mysql', 0 ) );
$date = new DateTime( $post->post_date );
$interval = date_diff( $now, $date );
$output .= '<h3 class="countdown sp-countdown"><time datetime="' . $post->post_date . '" data-countdown="' . str_replace( '-', '/', $post->post_date ) . '">' .
$output .= '<p class="countdown sp-countdown"><time datetime="' . $post->post_date . '" data-countdown="' . str_replace( '-', '/', $post->post_date ) . '">' .
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->d ) ) . ' <small>' . __( 'days', 'sportspress' ) . '</small></span> ' .
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->h ) ) . ' <small>' . __( 'hrs', 'sportspress' ) . '</small></span> ' .
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->i ) ) . ' <small>' . __( 'mins', 'sportspress' ) . '</small></span> ' .
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->s ) ) . ' <small>' . __( 'secs', 'sportspress' ) . '</small></span>' .
'</time></h3>';
'</time></p>';
$output .= '</div>';
else: