Easy Table of Contents - Version 2.0.34

Version Description

09/29/2022 = * BUG: Enabling sticky toggle makes the other links unclickable. #301 * BUG: Need to fix Pro Settings #300 * BUG: PRO Settings link design is disturb after esc_html_e() added in code #283 * BUG: Links are disabled when Sticky Toggle is on #282 * BUG: The numbering of the titles has disappeared after latest update. #281 * BUG: Sticky Toggle is not working on the plugin "Multiple Page Generator MPG" #279 * BUG: makesure this link goes to tocwp #273 * BUG: Admin JS issue not working well on other pages of WordPress #269

Download this release

Release Info

Developer magazine3
Plugin Icon 128x128 Easy Table of Contents
Version 2.0.34
Comparing to
See all releases

Code changes from version 2.0.33.2 to 2.0.34

README.txt CHANGED
@@ -1,11 +1,11 @@
1
  === Easy Table of Contents ===
2
  Contributors: magazine3
3
- Donate link: https://magazine3.company/
4
  Tags: table of contents, toc
5
  Requires at least: 5.3
6
  Tested up to: 6.0
7
  Requires PHP: 5.6.20
8
- Stable tag: 2.0.33.2
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -105,6 +105,15 @@ Easy Table Contents is a fork of the excellent [Table of Contents Plus](https://
105
  4. Activate the plugin on the Plugins admin page.
106
 
107
  == Changelog ==
 
 
 
 
 
 
 
 
 
108
 
109
  = 2.0.33.2 09/08/2022 =
110
  * BUG: Default settings set in options for ltr/rtl text direction - The numbering of the titles has disappeared after latest update. #281
1
  === Easy Table of Contents ===
2
  Contributors: magazine3
3
+ Donate link: https://tocwp.com/
4
  Tags: table of contents, toc
5
  Requires at least: 5.3
6
  Tested up to: 6.0
7
  Requires PHP: 5.6.20
8
+ Stable tag: 2.0.34
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
105
  4. Activate the plugin on the Plugins admin page.
106
 
107
  == Changelog ==
108
+ = 2.0.34 09/29/2022 =
109
+ * BUG: Enabling sticky toggle makes the other links unclickable. #301
110
+ * BUG: Need to fix Pro Settings #300
111
+ * BUG: PRO Settings link design is disturb after esc_html_e() added in code #283
112
+ * BUG: Links are disabled when Sticky Toggle is on #282
113
+ * BUG: The numbering of the titles has disappeared after latest update. #281
114
+ * BUG: Sticky Toggle is not working on the plugin "Multiple Page Generator – MPG" #279
115
+ * BUG: makesure this link goes to tocwp #273
116
+ * BUG: Admin JS issue not working well on other pages of WordPress #269
117
 
118
  = 2.0.33.2 09/08/2022 =
119
  * BUG: Default settings set in options for ltr/rtl text direction - The numbering of the titles has disappeared after latest update. #281
easy-table-of-contents.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /**
3
  * Plugin Name: Easy Table of Contents
4
- * Plugin URI: https://magazine3.company/
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.33.2
7
  * Author: Magazine3
8
- * Author URI: https://magazine3.company/
9
  * Text Domain: easy-table-of-contents
10
  * Domain Path: /languages
11
  *
@@ -26,7 +26,7 @@
26
  * @package Easy Table of Contents
27
  * @category Plugin
28
  * @author Magazine3
29
- * @version 2.0.33.2
30
  */
31
 
32
  use Easy_Plugins\Table_Of_Contents\Debug;
@@ -48,7 +48,7 @@ if ( ! class_exists( 'ezTOC' ) ) {
48
  * @since 1.0
49
  * @var string
50
  */
51
- const VERSION = '2.0.33.2';
52
 
53
  /**
54
  * Stores the instance of this class.
@@ -153,14 +153,29 @@ if ( ! class_exists( 'ezTOC' ) ) {
153
  //add_action( 'plugins_loaded', array( __CLASS__, 'loadTextdomain' ) );
154
  add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueueScripts' ) );
155
  add_action('admin_head', array( __CLASS__, 'addEditorButton' ));
156
- // Run after shortcodes are interpreted (priority 10).
157
- add_filter( 'the_content', array( __CLASS__, 'the_content' ), 100 );
158
- add_shortcode( 'ez-toc', array( __CLASS__, 'shortcode' ) );
159
- add_shortcode( 'lwptoc', array( __CLASS__, 'shortcode' ) );
160
- add_shortcode( apply_filters( 'ez_toc_shortcode', 'toc' ), array( __CLASS__, 'shortcode' ) );
 
 
 
 
161
  }
162
 
163
  /**
 
 
 
 
 
 
 
 
 
 
 
164
  * Load the plugin translation.
165
  *
166
  * Credit: Adapted from Ninja Forms / Easy Digital Downloads.
@@ -393,78 +408,84 @@ if ( ! class_exists( 'ezTOC' ) ) {
393
  private static function InlineCountingCSS( $direction = 'ltr', $directionClass = 'ez-toc-container-direction', $class = 'ez-toc-counter', $counter = 'counter', $containerId = 'ez-toc-container' )
394
  {
395
  $list_type = ezTOC_Option::get( $counter, 'decimal' );
396
- wp_enqueue_style('ez-toc');
397
- $inlineCSS = '';
398
- $counterListAll = array_merge(ezTOC_Option::getCounterListDecimal(), ezTOC_Option::getCounterList_i18n());
399
- $listTypesForCounting = array_keys($counterListAll);
400
- $inlineCSS .= <<<INLINECSS
 
401
  .$directionClass {
402
  direction: $direction;
403
  }\n\n
404
  INLINECSS;
405
- $listAnchorPosition = 'before';
406
- $marginCSS = 'margin-right: .2em;';
407
- $floatPosition = 'float: left;';
408
- if( $direction == 'rtl' )
409
- {
410
- $class .= '-rtl';
411
-
412
- $marginCSS = 'margin-left: .2em;';
413
- $floatPosition = 'float: right;';
414
- }
415
-
416
- if( $list_type == '- ' ) {
417
- $inlineCSS .= <<<INLINECSS
418
- #$containerId.$class nav ul li {
419
- list-style-type: '- ' !important;
420
- list-style-position: inside !important;
421
- }\n\n
422
- INLINECSS;
423
- } else if( in_array($list_type, $listTypesForCounting)) {
424
- if( $direction == 'rtl' )
425
  {
426
- $length = 6;
427
- $counterRTLCSS = self::rtlCounterResetCSS( $length, $class );
428
- $counterRTLCSS .= self::rtlCounterIncrementCSS( $length, $class );
429
- $counterRTLCSS .= self::rtlCounterContentCSS( $length, $list_type, $class );
430
- $inlineCSS .= <<<INLINECSS
431
- $counterRTLCSS
432
  INLINECSS;
433
- }
434
- if( $direction == 'ltr' )
435
- {
436
- $inlineCSS .= <<<INLINECSS
437
- .$class ul {
438
- counter-reset: item;
439
- }\n\n
440
-
441
- .$class nav ul li a::$listAnchorPosition {
442
- content: counters(item, ".", $list_type) ". ";
443
- display: inline-block;
444
- counter-increment: item;
445
- $marginCSS \n
446
- $floatPosition
447
- }\n\n
448
  INLINECSS;
449
- }
450
- } else {
451
-
452
-
453
- $inlineCSS .= <<<INLINECSS
454
- .$class ul {
455
- direction: $direction;
456
- counter-reset: item;
457
- }\n\n
458
- .$class nav ul li a::$listAnchorPosition {
459
- content: counter(item, $list_type) " ";
460
- $marginCSS
461
- counter-increment: item;
462
- $floatPosition
463
- }\n\n
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
464
  INLINECSS;
465
 
 
 
466
  }
467
- wp_add_inline_style('ez-toc', $inlineCSS);
468
  }
469
 
470
  /**
@@ -736,7 +757,7 @@ INLINESTICKYTOGGLECSS;
736
  * Sticky Sidebar JS
737
  */
738
  function hideBar(e) {
739
- e.preventDefault();
740
  var sidebar = document.querySelector(".ez-toc-sticky-fixed");
741
  sidebar.classList.remove("show");
742
  sidebar.classList.add("hide");
@@ -745,7 +766,7 @@ function hideBar(e) {
745
  }, 200);
746
  }
747
  function showBar(e) {
748
- e.preventDefault();
749
  document.querySelector(".ez-toc-open-icon").style = "z-index: -1;";
750
  setTimeout(function() {
751
  var sidebar = document.querySelector(".ez-toc-sticky-fixed");
@@ -757,7 +778,8 @@ function showBar(e) {
757
  let ez_toc_sticky_fixed_container = document.querySelector('div.ez-toc-sticky-fixed');
758
  if(ez_toc_sticky_fixed_container) {
759
  document.body.addEventListener("click", function (evt) {
760
- hideBar(event);
 
761
  });
762
  ez_toc_sticky_fixed_container.addEventListener('click', function(event) {
763
  event.stopPropagation();
@@ -1157,7 +1179,7 @@ INLINESTICKYTOGGLEJS;
1157
  /**
1158
  * @since 2.0.32
1159
  */
1160
- if ( ezTOC_Option::get('sticky-toggle') && !is_home() ) {
1161
  add_action('wp_footer', array(__CLASS__, 'stickyToggleContent'));
1162
  }
1163
 
1
  <?php
2
  /**
3
  * Plugin Name: Easy Table of Contents
4
+ * Plugin URI: https://tocwp.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.34
7
  * Author: Magazine3
8
+ * Author URI: https://tocwp.com/
9
  * Text Domain: easy-table-of-contents
10
  * Domain Path: /languages
11
  *
26
  * @package Easy Table of Contents
27
  * @category Plugin
28
  * @author Magazine3
29
+ * @version 2.0.34
30
  */
31
 
32
  use Easy_Plugins\Table_Of_Contents\Debug;
48
  * @since 1.0
49
  * @var string
50
  */
51
+ const VERSION = '2.0.34';
52
 
53
  /**
54
  * Stores the instance of this class.
153
  //add_action( 'plugins_loaded', array( __CLASS__, 'loadTextdomain' ) );
154
  add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueueScripts' ) );
155
  add_action('admin_head', array( __CLASS__, 'addEditorButton' ));
156
+
157
+ if( !self::checkBeaverBuilderPluginActive() ) {
158
+ add_filter( 'the_content', array( __CLASS__, 'the_content' ), 100 );
159
+
160
+ add_shortcode( 'ez-toc', array( __CLASS__, 'shortcode' ) );
161
+ add_shortcode( 'lwptoc', array( __CLASS__, 'shortcode' ) );
162
+ add_shortcode( apply_filters( 'ez_toc_shortcode', 'toc' ), array( __CLASS__, 'shortcode' ) );
163
+
164
+ }
165
  }
166
 
167
  /**
168
+ * checkBeaverBuilderPluginActive Method
169
+ * @since 2.0.34
170
+ * @return bool
171
+ */
172
+ private static function checkBeaverBuilderPluginActive() {
173
+ if( has_action( 'the_content' ) && isset($_REQUEST['fl_builder'])) {
174
+ return true;
175
+ }
176
+ return false;
177
+ }
178
+ /**
179
  * Load the plugin translation.
180
  *
181
  * Credit: Adapted from Ninja Forms / Easy Digital Downloads.
408
  private static function InlineCountingCSS( $direction = 'ltr', $directionClass = 'ez-toc-container-direction', $class = 'ez-toc-counter', $counter = 'counter', $containerId = 'ez-toc-container' )
409
  {
410
  $list_type = ezTOC_Option::get( $counter, 'decimal' );
411
+ if( $list_type != 'none' ) {
412
+ wp_enqueue_style( 'ez-toc' );
413
+ $inlineCSS = '';
414
+ $counterListAll = array_merge( ezTOC_Option::getCounterListDecimal(), ezTOC_Option::getCounterList_i18n() );
415
+ $listTypesForCounting = array_keys( $counterListAll );
416
+ $inlineCSS .= <<<INLINECSS
417
  .$directionClass {
418
  direction: $direction;
419
  }\n\n
420
  INLINECSS;
421
+ $listAnchorPosition = 'before';
422
+ $marginCSS = 'margin-right: .2em;';
423
+ $floatPosition = 'float: left;';
424
+ if( $direction == 'rtl' )
425
+ {
426
+ $class .= '-rtl';
427
+
428
+ $marginCSS = 'margin-left: .2em;';
429
+ $floatPosition = 'float: right;';
430
+ }
431
+
432
+ if( $list_type == '- ' )
 
 
 
 
 
 
 
 
433
  {
434
+ $inlineCSS .= <<<INLINECSS
435
+ #$containerId.$class nav ul li {
436
+ list-style-type: '- ' !important;
437
+ list-style-position: inside !important;
438
+ }\n\n
 
439
  INLINECSS;
440
+ } else if( in_array( $list_type, $listTypesForCounting ) ) {
441
+ if( $direction == 'rtl' )
442
+ {
443
+ $length = 6;
444
+ $counterRTLCSS = self::rtlCounterResetCSS( $length, $class );
445
+ $counterRTLCSS .= self::rtlCounterIncrementCSS( $length, $class );
446
+ $counterRTLCSS .= self::rtlCounterContentCSS( $length, $list_type, $class );
447
+ $inlineCSS .= <<<INLINECSS
448
+ $counterRTLCSS
 
 
 
 
 
 
449
  INLINECSS;
450
+ }
451
+ if( $direction == 'ltr' )
452
+ {
453
+ $inlineCSS .= <<<INLINECSS
454
+ .$class ul {
455
+ counter-reset: item;
456
+ }\n\n
457
+
458
+ .$class nav ul li a::$listAnchorPosition {
459
+ content: counters(item, ".", $list_type) ". ";
460
+ display: inline-block;
461
+ counter-increment: item;
462
+ $marginCSS \n
463
+ $floatPosition
464
+ }\n\n
465
+ INLINECSS;
466
+ }
467
+ } else {
468
+
469
+ $content = " ";
470
+ if( $list_type == 'numeric' || $list_type == 'cjk-earthly-branch' )
471
+ $content = ". ";
472
+
473
+ $inlineCSS .= <<<INLINECSS
474
+ .$class ul {
475
+ direction: $direction;
476
+ counter-reset: item;
477
+ }\n\n
478
+ .$class nav ul li a::$listAnchorPosition {
479
+ content: counter(item, $list_type) "$content";
480
+ $marginCSS
481
+ counter-increment: item;
482
+ $floatPosition
483
+ }\n\n
484
  INLINECSS;
485
 
486
+ }
487
+ wp_add_inline_style( 'ez-toc', $inlineCSS );
488
  }
 
489
  }
490
 
491
  /**
757
  * Sticky Sidebar JS
758
  */
759
  function hideBar(e) {
760
+ // e.preventDefault();
761
  var sidebar = document.querySelector(".ez-toc-sticky-fixed");
762
  sidebar.classList.remove("show");
763
  sidebar.classList.add("hide");
766
  }, 200);
767
  }
768
  function showBar(e) {
769
+ // e.preventDefault();
770
  document.querySelector(".ez-toc-open-icon").style = "z-index: -1;";
771
  setTimeout(function() {
772
  var sidebar = document.querySelector(".ez-toc-sticky-fixed");
778
  let ez_toc_sticky_fixed_container = document.querySelector('div.ez-toc-sticky-fixed');
779
  if(ez_toc_sticky_fixed_container) {
780
  document.body.addEventListener("click", function (evt) {
781
+ hideBar(evt);
782
+ evt.stopPropagation();
783
  });
784
  ez_toc_sticky_fixed_container.addEventListener('click', function(event) {
785
  event.stopPropagation();
1179
  /**
1180
  * @since 2.0.32
1181
  */
1182
+ if ( ezTOC_Option::get('sticky-toggle') && !is_home() && !self::checkBeaverBuilderPluginActive() ) {
1183
  add_action('wp_footer', array(__CLASS__, 'stickyToggleContent'));
1184
  }
1185
 
includes/inc.admin-options-page.php CHANGED
@@ -13,7 +13,7 @@
13
  $pro = '';
14
 
15
  if (function_exists('ez_toc_pro_activation_link')) {
16
- $pro = '<a id="eztoc-default" class="eztoc-tablinks" data-href="no" href="#eztoc-prosettings" onclick="ezTocTabToggle(event, \'prosettings\')">' . esc_html_e( 'PRO Settings', 'easy-table-of-contents' ) . '</a>';
17
  } ?>
18
  <?php echo $pro; ?>
19
 
13
  $pro = '';
14
 
15
  if (function_exists('ez_toc_pro_activation_link')) {
16
+ $pro = '<a id="eztoc-default" class="eztoc-tablinks" data-href="no" href="#eztoc-prosettings" onclick="ezTocTabToggle(event, \'general\')">PRO Settings</a>';
17
  } ?>
18
  <?php echo $pro; ?>
19
 
includes/inc.functions.php CHANGED
@@ -125,24 +125,55 @@ function ez_toc_woo_cat_desc_remove(){
125
  }
126
 
127
 
128
- if (function_exists( 'mpg_run' )) {
129
- add_filter('the_content', 'ez_toc_mpg');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  }
131
- function ez_toc_mpg($content){
132
- if (is_front_page() || is_single()) {
133
- return $content;
134
- }
135
- preg_match_all( '/<h(.*?).*?>(.*?)<\/h(.*?)>/', $content, $matches );
136
- $array = $matches[2];
137
- $container = '<div id="ez-toc-container" class="container counter-hierarchy counter-decimal ez-toc-grey"><div class="ez-toc-title-container"><p class="ez-toc-title">' . esc_html_e('Table of Contents', 'easy-table-of-contents') . '</p><span class="ez-toc-title-toggle"><a class="ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle" style="display: inline;"><i class="ez-toc-glyphicon ez-toc-icon-toggle"></i></a></span></div><nav><ul class="ez-toc-list">';
138
- foreach ( $array as $val ) {
139
- $val = preg_replace('/\[(.*?)\](.*?)\[(.*?)\]/', '$2', $val);
140
- $val = preg_replace('/{(.*?)\|(.*?)\|(.*?)}/', '$3', $val);
141
- $vals .= '<li><a class="anchor" href="#'.$val.'">'.$val.'</a></li>';
142
- $content = preg_replace('/<h(.*?).*?>(.*?)<\/h(.*?)>/', "<h$3 id='$2'>$2</h$3>", $content);
143
- }
144
- $last .= '</ul></nav></div>';
145
- $content = $container . $vals . $last . $content;
146
-
147
- return $content;
148
  }
125
  }
126
 
127
 
128
+ //if (function_exists( 'mpg_run' )) {
129
+ // add_filter('the_content', 'ez_toc_mpg');
130
+ //}
131
+ //function ez_toc_mpg($content){
132
+ // if (is_front_page() || is_single()) {
133
+ // return $content;
134
+ // }
135
+ /* preg_match_all( '/<h(.*?).*?>(.*?)<\/h(.*?)>/', $content, $matches );*/
136
+ // $array = $matches[2];
137
+ // $container = '<div id="ez-toc-container" class="container counter-hierarchy counter-decimal ez-toc-grey"><div class="ez-toc-title-container"><p class="ez-toc-title">' . esc_html_e('Table of Contents', 'easy-table-of-contents') . '</p><span class="ez-toc-title-toggle"><a class="ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle" style="display: inline;"><i class="ez-toc-glyphicon ez-toc-icon-toggle"></i></a></span></div><nav><ul class="ez-toc-list">';
138
+ // foreach ( $array as $val ) {
139
+ // $val = preg_replace('/\[(.*?)\](.*?)\[(.*?)\]/', '$2', $val);
140
+ // $val = preg_replace('/{(.*?)\|(.*?)\|(.*?)}/', '$3', $val);
141
+ // $vals .= '<li><a class="anchor" href="#'.$val.'">'.$val.'</a></li>';
142
+ /* $content = preg_replace('/<h(.*?).*?>(.*?)<\/h(.*?)>/', "<h$3 id='$2'>$2</h$3>", $content);*/
143
+ // }
144
+ // $last .= '</ul></nav></div>';
145
+ // $content = $container . $vals . $last . $content;
146
+ //
147
+ //return $content;
148
+ //}
149
+
150
+ //if( is_plugin_active('beaver-builder-lite-version/fl-builder.php') )
151
+ //{
152
+ // add_filter( 'the_content', array( ezTOC::class, 'the_content' ) );
153
+ //}
154
+
155
+ /**
156
+ * EzPrintR method
157
+ * to print_r content with pre tags
158
+ * @since 2.0.34
159
+ * @param $content
160
+ * @return void
161
+ */
162
+ function EzPrintR($content){
163
+ echo "<pre>";
164
+ print_r($content);
165
+ echo "</pre>";
166
  }
167
+
168
+ /**
169
+ * EzDumper method
170
+ * to var_dump content with pre tags
171
+ * @since 2.0.34
172
+ * @param $content
173
+ * @return void
174
+ */
175
+ function EzDumper($content){
176
+ echo "<pre>";
177
+ var_dump($content);
178
+ echo "</pre>";
 
 
 
 
 
179
  }
includes/inc.plugin-compatibility.php CHANGED
@@ -561,3 +561,28 @@ add_filter(
561
  return $apply;
562
  }
563
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
561
  return $apply;
562
  }
563
  );
564
+ /**
565
+ * Beaver Builder Plugin Customization
566
+ * for remove excluding heading contents
567
+ * @since 2.0.34
568
+ */
569
+ add_filter(
570
+ 'fl_builder_layout_data',
571
+ 'flBuilderLayoutDataEZTOC',
572
+ 12,
573
+ 1
574
+ );
575
+ function flBuilderLayoutDataEZTOC( $data ) {
576
+ if( has_action( 'the_content' ) ) {
577
+ $post = get_post( get_the_ID() );
578
+ foreach( $data as $nodeKey => $node )
579
+ {
580
+ // if( $node->type == 'module' )
581
+ // {
582
+ //// $node->settings->text = ezTOC::the_content($post->post_content);
583
+ // }
584
+ $data[$nodeKey] = $node;
585
+ }
586
+ }
587
+ return $data;
588
+ }