function the_quiz_timer($start) { global $post; $user_id = get_current_user_id(); $quiztaken = get_user_meta($user_id, get_the_ID(), true); $minutes = intval(get_post_meta($post->ID, 'vibe_duration', true)); if ($minutes > 9998) { return true; } if (isset($quiztaken) && is_numeric($quiztaken) && $quiztaken) { if ($quiztaken > time()) { $minutes = $quiztaken - time(); $start = 1; } else { $minutes = 1; } } else { if (!$minutes) { $minutes = 1; echo __("Duration not Set", "vibe"); } else { $start = 0; } $quiz_duration_parameter = apply_filters('vibe_quiz_duration_parameter', 60); $minutes = $minutes * $quiz_duration_parameter; } echo '<div class="quiz_timer ' . ($start ? 'start' : '') . '" data-time="' . $minutes . '"> <span class="timer" data-timer="' . $minutes . '"></span> <span class="countdown">' . minutes_to_hms($minutes) . '</span> <span>' . __('Time Remaining', 'vibe') . '</span> <span><strong>' . __('Mins', 'vibe') . '</strong> ' . __('Secs', 'vibe') . '</span> </div>'; }
function in_quiz_timer($args = NULL) { $defaults = array('start' => '', 'quiz_id' => $post->ID); $args = wp_parse_args((array) $args, $defaults); extract($args); $user_id = get_current_user_id(); $quiztaken = get_user_meta($user_id, $quiz_id, true); $minutes = intval(get_post_meta($quiz_id, 'vibe_duration', true)); if ($minutes > 9998) { return true; } if (isset($quiztaken) && is_numeric($quiztaken) && $quiztaken) { if ($quiztaken > time()) { $minutes = $quiztaken - time(); $start = 1; } else { $minutes = 1; } } else { if (!$minutes) { $minutes = 1; echo __("Duration not Set", "vibe"); } else { $start = 0; } $quiz_duration_parameter = apply_filters('vibe_quiz_duration_parameter', 60); $minutes = $minutes * $quiz_duration_parameter; } echo '<div class="quiz_meta"><div class="inquiz_timer ' . ($start ? 'start' : '') . '" data-time="' . $minutes . '"> <span class="timer" data-timer="' . $minutes . '"></span> <span class="countdown">' . minutes_to_hms($minutes) . '</span> </div><i>' . __('Progress', 'vibe') . ':<span>0</span></i> <div class="progress"> <div class="bar animate stretchRight load" style="width:0%;"></div> </div></div>'; }