Easy Table of Contents - Version 2.0.37

Version Description

11/11/2022 = * BUG: Need to test compatibility with wp 6.1. #335 * BUG: Warning: Trying to access array offset on value of type null #334 * BUG: Numbers are wrong #330 * BUG: Add a new functionality "reset to default settings" #293 * BUG: Shortcode are not working with Salient theme #271

Download this release

Release Info

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

Code changes from version 2.0.36.1 to 2.0.37

README.txt CHANGED
@@ -3,9 +3,9 @@ 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.36.1
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -105,6 +105,13 @@ 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
  = 2.0.36.1 11/07/2022 =
109
  * BUG: Shortcode [toc] not working #332
110
 
3
  Donate link: https://tocwp.com/
4
  Tags: table of contents, toc
5
  Requires at least: 5.3
6
+ Tested up to: 6.1
7
  Requires PHP: 5.6.20
8
+ Stable tag: 2.0.37
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.37 11/11/2022 =
109
+ * BUG: Need to test compatibility with wp 6.1. #335
110
+ * BUG: Warning: Trying to access array offset on value of type null #334
111
+ * BUG: Numbers are wrong #330
112
+ * BUG: Add a new functionality "reset to default settings" #293
113
+ * BUG: Shortcode are not working with Salient theme #271
114
+
115
  = 2.0.36.1 11/07/2022 =
116
  * BUG: Shortcode [toc] not working #332
117
 
assets/js/admin.js CHANGED
@@ -22,6 +22,19 @@ jQuery(document).ready(function ($) {
22
  });
23
  }
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  $("#subscribe-newsletter-form").on('submit', function (e) {
26
  e.preventDefault();
27
  var $form = $("#subscribe-newsletter-form");
22
  });
23
  }
24
 
