GenerateBlocks - Version 1.3.4

Version Description

  • New: Integrate with the new widget block editor
  • Fix: Memory leak when reusable blocks try to render inside themselves
  • Tweak: Use new block_categories_all filter in WP 5.8
Download this release

Release Info

Developer edge22
Plugin Icon 128x128 GenerateBlocks
Version 1.3.4
Comparing to
See all releases

Code changes from version 1.3.3 to 1.3.4

includes/class-enqueue-css.php CHANGED
@@ -45,6 +45,7 @@ class GenerateBlocks_Enqueue_CSS {
45
  add_action( 'save_post', array( $this, 'post_update_option' ), 10, 2 );
46
  add_action( 'save_post_wp_block', array( $this, 'wp_block_update' ), 10, 2 );
47
  add_action( 'init', array( $this, 'enqueue_assets' ) );
 
48
  }
49
 
50
  /**
@@ -435,6 +436,17 @@ class GenerateBlocks_Enqueue_CSS {
435
  public function update_saved_time() {
436
  update_option( 'generateblocks_dynamic_css_time', time() );
437
  }
 
 
 
 
 
 
 
 
 
 
 
438
  }
439
 
440
  GenerateBlocks_Enqueue_CSS::get_instance();
45
  add_action( 'save_post', array( $this, 'post_update_option' ), 10, 2 );
46
  add_action( 'save_post_wp_block', array( $this, 'wp_block_update' ), 10, 2 );
47
  add_action( 'init', array( $this, 'enqueue_assets' ) );
48
+ add_filter( 'widget_update_callback', array( $this, 'force_file_regen_on_widget_save' ) );
49
  }
50
 
51
  /**
436
  public function update_saved_time() {
437
  update_option( 'generateblocks_dynamic_css_time', time() );
438
  }
439
+
440
+ /**
441
+ * Force CSS files to regenerate after a widget has been saved.
442
+ *
443
+ * @param array $instance The current widget instance's settings.
444
+ */
445
+ public function force_file_regen_on_widget_save( $instance ) {
446
+ update_option( 'generateblocks_dynamic_css_posts', array() );
447
+
448
+ return $instance;
449
+ }
450
  }
451
 
452
  GenerateBlocks_Enqueue_CSS::get_instance();
