PluginProbe
SimpleTOC – Table of Contents Block / 5.0.29
SimpleTOC – Table of Contents Block v5.0.29
7.2.0 7.3.0 7.1.1 7.1.0 7.0.10 7.0.9 7.0.8 7.0.7 7.0.6 7.0.4 7.0.5 5.0.21.1 5.0.22 5.0.23 5.0.24 5.0.25 5.0.25.1 5.0.27 5.0.28 5.0.29 5.0.3 5.0.30 5.0.31 5.0.32 5.0.33 All 159 releases
← All changes | plugin.php +32 -38 5.0.315.0.29 View file →
@@ -3,9 +3,9 @@
3 3 /**
4 4 * Plugin Name: SimpleTOC - Table of Contents Block
5 5 * Plugin URI: https://marc.tv/simpletoc-wordpress-inhaltsverzeichnis-plugin-gutenberg/
6 6 * Description: SEO-friendly Table of Contents Gutenberg block. No JavaScript and no CSS means faster loading.
7 - * Version: 5.0.31
7 + * Version: 5.0.29
8 8 * Author: Marc Tönsing
9 9 * Author URI: https://marc.tv
10 10 * Text Domain: simpletoc
11 11 * License: GPL v2 or later
@@ -85,9 +85,9 @@
85 85 }, 10, 4 );
86 86
87 87 /**
88 88 * Sets the default value of translatable attributes.
89 - *
89 + *
90 90 * Values inside block.json are static strings that are not translated. This
91 91 * filter inserts relevant translations i
92 92 *
93 93 * @param array $settings Array of determined settings for registering a block type.
@@ -264,52 +264,46 @@
264 264
265 265 /**
266 266 * Return all headings with a recursive walk through all blocks.
267 267 * This includes groups and reusable block with groups within reusable blocks.
268 - * @var array[] $blocks
269 - * @return array[]
270 268 */
271 -function filter_headings_recursive( array $blocks ): array {
272 - $arr = [];
273 - // allow developers to ignore specific blocks
274 - $ignored_blocks = apply_filters( 'simpletoc_excluded_blocks', [] );
275 269
276 - foreach ( $blocks as $innerBlock ) {
270 +function filter_headings_recursive( $blocks )
271 +{
272 + $arr = array();
277 273
278 - if ( is_array( $innerBlock ) ) {
274 + foreach ($blocks as $block => $innerBlock) {
279 275
280 - // if block is ignored, skip
281 - if ( isset( $innerBlock['blockName'] ) && in_array( $innerBlock['blockName'], $ignored_blocks ) ) {
282 - continue;
283 - }
276 + if (is_array($innerBlock)) {
284 277
285 - if ( isset( $innerBlock['attrs']['ref'] ) ) {
286 - // search in reusable blocks
287 - $e_arr = parse_blocks( get_post( $innerBlock['attrs']['ref'] )->post_content );
288 - $arr = array_merge( filter_headings_recursive( $e_arr ), $arr );
289 - } else {
290 - // search in groups
291 - $arr = array_merge( filter_headings_recursive( $innerBlock ), $arr );
292 - }
293 - } else {
278 + if (isset($innerBlock['attrs']['ref'])) {
279 + // search in reusable blocks
280 + $e_arr = parse_blocks(get_post($innerBlock['attrs']['ref'])->post_content);
281 + $arr = array_merge(filter_headings_recursive($e_arr), $arr);
282 + } else {
283 + // search in groups
284 + $arr = array_merge(filter_headings_recursive($innerBlock), $arr);
285 + }
286 + } else {
294 287
295 - if ( isset( $blocks['blockName'] ) && ( $blocks['blockName'] === 'core/heading' ) && $innerBlock !== 'core/heading' ) {
296 - // make sure it's a headline.
297 - if ( preg_match( "/(<h1|<h2|<h3|<h4|<h5|<h6)/i", $innerBlock ) ) {
298 - $arr[] = $innerBlock;
299 - }
300 - }
288 + if (isset($blocks['blockName']) && ( $blocks['blockName'] === 'core/heading' ) && $innerBlock !== 'core/heading') {
289 + // make sure its a headline.
290 + if (preg_match("/(<h1|<h2|<h3|<h4|<h5|<h6)/i", $innerBlock)) {
291 + $arr[] = $innerBlock;
292 + }
293 + }
301 294
302 - if ( isset( $blocks['blockName'] ) && ( $blocks['blockName'] === 'generateblocks/headline' ) && $innerBlock !== 'core/heading' ) {
303 - // make sure it's a headline.
304 - if ( preg_match( "/(<h1|<h2|<h3|<h4|<h5|<h6)/i", $innerBlock ) ) {
305 - $arr[] = $innerBlock;
306 - }
307 - }
308 - }
309 - }
295 + if (isset($blocks['blockName']) && ( $blocks['blockName'] === 'generateblocks/headline' ) && $innerBlock !== 'core/heading') {
296 + // make sure its a headline.
297 + if (preg_match("/(<h1|<h2|<h3|<h4|<h5|<h6)/i", $innerBlock)) {
298 + $arr[] = $innerBlock;
299 + }
300 + }
301 + }
302 + }
310 303
311 - return $arr;
304 + return $arr;
305 +
312 306 }
313 307
314 308 /**
315 309 * Remove all problematic characters for toc links