@automattic/newspack-blocks 2.0.0 → 2.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cache/babel/405a59e43e00b2c52dbadde7c6a04c87.json.gz +0 -0
- package/.cache/babel/6715650e6d89955011841839faac29f2.json.gz +0 -0
- package/.cache/babel/8b2ff59858cc47bf8aca96b47daeb4e4.json.gz +0 -0
- package/.cache/babel/fb39540b9437544cb27c360f7d885b90.json.gz +0 -0
- package/CHANGELOG.md +7 -0
- package/dist/editor.asset.php +1 -1
- package/dist/editor.js +1 -1
- package/dist/modal.asset.php +1 -1
- package/dist/modal.js +1 -1
- package/dist/modalCheckout.asset.php +1 -1
- package/dist/modalCheckout.css +1 -1
- package/dist/modalCheckout.rtl.css +1 -1
- package/includes/class-modal-checkout.php +87 -44
- package/newspack-blocks.php +2 -2
- package/package.json +1 -1
- package/src/blocks/checkout-button/block.json +2 -1
- package/src/blocks/checkout-button/edit.js +1 -42
- package/src/blocks/donate/block.json +10 -0
- package/src/blocks/donate/edit/index.tsx +4 -0
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-base.php +14 -2
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-frequency-based.php +2 -2
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-tiers-based.php +1 -1
- package/src/blocks/donate/types.ts +4 -0
- package/src/components/redirect-after-success.tsx +50 -0
- package/src/modal-checkout/checkout.scss +2 -2
- package/src/modal-checkout/modal.js +17 -0
- package/src/modal-checkout/templates/thankyou.php +48 -35
- package/vendor/autoload.php +1 -1
- package/vendor/composer/autoload_real.php +4 -4
- package/vendor/composer/autoload_static.php +2 -2
- package/vendor/composer/installed.php +2 -2
- package/.cache/babel/05ef61416b32f57c09787aa5b64d2174.json.gz +0 -0
- package/.cache/babel/6e8243b5aa4f0e5b85ddf1418e5908d0.json.gz +0 -0
- package/.cache/babel/a3f4c297e3a52f8342c1ffea1b4b1c0c.json.gz +0 -0
package/dist/modal.asset.php
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '
|
|
1
|
+
<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'e544d521f12b6cc305696d5eb8522bff');
|
package/dist/modal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e={r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function o(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?n(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}e.r(t);var r;function
|
|
1
|
+
(()=>{"use strict";var e={r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function o(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?n(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}e.r(t);var r;function c(){var e=document.querySelector('iframe[name="newspack_modal_checkout"]');e&&(e.src="about:blank"),document.body.classList.remove("newspack-modal-checkout-open"),r&&r.disconnect(),Array.from(document.querySelectorAll(".newspack-blocks-modal")).forEach((function(e){var t,n;(e.style.display="none",e.overlayId&&null!==(t=window.newspackReaderActivation)&&void 0!==t&&t.overlays)&&(null===(n=window.newspackReaderActivation)||void 0===n||n.overlays.remove(e.overlayId))}))}window.newspackCloseModalCheckout=c;var a,l=".newspack-blocks-modal";a=function(){var e=document.querySelector(".newspack-blocks-checkout-modal");if(e){var t=document.querySelector("".concat(l,"__spinner")),n="newspack_modal_checkout",a=document.createElement("input");a.type="hidden",a.name="modal_checkout",a.value="1";var i=e.querySelector("".concat(l,"__content")),d=i.clientHeight+"px",u=document.createElement("iframe");u.name=n,i.appendChild(u),e.addEventListener("click",(function(t){t.target===e&&c()})),e.querySelectorAll("".concat(l,"__close")).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault(),i.style.height=d,t.style.display="flex",c()}))}));var s=document.querySelectorAll(".newspack-blocks-variation-modal");s.forEach((function(e){e.addEventListener("click",(function(t){t.target===e&&c()})),e.querySelectorAll(".newspack-blocks-modal__close").forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault(),c()}))}))})),document.querySelectorAll(".wpbnbd.wpbnbd--platform-wc,.wp-block-newspack-blocks-checkout-button,.newspack-blocks-variation-modal").forEach((function(c){c.querySelectorAll("form").forEach((function(c){c.appendChild(a.cloneNode()),c.target=n;var l=c.querySelector('input[name="after_success_url"]'),d=c.querySelector('input[name="after_success_behavior"]');d&&l&&"referrer"===d.getAttribute("value")&&l.setAttribute("value",document.referrer||window.location.href),c.addEventListener("submit",(function(n){var a,l,d=new FormData(c);if(s.forEach((function(e){return e.style.display="none"})),d.get("is_variable")&&!d.get("variation_id")){var f=o(s).find((function(e){return e.dataset.productId===d.get("product_id")}));if(f)return f.querySelectorAll('form[target="newspack_modal_checkout"]').forEach((function(e){["after_success_behavior","after_success_url","after_success_button_label"].forEach((function(t){var n=document.createElement("input");n.type="hidden",n.name=t,n.value=d.get(t),e.appendChild(n)}))})),n.preventDefault(),document.body.classList.add("newspack-modal-checkout-open"),void(f.style.display="block")}t.style.display="flex",e.style.display="block",document.body.classList.add("newspack-modal-checkout-open"),null!==(a=window.newspackReaderActivation)&&void 0!==a&&a.overlays&&(e.overlayId=null===(l=window.newspackReaderActivation)||void 0===l?void 0:l.overlays.add()),r=new ResizeObserver((function(e){if(e&&e.length){var n=e[0].contentRect;n&&(i.style.height=n.top+n.bottom+"px",t.style.display="none")}})),u.addEventListener("load",(function(){var e=u.contentWindow.location;if(window.newspackReaderActivation&&e.href.indexOf("order-received")>-1){var n=window.newspackReaderActivation,c=new Proxy(new URLSearchParams(e.search),{get:function(e,t){return e.get(t)}});c.email&&(n.setReaderEmail(c.email),n.setAuthenticated(!0))}var a=u.contentDocument.querySelector("#newspack_modal_checkout");a&&r.observe(a),o(u.contentDocument.querySelectorAll(".modal-continue, .edit-billing-link")).forEach((function(e){e.addEventListener("click",(function(){return t.style.display="flex"}))}));var l=u.contentDocument.querySelector(".checkout");l&&o(l.querySelectorAll(".woocommerce-billing-fields input")).forEach((function(e){e.addEventListener("keyup",(function(e){"Enter"===e.key&&(t.style.display="flex",l.submit())}))}))}))}))}))}))}},"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",a):a());var i=window;for(var d in t)i[d]=t[d];t.__esModule&&Object.defineProperty(i,"__esModule",{value:!0})})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '
|
|
1
|
+
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '92cca2d330580cefedef8f3e75b4e10d');
|
package/dist/modalCheckout.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
#newspack_modal_checkout{padding:32px;font-size:1rem}#newspack_modal_checkout .order-details-summary{border:2px solid;border-radius:3px;padding:16px}#newspack_modal_checkout .order-details-summary h4{font-size:1rem;margin:0}#newspack_modal_checkout .order-details-summary h4>span{color:inherit;font-size:clamp(1.75rem,1.75rem + (1vw - .48rem)*.962,2.25rem);font-weight:700;line-height:1.434}#newspack_modal_checkout .order-details-summary h4 .subscription-details{font-size:1rem;font-weight:400}#newspack_modal_checkout #order-details-wrapper.hidden{display:none}#newspack_modal_checkout .woocommerce-checkout-review-order-table,#newspack_modal_checkout .woocommerce-NoticeGroup{margin-top:16px}#newspack_modal_checkout .woocommerce-checkout-review-order-table td,#newspack_modal_checkout .woocommerce-checkout-review-order-table th{font-size:.8rem}#newspack_modal_checkout .woocommerce-checkout-review-order-table.empty{display:none;margin:0;padding:0}#newspack_modal_checkout .woocommerce-billing-fields{margin-bottom:16px}#newspack_modal_checkout .checkout-billing-summary{border-bottom:1px solid #ccc;padding-bottom:32px}#newspack_modal_checkout .checkout-billing-summary__grid{align-items:baseline;display:flex;flex-wrap:wrap;gap:8px;justify-content:space-between}#newspack_modal_checkout .checkout-billing-summary p{font-size:clamp(.75rem,.75rem + (1vw - .48rem)*.481,1rem);margin:16px 0 0}#newspack_modal_checkout .checkout-billing-summary .edit-billing-link{color:#767676;font-size:clamp(.75rem,.75rem + (1vw - .48rem)*.481,1rem);display:inline-block;text-decoration:underline}#newspack_modal_checkout .checkout-billing-summary .edit-billing-link:focus,#newspack_modal_checkout .checkout-billing-summary .edit-billing-link:hover{color:inherit}#newspack_modal_checkout .woocommerce-account-fields .create-account{border-bottom:1px solid #ccc;padding-bottom:32px}#newspack_modal_checkout .woocommerce-account-fields .create-account .woocommerce-password-hint,#newspack_modal_checkout .woocommerce-account-fields .create-account .woocommerce-password-strength{color:#cc1818;margin-top:16px}#newspack_modal_checkout form,#newspack_modal_checkout form #wc-stripe-payment-request-button-separator{margin:0}#newspack_modal_checkout form .woocommerce-terms-and-conditions-wrapper{margin:16px 0}#newspack_modal_checkout form h3{font-size:1.37rem;margin:32px 0 0}#newspack_modal_checkout form p{margin:16px 0}#newspack_modal_checkout form .select2-container .select2-selection--single{margin:0}#newspack_modal_checkout form #payment button#place_order{margin-bottom:0}#newspack_modal_checkout form .checkout-billing button[type=submit],#newspack_modal_checkout form button.modal-continue{display:block;width:100%}#newspack_modal_checkout .form-row-first,#newspack_modal_checkout .form-row-last{width:calc(50% - 8px)}#newspack_modal_checkout .form-row-last+.form-row-first,#newspack_modal_checkout .form-row-wide+.form-row-first,#newspack_modal_checkout .form-row-wide+.form-row-first+.form-row-last{margin-top:0}#newspack_modal_checkout .select2-container--default .select2-selection--single{border-color:#ccc;border-radius:0;height:44px}#newspack_modal_checkout .select2-container--default .select2-selection--single .select2-selection__rendered{color:inherit;line-height:44px}#newspack_modal_checkout .select2-container--default .select2-selection--single .select2-selection__arrow{height:42px}#newspack_modal_checkout .wc_payment_method .payment_box{background:#f0f0f0;border-radius:3px;padding:16px}#newspack_modal_checkout .wc_payment_method .payment_box p{margin-top:0}#newspack_modal_checkout .wc-saved-payment-methods{padding:0}#newspack_modal_checkout .woocommerce-error{border-radius:3px;margin:0}#newspack_modal_checkout .woocommerce-notices-wrapper:not(:empty){margin-bottom:32px}#newspack_modal_checkout .woocommerce-privacy-policy-text{color:#767676}#newspack_modal_checkout .woocommerce-privacy-policy-text p{font-size:clamp(.75rem,.75rem + (1vw - .48rem)*.481,1rem);margin:0}#newspack_modal_checkout .woocommerce-thankyou-order-received{align-items:center;border-bottom:1px solid #ccc;display:flex;flex-direction:column;justify-content:center;margin:0 0 32px;padding:0 0 32px}#newspack_modal_checkout .woocommerce-thankyou-order-received:before{-webkit-animation:bounce .25s ease-in;animation:bounce .25s ease-in;-webkit-animation-delay:1s;animation-delay:1s;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;background-color:#4ab866;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z' fill='%23fff'/%3E%3C/svg%3E");background-position:50% 50%;background-repeat:no-repeat;background-size:24px;border-radius:50%;content:"";display:block;height:40px;margin-bottom:16px;padding:8px;transform:scale(0);width:40px}#newspack_modal_checkout .woocommerce-form-login-toggle,#newspack_modal_checkout .woocommerce-thankyou-order-received+.woocommerce-info{display:none}#newspack_modal_checkout .woocommerce-order-overview{color:#767676;list-style:none;margin:16px 0 0;padding:0}#newspack_modal_checkout .blockOverlay{align-items:center;display:flex;inset:0;justify-content:center;position:fixed!important}#newspack_modal_checkout .blockOverlay:after{-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:2px solid #fff;border-top-color:#767676;border-radius:50%;content:"";display:block;height:25px;width:25px}.newspack-modal-newsletters{margin-top:20px;padding-top:22px;border-top:1px solid #ccc}.newspack-modal-newsletters__info{margin-bottom:35px}.newspack-modal-newsletters__info span{color:#767676}.newspack-modal-newsletters__list-item{display:flex;margin-bottom:18px;border:1px solid #ccc;border-radius:6px}.newspack-modal-newsletters__list-item b{display:block;margin-bottom:2px}.newspack-modal-newsletters label{flex:1;padding:12px;cursor:pointer}.newspack-modal-newsletters input[type=checkbox]{padding:10px;margin-top:18px;margin-right:19px;margin-left:20px;border-radius:5px}.newspack-modal-newsletters__button,.newspack-modal-newsletters input[type=submit]{margin-top:25px;width:100%;padding:22px;font-size:1em}@-webkit-keyframes bounce{0%{transform:scale(0)}90%{transform:scale(1.4)}to{transform:scale(1)}}@keyframes bounce{0%{transform:scale(0)}90%{transform:scale(1.4)}to{transform:scale(1)}}
|
|
1
|
+
#newspack_modal_checkout{padding:32px;font-size:1rem}#newspack_modal_checkout .order-details-summary{border:2px solid;border-radius:3px;padding:16px}#newspack_modal_checkout .order-details-summary h4{font-size:1rem;margin:0}#newspack_modal_checkout .order-details-summary h4>span{color:inherit;font-size:clamp(1.75rem,1.75rem + (1vw - .48rem)*.962,2.25rem);font-weight:700;line-height:1.434}#newspack_modal_checkout .order-details-summary h4 .subscription-details{font-size:1rem;font-weight:400}#newspack_modal_checkout #order-details-wrapper.hidden{display:none}#newspack_modal_checkout .woocommerce-checkout-review-order-table,#newspack_modal_checkout .woocommerce-NoticeGroup{margin-top:16px}#newspack_modal_checkout .woocommerce-checkout-review-order-table td,#newspack_modal_checkout .woocommerce-checkout-review-order-table th{font-size:.8rem}#newspack_modal_checkout .woocommerce-checkout-review-order-table.empty{display:none;margin:0;padding:0}#newspack_modal_checkout .woocommerce-billing-fields{margin-bottom:16px}#newspack_modal_checkout .checkout-billing-summary{border-bottom:1px solid #ccc;padding-bottom:32px}#newspack_modal_checkout .checkout-billing-summary__grid{align-items:baseline;display:flex;flex-wrap:wrap;gap:8px;justify-content:space-between}#newspack_modal_checkout .checkout-billing-summary p{font-size:clamp(.75rem,.75rem + (1vw - .48rem)*.481,1rem);margin:16px 0 0}#newspack_modal_checkout .checkout-billing-summary .edit-billing-link{color:#767676;font-size:clamp(.75rem,.75rem + (1vw - .48rem)*.481,1rem);display:inline-block;text-decoration:underline}#newspack_modal_checkout .checkout-billing-summary .edit-billing-link:focus,#newspack_modal_checkout .checkout-billing-summary .edit-billing-link:hover{color:inherit}#newspack_modal_checkout .woocommerce-account-fields .create-account{border-bottom:1px solid #ccc;padding-bottom:32px}#newspack_modal_checkout .woocommerce-account-fields .create-account .woocommerce-password-hint,#newspack_modal_checkout .woocommerce-account-fields .create-account .woocommerce-password-strength{color:#cc1818;margin-top:16px}#newspack_modal_checkout form,#newspack_modal_checkout form #wc-stripe-payment-request-button-separator{margin:0}#newspack_modal_checkout form .woocommerce-terms-and-conditions-wrapper{margin:16px 0}#newspack_modal_checkout form h3{font-size:1.37rem;margin:32px 0 0}#newspack_modal_checkout form p{margin:16px 0}#newspack_modal_checkout form .select2-container .select2-selection--single{margin:0}#newspack_modal_checkout form #payment button#place_order{margin-bottom:0}#newspack_modal_checkout form .checkout-billing button[type=submit],#newspack_modal_checkout form button.modal-continue{display:block;width:100%}#newspack_modal_checkout .form-row-first,#newspack_modal_checkout .form-row-last{width:calc(50% - 8px)}#newspack_modal_checkout .form-row-last+.form-row-first,#newspack_modal_checkout .form-row-wide+.form-row-first,#newspack_modal_checkout .form-row-wide+.form-row-first+.form-row-last{margin-top:0}#newspack_modal_checkout .select2-container--default .select2-selection--single{border-color:#ccc;border-radius:0;height:44px}#newspack_modal_checkout .select2-container--default .select2-selection--single .select2-selection__rendered{color:inherit;line-height:44px}#newspack_modal_checkout .select2-container--default .select2-selection--single .select2-selection__arrow{height:42px}#newspack_modal_checkout .wc_payment_method .payment_box{background:#f0f0f0;border-radius:3px;padding:16px}#newspack_modal_checkout .wc_payment_method .payment_box p{margin-top:0}#newspack_modal_checkout .wc-saved-payment-methods{padding:0}#newspack_modal_checkout .woocommerce-error{border-radius:3px;margin:0}#newspack_modal_checkout .woocommerce-notices-wrapper:not(:empty){margin-bottom:32px}#newspack_modal_checkout .woocommerce-privacy-policy-text{color:#767676}#newspack_modal_checkout .woocommerce-privacy-policy-text p{font-size:clamp(.75rem,.75rem + (1vw - .48rem)*.481,1rem);margin:0}#newspack_modal_checkout .woocommerce-thankyou-order-received{align-items:center;border-bottom:1px solid #ccc;display:flex;flex-direction:column;justify-content:center;margin:0 0 32px;padding:0 0 32px}#newspack_modal_checkout .woocommerce-thankyou-order-received:before{-webkit-animation:bounce .25s ease-in;animation:bounce .25s ease-in;-webkit-animation-delay:1s;animation-delay:1s;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;background-color:#4ab866;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z' fill='%23fff'/%3E%3C/svg%3E");background-position:50% 50%;background-repeat:no-repeat;background-size:24px;border-radius:50%;content:"";display:block;height:40px;margin-bottom:16px;padding:8px;transform:scale(0);width:40px}#newspack_modal_checkout .woocommerce-form-login-toggle,#newspack_modal_checkout .woocommerce-thankyou-order-received+.woocommerce-info{display:none}#newspack_modal_checkout .woocommerce-order-overview{color:#767676;list-style:none;margin:16px 0 0;padding:0}#newspack_modal_checkout .blockOverlay{align-items:center;display:flex;inset:0;justify-content:center;position:fixed!important}#newspack_modal_checkout .blockOverlay:after{-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:2px solid #fff;border-top-color:#767676;border-radius:50%;content:"";display:block;height:25px;width:25px}.newspack-modal-newsletters{margin-top:20px;padding-top:22px;border-top:1px solid #ccc}.newspack-modal-newsletters__info{margin-bottom:35px}.newspack-modal-newsletters__info span{color:#767676}.newspack-modal-newsletters__list-item{display:flex;margin-bottom:18px;border:1px solid #ccc;border-radius:6px}.newspack-modal-newsletters__list-item b{display:block;margin-bottom:2px}.newspack-modal-newsletters label{flex:1;padding:12px;cursor:pointer}.newspack-modal-newsletters input[type=checkbox]{padding:10px;margin-top:18px;margin-right:19px;margin-left:20px;border-radius:5px}.newspack-modal-newsletters__button,.newspack-modal-newsletters input[type=submit]{margin-top:25px;width:100%;padding:22px!important;font-size:1em!important}@-webkit-keyframes bounce{0%{transform:scale(0)}90%{transform:scale(1.4)}to{transform:scale(1)}}@keyframes bounce{0%{transform:scale(0)}90%{transform:scale(1.4)}to{transform:scale(1)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
#newspack_modal_checkout{padding:32px;font-size:1rem}#newspack_modal_checkout .order-details-summary{border:2px solid;border-radius:3px;padding:16px}#newspack_modal_checkout .order-details-summary h4{font-size:1rem;margin:0}#newspack_modal_checkout .order-details-summary h4>span{color:inherit;font-size:clamp(1.75rem,1.75rem + (1vw - .48rem)*.962,2.25rem);font-weight:700;line-height:1.434}#newspack_modal_checkout .order-details-summary h4 .subscription-details{font-size:1rem;font-weight:400}#newspack_modal_checkout #order-details-wrapper.hidden{display:none}#newspack_modal_checkout .woocommerce-checkout-review-order-table,#newspack_modal_checkout .woocommerce-NoticeGroup{margin-top:16px}#newspack_modal_checkout .woocommerce-checkout-review-order-table td,#newspack_modal_checkout .woocommerce-checkout-review-order-table th{font-size:.8rem}#newspack_modal_checkout .woocommerce-checkout-review-order-table.empty{display:none;margin:0;padding:0}#newspack_modal_checkout .woocommerce-billing-fields{margin-bottom:16px}#newspack_modal_checkout .checkout-billing-summary{border-bottom:1px solid #ccc;padding-bottom:32px}#newspack_modal_checkout .checkout-billing-summary__grid{align-items:baseline;display:flex;flex-wrap:wrap;gap:8px;justify-content:space-between}#newspack_modal_checkout .checkout-billing-summary p{font-size:clamp(.75rem,.75rem + (1vw - .48rem)*.481,1rem);margin:16px 0 0}#newspack_modal_checkout .checkout-billing-summary .edit-billing-link{color:#767676;font-size:clamp(.75rem,.75rem + (1vw - .48rem)*.481,1rem);display:inline-block;text-decoration:underline}#newspack_modal_checkout .checkout-billing-summary .edit-billing-link:focus,#newspack_modal_checkout .checkout-billing-summary .edit-billing-link:hover{color:inherit}#newspack_modal_checkout .woocommerce-account-fields .create-account{border-bottom:1px solid #ccc;padding-bottom:32px}#newspack_modal_checkout .woocommerce-account-fields .create-account .woocommerce-password-hint,#newspack_modal_checkout .woocommerce-account-fields .create-account .woocommerce-password-strength{color:#cc1818;margin-top:16px}#newspack_modal_checkout form,#newspack_modal_checkout form #wc-stripe-payment-request-button-separator{margin:0}#newspack_modal_checkout form .woocommerce-terms-and-conditions-wrapper{margin:16px 0}#newspack_modal_checkout form h3{font-size:1.37rem;margin:32px 0 0}#newspack_modal_checkout form p{margin:16px 0}#newspack_modal_checkout form .select2-container .select2-selection--single{margin:0}#newspack_modal_checkout form #payment button#place_order{margin-bottom:0}#newspack_modal_checkout form .checkout-billing button[type=submit],#newspack_modal_checkout form button.modal-continue{display:block;width:100%}#newspack_modal_checkout .form-row-first,#newspack_modal_checkout .form-row-last{width:calc(50% - 8px)}#newspack_modal_checkout .form-row-last+.form-row-first,#newspack_modal_checkout .form-row-wide+.form-row-first,#newspack_modal_checkout .form-row-wide+.form-row-first+.form-row-last{margin-top:0}#newspack_modal_checkout .select2-container--default .select2-selection--single{border-color:#ccc;border-radius:0;height:44px}#newspack_modal_checkout .select2-container--default .select2-selection--single .select2-selection__rendered{color:inherit;line-height:44px}#newspack_modal_checkout .select2-container--default .select2-selection--single .select2-selection__arrow{height:42px}#newspack_modal_checkout .wc_payment_method .payment_box{background:#f0f0f0;border-radius:3px;padding:16px}#newspack_modal_checkout .wc_payment_method .payment_box p{margin-top:0}#newspack_modal_checkout .wc-saved-payment-methods{padding:0}#newspack_modal_checkout .woocommerce-error{border-radius:3px;margin:0}#newspack_modal_checkout .woocommerce-notices-wrapper:not(:empty){margin-bottom:32px}#newspack_modal_checkout .woocommerce-privacy-policy-text{color:#767676}#newspack_modal_checkout .woocommerce-privacy-policy-text p{font-size:clamp(.75rem,.75rem + (1vw - .48rem)*.481,1rem);margin:0}#newspack_modal_checkout .woocommerce-thankyou-order-received{align-items:center;border-bottom:1px solid #ccc;display:flex;flex-direction:column;justify-content:center;margin:0 0 32px;padding:0 0 32px}#newspack_modal_checkout .woocommerce-thankyou-order-received:before{-webkit-animation:bounce .25s ease-in;animation:bounce .25s ease-in;-webkit-animation-delay:1s;animation-delay:1s;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;background-color:#4ab866;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z' fill='%23fff'/%3E%3C/svg%3E");background-position:50% 50%;background-repeat:no-repeat;background-size:24px;border-radius:50%;content:"";display:block;height:40px;margin-bottom:16px;padding:8px;transform:scale(0);width:40px}#newspack_modal_checkout .woocommerce-form-login-toggle,#newspack_modal_checkout .woocommerce-thankyou-order-received+.woocommerce-info{display:none}#newspack_modal_checkout .woocommerce-order-overview{color:#767676;list-style:none;margin:16px 0 0;padding:0}#newspack_modal_checkout .blockOverlay{align-items:center;display:flex;inset:0;justify-content:center;position:fixed!important}#newspack_modal_checkout .blockOverlay:after{-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:2px solid #fff;border-top-color:#767676;border-radius:50%;content:"";display:block;height:25px;width:25px}.newspack-modal-newsletters{margin-top:20px;padding-top:22px;border-top:1px solid #ccc}.newspack-modal-newsletters__info{margin-bottom:35px}.newspack-modal-newsletters__info span{color:#767676}.newspack-modal-newsletters__list-item{display:flex;margin-bottom:18px;border:1px solid #ccc;border-radius:6px}.newspack-modal-newsletters__list-item b{display:block;margin-bottom:2px}.newspack-modal-newsletters label{flex:1;padding:12px;cursor:pointer}.newspack-modal-newsletters input[type=checkbox]{padding:10px;margin-top:18px;margin-left:19px;margin-right:20px;border-radius:5px}.newspack-modal-newsletters__button,.newspack-modal-newsletters input[type=submit]{margin-top:25px;width:100%;padding:22px;font-size:1em}@-webkit-keyframes bounce{0%{transform:scale(0)}90%{transform:scale(1.4)}to{transform:scale(1)}}@keyframes bounce{0%{transform:scale(0)}90%{transform:scale(1.4)}to{transform:scale(1)}}
|
|
1
|
+
#newspack_modal_checkout{padding:32px;font-size:1rem}#newspack_modal_checkout .order-details-summary{border:2px solid;border-radius:3px;padding:16px}#newspack_modal_checkout .order-details-summary h4{font-size:1rem;margin:0}#newspack_modal_checkout .order-details-summary h4>span{color:inherit;font-size:clamp(1.75rem,1.75rem + (1vw - .48rem)*.962,2.25rem);font-weight:700;line-height:1.434}#newspack_modal_checkout .order-details-summary h4 .subscription-details{font-size:1rem;font-weight:400}#newspack_modal_checkout #order-details-wrapper.hidden{display:none}#newspack_modal_checkout .woocommerce-checkout-review-order-table,#newspack_modal_checkout .woocommerce-NoticeGroup{margin-top:16px}#newspack_modal_checkout .woocommerce-checkout-review-order-table td,#newspack_modal_checkout .woocommerce-checkout-review-order-table th{font-size:.8rem}#newspack_modal_checkout .woocommerce-checkout-review-order-table.empty{display:none;margin:0;padding:0}#newspack_modal_checkout .woocommerce-billing-fields{margin-bottom:16px}#newspack_modal_checkout .checkout-billing-summary{border-bottom:1px solid #ccc;padding-bottom:32px}#newspack_modal_checkout .checkout-billing-summary__grid{align-items:baseline;display:flex;flex-wrap:wrap;gap:8px;justify-content:space-between}#newspack_modal_checkout .checkout-billing-summary p{font-size:clamp(.75rem,.75rem + (1vw - .48rem)*.481,1rem);margin:16px 0 0}#newspack_modal_checkout .checkout-billing-summary .edit-billing-link{color:#767676;font-size:clamp(.75rem,.75rem + (1vw - .48rem)*.481,1rem);display:inline-block;text-decoration:underline}#newspack_modal_checkout .checkout-billing-summary .edit-billing-link:focus,#newspack_modal_checkout .checkout-billing-summary .edit-billing-link:hover{color:inherit}#newspack_modal_checkout .woocommerce-account-fields .create-account{border-bottom:1px solid #ccc;padding-bottom:32px}#newspack_modal_checkout .woocommerce-account-fields .create-account .woocommerce-password-hint,#newspack_modal_checkout .woocommerce-account-fields .create-account .woocommerce-password-strength{color:#cc1818;margin-top:16px}#newspack_modal_checkout form,#newspack_modal_checkout form #wc-stripe-payment-request-button-separator{margin:0}#newspack_modal_checkout form .woocommerce-terms-and-conditions-wrapper{margin:16px 0}#newspack_modal_checkout form h3{font-size:1.37rem;margin:32px 0 0}#newspack_modal_checkout form p{margin:16px 0}#newspack_modal_checkout form .select2-container .select2-selection--single{margin:0}#newspack_modal_checkout form #payment button#place_order{margin-bottom:0}#newspack_modal_checkout form .checkout-billing button[type=submit],#newspack_modal_checkout form button.modal-continue{display:block;width:100%}#newspack_modal_checkout .form-row-first,#newspack_modal_checkout .form-row-last{width:calc(50% - 8px)}#newspack_modal_checkout .form-row-last+.form-row-first,#newspack_modal_checkout .form-row-wide+.form-row-first,#newspack_modal_checkout .form-row-wide+.form-row-first+.form-row-last{margin-top:0}#newspack_modal_checkout .select2-container--default .select2-selection--single{border-color:#ccc;border-radius:0;height:44px}#newspack_modal_checkout .select2-container--default .select2-selection--single .select2-selection__rendered{color:inherit;line-height:44px}#newspack_modal_checkout .select2-container--default .select2-selection--single .select2-selection__arrow{height:42px}#newspack_modal_checkout .wc_payment_method .payment_box{background:#f0f0f0;border-radius:3px;padding:16px}#newspack_modal_checkout .wc_payment_method .payment_box p{margin-top:0}#newspack_modal_checkout .wc-saved-payment-methods{padding:0}#newspack_modal_checkout .woocommerce-error{border-radius:3px;margin:0}#newspack_modal_checkout .woocommerce-notices-wrapper:not(:empty){margin-bottom:32px}#newspack_modal_checkout .woocommerce-privacy-policy-text{color:#767676}#newspack_modal_checkout .woocommerce-privacy-policy-text p{font-size:clamp(.75rem,.75rem + (1vw - .48rem)*.481,1rem);margin:0}#newspack_modal_checkout .woocommerce-thankyou-order-received{align-items:center;border-bottom:1px solid #ccc;display:flex;flex-direction:column;justify-content:center;margin:0 0 32px;padding:0 0 32px}#newspack_modal_checkout .woocommerce-thankyou-order-received:before{-webkit-animation:bounce .25s ease-in;animation:bounce .25s ease-in;-webkit-animation-delay:1s;animation-delay:1s;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;background-color:#4ab866;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z' fill='%23fff'/%3E%3C/svg%3E");background-position:50% 50%;background-repeat:no-repeat;background-size:24px;border-radius:50%;content:"";display:block;height:40px;margin-bottom:16px;padding:8px;transform:scale(0);width:40px}#newspack_modal_checkout .woocommerce-form-login-toggle,#newspack_modal_checkout .woocommerce-thankyou-order-received+.woocommerce-info{display:none}#newspack_modal_checkout .woocommerce-order-overview{color:#767676;list-style:none;margin:16px 0 0;padding:0}#newspack_modal_checkout .blockOverlay{align-items:center;display:flex;inset:0;justify-content:center;position:fixed!important}#newspack_modal_checkout .blockOverlay:after{-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:2px solid #fff;border-top-color:#767676;border-radius:50%;content:"";display:block;height:25px;width:25px}.newspack-modal-newsletters{margin-top:20px;padding-top:22px;border-top:1px solid #ccc}.newspack-modal-newsletters__info{margin-bottom:35px}.newspack-modal-newsletters__info span{color:#767676}.newspack-modal-newsletters__list-item{display:flex;margin-bottom:18px;border:1px solid #ccc;border-radius:6px}.newspack-modal-newsletters__list-item b{display:block;margin-bottom:2px}.newspack-modal-newsletters label{flex:1;padding:12px;cursor:pointer}.newspack-modal-newsletters input[type=checkbox]{padding:10px;margin-top:18px;margin-left:19px;margin-right:20px;border-radius:5px}.newspack-modal-newsletters__button,.newspack-modal-newsletters input[type=submit]{margin-top:25px;width:100%;padding:22px!important;font-size:1em!important}@-webkit-keyframes bounce{0%{transform:scale(0)}90%{transform:scale(1.4)}to{transform:scale(1)}}@keyframes bounce{0%{transform:scale(0)}90%{transform:scale(1.4)}to{transform:scale(1)}}
|
|
@@ -313,6 +313,29 @@ final class Modal_Checkout {
|
|
|
313
313
|
ob_end_flush();
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
/**
|
|
317
|
+
* Get after success button params.
|
|
318
|
+
*/
|
|
319
|
+
private static function get_after_success_params() {
|
|
320
|
+
return array_filter(
|
|
321
|
+
[
|
|
322
|
+
'after_success_behavior' => isset( $_REQUEST['after_success_behavior'] ) ? rawurlencode( sanitize_text_field( wp_unslash( $_REQUEST['after_success_behavior'] ) ) ) : '', // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
|
323
|
+
'after_success_url' => isset( $_REQUEST['after_success_url'] ) ? rawurlencode( sanitize_text_field( wp_unslash( $_REQUEST['after_success_url'] ) ) ) : '', // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
|
324
|
+
'after_success_button_label' => isset( $_REQUEST['after_success_button_label'] ) ? rawurlencode( sanitize_text_field( wp_unslash( $_REQUEST['after_success_button_label'] ) ) ) : '', // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
|
325
|
+
]
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Render hidden inputs to pass some params along.
|
|
331
|
+
*/
|
|
332
|
+
private static function render_hidden_inputs() {
|
|
333
|
+
foreach ( self::get_after_success_params() as $key => $value ) {
|
|
334
|
+
?>
|
|
335
|
+
<input type="hidden" name="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value ); ?>" />
|
|
336
|
+
<?php
|
|
337
|
+
}
|
|
338
|
+
}
|
|
316
339
|
|
|
317
340
|
/**
|
|
318
341
|
* Return URL for modal checkout "thank you" page.
|
|
@@ -327,13 +350,13 @@ final class Modal_Checkout {
|
|
|
327
350
|
return $url;
|
|
328
351
|
}
|
|
329
352
|
|
|
330
|
-
$args =
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
353
|
+
$args = array_merge(
|
|
354
|
+
[
|
|
355
|
+
'modal_checkout' => '1',
|
|
356
|
+
'email' => isset( $_REQUEST['billing_email'] ) ? rawurlencode( \sanitize_email( \wp_unslash( $_REQUEST['billing_email'] ) ) ) : '', // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
|
357
|
+
],
|
|
358
|
+
self::get_after_success_params()
|
|
359
|
+
);
|
|
337
360
|
|
|
338
361
|
// Pass order ID for modal checkout templates.
|
|
339
362
|
if ( $order && is_a( $order, 'WC_Order' ) ) {
|
|
@@ -562,28 +585,42 @@ final class Modal_Checkout {
|
|
|
562
585
|
}
|
|
563
586
|
|
|
564
587
|
/**
|
|
565
|
-
*
|
|
588
|
+
* Render markup at the end of the "thank you" view.
|
|
589
|
+
*
|
|
590
|
+
* @param WC_Order $order The order related to the transaction.
|
|
566
591
|
*
|
|
567
592
|
* @return void
|
|
568
593
|
*/
|
|
569
|
-
public static function render_checkout_after_success_markup() {
|
|
594
|
+
public static function render_checkout_after_success_markup( $order ) {
|
|
595
|
+
if ( self::is_newsletter_signup_available() ) {
|
|
596
|
+
self::render_newsletter_signup_form( $order );
|
|
597
|
+
} else {
|
|
598
|
+
self::render_after_success_button();
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Render markup at the end of the "thank you" view.
|
|
604
|
+
*
|
|
605
|
+
* @return void
|
|
606
|
+
*/
|
|
607
|
+
private static function render_after_success_button() {
|
|
570
608
|
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
|
571
|
-
if (
|
|
572
|
-
empty( $_REQUEST['modal_checkout'] ) ||
|
|
573
|
-
empty( $_REQUEST['after_success_behavior'] ) ||
|
|
574
|
-
empty( $_REQUEST['after_success_url'] )
|
|
575
|
-
) {
|
|
609
|
+
if ( empty( $_REQUEST['modal_checkout'] ) ) {
|
|
576
610
|
return;
|
|
577
611
|
}
|
|
578
612
|
|
|
579
|
-
$button_label = ! empty( $_REQUEST['after_success_button_label'] ) ?
|
|
580
|
-
|
|
613
|
+
$button_label = ! empty( $_REQUEST['after_success_button_label'] ) ? urldecode( wp_unslash( $_REQUEST['after_success_button_label'] ) ) : __( 'Continue browsing', 'newspack-blocks' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
|
614
|
+
$url = ! empty( $_REQUEST['after_success_url'] ) ? urldecode( wp_unslash( $_REQUEST['after_success_url'] ) ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
|
581
615
|
?>
|
|
582
616
|
<a
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
617
|
+
<?php if ( empty( $url ) ) : ?>
|
|
618
|
+
onclick="parent.newspackCloseModalCheckout(this);"
|
|
619
|
+
<?php else : ?>
|
|
620
|
+
href="<?php echo esc_url( $url ); ?>"
|
|
621
|
+
target="_top"
|
|
622
|
+
<?php endif; ?>
|
|
623
|
+
class="button newspack-modal-newsletters__button"
|
|
587
624
|
>
|
|
588
625
|
<?php echo esc_html( $button_label ); ?>
|
|
589
626
|
</a>
|
|
@@ -596,10 +633,7 @@ final class Modal_Checkout {
|
|
|
596
633
|
*
|
|
597
634
|
* @param WC_Order $order The order related to the transaction.
|
|
598
635
|
*/
|
|
599
|
-
|
|
600
|
-
if ( ! self::is_newsletter_signup_available() ) {
|
|
601
|
-
return false;
|
|
602
|
-
}
|
|
636
|
+
private static function render_newsletter_signup_form( $order ) {
|
|
603
637
|
$email_address = $order->get_billing_email();
|
|
604
638
|
if ( ! $email_address ) {
|
|
605
639
|
return;
|
|
@@ -646,6 +680,7 @@ final class Modal_Checkout {
|
|
|
646
680
|
<input type="hidden" name="modal_checkout" value="1" />
|
|
647
681
|
<input type="hidden" name="newsletter_signup_email" value="<?php echo esc_html( $email_address ); ?>" />
|
|
648
682
|
<?php
|
|
683
|
+
self::render_hidden_inputs();
|
|
649
684
|
foreach ( $newsletters_lists as $list ) {
|
|
650
685
|
$checkbox_id = sprintf( 'newspack-blocks-list-%s', $list['id'] );
|
|
651
686
|
?>
|
|
@@ -693,18 +728,22 @@ final class Modal_Checkout {
|
|
|
693
728
|
}
|
|
694
729
|
$signup_data = self::get_newsletter_signup_data();
|
|
695
730
|
if ( false !== $signup_data ) {
|
|
696
|
-
$
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
'
|
|
731
|
+
if ( empty( $signup_data['lists'] ) ) {
|
|
732
|
+
return new \WP_Error( 'newspack_no_lists_selected', __( 'No lists selected.', 'newspack-blocks' ) );
|
|
733
|
+
} else {
|
|
734
|
+
$result = \Newspack_Newsletters_Subscription::add_contact(
|
|
735
|
+
[
|
|
736
|
+
'email' => $signup_data['email'],
|
|
737
|
+
'metadata' => [
|
|
738
|
+
'current_page_url' => home_url( add_query_arg( array(), \wp_get_referer() ) ),
|
|
739
|
+
'newsletters_subscription_method' => 'post-checkout',
|
|
740
|
+
],
|
|
702
741
|
],
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
742
|
+
$signup_data['lists']
|
|
743
|
+
);
|
|
744
|
+
if ( \is_wp_error( $result ) ) {
|
|
745
|
+
return $result;
|
|
746
|
+
}
|
|
708
747
|
}
|
|
709
748
|
return true;
|
|
710
749
|
}
|
|
@@ -718,22 +757,28 @@ final class Modal_Checkout {
|
|
|
718
757
|
$newsletter_signup_email = isset( $_GET['newsletter_signup_email'] ) ? \sanitize_text_field( \wp_unslash( $_GET['newsletter_signup_email'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
|
719
758
|
if ( $newsletter_signup_email && isset( $_SERVER['REQUEST_URI'] ) ) {
|
|
720
759
|
parse_str( \wp_parse_url( \wp_unslash( $_SERVER['REQUEST_URI'] ) )['query'], $query ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
|
760
|
+
$signup_data = [
|
|
761
|
+
'email' => $newsletter_signup_email,
|
|
762
|
+
'lists' => [],
|
|
763
|
+
];
|
|
721
764
|
if ( isset( $query['lists'] ) && count( $query['lists'] ) ) {
|
|
722
|
-
|
|
723
|
-
'email' => $newsletter_signup_email,
|
|
724
|
-
'lists' => $query['lists'],
|
|
725
|
-
];
|
|
765
|
+
$signup_data['lists'] = $query['lists'];
|
|
726
766
|
}
|
|
767
|
+
return $signup_data;
|
|
727
768
|
}
|
|
728
769
|
return false;
|
|
729
770
|
}
|
|
730
771
|
|
|
731
772
|
/**
|
|
732
773
|
* Renders newsletter signup confirmation.
|
|
774
|
+
*
|
|
775
|
+
* @param bool $no_lists_selected Whether no lists were selected.
|
|
733
776
|
*/
|
|
734
|
-
public static function render_newsletter_confirmation() {
|
|
777
|
+
public static function render_newsletter_confirmation( $no_lists_selected = false ) {
|
|
735
778
|
?>
|
|
736
|
-
|
|
779
|
+
<?php if ( ! $no_lists_selected ) : ?>
|
|
780
|
+
<h4><?php esc_html_e( 'Signup successful!', 'newspack-blocks' ); ?></h4>
|
|
781
|
+
<?php endif; ?>
|
|
737
782
|
<p>
|
|
738
783
|
<?php
|
|
739
784
|
echo esc_html(
|
|
@@ -745,10 +790,8 @@ final class Modal_Checkout {
|
|
|
745
790
|
);
|
|
746
791
|
?>
|
|
747
792
|
</p>
|
|
748
|
-
<button onclick="parent.newspackCloseModalCheckout(this);" class="newspack-modal-newsletters__button">
|
|
749
|
-
<?php esc_html_e( 'Close', 'newspack-blocks' ); ?>
|
|
750
|
-
</button>
|
|
751
793
|
<?php
|
|
794
|
+
self::render_after_success_button();
|
|
752
795
|
}
|
|
753
796
|
}
|
|
754
797
|
Modal_Checkout::init();
|
package/newspack-blocks.php
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Author URI: https://newspack.com/
|
|
8
8
|
* Text Domain: newspack-blocks
|
|
9
9
|
* Domain Path: /languages
|
|
10
|
-
* Version: 2.0.
|
|
10
|
+
* Version: 2.1.0-alpha.1
|
|
11
11
|
*
|
|
12
12
|
* @package Newspack_Blocks
|
|
13
13
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
define( 'NEWSPACK_BLOCKS__PLUGIN_FILE', __FILE__ );
|
|
16
16
|
define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
|
|
17
17
|
define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( NEWSPACK_BLOCKS__PLUGIN_FILE ) );
|
|
18
|
-
define( 'NEWSPACK_BLOCKS__VERSION', '2.0.
|
|
18
|
+
define( 'NEWSPACK_BLOCKS__VERSION', '2.1.0-alpha.1' );
|
|
19
19
|
|
|
20
20
|
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks.php';
|
|
21
21
|
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-api.php';
|
package/package.json
CHANGED
|
@@ -34,6 +34,7 @@ import apiFetch from '@wordpress/api-fetch';
|
|
|
34
34
|
* Internal dependencies
|
|
35
35
|
*/
|
|
36
36
|
import './edit.scss';
|
|
37
|
+
import RedirectAfterSuccess from '../../components/redirect-after-success';
|
|
37
38
|
|
|
38
39
|
function getVariationName( variation ) {
|
|
39
40
|
const attributes = [];
|
|
@@ -153,48 +154,6 @@ function ProductControl( props ) {
|
|
|
153
154
|
);
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
function RedirectAfterSuccess( props ) {
|
|
157
|
-
const { attributes, setAttributes } = props;
|
|
158
|
-
return (
|
|
159
|
-
<>
|
|
160
|
-
<SelectControl
|
|
161
|
-
label={ __( 'Post-Checkout Button', 'newspack-blocks' ) }
|
|
162
|
-
help={ __(
|
|
163
|
-
'Select whether the user should be presented with a button to navigate after a successful purchase.',
|
|
164
|
-
'newspack-blocks'
|
|
165
|
-
) }
|
|
166
|
-
value={ attributes.afterSuccessBehavior }
|
|
167
|
-
options={ [
|
|
168
|
-
{ label: __( 'Do not show a button', 'newspack-blocks' ), value: '' },
|
|
169
|
-
{ label: __( 'Go to a custom URL', 'newspack-blocks' ), value: 'custom' },
|
|
170
|
-
{ label: __( 'Go to the previous page', 'newspack-blocks' ), value: 'referrer' },
|
|
171
|
-
] }
|
|
172
|
-
onChange={ value => {
|
|
173
|
-
setAttributes( { afterSuccessBehavior: value.toString() } );
|
|
174
|
-
} }
|
|
175
|
-
/>
|
|
176
|
-
{ attributes.afterSuccessBehavior !== '' && (
|
|
177
|
-
<>
|
|
178
|
-
<TextControl
|
|
179
|
-
label={ __( 'Button Label', 'newspack-blocks' ) }
|
|
180
|
-
placeholder={ __( 'Continue browsing', 'newspack-blocks' ) }
|
|
181
|
-
value={ attributes.afterSuccessButtonLabel || '' }
|
|
182
|
-
onChange={ value => setAttributes( { afterSuccessButtonLabel: value } ) }
|
|
183
|
-
/>
|
|
184
|
-
{ attributes.afterSuccessBehavior === 'custom' && (
|
|
185
|
-
<TextControl
|
|
186
|
-
label={ __( 'Custom URL', 'newspack-blocks' ) }
|
|
187
|
-
placeholder={ __( 'https://example.com', 'newspack-blocks' ) }
|
|
188
|
-
value={ attributes.afterSuccessURL || '' }
|
|
189
|
-
onChange={ value => setAttributes( { afterSuccessURL: value } ) }
|
|
190
|
-
/>
|
|
191
|
-
) }
|
|
192
|
-
</>
|
|
193
|
-
) }
|
|
194
|
-
</>
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
157
|
function CheckoutButtonEdit( props ) {
|
|
199
158
|
const { attributes, setAttributes, className } = props;
|
|
200
159
|
const { placeholder, style, text, product, price, variation } = attributes;
|
|
@@ -90,6 +90,16 @@
|
|
|
90
90
|
"additionalFields": {
|
|
91
91
|
"type": "array",
|
|
92
92
|
"default": []
|
|
93
|
+
},
|
|
94
|
+
"afterSuccessBehavior": {
|
|
95
|
+
"type": "string"
|
|
96
|
+
},
|
|
97
|
+
"afterSuccessButtonLabel": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"default": "Continue browsing"
|
|
100
|
+
},
|
|
101
|
+
"afterSuccessURL": {
|
|
102
|
+
"type": "string"
|
|
93
103
|
}
|
|
94
104
|
},
|
|
95
105
|
"supports": {
|
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
LAYOUT_OPTIONS,
|
|
46
46
|
DISABLED_IN_TIERS_BASED_LAYOUT_TIER_INDEX,
|
|
47
47
|
} from '../consts';
|
|
48
|
+
import RedirectAfterSuccess from '../../../components/redirect-after-success';
|
|
48
49
|
|
|
49
50
|
const TIER_LABELS = [
|
|
50
51
|
__( 'Low-tier', 'newspack-blocks' ),
|
|
@@ -421,6 +422,9 @@ const Edit = ( { attributes, setAttributes, className }: EditProps ) => {
|
|
|
421
422
|
</p>
|
|
422
423
|
</PanelBody>
|
|
423
424
|
) }
|
|
425
|
+
<PanelBody title={ __( 'After purchase', 'newspack-blocks' ) }>
|
|
426
|
+
<RedirectAfterSuccess setAttributes={ setAttributes } attributes={ attributes } />
|
|
427
|
+
</PanelBody>
|
|
424
428
|
</InspectorControls>
|
|
425
429
|
</>
|
|
426
430
|
);
|
|
@@ -290,9 +290,11 @@ abstract class Newspack_Blocks_Donate_Renderer_Base {
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
/**
|
|
293
|
-
* Render hidden form
|
|
293
|
+
* Render hidden form inputs.
|
|
294
|
+
*
|
|
295
|
+
* @param array $attributes The block attributes.
|
|
294
296
|
*/
|
|
295
|
-
protected static function
|
|
297
|
+
protected static function render_hidden_form_inputs( $attributes ) {
|
|
296
298
|
ob_start();
|
|
297
299
|
/**
|
|
298
300
|
* Action to add custom fields before the form fields of the donation block.
|
|
@@ -302,6 +304,16 @@ abstract class Newspack_Blocks_Donate_Renderer_Base {
|
|
|
302
304
|
?>
|
|
303
305
|
<input type='hidden' name='newspack_donate' value='1' />
|
|
304
306
|
<?php
|
|
307
|
+
|
|
308
|
+
foreach ( [ [ 'afterSuccessBehavior', 'after_success_behavior' ], [ 'afterSuccessButtonLabel', 'after_success_button_label' ], [ 'afterSuccessURL', 'after_success_url' ] ] as $attribute ) {
|
|
309
|
+
$attribute_name = $attribute[0];
|
|
310
|
+
$param_name = $attribute[1];
|
|
311
|
+
$value = isset( $attributes[ $attribute_name ] ) ? $attributes[ $attribute_name ] : '';
|
|
312
|
+
?>
|
|
313
|
+
<input type='hidden' name='<?php echo esc_attr( $param_name ); ?>' value='<?php echo esc_attr( $value ); ?>' />
|
|
314
|
+
<?php
|
|
315
|
+
}
|
|
316
|
+
|
|
305
317
|
return ob_get_clean();
|
|
306
318
|
}
|
|
307
319
|
|
package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-frequency-based.php
CHANGED
|
@@ -105,7 +105,7 @@ class Newspack_Blocks_Donate_Renderer_Frequency_Based extends Newspack_Blocks_Do
|
|
|
105
105
|
id="<?php echo esc_html( $configuration['uid'] ); ?>"
|
|
106
106
|
>
|
|
107
107
|
<form data-streamlined-config="<?php echo esc_html( htmlspecialchars( wp_json_encode( $configuration['configuration_for_streamlined'] ), ENT_QUOTES, 'UTF-8' ) ); ?>">
|
|
108
|
-
<?php echo self::
|
|
108
|
+
<?php echo self::render_hidden_form_inputs( $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
109
109
|
<div class='wp-block-newspack-blocks-donate__options'>
|
|
110
110
|
<div class='wp-block-newspack-blocks-donate__frequencies frequencies'>
|
|
111
111
|
<?php foreach ( $configuration['frequencies'] as $frequency_slug => $frequency_name ) : ?>
|
|
@@ -154,7 +154,7 @@ class Newspack_Blocks_Donate_Renderer_Frequency_Based extends Newspack_Blocks_Do
|
|
|
154
154
|
id="<?php echo esc_html( $configuration['uid'] ); ?>"
|
|
155
155
|
>
|
|
156
156
|
<form data-streamlined-config="<?php echo esc_html( htmlspecialchars( wp_json_encode( $configuration['configuration_for_streamlined'] ), ENT_QUOTES, 'UTF-8' ) ); ?>">
|
|
157
|
-
<?php echo self::
|
|
157
|
+
<?php echo self::render_hidden_form_inputs( $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
158
158
|
<div class='wp-block-newspack-blocks-donate__options'>
|
|
159
159
|
<div class='wp-block-newspack-blocks-donate__frequencies frequencies'>
|
|
160
160
|
<?php foreach ( $configuration['frequencies'] as $frequency_slug => $frequency_name ) : ?>
|
|
@@ -150,7 +150,7 @@ class Newspack_Blocks_Donate_Renderer_Tiers_Based extends Newspack_Blocks_Donate
|
|
|
150
150
|
>
|
|
151
151
|
<form data-is-init-form <?php echo 'stripe' === $configuration['platform'] ? 'onsubmit="return false;"' : ''; ?>>
|
|
152
152
|
<div class="wpbnbd__tiers__view">
|
|
153
|
-
<?php echo self::
|
|
153
|
+
<?php echo self::render_hidden_form_inputs( $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
154
154
|
<input type="hidden" name="<?php echo esc_attr( self::FREQUENCY_PARAM ); ?>" value="<?php echo esc_attr( $intial_selected_frequency ); ?>">
|
|
155
155
|
<div class="wpbnbd__tiers">
|
|
156
156
|
<div class="wpbnbd__tiers__selection">
|
|
@@ -96,6 +96,10 @@ export type DonateBlockAttributes = OverridableConfiguration & {
|
|
|
96
96
|
tiersBasedOptions: [ TierBasedOptionValue, TierBasedOptionValue, TierBasedOptionValue ];
|
|
97
97
|
// Manual mode enables block-level overrides of the global Donate settings.
|
|
98
98
|
manual: boolean;
|
|
99
|
+
// Post-checkout button option.
|
|
100
|
+
afterSuccessBehavior: string;
|
|
101
|
+
afterSuccessButtonLabel: string;
|
|
102
|
+
afterSuccessURL: string;
|
|
99
103
|
// Legacy attributes.
|
|
100
104
|
suggestedAmounts?: [ number, number, number ];
|
|
101
105
|
suggestedAmountUntiered?: number;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { TextControl, SelectControl } from '@wordpress/components';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
attributes: {
|
|
9
|
+
afterSuccessBehavior: string;
|
|
10
|
+
afterSuccessButtonLabel: string;
|
|
11
|
+
afterSuccessURL: string;
|
|
12
|
+
};
|
|
13
|
+
setAttributes: ( attributes: Partial< Props[ 'attributes' ] > ) => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const RedirectAfterSuccess = ( { attributes, setAttributes }: Props ) => (
|
|
17
|
+
<>
|
|
18
|
+
<SelectControl
|
|
19
|
+
label={ __( 'Post-Checkout Button', 'newspack-blocks' ) }
|
|
20
|
+
help={ __(
|
|
21
|
+
'After a successful purchase, a button will be presented to finish the process.',
|
|
22
|
+
'newspack-blocks'
|
|
23
|
+
) }
|
|
24
|
+
value={ attributes.afterSuccessBehavior }
|
|
25
|
+
options={ [
|
|
26
|
+
{ label: __( 'Close the modal', 'newspack-blocks' ), value: '' },
|
|
27
|
+
{ label: __( 'Go to a custom URL', 'newspack-blocks' ), value: 'custom' },
|
|
28
|
+
{ label: __( 'Go to the previous page', 'newspack-blocks' ), value: 'referrer' },
|
|
29
|
+
] }
|
|
30
|
+
onChange={ ( value: string ) => {
|
|
31
|
+
setAttributes( { afterSuccessBehavior: value.toString() } );
|
|
32
|
+
} }
|
|
33
|
+
/>
|
|
34
|
+
<TextControl
|
|
35
|
+
label={ __( 'Button Label', 'newspack-blocks' ) }
|
|
36
|
+
value={ attributes.afterSuccessButtonLabel || '' }
|
|
37
|
+
onChange={ ( value: string ) => setAttributes( { afterSuccessButtonLabel: value } ) }
|
|
38
|
+
/>
|
|
39
|
+
{ attributes.afterSuccessBehavior === 'custom' && (
|
|
40
|
+
<TextControl
|
|
41
|
+
label={ __( 'Custom URL', 'newspack-blocks' ) }
|
|
42
|
+
placeholder={ __( 'https://example.com', 'newspack-blocks' ) }
|
|
43
|
+
value={ attributes.afterSuccessURL || '' }
|
|
44
|
+
onChange={ ( value: string ) => setAttributes( { afterSuccessURL: value } ) }
|
|
45
|
+
/>
|
|
46
|
+
) }
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export default RedirectAfterSuccess;
|
|
@@ -136,6 +136,23 @@ domReady( () => {
|
|
|
136
136
|
modal => modal.dataset.productId === formData.get( 'product_id' )
|
|
137
137
|
);
|
|
138
138
|
if ( variationModal ) {
|
|
139
|
+
// Fill in the after success variables in the variation modal.
|
|
140
|
+
variationModal
|
|
141
|
+
.querySelectorAll( 'form[target="newspack_modal_checkout"]' )
|
|
142
|
+
.forEach( singleVariationForm => {
|
|
143
|
+
[
|
|
144
|
+
'after_success_behavior',
|
|
145
|
+
'after_success_url',
|
|
146
|
+
'after_success_button_label',
|
|
147
|
+
].forEach( afterSuccessParam => {
|
|
148
|
+
const input = document.createElement( 'input' );
|
|
149
|
+
input.type = 'hidden';
|
|
150
|
+
input.name = afterSuccessParam;
|
|
151
|
+
input.value = formData.get( afterSuccessParam );
|
|
152
|
+
singleVariationForm.appendChild( input );
|
|
153
|
+
} );
|
|
154
|
+
} );
|
|
155
|
+
// Open the variations modal.
|
|
139
156
|
ev.preventDefault();
|
|
140
157
|
document.body.classList.add( 'newspack-modal-checkout-open' );
|
|
141
158
|
variationModal.style.display = 'block';
|