includes/functions.php CHANGED
@@ -68,13 +68,14 @@ function generateblocks_get_block_data( $content, $data = array(), $depth = 0 )
68
  if ( isset( $block['attrs'] ) && is_array( $block['attrs'] ) ) {
69
  $atts = $block['attrs'];
70
 
71
- if ( isset( $atts['ref'] ) ) {
72
  $reusable_block = get_post( $atts['ref'] );
73
 
74
  if ( $reusable_block && 'wp_block' === $reusable_block->post_type && 'publish' === $reusable_block->post_status ) {
75
  $reuse_data_block = parse_blocks( $reusable_block->post_content );
76
 
77
  if ( ! empty( $reuse_data_block ) ) {
 
78
  $data = generateblocks_get_block_data( $reuse_data_block, $data );
79
  }
80
  }
68
  if ( isset( $block['attrs'] ) && is_array( $block['attrs'] ) ) {
69
  $atts = $block['attrs'];
70
 
71
+ if ( isset( $atts['ref'] ) && ( empty( $data['reusableBlockIds'] ) || ! in_array( $atts['ref'], (array) $data['reusableBlockIds'] ) ) ) {
72
  $reusable_block = get_post( $atts['ref'] );
73
 
74
  if ( $reusable_block && 'wp_block' === $reusable_block->post_type && 'publish' === $reusable_block->post_status ) {
75
  $reuse_data_block = parse_blocks( $reusable_block->post_content );
76
 
77
  if ( ! empty( $reuse_data_block ) ) {
78
+ $data['reusableBlockIds'][] = $atts['ref'];
79
  $data = generateblocks_get_block_data( $reuse_data_block, $data );
80
  }
81
  }
includes/general.php CHANGED
@@ -120,7 +120,11 @@ function generateblocks_do_block_editor_assets() {
120
  );
121
  }
122
 
123
- add_filter( 'block_categories', 'generateblocks_do_category' );
 
 
 
 
124
  /**
125
  * Add GeneratePress category to Gutenberg.
126
  *
@@ -244,3 +248,22 @@ function generateblocks_do_shape_divider( $output, $attributes ) {
244
 
245
  return $output;
246
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  );
121
  }
122
 
123
+ if ( version_compare( $GLOBALS['wp_version'], '5.8-alpha-1', '<' ) ) {
124
+ add_filter( 'block_categories', 'generateblocks_do_category' );
125
+ } else {
126
+ add_filter( 'block_categories_all', 'generateblocks_do_category' );
127
+ }
128
  /**
129
  * Add GeneratePress category to Gutenberg.
130
  *
248
 
249
  return $output;
250
  }
251
+
252
+ add_filter( 'generateblocks_do_content', 'generateblocks_do_widget_styling' );
253
+ /**
254
+ * Process all widget content for potential styling.
255
+ *
256
+ * @since 1.3.4
257
+ * @param string $content The existing content to process.
258
+ */
259
+ function generateblocks_do_widget_styling( $content ) {
260
+ $widget_blocks = get_option( 'widget_block' );
261
+
262
+ foreach ( (array) $widget_blocks as $block ) {
263
+ if ( isset( $block['content'] ) ) {
264
+ $content .= $block['content'];
265
+ }
266
+ }
267
+
268
+ return $content;
269
+ }
plugin.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: A small collection of lightweight WordPress blocks that can accomplish nearly anything.
6
  * Author: Tom Usborne
7
  * Author URI: https://tomusborne.com
8
- * Version: 1.3.3
9
  * Requires at least: 5.4
10
  * Requires PHP: 5.6
11
  * License: GPL2+
@@ -19,7 +19,7 @@ if ( ! defined( 'ABSPATH' ) ) {
19
  exit; // Exit if accessed directly.
20
  }
21
 
22
- define( 'GENERATEBLOCKS_VERSION', '1.3.3' );
23
  define( 'GENERATEBLOCKS_DIR', plugin_dir_path( __FILE__ ) );
24
  define( 'GENERATEBLOCKS_DIR_URL', plugin_dir_url( __FILE__ ) );
25
 
5
  * Description: A small collection of lightweight WordPress blocks that can accomplish nearly anything.
6
  * Author: Tom Usborne
7
  * Author URI: https://tomusborne.com
8
+ * Version: 1.3.4
9
  * Requires at least: 5.4
10
  * Requires PHP: 5.6
11
  * License: GPL2+
19
  exit; // Exit if accessed directly.
20
  }
21
 
22
+ define( 'GENERATEBLOCKS_VERSION', '1.3.4' );
23
  define( 'GENERATEBLOCKS_DIR', plugin_dir_path( __FILE__ ) );
24
  define( 'GENERATEBLOCKS_DIR_URL', plugin_dir_url( __FILE__ ) );
25
 
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: edge22
3
  Donate link: https://generateblocks.com
4
  Tags: blocks, gutenberg, container, headline, grid, columns, page builder, wysiwyg, block editor
5
  Requires at least: 5.4
6
- Tested up to: 5.7
7
  Requires PHP: 5.6
8
- Stable tag: 1.3.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -77,6 +77,11 @@ GenerateBlocks was built to work hand-in-hand with [GeneratePress](https://gener
77
 
78
  == Changelog ==
79
 
 
 
 
 
 
80
  = 1.3.3 =
81
  * Fix: Constant re-rendering of SVG icons in code editor
82
  * Fix: Broken CSS when empty/non-published re-usable blocks are on the page
3
  Donate link: https://generateblocks.com
4
  Tags: blocks, gutenberg, container, headline, grid, columns, page builder, wysiwyg, block editor
5
  Requires at least: 5.4
6
+ Tested up to: 5.8
7
  Requires PHP: 5.6
8
+ Stable tag: 1.3.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
77
 
78
  == Changelog ==
79
 
80
+ = 1.3.4 =
81
+ * New: Integrate with the new widget block editor
82
+ * Fix: Memory leak when reusable blocks try to render inside themselves
83
+ * Tweak: Use new block_categories_all filter in WP 5.8
84
+
85
  = 1.3.3 =
86
  * Fix: Constant re-rendering of SVG icons in code editor
87
  * Fix: Broken CSS when empty/non-published re-usable blocks are on the page