25
+ $("#reset-options-to-default-button").click(function() {
26
+ let text = "Do you want reset settings to default options?";
27
+ if (confirm(text) == true) {
28
+ $.post(ajaxurl, { action: 'eztoc_reset_options_to_default', eztoc_security_nonce: cn_toc_admin_data.eztoc_security_nonce },
29
+ function (data) {
30
+ alert('Default Options Reset Now!');
31
+ window.location.reload();
32
+ }
33
+ );
34
+ }
35
+
36
+ });
37
+
38
  $("#subscribe-newsletter-form").on('submit', function (e) {
39
  e.preventDefault();
40
  var $form = $("#subscribe-newsletter-form");
assets/js/admin.min.js CHANGED
@@ -1 +1 @@
1
- function disableScrolling(){var e=window.scrollX,n=window.scrollY;window.onscroll=function(){window.scrollTo(e,n)}}function enableScrolling(){window.onscroll=function(){}}jQuery(document).ready((function(e){var n=e(".ez-toc-color-picker");n.length&&n.wpColorPicker();var t=document.getElementById("ez-toc-settings[width]"),o=document.getElementById("ez-toc-settings[width_custom]");o&&("custom"!=t.value&&(o.parentNode.parentNode.style.display="none"),t.addEventListener("change",(function(){"custom"==document.getElementById("ez-toc-settings[width]").value?o.parentNode.parentNode.style.display="revert":o.parentNode.parentNode.style.display="none"}))),e("#subscribe-newsletter-form").on("submit",(function(n){n.preventDefault();var t=e("#subscribe-newsletter-form"),o=t.find('input[name="name"]').val(),c=t.find('input[name="email"]').val(),l=t.find('input[name="company"]').val();e.post(ajaxurl,{action:"eztoc_subscribe_newsletter",name:o,email:c,website:l,eztoc_security_nonce:cn_toc_admin_data.eztoc_security_nonce},(function(e){}))}))}));const unsecuredCopyToClipboard=e=>{const n=document.createElement("textarea");n.value=e,document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy")}catch(e){console.error("Unable to copy to clipboard",e)}document.body.removeChild(n)};function ez_toc_clipboard(e,n,t,o){o.preventDefault(),disableScrolling();var c=t.parentNode.parentNode.querySelectorAll("#"+e)[0];c.select(),c.setSelectionRange(0,99999),unsecuredCopyToClipboard(c.value),t.querySelectorAll("span."+n)[0].innerHTML="Copied: "+c.value}function ez_toc_outFunc(e,n,t){t.preventDefault(),n.querySelectorAll("span."+e)[0].innerHTML="Copy to clipboard",enableScrolling()}
1
+ function disableScrolling(){var e=window.scrollX,t=window.scrollY;window.onscroll=function(){window.scrollTo(e,t)}}function enableScrolling(){window.onscroll=function(){}}jQuery(document).ready(function(e){var t=e(".ez-toc-color-picker");t.length&&t.wpColorPicker();var o=document.getElementById("ez-toc-settings[width]"),n=document.getElementById("ez-toc-settings[width_custom]");n&&("custom"!=o.value&&(n.parentNode.parentNode.style.display="none"),o.addEventListener("change",function(){"custom"==document.getElementById("ez-toc-settings[width]").value?n.parentNode.parentNode.style.display="revert":n.parentNode.parentNode.style.display="none"})),e("#reset-options-to-default-button").click(function(){!0==confirm("Do you want reset settings to default options?")&&e.post(ajaxurl,{action:"eztoc_reset_options_to_default",eztoc_security_nonce:cn_toc_admin_data.eztoc_security_nonce},function(e){window.location.reload()})}),e("#subscribe-newsletter-form").on("submit",function(t){t.preventDefault();var o=e("#subscribe-newsletter-form"),n=o.find('input[name="name"]').val(),l=o.find('input[name="email"]').val(),c=o.find('input[name="company"]').val();e.post(ajaxurl,{action:"eztoc_subscribe_newsletter",name:n,email:l,website:c,eztoc_security_nonce:cn_toc_admin_data.eztoc_security_nonce},function(e){})})});const unsecuredCopyToClipboard=e=>{let t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}catch(o){console.error("Unable to copy to clipboard",o)}document.body.removeChild(t)};function ez_toc_clipboard(e,t,o,n){n.preventDefault(),disableScrolling();var l=o.parentNode.parentNode.querySelectorAll("#"+e)[0];l.select(),l.setSelectionRange(0,99999),unsecuredCopyToClipboard(l.value),o.querySelectorAll("span."+t)[0].innerHTML="Copied: "+l.value}function ez_toc_outFunc(e,t,o){o.preventDefault(),t.querySelectorAll("span."+e)[0].innerHTML="Copy to clipboard",enableScrolling()}
easy-table-of-contents.php CHANGED
@@ -3,7 +3,7 @@
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.36.1
7
  * Author: Magazine3
8
  * Author URI: https://tocwp.com/
9
  * Text Domain: easy-table-of-contents
@@ -26,7 +26,7 @@
26
  * @package Easy Table of Contents
27
  * @category Plugin
28
  * @author Magazine3
29
- * @version 2.0.36.1
30
  */
31
 
32
  use Easy_Plugins\Table_Of_Contents\Debug;
@@ -49,7 +49,7 @@ if ( ! class_exists( 'ezTOC' ) ) {
49
  * @since 1.0
50
  * @var string
51
  */
52
- const VERSION = '2.0.36.1';
53
 
54
  /**
55
  * Stores the instance of this class.
@@ -154,10 +154,11 @@ if ( ! class_exists( 'ezTOC' ) ) {
154
  //add_action( 'plugins_loaded', array( __CLASS__, 'loadTextdomain' ) );
155
  add_option('ez-toc-shortcode-exist-and-render', false);
156
  if ( in_array( 'js_composer_salient/js_composer.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
157
- add_option( 'ez-toc-post-meta-content', '' );
158
  }
159
 
160
  add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueueScripts' ) );
 
161
  add_action('admin_head', array( __CLASS__, 'addEditorButton' ));
162
 
163
  if( !self::checkBeaverBuilderPluginActive() ) {
@@ -251,7 +252,7 @@ if ( ! class_exists( 'ezTOC' ) ) {
251
  $postMetaContent = get_post_meta( get_the_ID(), '_nectar_portfolio_extra_content',
252
  true );
253
  if( !empty( $postMetaContent ) )
254
- update_option( 'ez-toc-post-meta-content', do_shortcode( $postMetaContent ) );
255
  }
256
 
257
  $isEligible = self::is_eligible( get_post() );
@@ -448,17 +449,31 @@ INLINEWPBAKERYJS;
448
  wp_add_inline_style( 'ez-toc', $css );
449
  }
450
 
451
- /**
 
 
 
 
 
 
 
 
 
 
 
 
452
  * RTL Direction
453
  * @since 2.0.33
454
  */
455
- self::InlineCountingCSS( ezTOC_Option::get( 'heading-text-direction', 'ltr' ) );
456
- self::InlineCountingCSS( ezTOC_Option::get( 'heading-text-direction', 'ltr' ),'ez-toc-widget-direction','ez-toc-widget-container', 'counter', 'ez-toc-widget-container' );
457
 
458
  if( ezTOC_Option::get( 'sticky-toggle' ) ) {
459
- self::InlineCountingCSS( ezTOC_Option::get( 'heading-text-direction', 'ltr' ), 'ez-toc-sticky-toggle-direction', 'ez-toc-sticky-toggle-counter', 'counter', 'ez-toc-sticky-container' );
460
  }
461
  /* End rtl direction */
 
 
462
  }
463
 
464
  /**
@@ -471,7 +486,7 @@ INLINEWPBAKERYJS;
471
  * @param string $class
472
  * @param string $counter
473
  * @param string $containerId
474
- * @return void
475
  */
476
  private static function InlineCountingCSS( $direction = 'ltr', $directionClass = 'ez-toc-container-direction', $class = 'ez-toc-counter', $counter = 'counter', $containerId = 'ez-toc-container' )
477
  {
@@ -482,9 +497,7 @@ INLINEWPBAKERYJS;
482
  $counterListAll = array_merge( ezTOC_Option::getCounterListDecimal(), ezTOC_Option::getCounterList_i18n() );
483
  $listTypesForCounting = array_keys( $counterListAll );
484
  $inlineCSS .= <<<INLINECSS
485
- .$directionClass {
486
- direction: $direction;
487
- }\n\n
488
  INLINECSS;
489
  $listAnchorPosition = 'before';
490
  $marginCSS = 'margin-right: .2em;';
@@ -500,10 +513,7 @@ INLINECSS;
500
  if( $list_type == '- ' )
501
  {
502
  $inlineCSS .= <<<INLINECSS
503
- #$containerId.$class nav ul li {
504
- list-style-type: '- ' !important;
505
- list-style-position: inside !important;
506
- }\n\n
507
  INLINECSS;
508
  } else if( in_array( $list_type, $listTypesForCounting ) ) {
509
  if( $direction == 'rtl' )
@@ -519,19 +529,7 @@ INLINECSS;
519
  if( $direction == 'ltr' )
520
  {
521
  $inlineCSS .= <<<INLINECSS
522
- .$class ul {
523
- counter-reset: item;
524
- }\n\n
525
-
526
- .$class nav ul li a::$listAnchorPosition {
527
- content: counters(item, ".", $list_type) ". ";
528
- display: inline-block;
529
- counter-increment: item;
530
- flex-grow: 0;
531
- flex-shrink: 0;
532
- $marginCSS \n
533
- $floatPosition
534
- }\n\n
535
  INLINECSS;
536
  }
537
  } else {
@@ -541,22 +539,12 @@ INLINECSS;
541
  $content = ". ";
542
 
543
  $inlineCSS .= <<<INLINECSS
544
- .$class ul {
545
- direction: $direction;
546
- counter-reset: item;
547
- }\n\n
548
- .$class nav ul li a::$listAnchorPosition {
549
- content: counter(item, $list_type) "$content";
550
- $marginCSS
551
- counter-increment: item;
552
- flex-grow: 0;
553
- flex-shrink: 0;
554
- $floatPosition
555
- }\n\n
556
  INLINECSS;
557
 
558
  }
559
- wp_add_inline_style( 'ez-toc', $inlineCSS );
 
560
  }
561
  }
