Gutenberg Blocks – Ultimate Addons for Gutenberg - Version 1.23.1

Version Description

  • Fix: Broken path while generating assets (CSS/JS).
  • Fix: Table of Contents - Heading convert to question marks on the frontend.
  • Fix: Table of Contents - Unexpected characters in links. Restricted to alphanumeric characters.
Download this release

Release Info

Developer brainstormworg
Plugin Icon Gutenberg Blocks – Ultimate Addons for Gutenberg
Version 1.23.1
Comparing to
See all releases

Code changes from version 1.23.0 to 1.23.1

assets/js/table-of-contents.js CHANGED
@@ -15,10 +15,11 @@
15
 
16
  var parsedSlug = slug.toString().toLowerCase()
17
  .replace(/\…+/g,'') // Remove multiple …
18
- .replace(/&(amp;)/g, '') // Remove &
19
- .replace(/&(mdash;)/g, '') // Remove long dash
20
  .replace(/\u2013|\u2014/g, '') // Remove long dash
 
21
  .replace(/[&]nbsp[;]/gi, '-') // Replace inseccable spaces
 
 
22
  .replace(/\s+/g, '-') // Replace spaces with -
23
  .replace(/[&\/\\#,^!+()$~%.\[\]'":*?<>{}@‘’”“|]/g, '') // Remove special chars
24
  .replace(/\-\-+/g, '-') // Replace multiple - with single -
@@ -131,11 +132,22 @@
131
  var all_header = ( undefined !== allowed_h_tags_str && '' !== allowed_h_tags_str ) ? $( 'body' ).find( allowed_h_tags_str ) : $( 'body' ).find('h1, h2, h3, h4, h5, h6' );
132
 
133
  if ( 0 !== all_header.length ) {
134
-
 
 
135
  all_header.each( function (index,value){
136
  let header = $( this );
137
- let header_text = parseTocSlug(header.text());
138
- $( this ).before('<span id="'+ header_text +'" class="uag-toc__heading-anchor"></span>');
 
 
 
 
 
 
 
 
 
139
  });
140
  }
141
 
15
 
16
  var parsedSlug = slug.toString().toLowerCase()
17
  .replace(/\…+/g,'') // Remove multiple …
 
 
18
  .replace(/\u2013|\u2014/g, '') // Remove long dash
19
+ .replace(/&(amp;)/g, '') // Remove &
20
  .replace(/[&]nbsp[;]/gi, '-') // Replace inseccable spaces
21
+ .replace(/[^a-z0-9 -_]/gi,'') // Keep only alphnumeric, space, -, _
22
+ .replace(/&(mdash;)/g, '') // Remove long dash
23
  .replace(/\s+/g, '-') // Replace spaces with -
24
  .replace(/[&\/\\#,^!+()$~%.\[\]'":*?<>{}@‘’”“|]/g, '') // Remove special chars
25
  .replace(/\-\-+/g, '-') // Replace multiple - with single -
132
  var all_header = ( undefined !== allowed_h_tags_str && '' !== allowed_h_tags_str ) ? $( 'body' ).find( allowed_h_tags_str ) : $( 'body' ).find('h1, h2, h3, h4, h5, h6' );
133
 
134
  if ( 0 !== all_header.length ) {
135
+
136
+ let toc_list_wrap = $('.uagb-toc__list-wrap');
137
+
138
  all_header.each( function (index,value){
139
  let header = $( this );
140
+ let header_text = parseTocSlug( header.text() );
141
+
142
+ if ( header_text.length < 1 ) {
143
+ let list_heading = toc_list_wrap.find('a:contains("' + header.text() + '")');
144
+
145
+ if ( list_heading.length > 0 ) {
146
+ header_text = list_heading.attr('href').replace(/#/g, '');
147
+ }
148
+ }
149
+
150
+ header.before('<span id="'+ header_text +'" class="uag-toc__heading-anchor"></span>');
151
  });
152
  }
153
 
blocks-config/table-of-content/class-uagb-table-of-content.php CHANGED
@@ -84,7 +84,7 @@ if ( ! class_exists( 'UAGB_Table_Of_Content' ) ) {
84
  * @param boolean $update Whether this is an existing post being updated.
85
  */
86
  public function delete_toc_meta( $post_id, $post, $update ) {
87
- delete_post_meta( $post_id, '_uagb_toc_heading_content' );
88
  }
89
 
90
  /**
@@ -126,13 +126,11 @@ if ( ! class_exists( 'UAGB_Table_Of_Content' ) ) {
126
  // converts all special characters like < or > to HTML entities, so we use
127
  // htmlspecialchars_decode to decode them.
128
  htmlspecialchars_decode(
129
- utf8_decode(
130
- htmlentities(
131
- '<html><body>' . $content . '</body></html>',
132
- ENT_COMPAT,
133
- 'UTF-8',
134
- false
135
- )
136
  ),
137
  ENT_COMPAT
138
  )
@@ -195,7 +193,7 @@ if ( ! class_exists( 'UAGB_Table_Of_Content' ) ) {
195
  // and convert it to an integer. Should be faster than conditionals.
196
  'level' => (int) $heading->nodeName[1],
197
  'id' => $this->clean( $heading->textContent ),
198
- 'content' => $heading->textContent,
199
  'depth' => intval( substr( $heading->tagName, 1 ) ),
200
  );
201
  }
@@ -218,26 +216,24 @@ if ( ! class_exists( 'UAGB_Table_Of_Content' ) ) {
218
  * @return string $string.
219
  */
220
  public function clean( $string ) {
221
- $string = str_replace( array( '‘', '’', '“', '”' ), '', $string );
222
- $string = str_replace( array( '$', '.', '+', '!', '*', '\'', '(', ')', ',' ), '', $string );
223
- $string = str_replace( array( '%', '{', '}', '|', '\\', '^', '~', '[', ']', '`' ), '', $string );
224
- $string = str_replace(
225
- array( '*', '\'', '(', ')', ';', '@', '&', '=', '+', '$', ',', '/', '?', '#', '[', ']' ),
226
- '',
227
- $string
228
- );
229
  $string = preg_replace( '/[\x00-\x1F\x7F]*/u', '', $string );
230
  $string = str_replace( array( '&amp;', '&nbsp;' ), ' ', $string );
231
- $string = str_replace( array( ':' ), '', $string );
 
232
  // Convert space characters to an `_` (underscore).
233
  $string = preg_replace( '/\s+/', '_', $string );
 
 
234
  // Replace multiple `-` (hyphen) with a single `-` (hyphen).
235
  $string = preg_replace( '/-+/', '-', $string );
236
- // Replace multiple `_` (underscore) with a single `_` (underscore).
237
- $string = preg_replace( '/_+/', '-', $string );
238
  // Remove trailing `-` and `_`.
239
  $string = trim( $string, '-_' );
240
- return strtolower( preg_replace( '/-+/', '-', $string ) ); // Replaces multiple hyphens with single one.
 
 
 
 
 
241
  }
242
 
243
  /**
@@ -409,16 +405,23 @@ if ( ! class_exists( 'UAGB_Table_Of_Content' ) ) {
409
  return '';
410
  }
411
 
412
- $uagb_toc_heading_content = get_post_meta( $post->ID, '_uagb_toc_heading_content', true );
 
 
413
 
414
- if ( empty( $uagb_toc_heading_content ) ) {
415
 
416
  $uagb_toc_heading_content = $this->table_of_contents_get_headings(
417
  $post->ID,
418
  $attributes
419
  );
420
 
421
- update_post_meta( $post->ID, '_uagb_toc_heading_content', $uagb_toc_heading_content );
 
 
 
 
 
422
 
423
  }
424
 
84
  * @param boolean $update Whether this is an existing post being updated.
85
  */
86
  public function delete_toc_meta( $post_id, $post, $update ) {
87
+ delete_post_meta( $post_id, '_uagb_toc_options' );
88
  }
89
 
90
  /**
126
  // converts all special characters like < or > to HTML entities, so we use
127
  // htmlspecialchars_decode to decode them.
128
  htmlspecialchars_decode(
129
+ htmlentities(
130
+ '<html><body>' . $content . '</body></html>',
131
+ ENT_COMPAT,
132
+ 'UTF-8',
133
+ false
 
 
134
  ),
135
  ENT_COMPAT
136
  )
193
  // and convert it to an integer. Should be faster than conditionals.
194
  'level' => (int) $heading->nodeName[1],
195
  'id' => $this->clean( $heading->textContent ),
196
+ 'content' => utf8_decode( $heading->textContent ),
197
  'depth' => intval( substr( $heading->tagName, 1 ) ),
198
  );
199
  }
216
  * @return string $string.
217
  */
218
  public function clean( $string ) {
 
 
 
 
 
 
 
 
219
  $string = preg_replace( '/[\x00-\x1F\x7F]*/u', '', $string );
220
  $string = str_replace( array( '&amp;', '&nbsp;' ), ' ', $string );
221
+ // Remove all except alphbets, space, `-` and `_`.
222
+ $string = preg_replace( '/[^A-Za-z0-9 _-]/', '', $string );
223
  // Convert space characters to an `_` (underscore).
224
  $string = preg_replace( '/\s+/', '_', $string );
225
+ // Replace multiple `_` (underscore) with a single `-` (hyphen).
226
+ $string = preg_replace( '/_+/', '-', $string );
227
  // Replace multiple `-` (hyphen) with a single `-` (hyphen).
228
  $string = preg_replace( '/-+/', '-', $string );
 
 
229
  // Remove trailing `-` and `_`.
230
  $string = trim( $string, '-_' );
231
+
232
+ if ( empty( $string ) ) {
233
+ $string = 'toc_' . uniqid();
234
+ }
235
+
236
+ return strtolower( $string ); // Replaces multiple hyphens with single one.
237
  }
238
 
239
  /**
405
  return '';
406
  }
407
 
408
+ $uagb_toc_options = get_post_meta( $post->ID, '_uagb_toc_options', true );
409
+ $uagb_toc_version = ! empty( $uagb_toc_options['_uagb_toc_version'] ) ? $uagb_toc_options['_uagb_toc_version'] : '';
410
+ $uagb_toc_heading_content = ! empty( $uagb_toc_options['_uagb_toc_headings'] ) ? $uagb_toc_options['_uagb_toc_headings'] : '';
411
 
412
+ if ( empty( $uagb_toc_heading_content ) || UAGB_ASSET_VER !== $uagb_toc_version ) {
413
 
414
  $uagb_toc_heading_content = $this->table_of_contents_get_headings(
415
  $post->ID,
416
  $attributes
417
  );
418
 
419
+ $meta_array = array(
420
+ '_uagb_toc_version' => UAGB_ASSET_VER,
421
+ '_uagb_toc_headings' => $uagb_toc_heading_content,
422
+ );
423
+
424
+ update_post_meta( $post->ID, '_uagb_toc_options', $meta_array );
425
 
426
  }
427
 
classes/class-uagb-loader.php CHANGED
@@ -66,7 +66,7 @@ if ( ! class_exists( 'UAGB_Loader' ) ) {
66
  define( 'UAGB_BASE', plugin_basename( UAGB_FILE ) );
67
  define( 'UAGB_DIR', plugin_dir_path( UAGB_FILE ) );
68
  define( 'UAGB_URL', plugins_url( '/', UAGB_FILE ) );
69
- define( 'UAGB_VER', '1.23.0' );
70
  define( 'UAGB_MODULES_DIR', UAGB_DIR . 'modules/' );
71
  define( 'UAGB_MODULES_URL', UAGB_URL . 'modules/' );
72
  define( 'UAGB_SLUG', 'uag' );
66
  define( 'UAGB_BASE', plugin_basename( UAGB_FILE ) );
67
  define( 'UAGB_DIR', plugin_dir_path( UAGB_FILE ) );
68
  define( 'UAGB_URL', plugins_url( '/', UAGB_FILE ) );
69
+ define( 'UAGB_VER', '1.23.1' );
70
  define( 'UAGB_MODULES_DIR', UAGB_DIR . 'modules/' );
71
  define( 'UAGB_MODULES_URL', UAGB_URL . 'modules/' );
72
  define( 'UAGB_SLUG', 'uag' );
classes/class-uagb-scripts-utils.php CHANGED
@@ -156,11 +156,19 @@ final class UAGB_Scripts_Utils {
156
  public static function get_asset_info( $type, $post_id ) {
157
 
158
  $uploads_dir = UAGB_Helper::get_upload_dir();
159
- $info = array();
 
 
160
 
161
- $path = get_post_meta( $post_id, '_uag_' . $type . '_file_name', true );
162
- $info[ $type ] = $uploads_dir['path'] . $path;
163
- $info[ $type . '_url' ] = $uploads_dir['url'] . $path;
 
 
 
 
 
 
164
 
165
  return $info;
166
  }
156
  public static function get_asset_info( $type, $post_id ) {
157
 
158
  $uploads_dir = UAGB_Helper::get_upload_dir();
159
+ $file_name = get_post_meta( $post_id, '_uag_' . $type . '_file_name', true );
160
+ $path = $type;
161
+ $url = $type . '_url';
162
 
163
+ $info = array(
164
+ $path => '',
165
+ $url => '',
166
+ );
167
+
168
+ if ( ! empty( $file_name ) ) {
169
+ $info[ $path ] = $uploads_dir['path'] . $file_name;
170
+ $info[ $url ] = $uploads_dir['url'] . $file_name;
171
+ }
172
 
173
  return $info;
174
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: gutenberg, blocks, gutenberg blocks, editor, block
5
  Requires at least: 4.7
6
  Requires PHP: 5.6
7
  Tested up to: 5.7
8
- Stable tag: 1.23.0
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -168,6 +168,11 @@ The awesome React FontIconPicker is developed by [Alessandro Benoit](http://code
168
 
169
  == Changelog ==
170
 
 
 
 
 
 
171
  = 1.23.0 =
172
  * New: Added an option to rollback to a previous version.
173
  * New: Added an option to get update notifications for beta versions.
5
  Requires at least: 4.7
6
  Requires PHP: 5.6
7
  Tested up to: 5.7
8
+ Stable tag: 1.23.1
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
168
 
169
  == Changelog ==
170
 
171
+ = 1.23.1 =
172
+ * Fix: Broken path while generating assets (CSS/JS).
173
+ * Fix: Table of Contents - Heading convert to question marks on the frontend.
174
+ * Fix: Table of Contents - Unexpected characters in links. Restricted to alphanumeric characters.
175
+
176
  = 1.23.0 =
177
  * New: Added an option to rollback to a previous version.
178
  * New: Added an option to get update notifications for beta versions.
ultimate-addons-for-gutenberg.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: https://www.brainstormforce.com
5
  * Author: Brainstorm Force
6
  * Author URI: https://www.brainstormforce.com
7
- * Version: 1.23.0
8
  * Description: The Ultimate Addons for Gutenberg extends the Gutenberg functionality with several unique and feature-rich blocks that help build websites faster.
9
  * Text Domain: ultimate-addons-for-gutenberg
10
  *
4
  * Plugin URI: https://www.brainstormforce.com
5
  * Author: Brainstorm Force
6
  * Author URI: https://www.brainstormforce.com
7
+ * Version: 1.23.1
8
  * Description: The Ultimate Addons for Gutenberg extends the Gutenberg functionality with several unique and feature-rich blocks that help build websites faster.
9
  * Text Domain: ultimate-addons-for-gutenberg
10
  *