Version Description
Requires WordPress >
Download this release
Release Info
Developer | shazahm1@hotmail.com |
Plugin | Easy Table of Contents |
Version | 2.0.8 |
Comparing to | |
See all releases |
Code changes from version 2.0.7 to 2.0.8
- README.txt +13 -1
- easy-table-of-contents.php +3 -3
- includes/class.admin.php +8 -1
- includes/class.post.php +14 -11
- includes/class.widget-toc.php +5 -1
- includes/inc.plugin-compatibility.php +16 -0
- includes/inc.string-functions.php +33 -0
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 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -89,6 +89,15 @@ Easy Table Contents is a fork of the excellent [Table of Contents Plus](https://
|
|
89 |
|
90 |
== Changelog ==
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
= 2.0.7 04/02/2020 =
|
93 |
* NEW: Exclude any HTML nodes with the class of `.ez-toc-exclude-headings`.
|
94 |
* TWEAK: Change smooth scroll selector from `'body a'` to `'a.ez-toc-link'`.
|
@@ -376,3 +385,6 @@ Requires WordPress >= 5.0 and PHP version >= 5.6.20 (>= 7.1 is recommended).
|
|
376 |
|
377 |
= 2.0.7 =
|
378 |
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.8
|
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.8 04/03/2020 =
|
93 |
+
* TWEAK: Convert `<br />` tags in headings to a space.
|
94 |
+
* TWEAK: Add additional widget classes.
|
95 |
+
* TWEAK: Improve the sanitization of the excluded headings field post setting.
|
96 |
+
* TWEAK: Minor optimization of creating the matching pattern for excluding headings for improved performance.
|
97 |
+
* COMPATIBILITY: Exclude Create by Mediavine from heading eligibility.
|
98 |
+
* BUG: Ensure excluded headings are removed from the headings array.
|
99 |
+
* BUG: Ensure empty headings are removed from the headings array.
|
100 |
+
|
101 |
= 2.0.7 04/02/2020 =
|
102 |
* NEW: Exclude any HTML nodes with the class of `.ez-toc-exclude-headings`.
|
103 |
* TWEAK: Change smooth scroll selector from `'body a'` to `'a.ez-toc-link'`.
|
385 |
|
386 |
= 2.0.7 =
|
387 |
Requires WordPress >= 5.0 and PHP version >= 5.6.20 (>= 7.1 is recommended).
|
388 |
+
|
389 |
+
= 2.0.8 =
|
390 |
+
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.
|
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.
|
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.
|
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.8
|
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.8
|
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.8';
|
51 |
|
52 |
/**
|
53 |
* Stores the instance of this class.
|
includes/class.admin.php
CHANGED
@@ -416,7 +416,14 @@ if ( ! class_exists( 'ezTOC_Admin' ) ) {
|
|
416 |
$exclude = '';
|
417 |
}
|
418 |
|
419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
|
421 |
} else {
|
422 |
|
416 |
$exclude = '';
|
417 |
}
|
418 |
|
419 |
+
/*
|
420 |
+
* This is basically `esc_html()` but does not encode quotes.
|
421 |
+
* This is to allow angle brackets and such which `wp_kses_post` would strip as "evil" scripts.
|
422 |
+
*/
|
423 |
+
$exclude = wp_check_invalid_utf8( $exclude );
|
424 |
+
$exclude = _wp_specialchars( $exclude, ENT_NOQUOTES );
|
425 |
+
|
426 |
+
update_post_meta( $post_id, '_ez-toc-exclude', wp_kses_post( $exclude ) );
|
427 |
|
428 |
} else {
|
429 |
|
includes/class.post.php
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
3 |
class ezTOC_Post {
|
4 |
|
5 |
/**
|
@@ -590,6 +592,12 @@ class ezTOC_Post {
|
|
590 |
|
591 |
$found = false;
|
592 |
|
|
|
|
|
|
|
|
|
|
|
|
|
593 |
for ( $j = 0; $j < $excluded_count; $j++ ) {
|
594 |
|
595 |
// Since WP manipulates the post content it is required that the excluded header and
|
@@ -600,12 +608,6 @@ class ezTOC_Post {
|
|
600 |
get_option( 'blog_charset' )
|
601 |
);
|
602 |
|
603 |
-
$against = html_entity_decode(
|
604 |
-
wptexturize( strip_tags( str_replace( array( "\r", "\n" ), ' ', $matches[ $i ][0] ) ) ),
|
605 |
-
ENT_NOQUOTES,
|
606 |
-
get_option( 'blog_charset' )
|
607 |
-
);
|
608 |
-
|
609 |
if ( @preg_match( '/^' . $pattern . '$/imU', $against ) ) {
|
610 |
|
611 |
$found = true;
|
@@ -620,8 +622,8 @@ class ezTOC_Post {
|
|
620 |
}
|
621 |
|
622 |
//if ( count( $matches ) != count( $new_matches ) ) {
|
623 |
-
|
624 |
-
|
625 |
//}
|
626 |
}
|
627 |
}
|
@@ -777,7 +779,7 @@ class ezTOC_Post {
|
|
777 |
|
778 |
// WP entity encodes the post content.
|
779 |
$return = html_entity_decode( $heading, ENT_QUOTES, get_option( 'blog_charset' ) );
|
780 |
-
|
781 |
$return = trim( strip_tags( $return ) );
|
782 |
|
783 |
// Convert accented characters to ASCII.
|
@@ -879,8 +881,8 @@ class ezTOC_Post {
|
|
879 |
}
|
880 |
|
881 |
//if ( count( $matches ) != count( $new_matches ) ) {
|
882 |
-
|
883 |
-
|
884 |
//}
|
885 |
|
886 |
return $matches;
|
@@ -1236,6 +1238,7 @@ class ezTOC_Post {
|
|
1236 |
}
|
1237 |
|
1238 |
$title = isset( $matches[ $i ]['alternate'] ) ? $matches[ $i ]['alternate'] : $matches[ $i ][0];
|
|
|
1239 |
$title = strip_tags( apply_filters( 'ez_toc_title', $title ), apply_filters( 'ez_toc_title_allowable_tags', '' ) );
|
1240 |
|
1241 |
$html .= $this->createTOCItemAnchor( $page, $matches[ $i ]['id'], $title, $count );
|
1 |
<?php
|
2 |
|
3 |
+
use function Easy_Plugins\Table_Of_Contents\String\br2;
|
4 |
+
|
5 |
class ezTOC_Post {
|
6 |
|
7 |
/**
|
592 |
|
593 |
$found = false;
|
594 |
|
595 |
+
$against = html_entity_decode(
|
596 |
+
wptexturize( strip_tags( str_replace( array( "\r", "\n" ), ' ', $matches[ $i ][0] ) ) ),
|
597 |
+
ENT_NOQUOTES,
|
598 |
+
get_option( 'blog_charset' )
|
599 |
+
);
|
600 |
+
|
601 |
for ( $j = 0; $j < $excluded_count; $j++ ) {
|
602 |
|
603 |
// Since WP manipulates the post content it is required that the excluded header and
|
608 |
get_option( 'blog_charset' )
|
609 |
);
|
610 |
|
|
|
|
|
|
|
|
|
|
|
|
|
611 |
if ( @preg_match( '/^' . $pattern . '$/imU', $against ) ) {
|
612 |
|
613 |
$found = true;
|
622 |
}
|
623 |
|
624 |
//if ( count( $matches ) != count( $new_matches ) ) {
|
625 |
+
|
626 |
+
$matches = $new_matches;
|
627 |
//}
|
628 |
}
|
629 |
}
|
779 |
|
780 |
// WP entity encodes the post content.
|
781 |
$return = html_entity_decode( $heading, ENT_QUOTES, get_option( 'blog_charset' ) );
|
782 |
+
$return = br2( $return, ' ' );
|
783 |
$return = trim( strip_tags( $return ) );
|
784 |
|
785 |
// Convert accented characters to ASCII.
|
881 |
}
|
882 |
|
883 |
//if ( count( $matches ) != count( $new_matches ) ) {
|
884 |
+
|
885 |
+
$matches = $new_matches;
|
886 |
//}
|
887 |
|
888 |
return $matches;
|
1238 |
}
|
1239 |
|
1240 |
$title = isset( $matches[ $i ]['alternate'] ) ? $matches[ $i ]['alternate'] : $matches[ $i ][0];
|
1241 |
+
$title = br2( $title, ' ' );
|
1242 |
$title = strip_tags( apply_filters( 'ez_toc_title', $title ), apply_filters( 'ez_toc_title_allowable_tags', '' ) );
|
1243 |
|
1244 |
$html .= $this->createTOCItemAnchor( $page, $matches[ $i ]['id'], $title, $count );
|
includes/class.widget-toc.php
CHANGED
@@ -162,7 +162,11 @@ if ( ! class_exists( 'ezTOC_Widget' ) ) {
|
|
162 |
*/
|
163 |
extract( $args );
|
164 |
|
165 |
-
$class = array(
|
|
|
|
|
|
|
|
|
166 |
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
|
167 |
//$items = ezTOC::extract_headings( $find, $replace, $post );
|
168 |
|
162 |
*/
|
163 |
extract( $args );
|
164 |
|
165 |
+
$class = array(
|
166 |
+
'ez-toc-v' . str_replace( '.', '_', ezTOC::VERSION ),
|
167 |
+
'ez-toc-widget',
|
168 |
+
);
|
169 |
+
|
170 |
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
|
171 |
//$items = ezTOC::extract_headings( $find, $replace, $post );
|
172 |
|
includes/inc.plugin-compatibility.php
CHANGED
@@ -310,6 +310,22 @@ add_filter(
|
|
310 |
}
|
311 |
);
|
312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
class ezTOC_Elementor {
|
314 |
|
315 |
/**
|
310 |
}
|
311 |
);
|
312 |
|
313 |
+
/**
|
314 |
+
* Remove the Create by Mediavine node from the post content before extracting headings.
|
315 |
+
*
|
316 |
+
* @link https://wordpress.org/plugins/mediavine-create/
|
317 |
+
* @since 2.0.8
|
318 |
+
*/
|
319 |
+
add_filter(
|
320 |
+
'ez_toc_exclude_by_selector',
|
321 |
+
function( $selectors ) {
|
322 |
+
|
323 |
+
$selectors['mediavine-create'] = '.mv-create-card';
|
324 |
+
|
325 |
+
return $selectors;
|
326 |
+
}
|
327 |
+
);
|
328 |
+
|
329 |
class ezTOC_Elementor {
|
330 |
|
331 |
/**
|
includes/inc.string-functions.php
CHANGED
@@ -2,6 +2,39 @@
|
|
2 |
|
3 |
namespace Easy_Plugins\Table_Of_Contents\String;
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
/**
|
6 |
* Pulled from WordPress formatting functions.
|
7 |
*
|
2 |
|
3 |
namespace Easy_Plugins\Table_Of_Contents\String;
|
4 |
|
5 |
+
/**
|
6 |
+
* Replace `<br />` tags with parameter.
|
7 |
+
*
|
8 |
+
* @since 2.0.8
|
9 |
+
*
|
10 |
+
* @param string $string
|
11 |
+
* @param string $to
|
12 |
+
*
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
function br2( $string, $to = "\r\n" ) {
|
16 |
+
|
17 |
+
$string = preg_replace( '`<br[/\s]*>`i', $to, $string );
|
18 |
+
|
19 |
+
return $string;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Replace `<br />` tags with new lines.
|
24 |
+
*
|
25 |
+
* @link https://stackoverflow.com/a/27509016/5351316
|
26 |
+
*
|
27 |
+
* @since 2.0.8
|
28 |
+
*
|
29 |
+
* @param string $string
|
30 |
+
*
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
function br2nl( $string ) {
|
34 |
+
|
35 |
+
return br2( $string );
|
36 |
+
}
|
37 |
+
|
38 |
/**
|
39 |
* Pulled from WordPress formatting functions.
|
40 |
*
|