Changeset 2025157
- Timestamp:
- 02/05/2019 11:55:27 AM (7 years ago)
- Location:
- cloud-blocks
- Files:
-
- 1 deleted
- 15 edited
- 43 copied
-
tags/1.1.4 (copied) (copied from cloud-blocks/trunk)
-
tags/1.1.4/README.md (copied) (copied from cloud-blocks/trunk/README.md)
-
tags/1.1.4/assets (copied) (copied from cloud-blocks/trunk/assets)
-
tags/1.1.4/assets/css/style.css (copied) (copied from cloud-blocks/trunk/assets/css/style.css)
-
tags/1.1.4/assets/js/script.js (copied) (copied from cloud-blocks/trunk/assets/js/script.js) (2 diffs)
-
tags/1.1.4/assets/js/script.min.js (copied) (copied from cloud-blocks/trunk/assets/js/script.min.js) (1 diff)
-
tags/1.1.4/assets/source/js/block-component.js (copied) (copied from cloud-blocks/trunk/assets/source/js/block-component.js) (2 diffs)
-
tags/1.1.4/assets/source/js/block-details.js (copied) (copied from cloud-blocks/trunk/assets/source/js/block-details.js)
-
tags/1.1.4/assets/source/js/explorer-filter.js (copied) (copied from cloud-blocks/trunk/assets/source/js/explorer-filter.js)
-
tags/1.1.4/assets/source/js/script.js (copied) (copied from cloud-blocks/trunk/assets/source/js/script.js)
-
tags/1.1.4/assets/source/scss/style.css (copied) (copied from cloud-blocks/trunk/assets/source/scss/style.css)
-
tags/1.1.4/assets/source/scss/style.scss (copied) (copied from cloud-blocks/trunk/assets/source/scss/style.scss)
-
tags/1.1.4/assets/thumbnail.png (copied) (copied from cloud-blocks/trunk/assets/thumbnail.png)
-
tags/1.1.4/cloud-blocks.php (copied) (copied from cloud-blocks/trunk/cloud-blocks.php) (4 diffs)
-
tags/1.1.4/composer.json (copied) (copied from cloud-blocks/trunk/composer.json)
-
tags/1.1.4/composer.lock (copied) (copied from cloud-blocks/trunk/composer.lock)
-
tags/1.1.4/core (copied) (copied from cloud-blocks/trunk/core)
-
tags/1.1.4/core/Activator.php (copied) (copied from cloud-blocks/trunk/core/Activator.php) (8 diffs)
-
tags/1.1.4/core/Blocks/Blocks.php (copied) (copied from cloud-blocks/trunk/core/Blocks/Blocks.php) (10 diffs)
-
tags/1.1.4/core/Blocks/Explore.php (copied) (copied from cloud-blocks/trunk/core/Blocks/Explore.php) (7 diffs)
-
tags/1.1.4/core/Blocks/Options.php (copied) (copied from cloud-blocks/trunk/core/Blocks/Options.php) (3 diffs)
-
tags/1.1.4/core/CloudBlocks.php (copied) (copied from cloud-blocks/trunk/core/CloudBlocks.php) (2 diffs)
-
tags/1.1.4/core/Settings/Tools.php (copied) (copied from cloud-blocks/trunk/core/Settings/Tools.php) (1 diff)
-
tags/1.1.4/core/Settings/Translations.php (copied) (copied from cloud-blocks/trunk/core/Settings/Translations.php)
-
tags/1.1.4/docs (copied) (copied from cloud-blocks/trunk/docs)
-
tags/1.1.4/docs/changelog.md (copied) (copied from cloud-blocks/trunk/docs/changelog.md) (1 diff)
-
tags/1.1.4/docs/create-block.md (copied) (copied from cloud-blocks/trunk/docs/create-block.md) (1 diff)
-
tags/1.1.4/docs/hooks.md (copied) (copied from cloud-blocks/trunk/docs/hooks.md)
-
tags/1.1.4/docs/migrate-block.md (copied) (copied from cloud-blocks/trunk/docs/migrate-block.md) (1 diff)
-
tags/1.1.4/docs/private-blocks.md (copied) (copied from cloud-blocks/trunk/docs/private-blocks.md)
-
tags/1.1.4/languages (copied) (copied from cloud-blocks/trunk/languages)
-
tags/1.1.4/languages/cloud-blocks-it_IT.mo (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-it_IT.mo)
-
tags/1.1.4/languages/cloud-blocks-it_IT.po (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-it_IT.po)
-
tags/1.1.4/languages/cloud-blocks-nb_NO.mo (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-nb_NO.mo)
-
tags/1.1.4/languages/cloud-blocks-nb_NO.po (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-nb_NO.po)
-
tags/1.1.4/languages/cloud-blocks-pl_PL.mo (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-pl_PL.mo)
-
tags/1.1.4/languages/cloud-blocks-pl_PL.po (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-pl_PL.po) (4 diffs)
-
tags/1.1.4/languages/cloud-blocks-pt.mo (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-pt.mo)
-
tags/1.1.4/languages/cloud-blocks-pt.po (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-pt.po)
-
tags/1.1.4/languages/cloud-blocks-pt_PT.mo (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-pt_PT.mo)
-
tags/1.1.4/languages/cloud-blocks-pt_PT.po (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-pt_PT.po)
-
tags/1.1.4/readme.txt (copied) (copied from cloud-blocks/trunk/readme.txt) (2 diffs)
-
tags/1.1.4/vendor (copied) (copied from cloud-blocks/trunk/vendor)
-
tags/1.1.4/vendor/bin (deleted)
-
trunk/assets/js/script.js (modified) (2 diffs)
-
trunk/assets/js/script.min.js (modified) (1 diff)
-
trunk/assets/source/js/block-component.js (modified) (2 diffs)
-
trunk/cloud-blocks.php (modified) (4 diffs)
-
trunk/core/Activator.php (modified) (8 diffs)
-
trunk/core/Blocks/Blocks.php (modified) (10 diffs)
-
trunk/core/Blocks/Explore.php (modified) (7 diffs)
-
trunk/core/Blocks/Options.php (modified) (3 diffs)
-
trunk/core/CloudBlocks.php (modified) (2 diffs)
-
trunk/core/Settings/Tools.php (modified) (1 diff)
-
trunk/docs/changelog.md (modified) (1 diff)
-
trunk/docs/create-block.md (modified) (1 diff)
-
trunk/docs/migrate-block.md (modified) (1 diff)
-
trunk/languages/cloud-blocks-pl_PL.po (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cloud-blocks/tags/1.1.4/assets/js/script.js
r2011877 r2025157 116 116 theBlock.version = block.version 117 117 theBlock.packageName = block.name 118 119 if (res.version && b.block_version < res.version) { 120 this.updateAvailable = true 121 theBlock.availVersion = block.version 122 } 123 118 124 this.fromCloud = theBlock 119 } 120 if (res && res.version && b.block_version < res.version) { 121 this.updateAvailable = true 125 126 if (this.updateAvailable) { 127 this.setAvalVersion() 128 } 122 129 } 123 130 }) … … 204 211 this.installing = false 205 212 console.log('There is some issues updating block: ', error) 213 }) 214 }, 215 setAvalVersion() { 216 let postData = this.fromCloud 217 jQuery.ajax({ 218 type: 'POST', 219 url: fgcData.ajaxUrl, 220 data: { 221 action: "fgc_update_version", 222 data: postData 223 } 224 }) 225 .done(res => { 226 console.log('Available new version ', res.data) 227 }) 228 .fail(error => { 229 console.log('There is some issues: ', error) 206 230 }) 207 231 }, -
cloud-blocks/tags/1.1.4/assets/js/script.min.js
r2011877 r2025157 1 "use strict";function _typeof(a){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Vue.component("admin-notice",{data:function a(){return{activeTimeout:-1}},template:"\n <div\n :class=\"['fgc-notification', notification.class]\"\n v-cloak>\n <p v-html=\"notification.text\"></p>\n </div>\n ",watch:{isActive:function a(){this.showingTimeout()}},mounted:function a(){this.showingTimeout()},methods:{showingTimeout:function b(){var a=this;window.clearTimeout(this.activeTimeout),this.activeTimeout=window.setTimeout(function(){window.store.state.notification.class="",a.isShowing=!1},4e3)}},computed:{isActive:function a(){return window.store.state.notification.text},notification:function a(){return window.store.state.notification}}}),Vue.component("block-card",{props:["block"],data:function a(){return{installing:!1,alreadyInstaleld:!1,updateAvailable:!1,currentVersion:null,fromCloud:null}},template:"\n <div class=\"theme\">\n <div class=\"theme-screenshot\" @click=\"openMoreDetails\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"installing\"></div>\n </div>\n\n <div v-if=\"currentBrowseState != 'installed' && alreadyInstaleld\" class=\"notice inline notice-success notice-alt\"><p>{{fgcData.strings.installed}}</p></div>\n\n <div v-if=\"currentBrowseState == 'installed' && isLocalBlock\" class=\"notice inline notice-info notice-alt\"><p>{{fgcData.strings.local_block}}</p></div>\n\n <div v-if=\"updateAvailable\" class=\"update-message notice inline notice-warning notice-alt\">\n <p>{{fgcData.strings.update_available}} <button class=\"button-link\" type=\"button\" @click=\"updateBlock\">{{fgcData.strings.update_now}}</button></p>\n </div>\n\n <span class=\"more-details\" @click=\"openMoreDetails\">{{fgcData.strings.show_more_details}}</span>\n\n <div class=\"theme-id-container\">\n <h3 class=\"theme-name\">{{ block.name }}</h3>\n <span v-if=\"blockManifest && blockManifest.author\" class=\"block-author\">{{fgcData.strings.by}}: \n <span v-if=\"typeof blockManifest.author == 'object'\">\n {{ blockManifest.author.name }}\n </span>\n <span v-if=\"typeof blockManifest.author == 'string'\">\n {{ blockManifest.author }}\n </span>\n </span>\n <span v-else class=\"block-version\">{{fgcData.strings.version}}: {{ currentVersion }}</span>\n\n <div class=\"theme-actions\">\n <button class=\"button button-primary theme-install install-block-btn\"\n v-if=\"currentBrowseState != 'installed' && !alreadyInstaleld\"\n @click.prevent=\"installBlock\">\n {{fgcData.strings.install}}\n </button>\n <button class=\"button theme-install install-block-btn\"\n v-else\n @click.prevent=\"uninstallBlock\">\n {{fgcData.strings.uninstall}}\n </button>\n <a class=\"button button-primary\" :href=\"blockUrl\" target=\"_blank\">{{fgcData.strings.homepage}}</a>\n </div>\n </div>\n\n </div>\n ",mounted:function b(){var a=this;this.currentVersion=this.block.version,!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld="installed"!=this.currentBrowseState,"installed"==this.currentBrowseState&&(window.store.state.installedBlocks.map(function(c){c.package_name!=a.block.packageName||a.isLocalBlock||jQuery.get("https://api.gutenbergcloud.org/blocks/".concat(c.package_name),function(b){if(b){var d=b,e={};e.jsUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name, a.fromCloud=e}b&&b.version&&c.block_version<b.version&&(a.updateAvailable=!0)})}),this.currentVersion=window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName})[0].block_version))},methods:{installBlock:function c(){var a=this;this.installing=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!0,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this;this.installing=!0;var b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},updateBlock:function c(){var a=this;this.installing=!0;var b=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_block",data:b}}).done(function(b){a.installing=!1,a.updateAvailable=!1,a.currentVersion=a.block.version,window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_updated),class:"show success"}),console.log("Block Updated ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues updating block: ",b)})},incrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:-1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},openMoreDetails:function a(){window.store.commit("openOverlay",this.block)}},computed:{currentBrowseState:function a(){return window.store.state.browseState},blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)}}}),Vue.component("block-details",{props:["block"],data:function a(){return{alreadyInstaleld:!1,spinnerLoaded:!1}},template:"\n <div class=\"theme-overlay\" tabindex=\"0\" role=\"dialog\"><div class=\"theme-overlay\">\n <div class=\"theme-backdrop\"></div>\n <div class=\"theme-wrap wp-clearfix\" role=\"document\">\n <div class=\"theme-header\">\n <button class=\"close dashicons dashicons-no\" @click=\"closeOverlay\"></button>\n </div>\n\n <div class=\"theme-about wp-clearfix\">\n <div class=\"theme-screenshots\">\n <div class=\"screenshot\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"spinnerLoaded\"></div>\n </div>\n </div>\n\n <div class=\"theme-info\">\n <h2 class=\"theme-name\">\n {{ block.name }}\n <span class=\"theme-version\">{{fgcData.strings.version}}: {{ block.version }}</span>\n </h2>\n <p v-if=\"blockAuthor && authorUrl\" class=\"theme-author\">{{fgcData.strings.by}} <a :href=\"authorUrl\" target=\"_blank\">{{ blockAuthor }} </a></p>\n <p v-else-if=\"blockAuthor\" class=\"theme-author\">{{fgcData.strings.by}} {{ blockAuthor }}</p>\n\n \n <p class=\"theme-description\">\n {{ blockManifest.description }}\n </p>\n\n <p class=\"theme-tags\">\n <span>{{fgcData.strings.tags}}:</span>{{ blockTags }}\n </p>\n \n </div>\n </div>\n\n <div class=\"theme-actions\">\n <div class=\"inactive-theme\">\n <a v-if=\"alreadyInstaleld\" @click.prevent=\"uninstallBlock\" class=\"button activate\">{{fgcData.strings.uninstall}}</a>\n <a v-else @click.prevent=\"installBlock\" class=\"button activate\">{{fgcData.strings.install}}</a>\n <a :href=\"blockUrl\" target=\"_blank\" class=\"button button-primary load-customize hide-if-no-customize\">{{fgcData.strings.visit_homepage}}</a>\n <a v-if=\"isLocalBlock\" class=\"button install-block-btn button-delete load-customize hide-if-no-customize\" @click.prevent=\"deleteBlock\">{{fgcData.strings.delete_block}}</a>\n </div>\n </div>\n </div>\n </div>\n </div>",mounted:function b(){var a=this;window.addEventListener("keyup",this.keypressEvent),!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld=!0)},computed:{blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)},authorUrl:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:this.blockManifest.homepage?this.blockManifest.homepage:"https://www.npmjs.com/package/".concat(this.block.packageName)},blockAuthor:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.name?this.blockManifest.author.name:this.blockManifest.author&&"string"==typeof this.blockManifest.author?this.blockManifest.author:null},blockTags:function a(){return this.blockManifest?this.blockManifest.keywords.join(", "):""}},methods:{keypressEvent:function b(a){27===a.keyCode&&this.closeOverlay()},closeOverlay:function a(){window.store.commit("openOverlay",null)},installBlock:function c(){var a=this;this.spinnerLoaded=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.alreadyInstaleld=!0,a.spinnerLoaded=!1,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},deleteBlock:function c(){var a=this;this.spinnerLoaded=!0,this.alreadyInstaleld&&this.uninstallBlock();var b={block:this.block,nonce:fgcData.ajaxNonce};jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_delete_block",data:b}}).done(function(b){window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_deleted),class:"show success"}),window.store.commit("setRefetchBlocks",!0),a.closeOverlay(),a.spinnerLoaded=!1,window.store.dispatch("getInstalledBlocks"),console.log("Block removed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this,b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},incrementInstalls:function b(a){jQuery.ajax({type:"PUT",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"DELETE",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})}}}),Vue.component("explorer-filter",{componenets:["filter-drawer"],data:function a(){return{drawerFilterOpen:!1,searchQuery:null,filterLinks:[{name:fgcData.strings.installed,slug:"installed"},{name:fgcData.strings.popular,slug:"popular"},{name:fgcData.strings.latest,slug:"latest"},{name:fgcData.strings.local,slug:"local"}]}},template:"\n <div class=\"wp-filter g-blocks-filter hide-if-no-js\">\n <div class=\"filter-count\">\n <span class=\"count theme-count\">{{ blocksCount }}</span>\n </div>\n\n <ul class=\"filter-links\">\n <li><a v-for=\"filter in filterLinks\" :key=\"filter.slug\" @click=\"filterLink(filter.slug)\" :class=\"currentFilter(filter.slug)\">{{ filter.name }}</a></li>\n </ul>\n\n <button type=\"button\" v-if=\"false\" id=\"searchFilter\" class=\"button drawer-toggle\" :aria-expanded=\"drawerFilterOpen\" @click=\"drawerFilterOpen = !drawerFilterOpen\">{{fgcData.strings.filter}}</button>\n\n <form class=\"search-form\" @submit.prevent=\"searchForBlock\"><label class=\"screen-reader-text\" for=\"wp-filter-search-input\">{{fgcData.strings.search_for_blocks}}</label><input :placeholder=\"fgcData.strings.search_blocks\" v-model=\"searchQuery\" type=\"search\" id=\"wp-filter-search-input\" class=\"wp-filter-search\"></form>\n\n <filter-drawer :style=\"{display: drawerFilterOpen ? 'block' : 'none'}\"></filter-drawer>\n </div>\n ",mounted:function a(){window.store.state.installedBlocks.length||"local"==window.store.state.browseState||this.filterLink("popular")},methods:{filterLink:function c(a){var b=window.location.search.replace(/\&browse[=a-z]*/,"");history.pushState({state:a},null,"".concat(b,"&browse=").concat(a)),window.store.commit("setBrowseState",a)},currentFilter:function b(a){return window.store.state.browseState==a?"current":""},searchForBlock:function c(){var a=window.location.search.replace(/\&q[=a-z\-]*/,""),b=this.searchQuery.replace(/\s+/g,"-").toLowerCase();history.pushState({state:b},null,"".concat(a,"&q=").concat(b)),window.store.commit("setSearchQuery",b)}},computed:{blocksCount:function a(){return"installed"===window.store.state.browseState?window.store.state.installedBlocks.length:window.store.state.blocksCount}}}),Vue.component("filter-drawer",{template:"\n <div class=\"filter-drawer\">\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n <fieldset class=\"filter-group\">\n <legend>Subject</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-blog\" value=\"blog\">\n <label for=\"filter-id-blog\">Blog</label>\n <input type=\"checkbox\" id=\"filter-id-e-commerce\" value=\"e-commerce\">\n <label for=\"filter-id-e-commerce\">E-Commerce</label>\n <input type=\"checkbox\" id=\"filter-id-education\" value=\"education\">\n <label for=\"filter-id-education\">Education</label>\n <input type=\"checkbox\" id=\"filter-id-entertainment\" value=\"entertainment\">\n <label for=\"filter-id-entertainment\">News</label>\n </div>\n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Features</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-accessibility-ready\" value=\"accessibility-ready\">\n <label for=\"filter-id-accessibility-ready\">Custom Colors</label>\n <input type=\"checkbox\" id=\"filter-id-custom-background\" value=\"custom-background\">\n <label for=\"filter-id-custom-background\">Editor style</label>\n <input type=\"checkbox\" id=\"filter-id-custom-colors\" value=\"custom-colors\">\n <label for=\"filter-id-custom-colors\">Full Width Template</label>\n </div> \n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Layout</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-grid-layout\" value=\"grid-layout\">\n <label for=\"filter-id-grid-layout\">Grid-layout</label>\n <input type=\"checkbox\" id=\"filter-id-one-column\" value=\"one-column\">\n <label for=\"filter-id-one-column\">One Column</label>\n <input type=\"checkbox\" id=\"filter-id-two-columns\" value=\"two-columns\">\n <label for=\"filter-id-two-columns\">Two Column</label>\n <input type=\"checkbox\" id=\"filter-id-three-columns\" value=\"three-columns\">\n <label for=\"filter-id-three-columns\">Responsive</label>\n </div>\n </fieldset>\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n\n </div>\n "});var store=new Vuex.Store({state:{notification:{},browseState:null,installedBlocks:fgcData.installedBlocks,searchQuery:null,opendOverlay:null,blocksCount:0,refetchBlocks:!1},mutations:{setNotification:function c(a,b){a.notification=b},setBrowseState:function c(a,b){a.browseState=b},setInstalledBlocks:function c(a,b){a.installedBlocks=b},setSearchQuery:function c(a,b){a.searchQuery=b},openOverlay:function c(a,b){a.opendOverlay=b},setBlocksCount:function c(a,b){a.blocksCount=b},setRefetchBlocks:function c(a,b){a.refetchBlocks=b}},actions:{getInstalledBlocks:function b(a){jQuery.ajax({type:"GET",url:fgcData.ajaxUrl,data:{action:"fgc_get_all_blocks"}}).done(function(b){a.commit("setInstalledBlocks",b.data)}).fail(function(a){console.log("There is some issues installing block: ",a)})}}}),app=new Vue({el:"#blockExplorer",data:function a(){return{blocks:[]}},created:function c(){window.store.dispatch("getInstalledBlocks");var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed",b=this.getUrlParams("q")?this.getUrlParams("q"):"";this.getBlocks({state:a,q:b}),window.store.commit("setBrowseState",a)},mounted:function a(){window.addEventListener("popstate",this.fetchBlocks)},watch:{currentBrowseFilter:function c(a){var b=this.getUrlParams("q")?this.getUrlParams("q"):"";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:a,q:b})},currentSearchQuery:function c(a){var b=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:b,q:a})},installedBlocks:function d(a,b){var c=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";a.length!=b.length&&"installed"==c&&(this.blocks=this.blocks.filter(function(b){return a.some(function(a){return a.package_name==b.packageName})}))},refetchBlocks:function b(){var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";this.getBlocks({state:a})}},methods:{fetchBlocks:function c(a){var b=null;a.state&&(b=a.state.state),this.getBlocks(b)},getBlocks:function l(a){var b=this,c=[],d="";if(a.q&&null!==a.q&&(d="q=".concat(a.q)),null!==a.state&&(d+="&order=".concat(a.state)),null!=a.state&&"installed"!=a.state)"local"==a.state?this.localBlocks(a):jQuery.get("https://api.gutenbergcloud.org/blocks?".concat(d),function(d){d.count&&window.store.commit("setBlocksCount",d.count);var e=!0,f=!1,g=void 0;try{for(var h,i=function(){var d=h.value,e={};e.jsUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,null==a.state||"installed"==a.state?b.installedBlocks.length&&b.installedBlocks.filter(function(a){return a.package_name==e.packageName}).length&&c.push(e):c.push(e)},j=d.rows[Symbol.iterator]();!(e=(h=j.next()).done);e=!0)i()}catch(a){f=!0,g=a}finally{try{e||null==j.return||j.return()}finally{if(f)throw g}}});else if(this.installedBlocks.length){var e=!0,f=!1,g=void 0;try{for(var h,i=this.installedBlocks[Symbol.iterator]();!(e=(h=i.next()).done);e=!0){var j=h.value,k={};k.jsUrl=j.js_url,k.cssUrl=j.css_url,k.editorCss=j.editor_css,k.infoUrl=j.info_url,k.imageUrl=j.thumbnail,k.name=j.block_name,k.blockManifest="\""+j.block_manifest+"\"",k.version=j.block_version,k.packageName=j.package_name,(a.q&&null!==a.q&&(-1<k.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<k.packageName.toLowerCase().indexOf(a.q.toLowerCase()))||!a.q)&&c.push(k)}}catch(a){f=!0,g=a}finally{try{e||null==i.return||i.return()}finally{if(f)throw g}}}this.blocks=c},getUrlParams:function e(a,b){b||(b=window.location.href),a=a.replace(/[\[\]]/g,"\\$&");var c=new RegExp("[?&]"+a+"(=([^&#]*)|&|#|$)"),d=c.exec(b);return d?d[2]?decodeURIComponent(d[2].replace(/\+/g," ")):"":null},showUploader:function a(){document.body.classList.toggle("show-upload-view")},localBlocks:function c(a){var b=this;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_local_blocks"}}).done(function(c){c.data.length?(window.store.commit("setBlocksCount",c.data.length),window.store.commit("setRefetchBlocks",!1)):window.store.commit("setBlocksCount",0),b.blocks=a.q&&null!==a.q?c.data.filter(function(b){return-1<b.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<b.packageName.toLowerCase().indexOf(a.q.toLowerCase())}):c.data}).fail(function(a){console.log("There is some issues getting local blocks: ",a)})}},computed:{currentBrowseFilter:function a(){return window.store.state.browseState},currentSearchQuery:function a(){return window.store.state.searchQuery},installedBlocks:function a(){return window.store.state.installedBlocks},openOverlay:function a(){return window.store.state.opendOverlay},refetchBlocks:function a(){return window.store.state.refetchBlocks}}});1 "use strict";function _typeof(a){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Vue.component("admin-notice",{data:function a(){return{activeTimeout:-1}},template:"\n <div\n :class=\"['fgc-notification', notification.class]\"\n v-cloak>\n <p v-html=\"notification.text\"></p>\n </div>\n ",watch:{isActive:function a(){this.showingTimeout()}},mounted:function a(){this.showingTimeout()},methods:{showingTimeout:function b(){var a=this;window.clearTimeout(this.activeTimeout),this.activeTimeout=window.setTimeout(function(){window.store.state.notification.class="",a.isShowing=!1},4e3)}},computed:{isActive:function a(){return window.store.state.notification.text},notification:function a(){return window.store.state.notification}}}),Vue.component("block-card",{props:["block"],data:function a(){return{installing:!1,alreadyInstaleld:!1,updateAvailable:!1,currentVersion:null,fromCloud:null}},template:"\n <div class=\"theme\">\n <div class=\"theme-screenshot\" @click=\"openMoreDetails\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"installing\"></div>\n </div>\n\n <div v-if=\"currentBrowseState != 'installed' && alreadyInstaleld\" class=\"notice inline notice-success notice-alt\"><p>{{fgcData.strings.installed}}</p></div>\n\n <div v-if=\"currentBrowseState == 'installed' && isLocalBlock\" class=\"notice inline notice-info notice-alt\"><p>{{fgcData.strings.local_block}}</p></div>\n\n <div v-if=\"updateAvailable\" class=\"update-message notice inline notice-warning notice-alt\">\n <p>{{fgcData.strings.update_available}} <button class=\"button-link\" type=\"button\" @click=\"updateBlock\">{{fgcData.strings.update_now}}</button></p>\n </div>\n\n <span class=\"more-details\" @click=\"openMoreDetails\">{{fgcData.strings.show_more_details}}</span>\n\n <div class=\"theme-id-container\">\n <h3 class=\"theme-name\">{{ block.name }}</h3>\n <span v-if=\"blockManifest && blockManifest.author\" class=\"block-author\">{{fgcData.strings.by}}: \n <span v-if=\"typeof blockManifest.author == 'object'\">\n {{ blockManifest.author.name }}\n </span>\n <span v-if=\"typeof blockManifest.author == 'string'\">\n {{ blockManifest.author }}\n </span>\n </span>\n <span v-else class=\"block-version\">{{fgcData.strings.version}}: {{ currentVersion }}</span>\n\n <div class=\"theme-actions\">\n <button class=\"button button-primary theme-install install-block-btn\"\n v-if=\"currentBrowseState != 'installed' && !alreadyInstaleld\"\n @click.prevent=\"installBlock\">\n {{fgcData.strings.install}}\n </button>\n <button class=\"button theme-install install-block-btn\"\n v-else\n @click.prevent=\"uninstallBlock\">\n {{fgcData.strings.uninstall}}\n </button>\n <a class=\"button button-primary\" :href=\"blockUrl\" target=\"_blank\">{{fgcData.strings.homepage}}</a>\n </div>\n </div>\n\n </div>\n ",mounted:function b(){var a=this;this.currentVersion=this.block.version,!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld="installed"!=this.currentBrowseState,"installed"==this.currentBrowseState&&(window.store.state.installedBlocks.map(function(c){c.package_name!=a.block.packageName||a.isLocalBlock||jQuery.get("https://api.gutenbergcloud.org/blocks/".concat(c.package_name),function(b){if(b){var d=b,e={};e.jsUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,b.version&&c.block_version<b.version&&(a.updateAvailable=!0,e.availVersion=d.version),a.fromCloud=e,a.updateAvailable&&a.setAvalVersion()}})}),this.currentVersion=window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName})[0].block_version))},methods:{installBlock:function c(){var a=this;this.installing=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!0,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this;this.installing=!0;var b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},updateBlock:function c(){var a=this;this.installing=!0;var b=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_block",data:b}}).done(function(b){a.installing=!1,a.updateAvailable=!1,a.currentVersion=a.block.version,window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_updated),class:"show success"}),console.log("Block Updated ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues updating block: ",b)})},setAvalVersion:function b(){var a=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_version",data:a}}).done(function(a){console.log("Available new version ",a.data)}).fail(function(a){console.log("There is some issues: ",a)})},incrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:-1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},openMoreDetails:function a(){window.store.commit("openOverlay",this.block)}},computed:{currentBrowseState:function a(){return window.store.state.browseState},blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)}}}),Vue.component("block-details",{props:["block"],data:function a(){return{alreadyInstaleld:!1,spinnerLoaded:!1}},template:"\n <div class=\"theme-overlay\" tabindex=\"0\" role=\"dialog\"><div class=\"theme-overlay\">\n <div class=\"theme-backdrop\"></div>\n <div class=\"theme-wrap wp-clearfix\" role=\"document\">\n <div class=\"theme-header\">\n <button class=\"close dashicons dashicons-no\" @click=\"closeOverlay\"></button>\n </div>\n\n <div class=\"theme-about wp-clearfix\">\n <div class=\"theme-screenshots\">\n <div class=\"screenshot\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"spinnerLoaded\"></div>\n </div>\n </div>\n\n <div class=\"theme-info\">\n <h2 class=\"theme-name\">\n {{ block.name }}\n <span class=\"theme-version\">{{fgcData.strings.version}}: {{ block.version }}</span>\n </h2>\n <p v-if=\"blockAuthor && authorUrl\" class=\"theme-author\">{{fgcData.strings.by}} <a :href=\"authorUrl\" target=\"_blank\">{{ blockAuthor }} </a></p>\n <p v-else-if=\"blockAuthor\" class=\"theme-author\">{{fgcData.strings.by}} {{ blockAuthor }}</p>\n\n \n <p class=\"theme-description\">\n {{ blockManifest.description }}\n </p>\n\n <p class=\"theme-tags\">\n <span>{{fgcData.strings.tags}}:</span>{{ blockTags }}\n </p>\n \n </div>\n </div>\n\n <div class=\"theme-actions\">\n <div class=\"inactive-theme\">\n <a v-if=\"alreadyInstaleld\" @click.prevent=\"uninstallBlock\" class=\"button activate\">{{fgcData.strings.uninstall}}</a>\n <a v-else @click.prevent=\"installBlock\" class=\"button activate\">{{fgcData.strings.install}}</a>\n <a :href=\"blockUrl\" target=\"_blank\" class=\"button button-primary load-customize hide-if-no-customize\">{{fgcData.strings.visit_homepage}}</a>\n <a v-if=\"isLocalBlock\" class=\"button install-block-btn button-delete load-customize hide-if-no-customize\" @click.prevent=\"deleteBlock\">{{fgcData.strings.delete_block}}</a>\n </div>\n </div>\n </div>\n </div>\n </div>",mounted:function b(){var a=this;window.addEventListener("keyup",this.keypressEvent),!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld=!0)},computed:{blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)},authorUrl:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:this.blockManifest.homepage?this.blockManifest.homepage:"https://www.npmjs.com/package/".concat(this.block.packageName)},blockAuthor:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.name?this.blockManifest.author.name:this.blockManifest.author&&"string"==typeof this.blockManifest.author?this.blockManifest.author:null},blockTags:function a(){return this.blockManifest?this.blockManifest.keywords.join(", "):""}},methods:{keypressEvent:function b(a){27===a.keyCode&&this.closeOverlay()},closeOverlay:function a(){window.store.commit("openOverlay",null)},installBlock:function c(){var a=this;this.spinnerLoaded=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.alreadyInstaleld=!0,a.spinnerLoaded=!1,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},deleteBlock:function c(){var a=this;this.spinnerLoaded=!0,this.alreadyInstaleld&&this.uninstallBlock();var b={block:this.block,nonce:fgcData.ajaxNonce};jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_delete_block",data:b}}).done(function(b){window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_deleted),class:"show success"}),window.store.commit("setRefetchBlocks",!0),a.closeOverlay(),a.spinnerLoaded=!1,window.store.dispatch("getInstalledBlocks"),console.log("Block removed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this,b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},incrementInstalls:function b(a){jQuery.ajax({type:"PUT",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"DELETE",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})}}}),Vue.component("explorer-filter",{componenets:["filter-drawer"],data:function a(){return{drawerFilterOpen:!1,searchQuery:null,filterLinks:[{name:fgcData.strings.installed,slug:"installed"},{name:fgcData.strings.popular,slug:"popular"},{name:fgcData.strings.latest,slug:"latest"},{name:fgcData.strings.local,slug:"local"}]}},template:"\n <div class=\"wp-filter g-blocks-filter hide-if-no-js\">\n <div class=\"filter-count\">\n <span class=\"count theme-count\">{{ blocksCount }}</span>\n </div>\n\n <ul class=\"filter-links\">\n <li><a v-for=\"filter in filterLinks\" :key=\"filter.slug\" @click=\"filterLink(filter.slug)\" :class=\"currentFilter(filter.slug)\">{{ filter.name }}</a></li>\n </ul>\n\n <button type=\"button\" v-if=\"false\" id=\"searchFilter\" class=\"button drawer-toggle\" :aria-expanded=\"drawerFilterOpen\" @click=\"drawerFilterOpen = !drawerFilterOpen\">{{fgcData.strings.filter}}</button>\n\n <form class=\"search-form\" @submit.prevent=\"searchForBlock\"><label class=\"screen-reader-text\" for=\"wp-filter-search-input\">{{fgcData.strings.search_for_blocks}}</label><input :placeholder=\"fgcData.strings.search_blocks\" v-model=\"searchQuery\" type=\"search\" id=\"wp-filter-search-input\" class=\"wp-filter-search\"></form>\n\n <filter-drawer :style=\"{display: drawerFilterOpen ? 'block' : 'none'}\"></filter-drawer>\n </div>\n ",mounted:function a(){window.store.state.installedBlocks.length||"local"==window.store.state.browseState||this.filterLink("popular")},methods:{filterLink:function c(a){var b=window.location.search.replace(/\&browse[=a-z]*/,"");history.pushState({state:a},null,"".concat(b,"&browse=").concat(a)),window.store.commit("setBrowseState",a)},currentFilter:function b(a){return window.store.state.browseState==a?"current":""},searchForBlock:function c(){var a=window.location.search.replace(/\&q[=a-z\-]*/,""),b=this.searchQuery.replace(/\s+/g,"-").toLowerCase();history.pushState({state:b},null,"".concat(a,"&q=").concat(b)),window.store.commit("setSearchQuery",b)}},computed:{blocksCount:function a(){return"installed"===window.store.state.browseState?window.store.state.installedBlocks.length:window.store.state.blocksCount}}}),Vue.component("filter-drawer",{template:"\n <div class=\"filter-drawer\">\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n <fieldset class=\"filter-group\">\n <legend>Subject</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-blog\" value=\"blog\">\n <label for=\"filter-id-blog\">Blog</label>\n <input type=\"checkbox\" id=\"filter-id-e-commerce\" value=\"e-commerce\">\n <label for=\"filter-id-e-commerce\">E-Commerce</label>\n <input type=\"checkbox\" id=\"filter-id-education\" value=\"education\">\n <label for=\"filter-id-education\">Education</label>\n <input type=\"checkbox\" id=\"filter-id-entertainment\" value=\"entertainment\">\n <label for=\"filter-id-entertainment\">News</label>\n </div>\n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Features</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-accessibility-ready\" value=\"accessibility-ready\">\n <label for=\"filter-id-accessibility-ready\">Custom Colors</label>\n <input type=\"checkbox\" id=\"filter-id-custom-background\" value=\"custom-background\">\n <label for=\"filter-id-custom-background\">Editor style</label>\n <input type=\"checkbox\" id=\"filter-id-custom-colors\" value=\"custom-colors\">\n <label for=\"filter-id-custom-colors\">Full Width Template</label>\n </div> \n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Layout</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-grid-layout\" value=\"grid-layout\">\n <label for=\"filter-id-grid-layout\">Grid-layout</label>\n <input type=\"checkbox\" id=\"filter-id-one-column\" value=\"one-column\">\n <label for=\"filter-id-one-column\">One Column</label>\n <input type=\"checkbox\" id=\"filter-id-two-columns\" value=\"two-columns\">\n <label for=\"filter-id-two-columns\">Two Column</label>\n <input type=\"checkbox\" id=\"filter-id-three-columns\" value=\"three-columns\">\n <label for=\"filter-id-three-columns\">Responsive</label>\n </div>\n </fieldset>\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n\n </div>\n "});var store=new Vuex.Store({state:{notification:{},browseState:null,installedBlocks:fgcData.installedBlocks,searchQuery:null,opendOverlay:null,blocksCount:0,refetchBlocks:!1},mutations:{setNotification:function c(a,b){a.notification=b},setBrowseState:function c(a,b){a.browseState=b},setInstalledBlocks:function c(a,b){a.installedBlocks=b},setSearchQuery:function c(a,b){a.searchQuery=b},openOverlay:function c(a,b){a.opendOverlay=b},setBlocksCount:function c(a,b){a.blocksCount=b},setRefetchBlocks:function c(a,b){a.refetchBlocks=b}},actions:{getInstalledBlocks:function b(a){jQuery.ajax({type:"GET",url:fgcData.ajaxUrl,data:{action:"fgc_get_all_blocks"}}).done(function(b){a.commit("setInstalledBlocks",b.data)}).fail(function(a){console.log("There is some issues installing block: ",a)})}}}),app=new Vue({el:"#blockExplorer",data:function a(){return{blocks:[]}},created:function c(){window.store.dispatch("getInstalledBlocks");var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed",b=this.getUrlParams("q")?this.getUrlParams("q"):"";this.getBlocks({state:a,q:b}),window.store.commit("setBrowseState",a)},mounted:function a(){window.addEventListener("popstate",this.fetchBlocks)},watch:{currentBrowseFilter:function c(a){var b=this.getUrlParams("q")?this.getUrlParams("q"):"";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:a,q:b})},currentSearchQuery:function c(a){var b=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:b,q:a})},installedBlocks:function d(a,b){var c=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";a.length!=b.length&&"installed"==c&&(this.blocks=this.blocks.filter(function(b){return a.some(function(a){return a.package_name==b.packageName})}))},refetchBlocks:function b(){var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";this.getBlocks({state:a})}},methods:{fetchBlocks:function c(a){var b=null;a.state&&(b=a.state.state),this.getBlocks(b)},getBlocks:function l(a){var b=this,c=[],d="";if(a.q&&null!==a.q&&(d="q=".concat(a.q)),null!==a.state&&(d+="&order=".concat(a.state)),null!=a.state&&"installed"!=a.state)"local"==a.state?this.localBlocks(a):jQuery.get("https://api.gutenbergcloud.org/blocks?".concat(d),function(d){d.count&&window.store.commit("setBlocksCount",d.count);var e=!0,f=!1,g=void 0;try{for(var h,i=function(){var d=h.value,e={};e.jsUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,null==a.state||"installed"==a.state?b.installedBlocks.length&&b.installedBlocks.filter(function(a){return a.package_name==e.packageName}).length&&c.push(e):c.push(e)},j=d.rows[Symbol.iterator]();!(e=(h=j.next()).done);e=!0)i()}catch(a){f=!0,g=a}finally{try{e||null==j.return||j.return()}finally{if(f)throw g}}});else if(this.installedBlocks.length){var e=!0,f=!1,g=void 0;try{for(var h,i=this.installedBlocks[Symbol.iterator]();!(e=(h=i.next()).done);e=!0){var j=h.value,k={};k.jsUrl=j.js_url,k.cssUrl=j.css_url,k.editorCss=j.editor_css,k.infoUrl=j.info_url,k.imageUrl=j.thumbnail,k.name=j.block_name,k.blockManifest="\""+j.block_manifest+"\"",k.version=j.block_version,k.packageName=j.package_name,(a.q&&null!==a.q&&(-1<k.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<k.packageName.toLowerCase().indexOf(a.q.toLowerCase()))||!a.q)&&c.push(k)}}catch(a){f=!0,g=a}finally{try{e||null==i.return||i.return()}finally{if(f)throw g}}}this.blocks=c},getUrlParams:function e(a,b){b||(b=window.location.href),a=a.replace(/[\[\]]/g,"\\$&");var c=new RegExp("[?&]"+a+"(=([^&#]*)|&|#|$)"),d=c.exec(b);return d?d[2]?decodeURIComponent(d[2].replace(/\+/g," ")):"":null},showUploader:function a(){document.body.classList.toggle("show-upload-view")},localBlocks:function c(a){var b=this;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_local_blocks"}}).done(function(c){c.data.length?(window.store.commit("setBlocksCount",c.data.length),window.store.commit("setRefetchBlocks",!1)):window.store.commit("setBlocksCount",0),b.blocks=a.q&&null!==a.q?c.data.filter(function(b){return-1<b.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<b.packageName.toLowerCase().indexOf(a.q.toLowerCase())}):c.data}).fail(function(a){console.log("There is some issues getting local blocks: ",a)})}},computed:{currentBrowseFilter:function a(){return window.store.state.browseState},currentSearchQuery:function a(){return window.store.state.searchQuery},installedBlocks:function a(){return window.store.state.installedBlocks},openOverlay:function a(){return window.store.state.opendOverlay},refetchBlocks:function a(){return window.store.state.refetchBlocks}}}); -
cloud-blocks/tags/1.1.4/assets/source/js/block-component.js
r2007547 r2025157 76 76 theBlock.version = block.version 77 77 theBlock.packageName = block.name 78 79 if (res.version && b.block_version < res.version) { 80 this.updateAvailable = true 81 theBlock.availVersion = block.version 82 } 83 78 84 this.fromCloud = theBlock 79 } 80 if (res && res.version && b.block_version < res.version) { 81 this.updateAvailable = true 85 86 if (this.updateAvailable) { 87 this.setAvalVersion() 88 } 82 89 } 83 90 }) … … 166 173 }) 167 174 }, 175 setAvalVersion() { 176 let postData = this.fromCloud 177 jQuery.ajax({ 178 type: 'POST', 179 url: fgcData.ajaxUrl, 180 data: { 181 action: "fgc_update_version", 182 data: postData 183 } 184 }) 185 .done(res => { 186 console.log('Available new version ', res.data) 187 }) 188 .fail(error => { 189 console.log('There is some issues: ', error) 190 }) 191 }, 168 192 incrementInstalls(packageName) { 169 193 jQuery.ajax({ -
cloud-blocks/tags/1.1.4/cloud-blocks.php
r2020434 r2025157 2 2 /* 3 3 Plugin Name: Cloud Blocks 4 Version: 1.1. 34 Version: 1.1.4 5 5 Description: Your library of Gutenberg blocks in the cloud 6 6 Author: Frontkom … … 30 30 // Plugin version . 31 31 if ( ! defined( 'FGC_VERSION' ) ) { 32 define( 'FGC_VERSION', '1.1. 3' );32 define( 'FGC_VERSION', '1.1.4' ); 33 33 } 34 34 … … 37 37 38 38 // Register text-domain for translations 39 add_action( 'plugins_loaded', 'fgc_register_t extdomain' );40 function fgc_register_t extdomain() {39 add_action( 'plugins_loaded', 'fgc_register_translations' ); 40 function fgc_register_translations() { 41 41 load_plugin_textdomain( 'cloud-blocks', false, basename( dirname( __FILE__ ) ) . '/languages' ); 42 42 } … … 45 45 register_activation_hook( __FILE__, array( 'CloudBlocks\Activator', 'init' ) ); 46 46 47 // Register CRON hooks 48 register_activation_hook( __FILE__, array( 'CloudBlocks\Blocks\Explore', 'cron_schedule' ) ); 49 register_deactivation_hook( __FILE__, array( 'CloudBlocks\Blocks\Explore', 'cron_unschedule' ) ); 50 51 47 52 // Initiate plugin 48 53 new CloudBlocks\CloudBlocks; -
cloud-blocks/tags/1.1.4/core/Activator.php
r2005063 r2025157 1 <?php 1 <?php 2 2 3 3 namespace CloudBlocks; 4 5 use CloudBlocks\Blocks\Explore; 4 6 5 7 /** … … 10 12 */ 11 13 class Activator { 12 14 13 15 /** 14 16 * Current version of custom db table 15 17 * @param object 16 18 */ 17 public static $current_db_version = '1. 2';18 19 public static $current_db_version = '1.3'; 20 19 21 /** 20 22 * activate, runs at plugin activation. … … 25 27 public static function init() { 26 28 self::create_db(); 29 27 30 } 28 31 … … 37 40 $charset_collate = $wpdb->get_charset_collate(); 38 41 $table_name = $wpdb->prefix . str_replace( '-', '_', FGC_NAME ); 39 42 40 43 $sql = "CREATE TABLE $table_name ( 41 44 id mediumint(9) NOT NULL AUTO_INCREMENT, … … 51 54 block_installed datetime DEFAULT CURRENT_TIMESTAMP, 52 55 block_updated datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 56 available_version varchar(10) DEFAULT '' NOT NULL, 53 57 PRIMARY KEY (id) 54 58 ) $charset_collate;"; 55 59 56 60 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 57 61 dbDelta( $sql ); … … 59 63 update_option( 'gutenberg_cloud_db_version', '1.0' ); 60 64 } 61 65 62 66 63 67 /** … … 88 92 block_installed datetime DEFAULT CURRENT_TIMESTAMP, 89 93 block_updated datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 94 available_version varchar(10) DEFAULT '' NOT NULL, 90 95 PRIMARY KEY (id) 91 96 ) $charset_collate;"; … … 98 103 99 104 } 100 105 101 106 } -
cloud-blocks/tags/1.1.4/core/Blocks/Blocks.php
r2020451 r2025157 25 25 add_action( 'wp_ajax_fgc_update_block', array( $this, 'update' ) ); 26 26 add_action( 'wp_ajax_nopriv_fgc_update_block', array( $this, 'update' ) ); 27 28 add_action( 'wp_ajax_fgc_update_version', array( $this, 'update_version' ) ); 29 add_action( 'wp_ajax_nopriv_fgc_update_version', array( $this, 'update_version' ) ); 27 30 28 31 add_action( 'wp_ajax_fgc_local_blocks', array( $this, 'local_blocks' ) ); … … 62 65 'thumbnail' => isset( $block['imageUrl'] ) ? $block['imageUrl'] : '', 63 66 'block_version' => isset( $block['version'] ) ? $block['version'] : '', 64 'block_manifest' => isset( $block['blockManifest'] ) ? $block['blockManifest'] : '' 67 'block_manifest' => isset( $block['blockManifest'] ) ? $block['blockManifest'] : '', 68 'available_version' => isset( $block['availVersion'] ) ? $block['availVersion'] : '' 65 69 ); 66 70 Options::add( $new_block, true ); … … 126 130 'thumbnail' => isset( $block['imageUrl'] ) ? $block['imageUrl'] : '', 127 131 'block_version' => isset( $block['version'] ) ? $block['version'] : '', 128 'block_manifest' => isset( $block['blockManifest'] ) ? $block['blockManifest'] : '' 132 'block_manifest' => isset( $block['blockManifest'] ) ? $block['blockManifest'] : '', 133 'available_version' => isset( $block['availVersion'] ) ? $block['availVersion'] : '' 129 134 ); 130 135 … … 151 156 ); 152 157 wp_send_json_success( $response ); 158 } 159 160 /** 161 * Update available block version. 162 * 163 * @since 1.1.4 164 * @param 165 * @return 166 */ 167 public static function update_version( $block = false ) { 168 if( !$block ) { 169 $block = $_REQUEST['data']; 170 } 171 172 if ( isset( $block ) ) { 173 $the_block = array( 174 'package_name' => isset( $block['packageName'] ) ? $block['packageName'] : $block['package']['name'], 175 'available_version' => isset( $block['availVersion'] ) ? $block['availVersion'] : $block['version'] 176 ); 177 178 $existing_block = Options::get( $the_block['package_name'] ); 179 $block_id = Options::update_version( $existing_block->id, $the_block ); 180 181 if ( isset( $block_id ) ) { 182 $response = array( 183 'code' => 200, 184 'message' => 'Succesfully updated.' 185 ); 186 } else { 187 $response = array( 188 'code' => 400, 189 'message' => 'Version could not be updated!' 190 ); 191 } 192 wp_send_json_success( $response ); 193 } 194 $response = array( 195 'code' => 400, 196 'message' => 'Version could not be updated!' 197 ); 198 wp_send_json_success( $response ); 153 199 } 154 200 … … 191 237 $block_script = null; 192 238 $block_thumbnail = null; 193 239 194 240 // Extract block js and css files 195 241 foreach ($block_files as $file) { … … 204 250 } 205 251 } 206 // Extract block screenshot 252 // Extract block screenshot 207 253 foreach ($screenshot as $img) { 208 254 if ( preg_match('/thumbnail|screenshot/i', $img) ) { … … 245 291 ); 246 292 247 293 248 294 } 249 295 … … 269 315 $block = str_replace( $destination['baseurl'] . '/gutenberg-blocks/', '', $block ); 270 316 preg_match( '/[a-zA-Z0-9-_]*(?!:\/)/i', $block, $block_dir ); 271 317 272 318 $filesystem = new \WP_Filesystem_Direct(array()); 273 319 $removed = $filesystem->delete( $destination_path . $block_dir[0], true ); … … 307 353 foreach ($blocks as $block) { 308 354 /** 309 * Use this filter in your functions.php or custom plugin 355 * Use this filter in your functions.php or custom plugin 310 356 * to enable/disable styling per individual block or for all of them. 311 357 */ … … 314 360 wp_register_style( str_replace( ' ', '-', $block->block_name ) , $block->css_url, array(), $block->block_version); 315 361 wp_enqueue_style( str_replace( ' ', '-', $block->block_name ) ); 316 362 317 363 if (is_admin() && isset( $block->editor_css ) && !empty( $block->editor_css ) ) { 318 364 wp_register_style( str_replace( ' ', '-', $block->block_name ) . '-editor' , $block->editor_css, array(), $block->block_version); -
cloud-blocks/tags/1.1.4/core/Blocks/Explore.php
r2011877 r2025157 3 3 namespace CloudBlocks\Blocks; 4 4 5 use CloudBlocks\Blocks\Options; 6 use CloudBlocks\Blocks\Blocks; 7 5 8 class Explore { 6 9 7 10 /** 8 11 * @param object $page_title … … 25 28 self::$page_title = ucwords( str_replace( '-', ' ', FGC_NAME ) ); 26 29 self::$menu_slug = FGC_NAME; 27 // Add menu 28 add_action( 'admin_menu', array( __class__, 'add_menu') ); 30 31 // Add menu 32 add_action( 'admin_menu', array( __CLASS__, 'add_menu') ); 29 33 // Handle uploading custom blocks as zip files 30 34 add_action( 'init', array( __CLASS__, 'upload_block' ) ); 35 // Schedule cron with check updates 36 add_action( 'admin_init', array( __CLASS__, 'cron_schedule' ) ); 37 add_action( 'fgc_cron_check_updates', array( __CLASS__, 'check_updates' ) ); 31 38 } 32 39 … … 51 58 $okay = true; 52 59 break; 53 } 54 } 55 60 } 61 } 62 56 63 $continue = strtolower( $name[1] ) == 'zip' ? true : false; 57 64 if ( !$continue ) { … … 63 70 $destination_path = $destination['basedir'] . '/gutenberg-blocks/'; 64 71 $create_folder = wp_mkdir_p( $destination_path ); 65 72 66 73 // Here the magic happens. 67 74 if ( move_uploaded_file( $source, $destination_path . $filename ) ) { … … 101 108 ); 102 109 } 103 110 104 111 /** 105 112 * Settings page output. … … 135 142 </div> 136 143 </div> 137 144 138 145 <admin-notice></admin-notice> 139 146 <explorer-filter></explorer-filter> 140 147 141 148 <div class="theme-browser content-filterable rendered"> 142 149 <div class="themes wp-clearfix"> … … 157 164 * @return $counter 158 165 */ 159 160 166 public static function count_updates() { 161 167 $counter = 0; 162 163 168 $installed_blocks = Options::get_all(); 169 164 170 foreach ($installed_blocks as $block) { 165 // We must check if block is not local block, then we check for new versi noavailability171 // We must check if block is not local block, then we check for new version availability 166 172 $manifest = json_decode( stripslashes( $block->block_manifest ), true ); 167 if ( empty($manifest['isLocal']) ) { 168 $args = array( 169 'method' => 'GET' 170 ); 171 $response = wp_remote_request( 'https://api.gutenbergcloud.org/blocks/' . $block->package_name, $args ); 172 $body = wp_remote_retrieve_body( $response ); 173 $json = json_decode($body, true); 174 175 if( !empty($json['version']) && $json['version'] !== $block->block_version) { 176 $counter++; 173 174 if( empty($manifest['isLocal']) && !empty($block->available_version) && version_compare($block->available_version, $block->block_version, '>')) { 175 $counter++; 176 } 177 } 178 179 return $counter; 180 } 181 182 /** 183 * CRON schedule. 184 * 185 * @since 1.1.4 186 * @param 187 * @return 188 */ 189 public static function cron_schedule() { 190 if ( !wp_next_scheduled( 'fgc_cron_check_updates' ) ) { 191 wp_schedule_event(time(), 'daily', 'fgc_cron_check_updates'); 192 } 193 } 194 195 /** 196 * CRON unschedule. 197 * 198 * @since 1.1.4 199 * @param 200 * @return 201 */ 202 public static function cron_unschedule() { 203 wp_clear_scheduled_hook('fgc_cron_check_updates'); 204 } 205 206 /** 207 * CRON schedule. 208 * 209 * @since 1.1.4 210 * @param 211 * @return 212 */ 213 public static function check_updates() { 214 $installed_blocks = Options::get_all(); 215 216 foreach ( $installed_blocks as $block ) { 217 // We must check if block is not local block, then we check for new version availability 218 $manifest = json_decode( stripslashes( $block->block_manifest ), true ); 219 if ( empty( $manifest['isLocal'] ) ) { 220 $args = array( 221 'method' => 'GET' 222 ); 223 $response = wp_remote_request( 'https://api.gutenbergcloud.org/blocks/' . $block->package_name, $args ); 224 $body = wp_remote_retrieve_body( $response ); 225 $the_block = json_decode( $body, true ); 226 227 if( !empty($the_block['version']) && $the_block['version'] !== $block->block_version) { 228 $_REQUEST['data'] = $the_block; 229 Blocks::update_version($the_block); 230 } 177 231 } 178 232 } 179 } 180 181 return $counter; 233 182 234 } 183 235 -
cloud-blocks/tags/1.1.4/core/Blocks/Options.php
r1962907 r2025157 153 153 'thumbnail' => $thumbnail, 154 154 'block_version' => $block_version, 155 'block_manifest' => $block_manifest 155 'block_manifest' => $block_manifest, 156 'available_version' => '' 156 157 ), 157 158 array( … … 163 164 } 164 165 166 /** 167 * Update existing value in database. 168 * @since 1.1.4 169 * @param array $options The options need to be stored into database 170 * @return int $id Inserted records id 171 */ 172 public static function update_version( $id, $options ) { 173 global $wpdb; 174 175 $available_version = $options['available_version']; 176 177 $table_name = $wpdb->prefix . str_replace( '-', '_', FGC_NAME ); 178 179 $id = $wpdb->update( 180 $table_name, 181 array( 182 'available_version' => $available_version 183 ), 184 array( 185 'id' => $id 186 ) 187 ); 188 189 return $id; 190 } 191 165 192 /** 166 193 * Get all installed blocks. … … 209 236 210 237 /** 211 * Increa te number of installs on api.gutenbergcloud.org238 * Increase number of installs on api.gutenbergcloud.org 212 239 * @since 1.0.0 213 240 * @param string|null $package_name npm package name 214 241 * @return object|null $body Request response 215 242 */ 216 public static function increa te_installs( $package_name = null ) {243 public static function increase_installs( $package_name = null ) { 217 244 if ( empty( $package_name ) ) { 218 245 return; -
cloud-blocks/tags/1.1.4/core/CloudBlocks.php
r2020434 r2025157 20 20 public function __construct() { 21 21 global $wp_version; 22 22 23 23 include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 24 24 if ( \is_plugin_active( 'gutenberg/gutenberg.php' ) || (int) $wp_version >= 5 ) { … … 80 80 */ 81 81 public function enqueue_scripts() { 82 wp_enqueue_script( 'vuejs', 'https:// unpkg.com/vue@2.5.17/dist/vue.min.js', array( 'jquery' ), FGC_VERSION, true );83 wp_enqueue_script( 'vuex', 'https:// unpkg.com/vuex@3.0.1/dist/vuex.min.js', array('vuejs'), FGC_VERSION, TRUE);82 wp_enqueue_script( 'vuejs', 'https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.min.js', array( 'jquery' ), FGC_VERSION, true ); 83 wp_enqueue_script( 'vuex', 'https://cdn.jsdelivr.net/npm/vuex@3.1.0/dist/vuex.min.js', array( 'vuejs' ), FGC_VERSION, true ); 84 84 wp_enqueue_script( 'gutenberg_cloud_admin_js', FGC_URL . 'assets/js/script.js', array( 'jquery', 'vuejs', 'vuex' ), FGC_VERSION, true ); 85 85 $localized_data = array( -
cloud-blocks/tags/1.1.4/core/Settings/Tools.php
r1961288 r2025157 106 106 self::add_notice( sprintf(__('Block <b>%s</b> already installed.', 'gutenberg-cloug'), $imported->block_name ), 'error' ); 107 107 } else { 108 Options::increa te_installs( $block['package_name'] );108 Options::increase_installs( $block['package_name'] ); 109 109 self::add_notice( sprintf(__('Block <b>%s</b> installed successfully.', 'gutenberg-cloug'), $block['block_name'] ), 'success' ); 110 110 } -
cloud-blocks/tags/1.1.4/docs/changelog.md
r2020451 r2025157 1 1 ## Changelog 2 3 #### 1.1.4 4 * **Change**: Update counter as a WP CRON (Thanks to [ajotka](https://github.com/front/cloud-blocks/pull/14)) 5 * **Change**: Update some docs 6 * **Fix**: Fix polish translations 2 7 3 8 #### 1.1.3 -
cloud-blocks/tags/1.1.4/docs/create-block.md
r1965688 r2025157 89 89 Custom blocks generated by create-cloud-block tool come with all configuration needed to be distributed by Cloud Blocks. Also they have a deploy script which complies the build files and publish the package to NPM, so all we have to do is run `$ npm run deploy`. 90 90 91 After about 15 minutes, your custom block is available to the world through [api.gutenbergcloud.org/blocks](https://api.gutenbergcloud.org/blocks). Congrats!91 After our review, your custom block is available to the world through [api.gutenbergcloud.org/blocks](https://api.gutenbergcloud.org/blocks). Congrats! 92 92 93 93 ## Documentation -
cloud-blocks/tags/1.1.4/docs/migrate-block.md
r1965688 r2025157 147 147 or just `$ npm run deploy` if you used create-cloud-block tool. 148 148 149 That’s it! Your block will be available to Gutenberg Cloud in a few minutes. Bravo!149 That’s it! Your block will be available to Gutenberg Cloud after our review. Bravo! -
cloud-blocks/tags/1.1.4/languages/cloud-blocks-pl_PL.po
r2011879 r2025157 30 30 "again." 31 31 msgstr "" 32 "Plik, który próbujesz załadować zawiera niepoprawne rozszerzenie . Spróbuj "32 "Plik, który próbujesz załadować zawiera niepoprawne rozszerzenie. Spróbuj " 33 33 "ponownie." 34 34 … … 125 125 msgstr "" 126 126 "Eksport wszystkich zainstalowanych bloków z Chmury Gutenberga jako plik JSON." 127 " Uwaga: Treść bloków nie będzie wyeksportowana."127 " Uwaga: Treść bloków nie będzie eksportowana." 128 128 129 129 #: core/Settings/Tools.php:224 … … 229 229 #: core/Settings/Translations.php:38 230 230 msgid "have been installed successfully." 231 msgstr "został o pomyślnie zainstalowane."231 msgstr "został pomyślnie zainstalowany." 232 232 233 233 #: core/Settings/Translations.php:39 234 234 msgid "have been uninstalled successfully." 235 msgstr "został o pomyślnie odinstalowane."235 msgstr "został pomyślnie odinstalowany." 236 236 237 237 #: core/Settings/Translations.php:40 238 238 msgid "have been deleted successfully." 239 msgstr "został o pomyślnie usunięte."239 msgstr "został pomyślnie usunięty." 240 240 241 241 #: core/Settings/Translations.php:41 242 242 msgid "have been updated successfully." 243 msgstr "został o pomyślnie zaktualizowane."243 msgstr "został pomyślnie zaktualizowany." 244 244 245 245 #: core/Settings/Translations.php:42 … … 253 253 #: core/Settings/Translations.php:44 254 254 msgid "Visit homepage" 255 msgstr "Odwiedź stronę główną"255 msgstr "Odwiedź stronę bloku" 256 256 257 257 #: core/Settings/Translations.php:45 258 258 msgid "Homepage" 259 msgstr "Strona Główna"259 msgstr "Strona Bloku" 260 260 261 261 #: vendor/foadyousefi/seven-fields/src/Container/Container.php:196 -
cloud-blocks/tags/1.1.4/readme.txt
r2020451 r2025157 6 6 Tested up to: 5.0 7 7 Requires PHP: 5.4 8 Stable tag: 1.1. 38 Stable tag: 1.1.4 9 9 License: GPLv3 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 75 75 76 76 == Changelog == 77 78 = 1.1.4 = 79 * Change: Update counter as a WP CRON (Thanks to [ajotka](https://github.com/front/cloud-blocks/pull/14)) 80 * Change: Update some docs 81 * Fix: Fix polish translations 77 82 78 83 = 1.1.3 = -
cloud-blocks/trunk/assets/js/script.js
r2011877 r2025157 116 116 theBlock.version = block.version 117 117 theBlock.packageName = block.name 118 119 if (res.version && b.block_version < res.version) { 120 this.updateAvailable = true 121 theBlock.availVersion = block.version 122 } 123 118 124 this.fromCloud = theBlock 119 } 120 if (res && res.version && b.block_version < res.version) { 121 this.updateAvailable = true 125 126 if (this.updateAvailable) { 127 this.setAvalVersion() 128 } 122 129 } 123 130 }) … … 204 211 this.installing = false 205 212 console.log('There is some issues updating block: ', error) 213 }) 214 }, 215 setAvalVersion() { 216 let postData = this.fromCloud 217 jQuery.ajax({ 218 type: 'POST', 219 url: fgcData.ajaxUrl, 220 data: { 221 action: "fgc_update_version", 222 data: postData 223 } 224 }) 225 .done(res => { 226 console.log('Available new version ', res.data) 227 }) 228 .fail(error => { 229 console.log('There is some issues: ', error) 206 230 }) 207 231 }, -
cloud-blocks/trunk/assets/js/script.min.js
r2011877 r2025157 1 "use strict";function _typeof(a){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Vue.component("admin-notice",{data:function a(){return{activeTimeout:-1}},template:"\n <div\n :class=\"['fgc-notification', notification.class]\"\n v-cloak>\n <p v-html=\"notification.text\"></p>\n </div>\n ",watch:{isActive:function a(){this.showingTimeout()}},mounted:function a(){this.showingTimeout()},methods:{showingTimeout:function b(){var a=this;window.clearTimeout(this.activeTimeout),this.activeTimeout=window.setTimeout(function(){window.store.state.notification.class="",a.isShowing=!1},4e3)}},computed:{isActive:function a(){return window.store.state.notification.text},notification:function a(){return window.store.state.notification}}}),Vue.component("block-card",{props:["block"],data:function a(){return{installing:!1,alreadyInstaleld:!1,updateAvailable:!1,currentVersion:null,fromCloud:null}},template:"\n <div class=\"theme\">\n <div class=\"theme-screenshot\" @click=\"openMoreDetails\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"installing\"></div>\n </div>\n\n <div v-if=\"currentBrowseState != 'installed' && alreadyInstaleld\" class=\"notice inline notice-success notice-alt\"><p>{{fgcData.strings.installed}}</p></div>\n\n <div v-if=\"currentBrowseState == 'installed' && isLocalBlock\" class=\"notice inline notice-info notice-alt\"><p>{{fgcData.strings.local_block}}</p></div>\n\n <div v-if=\"updateAvailable\" class=\"update-message notice inline notice-warning notice-alt\">\n <p>{{fgcData.strings.update_available}} <button class=\"button-link\" type=\"button\" @click=\"updateBlock\">{{fgcData.strings.update_now}}</button></p>\n </div>\n\n <span class=\"more-details\" @click=\"openMoreDetails\">{{fgcData.strings.show_more_details}}</span>\n\n <div class=\"theme-id-container\">\n <h3 class=\"theme-name\">{{ block.name }}</h3>\n <span v-if=\"blockManifest && blockManifest.author\" class=\"block-author\">{{fgcData.strings.by}}: \n <span v-if=\"typeof blockManifest.author == 'object'\">\n {{ blockManifest.author.name }}\n </span>\n <span v-if=\"typeof blockManifest.author == 'string'\">\n {{ blockManifest.author }}\n </span>\n </span>\n <span v-else class=\"block-version\">{{fgcData.strings.version}}: {{ currentVersion }}</span>\n\n <div class=\"theme-actions\">\n <button class=\"button button-primary theme-install install-block-btn\"\n v-if=\"currentBrowseState != 'installed' && !alreadyInstaleld\"\n @click.prevent=\"installBlock\">\n {{fgcData.strings.install}}\n </button>\n <button class=\"button theme-install install-block-btn\"\n v-else\n @click.prevent=\"uninstallBlock\">\n {{fgcData.strings.uninstall}}\n </button>\n <a class=\"button button-primary\" :href=\"blockUrl\" target=\"_blank\">{{fgcData.strings.homepage}}</a>\n </div>\n </div>\n\n </div>\n ",mounted:function b(){var a=this;this.currentVersion=this.block.version,!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld="installed"!=this.currentBrowseState,"installed"==this.currentBrowseState&&(window.store.state.installedBlocks.map(function(c){c.package_name!=a.block.packageName||a.isLocalBlock||jQuery.get("https://api.gutenbergcloud.org/blocks/".concat(c.package_name),function(b){if(b){var d=b,e={};e.jsUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name, a.fromCloud=e}b&&b.version&&c.block_version<b.version&&(a.updateAvailable=!0)})}),this.currentVersion=window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName})[0].block_version))},methods:{installBlock:function c(){var a=this;this.installing=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!0,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this;this.installing=!0;var b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},updateBlock:function c(){var a=this;this.installing=!0;var b=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_block",data:b}}).done(function(b){a.installing=!1,a.updateAvailable=!1,a.currentVersion=a.block.version,window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_updated),class:"show success"}),console.log("Block Updated ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues updating block: ",b)})},incrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:-1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},openMoreDetails:function a(){window.store.commit("openOverlay",this.block)}},computed:{currentBrowseState:function a(){return window.store.state.browseState},blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)}}}),Vue.component("block-details",{props:["block"],data:function a(){return{alreadyInstaleld:!1,spinnerLoaded:!1}},template:"\n <div class=\"theme-overlay\" tabindex=\"0\" role=\"dialog\"><div class=\"theme-overlay\">\n <div class=\"theme-backdrop\"></div>\n <div class=\"theme-wrap wp-clearfix\" role=\"document\">\n <div class=\"theme-header\">\n <button class=\"close dashicons dashicons-no\" @click=\"closeOverlay\"></button>\n </div>\n\n <div class=\"theme-about wp-clearfix\">\n <div class=\"theme-screenshots\">\n <div class=\"screenshot\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"spinnerLoaded\"></div>\n </div>\n </div>\n\n <div class=\"theme-info\">\n <h2 class=\"theme-name\">\n {{ block.name }}\n <span class=\"theme-version\">{{fgcData.strings.version}}: {{ block.version }}</span>\n </h2>\n <p v-if=\"blockAuthor && authorUrl\" class=\"theme-author\">{{fgcData.strings.by}} <a :href=\"authorUrl\" target=\"_blank\">{{ blockAuthor }} </a></p>\n <p v-else-if=\"blockAuthor\" class=\"theme-author\">{{fgcData.strings.by}} {{ blockAuthor }}</p>\n\n \n <p class=\"theme-description\">\n {{ blockManifest.description }}\n </p>\n\n <p class=\"theme-tags\">\n <span>{{fgcData.strings.tags}}:</span>{{ blockTags }}\n </p>\n \n </div>\n </div>\n\n <div class=\"theme-actions\">\n <div class=\"inactive-theme\">\n <a v-if=\"alreadyInstaleld\" @click.prevent=\"uninstallBlock\" class=\"button activate\">{{fgcData.strings.uninstall}}</a>\n <a v-else @click.prevent=\"installBlock\" class=\"button activate\">{{fgcData.strings.install}}</a>\n <a :href=\"blockUrl\" target=\"_blank\" class=\"button button-primary load-customize hide-if-no-customize\">{{fgcData.strings.visit_homepage}}</a>\n <a v-if=\"isLocalBlock\" class=\"button install-block-btn button-delete load-customize hide-if-no-customize\" @click.prevent=\"deleteBlock\">{{fgcData.strings.delete_block}}</a>\n </div>\n </div>\n </div>\n </div>\n </div>",mounted:function b(){var a=this;window.addEventListener("keyup",this.keypressEvent),!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld=!0)},computed:{blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)},authorUrl:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:this.blockManifest.homepage?this.blockManifest.homepage:"https://www.npmjs.com/package/".concat(this.block.packageName)},blockAuthor:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.name?this.blockManifest.author.name:this.blockManifest.author&&"string"==typeof this.blockManifest.author?this.blockManifest.author:null},blockTags:function a(){return this.blockManifest?this.blockManifest.keywords.join(", "):""}},methods:{keypressEvent:function b(a){27===a.keyCode&&this.closeOverlay()},closeOverlay:function a(){window.store.commit("openOverlay",null)},installBlock:function c(){var a=this;this.spinnerLoaded=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.alreadyInstaleld=!0,a.spinnerLoaded=!1,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},deleteBlock:function c(){var a=this;this.spinnerLoaded=!0,this.alreadyInstaleld&&this.uninstallBlock();var b={block:this.block,nonce:fgcData.ajaxNonce};jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_delete_block",data:b}}).done(function(b){window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_deleted),class:"show success"}),window.store.commit("setRefetchBlocks",!0),a.closeOverlay(),a.spinnerLoaded=!1,window.store.dispatch("getInstalledBlocks"),console.log("Block removed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this,b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},incrementInstalls:function b(a){jQuery.ajax({type:"PUT",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"DELETE",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})}}}),Vue.component("explorer-filter",{componenets:["filter-drawer"],data:function a(){return{drawerFilterOpen:!1,searchQuery:null,filterLinks:[{name:fgcData.strings.installed,slug:"installed"},{name:fgcData.strings.popular,slug:"popular"},{name:fgcData.strings.latest,slug:"latest"},{name:fgcData.strings.local,slug:"local"}]}},template:"\n <div class=\"wp-filter g-blocks-filter hide-if-no-js\">\n <div class=\"filter-count\">\n <span class=\"count theme-count\">{{ blocksCount }}</span>\n </div>\n\n <ul class=\"filter-links\">\n <li><a v-for=\"filter in filterLinks\" :key=\"filter.slug\" @click=\"filterLink(filter.slug)\" :class=\"currentFilter(filter.slug)\">{{ filter.name }}</a></li>\n </ul>\n\n <button type=\"button\" v-if=\"false\" id=\"searchFilter\" class=\"button drawer-toggle\" :aria-expanded=\"drawerFilterOpen\" @click=\"drawerFilterOpen = !drawerFilterOpen\">{{fgcData.strings.filter}}</button>\n\n <form class=\"search-form\" @submit.prevent=\"searchForBlock\"><label class=\"screen-reader-text\" for=\"wp-filter-search-input\">{{fgcData.strings.search_for_blocks}}</label><input :placeholder=\"fgcData.strings.search_blocks\" v-model=\"searchQuery\" type=\"search\" id=\"wp-filter-search-input\" class=\"wp-filter-search\"></form>\n\n <filter-drawer :style=\"{display: drawerFilterOpen ? 'block' : 'none'}\"></filter-drawer>\n </div>\n ",mounted:function a(){window.store.state.installedBlocks.length||"local"==window.store.state.browseState||this.filterLink("popular")},methods:{filterLink:function c(a){var b=window.location.search.replace(/\&browse[=a-z]*/,"");history.pushState({state:a},null,"".concat(b,"&browse=").concat(a)),window.store.commit("setBrowseState",a)},currentFilter:function b(a){return window.store.state.browseState==a?"current":""},searchForBlock:function c(){var a=window.location.search.replace(/\&q[=a-z\-]*/,""),b=this.searchQuery.replace(/\s+/g,"-").toLowerCase();history.pushState({state:b},null,"".concat(a,"&q=").concat(b)),window.store.commit("setSearchQuery",b)}},computed:{blocksCount:function a(){return"installed"===window.store.state.browseState?window.store.state.installedBlocks.length:window.store.state.blocksCount}}}),Vue.component("filter-drawer",{template:"\n <div class=\"filter-drawer\">\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n <fieldset class=\"filter-group\">\n <legend>Subject</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-blog\" value=\"blog\">\n <label for=\"filter-id-blog\">Blog</label>\n <input type=\"checkbox\" id=\"filter-id-e-commerce\" value=\"e-commerce\">\n <label for=\"filter-id-e-commerce\">E-Commerce</label>\n <input type=\"checkbox\" id=\"filter-id-education\" value=\"education\">\n <label for=\"filter-id-education\">Education</label>\n <input type=\"checkbox\" id=\"filter-id-entertainment\" value=\"entertainment\">\n <label for=\"filter-id-entertainment\">News</label>\n </div>\n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Features</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-accessibility-ready\" value=\"accessibility-ready\">\n <label for=\"filter-id-accessibility-ready\">Custom Colors</label>\n <input type=\"checkbox\" id=\"filter-id-custom-background\" value=\"custom-background\">\n <label for=\"filter-id-custom-background\">Editor style</label>\n <input type=\"checkbox\" id=\"filter-id-custom-colors\" value=\"custom-colors\">\n <label for=\"filter-id-custom-colors\">Full Width Template</label>\n </div> \n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Layout</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-grid-layout\" value=\"grid-layout\">\n <label for=\"filter-id-grid-layout\">Grid-layout</label>\n <input type=\"checkbox\" id=\"filter-id-one-column\" value=\"one-column\">\n <label for=\"filter-id-one-column\">One Column</label>\n <input type=\"checkbox\" id=\"filter-id-two-columns\" value=\"two-columns\">\n <label for=\"filter-id-two-columns\">Two Column</label>\n <input type=\"checkbox\" id=\"filter-id-three-columns\" value=\"three-columns\">\n <label for=\"filter-id-three-columns\">Responsive</label>\n </div>\n </fieldset>\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n\n </div>\n "});var store=new Vuex.Store({state:{notification:{},browseState:null,installedBlocks:fgcData.installedBlocks,searchQuery:null,opendOverlay:null,blocksCount:0,refetchBlocks:!1},mutations:{setNotification:function c(a,b){a.notification=b},setBrowseState:function c(a,b){a.browseState=b},setInstalledBlocks:function c(a,b){a.installedBlocks=b},setSearchQuery:function c(a,b){a.searchQuery=b},openOverlay:function c(a,b){a.opendOverlay=b},setBlocksCount:function c(a,b){a.blocksCount=b},setRefetchBlocks:function c(a,b){a.refetchBlocks=b}},actions:{getInstalledBlocks:function b(a){jQuery.ajax({type:"GET",url:fgcData.ajaxUrl,data:{action:"fgc_get_all_blocks"}}).done(function(b){a.commit("setInstalledBlocks",b.data)}).fail(function(a){console.log("There is some issues installing block: ",a)})}}}),app=new Vue({el:"#blockExplorer",data:function a(){return{blocks:[]}},created:function c(){window.store.dispatch("getInstalledBlocks");var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed",b=this.getUrlParams("q")?this.getUrlParams("q"):"";this.getBlocks({state:a,q:b}),window.store.commit("setBrowseState",a)},mounted:function a(){window.addEventListener("popstate",this.fetchBlocks)},watch:{currentBrowseFilter:function c(a){var b=this.getUrlParams("q")?this.getUrlParams("q"):"";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:a,q:b})},currentSearchQuery:function c(a){var b=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:b,q:a})},installedBlocks:function d(a,b){var c=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";a.length!=b.length&&"installed"==c&&(this.blocks=this.blocks.filter(function(b){return a.some(function(a){return a.package_name==b.packageName})}))},refetchBlocks:function b(){var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";this.getBlocks({state:a})}},methods:{fetchBlocks:function c(a){var b=null;a.state&&(b=a.state.state),this.getBlocks(b)},getBlocks:function l(a){var b=this,c=[],d="";if(a.q&&null!==a.q&&(d="q=".concat(a.q)),null!==a.state&&(d+="&order=".concat(a.state)),null!=a.state&&"installed"!=a.state)"local"==a.state?this.localBlocks(a):jQuery.get("https://api.gutenbergcloud.org/blocks?".concat(d),function(d){d.count&&window.store.commit("setBlocksCount",d.count);var e=!0,f=!1,g=void 0;try{for(var h,i=function(){var d=h.value,e={};e.jsUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,null==a.state||"installed"==a.state?b.installedBlocks.length&&b.installedBlocks.filter(function(a){return a.package_name==e.packageName}).length&&c.push(e):c.push(e)},j=d.rows[Symbol.iterator]();!(e=(h=j.next()).done);e=!0)i()}catch(a){f=!0,g=a}finally{try{e||null==j.return||j.return()}finally{if(f)throw g}}});else if(this.installedBlocks.length){var e=!0,f=!1,g=void 0;try{for(var h,i=this.installedBlocks[Symbol.iterator]();!(e=(h=i.next()).done);e=!0){var j=h.value,k={};k.jsUrl=j.js_url,k.cssUrl=j.css_url,k.editorCss=j.editor_css,k.infoUrl=j.info_url,k.imageUrl=j.thumbnail,k.name=j.block_name,k.blockManifest="\""+j.block_manifest+"\"",k.version=j.block_version,k.packageName=j.package_name,(a.q&&null!==a.q&&(-1<k.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<k.packageName.toLowerCase().indexOf(a.q.toLowerCase()))||!a.q)&&c.push(k)}}catch(a){f=!0,g=a}finally{try{e||null==i.return||i.return()}finally{if(f)throw g}}}this.blocks=c},getUrlParams:function e(a,b){b||(b=window.location.href),a=a.replace(/[\[\]]/g,"\\$&");var c=new RegExp("[?&]"+a+"(=([^&#]*)|&|#|$)"),d=c.exec(b);return d?d[2]?decodeURIComponent(d[2].replace(/\+/g," ")):"":null},showUploader:function a(){document.body.classList.toggle("show-upload-view")},localBlocks:function c(a){var b=this;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_local_blocks"}}).done(function(c){c.data.length?(window.store.commit("setBlocksCount",c.data.length),window.store.commit("setRefetchBlocks",!1)):window.store.commit("setBlocksCount",0),b.blocks=a.q&&null!==a.q?c.data.filter(function(b){return-1<b.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<b.packageName.toLowerCase().indexOf(a.q.toLowerCase())}):c.data}).fail(function(a){console.log("There is some issues getting local blocks: ",a)})}},computed:{currentBrowseFilter:function a(){return window.store.state.browseState},currentSearchQuery:function a(){return window.store.state.searchQuery},installedBlocks:function a(){return window.store.state.installedBlocks},openOverlay:function a(){return window.store.state.opendOverlay},refetchBlocks:function a(){return window.store.state.refetchBlocks}}});1 "use strict";function _typeof(a){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Vue.component("admin-notice",{data:function a(){return{activeTimeout:-1}},template:"\n <div\n :class=\"['fgc-notification', notification.class]\"\n v-cloak>\n <p v-html=\"notification.text\"></p>\n </div>\n ",watch:{isActive:function a(){this.showingTimeout()}},mounted:function a(){this.showingTimeout()},methods:{showingTimeout:function b(){var a=this;window.clearTimeout(this.activeTimeout),this.activeTimeout=window.setTimeout(function(){window.store.state.notification.class="",a.isShowing=!1},4e3)}},computed:{isActive:function a(){return window.store.state.notification.text},notification:function a(){return window.store.state.notification}}}),Vue.component("block-card",{props:["block"],data:function a(){return{installing:!1,alreadyInstaleld:!1,updateAvailable:!1,currentVersion:null,fromCloud:null}},template:"\n <div class=\"theme\">\n <div class=\"theme-screenshot\" @click=\"openMoreDetails\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"installing\"></div>\n </div>\n\n <div v-if=\"currentBrowseState != 'installed' && alreadyInstaleld\" class=\"notice inline notice-success notice-alt\"><p>{{fgcData.strings.installed}}</p></div>\n\n <div v-if=\"currentBrowseState == 'installed' && isLocalBlock\" class=\"notice inline notice-info notice-alt\"><p>{{fgcData.strings.local_block}}</p></div>\n\n <div v-if=\"updateAvailable\" class=\"update-message notice inline notice-warning notice-alt\">\n <p>{{fgcData.strings.update_available}} <button class=\"button-link\" type=\"button\" @click=\"updateBlock\">{{fgcData.strings.update_now}}</button></p>\n </div>\n\n <span class=\"more-details\" @click=\"openMoreDetails\">{{fgcData.strings.show_more_details}}</span>\n\n <div class=\"theme-id-container\">\n <h3 class=\"theme-name\">{{ block.name }}</h3>\n <span v-if=\"blockManifest && blockManifest.author\" class=\"block-author\">{{fgcData.strings.by}}: \n <span v-if=\"typeof blockManifest.author == 'object'\">\n {{ blockManifest.author.name }}\n </span>\n <span v-if=\"typeof blockManifest.author == 'string'\">\n {{ blockManifest.author }}\n </span>\n </span>\n <span v-else class=\"block-version\">{{fgcData.strings.version}}: {{ currentVersion }}</span>\n\n <div class=\"theme-actions\">\n <button class=\"button button-primary theme-install install-block-btn\"\n v-if=\"currentBrowseState != 'installed' && !alreadyInstaleld\"\n @click.prevent=\"installBlock\">\n {{fgcData.strings.install}}\n </button>\n <button class=\"button theme-install install-block-btn\"\n v-else\n @click.prevent=\"uninstallBlock\">\n {{fgcData.strings.uninstall}}\n </button>\n <a class=\"button button-primary\" :href=\"blockUrl\" target=\"_blank\">{{fgcData.strings.homepage}}</a>\n </div>\n </div>\n\n </div>\n ",mounted:function b(){var a=this;this.currentVersion=this.block.version,!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld="installed"!=this.currentBrowseState,"installed"==this.currentBrowseState&&(window.store.state.installedBlocks.map(function(c){c.package_name!=a.block.packageName||a.isLocalBlock||jQuery.get("https://api.gutenbergcloud.org/blocks/".concat(c.package_name),function(b){if(b){var d=b,e={};e.jsUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,b.version&&c.block_version<b.version&&(a.updateAvailable=!0,e.availVersion=d.version),a.fromCloud=e,a.updateAvailable&&a.setAvalVersion()}})}),this.currentVersion=window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName})[0].block_version))},methods:{installBlock:function c(){var a=this;this.installing=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!0,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this;this.installing=!0;var b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},updateBlock:function c(){var a=this;this.installing=!0;var b=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_block",data:b}}).done(function(b){a.installing=!1,a.updateAvailable=!1,a.currentVersion=a.block.version,window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_updated),class:"show success"}),console.log("Block Updated ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues updating block: ",b)})},setAvalVersion:function b(){var a=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_version",data:a}}).done(function(a){console.log("Available new version ",a.data)}).fail(function(a){console.log("There is some issues: ",a)})},incrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:-1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},openMoreDetails:function a(){window.store.commit("openOverlay",this.block)}},computed:{currentBrowseState:function a(){return window.store.state.browseState},blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)}}}),Vue.component("block-details",{props:["block"],data:function a(){return{alreadyInstaleld:!1,spinnerLoaded:!1}},template:"\n <div class=\"theme-overlay\" tabindex=\"0\" role=\"dialog\"><div class=\"theme-overlay\">\n <div class=\"theme-backdrop\"></div>\n <div class=\"theme-wrap wp-clearfix\" role=\"document\">\n <div class=\"theme-header\">\n <button class=\"close dashicons dashicons-no\" @click=\"closeOverlay\"></button>\n </div>\n\n <div class=\"theme-about wp-clearfix\">\n <div class=\"theme-screenshots\">\n <div class=\"screenshot\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"spinnerLoaded\"></div>\n </div>\n </div>\n\n <div class=\"theme-info\">\n <h2 class=\"theme-name\">\n {{ block.name }}\n <span class=\"theme-version\">{{fgcData.strings.version}}: {{ block.version }}</span>\n </h2>\n <p v-if=\"blockAuthor && authorUrl\" class=\"theme-author\">{{fgcData.strings.by}} <a :href=\"authorUrl\" target=\"_blank\">{{ blockAuthor }} </a></p>\n <p v-else-if=\"blockAuthor\" class=\"theme-author\">{{fgcData.strings.by}} {{ blockAuthor }}</p>\n\n \n <p class=\"theme-description\">\n {{ blockManifest.description }}\n </p>\n\n <p class=\"theme-tags\">\n <span>{{fgcData.strings.tags}}:</span>{{ blockTags }}\n </p>\n \n </div>\n </div>\n\n <div class=\"theme-actions\">\n <div class=\"inactive-theme\">\n <a v-if=\"alreadyInstaleld\" @click.prevent=\"uninstallBlock\" class=\"button activate\">{{fgcData.strings.uninstall}}</a>\n <a v-else @click.prevent=\"installBlock\" class=\"button activate\">{{fgcData.strings.install}}</a>\n <a :href=\"blockUrl\" target=\"_blank\" class=\"button button-primary load-customize hide-if-no-customize\">{{fgcData.strings.visit_homepage}}</a>\n <a v-if=\"isLocalBlock\" class=\"button install-block-btn button-delete load-customize hide-if-no-customize\" @click.prevent=\"deleteBlock\">{{fgcData.strings.delete_block}}</a>\n </div>\n </div>\n </div>\n </div>\n </div>",mounted:function b(){var a=this;window.addEventListener("keyup",this.keypressEvent),!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld=!0)},computed:{blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)},authorUrl:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:this.blockManifest.homepage?this.blockManifest.homepage:"https://www.npmjs.com/package/".concat(this.block.packageName)},blockAuthor:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.name?this.blockManifest.author.name:this.blockManifest.author&&"string"==typeof this.blockManifest.author?this.blockManifest.author:null},blockTags:function a(){return this.blockManifest?this.blockManifest.keywords.join(", "):""}},methods:{keypressEvent:function b(a){27===a.keyCode&&this.closeOverlay()},closeOverlay:function a(){window.store.commit("openOverlay",null)},installBlock:function c(){var a=this;this.spinnerLoaded=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.alreadyInstaleld=!0,a.spinnerLoaded=!1,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},deleteBlock:function c(){var a=this;this.spinnerLoaded=!0,this.alreadyInstaleld&&this.uninstallBlock();var b={block:this.block,nonce:fgcData.ajaxNonce};jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_delete_block",data:b}}).done(function(b){window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_deleted),class:"show success"}),window.store.commit("setRefetchBlocks",!0),a.closeOverlay(),a.spinnerLoaded=!1,window.store.dispatch("getInstalledBlocks"),console.log("Block removed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this,b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},incrementInstalls:function b(a){jQuery.ajax({type:"PUT",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"DELETE",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})}}}),Vue.component("explorer-filter",{componenets:["filter-drawer"],data:function a(){return{drawerFilterOpen:!1,searchQuery:null,filterLinks:[{name:fgcData.strings.installed,slug:"installed"},{name:fgcData.strings.popular,slug:"popular"},{name:fgcData.strings.latest,slug:"latest"},{name:fgcData.strings.local,slug:"local"}]}},template:"\n <div class=\"wp-filter g-blocks-filter hide-if-no-js\">\n <div class=\"filter-count\">\n <span class=\"count theme-count\">{{ blocksCount }}</span>\n </div>\n\n <ul class=\"filter-links\">\n <li><a v-for=\"filter in filterLinks\" :key=\"filter.slug\" @click=\"filterLink(filter.slug)\" :class=\"currentFilter(filter.slug)\">{{ filter.name }}</a></li>\n </ul>\n\n <button type=\"button\" v-if=\"false\" id=\"searchFilter\" class=\"button drawer-toggle\" :aria-expanded=\"drawerFilterOpen\" @click=\"drawerFilterOpen = !drawerFilterOpen\">{{fgcData.strings.filter}}</button>\n\n <form class=\"search-form\" @submit.prevent=\"searchForBlock\"><label class=\"screen-reader-text\" for=\"wp-filter-search-input\">{{fgcData.strings.search_for_blocks}}</label><input :placeholder=\"fgcData.strings.search_blocks\" v-model=\"searchQuery\" type=\"search\" id=\"wp-filter-search-input\" class=\"wp-filter-search\"></form>\n\n <filter-drawer :style=\"{display: drawerFilterOpen ? 'block' : 'none'}\"></filter-drawer>\n </div>\n ",mounted:function a(){window.store.state.installedBlocks.length||"local"==window.store.state.browseState||this.filterLink("popular")},methods:{filterLink:function c(a){var b=window.location.search.replace(/\&browse[=a-z]*/,"");history.pushState({state:a},null,"".concat(b,"&browse=").concat(a)),window.store.commit("setBrowseState",a)},currentFilter:function b(a){return window.store.state.browseState==a?"current":""},searchForBlock:function c(){var a=window.location.search.replace(/\&q[=a-z\-]*/,""),b=this.searchQuery.replace(/\s+/g,"-").toLowerCase();history.pushState({state:b},null,"".concat(a,"&q=").concat(b)),window.store.commit("setSearchQuery",b)}},computed:{blocksCount:function a(){return"installed"===window.store.state.browseState?window.store.state.installedBlocks.length:window.store.state.blocksCount}}}),Vue.component("filter-drawer",{template:"\n <div class=\"filter-drawer\">\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n <fieldset class=\"filter-group\">\n <legend>Subject</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-blog\" value=\"blog\">\n <label for=\"filter-id-blog\">Blog</label>\n <input type=\"checkbox\" id=\"filter-id-e-commerce\" value=\"e-commerce\">\n <label for=\"filter-id-e-commerce\">E-Commerce</label>\n <input type=\"checkbox\" id=\"filter-id-education\" value=\"education\">\n <label for=\"filter-id-education\">Education</label>\n <input type=\"checkbox\" id=\"filter-id-entertainment\" value=\"entertainment\">\n <label for=\"filter-id-entertainment\">News</label>\n </div>\n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Features</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-accessibility-ready\" value=\"accessibility-ready\">\n <label for=\"filter-id-accessibility-ready\">Custom Colors</label>\n <input type=\"checkbox\" id=\"filter-id-custom-background\" value=\"custom-background\">\n <label for=\"filter-id-custom-background\">Editor style</label>\n <input type=\"checkbox\" id=\"filter-id-custom-colors\" value=\"custom-colors\">\n <label for=\"filter-id-custom-colors\">Full Width Template</label>\n </div> \n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Layout</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-grid-layout\" value=\"grid-layout\">\n <label for=\"filter-id-grid-layout\">Grid-layout</label>\n <input type=\"checkbox\" id=\"filter-id-one-column\" value=\"one-column\">\n <label for=\"filter-id-one-column\">One Column</label>\n <input type=\"checkbox\" id=\"filter-id-two-columns\" value=\"two-columns\">\n <label for=\"filter-id-two-columns\">Two Column</label>\n <input type=\"checkbox\" id=\"filter-id-three-columns\" value=\"three-columns\">\n <label for=\"filter-id-three-columns\">Responsive</label>\n </div>\n </fieldset>\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n\n </div>\n "});var store=new Vuex.Store({state:{notification:{},browseState:null,installedBlocks:fgcData.installedBlocks,searchQuery:null,opendOverlay:null,blocksCount:0,refetchBlocks:!1},mutations:{setNotification:function c(a,b){a.notification=b},setBrowseState:function c(a,b){a.browseState=b},setInstalledBlocks:function c(a,b){a.installedBlocks=b},setSearchQuery:function c(a,b){a.searchQuery=b},openOverlay:function c(a,b){a.opendOverlay=b},setBlocksCount:function c(a,b){a.blocksCount=b},setRefetchBlocks:function c(a,b){a.refetchBlocks=b}},actions:{getInstalledBlocks:function b(a){jQuery.ajax({type:"GET",url:fgcData.ajaxUrl,data:{action:"fgc_get_all_blocks"}}).done(function(b){a.commit("setInstalledBlocks",b.data)}).fail(function(a){console.log("There is some issues installing block: ",a)})}}}),app=new Vue({el:"#blockExplorer",data:function a(){return{blocks:[]}},created:function c(){window.store.dispatch("getInstalledBlocks");var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed",b=this.getUrlParams("q")?this.getUrlParams("q"):"";this.getBlocks({state:a,q:b}),window.store.commit("setBrowseState",a)},mounted:function a(){window.addEventListener("popstate",this.fetchBlocks)},watch:{currentBrowseFilter:function c(a){var b=this.getUrlParams("q")?this.getUrlParams("q"):"";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:a,q:b})},currentSearchQuery:function c(a){var b=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:b,q:a})},installedBlocks:function d(a,b){var c=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";a.length!=b.length&&"installed"==c&&(this.blocks=this.blocks.filter(function(b){return a.some(function(a){return a.package_name==b.packageName})}))},refetchBlocks:function b(){var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";this.getBlocks({state:a})}},methods:{fetchBlocks:function c(a){var b=null;a.state&&(b=a.state.state),this.getBlocks(b)},getBlocks:function l(a){var b=this,c=[],d="";if(a.q&&null!==a.q&&(d="q=".concat(a.q)),null!==a.state&&(d+="&order=".concat(a.state)),null!=a.state&&"installed"!=a.state)"local"==a.state?this.localBlocks(a):jQuery.get("https://api.gutenbergcloud.org/blocks?".concat(d),function(d){d.count&&window.store.commit("setBlocksCount",d.count);var e=!0,f=!1,g=void 0;try{for(var h,i=function(){var d=h.value,e={};e.jsUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,null==a.state||"installed"==a.state?b.installedBlocks.length&&b.installedBlocks.filter(function(a){return a.package_name==e.packageName}).length&&c.push(e):c.push(e)},j=d.rows[Symbol.iterator]();!(e=(h=j.next()).done);e=!0)i()}catch(a){f=!0,g=a}finally{try{e||null==j.return||j.return()}finally{if(f)throw g}}});else if(this.installedBlocks.length){var e=!0,f=!1,g=void 0;try{for(var h,i=this.installedBlocks[Symbol.iterator]();!(e=(h=i.next()).done);e=!0){var j=h.value,k={};k.jsUrl=j.js_url,k.cssUrl=j.css_url,k.editorCss=j.editor_css,k.infoUrl=j.info_url,k.imageUrl=j.thumbnail,k.name=j.block_name,k.blockManifest="\""+j.block_manifest+"\"",k.version=j.block_version,k.packageName=j.package_name,(a.q&&null!==a.q&&(-1<k.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<k.packageName.toLowerCase().indexOf(a.q.toLowerCase()))||!a.q)&&c.push(k)}}catch(a){f=!0,g=a}finally{try{e||null==i.return||i.return()}finally{if(f)throw g}}}this.blocks=c},getUrlParams:function e(a,b){b||(b=window.location.href),a=a.replace(/[\[\]]/g,"\\$&");var c=new RegExp("[?&]"+a+"(=([^&#]*)|&|#|$)"),d=c.exec(b);return d?d[2]?decodeURIComponent(d[2].replace(/\+/g," ")):"":null},showUploader:function a(){document.body.classList.toggle("show-upload-view")},localBlocks:function c(a){var b=this;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_local_blocks"}}).done(function(c){c.data.length?(window.store.commit("setBlocksCount",c.data.length),window.store.commit("setRefetchBlocks",!1)):window.store.commit("setBlocksCount",0),b.blocks=a.q&&null!==a.q?c.data.filter(function(b){return-1<b.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<b.packageName.toLowerCase().indexOf(a.q.toLowerCase())}):c.data}).fail(function(a){console.log("There is some issues getting local blocks: ",a)})}},computed:{currentBrowseFilter:function a(){return window.store.state.browseState},currentSearchQuery:function a(){return window.store.state.searchQuery},installedBlocks:function a(){return window.store.state.installedBlocks},openOverlay:function a(){return window.store.state.opendOverlay},refetchBlocks:function a(){return window.store.state.refetchBlocks}}}); -
cloud-blocks/trunk/assets/source/js/block-component.js
r2007547 r2025157 76 76 theBlock.version = block.version 77 77 theBlock.packageName = block.name 78 79 if (res.version && b.block_version < res.version) { 80 this.updateAvailable = true 81 theBlock.availVersion = block.version 82 } 83 78 84 this.fromCloud = theBlock 79 } 80 if (res && res.version && b.block_version < res.version) { 81 this.updateAvailable = true 85 86 if (this.updateAvailable) { 87 this.setAvalVersion() 88 } 82 89 } 83 90 }) … … 166 173 }) 167 174 }, 175 setAvalVersion() { 176 let postData = this.fromCloud 177 jQuery.ajax({ 178 type: 'POST', 179 url: fgcData.ajaxUrl, 180 data: { 181 action: "fgc_update_version", 182 data: postData 183 } 184 }) 185 .done(res => { 186 console.log('Available new version ', res.data) 187 }) 188 .fail(error => { 189 console.log('There is some issues: ', error) 190 }) 191 }, 168 192 incrementInstalls(packageName) { 169 193 jQuery.ajax({ -
cloud-blocks/trunk/cloud-blocks.php
r2020434 r2025157 2 2 /* 3 3 Plugin Name: Cloud Blocks 4 Version: 1.1. 34 Version: 1.1.4 5 5 Description: Your library of Gutenberg blocks in the cloud 6 6 Author: Frontkom … … 30 30 // Plugin version . 31 31 if ( ! defined( 'FGC_VERSION' ) ) { 32 define( 'FGC_VERSION', '1.1. 3' );32 define( 'FGC_VERSION', '1.1.4' ); 33 33 } 34 34 … … 37 37 38 38 // Register text-domain for translations 39 add_action( 'plugins_loaded', 'fgc_register_t extdomain' );40 function fgc_register_t extdomain() {39 add_action( 'plugins_loaded', 'fgc_register_translations' ); 40 function fgc_register_translations() { 41 41 load_plugin_textdomain( 'cloud-blocks', false, basename( dirname( __FILE__ ) ) . '/languages' ); 42 42 } … … 45 45 register_activation_hook( __FILE__, array( 'CloudBlocks\Activator', 'init' ) ); 46 46 47 // Register CRON hooks 48 register_activation_hook( __FILE__, array( 'CloudBlocks\Blocks\Explore', 'cron_schedule' ) ); 49 register_deactivation_hook( __FILE__, array( 'CloudBlocks\Blocks\Explore', 'cron_unschedule' ) ); 50 51 47 52 // Initiate plugin 48 53 new CloudBlocks\CloudBlocks; -
cloud-blocks/trunk/core/Activator.php
r2005063 r2025157 1 <?php 1 <?php 2 2 3 3 namespace CloudBlocks; 4 5 use CloudBlocks\Blocks\Explore; 4 6 5 7 /** … … 10 12 */ 11 13 class Activator { 12 14 13 15 /** 14 16 * Current version of custom db table 15 17 * @param object 16 18 */ 17 public static $current_db_version = '1. 2';18 19 public static $current_db_version = '1.3'; 20 19 21 /** 20 22 * activate, runs at plugin activation. … … 25 27 public static function init() { 26 28 self::create_db(); 29 27 30 } 28 31 … … 37 40 $charset_collate = $wpdb->get_charset_collate(); 38 41 $table_name = $wpdb->prefix . str_replace( '-', '_', FGC_NAME ); 39 42 40 43 $sql = "CREATE TABLE $table_name ( 41 44 id mediumint(9) NOT NULL AUTO_INCREMENT, … … 51 54 block_installed datetime DEFAULT CURRENT_TIMESTAMP, 52 55 block_updated datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 56 available_version varchar(10) DEFAULT '' NOT NULL, 53 57 PRIMARY KEY (id) 54 58 ) $charset_collate;"; 55 59 56 60 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 57 61 dbDelta( $sql ); … … 59 63 update_option( 'gutenberg_cloud_db_version', '1.0' ); 60 64 } 61 65 62 66 63 67 /** … … 88 92 block_installed datetime DEFAULT CURRENT_TIMESTAMP, 89 93 block_updated datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 94 available_version varchar(10) DEFAULT '' NOT NULL, 90 95 PRIMARY KEY (id) 91 96 ) $charset_collate;"; … … 98 103 99 104 } 100 105 101 106 } -
cloud-blocks/trunk/core/Blocks/Blocks.php
r2020451 r2025157 25 25 add_action( 'wp_ajax_fgc_update_block', array( $this, 'update' ) ); 26 26 add_action( 'wp_ajax_nopriv_fgc_update_block', array( $this, 'update' ) ); 27 28 add_action( 'wp_ajax_fgc_update_version', array( $this, 'update_version' ) ); 29 add_action( 'wp_ajax_nopriv_fgc_update_version', array( $this, 'update_version' ) ); 27 30 28 31 add_action( 'wp_ajax_fgc_local_blocks', array( $this, 'local_blocks' ) ); … … 62 65 'thumbnail' => isset( $block['imageUrl'] ) ? $block['imageUrl'] : '', 63 66 'block_version' => isset( $block['version'] ) ? $block['version'] : '', 64 'block_manifest' => isset( $block['blockManifest'] ) ? $block['blockManifest'] : '' 67 'block_manifest' => isset( $block['blockManifest'] ) ? $block['blockManifest'] : '', 68 'available_version' => isset( $block['availVersion'] ) ? $block['availVersion'] : '' 65 69 ); 66 70 Options::add( $new_block, true ); … … 126 130 'thumbnail' => isset( $block['imageUrl'] ) ? $block['imageUrl'] : '', 127 131 'block_version' => isset( $block['version'] ) ? $block['version'] : '', 128 'block_manifest' => isset( $block['blockManifest'] ) ? $block['blockManifest'] : '' 132 'block_manifest' => isset( $block['blockManifest'] ) ? $block['blockManifest'] : '', 133 'available_version' => isset( $block['availVersion'] ) ? $block['availVersion'] : '' 129 134 ); 130 135 … … 151 156 ); 152 157 wp_send_json_success( $response ); 158 } 159 160 /** 161 * Update available block version. 162 * 163 * @since 1.1.4 164 * @param 165 * @return 166 */ 167 public static function update_version( $block = false ) { 168 if( !$block ) { 169 $block = $_REQUEST['data']; 170 } 171 172 if ( isset( $block ) ) { 173 $the_block = array( 174 'package_name' => isset( $block['packageName'] ) ? $block['packageName'] : $block['package']['name'], 175 'available_version' => isset( $block['availVersion'] ) ? $block['availVersion'] : $block['version'] 176 ); 177 178 $existing_block = Options::get( $the_block['package_name'] ); 179 $block_id = Options::update_version( $existing_block->id, $the_block ); 180 181 if ( isset( $block_id ) ) { 182 $response = array( 183 'code' => 200, 184 'message' => 'Succesfully updated.' 185 ); 186 } else { 187 $response = array( 188 'code' => 400, 189 'message' => 'Version could not be updated!' 190 ); 191 } 192 wp_send_json_success( $response ); 193 } 194 $response = array( 195 'code' => 400, 196 'message' => 'Version could not be updated!' 197 ); 198 wp_send_json_success( $response ); 153 199 } 154 200 … … 191 237 $block_script = null; 192 238 $block_thumbnail = null; 193 239 194 240 // Extract block js and css files 195 241 foreach ($block_files as $file) { … … 204 250 } 205 251 } 206 // Extract block screenshot 252 // Extract block screenshot 207 253 foreach ($screenshot as $img) { 208 254 if ( preg_match('/thumbnail|screenshot/i', $img) ) { … … 245 291 ); 246 292 247 293 248 294 } 249 295 … … 269 315 $block = str_replace( $destination['baseurl'] . '/gutenberg-blocks/', '', $block ); 270 316 preg_match( '/[a-zA-Z0-9-_]*(?!:\/)/i', $block, $block_dir ); 271 317 272 318 $filesystem = new \WP_Filesystem_Direct(array()); 273 319 $removed = $filesystem->delete( $destination_path . $block_dir[0], true ); … … 307 353 foreach ($blocks as $block) { 308 354 /** 309 * Use this filter in your functions.php or custom plugin 355 * Use this filter in your functions.php or custom plugin 310 356 * to enable/disable styling per individual block or for all of them. 311 357 */ … … 314 360 wp_register_style( str_replace( ' ', '-', $block->block_name ) , $block->css_url, array(), $block->block_version); 315 361 wp_enqueue_style( str_replace( ' ', '-', $block->block_name ) ); 316 362 317 363 if (is_admin() && isset( $block->editor_css ) && !empty( $block->editor_css ) ) { 318 364 wp_register_style( str_replace( ' ', '-', $block->block_name ) . '-editor' , $block->editor_css, array(), $block->block_version); -
cloud-blocks/trunk/core/Blocks/Explore.php
r2011877 r2025157 3 3 namespace CloudBlocks\Blocks; 4 4 5 use CloudBlocks\Blocks\Options; 6 use CloudBlocks\Blocks\Blocks; 7 5 8 class Explore { 6 9 7 10 /** 8 11 * @param object $page_title … … 25 28 self::$page_title = ucwords( str_replace( '-', ' ', FGC_NAME ) ); 26 29 self::$menu_slug = FGC_NAME; 27 // Add menu 28 add_action( 'admin_menu', array( __class__, 'add_menu') ); 30 31 // Add menu 32 add_action( 'admin_menu', array( __CLASS__, 'add_menu') ); 29 33 // Handle uploading custom blocks as zip files 30 34 add_action( 'init', array( __CLASS__, 'upload_block' ) ); 35 // Schedule cron with check updates 36 add_action( 'admin_init', array( __CLASS__, 'cron_schedule' ) ); 37 add_action( 'fgc_cron_check_updates', array( __CLASS__, 'check_updates' ) ); 31 38 } 32 39 … … 51 58 $okay = true; 52 59 break; 53 } 54 } 55 60 } 61 } 62 56 63 $continue = strtolower( $name[1] ) == 'zip' ? true : false; 57 64 if ( !$continue ) { … … 63 70 $destination_path = $destination['basedir'] . '/gutenberg-blocks/'; 64 71 $create_folder = wp_mkdir_p( $destination_path ); 65 72 66 73 // Here the magic happens. 67 74 if ( move_uploaded_file( $source, $destination_path . $filename ) ) { … … 101 108 ); 102 109 } 103 110 104 111 /** 105 112 * Settings page output. … … 135 142 </div> 136 143 </div> 137 144 138 145 <admin-notice></admin-notice> 139 146 <explorer-filter></explorer-filter> 140 147 141 148 <div class="theme-browser content-filterable rendered"> 142 149 <div class="themes wp-clearfix"> … … 157 164 * @return $counter 158 165 */ 159 160 166 public static function count_updates() { 161 167 $counter = 0; 162 163 168 $installed_blocks = Options::get_all(); 169 164 170 foreach ($installed_blocks as $block) { 165 // We must check if block is not local block, then we check for new versi noavailability171 // We must check if block is not local block, then we check for new version availability 166 172 $manifest = json_decode( stripslashes( $block->block_manifest ), true ); 167 if ( empty($manifest['isLocal']) ) { 168 $args = array( 169 'method' => 'GET' 170 ); 171 $response = wp_remote_request( 'https://api.gutenbergcloud.org/blocks/' . $block->package_name, $args ); 172 $body = wp_remote_retrieve_body( $response ); 173 $json = json_decode($body, true); 174 175 if( !empty($json['version']) && $json['version'] !== $block->block_version) { 176 $counter++; 173 174 if( empty($manifest['isLocal']) && !empty($block->available_version) && version_compare($block->available_version, $block->block_version, '>')) { 175 $counter++; 176 } 177 } 178 179 return $counter; 180 } 181 182 /** 183 * CRON schedule. 184 * 185 * @since 1.1.4 186 * @param 187 * @return 188 */ 189 public static function cron_schedule() { 190 if ( !wp_next_scheduled( 'fgc_cron_check_updates' ) ) { 191 wp_schedule_event(time(), 'daily', 'fgc_cron_check_updates'); 192 } 193 } 194 195 /** 196 * CRON unschedule. 197 * 198 * @since 1.1.4 199 * @param 200 * @return 201 */ 202 public static function cron_unschedule() { 203 wp_clear_scheduled_hook('fgc_cron_check_updates'); 204 } 205 206 /** 207 * CRON schedule. 208 * 209 * @since 1.1.4 210 * @param 211 * @return 212 */ 213 public static function check_updates() { 214 $installed_blocks = Options::get_all(); 215 216 foreach ( $installed_blocks as $block ) { 217 // We must check if block is not local block, then we check for new version availability 218 $manifest = json_decode( stripslashes( $block->block_manifest ), true ); 219 if ( empty( $manifest['isLocal'] ) ) { 220 $args = array( 221 'method' => 'GET' 222 ); 223 $response = wp_remote_request( 'https://api.gutenbergcloud.org/blocks/' . $block->package_name, $args ); 224 $body = wp_remote_retrieve_body( $response ); 225 $the_block = json_decode( $body, true ); 226 227 if( !empty($the_block['version']) && $the_block['version'] !== $block->block_version) { 228 $_REQUEST['data'] = $the_block; 229 Blocks::update_version($the_block); 230 } 177 231 } 178 232 } 179 } 180 181 return $counter; 233 182 234 } 183 235 -
cloud-blocks/trunk/core/Blocks/Options.php
r1962907 r2025157 153 153 'thumbnail' => $thumbnail, 154 154 'block_version' => $block_version, 155 'block_manifest' => $block_manifest 155 'block_manifest' => $block_manifest, 156 'available_version' => '' 156 157 ), 157 158 array( … … 163 164 } 164 165 166 /** 167 * Update existing value in database. 168 * @since 1.1.4 169 * @param array $options The options need to be stored into database 170 * @return int $id Inserted records id 171 */ 172 public static function update_version( $id, $options ) { 173 global $wpdb; 174 175 $available_version = $options['available_version']; 176 177 $table_name = $wpdb->prefix . str_replace( '-', '_', FGC_NAME ); 178 179 $id = $wpdb->update( 180 $table_name, 181 array( 182 'available_version' => $available_version 183 ), 184 array( 185 'id' => $id 186 ) 187 ); 188 189 return $id; 190 } 191 165 192 /** 166 193 * Get all installed blocks. … … 209 236 210 237 /** 211 * Increa te number of installs on api.gutenbergcloud.org238 * Increase number of installs on api.gutenbergcloud.org 212 239 * @since 1.0.0 213 240 * @param string|null $package_name npm package name 214 241 * @return object|null $body Request response 215 242 */ 216 public static function increa te_installs( $package_name = null ) {243 public static function increase_installs( $package_name = null ) { 217 244 if ( empty( $package_name ) ) { 218 245 return; -
cloud-blocks/trunk/core/CloudBlocks.php
r2020434 r2025157 20 20 public function __construct() { 21 21 global $wp_version; 22 22 23 23 include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 24 24 if ( \is_plugin_active( 'gutenberg/gutenberg.php' ) || (int) $wp_version >= 5 ) { … … 80 80 */ 81 81 public function enqueue_scripts() { 82 wp_enqueue_script( 'vuejs', 'https:// unpkg.com/vue@2.5.17/dist/vue.min.js', array( 'jquery' ), FGC_VERSION, true );83 wp_enqueue_script( 'vuex', 'https:// unpkg.com/vuex@3.0.1/dist/vuex.min.js', array('vuejs'), FGC_VERSION, TRUE);82 wp_enqueue_script( 'vuejs', 'https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.min.js', array( 'jquery' ), FGC_VERSION, true ); 83 wp_enqueue_script( 'vuex', 'https://cdn.jsdelivr.net/npm/vuex@3.1.0/dist/vuex.min.js', array( 'vuejs' ), FGC_VERSION, true ); 84 84 wp_enqueue_script( 'gutenberg_cloud_admin_js', FGC_URL . 'assets/js/script.js', array( 'jquery', 'vuejs', 'vuex' ), FGC_VERSION, true ); 85 85 $localized_data = array( -
cloud-blocks/trunk/core/Settings/Tools.php
r1961288 r2025157 106 106 self::add_notice( sprintf(__('Block <b>%s</b> already installed.', 'gutenberg-cloug'), $imported->block_name ), 'error' ); 107 107 } else { 108 Options::increa te_installs( $block['package_name'] );108 Options::increase_installs( $block['package_name'] ); 109 109 self::add_notice( sprintf(__('Block <b>%s</b> installed successfully.', 'gutenberg-cloug'), $block['block_name'] ), 'success' ); 110 110 } -
cloud-blocks/trunk/docs/changelog.md
r2020451 r2025157 1 1 ## Changelog 2 3 #### 1.1.4 4 * **Change**: Update counter as a WP CRON (Thanks to [ajotka](https://github.com/front/cloud-blocks/pull/14)) 5 * **Change**: Update some docs 6 * **Fix**: Fix polish translations 2 7 3 8 #### 1.1.3 -
cloud-blocks/trunk/docs/create-block.md
r1965688 r2025157 89 89 Custom blocks generated by create-cloud-block tool come with all configuration needed to be distributed by Cloud Blocks. Also they have a deploy script which complies the build files and publish the package to NPM, so all we have to do is run `$ npm run deploy`. 90 90 91 After about 15 minutes, your custom block is available to the world through [api.gutenbergcloud.org/blocks](https://api.gutenbergcloud.org/blocks). Congrats!91 After our review, your custom block is available to the world through [api.gutenbergcloud.org/blocks](https://api.gutenbergcloud.org/blocks). Congrats! 92 92 93 93 ## Documentation -
cloud-blocks/trunk/docs/migrate-block.md
r1965688 r2025157 147 147 or just `$ npm run deploy` if you used create-cloud-block tool. 148 148 149 That’s it! Your block will be available to Gutenberg Cloud in a few minutes. Bravo!149 That’s it! Your block will be available to Gutenberg Cloud after our review. Bravo! -
cloud-blocks/trunk/languages/cloud-blocks-pl_PL.po
r2011879 r2025157 30 30 "again." 31 31 msgstr "" 32 "Plik, który próbujesz załadować zawiera niepoprawne rozszerzenie . Spróbuj "32 "Plik, który próbujesz załadować zawiera niepoprawne rozszerzenie. Spróbuj " 33 33 "ponownie." 34 34 … … 125 125 msgstr "" 126 126 "Eksport wszystkich zainstalowanych bloków z Chmury Gutenberga jako plik JSON." 127 " Uwaga: Treść bloków nie będzie wyeksportowana."127 " Uwaga: Treść bloków nie będzie eksportowana." 128 128 129 129 #: core/Settings/Tools.php:224 … … 229 229 #: core/Settings/Translations.php:38 230 230 msgid "have been installed successfully." 231 msgstr "został o pomyślnie zainstalowane."231 msgstr "został pomyślnie zainstalowany." 232 232 233 233 #: core/Settings/Translations.php:39 234 234 msgid "have been uninstalled successfully." 235 msgstr "został o pomyślnie odinstalowane."235 msgstr "został pomyślnie odinstalowany." 236 236 237 237 #: core/Settings/Translations.php:40 238 238 msgid "have been deleted successfully." 239 msgstr "został o pomyślnie usunięte."239 msgstr "został pomyślnie usunięty." 240 240 241 241 #: core/Settings/Translations.php:41 242 242 msgid "have been updated successfully." 243 msgstr "został o pomyślnie zaktualizowane."243 msgstr "został pomyślnie zaktualizowany." 244 244 245 245 #: core/Settings/Translations.php:42 … … 253 253 #: core/Settings/Translations.php:44 254 254 msgid "Visit homepage" 255 msgstr "Odwiedź stronę główną"255 msgstr "Odwiedź stronę bloku" 256 256 257 257 #: core/Settings/Translations.php:45 258 258 msgid "Homepage" 259 msgstr "Strona Główna"259 msgstr "Strona Bloku" 260 260 261 261 #: vendor/foadyousefi/seven-fields/src/Container/Container.php:196 -
cloud-blocks/trunk/readme.txt
r2020451 r2025157 6 6 Tested up to: 5.0 7 7 Requires PHP: 5.4 8 Stable tag: 1.1. 38 Stable tag: 1.1.4 9 9 License: GPLv3 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 75 75 76 76 == Changelog == 77 78 = 1.1.4 = 79 * Change: Update counter as a WP CRON (Thanks to [ajotka](https://github.com/front/cloud-blocks/pull/14)) 80 * Change: Update some docs 81 * Fix: Fix polish translations 77 82 78 83 = 1.1.3 =
Note: See TracChangeset
for help on using the changeset viewer.