diff --git a/blocks/form-captcha/build/render.php b/blocks/form-captcha/build/render.php index 0dea4d1ae..bbe1cbb27 100644 --- a/blocks/form-captcha/build/render.php +++ b/blocks/form-captcha/build/render.php @@ -1,6 +1,5 @@ wp_json_encode(array('namespace' => 'prc-block/form-captcha')), 'data-wp-context' => wp_json_encode(array( 'targetNamespace' => $interactive_namespace, + 'siteKey' => PRC_PLATFORM_TURNSTILE_SITE_KEY )), 'data-wp-watch--onDisplayCaptcha' => 'callbacks.onDisplayCaptcha', 'data-wp-bind--hidden' => $interactive_namespace . '::' . 'context.captchaHidden', diff --git a/blocks/form-captcha/build/view.asset.php b/blocks/form-captcha/build/view.asset.php index f892174ba..bf39b45e0 100644 --- a/blocks/form-captcha/build/view.asset.php +++ b/blocks/form-captcha/build/view.asset.php @@ -1 +1 @@ - array('@wordpress/interactivity', 'wp-polyfill'), 'version' => 'f9005b390391434549a8', 'type' => 'module'); + array('@wordpress/interactivity', 'wp-polyfill'), 'version' => 'db36ecb026780aef8f11', 'type' => 'module'); diff --git a/blocks/form-captcha/build/view.js b/blocks/form-captcha/build/view.js index a5404c26e..9ef95a438 100644 --- a/blocks/form-captcha/build/view.js +++ b/blocks/form-captcha/build/view.js @@ -1,2 +1,2 @@ -import*as e from"@wordpress/interactivity";var t={d:(e,c)=>{for(var o in c)t.o(c,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:c[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const c=(o={getContext:()=>e.getContext,getElement:()=>e.getElement,store:()=>e.store},r={},t.d(r,o),r);var o,r;(0,c.store)("prc-block/form-captcha",{callbacks:{onDisplayCaptcha:()=>{const e=(0,c.getContext)(),{targetNamespace:t}=e,o=(0,c.getContext)(t);if(!0===o.captchaHidden)return;const{ref:r}=(0,c.getElement)(),a=r.querySelector(".wp-block-prc-block-form-captcha__captcha");if(!a)return;const{turnstile:n}=window;n.ready((()=>{n.render(a,{sitekey:"0x4AAAAAAAPM0JJJz5nbcTZZ",callback:e=>{console.log(`Challenge Success ${e}`),o.captchaToken=e}})}))}}}); +import*as e from"@wordpress/interactivity";var t={d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const o=(r={getContext:()=>e.getContext,getElement:()=>e.getElement,store:()=>e.store},c={},t.d(c,r),c);var r,c;(0,o.store)("prc-block/form-captcha",{callbacks:{onDisplayCaptcha:()=>{const e=(0,o.getContext)(),{targetNamespace:t,siteKey:r}=e,c=(0,o.getContext)(t);if(!0===c.captchaHidden)return;const{ref:a}=(0,o.getElement)(),n=a.querySelector(".wp-block-prc-block-form-captcha__captcha");if(!n)return;const{turnstile:l}=window;l.ready((()=>{l.render(n,{sitekey:r,callback:e=>{console.log(`Challenge Success ${e}`),c.captchaToken=e}})}))}}}); //# sourceMappingURL=view.js.map \ No newline at end of file diff --git a/blocks/form-captcha/build/view.js.map b/blocks/form-captcha/build/view.js.map index ba8ef5c1e..4191c9245 100644 --- a/blocks/form-captcha/build/view.js.map +++ b/blocks/form-captcha/build/view.js.map @@ -1 +1 @@ -{"version":3,"file":"view.js","mappings":"2CACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,ICIlF,MAAM,GAJGI,EAI8B,CAAE,WAAgB,IAAOC,EAAwE,WAAG,WAAgB,IAAOA,EAAwE,WAAG,MAAW,IAAOA,EAAmE,OAH7TC,EAAI,CAAC,EAAGhB,EAAoBiB,EAAED,EAAGF,GAAWE,GADzC,IAACF,EACJE,GCILE,EAAAA,EAAAA,OAAM,yBAA0B,CAC/BC,UAAW,CACVC,iBAAkBA,KACjB,MAAMC,GAAUC,EAAAA,EAAAA,eACV,gBAAEC,GAAoBF,EACtBG,GAAgBF,EAAAA,EAAAA,YAAWC,GAGjC,IAAI,IAFaC,EAAcC,cAI9B,OAGD,MAAM,IAAEC,IAAQC,EAAAA,EAAAA,cACVC,EAASF,EAAIG,cAClB,6CAED,IAAKD,EACJ,OAGD,MAAM,UAAEE,GAAcC,OACtBD,EAAUE,OAAM,KACfF,EAAUG,OAAOL,EAAQ,CACxBM,QAAS,2BACTC,SAAWC,IACVC,QAAQC,IAAK,qBAAoBF,KACjCZ,EAAce,aAAeH,CAAK,GAElC,GACD","sources":["webpack://form-captcha/webpack/bootstrap","webpack://form-captcha/webpack/runtime/define property getters","webpack://form-captcha/webpack/runtime/hasOwnProperty shorthand","webpack://form-captcha/external module \"@wordpress/interactivity\"","webpack://form-captcha/./src/view.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","var x = (y) => {\n\tvar x = {}; __webpack_require__.d(x, y); return x\n} \nvar y = (x) => (() => (x))\nconst __WEBPACK_NAMESPACE_OBJECT__ = x({ [\"getContext\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getContext), [\"getElement\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getElement), [\"store\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.store) });","/**\n * WordPress Dependencies\n */\nimport { store, getContext, getElement } from '@wordpress/interactivity';\n\nstore('prc-block/form-captcha', {\n\tcallbacks: {\n\t\tonDisplayCaptcha: () => {\n\t\t\tconst context = getContext();\n\t\t\tconst { targetNamespace } = context;\n\t\t\tconst targetContext = getContext(targetNamespace);\n\t\t\tconst isHidden = targetContext.captchaHidden;\n\t\t\t// When we reach the point of the form where the captcha should be displayed, render it.\n\t\t\tif (true === isHidden) {\n\t\t\t\t// We need a way to \"unmount\" the captcha when the form is submitted.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ref } = getElement();\n\t\t\tconst target = ref.querySelector(\n\t\t\t\t'.wp-block-prc-block-form-captcha__captcha'\n\t\t\t);\n\t\t\tif (!target) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// eslint-disable-next-line no-undef\n\t\t\tconst { turnstile } = window;\n\t\t\tturnstile.ready(() => {\n\t\t\t\tturnstile.render(target, {\n\t\t\t\t\tsitekey: '0x4AAAAAAAPM0JJJz5nbcTZZ',\n\t\t\t\t\tcallback: (token) => {\n\t\t\t\t\t\tconsole.log(`Challenge Success ${token}`);\n\t\t\t\t\t\ttargetContext.captchaToken = token;\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t});\n\t\t},\n\t},\n});\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","y","__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__","x","d","store","callbacks","onDisplayCaptcha","context","getContext","targetNamespace","targetContext","captchaHidden","ref","getElement","target","querySelector","turnstile","window","ready","render","sitekey","callback","token","console","log","captchaToken"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"view.js","mappings":"2CACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,ICIlF,MAAM,GAJGI,EAI8B,CAAE,WAAgB,IAAOC,EAAwE,WAAG,WAAgB,IAAOA,EAAwE,WAAG,MAAW,IAAOA,EAAmE,OAH7TC,EAAI,CAAC,EAAGhB,EAAoBiB,EAAED,EAAGF,GAAWE,GADzC,IAACF,EACJE,GCILE,EAAAA,EAAAA,OAAM,yBAA0B,CAC/BC,UAAW,CACVC,iBAAkBA,KACjB,MAAMC,GAAUC,EAAAA,EAAAA,eACV,gBAAEC,EAAe,QAAEC,GAAYH,EAC/BI,GAAgBH,EAAAA,EAAAA,YAAWC,GAGjC,IAAI,IAFaE,EAAcC,cAI9B,OAGD,MAAM,IAAEC,IAAQC,EAAAA,EAAAA,cACVC,EAASF,EAAIG,cAClB,6CAED,IAAKD,EACJ,OAGD,MAAM,UAAEE,GAAcC,OACtBD,EAAUE,OAAM,KACfF,EAAUG,OAAOL,EAAQ,CACxBM,QAASX,EACTY,SAAWC,IACVC,QAAQC,IAAK,qBAAoBF,KACjCZ,EAAce,aAAeH,CAAK,GAElC,GACD","sources":["webpack://form-captcha/webpack/bootstrap","webpack://form-captcha/webpack/runtime/define property getters","webpack://form-captcha/webpack/runtime/hasOwnProperty shorthand","webpack://form-captcha/external module \"@wordpress/interactivity\"","webpack://form-captcha/./src/view.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","var x = (y) => {\n\tvar x = {}; __webpack_require__.d(x, y); return x\n} \nvar y = (x) => (() => (x))\nconst __WEBPACK_NAMESPACE_OBJECT__ = x({ [\"getContext\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getContext), [\"getElement\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getElement), [\"store\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.store) });","/**\n * WordPress Dependencies\n */\nimport { store, getContext, getElement } from '@wordpress/interactivity';\n\nstore('prc-block/form-captcha', {\n\tcallbacks: {\n\t\tonDisplayCaptcha: () => {\n\t\t\tconst context = getContext();\n\t\t\tconst { targetNamespace, siteKey } = context;\n\t\t\tconst targetContext = getContext(targetNamespace);\n\t\t\tconst isHidden = targetContext.captchaHidden;\n\t\t\t// When we reach the point of the form where the captcha should be displayed, render it.\n\t\t\tif (true === isHidden) {\n\t\t\t\t// We need a way to \"unmount\" the captcha when the form is submitted.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ref } = getElement();\n\t\t\tconst target = ref.querySelector(\n\t\t\t\t'.wp-block-prc-block-form-captcha__captcha'\n\t\t\t);\n\t\t\tif (!target) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// eslint-disable-next-line no-undef\n\t\t\tconst { turnstile } = window;\n\t\t\tturnstile.ready(() => {\n\t\t\t\tturnstile.render(target, {\n\t\t\t\t\tsitekey: siteKey,\n\t\t\t\t\tcallback: (token) => {\n\t\t\t\t\t\tconsole.log(`Challenge Success ${token}`);\n\t\t\t\t\t\ttargetContext.captchaToken = token;\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t});\n\t\t},\n\t},\n});\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","y","__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__","x","d","store","callbacks","onDisplayCaptcha","context","getContext","targetNamespace","siteKey","targetContext","captchaHidden","ref","getElement","target","querySelector","turnstile","window","ready","render","sitekey","callback","token","console","log","captchaToken"],"sourceRoot":""} \ No newline at end of file diff --git a/blocks/form-captcha/src/render.php b/blocks/form-captcha/src/render.php index 0dea4d1ae..bbe1cbb27 100644 --- a/blocks/form-captcha/src/render.php +++ b/blocks/form-captcha/src/render.php @@ -1,6 +1,5 @@ wp_json_encode(array('namespace' => 'prc-block/form-captcha')), 'data-wp-context' => wp_json_encode(array( 'targetNamespace' => $interactive_namespace, + 'siteKey' => PRC_PLATFORM_TURNSTILE_SITE_KEY )), 'data-wp-watch--onDisplayCaptcha' => 'callbacks.onDisplayCaptcha', 'data-wp-bind--hidden' => $interactive_namespace . '::' . 'context.captchaHidden', diff --git a/blocks/form-captcha/src/view.js b/blocks/form-captcha/src/view.js index 8897f9442..692d495dd 100644 --- a/blocks/form-captcha/src/view.js +++ b/blocks/form-captcha/src/view.js @@ -7,7 +7,7 @@ store('prc-block/form-captcha', { callbacks: { onDisplayCaptcha: () => { const context = getContext(); - const { targetNamespace } = context; + const { targetNamespace, siteKey } = context; const targetContext = getContext(targetNamespace); const isHidden = targetContext.captchaHidden; // When we reach the point of the form where the captcha should be displayed, render it. @@ -27,7 +27,7 @@ store('prc-block/form-captcha', { const { turnstile } = window; turnstile.ready(() => { turnstile.render(target, { - sitekey: '0x4AAAAAAAPM0JJJz5nbcTZZ', + sitekey: siteKey, callback: (token) => { console.log(`Challenge Success ${token}`); targetContext.captchaToken = token;