562
 
@@ -587,10 +575,7 @@ INLINECSS;
587
  }
588
  $items = implode(", ", $items);
589
  $counterResetCSS .= <<<COUNTERRESETCSS
590
- .$class $ul {
591
- direction: rtl;
592
- counter-reset: $items;
593
- }\n\n
594
  COUNTERRESETCSS;
595
  }
596
  return $counterResetCSS;
@@ -619,9 +604,7 @@ COUNTERRESETCSS;
619
  $ul = implode(" ", $ul);
620
  $item = "item-level$i";
621
  $counterIncrementCSS .= <<<COUNTERINCREMENTCSS
622
- .$class $ul li {
623
- counter-increment: $item;
624
- }\n\n
625
  COUNTERINCREMENTCSS;
626
  }
627
  return $counterIncrementCSS;
@@ -658,13 +641,7 @@ COUNTERINCREMENTCSS;
658
  }
659
  $items = implode(' "." ', $items);
660
  $counterContentCSS .= <<<COUNTERINCREMENTCSS
661
- .$class nav $ul li a::before {
662
- content: $items ". ";
663
- float: right;
664
- margin-left: 0.2rem;
665
- flex-grow: 0;
666
- flex-shrink: 0;
667
- }\n\n
668
  COUNTERINCREMENTCSS;
