diff --git a/src/advanced-gutenberg.php b/src/advanced-gutenberg.php index 8cb10226..09b27d4e 100644 --- a/src/advanced-gutenberg.php +++ b/src/advanced-gutenberg.php @@ -3,7 +3,7 @@ * Plugin Name: PublishPress Blocks * Plugin URI: https://publishpress.com/blocks/ * Description: PublishPress Blocks has everything you need to build professional websites with the Gutenberg editor. - * Version: 3.1.4.1 + * Version: 3.1.4.2 * Tested up to: 6.2 * Author: PublishPress * Author URI: https://publishpress.com/ @@ -38,6 +38,11 @@ defined('ABSPATH') || die; +// If the PHP version is not compatible, terminate the plugin execution. +if ( ! include_once __DIR__ . '/incl/check-php-version.php' ) { + return; +} + $includeFilebRelativePath = '/publishpress/publishpress-instance-protection/include.php'; if (file_exists(__DIR__ . '/vendor' . $includeFilebRelativePath)) { require_once __DIR__ . '/vendor' . $includeFilebRelativePath; @@ -56,7 +61,7 @@ if (! defined('ADVANCED_GUTENBERG_LOADED')) { if (! defined('ADVANCED_GUTENBERG_VERSION')) { - define('ADVANCED_GUTENBERG_VERSION', '3.1.4.1'); + define('ADVANCED_GUTENBERG_VERSION', '3.1.4.2'); } if (! defined('ADVANCED_GUTENBERG_PLUGIN')) { diff --git a/src/assets/blocks/editor.js b/src/assets/blocks/editor.js index bbd25f46..9f32c143 100644 --- a/src/assets/blocks/editor.js +++ b/src/assets/blocks/editor.js @@ -1,2 +1,2 @@ -!function(o){var e={};function n(t){if(e[t])return e[t].exports;var c=e[t]={i:t,l:!1,exports:{}};return o[t].call(c.exports,c,c.exports,n),c.l=!0,c.exports}n.m=o,n.c=e,n.d=function(o,e,t){n.o(o,e)||Object.defineProperty(o,e,{enumerable:!0,get:t})},n.r=function(o){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},n.t=function(o,e){if(1&e&&(o=n(o)),8&e)return o;if(4&e&&"object"==typeof o&&o&&o.__esModule)return o;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:o}),2&e&&"string"!=typeof o)for(var c in o)n.d(t,c,function(e){return o[e]}.bind(null,c));return t},n.n=function(o){var e=o&&o.__esModule?function(){return o.default}:function(){return o};return n.d(e,"a",e),e},n.o=function(o,e){return Object.prototype.hasOwnProperty.call(o,e)},n.p="",n(n.s=0)}([function(o,e,n){o.exports=n(1)},function(o,e,n){"use strict";var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o};"undefined"!=typeof wp&&void 0!==wp.domReady&&wp.domReady((function(){if("undefined"!==advgb_blocks_vars.blocks.active_blocks&&0!==advgb_blocks_vars.blocks.active_blocks.length){var o=null;void 0!==window._wpLoadBlockEditor&&(o=window._wpLoadBlockEditor),null!==o&&o.then((function(){if(!0===advgb_blocks_vars.original_settings.allowedBlockTypes){var o=[],e=[],n=!1,c=wp.blocks.getBlockTypes(),r={active_blocks:Object.values(advgb_blocks_vars.blocks.active_blocks),inactive_blocks:Object.values(advgb_blocks_vars.blocks.inactive_blocks)};for(var i in c){var l="",a={name:c[i].name,icon:c[i].icon.src,title:c[i].title,category:c[i].category,parent:c[i].parent},s=c[i].icon.src?c[i].icon.src:c[i].icon;void 0!==c[i].icon.foreground&&(a.iconColor=c[i].icon.foreground),"function"==typeof s?void 0!==s.prototype?(a.icon=wp.element.renderToString(wp.element.createElement(s)),a.icon=a.icon.replace(/stopcolor/g,"stop-color"),a.icon=a.icon.replace(/stopopacity/g,"stop-opacity")):(l=wp.element.createElement(wp.components.Dashicon,{icon:"block-default"}),a.icon=wp.element.renderToString(l)):"object"===(void 0===s?"undefined":t(s))?(a.icon=wp.element.renderToString(s),a.icon=a.icon.replace(/stopcolor/g,"stop-color"),a.icon=a.icon.replace(/stopopacity/g,"stop-opacity")):"string"==typeof s&&(l=wp.element.createElement(wp.components.Dashicon,{icon:s}),a.icon=wp.element.renderToString(l)),o.push(a),r.active_blocks.indexOf(c[i].name)>=0?e.push(c[i].name):r.inactive_blocks.indexOf(c[i].name)>=0||(e.push(c[i].name),n=!0)}if(n){void 0!==console&&void 0!==console.error&&console.log("Reloading editor by PublishPress Blocks plugin");var p=wp.blocks.getCategories();try{jQuery.ajax({url:advgb_blocks_vars.ajaxurl,method:"POST",data:{action:"advgb_update_blocks_list",blocksList:JSON.stringify(o),categoriesList:JSON.stringify(p),nonce:advgb_blocks_vars.nonce},success:function(o){}})}catch(o){}}}}))}}))}]); +!function(o){var e={};function t(n){if(e[n])return e[n].exports;var c=e[n]={i:n,l:!1,exports:{}};return o[n].call(c.exports,c,c.exports,t),c.l=!0,c.exports}t.m=o,t.c=e,t.d=function(o,e,n){t.o(o,e)||Object.defineProperty(o,e,{enumerable:!0,get:n})},t.r=function(o){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},t.t=function(o,e){if(1&e&&(o=t(o)),8&e)return o;if(4&e&&"object"==typeof o&&o&&o.__esModule)return o;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:o}),2&e&&"string"!=typeof o)for(var c in o)t.d(n,c,function(e){return o[e]}.bind(null,c));return n},t.n=function(o){var e=o&&o.__esModule?function(){return o.default}:function(){return o};return t.d(e,"a",e),e},t.o=function(o,e){return Object.prototype.hasOwnProperty.call(o,e)},t.p="",t(t.s=0)}([function(o,e,t){o.exports=t(1)},function(o,e,t){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o};"undefined"!=typeof wp&&void 0!==wp.domReady&&wp.domReady((function(){if("undefined"!==advgb_blocks_vars.blocks.active_blocks&&0!==advgb_blocks_vars.blocks.active_blocks.length){var o=null;void 0!==window._wpLoadBlockEditor&&(o=window._wpLoadBlockEditor),null!==o&&o.then((function(){if(!0===advgb_blocks_vars.original_settings.allowedBlockTypes){var o=[],e=[],t=!1,c=wp.blocks.getBlockTypes(),r={active_blocks:Object.values(advgb_blocks_vars.blocks.active_blocks),inactive_blocks:Object.values(advgb_blocks_vars.blocks.inactive_blocks)};for(var i in c){var l="",a={name:c[i].name,icon:c[i].icon.src,title:c[i].title,category:c[i].category,parent:c[i].parent},s=c[i].icon.src?c[i].icon.src:c[i].icon;void 0!==c[i].icon.foreground&&(a.iconColor=c[i].icon.foreground),"function"==typeof s?void 0!==s.prototype?(a.icon=wp.element.renderToString(wp.element.createElement(s)),a.icon=a.icon.replace(/stopcolor/g,"stop-color"),a.icon=a.icon.replace(/stopopacity/g,"stop-opacity")):(l=wp.element.createElement(wp.components.Dashicon,{icon:"block-default"}),a.icon=wp.element.renderToString(l)):"object"===(void 0===s?"undefined":n(s))?(a.icon=wp.element.renderToString(s),a.icon=a.icon.replace(/stopcolor/g,"stop-color"),a.icon=a.icon.replace(/stopopacity/g,"stop-opacity")):"string"==typeof s&&(l=wp.element.createElement(wp.components.Dashicon,{icon:s}),a.icon=wp.element.renderToString(l)),o.push(a),r.active_blocks.indexOf(c[i].name)>=0?e.push(c[i].name):r.inactive_blocks.indexOf(c[i].name)>=0||(e.push(c[i].name),t=!0)}if(t){void 0!==console&&void 0!==console.error&&console.log("Reloading editor by PublishPress Blocks plugin"),setTimeout((function(){wp.data.dispatch("core/editor").updateEditorSettings({allowedBlockTypes:e})}),3e3);var p=wp.blocks.getCategories();try{jQuery.ajax({url:advgb_blocks_vars.ajaxurl,method:"POST",data:{action:"advgb_update_blocks_list",blocksList:JSON.stringify(o),categoriesList:JSON.stringify(p),nonce:advgb_blocks_vars.nonce},success:function(o){}})}catch(o){}}}}))}}))}]); //# sourceMappingURL=editor.js.map \ No newline at end of file diff --git a/src/assets/blocks/editor.js.map b/src/assets/blocks/editor.js.map index 9bf6009c..d8fb4303 100644 --- a/src/assets/blocks/editor.js.map +++ b/src/assets/blocks/editor.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/assets/js/editor.jsx"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","wp","domReady","advgb_blocks_vars","blocks","active_blocks","length","gutenberg_init_function","window","_wpLoadBlockEditor","then","original_settings","allowedBlockTypes","list_blocks","granted_blocks","missing_block","getBlockTypes","savedBlocks","values","inactive_blocks","block","blockItemIcon","blockItem","icon","src","title","category","parent","savedIcon","undefined","foreground","iconColor","element","renderToString","createElement","replace","components","Dashicon","push","indexOf","console","error","log","list_categories","getCategories","jQuery","ajax","url","ajaxurl","method","data","action","blocksList","JSON","stringify","categoriesList","nonce","success","e"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EA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IAIlEsC,EAAewB,KAAKlC,EAAOgB,GAAO5C,MAClCuC,GAAgB,GAIxB,GAAIA,EAAe,MACCc,IAAZW,cAA2CX,IAAlBW,QAAQC,OAEjCD,QAAQE,IAAI,kDAyHhB,IAAIC,EAAkB1C,GAAGG,OAAOwC,gBAEhC,IAEIC,OAAOC,KAAK,CACRC,IAAK5C,kBAAkB6C,QACvBC,OAAQ,OACRC,KAAM,CACFC,OAAQ,2BACRC,WAAYC,KAAKC,UAAUzC,GAC3B0C,eAAgBF,KAAKC,UAAUX,GAC/Ba,MAAOrD,kBAAkBqD,OAE7BC,QAAS,SAAUP,OAIzB,MAAOQ","file":"editor.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","if (typeof wp !== 'undefined' && typeof wp.domReady !== 'undefined'){\n wp.domReady(()=>{\n\n if(advgb_blocks_vars.blocks.active_blocks === 'undefined' || advgb_blocks_vars.blocks.active_blocks.length === 0) {\n // No Block Access defined for this role, so we stop the process here\n return;\n }\n\n let gutenberg_init_function = null;\n if (typeof window._wpLoadBlockEditor !== 'undefined') {\n gutenberg_init_function = window._wpLoadBlockEditor;\n }\n\n if (gutenberg_init_function !== null) {\n // Wait for Gutenberg editor to be ready\n gutenberg_init_function.then(() => {\n if (advgb_blocks_vars.original_settings.allowedBlockTypes !== true) {\n // allowed_block_types filter has been used, in this case we do nothing as we don't know why blocks have been filtered\n return;\n }\n\n let list_blocks = [];\n let granted_blocks = [];\n let missing_block = false;\n // Retrieve all registered blocks\n let blocks = wp.blocks.getBlockTypes();\n const savedBlocks = {\n active_blocks: Object.values(advgb_blocks_vars.blocks.active_blocks),\n inactive_blocks: Object.values(advgb_blocks_vars.blocks.inactive_blocks),\n };\n\n for (let block in blocks) {\n var blockItemIcon = '';\n var blockItem = {\n name: blocks[block].name,\n icon: blocks[block].icon.src,\n title: blocks[block].title,\n category: blocks[block].category,\n parent: blocks[block].parent\n };\n\n var savedIcon = !!blocks[block].icon.src ? blocks[block].icon.src : blocks[block].icon;\n\n if (blocks[block].icon.foreground !== undefined) blockItem.iconColor = blocks[block].icon.foreground;\n\n if (typeof savedIcon === 'function') {\n if(typeof savedIcon.prototype !== 'undefined') {\n blockItem.icon = wp.element.renderToString(wp.element.createElement(savedIcon));\n blockItem.icon = blockItem.icon.replace(/stopcolor/g, 'stop-color');\n blockItem.icon = blockItem.icon.replace(/stopopacity/g, 'stop-opacity');\n } else {\n blockItemIcon = wp.element.createElement(wp.components.Dashicon, {icon: 'block-default'});\n blockItem.icon = wp.element.renderToString(blockItemIcon);\n }\n } else if (typeof savedIcon === 'object') {\n blockItem.icon = wp.element.renderToString(savedIcon);\n blockItem.icon = blockItem.icon.replace(/stopcolor/g, 'stop-color');\n blockItem.icon = blockItem.icon.replace(/stopopacity/g, 'stop-opacity');\n } else if (typeof savedIcon === 'string') {\n blockItemIcon = wp.element.createElement(wp.components.Dashicon, {icon: savedIcon});\n blockItem.icon = wp.element.renderToString(blockItemIcon);\n }\n list_blocks.push(blockItem);\n\n\n // Compare current block with the list of blocks we have\n if (savedBlocks.active_blocks.indexOf(blocks[block].name) >= 0) {\n // Block is active\n granted_blocks.push(blocks[block].name);\n } else if (savedBlocks.inactive_blocks.indexOf(blocks[block].name) >= 0) {\n // Block is inactive\n } else {\n // This block is not in our database yet, but by default we allow the usage\n granted_blocks.push(blocks[block].name);\n missing_block = true;\n }\n }\n\n if (missing_block) {\n if (console !== undefined && console.error !== undefined) {\n // Let's output as log instead of error\n console.log('Reloading editor by PublishPress Blocks plugin');\n }\n\n /*/ Replace original allowed block settings by our modified list\n let new_settings = advgb_blocks_vars.original_settings;\n //let new_settings = wp.data.select('core/editor').getEditorSettings();\n\n // Unregister core blocks to avoid registering twice later through wp.editPost.initializeEditor\n const core_blocks = [\n 'core/paragraph',\n 'core/image',\n 'core/heading',\n 'core/list',\n 'core/quote',\n 'core/archives',\n 'core/audio',\n 'core/button',\n 'core/buttons',\n 'core/calendar',\n 'core/categories',\n 'core/code',\n 'core/columns',\n 'core/column',\n 'core/cover',\n 'core/embed',\n 'core/group',\n 'core/freeform',\n 'core/html',\n 'core/media-text',\n 'core/latest-comments',\n 'core/latest-posts',\n 'core/list-item',\n 'core/missing',\n 'core/more',\n 'core/nextpage',\n 'core/page-list',\n 'core/preformatted',\n 'core/pullquote',\n 'core/rss',\n 'core/search',\n 'core/separator',\n 'core/block',\n 'core/social-links',\n 'core/social-link',\n 'core/spacer',\n 'core/table',\n 'core/tag-cloud',\n 'core/text-columns',\n 'core/verse',\n 'core/video',\n 'core/site-logo',\n 'core/site-tagline',\n 'core/site-title',\n 'core/query',\n 'core/post-template',\n 'core/query-title',\n 'core/query-pagination',\n 'core/query-pagination-next',\n 'core/query-pagination-numbers',\n 'core/query-pagination-previous',\n 'core/post-title',\n 'core/post-content',\n 'core/post-date',\n 'core/post-excerpt',\n 'core/post-featured-image',\n 'core/post-terms',\n 'core/loginout',\n 'core/gallery',\n 'core/shortcode',\n 'core/file',\n 'core/pattern',\n 'core/navigation',\n 'core/navigation-link',\n 'core/navigation-submenu',\n 'core/template-part',\n 'core/post-author',\n 'core/post-navigation-link',\n 'core/post-comments',\n 'core/term-description',\n 'core/avatar',\n 'core/query-no-results',\n 'core/read-more',\n 'core/comment-author-name',\n 'core/comment-content',\n 'core/comment-date',\n 'core/comment-edit-link',\n 'core/comment-reply-link',\n 'core/comment-template',\n 'core/comments',\n 'core/comments-title',\n 'core/comments-query-loop',\n 'core/comments-pagination',\n 'core/comments-pagination-next',\n 'core/comments-pagination-numbers',\n 'core/comments-pagination-previous',\n 'core/post-comments-form',\n 'core/home-link',\n 'core/post-author-biography',\n 'core/page-list-item',\n 'core/post-author-name',\n 'core/legacy-widget',\n 'core/widget-group'\n ];\n\n core_blocks.forEach( function( element ) {\n if ( wp.data.select( 'core/blocks' ).getBlockType( element ) ) {\n wp.blocks.unregisterBlockType( element );\n }\n });\n\n new_settings.allowedBlockTypes = granted_blocks;\n const target = document.getElementById('editor'); // Do we need this?\n\n // Initialize again the editor - Doesn't work - Cause inserter blink since WP 6.2\n wp.editPost.initializeEditor('editor', advgb_blocks_vars.post_type, parseInt(advgb_blocks_vars.post_id), new_settings, []);\n\n // It seems the best approach to update editor settings, however is overriden\n // https://github.com/WordPress/gutenberg/issues/15993#issuecomment-1487007071\n wp.data.dispatch('core/editor').updateEditorSettings({ allowedBlockTypes: granted_blocks })\n .then((a) => console.log('end',a,wp.data.select('core/editor').getEditorSettings()));;*/\n\n var list_categories = wp.blocks.getCategories();\n\n try {\n // Use this ajax query to update the block list in db\n jQuery.ajax({\n url: advgb_blocks_vars.ajaxurl,\n method: 'POST',\n data: {\n action: 'advgb_update_blocks_list',\n blocksList: JSON.stringify(list_blocks),\n categoriesList: JSON.stringify(list_categories),\n nonce: advgb_blocks_vars.nonce\n },\n success: function (data) {\n //console.log(data);\n }\n });\n } catch (e) {\n //console.log(e);\n }\n }\n });\n }\n });\n\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/assets/js/editor.jsx"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","wp","domReady","advgb_blocks_vars","blocks","active_blocks","length","gutenberg_init_function","window","_wpLoadBlockEditor","then","original_settings","allowedBlockTypes","list_blocks","granted_blocks","missing_block","getBlockTypes","savedBlocks","values","inactive_blocks","block","blockItemIcon","blockItem","icon","src","title","category","parent","savedIcon","undefined","foreground","iconColor","element","renderToString","createElement","replace","components","Dashicon","push","indexOf","console","error","log","setTimeout","data","dispatch","updateEditorSettings","list_categories","getCategories","jQuery","ajax","url","ajaxurl","method","action","blocksList","JSON","stringify","categoriesList","nonce","success","e"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YAAY,EAAMK,MAAOA,IACtD,EAAPE,GAA4B,iBAATF,EAAmB,IAAI,IAAIM,KAAON,EAAOrB,EAAoBU,EAAEe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OACRT,KAAM,CACFU,OAAQ,2BACRC,WAAYC,KAAKC,UAAU5C,GAC3B6C,eAAgBF,KAAKC,UAAUV,GAC/BY,MAAOxD,kBAAkBwD,OAE7BC,QAAS,SAAUhB,OAIzB,MAAOiB","file":"editor.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","if (typeof wp !== 'undefined' && typeof wp.domReady !== 'undefined'){\n wp.domReady(()=>{\n\n if(advgb_blocks_vars.blocks.active_blocks === 'undefined' || advgb_blocks_vars.blocks.active_blocks.length === 0) {\n // No Block Access defined for this role, so we stop the process here\n return;\n }\n\n let gutenberg_init_function = null;\n if (typeof window._wpLoadBlockEditor !== 'undefined') {\n gutenberg_init_function = window._wpLoadBlockEditor;\n }\n\n if (gutenberg_init_function !== null) {\n // Wait for Gutenberg editor to be ready\n gutenberg_init_function.then(() => {\n if (advgb_blocks_vars.original_settings.allowedBlockTypes !== true) {\n // allowed_block_types filter has been used, in this case we do nothing as we don't know why blocks have been filtered\n return;\n }\n\n let list_blocks = [];\n let granted_blocks = [];\n let missing_block = false;\n // Retrieve all registered blocks\n let blocks = wp.blocks.getBlockTypes();\n const savedBlocks = {\n active_blocks: Object.values(advgb_blocks_vars.blocks.active_blocks),\n inactive_blocks: Object.values(advgb_blocks_vars.blocks.inactive_blocks),\n };\n\n for (let block in blocks) {\n var blockItemIcon = '';\n var blockItem = {\n name: blocks[block].name,\n icon: blocks[block].icon.src,\n title: blocks[block].title,\n category: blocks[block].category,\n parent: blocks[block].parent\n };\n\n var savedIcon = !!blocks[block].icon.src ? blocks[block].icon.src : blocks[block].icon;\n\n if (blocks[block].icon.foreground !== undefined) blockItem.iconColor = blocks[block].icon.foreground;\n\n if (typeof savedIcon === 'function') {\n if(typeof savedIcon.prototype !== 'undefined') {\n blockItem.icon = wp.element.renderToString(wp.element.createElement(savedIcon));\n blockItem.icon = blockItem.icon.replace(/stopcolor/g, 'stop-color');\n blockItem.icon = blockItem.icon.replace(/stopopacity/g, 'stop-opacity');\n } else {\n blockItemIcon = wp.element.createElement(wp.components.Dashicon, {icon: 'block-default'});\n blockItem.icon = wp.element.renderToString(blockItemIcon);\n }\n } else if (typeof savedIcon === 'object') {\n blockItem.icon = wp.element.renderToString(savedIcon);\n blockItem.icon = blockItem.icon.replace(/stopcolor/g, 'stop-color');\n blockItem.icon = blockItem.icon.replace(/stopopacity/g, 'stop-opacity');\n } else if (typeof savedIcon === 'string') {\n blockItemIcon = wp.element.createElement(wp.components.Dashicon, {icon: savedIcon});\n blockItem.icon = wp.element.renderToString(blockItemIcon);\n }\n list_blocks.push(blockItem);\n\n\n // Compare current block with the list of blocks we have\n if (savedBlocks.active_blocks.indexOf(blocks[block].name) >= 0) {\n // Block is active\n granted_blocks.push(blocks[block].name);\n } else if (savedBlocks.inactive_blocks.indexOf(blocks[block].name) >= 0) {\n // Block is inactive\n } else {\n // This block is not in our database yet, but by default we allow the usage\n granted_blocks.push(blocks[block].name);\n missing_block = true;\n }\n }\n\n if (missing_block) {\n if (console !== undefined && console.error !== undefined) {\n // Let's output as log instead of error\n console.log('Reloading editor by PublishPress Blocks plugin');\n }\n\n /* It seems the best approach to update editor settings, however is overriden\n * https://github.com/WordPress/gutenberg/issues/15993#issuecomment-1487007071\n * We're adding 3 seconds delay to bypass the override */\n setTimeout( function() {\n wp.data.dispatch('core/editor').updateEditorSettings({\n allowedBlockTypes: granted_blocks\n });\n }, 3000 );\n\n var list_categories = wp.blocks.getCategories();\n\n try {\n // Use this ajax query to update the block list in db\n jQuery.ajax({\n url: advgb_blocks_vars.ajaxurl,\n method: 'POST',\n data: {\n action: 'advgb_update_blocks_list',\n blocksList: JSON.stringify(list_blocks),\n categoriesList: JSON.stringify(list_categories),\n nonce: advgb_blocks_vars.nonce\n },\n success: function (data) {\n //console.log(data);\n }\n });\n } catch (e) {\n //console.log(e);\n }\n }\n });\n }\n });\n\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/src/assets/js/editor.jsx b/src/assets/js/editor.jsx index b055e223..6828317d 100644 --- a/src/assets/js/editor.jsx +++ b/src/assets/js/editor.jsx @@ -82,123 +82,14 @@ if (typeof wp !== 'undefined' && typeof wp.domReady !== 'undefined'){ console.log('Reloading editor by PublishPress Blocks plugin'); } - /*/ Replace original allowed block settings by our modified list - let new_settings = advgb_blocks_vars.original_settings; - //let new_settings = wp.data.select('core/editor').getEditorSettings(); - - // Unregister core blocks to avoid registering twice later through wp.editPost.initializeEditor - const core_blocks = [ - 'core/paragraph', - 'core/image', - 'core/heading', - 'core/list', - 'core/quote', - 'core/archives', - 'core/audio', - 'core/button', - 'core/buttons', - 'core/calendar', - 'core/categories', - 'core/code', - 'core/columns', - 'core/column', - 'core/cover', - 'core/embed', - 'core/group', - 'core/freeform', - 'core/html', - 'core/media-text', - 'core/latest-comments', - 'core/latest-posts', - 'core/list-item', - 'core/missing', - 'core/more', - 'core/nextpage', - 'core/page-list', - 'core/preformatted', - 'core/pullquote', - 'core/rss', - 'core/search', - 'core/separator', - 'core/block', - 'core/social-links', - 'core/social-link', - 'core/spacer', - 'core/table', - 'core/tag-cloud', - 'core/text-columns', - 'core/verse', - 'core/video', - 'core/site-logo', - 'core/site-tagline', - 'core/site-title', - 'core/query', - 'core/post-template', - 'core/query-title', - 'core/query-pagination', - 'core/query-pagination-next', - 'core/query-pagination-numbers', - 'core/query-pagination-previous', - 'core/post-title', - 'core/post-content', - 'core/post-date', - 'core/post-excerpt', - 'core/post-featured-image', - 'core/post-terms', - 'core/loginout', - 'core/gallery', - 'core/shortcode', - 'core/file', - 'core/pattern', - 'core/navigation', - 'core/navigation-link', - 'core/navigation-submenu', - 'core/template-part', - 'core/post-author', - 'core/post-navigation-link', - 'core/post-comments', - 'core/term-description', - 'core/avatar', - 'core/query-no-results', - 'core/read-more', - 'core/comment-author-name', - 'core/comment-content', - 'core/comment-date', - 'core/comment-edit-link', - 'core/comment-reply-link', - 'core/comment-template', - 'core/comments', - 'core/comments-title', - 'core/comments-query-loop', - 'core/comments-pagination', - 'core/comments-pagination-next', - 'core/comments-pagination-numbers', - 'core/comments-pagination-previous', - 'core/post-comments-form', - 'core/home-link', - 'core/post-author-biography', - 'core/page-list-item', - 'core/post-author-name', - 'core/legacy-widget', - 'core/widget-group' - ]; - - core_blocks.forEach( function( element ) { - if ( wp.data.select( 'core/blocks' ).getBlockType( element ) ) { - wp.blocks.unregisterBlockType( element ); - } - }); - - new_settings.allowedBlockTypes = granted_blocks; - const target = document.getElementById('editor'); // Do we need this? - - // Initialize again the editor - Doesn't work - Cause inserter blink since WP 6.2 - wp.editPost.initializeEditor('editor', advgb_blocks_vars.post_type, parseInt(advgb_blocks_vars.post_id), new_settings, []); - - // It seems the best approach to update editor settings, however is overriden - // https://github.com/WordPress/gutenberg/issues/15993#issuecomment-1487007071 - wp.data.dispatch('core/editor').updateEditorSettings({ allowedBlockTypes: granted_blocks }) - .then((a) => console.log('end',a,wp.data.select('core/editor').getEditorSettings()));;*/ + /* It seems the best approach to update editor settings, however is overriden + * https://github.com/WordPress/gutenberg/issues/15993#issuecomment-1487007071 + * We're adding 3 seconds delay to bypass the override */ + setTimeout( function() { + wp.data.dispatch('core/editor').updateEditorSettings({ + allowedBlockTypes: granted_blocks + }); + }, 3000 ); var list_categories = wp.blocks.getCategories(); diff --git a/src/assets/js/main.js b/src/assets/js/main.js index a2a72eef..262b7a9d 100644 --- a/src/assets/js/main.js +++ b/src/assets/js/main.js @@ -195,7 +195,13 @@ function advgbGetBlocksFeature( inactive_blocks, nonce_field_id, page, exclude_b 'icon': 'block-default', 'title': 'Legacy Widget', 'category': 'widgets' - } + }, + { + 'name': 'core/widget-group', + 'icon': 'block-default', + 'title': 'Widget Group', + 'category': 'widgets' + }, ]; // Include force_activate_blocks in the blocks list diff --git a/src/assets/js/main.min.js b/src/assets/js/main.min.js index cdea3b4f..da9c6fc9 100644 --- a/src/assets/js/main.min.js +++ b/src/assets/js/main.min.js @@ -1 +1 @@ -(function($){var{__:__,_x:_x,_n:_n,_nx:_nx}=wp.i18n;$.expr[":"].contains=$.expr.createPseudo(function(arg){return function(elem){return $(elem).text().toLowerCase().indexOf(arg.toLowerCase())>=0}});$(".advgb-feature-box--disabled, .slider--disabled").bind("click",function(e){e.preventDefault();window.open("https://publishpress.com/links/blocks-banner")});$(".advgb-feature-setting .slider").bind("click",function(e){try{e.preventDefault();if($(this).hasClass("slider--disabled")){return false}var checkbox=$(this).parent().find("input");var isChecked=checkbox.is(":checked")?1:0;var newState=isChecked==1?0:1;var feature=checkbox.data("feature");var slider=checkbox.parent().find(".slider");$.ajax({url:advgb_main_dashboard.ajaxurl,method:"POST",data:{action:"advgb_feature_save",feature:feature,new_state:newState,nonce:advgb_main_dashboard.nonce},beforeSend:function(){slider.css("opacity",.5)},success:function(){newState==1?checkbox.prop("checked",true):checkbox.prop("checked",false);slider.css("opacity",1);var pMenu=$("#toplevel_page_advgb_main");switch(feature){case"enable_block_access":advgbDynamicSubmenu("advgb_block_access",newState);break;case"enable_advgb_blocks":advgbDynamicSubmenu("advgb_block_settings",newState);break;case"enable_custom_styles":advgbDynamicSubmenu("advgb_custom_styles",newState);break;case"block_controls":advgbDynamicSubmenu("advgb_block_controls",newState);break;case"reusable_blocks":advgbDynamicSubmenu('[class*="wp_block"]',newState,true);break}statusMsgNotification=advgbTimerStatus()},error:function(jqXHR,textStatus,errorThrown){console.error(jqXHR.responseText);statusMsgNotification=advgbTimerStatus("error")}})}catch(e){console.error(e)}});function advgbTimerStatus(type="success"){setTimeout(function(){var uniqueClass="advgb-floating-msg-"+Math.round((new Date).getTime()+Math.random()*100);var message=type==="success"?__("Changes saved!","advanced-gutenberg"):__(" Error: changes can't be saved.","advanced-gutenberg");var instances=$(".advgb-floating-status").length;$("#wpbody-content").after(''+message+"");$("."+uniqueClass).css("bottom",instances*45).fadeIn(1e3).delay(1e4).fadeOut(1e3,function(){$(this).remove()})},500)}function advgbDynamicSubmenu(slug,newState,attrSelector=false){var pMenu=$("#toplevel_page_advgb_main");var cSubmenu=!attrSelector?$(pMenu).find("li."+slug+"-menu-item"):$(pMenu).find("li"+slug);if(cSubmenu.length){newState==1?cSubmenu.removeClass("advgb-hide-menu-item").find("a").removeClass("advgb-hide-menu-item"):cSubmenu.addClass("advgb-hide-menu-item").find("a").addClass("advgb-hide-menu-item")}}})(jQuery);function advgbGetCookie(cname){var name=cname+"=";var ca=document.cookie.split(";");for(var i=0;i0){let diff_blocks=advgb_blocks_list.filter(blocksA=>!allBlocks.some(blocksB=>blocksA.name===blocksB.name));if(diff_blocks.length>0){diff_blocks.forEach(function(block){allBlocks.push(block)})}}var force_deactivate_blocks=[];var force_activate_blocks=[{name:"core/legacy-widget",icon:"block-default",title:"Legacy Widget",category:"widgets"}];force_activate_blocks.forEach(function(block){allBlocks.push(block)});allBlocks.forEach(function(block){var blockItemIcon="";var blockItem={name:block.name,icon:block.icon.src||block.icon,title:block.title,category:block.category,parent:block.parent};var savedIcon=!!block.icon.src?block.icon.src:block.icon;if(block.icon.foreground!==undefined)blockItem.iconColor=block.icon.foreground;if(typeof savedIcon==="function"){if(typeof savedIcon.prototype!=="undefined"){blockItem.icon=wp.element.renderToString(wp.element.createElement(savedIcon));blockItem.icon=blockItem.icon.replace(/stopcolor/g,"stop-color");blockItem.icon=blockItem.icon.replace(/stopopacity/g,"stop-opacity")}else{blockItemIcon=wp.element.createElement(wp.components.Dashicon,{icon:"block-default"});blockItem.icon=wp.element.renderToString(blockItemIcon)}}else if(typeof savedIcon==="object"){blockItem.icon=wp.element.renderToString(savedIcon);blockItem.icon=blockItem.icon.replace(/stopcolor/g,"stop-color");blockItem.icon=blockItem.icon.replace(/stopopacity/g,"stop-opacity")}else if(typeof savedIcon==="string"&&!savedIcon.includes("0){categoryBlock.find("h3.category-name").text(category.title)}else{var categoryHTML="";categoryHTML+='
';categoryHTML+=""+category.title+"";categoryHTML+='';categoryHTML+="";categoryHTML+='
    ';categoryHTML+="
    ";$(".blocks-section").append(categoryHTML)}});var list_blocks_names=[];listBlocks.forEach(function(block){if(exclude_blocks.length>0&&exclude_blocks.indexOf(block.name)>=0){return}list_blocks_names.push(block.name);var blockHTML="";blockHTML+='
  • ';blockHTML+='";blockHTML+='
    ';blockHTML+='";blockHTML+="
    ";blockHTML+="
  • ";var categoryBlock=$('.category-block[data-category="'+block.category+'"]');categoryBlock.find(".blocks-list").append(blockHTML)});$("#blocks_list").val(JSON.stringify(list_blocks_names));$(".category-block .category-name").unbind("click").click(function(){var categoryWrapper=$(this).closest(".category-block");if(categoryWrapper.hasClass("collapsed")){categoryWrapper.removeClass("collapsed")}else{categoryWrapper.addClass("collapsed")}});var feature=$("#advgb_feature").val();if(typeof feature!=="undefined"&&!advgbCUserRole[feature].active_blocks.length&&!advgbCUserRole[feature].inactive_blocks.length){$("#toggle_all_blocks").prop("checked",true)}$(".blocks-search-input").on("input",function(){var searchKey=$(this).val().trim().toLowerCase();$(".block-item .block-title").each(function(){var blockTitle=$(this).text().toLowerCase().trim(),blockItem=$(this).closest(".block-item");if(blockTitle.indexOf(searchKey)>-1){blockItem.show()}else{blockItem.hide()}})});$("#user_role").on("change",function(){window.location="admin.php?page="+page+"&user_role="+$(this).val()});$("#toggle_all_blocks").click(function(){$(".block-item-editable input").prop("checked",$(this).prop("checked"));saveButtonStatus()});$(".block-item-editable input").click(function(){saveButtonStatus()});var saveButtonStatus=function(){if($(".block-item-editable input:checked").length===0){$(".advgb-enable-one-block-msg").css("display","inline-block");$(".save-profile-button").prop("disabled",true)}else{$(".advgb-enable-one-block-msg").css("display","none");$(".save-profile-button").prop("disabled",false)}};$(".advgb-block-feature-loading-msg").hide()}}function advgbGetBlockControls(inactive_blocks,nonce_field_id,page,exclude_blocks=[]){if(typeof wp.blocks!=="undefined"){if(wp.blockLibrary&&typeof wp.blockLibrary.registerCoreBlocks==="function"){wp.blockLibrary.registerCoreBlocks()}var $=jQuery;var allBlocks=wp.blocks.getBlockTypes();var allCategories=wp.blocks.getCategories();var listBlocks=[];var nonce="";if(typeof advgbBlocks.block_extend!=="undefined"&&parseInt(advgbBlocks.block_extend)&&typeof advgb_blocks_list!=="undefined"&&advgb_blocks_list.length>0){let diff_blocks=advgb_blocks_list.filter(blocksA=>!allBlocks.some(blocksB=>blocksA.name===blocksB.name));if(diff_blocks.length>0){diff_blocks.forEach(function(block){allBlocks.push(block)})}}var force_deactivate_blocks=[];var force_activate_blocks=[{name:"core/legacy-widget",icon:"block-default",title:"Legacy Widget",category:"widgets"}];force_activate_blocks.forEach(function(block){allBlocks.push(block)});allBlocks.forEach(function(block){var blockItemIcon="";var blockItem={name:block.name,icon:block.icon.src||block.icon,title:block.title,category:block.category,parent:block.parent};var savedIcon=!!block.icon.src?block.icon.src:block.icon;if(block.icon.foreground!==undefined)blockItem.iconColor=block.icon.foreground;if(typeof savedIcon==="function"){if(typeof savedIcon.prototype!=="undefined"){blockItem.icon=wp.element.renderToString(wp.element.createElement(savedIcon));blockItem.icon=blockItem.icon.replace(/stopcolor/g,"stop-color");blockItem.icon=blockItem.icon.replace(/stopopacity/g,"stop-opacity")}else{blockItemIcon=wp.element.createElement(wp.components.Dashicon,{icon:"block-default"});blockItem.icon=wp.element.renderToString(blockItemIcon)}}else if(typeof savedIcon==="object"){blockItem.icon=wp.element.renderToString(savedIcon);blockItem.icon=blockItem.icon.replace(/stopcolor/g,"stop-color");blockItem.icon=blockItem.icon.replace(/stopopacity/g,"stop-opacity")}else if(typeof savedIcon==="string"&&!savedIcon.includes("0){categoryBlock.find("h3.category-name").text(category.title)}else{var categoryHTML="";categoryHTML+='
    ';categoryHTML+=""+category.title+"";categoryHTML+='';categoryHTML+="";categoryHTML+='
      ';categoryHTML+="
      ";$(".blocks-section").append(categoryHTML)}});var list_blocks_names=[];listBlocks.forEach(function(block){if(exclude_blocks.length>0&&exclude_blocks.indexOf(block.name)>=0){return}list_blocks_names.push(block.name);var blockHTML="";blockHTML+='
    • ';blockHTML+='";blockHTML+='
      ';blockHTML+='";blockHTML+="
      ";blockHTML+="
    • ";var categoryBlock=$('.category-block[data-category="'+block.category+'"]');categoryBlock.find(".blocks-list").append(blockHTML)});$("#blocks_list").val(JSON.stringify(list_blocks_names));$(".category-block .category-name").unbind("click").click(function(){var categoryWrapper=$(this).closest(".category-block");if(categoryWrapper.hasClass("collapsed")){categoryWrapper.removeClass("collapsed")}else{categoryWrapper.addClass("collapsed")}});if(!advgb_block_controls_vars.active_blocks.length&&!advgb_block_controls_vars.inactive_blocks.length){$("#toggle_all_blocks").prop("checked",true)}$(".blocks-search-input").on("input",function(){var searchKey=$(this).val().trim().toLowerCase();$(".block-item .block-title").each(function(){var blockTitle=$(this).text().toLowerCase().trim(),blockItem=$(this).closest(".block-item");if(blockTitle.indexOf(searchKey)>-1){blockItem.show()}else{blockItem.hide()}})});$("#toggle_all_blocks").click(function(){$(".block-item-editable input").prop("checked",$(this).prop("checked"));saveButtonStatus()});$(".block-item-editable input").click(function(){saveButtonStatus()});var saveButtonStatus=function(){if($(".block-item-editable input:checked").length===0){$(".advgb-enable-one-block-msg").css("display","inline-block");$(".save-profile-button").prop("disabled",true)}else{$(".advgb-enable-one-block-msg").css("display","none");$(".save-profile-button").prop("disabled",false)}};$(".advgb-block-feature-loading-msg").hide()}} \ No newline at end of file +(function($){var{__:__,_x:_x,_n:_n,_nx:_nx}=wp.i18n;$.expr[":"].contains=$.expr.createPseudo(function(arg){return function(elem){return $(elem).text().toLowerCase().indexOf(arg.toLowerCase())>=0}});$(".advgb-feature-box--disabled, .slider--disabled").bind("click",function(e){e.preventDefault();window.open("https://publishpress.com/links/blocks-banner")});$(".advgb-feature-setting .slider").bind("click",function(e){try{e.preventDefault();if($(this).hasClass("slider--disabled")){return false}var checkbox=$(this).parent().find("input");var isChecked=checkbox.is(":checked")?1:0;var newState=isChecked==1?0:1;var feature=checkbox.data("feature");var slider=checkbox.parent().find(".slider");$.ajax({url:advgb_main_dashboard.ajaxurl,method:"POST",data:{action:"advgb_feature_save",feature:feature,new_state:newState,nonce:advgb_main_dashboard.nonce},beforeSend:function(){slider.css("opacity",.5)},success:function(){newState==1?checkbox.prop("checked",true):checkbox.prop("checked",false);slider.css("opacity",1);var pMenu=$("#toplevel_page_advgb_main");switch(feature){case"enable_block_access":advgbDynamicSubmenu("advgb_block_access",newState);break;case"enable_advgb_blocks":advgbDynamicSubmenu("advgb_block_settings",newState);break;case"enable_custom_styles":advgbDynamicSubmenu("advgb_custom_styles",newState);break;case"block_controls":advgbDynamicSubmenu("advgb_block_controls",newState);break;case"reusable_blocks":advgbDynamicSubmenu('[class*="wp_block"]',newState,true);break}statusMsgNotification=advgbTimerStatus()},error:function(jqXHR,textStatus,errorThrown){console.error(jqXHR.responseText);statusMsgNotification=advgbTimerStatus("error")}})}catch(e){console.error(e)}});function advgbTimerStatus(type="success"){setTimeout(function(){var uniqueClass="advgb-floating-msg-"+Math.round((new Date).getTime()+Math.random()*100);var message=type==="success"?__("Changes saved!","advanced-gutenberg"):__(" Error: changes can't be saved.","advanced-gutenberg");var instances=$(".advgb-floating-status").length;$("#wpbody-content").after(''+message+"");$("."+uniqueClass).css("bottom",instances*45).fadeIn(1e3).delay(1e4).fadeOut(1e3,function(){$(this).remove()})},500)}function advgbDynamicSubmenu(slug,newState,attrSelector=false){var pMenu=$("#toplevel_page_advgb_main");var cSubmenu=!attrSelector?$(pMenu).find("li."+slug+"-menu-item"):$(pMenu).find("li"+slug);if(cSubmenu.length){newState==1?cSubmenu.removeClass("advgb-hide-menu-item").find("a").removeClass("advgb-hide-menu-item"):cSubmenu.addClass("advgb-hide-menu-item").find("a").addClass("advgb-hide-menu-item")}}})(jQuery);function advgbGetCookie(cname){var name=cname+"=";var ca=document.cookie.split(";");for(var i=0;i0){let diff_blocks=advgb_blocks_list.filter(blocksA=>!allBlocks.some(blocksB=>blocksA.name===blocksB.name));if(diff_blocks.length>0){diff_blocks.forEach(function(block){allBlocks.push(block)})}}var force_deactivate_blocks=[];var force_activate_blocks=[{name:"core/legacy-widget",icon:"block-default",title:"Legacy Widget",category:"widgets"},{name:"core/widget-group",icon:"block-default",title:"Widget Group",category:"widgets"}];force_activate_blocks.forEach(function(block){allBlocks.push(block)});allBlocks.forEach(function(block){var blockItemIcon="";var blockItem={name:block.name,icon:block.icon.src||block.icon,title:block.title,category:block.category,parent:block.parent};var savedIcon=!!block.icon.src?block.icon.src:block.icon;if(block.icon.foreground!==undefined)blockItem.iconColor=block.icon.foreground;if(typeof savedIcon==="function"){if(typeof savedIcon.prototype!=="undefined"){blockItem.icon=wp.element.renderToString(wp.element.createElement(savedIcon));blockItem.icon=blockItem.icon.replace(/stopcolor/g,"stop-color");blockItem.icon=blockItem.icon.replace(/stopopacity/g,"stop-opacity")}else{blockItemIcon=wp.element.createElement(wp.components.Dashicon,{icon:"block-default"});blockItem.icon=wp.element.renderToString(blockItemIcon)}}else if(typeof savedIcon==="object"){blockItem.icon=wp.element.renderToString(savedIcon);blockItem.icon=blockItem.icon.replace(/stopcolor/g,"stop-color");blockItem.icon=blockItem.icon.replace(/stopopacity/g,"stop-opacity")}else if(typeof savedIcon==="string"&&!savedIcon.includes("0){categoryBlock.find("h3.category-name").text(category.title)}else{var categoryHTML="";categoryHTML+='
      ';categoryHTML+=""+category.title+"";categoryHTML+='';categoryHTML+="";categoryHTML+='
        ';categoryHTML+="
        ";$(".blocks-section").append(categoryHTML)}});var list_blocks_names=[];listBlocks.forEach(function(block){if(exclude_blocks.length>0&&exclude_blocks.indexOf(block.name)>=0){return}list_blocks_names.push(block.name);var blockHTML="";blockHTML+='
      • ';blockHTML+='";blockHTML+='
        ';blockHTML+='";blockHTML+="
        ";blockHTML+="
      • ";var categoryBlock=$('.category-block[data-category="'+block.category+'"]');categoryBlock.find(".blocks-list").append(blockHTML)});$("#blocks_list").val(JSON.stringify(list_blocks_names));$(".category-block .category-name").unbind("click").click(function(){var categoryWrapper=$(this).closest(".category-block");if(categoryWrapper.hasClass("collapsed")){categoryWrapper.removeClass("collapsed")}else{categoryWrapper.addClass("collapsed")}});var feature=$("#advgb_feature").val();if(typeof feature!=="undefined"&&!advgbCUserRole[feature].active_blocks.length&&!advgbCUserRole[feature].inactive_blocks.length){$("#toggle_all_blocks").prop("checked",true)}$(".blocks-search-input").on("input",function(){var searchKey=$(this).val().trim().toLowerCase();$(".block-item .block-title").each(function(){var blockTitle=$(this).text().toLowerCase().trim(),blockItem=$(this).closest(".block-item");if(blockTitle.indexOf(searchKey)>-1){blockItem.show()}else{blockItem.hide()}})});$("#user_role").on("change",function(){window.location="admin.php?page="+page+"&user_role="+$(this).val()});$("#toggle_all_blocks").click(function(){$(".block-item-editable input").prop("checked",$(this).prop("checked"));saveButtonStatus()});$(".block-item-editable input").click(function(){saveButtonStatus()});var saveButtonStatus=function(){if($(".block-item-editable input:checked").length===0){$(".advgb-enable-one-block-msg").css("display","inline-block");$(".save-profile-button").prop("disabled",true)}else{$(".advgb-enable-one-block-msg").css("display","none");$(".save-profile-button").prop("disabled",false)}};$(".advgb-block-feature-loading-msg").hide()}}function advgbGetBlockControls(inactive_blocks,nonce_field_id,page,exclude_blocks=[]){if(typeof wp.blocks!=="undefined"){if(wp.blockLibrary&&typeof wp.blockLibrary.registerCoreBlocks==="function"){wp.blockLibrary.registerCoreBlocks()}var $=jQuery;var allBlocks=wp.blocks.getBlockTypes();var allCategories=wp.blocks.getCategories();var listBlocks=[];var nonce="";if(typeof advgbBlocks.block_extend!=="undefined"&&parseInt(advgbBlocks.block_extend)&&typeof advgb_blocks_list!=="undefined"&&advgb_blocks_list.length>0){let diff_blocks=advgb_blocks_list.filter(blocksA=>!allBlocks.some(blocksB=>blocksA.name===blocksB.name));if(diff_blocks.length>0){diff_blocks.forEach(function(block){allBlocks.push(block)})}}var force_deactivate_blocks=[];var force_activate_blocks=[{name:"core/legacy-widget",icon:"block-default",title:"Legacy Widget",category:"widgets"}];force_activate_blocks.forEach(function(block){allBlocks.push(block)});allBlocks.forEach(function(block){var blockItemIcon="";var blockItem={name:block.name,icon:block.icon.src||block.icon,title:block.title,category:block.category,parent:block.parent};var savedIcon=!!block.icon.src?block.icon.src:block.icon;if(block.icon.foreground!==undefined)blockItem.iconColor=block.icon.foreground;if(typeof savedIcon==="function"){if(typeof savedIcon.prototype!=="undefined"){blockItem.icon=wp.element.renderToString(wp.element.createElement(savedIcon));blockItem.icon=blockItem.icon.replace(/stopcolor/g,"stop-color");blockItem.icon=blockItem.icon.replace(/stopopacity/g,"stop-opacity")}else{blockItemIcon=wp.element.createElement(wp.components.Dashicon,{icon:"block-default"});blockItem.icon=wp.element.renderToString(blockItemIcon)}}else if(typeof savedIcon==="object"){blockItem.icon=wp.element.renderToString(savedIcon);blockItem.icon=blockItem.icon.replace(/stopcolor/g,"stop-color");blockItem.icon=blockItem.icon.replace(/stopopacity/g,"stop-opacity")}else if(typeof savedIcon==="string"&&!savedIcon.includes("0){categoryBlock.find("h3.category-name").text(category.title)}else{var categoryHTML="";categoryHTML+='
        ';categoryHTML+=""+category.title+"";categoryHTML+='';categoryHTML+="";categoryHTML+='
          ';categoryHTML+="
          ";$(".blocks-section").append(categoryHTML)}});var list_blocks_names=[];listBlocks.forEach(function(block){if(exclude_blocks.length>0&&exclude_blocks.indexOf(block.name)>=0){return}list_blocks_names.push(block.name);var blockHTML="";blockHTML+='
        • ';blockHTML+='";blockHTML+='
          ';blockHTML+='";blockHTML+="
          ";blockHTML+="
        • ";var categoryBlock=$('.category-block[data-category="'+block.category+'"]');categoryBlock.find(".blocks-list").append(blockHTML)});$("#blocks_list").val(JSON.stringify(list_blocks_names));$(".category-block .category-name").unbind("click").click(function(){var categoryWrapper=$(this).closest(".category-block");if(categoryWrapper.hasClass("collapsed")){categoryWrapper.removeClass("collapsed")}else{categoryWrapper.addClass("collapsed")}});if(!advgb_block_controls_vars.active_blocks.length&&!advgb_block_controls_vars.inactive_blocks.length){$("#toggle_all_blocks").prop("checked",true)}$(".blocks-search-input").on("input",function(){var searchKey=$(this).val().trim().toLowerCase();$(".block-item .block-title").each(function(){var blockTitle=$(this).text().toLowerCase().trim(),blockItem=$(this).closest(".block-item");if(blockTitle.indexOf(searchKey)>-1){blockItem.show()}else{blockItem.hide()}})});$("#toggle_all_blocks").click(function(){$(".block-item-editable input").prop("checked",$(this).prop("checked"));saveButtonStatus()});$(".block-item-editable input").click(function(){saveButtonStatus()});var saveButtonStatus=function(){if($(".block-item-editable input:checked").length===0){$(".advgb-enable-one-block-msg").css("display","inline-block");$(".save-profile-button").prop("disabled",true)}else{$(".advgb-enable-one-block-msg").css("display","none");$(".save-profile-button").prop("disabled",false)}};$(".advgb-block-feature-loading-msg").hide()}} \ No newline at end of file diff --git a/src/composer.json b/src/composer.json index 4b8b2159..815354c1 100644 --- a/src/composer.json +++ b/src/composer.json @@ -1,4 +1,8 @@ { + "name": "publishpress/publishpress-blocks", + "type": "wordpress-plugin", + "license": "GPL-2.0-or-later", + "description": "", "repositories": [ { "type": "git", @@ -6,9 +10,11 @@ } ], "require": { + "php": ">=7.2.5", "publishpress/wordpress-reviews": "^1.1", "publishpress/publishpress-instance-protection": "^1.0", "publishpress/wordpress-version-notices": "^1.1", - "publishpress/wordpress-banners": "^1.3" + "publishpress/wordpress-banners": "^1.3", + "psr/container": "^2.0" } } diff --git a/src/composer.lock b/src/composer.lock index 8def9826..75190b30 100644 --- a/src/composer.lock +++ b/src/composer.lock @@ -4,33 +4,33 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9fe0ce431fd3932133592d5756012e4c", + "content-hash": "c6f93fb8cda248266253fd74f8807361", "packages": [ { "name": "pimple/pimple", - "version": "v3.2.3", + "version": "v3.5.0", "source": { "type": "git", "url": "https://github.com/silexphp/Pimple.git", - "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32" + "reference": "a94b3a4db7fb774b3d78dad2315ddc07629e1bed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/silexphp/Pimple/zipball/9e403941ef9d65d20cba7d54e29fe906db42cf32", - "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32", + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/a94b3a4db7fb774b3d78dad2315ddc07629e1bed", + "reference": "a94b3a4db7fb774b3d78dad2315ddc07629e1bed", "shasum": "" }, "require": { - "php": ">=5.3.0", - "psr/container": "^1.0" + "php": ">=7.2.5", + "psr/container": "^1.1 || ^2.0" }, "require-dev": { - "symfony/phpunit-bridge": "^3.2" + "symfony/phpunit-bridge": "^5.4@dev" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2.x-dev" + "dev-master": "3.4.x-dev" } }, "autoload": { @@ -49,38 +49,37 @@ } ], "description": "Pimple, a simple Dependency Injection Container", - "homepage": "http://pimple.sensiolabs.org", + "homepage": "https://pimple.symfony.com", "keywords": [ "container", "dependency injection" ], "support": { - "issues": "https://github.com/silexphp/Pimple/issues", - "source": "https://github.com/silexphp/Pimple/tree/master" + "source": "https://github.com/silexphp/Pimple/tree/v3.5.0" }, - "time": "2018-01-21T07:42:36+00:00" + "time": "2021-10-28T11:13:42+00:00" }, { "name": "psr/container", - "version": "1.0.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + "reference": "68f5200c33f18c018db17eb869d4b0f97da17cad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "url": "https://api.github.com/repos/php-fig/container/zipball/68f5200c33f18c018db17eb869d4b0f97da17cad", + "reference": "68f5200c33f18c018db17eb869d4b0f97da17cad", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=7.2.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -95,7 +94,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common Container Interface (PHP FIG PSR-11)", @@ -109,9 +108,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/master" + "source": "https://github.com/php-fig/container/tree/2.0.0" }, - "time": "2017-02-14T16:28:37+00:00" + "time": "2021-03-05T16:02:18+00:00" }, { "name": "publishpress/publishpress-instance-protection", @@ -252,22 +251,22 @@ }, { "name": "publishpress/wordpress-version-notices", - "version": "1.1.4", + "version": "1.3.1", "source": { "type": "git", - "url": "https://github.com/publishpress/WordPress-Version-Notices.git", - "reference": "a46b552ac4cbec26d743307611e5dd8d56f80a57" + "url": "https://github.com/publishpress/wordpress-version-notices.git", + "reference": "ea8a694f10385275393c3e36b524d40019a591fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/publishpress/WordPress-Version-Notices/zipball/a46b552ac4cbec26d743307611e5dd8d56f80a57", - "reference": "a46b552ac4cbec26d743307611e5dd8d56f80a57", + "url": "https://api.github.com/repos/publishpress/wordpress-version-notices/zipball/ea8a694f10385275393c3e36b524d40019a591fa", + "reference": "ea8a694f10385275393c3e36b524d40019a591fa", "shasum": "" }, "require": { - "php": ">=5.6.20", - "pimple/pimple": "~3.2.0", - "psr/container": "~1.0.0" + "php": ">=7.2.5", + "pimple/pimple": "^3.5.0", + "psr/container": "2.0.0" }, "require-dev": { "codeception/module-asserts": "^1.0", @@ -302,10 +301,10 @@ ], "description": "Library for displaying version notices for Pro plugins in WordPress.", "support": { - "issues": "https://github.com/publishpress/WordPress-Version-Notices/issues", - "source": "https://github.com/publishpress/WordPress-Version-Notices/tree/1.1.4" + "issues": "https://github.com/publishpress/wordpress-version-notices/issues", + "source": "https://github.com/publishpress/wordpress-version-notices/tree/1.3.1" }, - "time": "2022-06-06T15:45:54+00:00" + "time": "2023-04-05T21:15:43+00:00" } ], "packages-dev": [], @@ -314,7 +313,9 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": ">=7.2.5" + }, "platform-dev": [], "plugin-api-version": "2.1.0" } diff --git a/src/incl/advanced-gutenberg-main.php b/src/incl/advanced-gutenberg-main.php index 4a05489b..0e6be100 100644 --- a/src/incl/advanced-gutenberg-main.php +++ b/src/incl/advanced-gutenberg-main.php @@ -173,6 +173,7 @@ public function __construct() add_filter('admin_body_class', array($this, 'setAdvgEditorBodyClassses')); add_filter( 'admin_footer_text', [$this, 'adminFooter'] ); add_action( 'admin_enqueue_scripts', [$this, 'adminMenuStyles'] ); + add_action( 'activated_plugin', [$this, 'maybeNewBlocks'], 9999, 2 ); if($wp_version >= 5.8) { add_action('admin_enqueue_scripts', array($this, 'addEditorAssetsWidgets'), 9999); @@ -747,13 +748,17 @@ function advgbAddScriptAttributes($tag, $handle) } /** - * Update the blocks list for first time install + * Update the blocks list for first time install or when a new block is installed + * + * @TODO - Blocks with block.json metadata are not detected in this trigger + * https://github.com/publishpress/PublishPress-Blocks/issues/1266 * * @return void */ public function initBlocksList() { if (get_option('advgb_blocks_list') === false + || (bool) get_option( 'advgb_maybe_new_blocks' ) || (defined('GUTENBERG_VERSION') && version_compare(get_option('advgb_gutenberg_version'), GUTENBERG_VERSION, '<'))) { $advgb_nonce = wp_create_nonce('advgb_update_blocks_list'); wp_enqueue_script('wp-blocks'); @@ -783,7 +788,18 @@ public function initBlocksList() 'after' ); + // Block types scripts + $block_type_registry = \WP_Block_Type_Registry::get_instance(); + foreach ( $block_type_registry->get_all_registered() as $block_name => $block_type ) { + if ( ! empty( $block_type->editor_script ) ) { + wp_enqueue_script( $block_type->editor_script ); + } + } + wp_localize_script('advgb_update_list', 'updateListNonce', array('nonce' => $advgb_nonce)); + + // Disable trigger + update_option( 'advgb_maybe_new_blocks', intval(false), false ); } } @@ -2304,6 +2320,20 @@ public function adminMenuStyles() wp_enqueue_style( 'advgb_admin_menu_styles' ); } + /** + * Let's save a trigger option when a new plugin has been activated + * We use the boolean value of advgb_maybe_new_blocks option + * to trigger an update for advgb_blocks_list option through initBlocksList() + * + * @since 3.1.4.2 + * + * @return void + */ + public function maybeNewBlocks( $plugin, $network_activation ) + { + update_option( 'advgb_maybe_new_blocks', intval(true), false ); + } + /** * Register meta data to use on editor sidebar * @@ -3354,7 +3384,9 @@ public function getUserBlocksForGutenberg() } } - // Make sure core/legacy-widget is included as active - Since 2.11.6 + /* Make sure core/legacy-widget is included as active - Since 2.11.6 + * If there is an scenario where core/widget-group is not saved as active block, + * let's add to active_blocks here */ if(!in_array('core/legacy-widget', $advgb_blocks_user_roles['active_blocks'])) { /* Remove from inactive blocks if is saved for the current user role. * The lines below won't save nothing in db, is just for execution on editor. */ @@ -3385,12 +3417,21 @@ public function getUserBlocksForGutenberg() } } - // Make sure core/legacy-widget is included as active - Since 2.11.6 - if(!in_array('core/legacy-widget', $all_blocks)) { - array_push( - $all_blocks, - 'core/legacy-widget' - ); + /* Make sure core/legacy-widget is included as active - Since 2.11.6 + * core/widget-group added - Since 3.1.4.2 + */ + $include_blocks = [ + 'core/legacy-widget', + 'core/widget-group' + ]; + + foreach( $include_blocks as $item ) { + if( ! in_array( $item, $all_blocks ) ) { + array_push( + $all_blocks, + $item + ); + } } return array( diff --git a/src/incl/check-php-version.php b/src/incl/check-php-version.php new file mode 100644 index 00000000..4a5b042d --- /dev/null +++ b/src/incl/check-php-version.php @@ -0,0 +1,63 @@ + 'PublishPress Blocks', + 'plugin_slug' => 'advanced-gutenberg', + 'plugin_file' => 'advanced-gutenberg/advanced-gutenberg.php', + 'min_php_version' => '7.2.5', + 'message_format' => __( + '%s requires PHP %s or later. Please upgrade PHP to a compatible version. Your current version is %s.', + 'advanced-gutenberg' + ), + ]; + + $isValidVersion = version_compare(PHP_VERSION, $data['min_php_version'], '>='); + + if (! $isValidVersion) { + load_plugin_textdomain($data['plugin_slug'], false, __DIR__ . '/../languages/'); + + add_action('after_plugin_row_' . $data['plugin_file'], function ($pluginFile) use ($data) { + ?> + +   + +
          +

          + + +

          +
          + + +

          PublishPress Blocks needs at least PHP 5.6.20 version, please update php before installing the plugin.

          '; - } - } - - //Add actions - add_action('admin_init', 'advgb_disable_plugin'); - add_action('admin_notices', 'advgb_show_error'); - - //Do not load anything more - return; -} - if (!defined('GUTENBERG_VERSION_REQUIRED')) { define('GUTENBERG_VERSION_REQUIRED', '5.7.0'); } @@ -87,10 +50,13 @@ function advg_language_domain_init() if (! function_exists('advg_check_legacy_widget_block_init')) { /** - * v2.11.0 - Check if core/legacy-widget exists in current user role through advgb_blocks_user_roles option, + * Check if widget blocks exists in current user role through advgb_blocks_user_roles option, * either in inactive_blocks or active_blocks array. * https://github.com/publishpress/PublishPress-Blocks/issues/756#issuecomment-932358037 * + * @since 2.11.0 + * @since 3.1.4.2 - Added support for core/widget-group block + * * This function can be used in future to add new blocks not available on widgets.php * * @return void @@ -101,6 +67,11 @@ function advg_check_legacy_widget_block_init() return false; } + $widget_blocks = [ + 'core/legacy-widget', + 'core/widget-group' + ]; + global $wp_version; global $pagenow; if( ( $pagenow === 'widgets.php' || $pagenow === 'customize.php' ) && $wp_version >= 5.8 ) { @@ -112,19 +83,19 @@ function advg_check_legacy_widget_block_init() if( count( $advgb_blocks_list ) && count( $advgb_blocks_user_roles ) ) { - if( - is_array($advgb_blocks_user_roles[$current_user_role]['active_blocks']) - && is_array($advgb_blocks_user_roles[$current_user_role]['inactive_blocks']) - && !in_array( 'core/legacy-widget', $advgb_blocks_user_roles[$current_user_role]['active_blocks'] ) - && !in_array( 'core/legacy-widget', $advgb_blocks_user_roles[$current_user_role]['inactive_blocks'] ) - && !empty( $current_user_role ) - ) { - - array_push( - $advgb_blocks_user_roles[$current_user_role]['active_blocks'], - 'core/legacy-widget' - ); - update_option( 'advgb_blocks_user_roles', $advgb_blocks_user_roles, false ); + foreach( $widget_blocks as $item ) { + if( is_array( $advgb_blocks_user_roles[$current_user_role]['active_blocks'] ) + && is_array($advgb_blocks_user_roles[$current_user_role]['inactive_blocks'] ) + && ! in_array( $item, $advgb_blocks_user_roles[$current_user_role]['active_blocks'] ) + && ! in_array( $item, $advgb_blocks_user_roles[$current_user_role]['inactive_blocks'] ) + && ! empty( $current_user_role ) + ) { + array_push( + $advgb_blocks_user_roles[$current_user_role]['active_blocks'], + $item + ); + update_option( 'advgb_blocks_user_roles', $advgb_blocks_user_roles, false ); + } } } } diff --git a/src/readme.txt b/src/readme.txt index 9071e65f..6c627490 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -3,8 +3,8 @@ Contributors: publishpress, stevejburge, htmgarcia Tags: gutenberg, gutenberg blocks, gutenberg block, block editor, blocks, accordion block, gallery block, slider block, tabs block, maps block, block controls Requires at least: 5.0 Tested up to: 6.2 -Stable tag: 3.1.4.1 -Requires PHP: 5.6 +Stable tag: 3.1.4.2 +Requires PHP: 7.2.5 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -270,6 +270,11 @@ Yes, we use the phrase "publishpress-advg-install" to share install links. You w == Changelog == += 3.1.4.2 - 12 Apr 2023 = + * Fix: Allowed block types for non-saved block types in post edit + * Fix: Widget Group block type not saved as active + * Add: PHP 7.2.5 as minimum PHP version + = 3.1.4.1 - 29 Mar 2023 = * Fix: Blinking block inserter in WordPress 6.2 * Fix: Toggle to open calendar popup in Block controls