get_settings(); // Countdown on single page is disabled if(!isset($settings['countdown_status']) or (isset($settings['countdown_status']) and !$settings['countdown_status'])) return; $event = $event[0]; $date = $event->date; $start_date = (isset($date['start']) and isset($date['start']['date'])) ? $date['start']['date'] : current_time('Y-m-d'); $end_date = (isset($date['end']) and isset($date['end']['date'])) ? $date['end']['date'] : current_time('Y-m-d'); $s_time = ''; if(!empty($date)) { $s_hour = $date['start']['hour']; if(strtoupper($date['start']['ampm']) == 'AM' and $s_hour == '0') $s_hour = 12; $s_time .= sprintf("%02d", $s_hour).':'; $s_time .= sprintf("%02d", $date['start']['minutes']); $s_time .= ' '.trim($date['start']['ampm']); } $e_time = ''; if(!empty($date)) { $e_hour = $date['end']['hour']; if(strtoupper($date['end']['ampm']) == 'AM' and $e_hour == '0') $e_hour = 12; $e_time .= sprintf("%02d", $e_hour).':'; $e_time .= sprintf("%02d", $date['end']['minutes']); $e_time .= ' '.trim($date['end']['ampm']); } $start_time = date('D M j Y G:i:s', strtotime($start_date.' '.$s_time)); $end_time = date('D M j Y G:i:s', strtotime($end_date.' '.$e_time)); // Timezone $TZO = $this->get_TZO($event); $d1 = new DateTime($start_time, $TZO); $d2 = new DateTime('now', $TZO); $d3 = new DateTime($end_time, $TZO); $countdown_method = get_post_meta($event->ID, 'mec_countdown_method', true); if(trim($countdown_method) == '') $countdown_method = 'global'; if($countdown_method == 'global') $ongoing = (isset($settings['hide_time_method']) and trim($settings['hide_time_method']) == 'end') ? true : false; else $ongoing = ($countdown_method == 'end') ? true : false; $disable_for_ongoing = (isset($settings['countdown_disable_for_ongoing_events']) and $settings['countdown_disable_for_ongoing_events']); if($d3 < $d2) { echo '

'.__('The event is finished.', 'modern-events-calendar-lite').'

'; return; } elseif(($d1 < $d2 and !$ongoing) or ($d1 < $d2 and $disable_for_ongoing)) { echo '

'.__('The event is ongoing.', 'modern-events-calendar-lite').'

'; return; } $gmt_offset = $this->get_gmt_offset($event, strtotime($start_date.' '.$s_time)); if(isset($_SERVER['HTTP_USER_AGENT']) and strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') === false) $gmt_offset = ' : '.$gmt_offset; if(isset($_SERVER['HTTP_USER_AGENT']) and strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') == true) $gmt_offset = substr(trim($gmt_offset), 0 , 3); if(isset($_SERVER['HTTP_USER_AGENT']) and strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') == true) $gmt_offset = substr(trim($gmt_offset), 2 , 3); $datetime = $ongoing ? $end_time : $start_time; // Generating javascript code of countdown default module $defaultjs = ''; // Generating javascript code of countdown flip module $flipjs = ''; $flipjsDivi = ''; if(!function_exists('is_plugin_active')) include_once( ABSPATH . 'wp-admin/includes/plugin.php'); ?> is_ajax()) echo $defaultjs; elseif (is_plugin_active( 'mec-single-builder/mec-single-builder.php')) echo $defaultjs; else $factory->params('footer', $defaultjs); ?>
is_ajax()) echo $flipjs; elseif(is_plugin_active( 'mec-single-builder/mec-single-builder.php')) { wp_enqueue_script('mec-flipcount-script', $this->asset('js/flipcount.js')); echo $flipjs; } elseif(is_plugin_active( 'divi-single-builder/divi-single-builder.php')) { wp_enqueue_script('mec-flipcount-script', $this->asset('js/flipcount-divi.js')); $factory->params('footer', $flipjsDivi); } else { // Include FlipCount library wp_enqueue_script('mec-flipcount-script', $this->asset('js/flipcount.js')); // Include the JS code $factory->params('footer', $flipjs); } ?>