LuckyWP Table of Contents - Version 2.0.6

Version Description

2020-01-29 = * When enabled smooth scroll hash changed after complete animation. * Fixed: incorrectly processing conditional comments in content. * Fixed: JS don't work on asynchronous loading.

Download this release

Release Info

Developer theluckywp
Plugin Icon 128x128 LuckyWP Table of Contents
Version 2.0.6
Comparing to
See all releases

Code changes from version 2.0.5 to 2.0.6

front/assets/main.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var o,l,n,e,f,g=function(t,e){var i,n={};for(i in t)n[i]=t[i];for(i in e)n[i]=e[i];return n},t=function(t){return t},c=(o={duration:300,action:"close",startTime:null,startHeight:null,endHeight:null,easing:t},l=function(e,i){cancelAnimationFrame(e.getAttribute("data-lwptoc-animation-request-id")),e.setAttribute("data-lwptoc-animation-request-id",window.requestAnimationFrame(function(t){n(e,i,t)}))},n=function(t,e,i){e.startTime||(e.startTime=i);var n,o=i-e.startTime;o<e.duration?(t.style.height=((e.endHeight-e.startingHeight)*e.easing(o/e.duration)+e.startingHeight).toFixed(2)+"px",l(t,e)):("close"===e.action&&(t.style.display="none"),"open"===e.action&&(t.style.display="block"),(n=t).style.height=null,n.style.overflow=null)},function(t,e){if(window.requestAnimationFrame){var i=g(o,{});i.action=e,t.style.height?i.startingHeight=parseFloat(t.style.height):i.startingHeight="close"===e?t.scrollHeight:0,(n=t).style.display="block",n.style.overflow="hidden",i.endHeight="close"===e?0:(t.style.height="0px",t.scrollHeight),l(t,i)}else t.style.display="close"===e?"none":"block";var n}),d=function(t){for(var e,i=document.querySelectorAll('[id="'+t+'"]'),n=0;n<i.length;n++)if((e=i[n]).offsetWidth||e.offsetHeight||e.getClientRects().length)return i[n];return null},i=(e={offset:0,duration:500,easing:t},f=function(t,e){var i=t.getBoundingClientRect().top+window.pageYOffset-e;return i<0?0:i},function(o,t){var l=g(e,t);if(window.requestAnimationFrame){var a,r,s,c=window.pageYOffset,d=null,u=function(t){a=f(o,l.offset),r=a-c;var e=window.pageYOffset;if(!s||!(0<r&&e<s||r<0&&s<e)){s=e,d||(d=t-1);var i=t-d,n=((a-c)*l.easing(i/l.duration)+c).toFixed();window.scroll(0,n),i<l.duration?window.requestAnimationFrame(u):window.scroll(0,a)}};window.requestAnimationFrame(u)}else window.scroll(0,f(o,l.offset))}),u={scrollTo:function(t,e){i(t,e)},registerScrollTrigger:function(t,c){for(var e=0;e<t.length;e++)t[e].addEventListener("click",function(t){t.preventDefault();var e,i,n,o,l,a=this.getAttribute("href"),r=a.substring(1),s=d(r);s&&(a!==document.location.hash&&(s.setAttribute("id",""),e=r,(l=document.createElement("a")).setAttribute("id",e),l.setAttribute("style","position:absolute;visibility:hidden;left:"+window.pageXOffset+"px;top:"+window.pageYOffset+"px;"),i=document.body,n=l,i.prepend?i.prepend(n):i.insertBefore(n,i.firstChild),document.location.hash=e,(o=l).remove?o.remove():o.parentNode.removeChild(o),s.setAttribute("id",r)),u.scrollTo(s,c))})},init:function(t){if("1"!==t.getAttribute("data-lwptoc-initialized")){var a,r=t.getElementsByClassName("lwptoc_toggle_label")[0],s=t.getElementsByClassName("lwptoc_items")[0];if(r)r.addEventListener("click",function(t){var e,i,n,o,l;t.preventDefault(),a=r.getAttribute("data-label"),r.setAttribute("data-label",r.innerHTML),r.innerHTML=a,l="lwptoc_items-visible",-1<(" "+s.className+" ").indexOf(" "+l+" ")?(o="lwptoc_items-visible",(n=s).className=(" "+n.className+" ").replace(" "+o+" ","").trim(),c(s,"close")):(i="lwptoc_items-visible",(e=s).className=e.className.trim()+" "+i,c(s,"open"))});"1"===t.getAttribute("data-smooth-scroll")&&u.registerScrollTrigger(s.getElementsByTagName("A"),{offset:t.getAttribute("data-smooth-scroll-offset")}),t.setAttribute("data-lwptoc-initialized","1")}}};window.lwptoc=u,document.addEventListener("DOMContentLoaded",function(){for(var t=document.getElementsByClassName("lwptoc"),e=0;e<t.length;e++)u.init(t[e])})}();
1
+ !function(){var o,l,n,e,f,g=function(t,e){var i,n={};for(i in t)n[i]=t[i];for(i in e)n[i]=e[i];return n},t=function(t){return t},c=(o={duration:300,action:"close",startTime:null,startHeight:null,endHeight:null,easing:t},l=function(e,i){cancelAnimationFrame(e.getAttribute("data-lwptoc-animation-request-id")),e.setAttribute("data-lwptoc-animation-request-id",window.requestAnimationFrame(function(t){n(e,i,t)}))},n=function(t,e,i){e.startTime||(e.startTime=i);var n,o=i-e.startTime;o<e.duration?(t.style.height=((e.endHeight-e.startingHeight)*e.easing(o/e.duration)+e.startingHeight).toFixed(2)+"px",l(t,e)):("close"===e.action&&(t.style.display="none"),"open"===e.action&&(t.style.display="block"),(n=t).style.height=null,n.style.overflow=null)},function(t,e){if(window.requestAnimationFrame){var i=g(o,{});i.action=e,t.style.height?i.startingHeight=parseFloat(t.style.height):i.startingHeight="close"===e?t.scrollHeight:0,(n=t).style.display="block",n.style.overflow="hidden",i.endHeight="close"===e?0:(t.style.height="0px",t.scrollHeight),l(t,i)}else t.style.display="close"===e?"none":"block";var n}),r=function(t){for(var e,i=document.querySelectorAll('[id="'+t+'"]'),n=0;n<i.length;n++)if((e=i[n]).offsetWidth||e.offsetHeight||e.getClientRects().length)return i[n];return null},i=(e={offset:0,duration:500,easing:t,onComplete:function(){}},f=function(t,e){var i=t.getBoundingClientRect().top+window.pageYOffset-e;return i<0?0:i},function(o,t){var l=g(e,t);if(window.requestAnimationFrame){var a,r,s,c=window.pageYOffset,d=null,u=function(t){a=f(o,l.offset),r=a-c;var e=window.pageYOffset;if(!s||!(0<r&&e<s||r<0&&s<e)){s=e,d||(d=t-1);var i=t-d,n=((a-c)*l.easing(i/l.duration)+c).toFixed();window.scroll(0,n),i<l.duration?window.requestAnimationFrame(u):(window.scroll(0,a),l.onComplete())}};window.requestAnimationFrame(u)}else window.scroll(0,f(o,l.offset)),l.onComplete()}),d={scrollTo:function(t,e){i(t,e)},registerScrollTrigger:function(t,i){for(var e=0;e<t.length;e++)t[e].addEventListener("click",function(t){t.preventDefault();var e=this.getAttribute("href"),l=e.substring(1),a=r(l);a&&(e!==document.location.hash&&(i.onComplete=function(){var t,e,i,n,o;a.setAttribute("id",""),t=l,(o=document.createElement("a")).setAttribute("id",t),o.setAttribute("style","position:absolute;visibility:hidden;left:"+window.pageXOffset+"px;top:"+window.pageYOffset+"px;"),e=document.body,i=o,e.prepend?e.prepend(i):e.insertBefore(i,e.firstChild),document.location.hash=t,(n=o).remove?n.remove():n.parentNode.removeChild(n),a.setAttribute("id",l)}),d.scrollTo(a,i))})},init:function(t){if("1"!==t.getAttribute("data-lwptoc-initialized")){t.setAttribute("data-lwptoc-initialized","1");var a,r=t.getElementsByClassName("lwptoc_toggle_label")[0],s=t.getElementsByClassName("lwptoc_items")[0];if(r)r.addEventListener("click",function(t){var e,i,n,o,l;t.preventDefault(),a=r.getAttribute("data-label"),r.setAttribute("data-label",r.innerHTML),r.innerHTML=a,l="lwptoc_items-visible",-1<(" "+s.className+" ").indexOf(" "+l+" ")?(o="lwptoc_items-visible",(n=s).className=(" "+n.className+" ").replace(" "+o+" ","").trim(),c(s,"close")):(i="lwptoc_items-visible",(e=s).className=e.className.trim()+" "+i,c(s,"open"))});"1"===t.getAttribute("data-smooth-scroll")&&d.registerScrollTrigger(s.getElementsByTagName("A"),{offset:t.getAttribute("data-smooth-scroll-offset")})}},globalInit:function(){for(var t=document.getElementsByClassName("lwptoc"),e=0;e<t.length;e++)d.init(t[e])}};window.lwptoc=d,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",d.globalInit):d.globalInit()}();
luckywp-table-of-contents.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: LuckyWP Table of Contents
4
  Plugin URI: https://theluckywp.com/product/table-of-contents/
5
  Description: Creates a table of contents for your posts/pages. Works automatically or manually (via shortcode, Gutenberg block or widget).
6
- Version: 2.0.5
7
  Author: LuckyWP
8
  Author URI: https://theluckywp.com/
9
  Text Domain: luckywp-table-of-contents
@@ -47,6 +47,6 @@ $lwptocAutoloader->register();
47
  $lwptocAutoloader->addNamespace('luckywp\tableOfContents', __DIR__);
48
 
49
  $config = require(__DIR__ . '/config/plugin.php');
50
- (new \luckywp\tableOfContents\plugin\Plugin($config))->run('2.0.5', __FILE__, 'lwptoc_');
51
 
52
  require_once __DIR__ . '/functions.php';
3
  Plugin Name: LuckyWP Table of Contents
4
  Plugin URI: https://theluckywp.com/product/table-of-contents/
5
  Description: Creates a table of contents for your posts/pages. Works automatically or manually (via shortcode, Gutenberg block or widget).
6
+ Version: 2.0.6
7
  Author: LuckyWP
8
  Author URI: https://theluckywp.com/
9
  Text Domain: luckywp-table-of-contents
47
  $lwptocAutoloader->addNamespace('luckywp\tableOfContents', __DIR__);
48
 
49
  $config = require(__DIR__ . '/config/plugin.php');
50
+ (new \luckywp\tableOfContents\plugin\Plugin($config))->run('2.0.6', __FILE__, 'lwptoc_');
51
 
52
  require_once __DIR__ . '/functions.php';
plugin/dom/Dom.php CHANGED
@@ -91,6 +91,9 @@ class Dom
91
  // CDATA
92
  $content = static::encode('#<!\[CDATA\[.*?\]\]>#imsu', $content);
93
 
 
 
 
94
  // Скрипты
95
  $content = static::encode('#<\s*script[^>]*>.*?</script\s*>#imsu', $content);
96
 
91
  // CDATA
92
  $content = static::encode('#<!\[CDATA\[.*?\]\]>#imsu', $content);
93
 
94
+ // Условные комментарии
95
+ $content = static::encode('#<!--\s*\[\s*if.*?endif\s*\]\s*-->#imsu', $content);
96
+
97
  // Скрипты
98
  $content = static::encode('#<\s*script[^>]*>.*?</script\s*>#imsu', $content);
99
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://theluckywp.com/product/table-of-contents/
4
  Tags: table of contents, toc, navigation, links, seo
5
  Requires at least: 4.7
6
  Tested up to: 5.3.2
7
- Stable tag: 2.0.5
8
  Requires PHP: 5.6.20
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -159,6 +159,11 @@ For non-English websites it is recommended to enable the `Intl` PHP extension.
159
 
160
  == Changelog ==
161
 
 
 
 
 
 
162
  = 2.0.5 — 2020-01-26 =
163
  * Fixed: incorrectly processing HTML entities in links.
164
  * Fixed: incorrectly processing scripts, styles and CDATA in content.
4
  Tags: table of contents, toc, navigation, links, seo
5
  Requires at least: 4.7
6
  Tested up to: 5.3.2
7
+ Stable tag: 2.0.6
8
  Requires PHP: 5.6.20
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
159
 
160
  == Changelog ==
161
 
162
+ = 2.0.6 — 2020-01-29 =
163
+ * When enabled smooth scroll hash changed after complete animation.
164
+ * Fixed: incorrectly processing conditional comments in content.
165
+ * Fixed: JS don't work on asynchronous loading.
166
+
167
  = 2.0.5 — 2020-01-26 =
168
  * Fixed: incorrectly processing HTML entities in links.
169
  * Fixed: incorrectly processing scripts, styles and CDATA in content.