1var pmpro_recaptcha_validated = false; 2var pmpro_recaptcha_onSubmit = function(token) { 3 if ( pmpro_recaptcha_validated ) { 4 jQuery('#pmpro_form').submit(); 5 return; 6 } else { 7 jQuery.ajax({ 8 url: pmpro_recaptcha_v3.admin_ajax_url, 9 type: 'GET', 10 timeout: 30000, 11 dataType: 'html', 12 data: { 13 'action': 'pmpro_validate_recaptcha', 14 'g-recaptcha-response': token, 15 }, 16 error: function(xml){ 17 alert('Error validating ReCAPTCHA.'); 18 }, 19 success: function(response){ 20 if ( response == '1' ) { 21 pmpro_recaptcha_validated = true; 22 23 //get a new token to be submitted with the form 24 grecaptcha.execute(); 25 } else { 26 pmpro_recaptcha_validated = false; 27 28 //warn user validation failed 29 alert( pmpro_recaptcha_v3.error_message ); 30 31 //get a new token to be submitted with the form 32 grecaptcha.execute(); 33 } 34 } 35 }); 36 } 37}; 38 39var pmpro_recaptcha_onloadCallback = function () { 40 41 // If we're using a custom button, let's add the button ID to the custom button. 42 var submit_buttons = jQuery('.pmpro_btn-submit-checkout'); 43 if (jQuery('#pmpro_btn-submit').length === 0) { 44 if (submit_buttons.length > 0) { 45 jQuery(submit_buttons[0]).attr('id', 'pmpro_btn-submit'); 46 } 47 } 48 49 // Render on submit button. 50 grecaptcha.render('pmpro_btn-submit', { 51 'sitekey': pmpro_recaptcha_v3.public_key, 52 'callback': pmpro_recaptcha_onSubmit 53 }); 54 55 // Move the <div> with the reCAPTCHA widget outside of the span that contains the submit button. 56 var submit_button = jQuery('#pmpro_btn-submit'); 57 var submit_span = submit_button.parent(); 58 var recaptcha_widget = jQuery('#pmpro_btn-submit').prev(); 59 recaptcha_widget.insertAfter( submit_span ); 60 61 // Run when the form is submitted. 62 jQuery('#pmpro_form, .pmro_form').submit(function (event) { 63 if (!pmpro_recaptcha_validated) { 64 event.preventDefault(); 65 grecaptcha.execute(); 66 } 67 }); 68};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.