Easy Table of Contents - Version 2.0.10

Version Description

Requires WordPress >

Download this release

Release Info

Developer shazahm1@hotmail.com
Plugin Icon 128x128 Easy Table of Contents
Version 2.0.10
Comparing to
See all releases

Code changes from version 2.0.9 to 2.0.10

README.txt CHANGED
@@ -5,7 +5,7 @@ Tags: table of contents, toc
5
  Requires at least: 5.2
6
  Tested up to: 5.4
7
  Requires PHP: 5.6.20
8
- Stable tag: 2.0.9
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -89,6 +89,11 @@ Easy Table Contents is a fork of the excellent [Table of Contents Plus](https://
89
 
90
  == Changelog ==
91
 
 
 
 
 
 
92
  = 2.0.9 04/08/2020 =
93
  * TWEAK: AMP/Caching plugins seems to break anchors with colons and periods even though they are valid characters for the id attribute in HTML5.
94
  * TWEAK: Replace multiple underscores with a single underscore.
@@ -399,3 +404,6 @@ Requires WordPress >= 5.0 and PHP version >= 5.6.20 (>= 7.1 is recommended).
399
 
400
  = 2.0.9 =
401
  Requires WordPress >= 5.0 and PHP version >= 5.6.20 (>= 7.1 is recommended).
 
 
 
5
  Requires at least: 5.2
6
  Tested up to: 5.4
7
  Requires PHP: 5.6.20
8
+ Stable tag: 2.0.10
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
89
 
90
  == Changelog ==
91
 
92
+ = 2.0.10 04/20/2020 =
93
+ * TWEAK: Add trailing `span` to heading, to prepare for `#` option and to fix duplicate heading title matching.
94
+ * TWEAK: Add second heading search/replace function to search for heading in content with heading html entities decoded. May help Beaver Builder users as it seems like it does not encode HTML entities as WP core does.
95
+
96
+
97
  = 2.0.9 04/08/2020 =
98
  * TWEAK: AMP/Caching plugins seems to break anchors with colons and periods even though they are valid characters for the id attribute in HTML5.
99
  * TWEAK: Replace multiple underscores with a single underscore.
404
 
405
  = 2.0.9 =
406
  Requires WordPress >= 5.0 and PHP version >= 5.6.20 (>= 7.1 is recommended).
407
+
408
+ = 2.0.10 =
409
+ Requires WordPress >= 5.0 and PHP version >= 5.6.20 (>= 7.1 is recommended).
easy-table-of-contents.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Easy Table of Contents
4
  * Plugin URI: http://connections-pro.com/
5
  * Description: Adds a user friendly and fully automatic way to create and display a table of contents generated from the page content.
6
- * Version: 2.0.9
7
  * Author: Steven A. Zahm
8
  * Author URI: http://connections-pro.com/
9
  * Text Domain: easy-table-of-contents
@@ -26,7 +26,7 @@
26
  * @package Easy Table of Contents
27
  * @category Plugin
28
  * @author Steven A. Zahm
29
- * @version 2.0.9
30
  */
31
 
32
  use function Easy_Plugins\Table_Of_Contents\String\mb_find_replace;
@@ -47,7 +47,7 @@ if ( ! class_exists( 'ezTOC' ) ) {
47
  * @since 1.0
48
  * @var string
49
  */
50
- const VERSION = '2.0.9';
51
 
52
  /**
53
  * Stores the instance of this class.
3
  * Plugin Name: Easy Table of Contents
4
  * Plugin URI: http://connections-pro.com/
5
  * Description: Adds a user friendly and fully automatic way to create and display a table of contents generated from the page content.
6
+ * Version: 2.0.10
7
  * Author: Steven A. Zahm
8
  * Author URI: http://connections-pro.com/
9
  * Text Domain: easy-table-of-contents
26
  * @package Easy Table of Contents
27
  * @category Plugin
28
  * @author Steven A. Zahm
29
+ * @version 2.0.10
30
  */
31
 
32
  use function Easy_Plugins\Table_Of_Contents\String\mb_find_replace;
47
  * @since 1.0
48
  * @var string
49
  */
50
+ const VERSION = '2.0.10';
51
 
52
  /**
53
  * Stores the instance of this class.
includes/class.post.php CHANGED
@@ -803,6 +803,9 @@ class ezTOC_Post {
803
  $return = str_replace( array( ':' ), '_', $return );
804
  $return = str_replace( array( '.' ), ' ', $return );
805
 
 
 
 
806
  // Convert space characters to an `_` (underscore).
807
  $return = preg_replace( '/\s+/', '_', $return );
808
 
@@ -992,7 +995,7 @@ class ezTOC_Post {
992
  ),
993
  array(
994
  '><span class="ez-toc-section" id="' . $anchor . '"></span>',
995
- '</h' . $matches[ $i ][2] . '>'
996
  ),
997
  $matches[ $i ][0]
998
  );
803
  $return = str_replace( array( ':' ), '_', $return );
804
  $return = str_replace( array( '.' ), ' ', $return );
805
 
806
+ // Do not allow these characters because some JS libraries just are dumb.
807
+ $return = str_replace( array( '#', '?' ), '', $return );
808
+
809
  // Convert space characters to an `_` (underscore).
810
  $return = preg_replace( '/\s+/', '_', $return );
811
 
995
  ),
996
  array(
997
  '><span class="ez-toc-section" id="' . $anchor . '"></span>',
998
+ '<span class="ez-toc-section-end"></span></h' . $matches[ $i ][2] . '>'
999
  ),
1000
  $matches[ $i ][0]
1001
  );
includes/inc.string-functions.php CHANGED
@@ -294,14 +294,27 @@ function mb_find_replace( &$find = false, &$replace = false, &$string = '' ) {
294
 
295
  for ( $i = 0; $i < count( $find ); $i ++ ) {
296
 
297
- $start = mb_strpos( $string, $find[ $i ] );
298
- $length = mb_strlen( $find[ $i ] );
 
 
 
 
 
 
 
 
 
 
 
 
299
 
300
  /*
301
  * `mb_strpos()` can return `false`. Only process `mb_substr_replace()` if position in string is found.
302
  */
303
  if ( is_int( $start ) ) {
304
 
 
305
  $string = mb_substr_replace( $string, $replace[ $i ], $start, $length );
306
  }
307
 
294
 
295
  for ( $i = 0; $i < count( $find ); $i ++ ) {
296
 
297
+ $needle = $find[ $i ];
298
+ $start = mb_strpos( $string, $needle );
299
+
300
+ // If heading can not be found, let try decoding entities to see if it can be found.
301
+ if ( false === $start ) {
302
+
303
+ $needle = html_entity_decode(
304
+ $needle,
305
+ ENT_QUOTES,
306
+ get_option( 'blog_charset' )
307
+ );
308
+
309
+ $start = mb_strpos( $string, $needle );
310
+ }
311
 
312
  /*
313
  * `mb_strpos()` can return `false`. Only process `mb_substr_replace()` if position in string is found.
314
  */
315
  if ( is_int( $start ) ) {
316
 
317
+ $length = mb_strlen( $needle );
318
  $string = mb_substr_replace( $string, $replace[ $i ], $start, $length );
319
  }
320