laipower/wp-content/plugins/gp-premium/dist/site-library.js

5 lines
35 KiB
JavaScript
Raw Normal View History

!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=53)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wp.components},function(e,t){e.exports=window.React},function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(t)}e.exports=n},function(e,t,n){e.exports=n(26)()},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(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)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},function(e,t,n){var r=n(18);e.exports=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}}),t&&r(e,t)}},function(e,t,n){var r=n(19),i=n(11);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?i(e):t}},,function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},function(e,t){e.exports=window.wp.apiFetch},,,function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.forceVisible=t.forceCheck=t.lazyload=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(3),s=u(i),a=u(n(5)),o=n(28),l=u(n(29)),c=u(n(30)),p=u(n(31));function u(e){return e&&e.__esModule?e:{default:e}}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(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}function g(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)}var d="data-lazyload-listened",b=[],h=[],O=!1;try{var v=Object.defineProperty({},"passive",{get:function(){O=!0}});window.addEventListener("test",null,v)}catch(e){}var y=!!O&&{capture:!1,passive:!0},j=function(e){var t=e.ref;if(t instanceof HTMLElement){var n=(0,l.default)(t);(e.props.overflow&&n!==t.ownerDocument&&n!==document&&n!==document.documentElement?function(e,t){var n=e.ref,r=void 0,i=void 0,s=void 0,a=void 0;try{var o=t.getBoundingClientRect();r=o.top,i=o.left,s=o.height,a=o.width}catch(e){r=0,i=0,s=0,a=0}var l=window.innerHeight||document.documentElement.clientHeight,c=window.innerWidth||document.documentElement.clientWidth,p=Math.max(r,0),u=Math.max(i,0),m=Math.min(l,r+s)-p,f=Math.min(c,i+a)-u,g=void 0,d=void 0,b=void 0,h=void 0;try{var O=n.getBoundingClientRect();g=O.top,d=O.left,b=O.he
/* translators: Installing "Plugin Name" */
Object(y.__)("Installing %s","gp-premium"),l),wp.updates.installPlugin({slug:o,success:function(n){console.log(n),delete t.state.hasData.plugin_data[s],0===Object.keys(t.state.hasData.plugin_data).length&&t.activatePlugins(e)},error:function(n){console.log(n),delete t.state.hasData.plugin_data[s],0===Object.keys(t.state.hasData.plugin_data).length&&t.activatePlugins(e)}}))}))}},{key:"activatePlugins",value:function(e){var t=this;e.classList.add("gpp-library-action-message--show"),e.textContent=Object(y.__)("Activating plugins","gp-premium"),w()({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=Object(y.__)("Importing content","gp-premium"),w()({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=Object(y.__)("Importing site options","gp-premium"),w()({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=Object(y.__)("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=Object(y.__)("Importing widgets","gp-premium"),w()({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=Object(y.__)("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=Object(y.__)("Restoring theme options","gp-premium"),w()({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=Object(y.__)("Restoring content","gp-premium"),w()({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 Object(h.createElement)(j.Placeholder,{className:"gpp-library-placeholder"},Object(h.createElement)(j.Spinner,null));var t=this.state.allSites;if(!t||"no results"===t)return Object(h.createElement)("div",{className:"generatepress-site-library-no-results"},Object(h.createElement)("p",null,Objec
/* translators: Version number */
Object(y.__)("Requires GP Premium %s.","gp-premium"),t[n].min_version)))))}))),Object(h.createElement)("div",{className:"generatepress-site-library-refresh"},Object(h.createElement)(j.Button,{isPrimary:!0,onClick:function(){e.setState({refreshingSites:!0}),w()({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&&Object(h.createElement)(j.Spinner,null),!this.state.refreshingSites&&Object(y.__)("Refresh sites","gp-premium")))),this.state.siteOpened&&Object(h.createElement)("div",{className:"generatepress-site-library-opened"},Object(h.createElement)("div",{className:"generatepress-site-library-iframe"},Object(h.createElement)("iframe",{title:"gpp-site-library-frame",src:this.state.siteData.preview_url,style:{width:o}})),Object(h.createElement)("div",{className:"generatepress-site-library-info"},Object(h.createElement)("div",{className:"generatepress-site-library-header"},Object(h.createElement)("h2",null,Object(_.decodeEntities)(this.state.siteData.name)),Object(h.createElement)(j.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:[]})}},Object(h.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"},Object(h.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"})))),Object(h.createElement)("div",{className:"generatepress-site-library-content"},Object(h.createElement)("p",null,Object(_.decodeEntities)(this.state.siteData.description)),!this.state.importComplete&&Object(h.createElement)(h.Fragment,null,0===Object.keys(this.state.hasData).length&&Object(h.createElement)(h.Fragment,null,gppSiteLibrary.isDebugEnabled&&Object(h.createElement)(h.Fragment,null,Object(h.createElement)("h3",null,Object(y.__)("Debug Mode Enabled","gp-premium")),Object(h.createElement)("p",null,Object(y.__)("WordPress debug mode is currently enabled. With this, any errors from third-party plugins might affect the import process.","gp-premium")),Object(h.createElement)("p",null,Object(y.__)("To disable it, find WP_DEBUG in your wp-config.php file and set it to false like the below.","gp-premium")),Object(h.createElement)("code",null,"define( 'WP_DEBUG', false );"),Object(h.createElement)("p",null,Object(h.createElement)("a",{href:"https://docs.generatepress.com/article/debug-mode-enabled/",target:"_blank",rel:"noreferrer noopener"},Object(y.__)("Learn more here","gp-premium")))),Object.keys(this.state.sitePlugins).length>0&&Object(h.createElement)(h.Fragment,null,Object(h.createElement)("h3",null,Object(y.__)("Plugins","gp-premium")),Object(h.createElement)("p",null,Object(y.__)("This site uses the following plugins.","gp-premium")),Object(h.createElement)("ul",{className:"generatepress-site-library-plugins"},Object.entries(this.state.sitePlugins).map((function(e){var t=i()(e,1)[0];return Object(h.createElement)("li",{key:t},t)})))),Object(h.createElement)("div",{className:"gpp-library-action-button"},Object(h.createElement)(j.Button,{isPrimary:!0,disabled:this.state.isAPIWorking,onClick:function(t){e.setState({isAPIWorking:!0});var n=t.target.nextElementSibling;n.textContent=Object(y.__)("Gathering information","gp-premium"),w()({path:"/generatepress-site-library/v1/get_site_data",method:"POST",data:{siteData:e.state.siteData}}).then((function(t){var r=[],s=[],a=[];Object.entries(t.response.plugin_data).forEach((function(e){var n=i()(e,1)[0],o=t.response.plugin_data[n];o.repo&&!o.installed?r.push(o.name):o.installed||o.active?s.push(o.name):a.push(o.name)})),e.setState({isAPIWorking:!1,hasData:t.response,sitePlugins:t.response.plugins,hasWidgets:t.response.widgets,installablePlugins:r,activePlugins:s,manualPlugins:a}),n.classList.add("gpp-library-a