669
  }
670
  return $counterContentCSS;
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.37
7
  * Author: Magazine3
8
  * Author URI: https://tocwp.com/
9
  * Text Domain: easy-table-of-contents
26
  * @package Easy Table of Contents
27
  * @category Plugin
28
  * @author Magazine3
29
+ * @version 2.0.37
30
  */
31
 
32
  use Easy_Plugins\Table_Of_Contents\Debug;
49
  * @since 1.0
50
  * @var string
51
  */
52
+ const VERSION = '2.0.37';
53
 
54
  /**
55
  * Stores the instance of this class.
154
  //add_action( 'plugins_loaded', array( __CLASS__, 'loadTextdomain' ) );
155
  add_option('ez-toc-shortcode-exist-and-render', false);
156
  if ( in_array( 'js_composer_salient/js_composer.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
157
+ add_option( 'ez-toc-post-meta-content', array( get_the_ID() => false ) );
158
  }
159
 
160
  add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueueScripts' ) );
161
+ add_action( 'wp_head', array( __CLASS__, 'inlineMainCountingCSS' ) );
162
  add_action('admin_head', array( __CLASS__, 'addEditorButton' ));
163
 
164
  if( !self::checkBeaverBuilderPluginActive() ) {
252
  $postMetaContent = get_post_meta( get_the_ID(), '_nectar_portfolio_extra_content',
253
  true );
254
  if( !empty( $postMetaContent ) )
255
+ update_option( 'ez-toc-post-meta-content', array( get_the_ID() => do_shortcode( $postMetaContent ) ) );
256
  }
257
 
258
  $isEligible = self::is_eligible( get_post() );
449
  wp_add_inline_style( 'ez-toc', $css );
450
  }
451
 
452
+
453
+ }
454
+
455
+ /**
456
+ * inlineMainCountingCSS Method
457
+ * for adding inlineCounting CSS
458
+ * in wp_head in last
459
+ * @since 2.0.37
460
+ * @return void
461
+ */
462
+ public static function inlineMainCountingCSS() {
463
+ $css = '';
464
+ /**
465
  * RTL Direction
466
  * @since 2.0.33
467
  */
468
+ $css .= self::InlineCountingCSS( ezTOC_Option::get( 'heading-text-direction', 'ltr' ) );
469
+ $css .= self::InlineCountingCSS( ezTOC_Option::get( 'heading-text-direction', 'ltr' ),'ez-toc-widget-direction','ez-toc-widget-container', 'counter', 'ez-toc-widget-container' );
470
 
471
  if( ezTOC_Option::get( 'sticky-toggle' ) ) {
472
+ $css .= self::InlineCountingCSS( ezTOC_Option::get( 'heading-text-direction', 'ltr' ), 'ez-toc-sticky-toggle-direction', 'ez-toc-sticky-toggle-counter', 'counter', 'ez-toc-sticky-container' );
473
  }
474
  /* End rtl direction */
475
+
476
+ echo "<style>$css</style>";
477
  }
478
 
479
  /**
486
  * @param string $class
487
  * @param string $counter
488
  * @param string $containerId
489
+ * @return string
490
  */
491
  private static function InlineCountingCSS( $direction = 'ltr', $directionClass = 'ez-toc-container-direction', $class = 'ez-toc-counter', $counter = 'counter', $containerId = 'ez-toc-container' )
492
  {
497
  $counterListAll = array_merge( ezTOC_Option::getCounterListDecimal(), ezTOC_Option::getCounterList_i18n() );
498
  $listTypesForCounting = array_keys( $counterListAll );
499
  $inlineCSS .= <<<INLINECSS
500
+ .$directionClass {direction: $direction;}
 
 
501
  INLINECSS;
502
  $listAnchorPosition = 'before';
503
  $marginCSS = 'margin-right: .2em;';
513
  if( $list_type == '- ' )
514
  {
515
  $inlineCSS .= <<<INLINECSS
516
+ #$containerId.$class nav ul li { list-style-type: '- ' !important; list-style-position: inside !important;}
 
 
 
517
  INLINECSS;
518
  } else if( in_array( $list_type, $listTypesForCounting ) ) {
519
  if( $direction == 'rtl' )
529
  if( $direction == 'ltr' )
530
  {
531
  $inlineCSS .= <<<INLINECSS
532
+ .$class ul{counter-reset: item;}.$class nav ul li a::$listAnchorPosition {content: counters(item, ".", $list_type) ". ";display: inline-block;counter-increment: item;flex-grow: 0;flex-shrink: 0;$marginCSS $floatPosition}
 
 
 
 
 
 
 
 
 
 
 
 
533
  INLINECSS;
534
  }
535
  } else {
539
  $content = ". ";
540
 
541
  $inlineCSS .= <<<INLINECSS
542
+ .$class ul {direction: $direction;counter-reset: item;}.$class nav ul li a::$listAnchorPosition {content: counter(item, $list_type) "$content";$marginCSS counter-increment: item;flex-grow: 0;flex-shrink: 0;$floatPosition }
 
 
 
 
 
 
 
 
 
 
 
543
  INLINECSS;
544
 
545
  }
546
+ // wp_add_inline_style( 'ez-toc', $inlineCSS );
547
+ return $inlineCSS;
548
  }
549
  }
550
 
575
  }
576
  $items = implode(", ", $items);
577
  $counterResetCSS .= <<<COUNTERRESETCSS
578
+ .$class $ul {direction: rtl;counter-reset: $items;}
 
 
 
579
  COUNTERRESETCSS;
580
  }
581
  return $counterResetCSS;
604
  $ul = implode(" ", $ul);
605
  $item = "item-level$i";
606
  $counterIncrementCSS .= <<<COUNTERINCREMENTCSS
607
+ .$class $ul li {counter-increment: $item;}
 
 
608
  COUNTERINCREMENTCSS;
609
  }
