Last active
November 23, 2022 04:47
-
-
Save alfredo-wpmudev/c65caa84455cf333dde4d1a09cd316b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: [Forminator] Time Date Picker Minute Default Value | |
* Plugin URI: https://premium.wpmudev.org | |
* Description: With this snippet is possible set all Forminator Time Date Picker Minute field to a default value, 00 | |
* Author: Alfredo Galano Loyola @ WPMUDEV | |
* Author URI: https://premium.wpmudev.org | |
* License: GPLv2 or later | |
*/ | |
add_action( 'wp_footer', 'setForminatorDefaultMinutes' ); | |
function setForminatorDefaultMinutes() { ?> | |
<script> | |
//Use for simple forms | |
function setDefaultMinutes(){ | |
//Set All Time Datepicker Minutes to 00 | |
jQuery('[id*="-minutes_"]').val(00); | |
jQuery('[id*="-minutes_"]').trigger('change'); | |
} | |
//Use when the form have pages to re-check after every click | |
var timers = jQuery('[id*="-minutes_"]'); | |
function timersDefault(){ | |
for (let index = 0; index < timers.length; index++) { | |
//Check if the timer is showing the - and then change the value | |
if (timers[index].value =="") { | |
jQuery('#'+timers[index].getAttribute('id')).val(00); | |
jQuery('#'+timers[index].getAttribute('id')).trigger('change'); | |
} | |
} | |
} | |
jQuery( document ).ready(function() { | |
setDefaultMinutes(); | |
setTimeout( function() { | |
//Binding click to the Next Button | |
var btn_next = document.querySelector( '.forminator-button-next' ); | |
if ( typeof( btn_next ) != 'undefined' && btn_next != null ) { | |
btn_next.addEventListener('click', function() { | |
console.log('Clicked Next!!!'); | |
timersDefault(); | |
}); | |
} | |
//Binding click to the Back Button | |
var btn_back = document.querySelector( '.forminator-button-back' ); | |
if ( typeof( btn_back ) != 'undefined' && btn_back != null ) { | |
btn_back.addEventListener( 'click', function() { | |
console.log('Clicked Back!!!'); | |
timersDefault(); | |
}); | |
} | |
}, 1 ); | |
}); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment