get_settings();
// Countdown on single page is disabled
if (!isset($settings['countdown_status']) || !$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');
else $ongoing = $countdown_method == 'end';
$disable_for_ongoing = (isset($settings['countdown_disable_for_ongoing_events']) and $settings['countdown_disable_for_ongoing_events']);
if ($d3 < $d2) {
echo '
' . esc_html__('The event is finished.', 'modern-events-calendar-lite') . '
';
return;
} elseif (($d1 < $d2 and !$ongoing) or ($d1 < $d2 and $disable_for_ongoing)) {
echo '' . esc_html__('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 MEC_kses::full($defaultjs);
elseif (is_plugin_active('mec-single-builder/mec-single-builder.php')) echo MEC_kses::full($defaultjs);
else $factory->params('footer', $defaultjs);
?>
is_ajax()) echo MEC_kses::full($flipjs);
elseif (is_plugin_active('mec-single-builder/mec-single-builder.php')) {
wp_enqueue_script('mec-flipcount-script');
echo MEC_kses::full($flipjs);
} elseif (is_plugin_active('divi-single-builder/divi-single-builder.php') || is_plugin_active('mec-divi-single-builder/divi-single-builder.php')) {
wp_enqueue_script('mec-flipcount-script');
$factory->params('footer', $flipjsDivi);
} else {
// Include FlipCount library
wp_enqueue_script('mec-flipcount-script');
// Include the JS code
$factory->params('footer', $flipjs);
}
if (is_plugin_active('mec-gutenberg-single-builder/mec-gutenberg-single-builder.php') && str_contains($_SERVER['REQUEST_URI'],'gsb')){?>
days
hours
minutes
seconds