610
  return $counterIncrementCSS;
641
  }
642
  $items = implode(' "." ', $items);
643
  $counterContentCSS .= <<<COUNTERINCREMENTCSS
644
+ .$class nav $ul li a::before {content: $items ". ";float: right;margin-left: 0.2rem;flex-grow: 0;flex-shrink: 0;}
 
 
 
 
 
 
645
  COUNTERINCREMENTCSS;
646
  }
647
  return $counterContentCSS;
includes/class.options.php CHANGED
@@ -1665,7 +1665,27 @@ public static function child_font_size( $args ) {
1665
  echo '<label for="ez-toc-settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
1666
  }
1667
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1668
  }
1669
 
1670
  add_action( 'admin_init', array( 'ezTOC_Option', 'register' ) );
 
 
 
 
1671
  }
1665
  echo '<label for="ez-toc-settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
1666
  }
1667
  }
1668
+
1669
+ /**
1670
+ * reset_options_to_default Method
1671
+ * to reset options
1672
+ * @since 2.0.37
1673
+ * @return bool|string
1674
+ */
1675
+ public static function eztoc_reset_options_to_default() {
1676
+ if( !wp_verify_nonce( sanitize_text_field( $_POST['eztoc_security_nonce'] ), 'eztoc_ajax_check_nonce' ) )
1677
+ {
1678
+ return esc_attr__('Security Alert: nonce not verified!', 'easy-table-of-contents' );
1679
+ }
1680
+
1681
+ delete_option('ez-toc-settings');
1682
+ return add_option( 'ez-toc-settings', self::getDefaults() );
1683
+ }
1684
  }
1685
 
1686
  add_action( 'admin_init', array( 'ezTOC_Option', 'register' ) );
1687
+
1688
+ add_action( 'wp_ajax_eztoc_reset_options_to_default', array( 'ezTOC_Option', 'eztoc_reset_options_to_default' ) );
1689
+
1690
+
1691
  }
includes/inc.admin-options-page.php CHANGED
@@ -32,7 +32,10 @@
32
 
33
  if (function_exists('ez_toc_pro_activation_link')) {
34
  $license_info = get_option("easytoc_pro_upgrade_license");
35
- $license_exp = date('Y-m-d', strtotime($license_info['pro']['license_key_expires']));
 
 
 
36
  $today = date('Y-m-d');
37
  $exp_date = $license_exp;
38
  $date1 = date_create($today);
@@ -160,7 +163,10 @@
160
  </div><!-- /.metabox-holder -->
161
  <?php } ?>
162
  <?php settings_fields('ez-toc-settings'); ?>
163
- <?php submit_button(esc_html('Save Changes', 'easy-table-of-contents')); ?>
 
 
 
164
  </form>
165
  </div><!-- /.General Settings ended -->
166
 
32
 
33
  if (function_exists('ez_toc_pro_activation_link')) {
34
  $license_info = get_option("easytoc_pro_upgrade_license");
35
+ $license_exp = null;
36
+ if( !empty( $license_info['pro']['license_key_expires'] ) ) {
37
+ $license_exp = date( 'Y-m-d', strtotime($license_info['pro']['license_key_expires'] ) );
38
+ }
39
  $today = date('Y-m-d');
40
  $exp_date = $license_exp;
41
  $date1 = date_create($today);
163
  </div><!-- /.metabox-holder -->
164
  <?php } ?>
165
  <?php settings_fields('ez-toc-settings'); ?>
166
+ <p class="submit">
167
+ <?php submit_button( esc_html( 'Save Changes', 'easy-table-of-contents' ), 'primary large', 'submit', false) ; ?>
168
+ <button type="button" id="reset-options-to-default-button" class="button button-primary button-large" style="background-color: #cd3241"><?= __( 'Reset', 'easy-table-of-contents' ) ?></button>
169
+ </p>
170
  </form>
171
  </div><!-- /.General Settings ended -->
172