WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Easy Timer] How to format a timer's title? (2 posts)

  1. José Luís
    Member
    Posted 4 years ago #

    Great plugin, thanks!

    I have a request though: how do I format a timer's title? I mean, according to the plugin's source-code, when the plugin shows the timer, it's title property shows $T, what I guess is the event timestamp. How do I format it to something like "dd/mm/yyyy hh:mm:ss"?

    http://wordpress.org/extend/plugins/easy-timer/

  2. Kleor
    Member
    Posted 4 years ago #

    You can insert this line:

    $T = date('d/m/Y H:i:s', $T);

    in the easy-timer.php file just before:

    $content = str_ireplace('[timer]', '<span class="dhmscount'.$way.'" title="'.$T.'">'.$stringDhms.'</span>', $content);

    But the reactualization will not work and to solve this problem, you will have to edit the easy-timer.js file or remove this line:

    add_action('wp_footer', 'easy_timer_js');

    in the easy-timer.php file.

    In fact, the timer's title is only an information for the easy-timer.js file. The easy-timer.js file calculates the difference between event timestamp (the timer's title) and actual timestamp to know the remaining/elapsed time:

    function dhmstimer_decrease(el) {
    var T = Math.round(((new Date()).getTime())/1000);
    var S = dhmscountdown[el].title - T;
    if (S == 0) { window.location.reload(); }
    dhmscountdown[el].innerHTML = timer(S, 'dhms'); }

    For your visitors, it's not an important visual detail and the majority of them will never realize that your timers have a title attribute.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags