Initial commit.

This commit is contained in:
2025-11-24 21:33:55 +00:00
parent 14b7ade051
commit d6e9d316bc
8974 changed files with 1423277 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
<?php
namespace {
return array('dependencies' => array(), 'version' => '8944fa12c33f0c6e9c9f');
}

View File

@@ -0,0 +1 @@
!function(e){"use strict";const t=window.ppcpRecaptchaSettings||{};let o=null,n=null,c=null,r=!1;function a(){return new Promise(function(e){"undefined"!=typeof grecaptcha&&grecaptcha.execute?(console.log("PPCP reCAPTCHA: reCAPTCHA v3 loaded and ready"),e()):(console.log("PPCP reCAPTCHA: Waiting for reCAPTCHA v3 to load..."),setTimeout(function(){a().then(e)},100))})}function i(o,n){if(t.isBlocks)return;const c=t.isSingleProduct?"form.cart":t.isCheckout?"form.checkout":null;if(!c)return;const r=e(c);0!==r.length?(r.find('input[name="ppcp_recaptcha_token"]').remove(),r.find('input[name="ppcp_recaptcha_version"]').remove(),r.append('<input type="hidden" name="ppcp_recaptcha_token" value="'+o+'">'),r.append('<input type="hidden" name="ppcp_recaptcha_version" value="'+n+'">')):console.error("PPCP reCAPTCHA: Form not found for token update")}function s(e){console.log("PPCP reCAPTCHA: Checkout error detected");const o=e&&("string"==typeof e?e.toLowerCase().includes("captcha"):e.some(e=>e.content&&e.content.toLowerCase().includes("captcha")));r?null!==c&&"undefined"!=typeof grecaptcha&&grecaptcha.reset&&(console.log("PPCP reCAPTCHA: Resetting v2 widget"),grecaptcha.reset(c),n=null):o?(console.log("PPCP reCAPTCHA: v3 failed on checkout, rendering v2"),d()):t.siteKeyV3&&(console.log("PPCP reCAPTCHA: Regenerating v3 token"),l())}async function l(){if("undefined"!=typeof grecaptcha&&grecaptcha.execute)try{o=await grecaptcha.execute(t.siteKeyV3,{action:"ppcp"}),console.log("PPCP reCAPTCHA: New v3 token generated"),i(o,"v3"),t.isBlocks&&window.wp&&window.wp.data&&window.wp.data.dispatch("wc/store/checkout").__internalSetExtensionData("ppcp_recaptcha",{token:o,version:"v3"})}catch(e){console.error("PPCP reCAPTCHA: Failed to generate v3 token",e),o=null}else console.error("PPCP reCAPTCHA: grecaptcha v3 not loaded")}function d(){if(r||!t.siteKeyV2)return;const e=document.getElementById(t.v2ContainerId);if(!e)return void console.error("PPCP reCAPTCHA: v2 container not found");if("undefined"==typeof grecaptcha||!grecaptcha.render)return void console.error("PPCP reCAPTCHA: grecaptcha v2 not loaded");e.innerHTML="";const o=document.createElement("div");o.className="g-recaptcha",o.setAttribute("data-sitekey",t.siteKeyV2),o.setAttribute("data-theme",t.theme),e.appendChild(o),c=grecaptcha.render(o,{sitekey:t.siteKeyV2,theme:t.theme,callback(e){n=e,console.log("PPCP reCAPTCHA: v2 verified"),i(e,"v2"),t.isBlocks&&window.wp&&window.wp.data&&window.wp.data.dispatch("wc/store/checkout").__internalSetExtensionData("ppcp_recaptcha",{token:e,version:"v2"})},"expired-callback"(){n=null,i("","v2"),t.isBlocks&&window.wp&&window.wp.data&&window.wp.data.dispatch("wc/store/checkout").__internalSetExtensionData("ppcp_recaptcha",{token:"",version:"v2"})}}),r=!0}const p=window.fetch;if(window.fetch=async function(e,a={}){const i="string"==typeof e?e:e.url;if(!i||!i.includes("ppc-create-order"))return p.call(this,e,a);let s,l;if(console.log("PPCP reCAPTCHA: Intercepting AJAX",i),r&&n?(s=n,l="v2"):(s=o,l="v3"),!s)return console.error("PPCP reCAPTCHA: No token available"),Promise.reject(new Error("Missing reCAPTCHA token"));try{const e=JSON.parse(a.body);e.ppcp_recaptcha_token=s,e.ppcp_recaptcha_version=l,a.body=JSON.stringify(e),console.log("PPCP reCAPTCHA: Token injected",l)}catch(e){console.error("PPCP reCAPTCHA: Failed to inject token",e)}return p.call(this,e,a).then(function(e){return 403!==e.status&&400!==e.status||e.clone().json().then(function(e){e.data.code===t.errorCodeVerificationFailed&&(r?(console.log("PPCP reCAPTCHA: v2 verification failed, resetting v2 widget"),grecaptcha.reset(c),n=null):(console.log("PPCP reCAPTCHA: v3 failed, rendering v2"),d()))}),e})},e(document).ready(function(){t.siteKeyV3&&a().then(function(){console.log("PPCP reCAPTCHA: Pre-generating v3 token"),l(),setInterval(l,9e4)})}),!t.isBlocks&&t.isCheckout&&e(document.body).on("checkout_error",function(){s(e(".woocommerce-error, .woocommerce-NoticeGroup-checkout").text())}),t.isBlocks&&window.wp&&window.wp.data){const{subscribe:t,select:o}=window.wp.data;let n=!1;t(()=>{const t=o("wc/store/checkout");if(!t)return;const c=t.hasError();c&&!n&&(console.log("PPCP reCAPTCHA: Block checkout error detected"),setTimeout(function(){const t=e(".wc-block-components-notice-banner__content");if(t.length>0){const e=t.text();console.log("PPCP reCAPTCHA: Error message extracted:",e),s(e)}else console.error("PPCP reCAPTCHA: Error banner not found in DOM")},100)),n=c})}}(jQuery);