Skip to content

Commit

Permalink
Merge pull request #1270 from publishpress/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
htmgarcia authored Apr 12, 2023
2 parents 1f90962 + 4c37028 commit a372d96
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 219 deletions.
9 changes: 7 additions & 2 deletions src/advanced-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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;
Expand All @@ -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')) {
Expand Down
2 changes: 1 addition & 1 deletion src/assets/blocks/editor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/assets/blocks/editor.js.map

Large diffs are not rendered by default.

125 changes: 8 additions & 117 deletions src/assets/js/editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
8 changes: 7 additions & 1 deletion src/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit a372d96

Please sign in to comment.