diff --git a/assets/css/scss/_icons.scss b/assets/css/scss/_icons.scss index 41ef0127..0eac7f5b 100644 --- a/assets/css/scss/_icons.scss +++ b/assets/css/scss/_icons.scss @@ -116,7 +116,8 @@ } }*/ -.lsx-price-wrapper { +.lsx-price-wrapper, +.lsx-single-supplement-wrapper { /*&:before { background-image: url( ../img/icons/price-icon.png ); }*/ @@ -129,6 +130,3 @@ } } } - -// Add the icon ULR here. -//.lsx-destination-to-tour-wrapper::before { background-image: url( ../img/icons/destinations-icon.webp ); } diff --git a/assets/css/scss/style.scss b/assets/css/scss/style.scss deleted file mode 100644 index d92f46ae..00000000 --- a/assets/css/scss/style.scss +++ /dev/null @@ -1,27 +0,0 @@ -/* - * LSX Tour Operators - */ - -@import 'include-media'; -@import 'customizer-to-body-colours'; -@import 'customizer-to-main-menu-colours'; - -@import 'base/variables'; - -@import 'base/scaffolding'; - -@import 'layout/widget'; -@import 'layout/slider'; -@import 'layout/meta-data'; -@import 'layout/archive'; -@import 'layout/contact'; -@import 'layout/single-sections'; -@import 'layout/spy-bar'; -@import 'layout/modals'; -@import 'layout/maps'; -@import 'layout/mobile'; - -@import 'update-fixes'; - -@include customizer-to-body-colours(#F6F6F6, #DADDDF, #4A4A4A, #1098AD, #F7AE00, #919191); -@include customizer-to-main-menu-colours(#374750, #2B3840, #FFF, #1098AD); diff --git a/assets/css/style.css b/assets/css/style.css index 5573a925..cbb562c4 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -2,74 +2,105 @@ /* * LSX Tour Operators */ -.lsx-price-wrapper .amount .currency-icon:after { +.lsx-price-wrapper .amount .currency-icon:after, +.lsx-single-supplement-wrapper .amount .currency-icon:after { margin-left: 3px; margin-right: 3px; } -.lsx-price-wrapper .amount .currency-icon.usd:after, .lsx-price-wrapper .amount .currency-icon.nad:after, .lsx-price-wrapper .amount .currency-icon.cad:after, .lsx-price-wrapper .amount .currency-icon.hkd:after, .lsx-price-wrapper .amount .currency-icon.sgd:after, .lsx-price-wrapper .amount .currency-icon.nzd:after, .lsx-price-wrapper .amount .currency-icon.aud:after { +.lsx-price-wrapper .amount .currency-icon.usd:after, +.lsx-single-supplement-wrapper .amount .currency-icon.usd:after, .lsx-price-wrapper .amount .currency-icon.nad:after, +.lsx-single-supplement-wrapper .amount .currency-icon.nad:after, .lsx-price-wrapper .amount .currency-icon.cad:after, +.lsx-single-supplement-wrapper .amount .currency-icon.cad:after, .lsx-price-wrapper .amount .currency-icon.hkd:after, +.lsx-single-supplement-wrapper .amount .currency-icon.hkd:after, .lsx-price-wrapper .amount .currency-icon.sgd:after, +.lsx-single-supplement-wrapper .amount .currency-icon.sgd:after, .lsx-price-wrapper .amount .currency-icon.nzd:after, +.lsx-single-supplement-wrapper .amount .currency-icon.nzd:after, .lsx-price-wrapper .amount .currency-icon.aud:after, +.lsx-single-supplement-wrapper .amount .currency-icon.aud:after { content: "$"; } -.lsx-price-wrapper .amount .currency-icon.eur:after { +.lsx-price-wrapper .amount .currency-icon.eur:after, +.lsx-single-supplement-wrapper .amount .currency-icon.eur:after { content: "€"; } -.lsx-price-wrapper .amount .currency-icon.gbp:after { +.lsx-price-wrapper .amount .currency-icon.gbp:after, +.lsx-single-supplement-wrapper .amount .currency-icon.gbp:after { content: "£"; } -.lsx-price-wrapper .amount .currency-icon.zar:after { +.lsx-price-wrapper .amount .currency-icon.zar:after, +.lsx-single-supplement-wrapper .amount .currency-icon.zar:after { content: "R"; } -.lsx-price-wrapper .amount .currency-icon.brl:after { +.lsx-price-wrapper .amount .currency-icon.brl:after, +.lsx-single-supplement-wrapper .amount .currency-icon.brl:after { content: "R$"; } -.lsx-price-wrapper .amount .currency-icon.bwp:after { +.lsx-price-wrapper .amount .currency-icon.bwp:after, +.lsx-single-supplement-wrapper .amount .currency-icon.bwp:after { content: "P"; } -.lsx-price-wrapper .amount .currency-icon.cny:after, .lsx-price-wrapper .amount .currency-icon.jpy:after { +.lsx-price-wrapper .amount .currency-icon.cny:after, +.lsx-single-supplement-wrapper .amount .currency-icon.cny:after, .lsx-price-wrapper .amount .currency-icon.jpy:after, +.lsx-single-supplement-wrapper .amount .currency-icon.jpy:after { content: "¥"; } -.lsx-price-wrapper .amount .currency-icon.inr:after { +.lsx-price-wrapper .amount .currency-icon.inr:after, +.lsx-single-supplement-wrapper .amount .currency-icon.inr:after { content: "₹"; } -.lsx-price-wrapper .amount .currency-icon.idr:after { +.lsx-price-wrapper .amount .currency-icon.idr:after, +.lsx-single-supplement-wrapper .amount .currency-icon.idr:after { content: "₹"; } -.lsx-price-wrapper .amount .currency-icon.ils:after { +.lsx-price-wrapper .amount .currency-icon.ils:after, +.lsx-single-supplement-wrapper .amount .currency-icon.ils:after { content: "₪"; } -.lsx-price-wrapper .amount .currency-icon.kes:after { +.lsx-price-wrapper .amount .currency-icon.kes:after, +.lsx-single-supplement-wrapper .amount .currency-icon.kes:after { content: "K"; } -.lsx-price-wrapper .amount .currency-icon.lak:after { +.lsx-price-wrapper .amount .currency-icon.lak:after, +.lsx-single-supplement-wrapper .amount .currency-icon.lak:after { content: "₭"; } -.lsx-price-wrapper .amount .currency-icon.mwk:after { +.lsx-price-wrapper .amount .currency-icon.mwk:after, +.lsx-single-supplement-wrapper .amount .currency-icon.mwk:after { content: "MK"; } -.lsx-price-wrapper .amount .currency-icon.myr:after { +.lsx-price-wrapper .amount .currency-icon.myr:after, +.lsx-single-supplement-wrapper .amount .currency-icon.myr:after { content: "RM"; } -.lsx-price-wrapper .amount .currency-icon.mzn:after { +.lsx-price-wrapper .amount .currency-icon.mzn:after, +.lsx-single-supplement-wrapper .amount .currency-icon.mzn:after { content: "MT"; } -.lsx-price-wrapper .amount .currency-icon.nok:after, .lsx-price-wrapper .amount .currency-icon.sek:after { +.lsx-price-wrapper .amount .currency-icon.nok:after, +.lsx-single-supplement-wrapper .amount .currency-icon.nok:after, .lsx-price-wrapper .amount .currency-icon.sek:after, +.lsx-single-supplement-wrapper .amount .currency-icon.sek:after { content: "kr"; } -.lsx-price-wrapper .amount .currency-icon.rub:after { +.lsx-price-wrapper .amount .currency-icon.rub:after, +.lsx-single-supplement-wrapper .amount .currency-icon.rub:after { content: "руб"; } -.lsx-price-wrapper .amount .currency-icon.chf:after { +.lsx-price-wrapper .amount .currency-icon.chf:after, +.lsx-single-supplement-wrapper .amount .currency-icon.chf:after { content: "CHF"; } -.lsx-price-wrapper .amount .currency-icon.tzs:after { +.lsx-price-wrapper .amount .currency-icon.tzs:after, +.lsx-single-supplement-wrapper .amount .currency-icon.tzs:after { content: "TSh"; } -.lsx-price-wrapper .amount .currency-icon.aed:after { +.lsx-price-wrapper .amount .currency-icon.aed:after, +.lsx-single-supplement-wrapper .amount .currency-icon.aed:after { content: "د.إ"; } -.lsx-price-wrapper .amount .currency-icon.zmw:after { +.lsx-price-wrapper .amount .currency-icon.zmw:after, +.lsx-single-supplement-wrapper .amount .currency-icon.zmw:after { content: "Zk"; } -.lsx-price-wrapper .amount .currency-icon.zwl:after { +.lsx-price-wrapper .amount .currency-icon.zwl:after, +.lsx-single-supplement-wrapper .amount .currency-icon.zwl:after { content: "Z$"; } @@ -84,12 +115,14 @@ background-position: center top; } }*/ -.lsx-price-wrapper { +.lsx-price-wrapper, +.lsx-single-supplement-wrapper { /*&:before { background-image: url( ../img/icons/price-icon.png ); }*/ } -.lsx-price-wrapper .amount .currency-icon:after { +.lsx-price-wrapper .amount .currency-icon:after, +.lsx-single-supplement-wrapper .amount .currency-icon:after { margin-right: 0px; } @@ -197,4 +230,4 @@ .lsx-units-wrapper .hidden { display: none; } -/*# sourceMappingURL=style.css.map */ +/*# sourceMappingURL=style.css.map */ \ No newline at end of file diff --git a/assets/css/style.css.map b/assets/css/style.css.map index e93d1452..d858bc1a 100644 --- a/assets/css/style.css.map +++ b/assets/css/style.css.map @@ -1 +1 @@ -{"version":3,"sources":["style.css","style.scss","scss/_icons.scss","scss/_slider.scss"],"names":[],"mappings":"AAAA,gBAAgB;ACAhB;;EAAA;ACEE;EACC,gBAAA;EACA,iBAAA;AFGH;AEOG;EAAU,YAAA;AFJb;AEQG;EAAU,YAAA;AFLb;AESG;EAAU,YAAA;AFNb;AEUG;EAAU,YAAA;AFPb;AEWG;EAAU,aAAA;AFRb;AEYG;EAAU,YAAA;AFTb;AEcG;EAAU,YAAA;AFXb;AEeG;EAAU,YAAA;AFZb;AEgBG;EAAU,YAAA;AFbb;AEiBG;EAAU,YAAA;AFdb;AEkBG;EAAU,YAAA;AFfb;AEmBG;EAAU,YAAA;AFhBb;AEoBG;EAAU,aAAA;AFjBb;AEqBG;EAAU,aAAA;AFlBb;AEsBG;EAAU,aAAA;AFnBb;AEwBG;EAAU,aAAA;AFrBb;AEyBG;EAAU,cAAA;AFtBb;AE0BG;EAAU,cAAA;AFvBb;AE2BG;EAAU,cAAA;AFxBb;AE4BG;EAAU,cAAA;AFzBb;AE6BG;EAAU,aAAA;AF1Bb;AE8BG;EAAU,aAAA;AF3Bb;;AEiCA;;;;;;;;;;EAAA;AAYA;EACC;;IAAA;AF7BD;AEqCG;EAAU,iBAAA;AFlCb;;AG7FA;EACC,WAAA;EACA,SAAA;AHgGD;;AG3FC;;EACC,uBAAA;EACA,kBAAA;EACA,mBAAA;EACA,iBAAA;EACA,WAAA;EACA,YAAA;EACA,sCAAA;EACA,UAAA;EACA,iBAAA;EACA,2BAAA;EACA,6BAAA;EACA,WAAA;EACA,UAAA;AH+FF;AG7FE;;EACC,cAAA;EACA,0BAAA;EACA,eAAA;EACA,cAAA;EACA,kBAAA;EACA,oBAAA;EACA,QAAA;EACA,2BAAA;EACA,4BAAA;EAEA,mCAAA;EACA,kCAAA;AH+FH;AG5FE;;EAAmB,mBAAA;AHgGrB;AG7FG;;EACC,gBAAA;EACA,YAAA;AHgGJ;AG3FG;;EACC,gBAAA;EACA,YAAA;AH8FJ;;AGvFC;EACC,mBAAA;EACA,aAAA;EACA,mBAAA;EACA,YAAA;EACA,uBAAA;EACA,gBAAA;EACA,gBAAA;EACA,UAAA;AH0FF;AGxFE;EACC,cAAA;EACA,YAAA;AH0FH;AGxFG;EACC,uBAAA;EACA,mBAAA;EACA,iBAAA;EACA,WAAA;EACA,YAAA;EACA,iCAAA;EACA,WAAA;AH0FJ;AGpFE;EAAe,WAAA;AHuFjB;AGtFE;EAAe,YAAA;AHyFjB;;AGpFC;EAAoB,gBAAA;AHwFrB;;AGpFC;EACC,aAAA;AHuFF;AGrFE;EAAU,UAAA;AHwFZ;;AGpFA;EAAgC,qBAAA;AHwFhC;;AGnFE;;EACC,iBAAA;AHuFH;;ACvLC;;EACC,aAAA;AD2LF","file":"style.css"} \ No newline at end of file +{"version":3,"sources":["style.css","style.scss","scss/_icons.scss","scss/_slider.scss"],"names":[],"mappings":"AAAA,gBAAgB;ACAhB;;EAAA;ACEE;;EACC,gBAAA;EACA,iBAAA;AFIH;AEMG;;;;;;;;EAAU,YAAA;AFIb;AEAG;;EAAU,YAAA;AFIb;AEAG;;EAAU,YAAA;AFIb;AEAG;;EAAU,YAAA;AFIb;AEAG;;EAAU,aAAA;AFIb;AEAG;;EAAU,YAAA;AFIb;AECG;;;EAAU,YAAA;AFIb;AEAG;;EAAU,YAAA;AFIb;AEAG;;EAAU,YAAA;AFIb;AEAG;;EAAU,YAAA;AFIb;AEAG;;EAAU,YAAA;AFIb;AEAG;;EAAU,YAAA;AFIb;AEAG;;EAAU,aAAA;AFIb;AEAG;;EAAU,aAAA;AFIb;AEAG;;EAAU,aAAA;AFIb;AECG;;;EAAU,aAAA;AFIb;AEAG;;EAAU,cAAA;AFIb;AEAG;;EAAU,cAAA;AFIb;AEAG;;EAAU,cAAA;AFIb;AEAG;;EAAU,cAAA;AFIb;AEAG;;EAAU,aAAA;AFIb;AEAG;;EAAU,aAAA;AFIb;;AEEA;;;;;;;;;;EAAA;AAYA;;EAEC;;IAAA;AFED;AEMG;;EAAU,iBAAA;AFFb;;AG9HA;EACC,WAAA;EACA,SAAA;AHiID;;AG5HC;;EACC,uBAAA;EACA,kBAAA;EACA,mBAAA;EACA,iBAAA;EACA,WAAA;EACA,YAAA;EACA,sCAAA;EACA,UAAA;EACA,iBAAA;EACA,2BAAA;EACA,6BAAA;EACA,WAAA;EACA,UAAA;AHgIF;AG9HE;;EACC,cAAA;EACA,0BAAA;EACA,eAAA;EACA,cAAA;EACA,kBAAA;EACA,oBAAA;EACA,QAAA;EACA,2BAAA;EACA,4BAAA;EAEA,mCAAA;EACA,kCAAA;AHgIH;AG7HE;;EAAmB,mBAAA;AHiIrB;AG9HG;;EACC,gBAAA;EACA,YAAA;AHiIJ;AG5HG;;EACC,gBAAA;EACA,YAAA;AH+HJ;;AGxHC;EACC,mBAAA;EACA,aAAA;EACA,mBAAA;EACA,YAAA;EACA,uBAAA;EACA,gBAAA;EACA,gBAAA;EACA,UAAA;AH2HF;AGzHE;EACC,cAAA;EACA,YAAA;AH2HH;AGzHG;EACC,uBAAA;EACA,mBAAA;EACA,iBAAA;EACA,WAAA;EACA,YAAA;EACA,iCAAA;EACA,WAAA;AH2HJ;AGrHE;EAAe,WAAA;AHwHjB;AGvHE;EAAe,YAAA;AH0HjB;;AGrHC;EAAoB,gBAAA;AHyHrB;;AGrHC;EACC,aAAA;AHwHF;AGtHE;EAAU,UAAA;AHyHZ;;AGrHA;EAAgC,qBAAA;AHyHhC;;AGpHE;;EACC,iBAAA;AHwHH;;ACxNC;;EACC,aAAA;AD4NF","file":"style.css"} \ No newline at end of file diff --git a/assets/js/blocks/general.js b/assets/js/blocks/general.js index 6c9b0b2e..fbaf07b5 100644 --- a/assets/js/blocks/general.js +++ b/assets/js/blocks/general.js @@ -44,6 +44,7 @@ wp.domReady(() => { wp.blocks.registerBlockVariation("core/group", { name: "lsx-tour-operator/price", title: "Price", + category: 'lsx-tour-operator', icon: "bank", attributes: { metadata: { diff --git a/assets/js/blocks/tour.js b/assets/js/blocks/tour.js index 1059ca6e..5b0c180b 100644 --- a/assets/js/blocks/tour.js +++ b/assets/js/blocks/tour.js @@ -159,136 +159,108 @@ wp.domReady(() => { allowedPostTypes: ['tour'] }); - // Price Included + Excluded - wp.registerBlockVariation( 'core/group', { - name: 'price-include-exclude', - title: 'Price Include & Exclude', - category: 'layout', + // Single Supplement + wp.blocks.registerBlockVariation('core/group', { + name: 'lsx-tour-operator/single-supplement-wrapper', + title: 'Single Supplement', + category: 'lsx-tour-operator', attributes: { - align: 'wide', - className: 'lsx-include-exclude-wrapper', + metadata: { + name: 'Single Supplement', + }, + className: 'lsx-single-supplement-wrapper', style: { spacing: { - padding: { - top: 'var:preset|spacing|x-small', - bottom: 'var:preset|spacing|x-small', - left: 'var:preset|spacing|x-small', - right: 'var:preset|spacing|x-small' - } - }, - border: { - radius: '8px', - width: '1px' + blockGap: '5px' } }, - backgroundColor: 'base', - borderColor: 'primary', layout: { - type: 'constrained' + type: 'flex', + flexWrap: 'nowrap' } }, innerBlocks: [ - [ - 'core/columns', { - align: 'wide', - style: { - spacing: { - blockGap: { - top: 'var:preset|spacing|medium', - left: 'var:preset|spacing|medium' - } - } - } - }, - [ - [ - 'core/column', { - width: '50%', - id: 'lsx-included-wrapper', + ['core/group', { style: { - spacing: { - blockGap: '0' - } - } + spacing: { + blockGap: '5px' + } + }, + layout: { + type: 'flex', + flexWrap: 'nowrap', + verticalAlignment: 'top' + } }, [ - [ - 'core/paragraph', { + ['core/image', { + id: 122733, + width: '20px', + sizeSlug: 'large', + linkDestination: 'none', + url: 'https://tour-operator.lsx.design/wp-content/uploads/2024/11/single-supplement-icon-black-52px-1.svg', + alt: '' + }], + ['core/paragraph', { style: { - elements: { - link: { - color: { - text: 'var:preset|color|primary-700' - } + spacing: { + padding: { + top: '2px', + bottom: '2px' + } } - } }, - textColor: 'primary-700', - fontSize: 'medium' - }, - [ 'Price Includes:' ] - ], - [ - 'core/paragraph', { - metadata: { - bindings: { - content: { - source: 'lsx/post-meta', - args: { key: 'included' } - } - } - } - }, - [] - ] + fontSize: 'x-small', + content: 'Single supplement:' + }] ] - ], - [ - 'core/column', { - width: '50%', - className: 'lsx-not-included-wrapper', + ], + ['core/group', { style: { - spacing: { - blockGap: '0' - } + spacing: { + blockGap: '5px' + }, + layout: { + type: 'flex', + flexWrap: 'nowrap' + } } }, [ - [ - 'core/paragraph', { - style: { - elements: { - link: { - color: { - text: 'var:preset|color|primary-700' + ['core/paragraph', { + metadata: { + bindings: { + content: { + source: 'lsx/post-meta', + args: { + key: 'single_supplement' + } + } } + }, + className: 'amount has-primary-color has-text-color has-link-color', + style: { + elements: { + link: { + color: { + text: 'var:preset|color|primary-700' + } + } + }, + spacing: { + padding: { + top: '2px', + bottom: '2px' + } } - } }, textColor: 'primary-700', - fontSize: 'medium' - }, - [ 'Price Excludes:' ] - ], - [ - 'core/paragraph', { - metadata: { - bindings: { - content: { - source: 'lsx/post-meta', - args: { key: 'not_included' } - } - } - } - }, - [] - ] - ] + content: '' + }] ] ] - ] ] - } ); + }); // Destination to Tour wp.blocks.registerBlockVariation("core/group", { @@ -326,7 +298,7 @@ wp.domReady(() => { [ 'core/image', { - width: 20, + width: '20px', sizeSlug: 'large', url: 'https://tour-operator.lsx.design/wp-content/uploads/2024/09/Typelocation-icon.png', alt: '' @@ -642,109 +614,6 @@ wp.domReady(() => { ] }); - // Single Supplement - wp.blocks.registerBlockVariation('core/group', { - name: 'lsx-tour-operator/single-supplement-wrapper', - title: 'Single Supplement', - category: 'lsx-tour-operator', - attributes: { - metadata: { - name: 'Single Supplement', - }, - className: 'lsx-single-supplement-wrapper', - style: { - spacing: { - blockGap: '5px' - } - }, - layout: { - type: 'flex', - flexWrap: 'nowrap' - } - }, - innerBlocks: [ - ['core/group', { - style: { - spacing: { - blockGap: '5px' - } - }, - layout: { - type: 'flex', - flexWrap: 'nowrap', - verticalAlignment: 'top' - } - }, - [ - ['core/image', { - id: 122733, - width: 20, - sizeSlug: 'large', - linkDestination: 'none', - url: 'https://tour-operator.lsx.design/wp-content/uploads/2024/11/single-supplement-icon-black-52px-1.svg', - alt: '' - }], - ['core/paragraph', { - style: { - spacing: { - padding: { - top: '2px', - bottom: '2px' - } - } - }, - fontSize: 'x-small', - content: 'Single supplement:' - }] - ] - ], - ['core/group', { - style: { - spacing: { - blockGap: '5px' - }, - layout: { - type: 'flex', - flexWrap: 'nowrap' - } - } - }, - [ - ['core/paragraph', { - metadata: { - bindings: { - content: { - source: 'lsx/post-meta', - args: { - key: 'single_supplement' - } - } - } - }, - className: 'has-primary-color has-text-color has-link-color', - style: { - elements: { - link: { - color: { - text: 'var:preset|color|primary-700' - } - } - }, - spacing: { - padding: { - top: '2px', - bottom: '2px' - } - } - }, - textColor: 'primary-700', - content: '' - }] - ] - ] - ] - }); - // Booking Validity wp.blocks.registerBlockVariation('core/group', { name: 'lsx-tour-operator/booking-validity-start', @@ -1086,4 +955,125 @@ wp.domReady(() => { ] ] }); + + // Price Included + Excluded + wp.blocks.registerBlockVariation( 'core/group', { + name: 'lsx-tour-operator/price-include-exclude', + title: 'Price Include & Exclude', + category: 'lsx-tour-operator', + attributes: { + align: 'wide', + metadata: { + name: 'Price Include & Exclude', + }, + className: 'lsx-include-exclude-wrapper', + style: { + spacing: { + padding: { + top: 'var:preset|spacing|x-small', + bottom: 'var:preset|spacing|x-small', + left: 'var:preset|spacing|x-small', + right: 'var:preset|spacing|x-small' + } + }, + border: { + radius: '8px', + width: '1px' + } + }, + backgroundColor: 'base', + borderColor: 'primary', + layout: { + type: 'constrained' + } + }, + innerBlocks: [ + [ 'core/columns', { + align: 'wide', + style: { + spacing: { + blockGap: { + top: 'var:preset|spacing|medium', + left: 'var:preset|spacing|medium' + } + } + } + }, + [ + ['core/column', { + width: '50%', + id: 'lsx-included-wrapper', + style: { + spacing: { + blockGap: '0' + } + } + }, + [ + [ 'core/paragraph', { + style: { + elements: { + link: { + color: { + text: 'var:preset|color|primary-700' + } + } + } + }, + textColor: 'primary-700', + fontSize: 'medium', + content: 'Price Includes:' + } ], + [ 'core/paragraph', { + metadata: { + bindings: { + content: { + source: 'lsx/post-meta', + args: { key: 'included' } + } + } + } + }] + ] + ], + [ 'core/column', { + width: '50%', + className: 'lsx-not-included-wrapper', + style: { + spacing: { + blockGap: '0' + } + } + }, + [ + [ 'core/paragraph', { + style: { + elements: { + link: { + color: { + text: 'var:preset|color|primary-700' + } + } + } + }, + textColor: 'primary-700', + fontSize: 'medium', + content: 'Price Excludes:' + }], + [ 'core/paragraph', { + metadata: { + bindings: { + content: { + source: 'lsx/post-meta', + args: { key: 'not_included' } + } + } + } + }] + ] + ] + ] + ] + ] + } ); }); diff --git a/includes/classes/blocks/class-bindings.php b/includes/classes/blocks/class-bindings.php index c13ecf1b..67f9ddde 100644 --- a/includes/classes/blocks/class-bindings.php +++ b/includes/classes/blocks/class-bindings.php @@ -68,7 +68,6 @@ public function __construct() { add_filter( 'render_block', array( $this, 'render_units_block' ), 10, 3 ); add_filter( 'render_block', array( $this, 'render_gallery_block' ), 10, 3 ); add_filter( 'render_block', array( $this, 'render_map_block' ), 10, 3 ); - add_filter( 'render_block', array( $this, 'maybe_hide_varitaion' ), 10, 3 ); } public function register_block_bindings() { @@ -133,6 +132,8 @@ public function post_connections_callback( $source_args, $block_instance ) { return ''; } + $value = ''; + switch ( $source_args['key'] ) { case 'post_children': @@ -173,7 +174,7 @@ public function post_connections_callback( $source_args, $block_instance ) { continue; } } - + $values[] = '' . get_the_title( $pid ) . ''; } $value = implode( ', ', $values ); @@ -211,15 +212,18 @@ public function post_meta_callback( $source_args, $block_instance ) { } $value = lsx_to_custom_field_query( $source_args['key'], '', '', false, get_the_ID(), $single ); - $date_transforms = [ - 'booking_validity_start', - 'booking_validity_end', - ]; - if ( in_array( $source_args['key'], $date_transforms ) ) { - $value = wp_date( 'j M Y', $value ); + if ( null !== $value ) { + $date_transforms = [ + 'booking_validity_start', + 'booking_validity_end', + ]; + if ( in_array( $source_args['key'], $date_transforms ) ) { + $value = wp_date( 'j M Y', $value ); + } + + $value = preg_replace( '/^
(.*?)<\/p>$/', '$1', $value ); } - - $value = preg_replace( '/^
(.*?)<\/p>$/', '$1', $value ); + } return $value; } @@ -307,9 +311,10 @@ public function build_itinerary_field( $build = '', $field = '', $count = 1 ) { $value = lsx_to_itinerary_description( false ); $pattern = '/
]*\bclass="[^"]*\bitinerary-description\b[^"]*"[^>]*>.*?<\/p>/is'; - if ( ! empty( $value ) ) { - $value = '
' . $value . ''; + if ( empty( $value ) ) { + $value = ''; } + $value = '' . $value . ''; } break; @@ -579,6 +584,10 @@ public function render_gallery_block( $block_content, $parsed_block, $block_obj return $block_content; } + if ( ! is_array( $gallery ) ) { + $gallery = [ $gallery ]; + } + $classes = $this->find_gallery_classes( $block_content ); $images = array(); @@ -679,126 +688,6 @@ public function render_map_block( $block_content, $parsed_block, $block_obj ) { return $block_content; } - /** - * A function to detect variation, and alter the query args. - * - * Following the https://developer.wordpress.org/news/2022/12/building-a-book-review-grid-with-a-query-loop-block-variation/ - * - * @param string|null $pre_render The pre-rendered content. Default null. - * @param array $parsed_block The block being rendered. - * @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block. - */ - public function maybe_hide_varitaion( $block_content, $parsed_block, $block_obj ) { - // Determine if this is the custom block variation. - if ( ! isset( $parsed_block['blockName'] ) || ! isset( $parsed_block['attrs'] ) ) { - return $block_content; - } - $allowed_blocks = array( - 'core/group', - ); - - if ( ! in_array( $parsed_block['blockName'], $allowed_blocks, true ) ) { - return $block_content; - } - if ( ! isset( $parsed_block['attrs']['className'] ) || '' === $parsed_block['attrs']['className'] || false === $parsed_block['attrs']['className'] ) { - return $block_content; - } - - $pattern = "/(lsx|facts)-(.*?)-wrapper/"; - preg_match( $pattern, $parsed_block['attrs']['className'], $matches ); - - if ( empty( $matches ) ) { - return $block_content; - } - - if ( ! empty( $matches ) && isset( $matches[0] ) ) { - // Save the first match to a variable - $key = str_replace( [ 'facts-', 'lsx-', '-wrapper' ], '', $matches[0] ); - } else { - return $block_content; - } - - /* - * 1 - Check if it is an itinerary or a units query - * 2 - See if it is a post query - * 3 - See if it is a taxonomy query - * 4 - Lastly default to the custom fields - */ - - if ( 0 < stripos( $key, '-query' ) ) { - - $query_key = str_replace( [ '-query' ], '', $key ); - $current_parent = get_post_parent( get_the_ID() ); - - switch ( $query_key ) { - case 'regions': - // If the current item is not a country - if ( null !== $current_parent ) { - return ''; - } - - if ( false === lsx_to_item_has_children( get_the_ID(), 'destination' ) ) { - return ''; - } - - break; - - case 'related-regions': - // If the current item is a country, then there wont be any other child regions. - if ( null === $current_parent ) { - return ''; - } - - if ( false === lsx_to_item_has_children( $current_parent, 'destination' ) ) { - return ''; - } - - break; - - case 'country': - // If the current item is not a country - if ( null === $current_parent ) { - return ''; - } - - break; - - default: - break; - } - } else if ( taxonomy_exists( $key ) ) { - // Check to see if this is a taxonomy or a custom field. - $tax_args = array( - 'fields' => 'ids' - ); - if ( empty( wp_get_post_terms( get_the_ID(), $key, $tax_args ) ) ) { - $block_content = ''; - } - } else { - $key = str_replace( '-', '_', $key ); - $key_array = [ $key ]; - $has_values = false; - - // If this is a wrapper that houses many fields, then we need to review them all. - if ( 'include_exclude' === $key ) { - $key_array = [ 'included', 'not_included' ]; - } - - foreach ( $key_array as $meta_key ) { - $value = lsx_to_custom_field_query( $meta_key, '', '', false ); - if ( ! empty( $value ) && '' !== $value ) { - $has_values = true; - } - } - - if ( false === $has_values ) { - $block_content = ''; - } - } - - return $block_content; - } - /** * Takes an array of IDs and iterate to return the post links. * diff --git a/includes/classes/blocks/class-registration.php b/includes/classes/blocks/class-registration.php index 5e3fdfe3..9db094b1 100644 --- a/includes/classes/blocks/class-registration.php +++ b/includes/classes/blocks/class-registration.php @@ -8,6 +8,11 @@ * @author LightSpeed */ class Registration { + + protected $disabled = []; + + protected $featured = []; + /** * Initialize the plugin by setting localization, filters, and administration functions. * @@ -18,6 +23,9 @@ class Registration { public function __construct() { add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_variations_script' ), 10 ); add_filter( 'query_loop_block_query_vars', array( $this, 'query_args_filter' ), 10, 2 ); + add_filter( 'render_block', array( $this, 'maybe_hide_varitaion' ), 10, 3 ); + + add_filter( 'posts_pre_query', array( $this, 'posts_pre_query' ), 10, 2 ); } /** @@ -94,6 +102,8 @@ public function query_args_filter( $query, $block ) { return $query; } + do_action( 'qm/debug', [ $key ] ); + switch ( $key ) { case 'regions': // We only restric this on the destination post type, in case the block is used on a landing page. @@ -114,6 +124,7 @@ public function query_args_filter( $query, $block ) { case 'featured-accommodation': case 'featured-tours': case 'featured-destinations': + $query['meta_query'] = array( 'relation' => 'OR', array( @@ -123,6 +134,14 @@ public function query_args_filter( $query, $block ) { ), ); + $featured_items = $this->find_featured_items( $query ); + if ( ! empty( $featured_items ) ) { + $query['lsx_to_featured'] = $key; + $this->featured[ $key ] = $featured_items; + } else { + $this->disabled[ $key ] = true; + } + break; // Accommodation relating to the tour via the destinations. @@ -174,6 +193,11 @@ public function query_args_filter( $query, $block ) { $query['post__in'] = $items; } } + + if ( ! isset( $query['post__in'] ) ) { + $this->disabled[ $key ] = true; + } + $query['post__not_in'] = $excluded_items; break; @@ -198,8 +222,10 @@ public function query_args_filter( $query, $block ) { if ( ! is_array( $found_items ) ) { $found_items = [ $found_items ]; } - $query['post__in'] = $found_items; + } else { + $this->disabled[ $key ] = true; + $query['post__in'] = [ get_the_ID() ]; } break; @@ -210,4 +236,195 @@ public function query_args_filter( $query, $block ) { return $query; } + + /** + * A function to detect variation, and alter the query args. + * + * Following the https://developer.wordpress.org/news/2022/12/building-a-book-review-grid-with-a-query-loop-block-variation/ + * + * @param string|null $pre_render The pre-rendered content. Default null. + * @param array $parsed_block The block being rendered. + * @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block. + */ + public function maybe_hide_varitaion( $block_content, $parsed_block, $block_obj ) { + // Determine if this is the custom block variation. + if ( ! isset( $parsed_block['blockName'] ) || ! isset( $parsed_block['attrs'] ) ) { + return $block_content; + } + $allowed_blocks = array( + 'core/group', + ); + + if ( ! in_array( $parsed_block['blockName'], $allowed_blocks, true ) ) { + return $block_content; + } + if ( ! isset( $parsed_block['attrs']['className'] ) || '' === $parsed_block['attrs']['className'] || false === $parsed_block['attrs']['className'] ) { + return $block_content; + } + + $pattern = "/(lsx|facts)-(.*?)-wrapper/"; + preg_match( $pattern, $parsed_block['attrs']['className'], $matches ); + + if ( empty( $matches ) ) { + return $block_content; + } + + if ( ! empty( $matches ) && isset( $matches[0] ) ) { + // Save the first match to a variable + $key = str_replace( [ 'facts-', 'lsx-', '-wrapper' ], '', $matches[0] ); + } else { + return $block_content; + } + + /* + * 1 - Check if it is an itinerary or a units query + * 2 - See if it is a post query + * 3 - See if it is a taxonomy query + * 4 - Lastly default to the custom fields + */ + + if ( 0 < stripos( $key, '-query' ) ) { + + $query_key = str_replace( [ '-query' ], '', $key ); + $current_parent = get_post_parent( get_the_ID() ); + + switch ( $query_key ) { + case 'regions': + // If the current item is not a country + if ( null !== $current_parent ) { + return ''; + } + + if ( false === lsx_to_item_has_children( get_the_ID(), 'destination' ) ) { + return ''; + } + + break; + + case 'related-regions': + // If the current item is a country, then there wont be any other child regions. + if ( null === $current_parent ) { + return ''; + } + + if ( false === lsx_to_item_has_children( $current_parent, 'destination' ) ) { + return ''; + } + + break; + + case 'country': + // If the current item is not a country + if ( null === $current_parent ) { + return ''; + } + + break; + + default: + if ( isset( $this->disabled[ $query_key ] ) ) { + return ''; + } + + break; + } + } else if ( taxonomy_exists( $key ) ) { + // Check to see if this is a taxonomy or a custom field. + $tax_args = array( + 'fields' => 'ids' + ); + if ( empty( wp_get_post_terms( get_the_ID(), $key, $tax_args ) ) ) { + $block_content = ''; + } + } else { + $key = str_replace( '-', '_', $key ); + $key_array = [ $key ]; + $has_values = false; + + // If this is a wrapper that houses many fields, then we need to review them all. + if ( 'include_exclude' === $key ) { + $key_array = [ 'included', 'not_included' ]; + } + + foreach ( $key_array as $meta_key ) { + $value = lsx_to_custom_field_query( $meta_key, '', '', false ); + + // we need to see if the posts exist before we can use them + if ( stripos( $meta_key, '_to_' ) && 0 === $this->post_ids_exist( $value ) ) { + continue; + } + + if ( ! empty( $value ) && '' !== $value ) { + $has_values = true; + } + } + + if ( false === $has_values ) { + $block_content = ''; + } + } + + return $block_content; + } + + /** + * Determines if a post exists based on the ID. + * + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $title Post title. + * @param string $content Optional. Post content. + * @param string $date Optional. Post date. + * @param string $type Optional. Post type. + * @param string $status Optional. Post status. + * @return int Post ID if post exists, 0 otherwise. + */ + protected function post_ids_exist( $ids ) { + global $wpdb; + + if ( is_array( $ids ) ) { + $ids = implode( ',', $ids ); + } + + $ids = wp_unslash( sanitize_post_field( 'id', $ids, 0, 'db' ) ); + + $query = "SELECT COUNT(ID) + FROM $wpdb->posts + WHERE 1=1 + AND ID IN (%s) + AND post_status IN ('draft', 'publish')"; + + return (int) $wpdb->get_var( $wpdb->prepare( $query, $ids ) ); + } + + /** + * This function will grab our Featured query so we dont have to redo that. + * + * @param null $posts + * @param WP_Query $query + * @return null|array + */ + public function posts_pre_query( $posts, $query ) { + if ( isset( $query->query['lsx_to_featured'] ) && isset( $this->featured[ $query->query['lsx_to_featured'] ] ) ) { + do_action( 'qm/debug', $this->featured[ $query->query['lsx_to_featured'] ] ); + $posts = $this->featured[ $query->query['lsx_to_featured'] ]; + } + return $posts; + } + + /** + * Find the featured items for the current query + * + * @param array $query + * @return array + */ + public function find_featured_items( $query ) { + $items = []; + $item_query = new \WP_Query( $query ); + if ( $item_query->have_posts() ) { + $items = $item_query->posts; + } + return $items; + } } diff --git a/includes/classes/legacy/class-accommodation.php b/includes/classes/legacy/class-accommodation.php index 2787c7e6..b96d28ef 100644 --- a/includes/classes/legacy/class-accommodation.php +++ b/includes/classes/legacy/class-accommodation.php @@ -118,7 +118,12 @@ function entry_class( $classes ) { * Adds in additional info for the price custom field */ public function price_filter( $html = '', $meta_key = false, $value = false, $before = '', $after = '' ) { - if ( get_post_type() === 'accommodation' && 'price' === $meta_key ) { + $currency_fields = [ + 'price', + 'single_supplement' + ]; + + if ( get_post_type() === 'accommodation' && in_array( $meta_key, $currency_fields ) ) { $price_type = get_post_meta( get_the_ID(), 'price_type', true ); $value = preg_replace( '/[^0-9,.]/', '', $value ); $value = ltrim( $value, '.' ); @@ -127,11 +132,9 @@ public function price_filter( $html = '', $meta_key = false, $value = false, $be $tour_operator = tour_operator(); $currency = ''; - if ( is_object( $tour_operator ) && isset( $tour_operator->options['general'] ) && is_array( $tour_operator->options['general'] ) ) { - if ( isset( $tour_operator->options['general']['currency'] ) && ! empty( $tour_operator->options['general']['currency'] ) ) { - $currency = $tour_operator->options['general']['currency']; - $currency = ' '; - } + if ( is_object( $tour_operator ) && isset( $tour_operator->options['currency'] ) && ! empty( $tour_operator->options['currency'] ) ) { + $currency = $tour_operator->options['currency']; + $currency = ' '; } $value = apply_filters( 'lsx_to_accommodation_price', $value, $price_type, $currency ); diff --git a/includes/classes/legacy/class-tour.php b/includes/classes/legacy/class-tour.php index c2b09e25..2b81f280 100644 --- a/includes/classes/legacy/class-tour.php +++ b/includes/classes/legacy/class-tour.php @@ -176,7 +176,12 @@ public function itinerary_needs_read_more( $return ) { * Adds in additional info for the price custom field */ public function price_filter( $html = '', $meta_key = false, $value = false, $before = '', $after = '' ) { - if ( get_post_type() === 'tour' && 'price' === $meta_key ) { + $currency_fields = [ + 'price', + 'single_supplement' + ]; + + if ( get_post_type() === 'tour' && in_array( $meta_key, $currency_fields ) ) { $value = preg_replace( '/[^0-9,.]/', '', $value ); $value = ltrim( $value, '.' ); $value = str_replace( ',', '', $value );