From df1eaf9ad7f9ce31eb5e791e1de981b370f0b59b Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Wed, 17 Feb 2016 03:36:00 +1100 Subject: [PATCH] Add date and time option to events --- .../admin/settings/class-sp-settings-events.php | 14 ++++++++++++++ templates/event-details.php | 16 +++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/includes/admin/settings/class-sp-settings-events.php b/includes/admin/settings/class-sp-settings-events.php index 6540cce6..7133f53f 100644 --- a/includes/admin/settings/class-sp-settings-events.php +++ b/includes/admin/settings/class-sp-settings-events.php @@ -63,6 +63,20 @@ class SP_Settings_Events extends SP_Settings_Page { 'type' => 'checkbox', 'checkboxgroup' => 'start', ), + array( + 'desc' => __( 'Date', 'sportspress' ), + 'id' => 'sportspress_event_show_date', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => '', + ), + array( + 'desc' => __( 'Time', 'sportspress' ), + 'id' => 'sportspress_event_show_time', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => '', + ), array( 'desc' => __( 'Results', 'sportspress' ), 'id' => 'sportspress_event_show_results', diff --git a/templates/event-details.php b/templates/event-details.php index 31799871..272790c7 100644 --- a/templates/event-details.php +++ b/templates/event-details.php @@ -14,10 +14,18 @@ if ( ! isset( $id ) ) $id = get_the_ID(); $scrollable = get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false; -$date = get_the_time( get_option('date_format'), $id ); -$time = get_the_time( get_option('time_format'), $id ); -$data = array( __( 'Date', 'sportspress' ) => $date, __( 'Time', 'sportspress' ) => $time ); +$data = array(); + +if ( 'yes' === get_option( 'sportspress_event_show_date', 'yes' ) ) { + $date = get_the_time( get_option('date_format'), $id ); + $data[ __( 'Date', 'sportspress' ) ] = $date; +} + +if ( 'yes' === get_option( 'sportspress_event_show_time', 'yes' ) ) { + $time = get_the_time( get_option('time_format'), $id ); + $data[ __( 'Time', 'sportspress' ) ] = $time; +} $taxonomies = apply_filters( 'sportspress_event_taxonomies', array( 'sp_league' => null, 'sp_season' => null ) ); @@ -31,6 +39,8 @@ foreach ( $taxonomies as $taxonomy => $post_type ): endforeach; $data = apply_filters( 'sportspress_event_details', $data, $id ); + +if ( ! sizeof( $data ) ) return; ?>