@automattic/newspack-blocks 4.5.8 → 4.5.9

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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [4.5.9](https://github.com/Automattic/newspack-blocks/compare/v4.5.8...v4.5.9) (2025-02-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add supported gateways check ([#2009](https://github.com/Automattic/newspack-blocks/issues/2009)) ([1462233](https://github.com/Automattic/newspack-blocks/commit/1462233821b4f41ef6b80f6929243dc1b805cdb1))
7
+ * return no posts for authors without term ([#2033](https://github.com/Automattic/newspack-blocks/issues/2033)) ([3b72633](https://github.com/Automattic/newspack-blocks/commit/3b7263349707326bf988ff6a815cf92ffb061972))
8
+
1
9
  ## [4.5.8](https://github.com/Automattic/newspack-blocks/compare/v4.5.7...v4.5.8) (2025-02-03)
2
10
 
3
11
 
package/composer.lock CHANGED
@@ -800,16 +800,16 @@
800
800
  },
801
801
  {
802
802
  "name": "phpcompatibility/phpcompatibility-wp",
803
- "version": "2.1.5",
803
+ "version": "2.1.6",
804
804
  "source": {
805
805
  "type": "git",
806
806
  "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git",
807
- "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082"
807
+ "reference": "80ccb1a7640995edf1b87a4409fa584cd5869469"
808
808
  },
809
809
  "dist": {
810
810
  "type": "zip",
811
- "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/01c1ff2704a58e46f0cb1ca9d06aee07b3589082",
812
- "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082",
811
+ "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/80ccb1a7640995edf1b87a4409fa584cd5869469",
812
+ "reference": "80ccb1a7640995edf1b87a4409fa584cd5869469",
813
813
  "shasum": ""
814
814
  },
815
815
  "require": {
@@ -866,7 +866,7 @@
866
866
  "type": "open_collective"
867
867
  }
868
868
  ],
869
- "time": "2024-04-24T21:37:59+00:00"
869
+ "time": "2025-01-16T22:34:19+00:00"
870
870
  },
871
871
  {
872
872
  "name": "phpcsstandards/phpcsextra",
@@ -1 +1 @@
1
- .newspack-ui iframe[name=newspack_modal_checkout_iframe]{border:none;height:calc(100% + var(--newspack-ui-spacer-9, 48px));margin:calc(var(--newspack-ui-spacer-5, 24px)*-1);max-width:unset;width:calc(100% + var(--newspack-ui-spacer-9, 48px))}.newspack-blocks__modal-container{align-items:center;display:flex;inset:0;justify-content:center;overflow:hidden;pointer-events:none;position:fixed;visibility:hidden;z-index:-1}.newspack-blocks__modal-container__overlay{background:rgba(0,0,0,.5);inset:0;opacity:0;position:absolute;transition:opacity .1s linear;z-index:1}.newspack-blocks__modal-container[data-state=open]{pointer-events:auto;visibility:visible;z-index:99999}.newspack-blocks__modal-container[data-state=open] .newspack-blocks__modal-container__overlay{opacity:1}.newspack-blocks__modal-container[data-state=open] .newspack-blocks__modal{opacity:1;transform:translateY(0)}.newspack-blocks__modal-container .newspack-blocks__modal{background:#fff;border-radius:6px;display:flex;flex-direction:column;justify-content:space-between;max-height:90%;max-width:600px;min-height:300px;opacity:0;overflow:auto;position:relative;transform:translateY(50px);transition:transform .1s linear,opacity .1s linear;width:100%;z-index:2}.newspack-blocks__modal-container .newspack-blocks__modal__header{align-items:center;border-bottom:1px solid #ddd;box-sizing:border-box;display:flex;height:64px;justify-content:space-between;padding:24px}.newspack-blocks__modal-container .newspack-blocks__modal__header h2{font-size:16px}.newspack-blocks__modal-container .newspack-blocks__modal__content{flex-grow:1;position:relative}.newspack-blocks__modal-container .newspack-blocks__modal__content>*{border:0;border-radius:6px;height:100%;width:100%}.newspack-blocks__modal-container .newspack-blocks__modal__close{background:transparent;border:0;color:#111;cursor:pointer;padding:8px}.newspack-blocks__modal-container .newspack-blocks__modal__close:focus,.newspack-blocks__modal-container .newspack-blocks__modal__close:hover{color:#767676}.newspack-blocks__modal-container .newspack-blocks__modal__close svg{display:block}.newspack-blocks__modal-container .newspack-blocks__spinner{align-items:center;background:#fff;border-radius:5px;bottom:0;display:flex;justify-content:center;position:absolute;top:0;width:calc(100% - 24px)}.newspack-blocks__modal-container .newspack-blocks__spinner>span{animation:spin 1s linear infinite;border:2px solid #fff;border-radius:50%;border-top-color:#767676;height:25px;margin-right:-12.5px;margin-top:-12.5px;width:25px}.newspack-blocks__modal-variation .newspack-blocks__selection>:first-child{margin-top:0}.newspack-blocks__modal-variation .newspack-blocks__selection h3{margin:0}.newspack-blocks__modal-variation .newspack-blocks__selection h3+p{margin-top:calc(var(--newspack-ui-spacer-base, 8px)/2)}.newspack-blocks__modal-variation .newspack-blocks__options{display:flex;flex-wrap:wrap;gap:var(--newspack-ui-spacer-2,12px);list-style:none;margin:var(--newspack-ui-spacer-5,24px) 0 0;padding:0}.newspack-blocks__modal-variation .newspack-blocks__options__item{border:1px solid var(--newspack-ui-color-border,#ddd);border-radius:var(--newspack-ui-border-radius-m,6px);display:flex;flex:1 1 100%;flex-direction:column;text-align:center}@media(min-width:600px){.newspack-blocks__modal-variation .newspack-blocks__options__item{flex:1 1 30%;max-width:calc(33.3333% - 10px)}.newspack-blocks__modal-variation .newspack-blocks__options__item:first-child:nth-last-child(2),.newspack-blocks__modal-variation .newspack-blocks__options__item:first-child:nth-last-child(2)~li{flex:1 1 40%;max-width:calc(50% - 10px)}}.newspack-blocks__modal-variation .newspack-blocks__options__item .summary{font-size:var(--newspack-ui-font-size-xs,14px);height:100%;line-height:var(--newspack-ui-line-height-xs,1.4286);padding:var(--newspack-ui-spacer-5,24px) var(--newspack-ui-spacer-2,12px);position:relative}.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price .suggested-prefix,.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price del{color:var(--newspack-ui-color-neutral-60,#6c6c6c);right:0;position:absolute;top:calc(var(--newspack-ui-spacer-base, 8px)*.75);width:100%}.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price>.amount>bdi,.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price>.suggested-text>.amount>bdi,.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price>ins>.amount>bdi{color:initial;display:block;font-size:var(--newspack-ui-font-size-xl,clamp(1.375rem,.394rem + 2.008vw,2rem));font-weight:600;line-height:var(--newspack-ui-line-height-xl,1.375)}.newspack-blocks__modal-variation .newspack-blocks__options__item .variation{border-top:1px solid var(--newspack-ui-color-border,#ddd);font-size:var(--newspack-ui-font-size-xs,14px);font-weight:600;line-height:var(--newspack-ui-line-height-xs,1.4286);margin-top:auto;padding:var(--newspack-ui-spacer-2,12px)}.newspack-blocks__modal-variation .newspack-blocks__options__item form{border-top:1px solid var(--newspack-ui-color-border,#ddd);padding:var(--newspack-ui-spacer-2,12px) var(--newspack-ui-spacer-2,12px) 0}.newspack-blocks__modal-variation .newspack-blocks__options__item form button{display:block;margin-top:0!important;width:100%}@keyframes spin{0%{transform:rotate(0deg)}50%{transform:rotate(-180deg)}to{transform:rotate(-1turn)}}.modal-processing{opacity:.5}
1
+ .newspack-ui iframe[name=newspack_modal_checkout_iframe]{border:none;height:calc(100% + var(--newspack-ui-spacer-9, 48px));margin:calc(var(--newspack-ui-spacer-5, 24px)*-1);max-width:unset;width:calc(100% + var(--newspack-ui-spacer-9, 48px))}.newspack-blocks__modal-container{align-items:center;display:flex;inset:0;justify-content:center;overflow:hidden;pointer-events:none;position:fixed;visibility:hidden;z-index:-1}.newspack-blocks__modal-container__overlay{background:rgba(0,0,0,.5);inset:0;opacity:0;position:absolute;transition:opacity .1s linear;z-index:1}.newspack-blocks__modal-container[data-state=open]{pointer-events:auto;visibility:visible;z-index:99999}.newspack-blocks__modal-container[data-state=open] .newspack-blocks__modal-container__overlay{opacity:1}.newspack-blocks__modal-container[data-state=open] .newspack-blocks__modal{opacity:1;transform:translateY(0)}.newspack-blocks__modal-container .newspack-blocks__modal{background:#fff;border-radius:6px;display:flex;flex-direction:column;justify-content:space-between;max-height:90%;max-width:600px;min-height:300px;opacity:0;overflow:auto;position:relative;transform:translateY(50px);transition:transform .1s linear,opacity .1s linear;width:100%;z-index:2}.newspack-blocks__modal-container .newspack-blocks__modal__header{align-items:center;border-bottom:1px solid #ddd;box-sizing:border-box;display:flex;height:64px;justify-content:space-between;padding:24px}.newspack-blocks__modal-container .newspack-blocks__modal__header h2{font-size:16px}.newspack-blocks__modal-container .newspack-blocks__modal__content{flex-grow:1;position:relative}.newspack-blocks__modal-container .newspack-blocks__modal__content>*{border:0;border-radius:6px;height:100%;width:100%}.newspack-blocks__modal-container .newspack-blocks__modal__close{background:transparent;border:0;color:#111;cursor:pointer;padding:8px}.newspack-blocks__modal-container .newspack-blocks__modal__close:focus,.newspack-blocks__modal-container .newspack-blocks__modal__close:hover{color:#767676}.newspack-blocks__modal-container .newspack-blocks__modal__close svg{display:block}.newspack-blocks__modal-container .newspack-blocks__spinner{align-items:center;background:#fff;border-radius:5px;bottom:0;display:flex;justify-content:center;position:absolute;top:0;width:calc(100% - 24px)}.newspack-blocks__modal-container .newspack-blocks__spinner>span{animation:spin 1s linear infinite;border:2px solid #fff;border-radius:50%;border-top-color:#767676;height:25px;margin-right:-12.5px;margin-top:-12.5px;width:25px}.newspack-blocks__modal-variation .newspack-blocks__selection>:first-child{margin-top:0}.newspack-blocks__modal-variation .newspack-blocks__selection h3{margin:0}.newspack-blocks__modal-variation .newspack-blocks__selection h3+p{margin-top:calc(var(--newspack-ui-spacer-base, 8px)/2)}.newspack-blocks__modal-variation .newspack-blocks__options{display:flex;flex-wrap:wrap;gap:var(--newspack-ui-spacer-2,12px);list-style:none;margin:var(--newspack-ui-spacer-5,24px) 0 0;padding:0}.newspack-blocks__modal-variation .newspack-blocks__options__item{border:1px solid var(--newspack-ui-color-border,#ddd);border-radius:var(--newspack-ui-border-radius-m,6px);display:flex;flex:1 1 100%;flex-direction:column;text-align:center}@media(min-width:600px){.newspack-blocks__modal-variation .newspack-blocks__options__item{flex:1 1 30%;max-width:calc(33.3333% - 10px)}.newspack-blocks__modal-variation .newspack-blocks__options__item:first-child:nth-last-child(2),.newspack-blocks__modal-variation .newspack-blocks__options__item:first-child:nth-last-child(2)~li{flex:1 1 40%;max-width:calc(50% - 10px)}}.newspack-blocks__modal-variation .newspack-blocks__options__item .summary{font-size:var(--newspack-ui-font-size-xs,14px);height:100%;line-height:var(--newspack-ui-line-height-xs,1.4286);padding:var(--newspack-ui-spacer-5,24px) var(--newspack-ui-spacer-2,12px);position:relative}.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price .suggested-prefix,.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price del{color:var(--newspack-ui-color-neutral-60,#6c6c6c);right:0;position:absolute;top:calc(var(--newspack-ui-spacer-base, 8px)*.75);width:100%}.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price>.amount>bdi,.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price>.suggested-text>.amount>bdi,.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price>ins>.amount>bdi{color:initial;display:block;font-size:var(--newspack-ui-font-size-xl,clamp(1.375rem,.394rem + 2.008vw,2rem));font-weight:600;line-height:var(--newspack-ui-line-height-xl,1.375)}.newspack-blocks__modal-variation .newspack-blocks__options__item .variation{border-top:1px solid var(--newspack-ui-color-border,#ddd);font-size:var(--newspack-ui-font-size-xs,14px);font-weight:600;line-height:var(--newspack-ui-line-height-xs,1.4286);margin-top:auto;padding:var(--newspack-ui-spacer-2,12px)}.newspack-blocks__modal-variation .newspack-blocks__options__item form{border-top:1px solid var(--newspack-ui-color-border,#ddd);padding:var(--newspack-ui-spacer-2,12px) var(--newspack-ui-spacer-2,12px) 0}.newspack-blocks__modal-variation .newspack-blocks__options__item form button{display:block;margin-top:0!important;width:100%}.non-modal-checkout-loading{position:relative}.non-modal-checkout-loading span{visibility:hidden}.non-modal-checkout-loading:before{animation:spin .9s linear infinite;border-color:currentcolor transparent transparent currentcolor;border-radius:50%;border-style:solid;border-width:1.5px;content:"";display:block;height:18px;inset:calc(50% - 9px) calc(50% - 9px) auto auto;position:absolute;width:18px}@keyframes spin{0%{transform:rotate(0deg)}50%{transform:rotate(-180deg)}to{transform:rotate(-1turn)}}.modal-processing{opacity:.5}
@@ -1 +1 @@
1
- <?php return array('dependencies' => array(), 'version' => 'e93a12fa2819716cd025');
1
+ <?php return array('dependencies' => array(), 'version' => '6202d84523d2b05ea8fc');
package/dist/modal.css CHANGED
@@ -1 +1 @@
1
- .newspack-ui iframe[name=newspack_modal_checkout_iframe]{border:none;height:calc(100% + var(--newspack-ui-spacer-9, 48px));margin:calc(var(--newspack-ui-spacer-5, 24px)*-1);max-width:unset;width:calc(100% + var(--newspack-ui-spacer-9, 48px))}.newspack-blocks__modal-container{align-items:center;display:flex;inset:0;justify-content:center;overflow:hidden;pointer-events:none;position:fixed;visibility:hidden;z-index:-1}.newspack-blocks__modal-container__overlay{background:rgba(0,0,0,.5);inset:0;opacity:0;position:absolute;transition:opacity .1s linear;z-index:1}.newspack-blocks__modal-container[data-state=open]{pointer-events:auto;visibility:visible;z-index:99999}.newspack-blocks__modal-container[data-state=open] .newspack-blocks__modal-container__overlay{opacity:1}.newspack-blocks__modal-container[data-state=open] .newspack-blocks__modal{opacity:1;transform:translateY(0)}.newspack-blocks__modal-container .newspack-blocks__modal{background:#fff;border-radius:6px;display:flex;flex-direction:column;justify-content:space-between;max-height:90%;max-width:600px;min-height:300px;opacity:0;overflow:auto;position:relative;transform:translateY(50px);transition:transform .1s linear,opacity .1s linear;width:100%;z-index:2}.newspack-blocks__modal-container .newspack-blocks__modal__header{align-items:center;border-bottom:1px solid #ddd;box-sizing:border-box;display:flex;height:64px;justify-content:space-between;padding:24px}.newspack-blocks__modal-container .newspack-blocks__modal__header h2{font-size:16px}.newspack-blocks__modal-container .newspack-blocks__modal__content{flex-grow:1;position:relative}.newspack-blocks__modal-container .newspack-blocks__modal__content>*{border:0;border-radius:6px;height:100%;width:100%}.newspack-blocks__modal-container .newspack-blocks__modal__close{background:transparent;border:0;color:#111;cursor:pointer;padding:8px}.newspack-blocks__modal-container .newspack-blocks__modal__close:focus,.newspack-blocks__modal-container .newspack-blocks__modal__close:hover{color:#767676}.newspack-blocks__modal-container .newspack-blocks__modal__close svg{display:block}.newspack-blocks__modal-container .newspack-blocks__spinner{align-items:center;background:#fff;border-radius:5px;bottom:0;display:flex;justify-content:center;position:absolute;top:0;width:calc(100% - 24px)}.newspack-blocks__modal-container .newspack-blocks__spinner>span{animation:spin 1s linear infinite;border:2px solid #fff;border-radius:50%;border-top-color:#767676;height:25px;margin-left:-12.5px;margin-top:-12.5px;width:25px}.newspack-blocks__modal-variation .newspack-blocks__selection>:first-child{margin-top:0}.newspack-blocks__modal-variation .newspack-blocks__selection h3{margin:0}.newspack-blocks__modal-variation .newspack-blocks__selection h3+p{margin-top:calc(var(--newspack-ui-spacer-base, 8px)/2)}.newspack-blocks__modal-variation .newspack-blocks__options{display:flex;flex-wrap:wrap;gap:var(--newspack-ui-spacer-2,12px);list-style:none;margin:var(--newspack-ui-spacer-5,24px) 0 0;padding:0}.newspack-blocks__modal-variation .newspack-blocks__options__item{border:1px solid var(--newspack-ui-color-border,#ddd);border-radius:var(--newspack-ui-border-radius-m,6px);display:flex;flex:1 1 100%;flex-direction:column;text-align:center}@media(min-width:600px){.newspack-blocks__modal-variation .newspack-blocks__options__item{flex:1 1 30%;max-width:calc(33.3333% - 10px)}.newspack-blocks__modal-variation .newspack-blocks__options__item:first-child:nth-last-child(2),.newspack-blocks__modal-variation .newspack-blocks__options__item:first-child:nth-last-child(2)~li{flex:1 1 40%;max-width:calc(50% - 10px)}}.newspack-blocks__modal-variation .newspack-blocks__options__item .summary{font-size:var(--newspack-ui-font-size-xs,14px);height:100%;line-height:var(--newspack-ui-line-height-xs,1.4286);padding:var(--newspack-ui-spacer-5,24px) var(--newspack-ui-spacer-2,12px);position:relative}.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price .suggested-prefix,.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price del{color:var(--newspack-ui-color-neutral-60,#6c6c6c);left:0;position:absolute;top:calc(var(--newspack-ui-spacer-base, 8px)*.75);width:100%}.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price>.amount>bdi,.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price>.suggested-text>.amount>bdi,.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price>ins>.amount>bdi{color:initial;display:block;font-size:var(--newspack-ui-font-size-xl,clamp(1.375rem,.394rem + 2.008vw,2rem));font-weight:600;line-height:var(--newspack-ui-line-height-xl,1.375)}.newspack-blocks__modal-variation .newspack-blocks__options__item .variation{border-top:1px solid var(--newspack-ui-color-border,#ddd);font-size:var(--newspack-ui-font-size-xs,14px);font-weight:600;line-height:var(--newspack-ui-line-height-xs,1.4286);margin-top:auto;padding:var(--newspack-ui-spacer-2,12px)}.newspack-blocks__modal-variation .newspack-blocks__options__item form{border-top:1px solid var(--newspack-ui-color-border,#ddd);padding:var(--newspack-ui-spacer-2,12px) var(--newspack-ui-spacer-2,12px) 0}.newspack-blocks__modal-variation .newspack-blocks__options__item form button{display:block;margin-top:0!important;width:100%}@keyframes spin{0%{transform:rotate(0deg)}50%{transform:rotate(180deg)}to{transform:rotate(1turn)}}.modal-processing{opacity:.5}
1
+ .newspack-ui iframe[name=newspack_modal_checkout_iframe]{border:none;height:calc(100% + var(--newspack-ui-spacer-9, 48px));margin:calc(var(--newspack-ui-spacer-5, 24px)*-1);max-width:unset;width:calc(100% + var(--newspack-ui-spacer-9, 48px))}.newspack-blocks__modal-container{align-items:center;display:flex;inset:0;justify-content:center;overflow:hidden;pointer-events:none;position:fixed;visibility:hidden;z-index:-1}.newspack-blocks__modal-container__overlay{background:rgba(0,0,0,.5);inset:0;opacity:0;position:absolute;transition:opacity .1s linear;z-index:1}.newspack-blocks__modal-container[data-state=open]{pointer-events:auto;visibility:visible;z-index:99999}.newspack-blocks__modal-container[data-state=open] .newspack-blocks__modal-container__overlay{opacity:1}.newspack-blocks__modal-container[data-state=open] .newspack-blocks__modal{opacity:1;transform:translateY(0)}.newspack-blocks__modal-container .newspack-blocks__modal{background:#fff;border-radius:6px;display:flex;flex-direction:column;justify-content:space-between;max-height:90%;max-width:600px;min-height:300px;opacity:0;overflow:auto;position:relative;transform:translateY(50px);transition:transform .1s linear,opacity .1s linear;width:100%;z-index:2}.newspack-blocks__modal-container .newspack-blocks__modal__header{align-items:center;border-bottom:1px solid #ddd;box-sizing:border-box;display:flex;height:64px;justify-content:space-between;padding:24px}.newspack-blocks__modal-container .newspack-blocks__modal__header h2{font-size:16px}.newspack-blocks__modal-container .newspack-blocks__modal__content{flex-grow:1;position:relative}.newspack-blocks__modal-container .newspack-blocks__modal__content>*{border:0;border-radius:6px;height:100%;width:100%}.newspack-blocks__modal-container .newspack-blocks__modal__close{background:transparent;border:0;color:#111;cursor:pointer;padding:8px}.newspack-blocks__modal-container .newspack-blocks__modal__close:focus,.newspack-blocks__modal-container .newspack-blocks__modal__close:hover{color:#767676}.newspack-blocks__modal-container .newspack-blocks__modal__close svg{display:block}.newspack-blocks__modal-container .newspack-blocks__spinner{align-items:center;background:#fff;border-radius:5px;bottom:0;display:flex;justify-content:center;position:absolute;top:0;width:calc(100% - 24px)}.newspack-blocks__modal-container .newspack-blocks__spinner>span{animation:spin 1s linear infinite;border:2px solid #fff;border-radius:50%;border-top-color:#767676;height:25px;margin-left:-12.5px;margin-top:-12.5px;width:25px}.newspack-blocks__modal-variation .newspack-blocks__selection>:first-child{margin-top:0}.newspack-blocks__modal-variation .newspack-blocks__selection h3{margin:0}.newspack-blocks__modal-variation .newspack-blocks__selection h3+p{margin-top:calc(var(--newspack-ui-spacer-base, 8px)/2)}.newspack-blocks__modal-variation .newspack-blocks__options{display:flex;flex-wrap:wrap;gap:var(--newspack-ui-spacer-2,12px);list-style:none;margin:var(--newspack-ui-spacer-5,24px) 0 0;padding:0}.newspack-blocks__modal-variation .newspack-blocks__options__item{border:1px solid var(--newspack-ui-color-border,#ddd);border-radius:var(--newspack-ui-border-radius-m,6px);display:flex;flex:1 1 100%;flex-direction:column;text-align:center}@media(min-width:600px){.newspack-blocks__modal-variation .newspack-blocks__options__item{flex:1 1 30%;max-width:calc(33.3333% - 10px)}.newspack-blocks__modal-variation .newspack-blocks__options__item:first-child:nth-last-child(2),.newspack-blocks__modal-variation .newspack-blocks__options__item:first-child:nth-last-child(2)~li{flex:1 1 40%;max-width:calc(50% - 10px)}}.newspack-blocks__modal-variation .newspack-blocks__options__item .summary{font-size:var(--newspack-ui-font-size-xs,14px);height:100%;line-height:var(--newspack-ui-line-height-xs,1.4286);padding:var(--newspack-ui-spacer-5,24px) var(--newspack-ui-spacer-2,12px);position:relative}.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price .suggested-prefix,.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price del{color:var(--newspack-ui-color-neutral-60,#6c6c6c);left:0;position:absolute;top:calc(var(--newspack-ui-spacer-base, 8px)*.75);width:100%}.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price>.amount>bdi,.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price>.suggested-text>.amount>bdi,.newspack-blocks__modal-variation .newspack-blocks__options__item .summary .price>ins>.amount>bdi{color:initial;display:block;font-size:var(--newspack-ui-font-size-xl,clamp(1.375rem,.394rem + 2.008vw,2rem));font-weight:600;line-height:var(--newspack-ui-line-height-xl,1.375)}.newspack-blocks__modal-variation .newspack-blocks__options__item .variation{border-top:1px solid var(--newspack-ui-color-border,#ddd);font-size:var(--newspack-ui-font-size-xs,14px);font-weight:600;line-height:var(--newspack-ui-line-height-xs,1.4286);margin-top:auto;padding:var(--newspack-ui-spacer-2,12px)}.newspack-blocks__modal-variation .newspack-blocks__options__item form{border-top:1px solid var(--newspack-ui-color-border,#ddd);padding:var(--newspack-ui-spacer-2,12px) var(--newspack-ui-spacer-2,12px) 0}.newspack-blocks__modal-variation .newspack-blocks__options__item form button{display:block;margin-top:0!important;width:100%}.non-modal-checkout-loading{position:relative}.non-modal-checkout-loading span{visibility:hidden}.non-modal-checkout-loading:before{animation:spin .9s linear infinite;border-color:currentcolor currentcolor transparent transparent;border-radius:50%;border-style:solid;border-width:1.5px;content:"";display:block;height:18px;inset:calc(50% - 9px) calc(50% - 9px) auto auto;position:absolute;width:18px}@keyframes spin{0%{transform:rotate(0deg)}50%{transform:rotate(180deg)}to{transform:rotate(1turn)}}.modal-processing{opacity:.5}
package/dist/modal.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";function e(e,t=!1){const n=e.querySelectorAll('button, [href], input:not([type="hidden"]), select, textarea, [tabindex]:not([tabindex="-1"])');if(0===n.length)return!1;const o=n?.[0];let c;o.focus(),t?(document.addEventListener("keydown",(function(e){if(("Tab"===e.key||9===e.keyCode)&&e.shiftKey&&document.activeElement===o){const n=t.contentWindow.document,o=n.getElementById("customer_details"),a=n.getElementById("after_customer_details"),r=n.getElementById("checkout-after-success");null!==r?c=r:null!==o.offsetParent?c=n.getElementById("checkout_continue"):null!==a.offsetParent&&(c=n.getElementById("checkout_back")),c.focus(),e.preventDefault()}})),document.getElementById("newspack-a11y-last-element").addEventListener("focus",(()=>{o.focus()}))):(c=n[n.length-1],document.addEventListener("keydown",(function(e){("Tab"===e.key||9===e.keyCode)&&(e.shiftKey?document.activeElement===o&&(c.focus(),e.preventDefault()):document.activeElement===c&&(o.focus(),e.preventDefault()))})))}const t=(e,t={})=>({...t,action:e}),n=(e,t="np_modal_checkout_interaction")=>{"function"==typeof window.gtag&&e&&window.gtag("event",t,e)},o=e=>{if("function"!=typeof window.gtag)return;let o="opened";const{action_type:c,amount:a="",currency:r,is_variable:i="",price:s="",product_id:l,product_type:d,recurrence:u,referrer:p,variation_id:_=""}=e,m={action_type:c,currency:r,product_id:l,product_type:d,referrer:p};(a||s)&&(m.amount=a||s),i&&(m.is_variable=i),_&&(m.variation_id=_),u&&(m.recurrence=u),i&&!_&&(o="opened_variations");const y=t(o,m);n(y)},c=e=>{if("function"!=typeof window.gtag)return;e=e||(e=>{const t=document.getElementById("newspack_modal_checkout"),n=!!t&&t.getAttribute("data-order-details");return!!n&&JSON.parse(n)||{}})();const{action_type:o,amount:c="",currency:a,price:r="",product_id:i,product_type:s,recurrence:l,referrer:d,variation_id:u=""}=e,p={action_type:o,currency:a,product_id:i,product_type:s,recurrence:l,referrer:d};(c||r)&&(p.amount=c||r),u&&(p.variation_id=u);const _=t("dismissed",p);n(_)};function a(e,t=null){const n=document.createElement("input");return n.type="hidden",n.name=e,t&&(n.value=t),n}const r=newspackBlocksModal.newspack_class_prefix,i="newspack_modal_checkout_iframe",s="newspack_modal_checkout_container",l=`${r}__modal`,d="newspack-blocks__modal-variation";let u={},p=!1;var _;_=()=>{const t=document.querySelector("#newspack_modal_checkout");if(!t)return;const n=t.querySelector(`.${l}__content`),_=a("modal_checkout","1"),m=n.querySelector(`.${r}__spinner`);let y=document.querySelector(".newspack-reader__account-link")?.[0];const f="600px",h=document.createElement("iframe");function k(){const n=h.contentWindow?.location;if(window.newspackReaderActivation&&n?.href?.includes("order-received")){const e=window.newspackReaderActivation,t=new Proxy(new URLSearchParams(n.search),{get:(e,t)=>e.get(t)});t.email&&(e.setReaderEmail(t.email),e.setAuthenticated(!0))}const o=h?.contentDocument?.querySelector(`#${s}`),c=()=>{g.observe(o),"none"!==m.style.display&&(m.style.display="none"),"visible"!==h.style.visibility&&(h.style.visibility="visible"),h._ready=!0};o&&(o.checkoutComplete?($("small"),A(newspackBlocksModal.labels.thankyou_modal_title),c(),e(t.querySelector(`.${l}`))):($(),A(newspackBlocksModal.labels.checkout_modal_title),h.contentWindow?.newspackBlocksModalCheckout?.checkout_nonce&&(t.checkout_nonce=h.contentWindow.newspackBlocksModalCheckout.checkout_nonce)),o.checkoutReady?c():o.addEventListener("checkout-ready",c))}h.name=i,h.style.height=f,h.style.visibility="hidden",h.addEventListener("load",k);const w=t=>{const n=t.target;n.classList.add("modal-processing");const s=n.dataset.product;if(s){const e=JSON.parse(s);Object.keys(e).forEach((t=>{0===n.querySelectorAll('input[name="'+t+'"]').length&&n.appendChild(a(t,e[t]))}))}const l=new FormData(n);l.get("variation_id")||(y=t.submitter);const _=document.querySelectorAll(`.${d}`);if(_.forEach((e=>{E(e)})),l.get("is_variable")&&!l.get("variation_id")){const c=[..._].find((e=>e.dataset.productId===l.get("product_id")));if(c){c.querySelectorAll(`form[target="${i}"]`).forEach((e=>{["after_success_behavior","after_success_url","after_success_button_label"].forEach((t=>{0===e.querySelectorAll('input[name="'+t+'"]').length&&e.appendChild(a(t,l.get(t)))}));const t=e.dataset.product;if(t){const n=JSON.parse(t);Object.keys(n).forEach((t=>{0===e.querySelectorAll('input[name="'+t+'"]').length&&e.appendChild(a(t,n[t]))}))}})),t.preventDefault(),n.classList.remove("modal-processing"),q(c),e(c,!1);const r=n.getAttribute("data-product");return u=r?JSON.parse(r):{},p||o(u),void document.getElementById("newspack_modal_checkout").setAttribute("data-order-details",JSON.stringify(u))}}n.classList.remove("modal-processing");const m=l.get("newspack_donate"),f=l.get("newspack_checkout");if(f){const e=n.getAttribute("data-product");u=e?JSON.parse(e):{}}else if(m){const e=l.get("donation_frequency");let t="",n="";for(const n of l.keys())n.indexOf("donation_value_"+e)>=0&&"other"!==l.get(n)&&""!==l.get(n)&&(t=l.get(n));const o=JSON.parse(l.get("frequency_ids"));for(const t in o)t===e&&(n=o[t].toString());u={amount:t,action_type:"donation",currency:l.get("donation_currency"),product_id:n,product_type:"donation",recurrence:e,referrer:l.get("_wp_http_referer")}}if(p||o(u),p=!0,"undefined"!=typeof newspack_ras_config&&!newspack_ras_config?.is_logged_in&&!window?.newspackReaderActivation?.getReader?.()?.authenticated&&newspackBlocksModal?.is_registration_required&&window?.newspackReaderActivation?.openAuthModal){t.preventDefault();let e="",o="0",a="";if(m){const e=l.get("donation_frequency"),t=n.querySelectorAll(`.donation-tier__${e}, .donation-frequency__${e}`);if(t?.length){const c=l.get("donation_tier_index");if(c){const n=JSON.parse(t?.[c].dataset.product);n.hasOwnProperty(`donation_price_summary_${e}`)&&(a=n[`donation_price_summary_${e}`])}else{const c=n.querySelectorAll(`input[name="donation_value_${e}"], input[name="donation_value_${e}_untiered"]`);c?.length&&(c.forEach((e=>{e.checked&&"other"!==e.value&&(o=e.value)})),t.forEach((t=>{const n=JSON.parse(t.dataset.product);if(n.hasOwnProperty(`donation_price_summary_${e}`)){const t=n[`donation_price_summary_${e}`];new RegExp(`(?<=\\D)${o}(?=\\D)`).test(t)&&(a=t)}if("0"===o&&a){let t=l.get(`donation_value_${e}_other`);t||(t=l.get(`donation_value_${e}_untiered`)),t&&(a=a.replace("0",t))}})))}}}else if(f){const e=n.querySelector('input[name="product_price_summary"]');e&&(a=e.value)}a&&(e=`<div class="order-details-summary ${r}__box ${r}__box--text-center"><p><strong>${a}</strong></p></div>`);const i=(e=>new Promise(((t,n)=>{const o=new URLSearchParams(e);o.append("action","modal_checkout_request"),fetch(newspackBlocksModal.ajax_url+"?"+o.toString()).then((e=>{e.ok||n(e),e.json().then((e=>{t(e.url)})).catch(n)})).catch(n)})))(l);i.then((e=>{window.newspackReaderActivation?.setPendingCheckout?.(e)})),window.newspackReaderActivation.openAuthModal({title:newspackBlocksModal.labels.auth_modal_title,onSuccess:(e,t)=>{i.then((e=>{t?.registered&&(e+=`&${newspackBlocksModal.checkout_registration_flag}=1`);const n=v(e);L(n)})).catch((e=>{console.warn("Unable to generate cart:",e),b()}))},onError:()=>{b()},onDismiss:()=>{c(u),p=!1,document.getElementById("newspack_modal_checkout").removeAttribute("data-order-details")},skipSuccess:!0,skipNewslettersSignup:!0,labels:{signin:{title:newspackBlocksModal.labels.signin_modal_title},register:{title:newspackBlocksModal.labels.register_modal_title}},content:e,trigger:t.submitter})}else S(),document.getElementById("newspack_modal_checkout").setAttribute("data-order-details",JSON.stringify(u))},v=e=>{const t=document.createElement("form");t.method="POST",t.action=e,t.target=i,t.style.display="none";const n=document.createElement("button");return n.setAttribute("type","submit"),t.appendChild(n),document.body.appendChild(t),t.addEventListener("submit",w),t},g=new ResizeObserver((e=>{if(!e||!e.length)return;if(h.scrollIntoView({behavior:"smooth",block:"start"}),!h.contentDocument)return;const t=e[0].contentRect;if(t){const e=t.top+t.bottom;if(0===e)return void(h.style.visibility="hidden");n.style.height=e+"px",h.style.height=e+"px"}})),b=()=>{const e=h?.contentDocument?.querySelector(`#${s}`),o=e?.querySelector('input[name="after_success_url"]'),a=e?.querySelector('input[name="after_success_behavior"]'),r=document?.querySelector(".newspack-newsletters-signup-modal");e?.checkoutComplete||(()=>{const e=new FormData;e.append("modal_checkout","1"),e.append("action","abandon_modal_checkout"),e.append("_wpnonce",t.checkout_nonce),t.checkout_nonce=null,fetch(newspackBlocksModal.ajax_url,{method:"POST",body:e})})();const i=!(h.contentDocument&&o&&a&&e?.checkoutComplete);if((i||r)&&(m.style.display="flex",h&&n.contains(h)&&(h._ready=!1,h.src="about:blank",h.style.height=f,h.style.visibility="hidden",n.style.height=f,n.removeChild(h)),g&&g.disconnect(),document.querySelectorAll(`.${l}-container`).forEach((e=>E(e))),y&&y.focus()),e?.checkoutComplete){const e=()=>{if(o&&a){const e=o.getAttribute("value"),t=a.getAttribute("value");"custom"===t?window.location.href=e:"referrer"===t&&window.history.back()}window?.newspackReaderActivation?.setPendingCheckout?.(),p=!1};window?.newspackReaderActivation?.openNewslettersSignupModal?window.newspackReaderActivation.openNewslettersSignupModal({onSuccess:e,onError:e,closeOnSuccess:i}):e(),i&&($(),A(newspackBlocksModal.labels.checkout_modal_title))}else window?.newspackReaderActivation?.setPendingCheckout?.(),c(),p=!1,document.getElementById("newspack_modal_checkout").removeAttribute("data-order-details")},S=()=>{m.style.display="flex",q(t),n.appendChild(h),t.addEventListener("click",(e=>{e.target===t&&b()})),e(t,h),function(e){h._readyTimer&&clearTimeout(h._readyTimer);let t=!1;function n(){t||(t=!0,clearTimeout(h._readyTimer),e.call(this))}function o(){"complete"===this.readyState&&n.call(this)}!function e(){if(h._ready)return void clearTimeout(h._readyTimer);const t=h.contentDocument||h.contentWindow?.document;t&&0!==t.URL.indexOf("about:")?"complete"===t?.readyState?n.call(t):(t.addEventListener("DOMContentLoaded",n),t.addEventListener("readystatechange",o)):h._readyTimer=setTimeout(e,10)}()}(k)},E=e=>{e.overlayId&&window.newspackReaderActivation?.overlays&&window.newspackReaderActivation?.overlays.remove(e.overlayId),e.setAttribute("data-state","closed"),document.body.style.overflow="auto"},q=e=>{window.newspackReaderActivation?.overlays&&(t.overlayId=window.newspackReaderActivation?.overlays.add()),e.setAttribute("data-state","open"),document.body.style.overflow="hidden"},A=e=>{const n=t.querySelector(`.${l}__header h2`);n&&(n.innerText=e)},$=(e="default")=>{const n=t.querySelector(`.${l}`);n&&("small"===e?n.classList.add(`${l}--small`):n.classList.remove(`${l}--small`))};window.newspackCloseModalCheckout=b,t.querySelectorAll(`.${l}__close`).forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault(),b()}))})),document.querySelectorAll(".newspack-blocks__modal-variation").forEach((e=>{e.addEventListener("click",(t=>{t.target===e&&b()})),e.querySelectorAll(`.${l}__close`).forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault(),b()}))}))})),document.addEventListener("keydown",(function(e){"Escape"===e.key&&b()})),document.querySelectorAll(".wpbnbd.wpbnbd--platform-wc, .wp-block-newspack-blocks-checkout-button, .newspack-blocks__modal-variation").forEach((e=>{e.querySelectorAll("form").forEach((e=>{e.appendChild(_.cloneNode()),e.target=i,e.addEventListener("submit",w)}))}));const L=e=>{e.requestSubmit(e.querySelector('button[type="submit"]'))};(()=>{const e=new URLSearchParams(window.location.search);if(!e.has("checkout"))return;const t=e.get("type");if("donate"===t){const t=e.get("layout"),n=e.get("frequency"),o=e.get("amount"),c=e.get("other");t&&n&&o&&((e,t,n,o=null)=>{let c;document.querySelectorAll(".wpbnbd.wpbnbd--platform-wc form").forEach((a=>{const r=a.querySelector(`input[name="donation_frequency"][value="${t}"]`);if(r)if("tiered"===e){const e=document.querySelector(`button[data-frequency-slug="${t}"]`);if(!e)return;e.click();const o=a.querySelector(`button[type="submit"][name="donation_value_${t}"][value="${n}"]`);if(!o)return;o.click()}else{const i="untiered"===e?a.querySelector(`input[name="donation_value_${t}_untiered"]`):a.querySelector(`input[name="donation_value_${t}"][value="${n}"]`);if(r&&i){if(r.checked=!0,"untiered"===e)i.value=n;else if("other"===n){i.click();const e=a.querySelector(`input[name="donation_value_${t}_other"]`);e&&o&&(e.value=o)}else i.checked=!0;c=a}}})),c&&L(c)})(t,n,o,c)}else if("checkout_button"===t){const t=e.get("product_id"),n=e.get("variation_id");t&&((e,t=null)=>{let n;if(t&&t!==e){const o=[...document.querySelectorAll(`.${d}`)].find((t=>t.dataset.productId===e));o&&o.querySelectorAll(`form[target="${i}"]`).forEach((e=>{const o=JSON.parse(e.dataset.product);o?.variation_id===Number(t)&&(n=e)}))}else document.querySelectorAll(".wp-block-newspack-blocks-checkout-button").forEach((t=>{const o=t.querySelector("form");if(!o)return;const c=JSON.parse(o.dataset.product);c?.product_id===e&&(n=o)}));n&&L(n)})(t,n)}else{const e=window.newspackReaderActivation?.getPendingCheckout?.();if(e){const t=v(e);L(t)}}window.history.replaceState(null,null,window.location.pathname)})()},"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",_):_())})();
1
+ (()=>{"use strict";function e(e,t=!1){const n=e.querySelectorAll('button, [href], input:not([type="hidden"]), select, textarea, [tabindex]:not([tabindex="-1"])');if(0===n.length)return!1;const o=n?.[0];let c;o.focus(),t?(document.addEventListener("keydown",(function(e){if(("Tab"===e.key||9===e.keyCode)&&e.shiftKey&&document.activeElement===o){const n=t.contentWindow.document,o=n.getElementById("customer_details"),a=n.getElementById("after_customer_details"),r=n.getElementById("checkout-after-success");null!==r?c=r:null!==o.offsetParent?c=n.getElementById("checkout_continue"):null!==a.offsetParent&&(c=n.getElementById("checkout_back")),c.focus(),e.preventDefault()}})),document.getElementById("newspack-a11y-last-element").addEventListener("focus",(()=>{o.focus()}))):(c=n[n.length-1],document.addEventListener("keydown",(function(e){("Tab"===e.key||9===e.keyCode)&&(e.shiftKey?document.activeElement===o&&(c.focus(),e.preventDefault()):document.activeElement===c&&(o.focus(),e.preventDefault()))})))}const t=(e,t={})=>({...t,action:e}),n=(e,t="np_modal_checkout_interaction")=>{"function"==typeof window.gtag&&e&&window.gtag("event",t,e)},o=e=>{if("function"!=typeof window.gtag)return;let o="opened";const{action_type:c,amount:a="",currency:r,is_variable:i="",price:s="",product_id:l,product_type:d,recurrence:u,referrer:p,variation_id:_=""}=e,m={action_type:c,currency:r,product_id:l,product_type:d,referrer:p};(a||s)&&(m.amount=a||s),i&&(m.is_variable=i),_&&(m.variation_id=_),u&&(m.recurrence=u),i&&!_&&(o="opened_variations");const y=t(o,m);n(y)},c=e=>{if("function"!=typeof window.gtag)return;e=e||(e=>{const t=document.getElementById("newspack_modal_checkout"),n=!!t&&t.getAttribute("data-order-details");return!!n&&JSON.parse(n)||{}})();const{action_type:o,amount:c="",currency:a,price:r="",product_id:i,product_type:s,recurrence:l,referrer:d,variation_id:u=""}=e,p={action_type:o,currency:a,product_id:i,product_type:s,recurrence:l,referrer:d};(c||r)&&(p.amount=c||r),u&&(p.variation_id=u);const _=t("dismissed",p);n(_)};function a(e,t=null){const n=document.createElement("input");return n.type="hidden",n.name=e,t&&(n.value=t),n}const r=newspackBlocksModal.newspack_class_prefix,i="newspack_modal_checkout_iframe",s="newspack_modal_checkout_container",l=`${r}__modal`,d="newspack-blocks__modal-variation";let u={},p=!1;const _=e=>{e.overlayId&&window.newspackReaderActivation?.overlays&&window.newspackReaderActivation?.overlays.remove(e.overlayId),e.setAttribute("data-state","closed"),document.body.style.overflow="auto"};var m;window.onpageshow=e=>{e.persisted&&(document.querySelectorAll(".modal-processing").forEach((e=>e.classList.remove("modal-processing"))),document.querySelectorAll(".non-modal-checkout-loading").forEach((e=>e.classList.remove("non-modal-checkout-loading"))),document.querySelectorAll(`.${l}-container`).forEach((e=>_(e))))},m=()=>{const t=document.querySelector("#newspack_modal_checkout");if(!t)return;const n=t.querySelector(`.${l}__content`),m=a("modal_checkout","1"),y=n.querySelector(`.${r}__spinner`);let f=document.querySelector(".newspack-reader__account-link")?.[0];const h="600px",k=document.createElement("iframe");function w(){const n=k.contentWindow?.location;if(window.newspackReaderActivation&&n?.href?.includes("order-received")){const e=window.newspackReaderActivation,t=new Proxy(new URLSearchParams(n.search),{get:(e,t)=>e.get(t)});t.email&&(e.setReaderEmail(t.email),e.setAuthenticated(!0))}const o=k?.contentDocument?.querySelector(`#${s}`),c=()=>{E.observe(o),"none"!==y.style.display&&(y.style.display="none"),"visible"!==k.style.visibility&&(k.style.visibility="visible"),k._ready=!0};o&&(o.checkoutComplete?(B("small"),L(newspackBlocksModal.labels.thankyou_modal_title),c(),e(t.querySelector(`.${l}`))):(B(),L(newspackBlocksModal.labels.checkout_modal_title),k.contentWindow?.newspackBlocksModalCheckout?.checkout_nonce&&(t.checkout_nonce=k.contentWindow.newspackBlocksModalCheckout.checkout_nonce)),o.checkoutReady?c():o.addEventListener("checkout-ready",c))}k.name=i,k.style.height=h,k.style.visibility="hidden",k.addEventListener("load",w);const g=e=>new Promise(((t,n)=>{const o=new URLSearchParams(e);o.append("action","modal_checkout_request"),fetch(newspackBlocksModal.ajax_url+"?"+o.toString()).then((e=>{e.ok||n(e),e.json().then((e=>{t(e.url)})).catch(n)})).catch(n)})),v=()=>"undefined"!=typeof newspack_ras_config&&!newspack_ras_config?.is_logged_in&&!window?.newspackReaderActivation?.getReader?.()?.authenticated&&newspackBlocksModal?.is_registration_required&&window?.newspackReaderActivation?.openAuthModal,b=t=>{const n=!newspackBlocksModal.has_unsupported_payment_gateway;n||t.preventDefault();const s=t.target;s.classList.add("modal-processing");const l=s.dataset.product;if(l){const e=JSON.parse(l);Object.keys(e).forEach((t=>{0===s.querySelectorAll('input[name="'+t+'"]').length&&s.appendChild(a(t,e[t]))}))}const m=new FormData(s);m.get("variation_id")||(f=t.submitter);const y=document.querySelectorAll(`.${d}`);if(y.forEach((e=>{(v()||n)&&_(e)})),m.get("is_variable")&&!m.get("variation_id")){const n=[...y].find((e=>e.dataset.productId===m.get("product_id")));if(n){n.querySelectorAll(`form[target="${i}"]`).forEach((e=>{["after_success_behavior","after_success_url","after_success_button_label"].forEach((t=>{0===e.querySelectorAll('input[name="'+t+'"]').length&&e.appendChild(a(t,m.get(t)))}));const t=e.dataset.product;if(t){const n=JSON.parse(t);Object.keys(n).forEach((t=>{0===e.querySelectorAll('input[name="'+t+'"]').length&&e.appendChild(a(t,n[t]))}))}})),t.preventDefault(),s.classList.remove("modal-processing"),$(n),e(n,!1);const c=s.getAttribute("data-product");return u=c?JSON.parse(c):{},p||o(u),void document.getElementById("newspack_modal_checkout").setAttribute("data-order-details",JSON.stringify(u))}}if(!n&&!v())return g(m).then((e=>{window.location.href=e})),void((!m.get("is_variable")||m.get("variation_id"))&&s.querySelectorAll("button[type=submit]:focus").forEach((e=>{e.classList.add("non-modal-checkout-loading");const t=e.innerHTML;e.innerHTML="<span>"+t+"</span>"})));s.classList.remove("modal-processing");const h=m.get("newspack_donate"),k=m.get("newspack_checkout");if(k){const e=s.getAttribute("data-product");u=e?JSON.parse(e):{}}else if(h){const e=m.get("donation_frequency");let t="",n="";for(const n of m.keys())n.indexOf("donation_value_"+e)>=0&&"other"!==m.get(n)&&""!==m.get(n)&&(t=m.get(n));const o=JSON.parse(m.get("frequency_ids"));for(const t in o)t===e&&(n=o[t].toString());u={amount:t,action_type:"donation",currency:m.get("donation_currency"),product_id:n,product_type:"donation",recurrence:e,referrer:m.get("_wp_http_referer")}}if(p||o(u),p=!0,v()){t.preventDefault();let e="",o="0",a="";if(h){const e=m.get("donation_frequency"),t=s.querySelectorAll(`.donation-tier__${e}, .donation-frequency__${e}`);if(t?.length){const n=m.get("donation_tier_index");if(n){const o=JSON.parse(t?.[n].dataset.product);o.hasOwnProperty(`donation_price_summary_${e}`)&&(a=o[`donation_price_summary_${e}`])}else{const n=s.querySelectorAll(`input[name="donation_value_${e}"], input[name="donation_value_${e}_untiered"]`);n?.length&&(n.forEach((e=>{e.checked&&"other"!==e.value&&(o=e.value)})),t.forEach((t=>{const n=JSON.parse(t.dataset.product);if(n.hasOwnProperty(`donation_price_summary_${e}`)){const t=n[`donation_price_summary_${e}`];new RegExp(`(?<=\\D)${o}(?=\\D)`).test(t)&&(a=t)}if("0"===o&&a){let t=m.get(`donation_value_${e}_other`);t||(t=m.get(`donation_value_${e}_untiered`)),t&&(a=a.replace("0",t))}})))}}}else if(k){const e=s.querySelector('input[name="product_price_summary"]');e&&(a=e.value)}a&&(e=`<div class="order-details-summary ${r}__box ${r}__box--text-center"><p><strong>${a}</strong></p></div>`);const i=g(m);i.then((e=>{window.newspackReaderActivation?.setPendingCheckout?.(e)})),window.newspackReaderActivation.openAuthModal({title:newspackBlocksModal.labels.auth_modal_title,onSuccess:(e,t)=>{i.then((e=>{if(t?.registered&&n&&(e+=`&${newspackBlocksModal.checkout_registration_flag}=1`),n){const t=S(e);M(t)}else g(m).then(window.location.href=e)})).catch((e=>{console.warn("Unable to generate cart:",e),q()}))},onError:()=>{q()},onDismiss:()=>{c(u),p=!1,document.getElementById("newspack_modal_checkout").removeAttribute("data-order-details")},skipSuccess:!0,skipNewslettersSignup:!0,labels:{signin:{title:newspackBlocksModal.labels.signin_modal_title},register:{title:newspackBlocksModal.labels.register_modal_title}},content:e,trigger:t.submitter,closeOnSuccess:n})}else A(),document.getElementById("newspack_modal_checkout").setAttribute("data-order-details",JSON.stringify(u))},S=e=>{const t=document.createElement("form");t.method="POST",t.action=e,t.target=i,t.style.display="none";const n=document.createElement("button");return n.setAttribute("type","submit"),t.appendChild(n),document.body.appendChild(t),t.addEventListener("submit",b),t},E=new ResizeObserver((e=>{if(!e||!e.length)return;if(k.scrollIntoView({behavior:"smooth",block:"start"}),!k.contentDocument)return;const t=e[0].contentRect;if(t){const e=t.top+t.bottom;if(0===e)return void(k.style.visibility="hidden");n.style.height=e+"px",k.style.height=e+"px"}})),q=()=>{const e=k?.contentDocument?.querySelector(`#${s}`),o=e?.querySelector('input[name="after_success_url"]'),a=e?.querySelector('input[name="after_success_behavior"]'),r=document?.querySelector(".newspack-newsletters-signup-modal");e?.checkoutComplete||(()=>{const e=new FormData;newspackBlocksModal.has_unsupported_payment_gateway||e.append("modal_checkout","1"),e.append("action","abandon_modal_checkout"),e.append("_wpnonce",t.checkout_nonce),t.checkout_nonce=null,fetch(newspackBlocksModal.ajax_url,{method:"POST",body:e})})();const i=!(k.contentDocument&&o&&a&&e?.checkoutComplete);if((i||r)&&(y.style.display="flex",k&&n.contains(k)&&(k._ready=!1,k.src="about:blank",k.style.height=h,k.style.visibility="hidden",n.style.height=h,n.removeChild(k)),E&&E.disconnect(),document.querySelectorAll(`.${l}-container`).forEach((e=>_(e))),f&&f.focus()),e?.checkoutComplete){const e=()=>{if(o&&a){const e=o.getAttribute("value"),t=a.getAttribute("value");"custom"===t?window.location.href=e:"referrer"===t&&window.history.back()}window?.newspackReaderActivation?.setPendingCheckout?.(),p=!1};window?.newspackReaderActivation?.openNewslettersSignupModal?window.newspackReaderActivation.openNewslettersSignupModal({onSuccess:e,onError:e,closeOnSuccess:i}):e(),i&&(B(),L(newspackBlocksModal.labels.checkout_modal_title))}else window?.newspackReaderActivation?.setPendingCheckout?.(),c(),p=!1,document.getElementById("newspack_modal_checkout").removeAttribute("data-order-details")},A=()=>{y.style.display="flex",$(t),n.appendChild(k),t.addEventListener("click",(e=>{e.target===t&&q()})),e(t,k),function(e){k._readyTimer&&clearTimeout(k._readyTimer);let t=!1;function n(){t||(t=!0,clearTimeout(k._readyTimer),e.call(this))}function o(){"complete"===this.readyState&&n.call(this)}!function e(){if(k._ready)return void clearTimeout(k._readyTimer);const t=k.contentDocument||k.contentWindow?.document;t&&0!==t.URL.indexOf("about:")?"complete"===t?.readyState?n.call(t):(t.addEventListener("DOMContentLoaded",n),t.addEventListener("readystatechange",o)):k._readyTimer=setTimeout(e,10)}()}(w)},$=e=>{window.newspackReaderActivation?.overlays&&(t.overlayId=window.newspackReaderActivation?.overlays.add()),e.setAttribute("data-state","open"),document.body.style.overflow="hidden"},L=e=>{const n=t.querySelector(`.${l}__header h2`);n&&(n.innerText=e)},B=(e="default")=>{const n=t.querySelector(`.${l}`);n&&("small"===e?n.classList.add(`${l}--small`):n.classList.remove(`${l}--small`))};window.newspackCloseModalCheckout=q,t.querySelectorAll(`.${l}__close`).forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault(),q()}))})),document.querySelectorAll(".newspack-blocks__modal-variation").forEach((e=>{e.addEventListener("click",(t=>{t.target===e&&q()})),e.querySelectorAll(`.${l}__close`).forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault(),q()}))}))})),document.addEventListener("keydown",(function(e){"Escape"===e.key&&q()})),document.querySelectorAll(".wpbnbd.wpbnbd--platform-wc, .wp-block-newspack-blocks-checkout-button, .newspack-blocks__modal-variation").forEach((e=>{e.querySelectorAll("form").forEach((e=>{newspackBlocksModal.has_unsupported_payment_gateway||e.appendChild(m.cloneNode()),e.target=i,e.addEventListener("submit",b)}))}));const M=e=>{e.requestSubmit(e.querySelector('button[type="submit"]'))};(()=>{const e=new URLSearchParams(window.location.search);if(!e.has("checkout"))return;const t=e.get("type");if("donate"===t){const t=e.get("layout"),n=e.get("frequency"),o=e.get("amount"),c=e.get("other");t&&n&&o&&((e,t,n,o=null)=>{let c;document.querySelectorAll(".wpbnbd.wpbnbd--platform-wc form").forEach((a=>{const r=a.querySelector(`input[name="donation_frequency"][value="${t}"]`);if(r)if("tiered"===e){const e=document.querySelector(`button[data-frequency-slug="${t}"]`);if(!e)return;e.click();const o=a.querySelector(`button[type="submit"][name="donation_value_${t}"][value="${n}"]`);if(!o)return;o.click()}else{const i="untiered"===e?a.querySelector(`input[name="donation_value_${t}_untiered"]`):a.querySelector(`input[name="donation_value_${t}"][value="${n}"]`);if(r&&i){if(r.checked=!0,"untiered"===e)i.value=n;else if("other"===n){i.click();const e=a.querySelector(`input[name="donation_value_${t}_other"]`);e&&o&&(e.value=o)}else i.checked=!0;c=a}}})),c&&M(c)})(t,n,o,c)}else if("checkout_button"===t){const t=e.get("product_id"),n=e.get("variation_id");t&&((e,t=null)=>{let n;if(t&&t!==e){const o=[...document.querySelectorAll(`.${d}`)].find((t=>t.dataset.productId===e));o&&o.querySelectorAll(`form[target="${i}"]`).forEach((e=>{const o=JSON.parse(e.dataset.product);o?.variation_id===Number(t)&&(n=e)}))}else document.querySelectorAll(".wp-block-newspack-blocks-checkout-button").forEach((t=>{const o=t.querySelector("form");if(!o)return;const c=JSON.parse(o.dataset.product);c?.product_id===e&&(n=o)}));n&&M(n)})(t,n)}else{const e=window.newspackReaderActivation?.getPendingCheckout?.();if(e){const t=S(e);M(t)}}window.history.replaceState(null,null,window.location.pathname)})()},"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",m):m())})();
@@ -108,6 +108,21 @@ final class Modal_Checkout {
108
108
  'metorik',
109
109
  ];
