diff --git a/bootstrap.php b/bootstrap.php index 62ff823..a56d998 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -17,7 +17,7 @@ return; } -define( 'NFD_COMING_SOON_MODULE_VERSION', '1.2.5' ); +define( 'NFD_COMING_SOON_MODULE_VERSION', '1.2.6' ); require __DIR__ . '/includes/functions.php'; diff --git a/build/1.2.5/coming-soon-rtl.css b/build/1.2.5/coming-soon-rtl.css deleted file mode 100644 index 60f74e7..0000000 --- a/build/1.2.5/coming-soon-rtl.css +++ /dev/null @@ -1 +0,0 @@ -.modal-buttons{display:flex;justify-content:flex-end;margin-top:30px}@media only screen and (max-width:600px){.modal-buttons{align-items:stretch;flex-direction:column}}.modal-buttons svg{margin-top:5px}.modal-buttons .is-primary{box-shadow:none;margin-left:5px}.modal-buttons .is-secondary{box-shadow:none} diff --git a/build/1.2.5/coming-soon.asset.php b/build/1.2.5/coming-soon.asset.php deleted file mode 100644 index 56eee83..0000000 --- a/build/1.2.5/coming-soon.asset.php +++ /dev/null @@ -1 +0,0 @@ - array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '524851519375394dc45b'); diff --git a/build/1.2.5/coming-soon.css b/build/1.2.5/coming-soon.css deleted file mode 100644 index 30875d6..0000000 --- a/build/1.2.5/coming-soon.css +++ /dev/null @@ -1 +0,0 @@ -.modal-buttons{display:flex;justify-content:flex-end;margin-top:30px}@media only screen and (max-width:600px){.modal-buttons{align-items:stretch;flex-direction:column}}.modal-buttons svg{margin-top:5px}.modal-buttons .is-primary{box-shadow:none;margin-right:5px}.modal-buttons .is-secondary{box-shadow:none} diff --git a/build/1.2.5/coming-soon.js b/build/1.2.5/coming-soon.js deleted file mode 100644 index 66b31ca..0000000 --- a/build/1.2.5/coming-soon.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t);var n={};e.r(n),e.d(n,{setIsModalOpen:()=>c});var o={};e.r(o),e.d(o,{isModalOpen:()=>l});const i=window.React,r=window.wp.domReady;var s=e.n(r);const d=window.wp.element,a=window.wp.data;function c(e){return{type:"SET_MODAL_OPEN",isOpen:e}}function l(e){return e.modal.isOpen}const u={reducer:(0,a.combineReducers)({modal:function(e={isOpen:!1},t){return"SET_MODAL_OPEN"===t.type?{...e,isOpen:t.isOpen}:e}}),actions:n,selectors:o},w=(0,a.createReduxStore)("newfold/coming-soon",u);(0,a.register)(w);const p=window.wp.components,m=(window.wp.editPost,window.wp.i18n),C=window.wp.primitives,b=(0,i.createElement)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 22"},(0,i.createElement)(C.Path,{d:"M11.8667 10.975C12.0402 11.7092 12.0453 12.4732 11.8816 13.2097C11.718 13.9462 11.3898 14.6361 10.9216 15.2277C10.4534 15.8193 9.85744 16.2973 9.17829 16.6259C8.49915 16.9545 7.75445 17.1251 7 17.125V13.125M11.8667 10.975C13.4582 9.81565 14.753 8.29625 15.6451 6.5409C16.5373 4.78556 17.0016 2.84406 17 0.875003C15.0311 0.873581 13.0898 1.33791 11.3346 2.23006C9.57937 3.12221 8.0601 4.41688 6.90083 6.00834M11.8667 10.975C10.4183 12.0344 8.7586 12.7678 7 13.125M7 13.125C6.91417 13.1425 6.8275 13.1592 6.74083 13.175C5.98482 12.5755 5.30032 11.891 4.70083 11.135C4.71658 11.0482 4.73241 10.9615 4.75 10.875M6.90083 6.00834C6.16655 5.83467 5.40248 5.82944 4.66589 5.99304C3.9293 6.15664 3.23928 6.48483 2.64756 6.95301C2.05584 7.4212 1.57775 8.01723 1.24912 8.69645C0.9205 9.37567 0.749863 10.1205 0.75 10.875H4.75M6.90083 6.00834C5.84157 7.45652 5.10729 9.11671 4.75 10.875M2.88417 12.8667C2.33598 13.2743 1.90977 13.8242 1.65169 14.4567C1.3936 15.0892 1.31348 15.7802 1.42 16.455C2.09486 16.5614 2.78597 16.4812 3.41848 16.2229C4.05099 15.9647 4.6008 15.5383 5.00833 14.99M12.625 6.5C12.625 6.83152 12.4933 7.14947 12.2589 7.38389C12.0245 7.61831 11.7065 7.75 11.375 7.75C11.0435 7.75 10.7255 7.61831 10.4911 7.38389C10.2567 7.14947 10.125 6.83152 10.125 6.5C10.125 6.16848 10.2567 5.85054 10.4911 5.61612C10.7255 5.3817 11.0435 5.25 11.375 5.25C11.7065 5.25 12.0245 5.3817 12.2589 5.61612C12.4933 5.85054 12.625 6.16848 12.625 6.5Z",stroke:"white","stroke-width":"1.15","stroke-linecap":"round","stroke-linejoin":"round"})),y=window.wp.apiFetch;var h=e.n(y);const f=()=>{const{setIsModalOpen:e}=(0,a.useDispatch)(w),[t,n]=(0,i.useState)(!0),{isModalOpen:o}=(0,a.useSelect)((e=>({isModalOpen:e(w).isModalOpen()})));if(!o||!t)return null;const r=(0,m.__)("Ready to launch your Site?","nfd-coming-soon"),s=(0,m.__)("Pages and posts you publish will not be visible to the public until you launch your site.","nfd-coming-soon"),d=(0,m.__)("Publish & Launch Site","nfd-coming-soon"),c=(0,m.__)("Publish without launching","nfd-coming-soon");return(0,i.createElement)(p.Modal,{title:r,onRequestClose:()=>e(!1)},(0,i.createElement)("div",null,(0,i.createElement)("p",null,s),(0,i.createElement)("div",{className:"modal-buttons"},(0,i.createElement)(p.Button,{icon:(0,i.createElement)(p.Icon,{icon:b}),variant:"primary",onClick:()=>{!async function(e){await async function(e){const t={body:null,error:null};try{t.body=await e}catch(e){t.error=e}return t}(h()({url:"/index.php?rest_route=/bluehost/v1/settings&_locale=user",method:"POST",data:{comingSoon:!1}}).then())}(),n(!1),e(!1)}},d),(0,i.createElement)(p.Button,{variant:"secondary",onClick:()=>e(!1)},c))))};s()((()=>{g("nfd-pre-publish-modal")}));const g=e=>{const t=document.createElement("div");t.id=e,document.getElementById(e)||document.body.append(t),(0,d.render)((0,i.createElement)(f,null),t)},O=()=>{const e=window.wp.data.select("core/editor").getEditedPostAttribute("status");void 0!==e?(e=>{if("publish"!==e){const e=(0,a.subscribe)((()=>{if("publish"===window.wp.data.select("core/editor").getEditedPostAttribute("status")){e();const t=()=>{document.querySelector(".components-snackbar-list__notice-container")?(0,a.dispatch)(w).setIsModalOpen(!0):setTimeout(t,50)};t()}}))}})(e):setTimeout(O,50)};O(),((window.newfold=window.newfold||{}).ComingSoon=window.newfold.ComingSoon||{})["coming-soon"]=t})(); \ No newline at end of file diff --git a/build/1.2.6/coming-soon.asset.php b/build/1.2.6/coming-soon.asset.php new file mode 100644 index 0000000..d2c03ef --- /dev/null +++ b/build/1.2.6/coming-soon.asset.php @@ -0,0 +1 @@ + array('react', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '99d786ddc46b8ca5c7b2'); diff --git a/build/1.2.6/coming-soon.js b/build/1.2.6/coming-soon.js new file mode 100644 index 0000000..493d195 --- /dev/null +++ b/build/1.2.6/coming-soon.js @@ -0,0 +1 @@ +(()=>{"use strict";var e={n:n=>{var t=n&&n.__esModule?()=>n.default:()=>n;return e.d(t,{a:t}),t},d:(n,t)=>{for(var o in t)e.o(t,o)&&!e.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:t[o]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n);var t={};e.r(t),e.d(t,{setIsModalOpen:()=>a});var o={};e.r(o),e.d(o,{isModalOpen:()=>c});const i=window.React,l=window.wp.domReady;var s=e.n(l);const d=window.wp.element,r=window.wp.data;function a(e){return{type:"SET_MODAL_OPEN",isOpen:e}}function c(e){return e.modal.isOpen}const u={reducer:(0,r.combineReducers)({modal:function(e={isOpen:!1},n){return"SET_MODAL_OPEN"===n.type?{...e,isOpen:n.isOpen}:e}}),actions:t,selectors:o},p=(0,r.createReduxStore)("newfold/coming-soon",u);(0,r.register)(p);const w=window.wp.components,m=window.wp.i18n,f=()=>{const{setIsModalOpen:e}=(0,r.useDispatch)(p),{isModalOpen:n}=(0,r.useSelect)((e=>({isModalOpen:e(p).isModalOpen()})));if(!n||!window.NewfoldRuntime.comingSoon.isEnabled)return null;const t=(0,m.__)("Ready to launch your Site?","nfd-coming-soon"),o=(0,m.__)("Pages and posts you publish will not be visible to the public until you launch your site.","nfd-coming-soon"),l=(0,m.__)("Publish & Launch Site","nfd-coming-soon"),s=(0,m.__)("Publish Without Launching","nfd-coming-soon");return(0,i.createElement)(w.Modal,{title:t,onRequestClose:()=>e(!1)},(0,i.createElement)("div",null,(0,i.createElement)("p",null,o),(0,i.createElement)("br",null),(0,i.createElement)("div",{style:{alignContent:"space-between",display:"flex",flexWrap:"wrap",gap:"16px",boxSizing:"inherit"}},(0,i.createElement)(w.Button,{variant:"primary",onClick:()=>{window.NewfoldRuntime.comingSoon.disable(),e(!1)},style:{flex:1,justifyContent:"center"}},l),(0,i.createElement)(w.Button,{variant:"link",onClick:()=>e(!1),style:{flex:1,justifyContent:"center"}},s))))};s()((()=>{b("nfd-pre-publish-modal")}));const b=e=>{const n=document.createElement("div");n.id=e,document.getElementById(e)||document.body.append(n),(0,d.render)((0,i.createElement)(f,null),n)},y=()=>{const e=window.wp.data.select("core/editor").getEditedPostAttribute("status");void 0!==e?(e=>{if("publish"!==e){const e=(0,r.subscribe)((()=>{if("publish"===window.wp.data.select("core/editor").getEditedPostAttribute("status")){e();const n=()=>{document.querySelector(".components-snackbar-list__notice-container")?(0,r.dispatch)(p).setIsModalOpen(!0):setTimeout(n,50)};n()}}))}})(e):setTimeout(y,50)};y(),((window.newfold=window.newfold||{}).ComingSoon=window.newfold.ComingSoon||{})["coming-soon"]=n})(); \ No newline at end of file diff --git a/composer.json b/composer.json index 2ff6a0e..99356e5 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ ] }, "require-dev": { - "newfold-labs/wp-php-standards": "^1.2" + "newfold-labs/wp-php-standards": "^1.2.4" }, "scripts": { "fix": [ @@ -46,7 +46,7 @@ } }, "require": { - "newfold-labs/wp-module-data": ">=2.4.18", + "newfold-labs/wp-module-data": ">=2.6.2", "wp-forge/wp-upgrade-handler": "^1.0" } } diff --git a/package-lock.json b/package-lock.json index 15cefd1..1e7fa06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,11 @@ { "name": "wp-module-coming-soon", - "version": "1.2.3", + "version": "1.2.6", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "wp-module-coming-soon", - "version": "1.2.3", + "version": "1.2.6", "license": "GPL-2.0-or-later", "dependencies": { "@newfold-labs/js-utility-ui-analytics": "1.2.0", diff --git a/package.json b/package.json index 458c253..2d3bed2 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.2.5", + "version": "1.2.6", "description": "Coming Soon", "license": "GPL-2.0-or-later", "private": true, diff --git a/src/coming-soon.js b/src/coming-soon.js index e7974e7..03ed96f 100644 --- a/src/coming-soon.js +++ b/src/coming-soon.js @@ -1,8 +1,3 @@ -/** - * Styles. - */ -import './styles/app.scss'; - /** * WordPress dependencies */ diff --git a/src/components/Icons/index.js b/src/components/Icons/index.js deleted file mode 100644 index 4228a6a..0000000 --- a/src/components/Icons/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default as launch } from './launch'; diff --git a/src/components/Icons/launch.jsx b/src/components/Icons/launch.jsx deleted file mode 100644 index 29b08e7..0000000 --- a/src/components/Icons/launch.jsx +++ /dev/null @@ -1,12 +0,0 @@ -/** - * WordPress dependencies - */ -import { Path, SVG } from '@wordpress/primitives'; - -const launch = ( - - - -); - -export default launch; diff --git a/src/components/Modal.jsx b/src/components/Modal.jsx index 2dced53..fa0d329 100644 --- a/src/components/Modal.jsx +++ b/src/components/Modal.jsx @@ -1,63 +1,78 @@ /** * External dependencies */ -import { useState } from 'react'; +import { useState } from '@wordpress/element'; /** * WordPress dependencies */ -import { Modal as WP2Modal, Button, Icon } from '@wordpress/components'; +import { Modal as WP2Modal, Button } from '@wordpress/components'; import { useDispatch, useSelect } from '@wordpress/data'; -import { useEffect } from '@wordpress/element'; -import { store as editPostStore } from '@wordpress/edit-post'; import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ -import { launch } from './Icons'; import { store as nfdComingSoonStore } from '../store'; -import { setComingSoon } from '../utils/api/comingSoon'; - const Modal = () => { const { setIsModalOpen } = useDispatch(nfdComingSoonStore); - const [isComingSoonActive, setIsComingSoonActive] = useState(true); - const { isModalOpen } = useSelect( - (select) => ({ - isModalOpen: select(nfdComingSoonStore).isModalOpen(), - }) - ); + const { isModalOpen } = useSelect((select) => ({ + isModalOpen: select(nfdComingSoonStore).isModalOpen(), + })); const handlePublishAndLaunch = () => { - setComingSoon(false); - setIsComingSoonActive(false); + window.NewfoldRuntime.comingSoon.disable(); setIsModalOpen(false); }; - if (!isModalOpen || !isComingSoonActive) { + if (!isModalOpen || !window.NewfoldRuntime.comingSoon.isEnabled) { return null; } const title = __('Ready to launch your Site?', 'nfd-coming-soon'); - const heading = __('Pages and posts you publish will not be visible to the public until you launch your site.', 'nfd-coming-soon'); + const heading = __( + 'Pages and posts you publish will not be visible to the public until you launch your site.', + 'nfd-coming-soon' + ); const launchButtonText = __('Publish & Launch Site', 'nfd-coming-soon'); - const withoutLaunchButtonText = __('Publish without launching', 'nfd-coming-soon'); + const withoutLaunchButtonText = __( + 'Publish Without Launching', + 'nfd-coming-soon' + ); return ( - setIsModalOpen(false)} - > + setIsModalOpen(false)}>

{heading}

-
+
+
-
diff --git a/src/styles/_mixins.scss b/src/styles/_mixins.scss deleted file mode 100644 index 8a38f2d..0000000 --- a/src/styles/_mixins.scss +++ /dev/null @@ -1,15 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* Mixins */ -/* -------------------------------------------------------------------------- */ - -/** - * Responsive mixin - * @param {string} $breakpoint - breakpoint name. Possible values are: small -*/ -@mixin responsive($breakpoint) { - @if $breakpoint == small { - @media only screen and (max-width: 600px) { - @content; - } - } -} diff --git a/src/styles/app.scss b/src/styles/app.scss deleted file mode 100644 index 4b50cdd..0000000 --- a/src/styles/app.scss +++ /dev/null @@ -1,4 +0,0 @@ -@use "modal"; - -@tailwind components; -@tailwind utilities; diff --git a/src/styles/modal.scss b/src/styles/modal.scss deleted file mode 100644 index fa86d29..0000000 --- a/src/styles/modal.scss +++ /dev/null @@ -1,26 +0,0 @@ -@use "mixins" as m; - -.modal-buttons { - - @include m.responsive(small) { - flex-direction: column; - align-items: stretch; - } - - display: flex; - justify-content: flex-end; - margin-top: 30px; - - svg { - margin-top: 5px; - } - - .is-primary { - margin-right: 5px; - box-shadow: none; - } - - .is-secondary { - box-shadow: none; - } -} diff --git a/src/utils/api/comingSoon.js b/src/utils/api/comingSoon.js deleted file mode 100644 index 8dfb287..0000000 --- a/src/utils/api/comingSoon.js +++ /dev/null @@ -1,16 +0,0 @@ -import { wpSettingsRestRoute } from '../../constants'; -import { resolve } from './resolve'; - -import apiFetch from '@wordpress/api-fetch'; - -export async function setComingSoon( comingSoon ) { - return await resolve( - apiFetch( { - url: wpSettingsRestRoute, - method: 'POST', - data: { - comingSoon, - }, - } ).then() - ); -} diff --git a/src/utils/api/resolve.js b/src/utils/api/resolve.js deleted file mode 100644 index cc363cd..0000000 --- a/src/utils/api/resolve.js +++ /dev/null @@ -1,14 +0,0 @@ -export async function resolve(promise) { - const resolved = { - body: null, - error: null - }; - - try { - resolved.body = await promise; - } catch (e) { - resolved.error = e; - } - - return resolved; -}