Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #789951

    Is there an easy way to always have two digits in the countdown — so 0 would be changed to be 00, 01, 02, etc.

    For reference: https://hasheart.us/

    Thanks!

    #790016

    Hey Andrea,

    If you aren’t using a child theme yet, I would suggest doing so: http://kriesi.at/documentation/enfold/using-a-child-theme/ if you are using a child theme already then you can skip this part.

    Next create a js folder in your child theme, then copy shortcodes.js from parent theme (enfold/js/shortcodes.js) to the child theme’s js folder and then edit this file (line 246-250 in Enfold 4.0.5):

    _self.time.weeks   	= Math.floor( _timestamp / _week);
    _self.time.days 	= Math.floor((_timestamp % _week) / _day);
    _self.time.hours	= Math.floor((_timestamp % _day) / _hour); 
    _self.time.minutes 	= Math.floor((_timestamp % _hour) / _minute); 
    _self.time.seconds 	= Math.floor((_timestamp % _minute) / _second); 
    

    and replace it with this one:

    
    _self.time.weeks   	= ("0" + Math.floor( _timestamp / _week)).slice(-2);
    _self.time.days 	= ("0" + Math.floor((_timestamp % _week) / _day)).slice(-2);
    _self.time.hours	= ("0" + Math.floor((_timestamp % _day) / _hour)).slice(-2); 
    _self.time.minutes 	= ("0" + Math.floor((_timestamp % _hour) / _minute)).slice(-2); 
    _self.time.seconds 	= ("0" + Math.floor((_timestamp % _minute) / _second)).slice(-2); 
    

    Then added this code in functions.php so it uses shortcodes.js in the child theme:

    // Replace shortcodes.js
    function change_shortcodesjs() {
       wp_dequeue_script( 'avia-shortcodes' );
       wp_enqueue_script( 'avia-shortcodes-child', get_stylesheet_directory_uri().'/js/shortcodes.js', array('jquery'), 2, true );
    }
    add_action( 'wp_enqueue_scripts', 'change_shortcodesjs', 100 );
    

    And that should be it. Hope this helps :)

    Best regards,
    Nikko

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.