110
110
 
111
+ /**
112
+ * Supported Payment Gateways
113
+ *
114
+ * @var string[]
115
+ */
116
+ private static $supported_gateways = [
117
+ 'bacs', // Direct bank transfer.
118
+ 'cheque',
119
+ 'cod', // Cash on delivery.
120
+ 'ppcp-gateway', // PayPal Payments.
121
+ 'stripe',
122
+ 'stripe-link',
123
+ 'woocommerce_payments',
124
+ ];
125
+
111
126
  /**
112
127
  * Initialize hooks.
113
128
  */
@@ -151,7 +166,6 @@ final class Modal_Checkout {
151
166
  add_action( 'init', [ __CLASS__, 'unhook_woocommerce_payments_update_billing_fields' ] );
152
167
  add_action( 'wp_enqueue_scripts', [ __CLASS__, 'update_password_strength_message' ], 9999 );
153
168
 
154
-
155
169
  /** Custom handling for registered users. */
156
170
  add_filter( 'woocommerce_checkout_customer_id', [ __CLASS__, 'associate_existing_user' ] );
157
171
  add_action( 'woocommerce_after_checkout_validation', [ __CLASS__, 'maybe_reset_checkout_registration_flag' ], 10, 2 );
@@ -224,6 +238,38 @@ final class Modal_Checkout {
224
238
  return $enqueue_styles;
225
239
  }
226
240
 
241
+ /**
242
+ * Get list of supported payment gateways for Modal Checkout.
243
+ *
244
+ * @return string[] Supported payment gateways.
245
+ */
246
+ public static function get_supported_payment_gateways() {
247
+ /**
248
+ * Filters the list of supported gateways in modal checkout.
249
+ *
250
+ * @param array $supported_gateways
251
+ */
252
+ return apply_filters( 'newspack_blocks_modal_checkout_supported_gateways', self::$supported_gateways );
253
+ }
254
+
255
+ /**
256
+ * Whether any available payment gateways are not suppored in modal checkout.
257
+ *
258
+ * @return boolean
259
+ */
260
+ public static function has_unsupported_payment_gateway() {
261
+ $supported_gateways = self::get_supported_payment_gateways();
262
+ $available_gateways = \WC()->payment_gateways->get_available_payment_gateways();
263
+ $unsupported_payment_gateway = false;
264
+ foreach ( $available_gateways as $id => $gateway ) {
265
+ if ( ! in_array( $id, $supported_gateways, true ) ) {
266
+ $unsupported_payment_gateway = true;
267
+ break;
268
+ }
269
+ }
270
+ return $unsupported_payment_gateway;
271
+ }
272
+
227
273
  /**
228
274
  * Process checkout request for modal.
229
275
  */
@@ -334,13 +380,18 @@ final class Modal_Checkout {
334
380
  if ( ! empty( $referer_categories ) ) {
335
381
  $query_args['referer_categories'] = implode( ',', $referer_categories );
336
382
  }
337
- $query_args['modal_checkout'] = 1;
383
+
384
+ if ( ! self::has_unsupported_payment_gateway() ) {
385
+ $query_args['modal_checkout'] = 1;
386
+ }
338
387
 
339
388
  // Pass through UTM and after_success params so they can be forwarded to the WooCommerce checkout flow.
340
389
  foreach ( $params as $param => $value ) {
341
390
  if ( 'utm' === substr( $param, 0, 3 ) || 'after_success' === substr( $param, 0, 13 ) ) {
342
- $param = sanitize_text_field( $param );
343
- $query_args[ $param ] = sanitize_text_field( $value );
391
+ if ( ! empty( $value ) ) {
392
+ $param = sanitize_text_field( $param );
393
+ $query_args[ $param ] = sanitize_text_field( $value );
394
+ }
344
395
  }
345
396
  }
346
397
 
@@ -933,11 +984,12 @@ final class Modal_Checkout {
933
984
  'newspack-blocks-modal',
934
985
  'newspackBlocksModal',
935
986
  [
936
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
937
- 'checkout_registration_flag' => self::CHECKOUT_REGISTRATION_FLAG,
938
- 'newspack_class_prefix' => self::get_class_prefix(),
939
- 'is_registration_required' => self::is_registration_required(),
940
- 'labels' => [
987
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
988
+ 'checkout_registration_flag' => self::CHECKOUT_REGISTRATION_FLAG,
989
+ 'newspack_class_prefix' => self::get_class_prefix(),
990
+ 'is_registration_required' => self::is_registration_required(),
991
+ 'has_unsupported_payment_gateway' => self::has_unsupported_payment_gateway(),
992
+ 'labels' => [
941
993
  'auth_modal_title' => self::get_modal_checkout_labels( 'auth_modal_title' ),
942
994
  'checkout_modal_title' => self::get_modal_checkout_labels( 'checkout_modal_title' ),
943
995
  'register_modal_title' => self::get_modal_checkout_labels( 'register_modal_title' ),
@@ -1052,7 +1104,7 @@ final class Modal_Checkout {
1052
1104
  * @return string
1053
1105
  */
1054
1106
  public static function woocommerce_get_return_url( $url, $order ) {
1055
- if ( ! self::is_modal_checkout() ) {
1107
+ if ( ! self::is_modal_checkout() || self::has_unsupported_payment_gateway() ) {
1056
1108
  return $url;
1057
1109
  }
1058
1110
 
@@ -689,6 +689,10 @@ class Newspack_Blocks {
689
689
  $term = $coauthors_plus->get_author_term( $co_author );
690
690
  if ( $term ) {
691
691
  $authors_term_ids[] = $term->term_id;
692
+ } else {
693
+ // If the author term does not exist, force a non-match, otherwise all posts will be returned.
694
+ // CAP's cli command to create author terms will only create terms for users that have authored posts.
695
+ $authors_term_ids[] = -1;
692
696
  }
693
697
 
694
698
  // If it's a guest author, also check the linked author.
@@ -7,7 +7,7 @@
7
7
  * Author URI: https://newspack.com/
8
8
  * Text Domain: newspack-blocks
9
9
  * Domain Path: /languages
10
- * Version: 4.5.8
10
+ * Version: 4.5.9
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', '4.5.8' );
18
+ define( 'NEWSPACK_BLOCKS__VERSION', '4.5.9' );
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
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@automattic/newspack-blocks",
3
- "version": "4.5.8",
3
+ "version": "4.5.9",
4
4
  "author": "Automattic",
5
5
  "devDependencies": {
6
6
  "@rushstack/eslint-patch": "^1.10.5",
7
7
  "@testing-library/dom": "^10.4.0",
8
- "@testing-library/user-event": "^14.5.2",
8
+ "@testing-library/user-event": "^14.6.0",
9
9
  "@types/lodash": "^4.17.14",
10
- "@wordpress/browserslist-config": "^6.15.0",
10
+ "@wordpress/browserslist-config": "^6.16.0",
11
11
  "eslint": "^8.57.0",
12
12
  "fetch-mock-jest": "^1.5.1",
13
13
  "html-entities": "^2.5.2",
14
14
  "identity-obj-proxy": "^3.0.0",
15
- "lint-staged": "^15.3.0",
15
+ "lint-staged": "^15.4.1",
16
16
  "newspack-components": "^3.1.0",
17
17
  "newspack-scripts": "^5.5.2",
18
18
  "postcss-scss": "^4.0.9"
@@ -101,10 +101,12 @@ function render_callback( $attributes ) {
101
101
  );
102
102
 
103
103
  // Generate hidden fields for the form.
104
- $hidden_fields = '<input type="hidden" name="newspack_checkout" value="1" />';
105
- $hidden_fields .= $after_success_behavior ? '<input type="hidden" name="after_success_behavior" value="' . esc_attr( $after_success_behavior ) . '" />' : '';
106
- $hidden_fields .= $after_success_button_label ? '<input type="hidden" name="after_success_button_label" value="' . esc_attr( $after_success_button_label ) . '" />' : '';
107
- $hidden_fields .= $after_success_url ? '<input type="hidden" name="after_success_url" value="' . esc_attr( $after_success_url ) . '" />' : '';
104
+ $hidden_fields = '<input type="hidden" name="newspack_checkout" value="1" />';
105
+ if ( ! Modal_Checkout::has_unsupported_payment_gateway() ) {
106
+ $hidden_fields .= $after_success_behavior ? '<input type="hidden" name="after_success_behavior" value="' . esc_attr( $after_success_behavior ) . '" />' : '';
107
+ $hidden_fields .= $after_success_button_label ? '<input type="hidden" name="after_success_button_label" value="' . esc_attr( $after_success_button_label ) . '" />' : '';
108
+ $hidden_fields .= $after_success_url ? '<input type="hidden" name="after_success_url" value="' . esc_attr( $after_success_url ) . '" />' : '';
109
+ }
108
110
 
109
111
  // Generate the form.
110
112
  if ( function_exists( 'wc_get_product' ) ) {
@@ -203,13 +203,15 @@ abstract class Newspack_Blocks_Donate_Renderer_Base {
203
203
  <input type='hidden' name='frequency_ids' value='<?php echo esc_attr( wp_json_encode( $donate_child_ids ) ); ?>' />
204
204
  <?php
205
205
 
206
- foreach ( [ [ 'afterSuccessBehavior', 'after_success_behavior' ], [ 'afterSuccessButtonLabel', 'after_success_button_label' ], [ 'afterSuccessURL', 'after_success_url' ] ] as $attribute ) {
207
- $attribute_name = $attribute[0];
208
- $param_name = $attribute[1];
209
- $value = isset( $attributes[ $attribute_name ] ) ? $attributes[ $attribute_name ] : '';
210
- ?>
211
- <input type='hidden' name='<?php echo esc_attr( $param_name ); ?>' value='<?php echo esc_attr( $value ); ?>' />
212
- <?php
206
+ if ( ! \Newspack_Blocks\Modal_Checkout::has_unsupported_payment_gateway() ) {
207
+ foreach ( [ [ 'afterSuccessBehavior', 'after_success_behavior' ], [ 'afterSuccessButtonLabel', 'after_success_button_label' ], [ 'afterSuccessURL', 'after_success_url' ] ] as $attribute ) {
208
+ $attribute_name = $attribute[0];
209
+ $param_name = $attribute[1];
210
+ $value = isset( $attributes[ $attribute_name ] ) ? $attributes[ $attribute_name ] : '';
211
+ ?>
212
+ <input type='hidden' name='<?php echo esc_attr( $param_name ); ?>' value='<?php echo esc_attr( $value ); ?>' />
213
+ <?php
214
+ }
213
215
  }
214
216
  return ob_get_clean();
215
217
  }
@@ -24,9 +24,27 @@ let analyticsData = {};
24
24
  // Track the checkout intent to avoid multiple analytics events.
25
25
  let inCheckoutIntent = false;
26
26
 
27
+ // Close the modal.
28
+ const closeModal = el => {
29
+ if ( el.overlayId && window.newspackReaderActivation?.overlays ) {
30
+ window.newspackReaderActivation?.overlays.remove( el.overlayId );
31
+ }
32
+ el.setAttribute( 'data-state', 'closed' );
33
+ document.body.style.overflow = 'auto';
34
+ };
35
+
36
+ // Cleanup if page is loaded via back button.
37
+ window.onpageshow = event => {
38
+ if ( event.persisted ) {
39
+ // If the page is loaded from the back button, find and remove any loading-related classes and modals:
40
+ document.querySelectorAll( '.modal-processing' ).forEach( el => el.classList.remove( 'modal-processing' ) );
41
+ document.querySelectorAll( '.non-modal-checkout-loading' ).forEach( el => el.classList.remove( 'non-modal-checkout-loading' ) );
42
+ document.querySelectorAll( `.${ MODAL_CLASS_PREFIX }-container` ).forEach( el => closeModal( el ) );
43
+ }
44
+ }
45
+
27
46
  domReady( () => {
28
47
  const modalCheckout = document.querySelector( `#${ MODAL_CHECKOUT_ID }` );
29
-
30
48
  if ( ! modalCheckout ) {
31
49
  return;
32
50
  }
@@ -167,7 +185,9 @@ domReady( () => {
167
185
  */
168
186
  const emptyCart = () => {
169
187
  const body = new FormData();
170
- body.append( 'modal_checkout', '1' );
188
+ if ( ! newspackBlocksModal.has_unsupported_payment_gateway ) {
189
+ body.append( 'modal_checkout', '1' );
190
+ }
171
191
  body.append( 'action', 'abandon_modal_checkout' );
172
192
  body.append( '_wpnonce', modalCheckout.checkout_nonce );
173
193
  modalCheckout.checkout_nonce = null;
@@ -197,12 +217,13 @@ domReady( () => {
197
217
  * @param {Event} ev
198
218
  */
199
219
  const handleCheckoutFormSubmit = ev => {
220
+ const isModalCheckout = ! newspackBlocksModal.has_unsupported_payment_gateway;
221
+ if ( ! isModalCheckout ) {
222
+ ev.preventDefault();
223
+ }
200
224
  const form = ev.target;
201
-
202
225
  form.classList.add( 'modal-processing' );
203
-
204
226
  const productData = form.dataset.product;
205
-
206
227
  if ( productData ) {
207
228
  const data = JSON.parse( productData );
208
229
  Object.keys( data ).forEach( key => {
@@ -213,17 +234,19 @@ domReady( () => {
213
234
  } );
214
235
  }
215
236
  const formData = new FormData( form );
216
-
217
237
  // If we're not going from variation picker to checkout, set the modal trigger:
218
238
  if ( ! formData.get( 'variation_id' ) ) {
219
239
  modalTrigger = ev.submitter;
220
240
  }
221
-
222
- const variationModals = document.querySelectorAll( `.${ VARIATON_MODAL_CLASS_PREFIX }` );
223
241
  // Clear any open variation modal.
242
+ const variationModals = document.querySelectorAll( `.${ VARIATON_MODAL_CLASS_PREFIX }` );
224
243
  variationModals.forEach( variationModal => {
225
- closeModal( variationModal );
244
+ // Only close the variation picker if is the modal checkout, or if registration is required.
245
+ if ( shouldPromptRegistration() || isModalCheckout ) {
246
+ closeModal( variationModal );
247
+ }
226
248
  } );
249
+
227
250
  // Trigger variation modal if variation is not selected.
228
251
  if ( formData.get( 'is_variable' ) && ! formData.get( 'variation_id' ) ) {
229
252
  const variationModal = [ ...variationModals ].find(
@@ -283,11 +306,27 @@ domReady( () => {
283
306
  }
284
307
  }
285
308
 
309
+ // Populate cart and redirect to checkout if there is an unsupported payment gateway.
310
+ if ( ! isModalCheckout && ! shouldPromptRegistration() ) {
311
+ generateCart( formData ).then( url => {
312
+ // Remove modal checkout query string and trailing question mark (if any).
313
+ window.location.href = url;
314
+ } );
315
+ // Add some animation to the Checkout Button while the non-modal checkout is loading.
316
+ // For now, don't do it when any popup opens, just when we go right to the checkout page.
317
+ if ( ! ( formData.get( 'is_variable' ) && ! formData.get( 'variation_id' ) ) ) {
318
+ const buttons = form.querySelectorAll( 'button[type=submit]:focus' );
319
+ buttons.forEach( button => {
320
+ button.classList.add( 'non-modal-checkout-loading' );
321
+ const buttonText = button.innerHTML;
322
+ button.innerHTML = '<span>' + buttonText + '</span>';
323
+ } );
324
+ }
325
+ return;
326
+ }
286
327
  form.classList.remove( 'modal-processing' );
287
-
288
328
  const isDonateBlock = formData.get( 'newspack_donate' );
289
329
  const isCheckoutButtonBlock = formData.get( 'newspack_checkout' );
290
-
291
330
  // Set up some GA4 information.
292
331
  if ( isCheckoutButtonBlock ) { // this fires on the second in-modal variations screen, too
293
332
  const formAnalyticsData = form.getAttribute( 'data-product' );
@@ -416,18 +455,23 @@ domReady( () => {
416
455
  cartReq.then( url => {
417
456
  window.newspackReaderActivation?.setPendingCheckout?.( url );
418
457
  } );
419
-
420
458
  // Initialize auth flow if reader is not authenticated.
421
459
  window.newspackReaderActivation.openAuthModal( {
422
460
  title: newspackBlocksModal.labels.auth_modal_title,
423
461
  onSuccess: ( message, authData ) => {
424
462
  cartReq.then( url => {
425
- // If registered, append the registration flag query param to the url.
426
- if ( authData?.registered ) {
463
+ // If registered and in a modal checkout, append the registration flag query param to the url.
464
+ if ( authData?.registered && isModalCheckout ) {
427
465
  url += `&${ newspackBlocksModal.checkout_registration_flag }=1`;
428
466
  }
429
- const checkoutForm = generateCheckoutPageForm( url );
430
- triggerCheckout( checkoutForm );
467
+ // Populate cart and redirect to checkout if there is an unsupported payment gateway.
468
+ if ( ! isModalCheckout ) {
469
+ // Remove modal checkout query string, and trailing question mark (if any).
470
+ generateCart( formData ).then( window.location.href = url );
471
+ } else {
472
+ const checkoutForm = generateCheckoutPageForm( url );
473
+ triggerCheckout( checkoutForm );
474
+ }
431
475
  } )
432
476
  .catch( error => {
433
477
  console.warn( 'Unable to generate cart:', error ); // eslint-disable-line no-console
@@ -455,6 +499,7 @@ domReady( () => {
455
499
  },
456
500
  content,
457
501
  trigger: ev.submitter,
502
+ closeOnSuccess: isModalCheckout,
458
503
  } );
459
504
  } else {
460
505
  // Otherwise initialize checkout.
@@ -604,14 +649,6 @@ domReady( () => {
604
649
  iframeReady( handleIframeReady );
605
650
  };
606
651
 
607
- const closeModal = el => {
608
- if ( el.overlayId && window.newspackReaderActivation?.overlays ) {
609
- window.newspackReaderActivation?.overlays.remove( el.overlayId );
610
- }
611
- el.setAttribute( 'data-state', 'closed' );
612
- document.body.style.overflow = 'auto';
613
- };
614
-
615
652
  const openModal = el => {
616
653
  if ( window.newspackReaderActivation?.overlays ) {
617
654
  modalCheckout.overlayId = window.newspackReaderActivation?.overlays.add();
@@ -700,7 +737,9 @@ domReady( () => {
700
737
  .forEach( element => {
701
738
  const forms = element.querySelectorAll( 'form' );
702
739
  forms.forEach( form => {
703
- form.appendChild( modalCheckoutHiddenInput.cloneNode() );
740
+ if ( ! newspackBlocksModal.has_unsupported_payment_gateway ) {
741
+ form.appendChild( modalCheckoutHiddenInput.cloneNode() );
742
+ }
704
743
  form.target = IFRAME_NAME;
705
744
  form.addEventListener( 'submit', handleCheckoutFormSubmit );
706
745
  } );
@@ -226,6 +226,28 @@
226
226
  }
227
227
  }
228
228
 
229
+ .non-modal-checkout-loading {
230
+ position: relative;
231
+
232
+ span {
233
+ visibility: hidden;
234
+ }
235
+
236
+ &::before {
237
+ animation: spin 900ms infinite linear;
238
+ border: 1.5px solid;
239
+ border-color: currentcolor currentcolor transparent transparent;
240
+ border-radius: 50%;
241
+ content: "";
242
+ display: block;
243
+ height: 18px;
244
+ inset: calc(50% - 9px) calc(50% - 9px) auto auto;
245
+ position: absolute;
246
+ width: 18px;
247
+ }
248
+ }
249
+
250
+
229
251
  @keyframes spin {
230
252
  0% {
231
253
  transform: rotate(0deg);
@@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
22
22
 
23
23
  require_once __DIR__ . '/composer/autoload_real.php';
24
24
 
25
- return ComposerAutoloaderInitd252a2d3f51e2d9acf044fc40e95a025::getLoader();
25
+ return ComposerAutoloaderInit324e5bd33f1e07fe4aef610ebf7210de::getLoader();
@@ -2,7 +2,7 @@
2
2
 
3
3
  // autoload_real.php @generated by Composer
4
4
 
5
- class ComposerAutoloaderInitd252a2d3f51e2d9acf044fc40e95a025
5
+ class ComposerAutoloaderInit324e5bd33f1e07fe4aef610ebf7210de
6
6
  {
7
7
  private static $loader;
8
8
 
@@ -22,12 +22,12 @@ class ComposerAutoloaderInitd252a2d3f51e2d9acf044fc40e95a025
22
22
  return self::$loader;
23
23
  }
24
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInitd252a2d3f51e2d9acf044fc40e95a025', 'loadClassLoader'), true, true);
25
+ spl_autoload_register(array('ComposerAutoloaderInit324e5bd33f1e07fe4aef610ebf7210de', 'loadClassLoader'), true, true);
26
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
27
- spl_autoload_unregister(array('ComposerAutoloaderInitd252a2d3f51e2d9acf044fc40e95a025', 'loadClassLoader'));
27
+ spl_autoload_unregister(array('ComposerAutoloaderInit324e5bd33f1e07fe4aef610ebf7210de', 'loadClassLoader'));
28
28
 
29
29
  require __DIR__ . '/autoload_static.php';
30
- call_user_func(\Composer\Autoload\ComposerStaticInitd252a2d3f51e2d9acf044fc40e95a025::getInitializer($loader));
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit324e5bd33f1e07fe4aef610ebf7210de::getInitializer($loader));
31
31
 
32
32
  $loader->register(true);
33
33
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  namespace Composer\Autoload;
6
6
 
7
- class ComposerStaticInitd252a2d3f51e2d9acf044fc40e95a025
7
+ class ComposerStaticInit324e5bd33f1e07fe4aef610ebf7210de
8
8
  {
9
9
  public static $classMap = array (
10
10
  'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
@@ -13,7 +13,7 @@ class ComposerStaticInitd252a2d3f51e2d9acf044fc40e95a025
13
13
  public static function getInitializer(ClassLoader $loader)
14
14
  {
15
15
  return \Closure::bind(function () use ($loader) {
16
- $loader->classMap = ComposerStaticInitd252a2d3f51e2d9acf044fc40e95a025::$classMap;
16
+ $loader->classMap = ComposerStaticInit324e5bd33f1e07fe4aef610ebf7210de::$classMap;
17
17
 
18
18
  }, null, ClassLoader::class);
19
19
  }
@@ -3,7 +3,7 @@
3
3
  'name' => 'automattic/newspack-blocks',
4
4
  'pretty_version' => 'dev-trunk',
5
5
  'version' => 'dev-trunk',
6
- 'reference' => 'b251f999a2dd71a5c6aedfeb3bf9d03bef24e3f4',
6
+ 'reference' => 'c8590c2b8741f2fae57b43d6d84de6cf50f134ea',
7
7
  'type' => 'wordpress-plugin',
8
8
  'install_path' => __DIR__ . '/../../',
9
9
  'aliases' => array(),
@@ -13,7 +13,7 @@
13
13
  'automattic/newspack-blocks' => array(
14
14
  'pretty_version' => 'dev-trunk',
15
15
  'version' => 'dev-trunk',
16
- 'reference' => 'b251f999a2dd71a5c6aedfeb3bf9d03bef24e3f4',
16
+ 'reference' => 'c8590c2b8741f2fae57b43d6d84de6cf50f134ea',
17
17
  'type' => 'wordpress-plugin',
18
18
  'install_path' => __DIR__ . '/../../',
19
19
  'aliases' => array(),