6 lines
34 KiB
JavaScript
6 lines
34 KiB
JavaScript
!function(){var e={703:function(e,t,n){"use strict";var r=n(414);function i(){}function a(){}a.resetWarningCache=i,e.exports=function(){function e(e,t,n,i,a,s){if(s!==r){var o=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw o.name="Invariant Violation",o}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:i};return n.PropTypes=n,n}},697:function(e,t,n){e.exports=n(703)()},414:function(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},216:function(e,t,n){"use strict";t.be=void 0;var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=n(196),a=c(i),s=c(n(697)),o=n(81),l=c(n(315)),p=c(n(282)),u=c(n(821));function c(e){return e&&e.__esModule?e:{default:e}}var m="data-lazyload-listened",h=[],g=[],f=!1;try{var d=Object.defineProperty({},"passive",{get:function(){f=!0}});window.addEventListener("test",null,d)}catch(e){}var v=!!f&&{capture:!1,passive:!0},b=function(e){var t=e.ref;if(t instanceof HTMLElement){var n=(0,l.default)(t),r=e.props.overflow&&n!==t.ownerDocument&&n!==document&&n!==document.documentElement?function(e,t){var n=e.ref,r=void 0,i=void 0,a=void 0,s=void 0;try{var o=t.getBoundingClientRect();r=o.top,i=o.left,a=o.height,s=o.width}catch(e){r=0,i=0,a=0,s=0}var l=window.innerHeight||document.documentElement.clientHeight,p=window.innerWidth||document.documentElement.clientWidth,u=Math.max(r,0),c=Math.max(i,0),m=Math.min(l,r+a)-u,h=Math.min(p,i+s)-c,g=void 0,f=void 0,d=void 0,v=void 0;try{var b=n.getBoundingClientRect();g=b.top,f=b.left,d=b.height,v=b.width}catch(e){g=0,f=0,d=0,v=0}var y=g-u,_=f-c,E=Array.isArray(e.props.offset)?e.props.offset:[e.props.offset,e.props.offset];return y-E[0]<=m&&y+d+E[1]>=0&&_-E[0]<=h&&_+v+E[1]>=0}(e,n):function(e){var t=e.ref;if(!(t.offsetWidth||t.offsetHeight||t.getClientRects().length))return!1;var n=void 0,r=void 0;try{var i=t.getBoundingClientRect();n=i.top,r=i.height}catch(e){n=0,r=0}var a=window.innerHeight||document.documentElement.clientHeight,s=Array.isArray(e.props.offset)?e.props.offset:[e.props.offset,e.props.offset];return n-s[0]<=a&&n+r+s[1]>=0}(e);r?e.visible||(e.props.once&&g.push(e),e.visible=!0,e.forceUpdate()):e.props.once&&e.visible||(e.visible=!1,e.props.unmountIfInvisible&&e.forceUpdate())}},y=function(){for(var e=0;e<h.length;++e){var t=h[e];b(t)}g.forEach((function(e){var t=h.indexOf(e);-1!==t&&h.splice(t,1)})),g=[]},_=void 0,E=null,w=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.visible=!1,n.setRef=n.setRef.bind(n),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),r(t,[{key:"componentDidMount",value:function(){var e=window,t=this.props.scrollContainer;t&&"string"==typeof t&&(e=e.document.querySelector(t));var n=void 0!==this.props.debounce&&"throttle"===_||"debounce"===_&&void 0===this.props.debounce;if(n&&((0,o.off)(e,"scroll",E,v),(0,o.off)(window,"resize",E,v),E=null),E||(void 0!==this.props.debounce?(E=(0,p.default)(y,"number"==typeof this.props.debounce?this.props.debounce:300),_="debounce"):void 0!==this.props.throttle?(E=(0,u.default)(y,"number"==typeof this.props.throttle?this.props.throttle:300),_="throttle"):E=y),this.props.overflow){var r=(0,l.default)(this.ref);if(r&&"function"==typeof r.getAttribute){var i=+r.getAttribute(m)+1;1===i&&r.addEventListener("scroll",E,v),r.setAttribute(m,i)}}else if(0===h.length||n){var a=this.props,s=a.scroll,c=a.resize;s&&(0,o.on)(e,"scroll",E,v),c&&(0,o.on)(window,"resize",E,v)}h.push(this),b(this)}},{key:"shouldComponentUpdate",value:function(){return this.visible}},{key:"componentWillUnmount",value:function(){if(this.props.overflow){var e=(0,l.default)(this.ref);if(e&&"function"==typeof e.getAttribute){var t=+e.getAttribute(m)-1;0===t?(e.removeEventListener("scroll",E,v),e.removeAttribute(m)):e.setAttribute(m,t)}}var n=h.indexOf(this);-1!==n&&h.splice(n,1),0===h.length&&"undefined"!=typeof window&&((0,o.off)(window,"resize",E,v),(0,o.off)(window,"scroll",E,v))}},{key:"setRef",value:function(e){e&&(this.ref=e)}},{key:"render",value:function(){var e=this.props,t=e.height,n=e.children,r=e.placeholder,i=e.className,s=e.classNamePrefix,o=e.style;return a.default.createElement("div",{className:s+"-wrapper "+i,ref:this.setRef,style:o},this.visible?n:r||a.default.createElement("div",{style:{height:t},className:s+"-placeholder"}))}}]),t}(i.Component);w.propTypes={className:s.default.string,classNamePrefix:s.default.string,once:s.default.bool,height:s.default.oneOfType([s.default.number,s.default.string]),offset:s.default.oneOfType([s.default.number,s.default.arrayOf(s.default.number)]),overflow:s.default.bool,resize:s.default.bool,scroll:s.default.bool,children:s.default.node,throttle:s.default.oneOfType([s.default.number,s.default.bool]),debounce:s.default.oneOfType([s.default.number,s.default.bool]),placeholder:s.default.node,scrollContainer:s.default.oneOfType([s.default.string,s.default.object]),unmountIfInvisible:s.default.bool,style:s.default.object},w.defaultProps={className:"",classNamePrefix:"lazyload",once:!1,offset:0,overflow:!1,resize:!1,scroll:!0,unmountIfInvisible:!1},t.ZP=w,t.be=y},282:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n){var r=void 0,i=void 0,a=void 0,s=void 0,o=void 0,l=function l(){var p=+new Date-s;p<t&&p>=0?r=setTimeout(l,t-p):(r=null,n||(o=e.apply(a,i),r||(a=null,i=null)))};return function(){a=this,i=arguments,s=+new Date;var p=n&&!r;return r||(r=setTimeout(l,t)),p&&(o=e.apply(a,i),a=null,i=null),o}}},81:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.on=function(e,t,n,r){r=r||!1,e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on"+t,(function(t){n.call(e,t||window.event)}))},t.off=function(e,t,n,r){r=r||!1,e.removeEventListener?e.removeEventListener(t,n,r):e.detachEvent&&e.detachEvent("on"+t,n)}},315:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){if(!(e instanceof HTMLElement))return document.documentElement;for(var t="absolute"===e.style.position,n=/(scroll|auto)/,r=e;r;){if(!r.parentNode)return e.ownerDocument||document.documentElement;var i=window.getComputedStyle(r),a=i.position,s=i.overflow,o=i["overflow-x"],l=i["overflow-y"];if("static"===a&&t)r=r.parentNode;else{if(n.test(s)&&n.test(o)&&n.test(l))return r;r=r.parentNode}}return e.ownerDocument||e.documentElement||document.documentElement}},821:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n){var r,i;return t||(t=250),function(){var a=n||this,s=+new Date,o=arguments;r&&s<r+t?(clearTimeout(i),i=setTimeout((function(){r=s,e.apply(a,o)}),t)):(r=s,e.apply(a,o))}}},196:function(e){"use strict";e.exports=window.React}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(t,n){return function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,s,o=[],l=!0,p=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=a.call(n)).done)&&(o.push(r.value),o.length!==t);l=!0);}catch(e){p=!0,i=e}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(p)throw i}}return o}}(t,n)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(a=i.key,s=void 0,s=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(a),"symbol"===r(s)?s:String(s)),i)}var a,s}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}function o(e){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},o(e)}var l=n(196),p=n(216);function u(e,t,n){var r=n&&n.lexicographical,i=n&&n.zeroExtend,a=e.split("."),s=t.split(".");function o(e){return(r?/^\d+[A-Za-z]*$/:/^\d+$/).test(e)}if(!a.every(o)||!s.every(o))return NaN;if(i){for(;a.length<s.length;)a.push("0");for(;s.length<a.length;)s.push("0")}r||(a=a.map(Number),s=s.map(Number));for(var l=0;l<a.length;++l){if(s.length===l)return 1;if(a[l]!==s[l])return a[l]>s[l]?1:-1}return a.length!==s.length?-1:0}var c=window.wp.i18n,m=window.wp.components,h=window.wp.element,g=window.wp.htmlEntities,f=window.wp.apiFetch,d=n.n(f);function v(e){var t=e.allSites,n=e.value,r=e.onChange;if(!t)return null;var i=[""];return Object.keys(t).forEach((function(e){t[e].category.forEach((function(e){i.includes(e)||i.push(e)}))})),i.length<2?null:(0,l.createElement)("div",null,i.map((function(e){return(0,l.createElement)(m.Button,{key:e,variant:e===n?"primary":"",onClick:function(){return r(e)}},""===e?(0,c.__)("All","gp-premium"):e)})))}function b(e){var t=e.onChange,n=e.value;return(0,l.createElement)("div",null,(0,l.createElement)("input",{type:"search",onChange:function(e){var n;return t(null==e||null===(n=e.target)||void 0===n?void 0:n.value)},value:n,placeholder:(0,c.__)("Search site name or author","gp-premium")}))}var y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}(w,e);var n,f,y,_,E=(y=w,_=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=o(y);if(_){var n=o(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return a(e)}(this,e)});function w(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,w),(e=E.apply(this,arguments)).state={allSites:{},isAPIWorking:!1,siteOpened:!1,siteData:{},siteSlug:"",sitePlugins:{},hasData:{},hasWidgets:!1,importOptions:!0,importContent:!0,confirmImport:!1,importComplete:!1,installablePlugins:[],activePlugins:[],manualPlugins:[],refreshingSites:!1,hasBackup:gppSiteLibrary.hasBackup,category:"",search:"",device:"desktop"},e.importThemeOptions=e.importThemeOptions.bind(a(e)),e.installPlugins=e.installPlugins.bind(a(e)),e.activatePlugins=e.activatePlugins.bind(a(e)),e.importContent=e.importContent.bind(a(e)),e.importSiteOptions=e.importSiteOptions.bind(a(e)),e.importWidgets=e.importWidgets.bind(a(e)),e}return n=w,(f=[{key:"componentDidMount",value:function(){var e=this;d()({path:"/generatepress-site-library/v1/get_sites",method:"POST",data:{forceRefresh:!1}}).then((function(t){e.setState({isAPILoaded:!0,allSites:t.response})}))}},{key:"importThemeOptions",value:function(e){var t=this,n=e.target.nextElementSibling;n.classList.add("gpp-library-action-message--show"),n.textContent=(0,c.__)("Importing theme options","gp-premium"),d()({path:"/generatepress-site-library/v1/import_theme_options",method:"POST",data:{siteData:this.state.siteData,siteSlug:this.state.siteData.name.replace(/\s+/g,"_").toLowerCase(),importOptions:this.state.importOptions,importContent:this.state.importContent}}).then((function(e){n.textContent=e.response,e.success&&e.response||n.classList.add("gblocks-action-message--error"),setTimeout((function(){t.state.importContent?Object.keys(t.state.hasData.plugin_data).length>0?t.installPlugins(n):t.importContent(n):(n.textContent=(0,c.__)("Import Complete","gp-premium"),t.setState({isAPIWorking:!1,importComplete:!0,hasBackup:!0}))}),2e3)}))}},{key:"installPlugins",value:function(e){var n=this;void 0!==e.target&&(e=e.target.nextElementSibling),e.classList.add("gpp-library-action-message--show"),e.textContent=(0,c.__)("Installing plugins","gp-premium"),Object.entries(this.state.hasData.plugin_data).forEach((function(r){var i=t(r,2),a=i[0],s=i[1],o=s.slug.split("/")[0],l=s.name;s.installed?(delete n.state.hasData.plugin_data[a],0===Object.keys(n.state.hasData.plugin_data).length&&n.activatePlugins(e)):("bb-plugin"===o&&(o="beaver-builder-lite-version",l="Beaver Builder Lite"),e.textContent=(0,c.sprintf)(/* translators: Installing "Plugin Name" */
|
|
(0,c.__)("Installing %s","gp-premium"),l),wp.updates.installPlugin({slug:o,success:function(t){console.log(t),delete n.state.hasData.plugin_data[a],0===Object.keys(n.state.hasData.plugin_data).length&&n.activatePlugins(e)},error:function(t){console.log(t),delete n.state.hasData.plugin_data[a],0===Object.keys(n.state.hasData.plugin_data).length&&n.activatePlugins(e)}}))}))}},{key:"activatePlugins",value:function(e){var t=this;e.classList.add("gpp-library-action-message--show"),e.textContent=(0,c.__)("Activating plugins","gp-premium"),d()({path:"/generatepress-site-library/v1/activate_plugins",method:"POST",data:{siteData:this.state.siteData,siteSlug:this.state.siteData.name.replace(/\s+/g,"_").toLowerCase(),importOptions:this.state.importOptions,importContent:this.state.importContent}}).then((function(n){e.textContent=n.response,n.success&&n.response||e.classList.add("gblocks-action-message--error"),setTimeout((function(){t.importContent(e)}),2e3)}))}},{key:"importContent",value:function(e){var t=this;e.classList.add("gpp-library-action-message--show"),e.textContent=(0,c.__)("Importing content","gp-premium"),d()({path:"/generatepress-site-library/v1/import_content",method:"POST",data:{siteData:this.state.siteData,siteSlug:this.state.siteData.name.replace(/\s+/g,"_").toLowerCase(),importOptions:this.state.importOptions,importContent:this.state.importContent}}).then((function(n){e.textContent=n.response,n.success&&n.response||e.classList.add("gblocks-action-message--error"),setTimeout((function(){t.importSiteOptions(e)}),2e3)}))}},{key:"importSiteOptions",value:function(e){var t=this;e.classList.add("gpp-library-action-message--show"),e.textContent=(0,c.__)("Importing site options","gp-premium"),d()({path:"/generatepress-site-library/v1/import_site_options",method:"POST",data:{siteData:this.state.siteData,siteSlug:this.state.siteData.name.replace(/\s+/g,"_").toLowerCase(),importOptions:this.state.importOptions,importContent:this.state.importContent}}).then((function(n){e.textContent=n.response,n.success&&n.response||e.classList.add("gblocks-action-message--error"),setTimeout((function(){t.state.hasWidgets?t.importWidgets(e):(e.textContent=(0,c.__)("Import Complete","gp-premium"),t.setState({isAPIWorking:!1,importComplete:!0,hasBackup:!0}))}),2e3)}))}},{key:"importWidgets",value:function(e){var t=this;e.classList.add("gpp-library-action-message--show"),e.textContent=(0,c.__)("Importing widgets","gp-premium"),d()({path:"/generatepress-site-library/v1/import_widgets",method:"POST",data:{siteData:this.state.siteData,siteSlug:this.state.siteData.name.replace(/\s+/g,"_").toLowerCase(),importOptions:this.state.importOptions,importContent:this.state.importContent}}).then((function(n){e.textContent=n.response,n.success&&n.response||e.classList.add("gblocks-action-message--error"),setTimeout((function(){e.textContent=(0,c.__)("Import Complete","gp-premium"),t.setState({isAPIWorking:!1,importComplete:!0,hasBackup:!0})}),2e3)}))}},{key:"restoreBackup",value:function(e){var t=this,n=e.target.nextElementSibling;n.classList.add("gpp-library-action-message--show"),n.textContent=(0,c.__)("Restoring theme options","gp-premium"),d()({path:"/generatepress-site-library/v1/restore_theme_options",method:"POST"}).then((function(e){n.textContent=e.response,e.success&&e.response||n.classList.add("gblocks-action-message--error"),setTimeout((function(){n.textContent=(0,c.__)("Restoring content","gp-premium"),d()({path:"/generatepress-site-library/v1/restore_content",method:"POST"}).then((function(e){n.textContent=e.response,e.success&&e.response||n.classList.add("gblocks-action-message--error"),t.setState({isAPIWorking:!1,hasBackup:!1})}))}),2e3)}))}},{key:"render",value:function(){var e=this;if(!this.state.isAPILoaded)return(0,l.createElement)(m.Placeholder,{className:"gpp-library-placeholder"},(0,l.createElement)(m.Spinner,null));var n=this.state.allSites;if(!n||"no results"===n)return(0,l.createElement)("div",{className:"generatepress-site-library-no-results"},(0,l.createElement)("p",null,(0,c.__)("No sites were found.","gp-premium")," ",(0,l.createElement)("a",{href:"https://docs.generatepress.com/article/site-library-unavailable/",target:"_blank",rel:"noreferrer noopener"},(0,c.__)("Why?","gp-premium"))),(0,l.createElement)(m.Button,{variant:"primary",onClick:function(){e.setState({refreshingSites:!0}),d()({path:"/generatepress-site-library/v1/get_sites",method:"POST",data:{forceRefresh:!0}}).then((function(t){e.setState({isAPILoaded:!0,allSites:t.response,refreshingSites:!1})}))}},this.state.refreshingSites&&(0,l.createElement)(m.Spinner,null),!this.state.refreshingSites&&(0,c.__)("Try again","gp-premium")));var r="";"tablet"===this.state.device&&(r="768px"),"mobile"===this.state.device&&(r="480px");var i=this.state.siteData.author_name&&this.state.siteData.author_url&&"GeneratePress"!==this.state.siteData.author_name;return(0,l.createElement)(h.Fragment,null,(0,l.createElement)("div",{className:"generatepress-site-library"},!!this.state.hasBackup&&(0,l.createElement)("div",{className:"generatepress-site-library-restore"},(0,l.createElement)("h2",null,(0,c.__)("Existing Site Import Detected","gp-premium")),(0,l.createElement)("p",null,(0,c.__)("It is highly recommended that you remove the last site you imported before importing a new one.","gp-premium")),(0,l.createElement)("p",null,(0,c.__)("This process restores your previous options, widgets and active plugins. It will also remove your imported content and CSS.","gp-premium")),(0,l.createElement)("div",{className:"gpp-library-action-button"},(0,l.createElement)(m.Button,{variant:"primary",onClick:function(t){window.confirm((0,c.__)("This process makes changes to your website. If it contains important data, we suggest backing it up before proceeding.","gp-premium"))&&(e.setState({isAPIWorking:!0}),e.restoreBackup(t))}},this.state.isAPIWorking&&(0,l.createElement)(m.Spinner,null),!this.state.isAPIWorking&&(0,c.__)("Remove imported site","gp-premium")),(0,l.createElement)("span",{className:"gpp-library-action-message"}),!this.state.isAPIWorking&&(0,l.createElement)(m.Button,{onClick:function(){e.setState({hasBackup:!1})}},(0,c.__)("No thanks","gp-premium")))),!this.state.siteOpened&&!this.state.hasBackup&&(0,l.createElement)(h.Fragment,null,(0,l.createElement)("div",{className:"generatepress-site-library-filter"},(0,l.createElement)(v,{allSites:n,value:this.state.category,onChange:function(t){e.setState({category:t}),setTimeout((function(){(0,p.be)()}),100)}}),(0,l.createElement)(b,{value:this.state.search,onChange:function(t){e.setState({search:t,category:""}),setTimeout((function(){(0,p.be)()}),100)}})),(0,l.createElement)("ul",{className:"generatepress-site-library-list"},Object.keys(n).map((function(t){if(""!==e.state.category&&!n[t].category.includes(e.state.category))return null;var r=n[t].name,i=(0,g.decodeEntities)(r);if(""!==e.state.search&&!i.toLowerCase().includes(e.state.search.toLowerCase())&&!n[t].author_name.toLowerCase().includes(e.state.search.toLowerCase()))return null;var a=n[t].directory+"/screenshot.png",s=gppSiteLibrary.gppVersion.split("-")[0],o=n[t].min_version.split("-")[0],m=gppSiteLibrary.gpVersion.split("-")[0],h=gppSiteLibrary.generateblocksVersion.split("-")[0],f=n[t].min_theme_version?n[t].min_theme_version.split("-")[0]:m,d=n[t].min_generateblocks_version?n[t].min_generateblocks_version.split("-")[0]:h,v=n[t].image_width,b=n[t].image_height,y=u(o,s)>0||u(f,m)>0||h&&u(d,h)>0;return(0,l.createElement)("li",{className:"generatepress-site-library-list-item",key:r+":"+t},(0,l.createElement)("button",{disabled:y,onClick:function(){e.setState({siteOpened:!0,siteData:n[t],sitePlugins:JSON.parse(n[t].plugins)})}},(0,l.createElement)("div",{className:"generatepress-site-library-list-item-image"},(0,l.createElement)(p.ZP,{offset:100,once:!0},(0,l.createElement)("img",{src:a,alt:r,width:v,height:b}))),(0,l.createElement)("div",{className:"generatepress-site-library-list-item-title"},i,!!y&&u(o,s)>0&&(0,l.createElement)("span",{className:"generatepress-site-library-required-version"},(0,c.sprintf)(/* translators: Version number */
|
|
(0,c.__)("Requires GP Premium %s.","gp-premium"),o)),!!y&&u(f,m)>0&&(0,l.createElement)("span",{className:"generatepress-site-library-required-version"},(0,c.sprintf)(/* translators: Version number */
|
|
(0,c.__)("Requires GeneratePress %s.","gp-premium"),f)),!!y&&h&&u(d,h)>0&&(0,l.createElement)("span",{className:"generatepress-site-library-required-version"},(0,c.sprintf)(/* translators: Version number */
|
|
(0,c.__)("Requires GenerateBlocks %s.","gp-premium"),d)))))}))),(0,l.createElement)("div",{className:"generatepress-site-library-refresh"},(0,l.createElement)(m.Button,{variant:"primary",onClick:function(){e.setState({refreshingSites:!0}),d()({path:"/generatepress-site-library/v1/get_sites",method:"POST",data:{forceRefresh:!0}}).then((function(t){e.setState({isAPILoaded:!0,allSites:t.response,refreshingSites:!1})}))}},this.state.refreshingSites&&(0,l.createElement)(m.Spinner,null),!this.state.refreshingSites&&(0,c.__)("Refresh sites","gp-premium")))),this.state.siteOpened&&(0,l.createElement)("div",{className:"generatepress-site-library-opened"},(0,l.createElement)("div",{className:"generatepress-site-library-iframe"},(0,l.createElement)("iframe",{title:"gpp-site-library-frame",src:this.state.siteData.preview_url,style:{width:r}})),(0,l.createElement)("div",{className:"generatepress-site-library-info"},(0,l.createElement)("div",{className:"generatepress-site-library-header"},(0,l.createElement)("div",{className:"generatepress-site-library-header__title"},(0,l.createElement)("h2",{className:i?"has-author":""},(0,g.decodeEntities)(this.state.siteData.name)),i&&(0,l.createElement)("span",{className:"site-library-author"},/* translators: Site library site built by "author name" */
|
|
(0,c.__)("Built by","gp-premium")+" ",(0,l.createElement)("a",{href:this.state.siteData.author_url,target:"_blank",rel:"noreferrer noopener"},this.state.siteData.author_name))),(0,l.createElement)(m.Button,{onClick:function(){e.setState({isAPIWorking:!1,siteOpened:!1,siteData:{},siteSlug:"",sitePlugins:{},hasData:{},hasWidgets:!1,importOptions:!0,importContent:!0,confirmImport:!1,importComplete:!1,installablePlugins:[],activePlugins:[],manualPlugins:[]})}},(0,l.createElement)("svg",{width:"35",height:"35",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",role:"img","aria-hidden":"true",focusable:"false"},(0,l.createElement)("path",{d:"M13 11.9l3.3-3.4-1.1-1-3.2 3.3-3.2-3.3-1.1 1 3.3 3.4-3.5 3.6 1 1L12 13l3.5 3.5 1-1z"})))),(0,l.createElement)("div",{className:"generatepress-site-library-content"},!!this.state.siteData.description&&(0,l.createElement)("p",null,(0,g.decodeEntities)(this.state.siteData.description)),!this.state.importComplete&&(0,l.createElement)(h.Fragment,null,0===Object.keys(this.state.hasData).length&&(0,l.createElement)(h.Fragment,null,gppSiteLibrary.isDebugEnabled&&(0,l.createElement)(h.Fragment,null,(0,l.createElement)("h3",null,(0,c.__)("Debug Mode Enabled","gp-premium")),(0,l.createElement)("p",null,(0,c.__)("WordPress debug mode is currently enabled. With this, any errors from third-party plugins might affect the import process.","gp-premium")),(0,l.createElement)("p",null,(0,c.__)("To disable it, find WP_DEBUG in your wp-config.php file and set it to false like the below.","gp-premium")),(0,l.createElement)("code",null,"define( 'WP_DEBUG', false );"),(0,l.createElement)("p",null,(0,l.createElement)("a",{href:"https://docs.generatepress.com/article/debug-mode-enabled/",target:"_blank",rel:"noreferrer noopener"},(0,c.__)("Learn more here","gp-premium")))),Object.keys(this.state.sitePlugins).length>0&&(0,l.createElement)(h.Fragment,null,(0,l.createElement)("h3",null,(0,c.__)("Plugins","gp-premium")),(0,l.createElement)("p",null,(0,c.__)("This site uses the following plugins.","gp-premium")),(0,l.createElement)("ul",{className:"generatepress-site-library-plugins"},Object.entries(this.state.sitePlugins).map((function(e){var n=t(e,1)[0];return(0,l.createElement)("li",{key:n},n)})))),(0,l.createElement)("div",{className:"gpp-library-action-button"},(0,l.createElement)(m.Button,{variant:"primary",disabled:this.state.isAPIWorking,onClick:function(n){e.setState({isAPIWorking:!0});var r=n.target.nextElementSibling;r.textContent=(0,c.__)("Gathering information","gp-premium"),d()({path:"/generatepress-site-library/v1/get_site_data",method:"POST",data:{siteData:e.state.siteData}}).then((function(n){var i=[],a=[],s=[];Object.entries(n.response.plugin_data).forEach((function(e){var r=t(e,1)[0],o=n.response.plugin_data[r];o.repo&&!o.installed?i.push(o.name):o.installed||o.active?a.push(o.name):s.push(o.name)})),e.setState({isAPIWorking:!1,hasData:n.response,sitePlugins:n.response.plugins,hasWidgets:n.response.widgets,installablePlugins:i,activePlugins:a,manualPlugins:s}),r.classList.add("gpp-library-action-message--show"),r.textContent=n.response,n.success&&n.response?setTimeout((function(){r.classList.remove("gpp-library-action-message--show")}),3e3):r.classList.add("gpp-library-action-message--error")}))}},this.state.isAPIWorking&&(0,l.createElement)(m.Spinner,null),!this.state.isAPIWorking&&(0,c.__)("Get Started","gp-premium")),(0,l.createElement)("span",{className:"gpp-library-action-message"}))),Object.keys(this.state.hasData).length>0&&Object.keys(this.state.sitePlugins).length>0&&(0,l.createElement)(h.Fragment,null,(0,l.createElement)("h3",null,(0,c.__)("Plugins","gp-premium")),this.state.installablePlugins.length>0&&(0,l.createElement)(h.Fragment,null,(0,l.createElement)("p",null,(0,c.__)("These plugins can be installed automatically.","gp-premium")),(0,l.createElement)("ul",{className:"generatepress-site-library-plugins"},this.state.installablePlugins.map((function(e){return(0,l.createElement)("li",{key:e},e)})))),this.state.activePlugins.length>0&&(0,l.createElement)(h.Fragment,null,(0,l.createElement)("p",null,(0,c.__)("These plugins are already installed.","gp-premium")),(0,l.createElement)("ul",{className:"generatepress-site-library-plugins"},this.state.activePlugins.map((function(e){return(0,l.createElement)("li",{key:e},e)})))),this.state.manualPlugins.length>0&&(0,l.createElement)(h.Fragment,null,(0,l.createElement)("p",null,(0,c.__)("These plugins need to be installed manually.","gp-premium")),(0,l.createElement)("ul",{className:"generatepress-site-library-plugins"},this.state.manualPlugins.map((function(e){return(0,l.createElement)("li",{key:e},e)}))))),Object.keys(this.state.hasData).length>0&&(0,l.createElement)(h.Fragment,null,(0,l.createElement)("h3",null,(0,c.__)("Import","gp-premium")),this.state.hasData.options&&!this.state.isAPIWorking&&(0,l.createElement)(m.Tooltip,{text:(0,c.__)("This will import the options from the Customizer.","gp-premium")},(0,l.createElement)(m.ToggleControl,{checked:!!this.state.importOptions,label:(0,c.__)("Import Theme Options","gp-premium"),onChange:function(t){e.setState({importOptions:t})}})),this.state.hasData.content&&!this.state.isAPIWorking&&(0,l.createElement)(m.Tooltip,{text:(0,c.__)("This will install and activate needed plugins, import demo content, and import site options.","gp-premium")},(0,l.createElement)(m.ToggleControl,{checked:!!this.state.importContent,label:(0,c.__)("Import Demo Content","gp-premium"),onChange:function(t){e.setState({importContent:t})}})),(!!this.state.importOptions||!!this.state.importContent)&&(0,l.createElement)(h.Fragment,null,!this.state.isAPIWorking&&(0,l.createElement)(h.Fragment,null,(0,l.createElement)("h3",null,(0,c.__)("Confirm Import","gp-premium")),(0,l.createElement)("p",null,(0,c.__)("This process makes changes to your website. If it contains important data, we suggest backing it up before proceeding.","gp-premium")),(0,l.createElement)(m.ToggleControl,{checked:!!this.state.confirmImport,label:(0,c.__)("I understand","gp-premium"),onChange:function(t){e.setState({confirmImport:t})}})),!!this.state.confirmImport&&!this.state.importComplete&&(0,l.createElement)("div",{className:"gpp-library-action-button"},(0,l.createElement)(m.Button,{variant:"primary",disabled:this.state.isAPIWorking,onClick:function(t){e.setState({isAPIWorking:!0}),e.state.importOptions?e.importThemeOptions(t):e.state.importContent&&e.installPlugins(t)}},this.state.isAPIWorking&&(0,l.createElement)(m.Spinner,null),!this.state.isAPIWorking&&(0,c.__)("Begin Import","gp-premium")),(0,l.createElement)("span",{className:"gpp-library-action-message"}))))),!!this.state.importComplete&&(0,l.createElement)(h.Fragment,null,(0,l.createElement)("h3",null,(0,c.__)("Import Complete","gp-premium")),(0,l.createElement)("p",null,(0,c.__)("Check out your new site and start making it yours!","gp-premium")),(0,l.createElement)("p",null,(0,c.__)("Note: We do our best to ensure all imported images are licensed for open use. However, image licenses can change, so we strongly advise that you replace all imported images with your own.","gp-premium")),(0,l.createElement)("a",{className:"components-button is-primary",href:gppSiteLibrary.homeUrl},(0,c.__)("View Site","gp-premium")),this.state.siteData.uploads_url&&Object.values(this.state.sitePlugins).includes("elementor/elementor.php")&&(0,l.createElement)(h.Fragment,null,(0,l.createElement)("h3",null,(0,c.__)("Additional Cleanup","gp-premium")),(0,l.createElement)("p",null,(0,c.__)("This site is using Elementor which means you will want to replace the imported image URLs.","gp-premium")),(0,l.createElement)("p",null,(0,c.__)("Take note of the old and new URLs below, then head over to the Elementor Tools area to replace them.","gp-premium")),(0,l.createElement)(m.TextControl,{label:(0,c.__)("Old URL","gp-premium"),readOnly:!0,value:this.state.siteData.uploads_url}),(0,l.createElement)(m.TextControl,{label:(0,c.__)("New URL","gp-premium"),readOnly:!0,value:gppSiteLibrary.uploadsUrl}),(0,l.createElement)("a",{href:gppSiteLibrary.elementorReplaceUrls,className:"components-button is-primary",target:"_blank",rel:"noopener noreferrer"},(0,c.__)("Elementor Tools","gp-premium")))),(0,l.createElement)("div",{className:"generatepress-site-library-footer"},(0,l.createElement)(m.Tooltip,{text:(0,c.__)("Preview desktop","gp-premium")},(0,l.createElement)(m.Button,{variant:"desktop"===this.state.device?"primary":"",onClick:function(){e.setState({device:"desktop"})}},(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24"},(0,l.createElement)("path",{d:"M21 14H3V4h18m0-2H3c-1.11 0-2 .89-2 2v12a2 2 0 002 2h7l-2 3v1h8v-1l-2-3h7a2 2 0 002-2V4a2 2 0 00-2-2z",fill:"currentColor"})))),(0,l.createElement)(m.Tooltip,{text:(0,c.__)("Preview tablet","gp-premium")},(0,l.createElement)(m.Button,{variant:"tablet"===this.state.device?"primary":"",onClick:function(){e.setState({device:"tablet"})}},(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24"},(0,l.createElement)("path",{d:"M19 19H4V3h15m-7.5 20a1.5 1.5 0 01-1.5-1.5 1.5 1.5 0 011.5-1.5 1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m7-23h-14A2.5 2.5 0 002 2.5v19A2.5 2.5 0 004.5 24h14a2.5 2.5 0 002.5-2.5v-19A2.5 2.5 0 0018.5 0z",fill:"currentColor"})))),(0,l.createElement)(m.Tooltip,{text:(0,c.__)("Preview mobile","gp-premium")},(0,l.createElement)(m.Button,{variant:"mobile"===this.state.device?"primary":"",onClick:function(){e.setState({device:"mobile"})}},(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24"},(0,l.createElement)("path",{d:"M17 19H7V5h10m0-4H7c-1.11 0-2 .89-2 2v18a2 2 0 002 2h10a2 2 0 002-2V3a2 2 0 00-2-2z",fill:"currentColor"}))))))))))}}])&&i(n.prototype,f),Object.defineProperty(n,"prototype",{writable:!1}),w}(h.Component);(0,h.render)((0,l.createElement)(y,null),document.getElementById("gpp-site-library"))}()}(); |