PluginProbe
SimpleTOC – Table of Contents Block / 7.4.0
SimpleTOC – Table of Contents Block v7.4.0
7.4.0 7.3.1 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 All 161 releases
← All changes | plugin.php +17 -10 7.2.07.4.0 View file →
@@ -2,9 +2,9 @@
2 2 /**
3 3 * Plugin Name: SimpleTOC - Table of Contents Block
4 4 * Plugin URI: https://marc.tv/simpletoc-wordpress-inhaltsverzeichnis-plugin-gutenberg/
5 5 * Description: SEO-friendly Table of Contents Gutenberg block. No JavaScript or CSS by default.
6 - * Version: 7.2.0
6 + * Version: 7.4.0
7 7 * Requires at least: 6.2
8 8 * Requires PHP: 7.3
9 9 * Author: Marc Tönsing
10 10 * Author URI: https://toensing.com
@@ -20,9 +20,9 @@
20 20 require_once __DIR__ . '/simpletoc-admin-settings.php';
21 21 require_once __DIR__ . '/simpletoc-class-headline-ids.php';
22 22
23 23 const DEFAULT_BOX_COLOR = '#ebebeb';
24 -const SIMPLETOC_VERSION = '7.2.0';
24 +const SIMPLETOC_VERSION = '7.4.0';
25 25
26 26 /**
27 27 * Prevents direct execution of the plugin file.
28 28 * If a WordPress function does not exist, it means that the file has not been run by WordPress.
@@ -57,9 +57,10 @@
57 57 wp_add_inline_script(
58 58 'simpletoc-toc-editor-script',
59 59 'window.simpletocEditorSettings = ' . wp_json_encode(
60 60 array(
61 - 'settingsUrl' => admin_url( 'options-general.php?page=simpletoc' ),
61 + 'settingsUrl' => admin_url( 'options-general.php?page=simpletoc' ),
62 + 'scrollSpyEnabled' => simpletoc_scroll_spy_enabled(),
62 63 )
63 64 ) . ';',
64 65 'before'
65 66 );
@@ -77,8 +78,10 @@
77 78 */
78 79 function add_simpletoc_block_editor_settings( $editor_settings, $editor_context ) {
79 80 $editor_settings['simpletocSettingsUrl'] = admin_url( 'options-general.php?page=simpletoc' );
80 81
82 + $editor_settings['simpletocScrollSpyEnabled'] = simpletoc_scroll_spy_enabled();
83 +
81 84 return $editor_settings;
82 85 }
83 86
84 87 add_filter( 'block_editor_settings_all', __NAMESPACE__ . '\add_simpletoc_block_editor_settings', 10, 2 );
@@ -246,23 +249,28 @@
246 249 $title_text = $attributes['title_text'] ? esc_html( trim( $attributes['title_text'] ) ) : __( 'Table of Contents', 'simpletoc' );
247 250 $alignclass = ! empty( $attributes['align'] ) ? 'align' . $attributes['align'] : '';
248 251 $title_level = $attributes['title_level'];
249 252 $global_box_style_enabled = apply_filters( 'simpletoc_box_style_enabled', false ) || true === (bool) get_option( 'simpletoc_box_style_enabled', false );
250 - $box_style_enabled = $global_box_style_enabled || ! empty( $attributes['box_style'] );
253 + $legacy_box_style_enabled = ! empty( $attributes['box_style'] );
251 254 $typography_enabled = ! empty( $attributes['fontSize'] ) || ! empty( $attributes['style']['typography'] );
252 255 $wrapper_classes = array( 'simpletoc' );
253 256 $wrapper_style = '';
254 257
258 + if ( simpletoc_scroll_spy_enabled() || ! empty( $attributes['scroll_spy'] ) ) {
259 + $wrapper_classes[] = 'has-simpletoc-scroll-spy';
260 + }
261 +
255 262 if ( $typography_enabled ) {
256 263 $wrapper_classes[] = 'has-simpletoc-typography';
257 264 }
258 265
259 - if ( $box_style_enabled ) {
266 + if ( $global_box_style_enabled || $legacy_box_style_enabled ) {
267 + $wrapper_classes[] = 'is-style-boxed';
260 268 $wrapper_classes[] = 'has-simpletoc-box-style';
261 269
262 270 if ( $global_box_style_enabled ) {
263 271 $wrapper_classes[] = 'has-background';
264 - $wrapper_style = safecss_filter_attr( 'background-color:' . DEFAULT_BOX_COLOR . ';' );
272 + $wrapper_style = safecss_filter_attr( 'background-color:' . DEFAULT_BOX_COLOR . ';' );
265 273 } elseif ( ! empty( $attributes['box_color'] ) ) {
266 274 $wrapper_classes[] = 'has-background';
267 275 $wrapper_style = safecss_filter_attr( 'background-color:' . $attributes['box_color'] . ';' );
268 276 } else {
@@ -474,12 +482,11 @@
474 482 $html_wo_nbs = str_replace( ' ', ' ', $zero_punctuation );
475 483 // remove umlauts and accents.
476 484 $string_without_accents = remove_accents( $html_wo_nbs );
477 485 // Sanitizes a title, replacing whitespace and a few other characters with dashes.
478 - $sanitized_string = sanitize_title_with_dashes( $string_without_accents );
479 - // Encode for use in an url.
480 - $urlencoded = rawurlencode( $sanitized_string );
481 - return $urlencoded;
486 + // Already returns a URL-safe, percent-encoded slug for non-ASCII input, so no
487 + // further rawurlencode() is needed (that would double-encode the string).
488 + return sanitize_title_with_dashes( $string_without_accents );
482 489 }
483 490
484 491 /**
485 492 * Add additional plugin meta links to the SimpleTOC plugin page.