Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions includes/class-recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public static function add_recaptcha_to_checkout() {
<script>
grecaptcha.ready( function() {
var field;
setInterval( function() {
function refreshToken() {
grecaptcha.execute(
'<?php echo \esc_attr( $site_key ); ?>',
{ action: 'checkout' }
Expand All @@ -332,7 +332,13 @@ public static function add_recaptcha_to_checkout() {
field.value = token;
}
} );
}, 30000 );
}
setInterval( refreshToken, 30000 );
( function( $ ) {
if ( ! $ ) { return; }
$( document ).on( 'updated_checkout', refreshToken );
$( document.body ).on( 'checkout_error', refreshToken );
} )( jQuery );
grecaptcha.execute(
'<?php echo \esc_attr( $site_key ); ?>',
{ action: 'checkout' }
Expand Down