1/* Woo Checkout */ 2jQuery( document ).ready(function() { 3 jQuery( document.body ).on( 'update_checkout updated_checkout applied_coupon_in_checkout removed_coupon_in_checkout checkout_error', function() { 4 if(jQuery('.g-recaptcha').length > 0) { 5 if (typeof grecaptcha !== "undefined" && typeof grecaptcha.reset === "function") { 6 var count = 0; 7 jQuery(".g-recaptcha").each(function () { 8 grecaptcha.reset(count); 9 count++; 10 }); 11 } 12 } 13 }); 14}); 15 16/* Woo Checkout Block */ 17(function() { 18 document.addEventListener('DOMContentLoaded', function() { 19 // Global callbacks used by auto-rendered v2 widgets in the block checkout 20 window.rcfwcRecaptchaCallback = function(token) { 21 try { 22 if (typeof wp !== 'undefined' && wp.data) { 23 wp.data.dispatch('wc/store/checkout').__internalSetExtensionData('rcfwc', { token: token }); 24 } 25 } catch (e) {} 26 }; 27 window.rcfwcRecaptchaExpired = function() { 28 try { 29 if (typeof wp !== 'undefined' && wp.data) { 30 wp.data.dispatch('wc/store/checkout').__internalSetExtensionData('rcfwc', { token: '' }); 31 } 32 } catch (e) {} 33 }; 34 35 // Try to render explicitly if needed once the blocks mount/update 36 if (typeof wp !== 'undefined' && wp.data) { 37 var unsubscribe = wp.data.subscribe(function() { 38 var el = document.getElementById('g-recaptcha-woo-checkout'); 39 if (!el) { 40 return; 41 } 42 // If already rendered (has inner HTML/iframe), stop listening 43 if (el.innerHTML && el.innerHTML.trim() !== '') { 44 unsubscribe && unsubscribe(); 45 return; 46 } 47 // Render explicitly with callbacks if the API is ready 48 if (typeof grecaptcha !== 'undefined' && typeof grecaptcha.render === 'function') { 49 try { 50 grecaptcha.render(el, { 51 sitekey: el.getAttribute('data-sitekey'), 52 callback: rcfwcRecaptchaCallback, 53 'expired-callback': rcfwcRecaptchaExpired 54 }); 55 } catch (e) { 56 // Ignore if already rendered or API not ready 57 } 58 unsubscribe && unsubscribe(); 59 } 60 }, 'wc/store/cart'); 61 } 62 }); 63})();
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.