Version Description
2019-08-04 = + Added special color scheme "Inherit from theme". + Added option "List Markup Tags". + Added support Beaver Builder Themer Add-On. + Implemented automatic removal of empty headings from table of contents. * Automatic insertion of table of contents "after first block" takes into account only paragraphs and headings. * Improved JS code to prevent reinitialization. * Minor changes in strings, fixed typos. * Added tips for translators in code.
Download this release
Release Info
Developer | theluckywp |
Plugin | LuckyWP Table of Contents |
Version | 1.9 |
Comparing to | |
See all releases |
Code changes from version 1.8 to 1.9
- admin/assets/main.min.js +1 -1
- admin/widgets/metabox/views/box.php +1 -1
- config/settings.php +15 -6
- core/helpers/Html.php +12 -0
- front/Front.php +2 -2
- front/Toc.php +3 -0
- front/assets/main.min.css +1 -1
- front/assets/main.min.js +1 -1
- front/views/items.php +20 -14
- functions.php +14 -0
- integrations/BeaverBuilder.php +24 -3
- languages/luckywp-table-of-contents-ru_RU.mo +0 -0
- languages/luckywp-table-of-contents.pot +24 -16
- luckywp-table-of-contents.php +2 -2
- plugin/Plugin.php +14 -2
- plugin/Settings.php +12 -0
- plugin/Shortcode.php +1 -1
- plugin/contentHandling/ContentHandling.php +4 -0
- readme.txt +17 -4
admin/assets/main.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,t){var o="lwptocPreloader";e.fn[o+"Show"]=function(){var t=e(this);t.addClass(o+"Wrapper"),t.append('<div class="'+o+'Overlay"><div class="lwptocDarkSpinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div></div>')},e.fn[o+"Hide"]=function(){var t=e(this);t.removeClass(o+"Wrapper"),t.find("."+o+"Overlay").remove()}}(jQuery),function(l,t){var r="lwptocModal",e={type:"html",content:"",url:"",ajax:{},ajaxRequest:null,closeOnEsc:!0,closeOnOverlayClick:!0,clone:!1,overlay:{block:void 0,tpl:'<div class="'+r+'-overlay"></div>',css:{backgroundColor:"#000",opacity:.6,zIndex:1e5}},container:{block:void 0,tpl:'<div class="'+r+'-container"><div class="'+r+'-container_i"><div class="'+r+'-container_i2"></div></div></div>'},preloader:{verticalAlign:void 0,tpl:'<div class="'+r+'-preloader" />'},wrap:void 0,body:void 0,errors:{tpl:'<div class="'+r+"-error "+r+'-close"></div>',autocloseDelay:2e3,ajaxUnsuccessfulLoad:"Error"},openEffect:{type:"fade",speed:400},closeEffect:{type:"fade",speed:400},width:"auto",verticalAlign:"middle",beforeOpen:l.noop,afterOpen:l.noop,beforeClose:l.noop,afterClose:l.noop,afterLoading:l.noop,afterLoadingOnShow:l.noop,errorLoading:l.noop},d=0,s=l([]),u=function(t,e){var o=!0;return l(t).each(function(){l(e.target).get(0)==l(this).get(0)&&(o=!1),0==l(e.target).closest("HTML",l(this).get(0)).length&&(o=!1)}),o},i={getParentEl:function(t){var e=l(t);return e.data(r)?e:(e=l(t).closest("."+r+"-container").data(r+"ParentEl"))||!1},transition:function(t,e,o,n){switch(n=null==n?l.noop:n,o.type){case"fade":"show"==e?t.fadeIn(o.speed,n):t.fadeOut(o.speed,n);break;case"none":"show"==e?t.show():t.hide(),n()}},setWrapMarginRight:function(t,e){t.wrap.css("marginRight",e+"px"),l(document).trigger(r+"_setWrapMarginRight",e)},initEl:function(e,t){var o=e.data(r);if(!o){if(d++,(o=t).modalID=d,o.overlay.block=l(o.overlay.tpl),o.overlay.block.css(o.overlay.css),o.container.block=l(o.container.tpl),o.body=l("."+r+"-container_i2",o.container.block),t.clone?o.body.html(e.clone(!0)):(e.before('<div id="'+r+"Reserve"+o.modalID+'" style="display: none" />'),o.body.html(e)),o.body.on("click","."+r+"-close",function(){return e[r]("close"),!1}),o.closeOnOverlayClick&&o.overlay.block.add(o.container.block).click(function(t){u(l(">*",o.body),t)&&e[r]("close")}),o.container.block.data(r+"ParentEl",e),e.data(r,o),s=l.merge(s,e),l.proxy(p.show,e)(),"html"==o.type)return e;if(null!=o.ajax.beforeSend){var n=o.ajax.beforeSend;delete o.ajax.beforeSend}if(null!=o.ajax.success){var i=o.ajax.success;delete o.ajax.success}if(null!=o.ajax.error){var a=o.ajax.error;delete o.ajax.error}var c=l.extend(!0,{url:o.url,beforeSend:function(){o.body.html(o.preloader.tpl).css("verticalAlign",void 0===o.preloader.verticalAlign?o.verticalAlign:o.preloader.verticalAlign),void 0!==n&&n(o,e)},success:function(t){e.trigger("afterLoading."+r),t=o.afterLoading(o,e,t)||t,o.body.css("verticalAlign",o.verticalAlign),null==i?o.body.html(t):i(o,e,t),e.trigger("afterLoadingOnShow."+r),o.afterLoadingOnShow(o,e,t)},error:function(){e.trigger("errorLoading."+r),o.errorLoading(o,e),null==a?(o.body.html(o.errors.tpl),l("."+r+"-error",o.body).html(o.errors.ajaxUnsuccessfulLoad),l("."+r+"-close",o.body).click(function(){return e[r]("close"),!1}),o.errors.autocloseDelay&&setTimeout(function(){e[r]("close")},o.errors.autocloseDelay)):a(o,e)}},o.ajax);o.ajaxRequest=l.ajax(c),e.data(r,o)}},init:function(t){return t=l.extend(!0,{},e,t),l.isFunction(this)?null==t?void l.error(r+": Uncorrect parameters"):""!=t.url?(t.type="ajax",i.initEl(l("<div />"),t)):""!=t.content?(t.type="html",i.initEl(l(t.content),t)):void l.error(r+': Set parameter "url" or "content"'):this.each(function(){i.initEl(l(this),l.extend(!0,{},t))})}},p={show:function(){var t=i.getParentEl(this);if(!1!==t){var e=t.data(r);if(e.overlay.block.hide(),e.container.block.hide(),l("BODY").append(e.overlay.block),l("BODY").append(e.container.block),e.container.block.css("zIndex",e.overlay.block.css("zIndex")),e.beforeOpen(e,t),t.trigger("beforeOpen."+r),"hidden"!=e.wrap.css("overflow-y")){e.wrap.data(r+"Overflow",e.wrap.css("overflow-y"));var o=e.wrap.outerWidth(!0);e.wrap.css("overflow-y","hidden");var n=e.wrap.outerWidth(!0);n!=o&&i.setWrapMarginRight(e,n-o)}return s.not(t).each(function(){l(this).data(r).overlay.block.hide()}),e.body.css("verticalAlign",e.verticalAlign),e.body.parent().css("width",e.width),i.transition(e.overlay.block,"show",1<s.length?{type:"none"}:e.openEffect),i.transition(e.container.block,"show",1<s.length?{type:"none"}:e.openEffect,function(){e.afterOpen(e,t),t.trigger("afterOpen."+r)}),t}l.error(r+": Uncorrect call")},close:function(){if(!l.isFunction(this))return this.each(function(){var t=i.getParentEl(this);if(!1!==t){var e=t.data(r);!1!==e.beforeClose(e,t)&&(t.trigger("beforeClose."+r),s.not(t).last().each(function(){l(this).data(r).overlay.block.show()}),i.transition(e.overlay.block,"hide",1<s.length?{type:"none"}:e.closeEffect),i.transition(e.container.block,"hide",1<s.length?{type:"none"}:e.closeEffect,function(){e.afterClose(e,t),t.trigger("afterClose."+r),e.clone||l("#"+r+"Reserve"+e.modalID).replaceWith(e.body.find(">*")),e.overlay.block.remove(),e.container.block.remove(),t.data(r,null),l("."+r+"-container").length||(e.wrap.data(r+"Overflow")&&e.wrap.css("overflow-y",e.wrap.data(r+"Overflow")),i.setWrapMarginRight(e,0))}),"ajax"==e.type&&e.ajaxRequest.abort(),s=s.not(t))}else l.error(r+": Uncorrect call")});s.each(function(){l(this)[r]("close")})},getActive:function(){var t=l("."+r+"-container").last();return!!t.length&&t.data(r+"ParentEl").data(r)},setDefault:function(t){l.extend(!0,e,t)}};l(function(){e.wrap=l(document.all&&!document.querySelector?"html":"body")}),l(document).bind("keyup."+r,function(t){var e=s.last();e.length&&(e.data(r).closeOnEsc&&27===t.keyCode&&e[r]("close"))}),l[r]=l.fn[r]=function(t){return p[t]?p[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void l.error(r+": Method "+t+" does not exist"):i.init.apply(this,arguments)}}(jQuery),function(n,t){var i="lwptocAjaxForm",e={afterInit:n.noop,beforeSend:n.noop,success:n.noop,error:function(){alert("Failed to execute the query. Reload the page and try again.")},b:{}},a={isForm:function(t){return"form"==t.get(0).tagName.toLowerCase()},makeData:function(t){return a.isForm(t)?t.serialize():(e=t.clone().wrap("<form/>"),t.find("select").each(function(t){e.find("select").eq(t).val(n(this).val())}),e.serialize());var e},submit:function(t,e){n.ajax({type:"POST",cache:!1,data:a.makeData(t),url:a.isForm(t)?t.attr("action"):t.data("action"),beforeSend:function(){e.beforeSend(e,t)},success:function(t){e.b.container.html(t),e.success(e)},error:function(){e.error(e,t)}})},initContainer:function(t,e){var o=t.data(i);o||(o=e,t.data(i,o),(o.b.container=t).on("submit","[data-ajax-form]",function(){return a.submit(n(this),o),!1}),o.afterInit(o))},init:function(t){return t=n.extend(!0,{},e,t),n.isFunction(this)?(n.error(i+": Uncorrect call"),!1):this.each(function(){a.initContainer(n(this),n.extend(!0,{},t))})}},o={setDefault:function(t){n.extend(!0,e,t)}};n[i]=n.fn[i]=function(t){return o[t]?o[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?(n.error(i+": Method "+t+" does not exist"),!1):a.init.apply(this,arguments)}}(jQuery),function(d){d.lwptocModal("setDefault",{preloader:{tpl:'<div class="lwptocLightSpinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>'},overlay:{css:{zIndex:999999}}}),d(function(){var t=d(".js-lwptocSmoothScrollCheckbox");if(t.length){var e=d(".js-lwptocSmoothScrollIOffsetInput").closest("TR");t.change(function(){t.prop("checked")?e.show():e.hide()}).change()}var o=d(".js-lwptocToggleCheckbox");if(o.length){var n=d(".js-lwptocToggleEl").closest("TR");o.change(function(){o.prop("checked")?n.show():n.hide()}).change()}var i=d(".js-lwptocAutoInsertEnableCheckbox");if(i.length){var a=d(".js-lwptocAutoInsertEl").closest("TR");i.change(function(){i.prop("checked")?a.show():a.hide()}).change()}var c=d(".js-lwptocNumerationSelect");if(c.length){var l=d(".js-lwptocNumerationSuffixSelect").closest("TR");c.change(function(){"none"==c.val()?l.hide():l.show()}).change()}var r=d(".lwptoc_colorPicker");r.length&&r.wpColorPicker()}),d.lwptocCustomize={init:function(e,o){n.init(e.find(".lwptocWidthField")),i.init(e.find(".lwptocFontSizeField")),e.find(".lwptoc_colorPicker").wpColorPicker(),e.on("click",".lwptocCustomize_field_override",function(){var t=d(this).closest(".lwptocCustomize_field");t.removeClass("lwptocCustomize_field-default"),t.find("INPUT[type=text]").focus(),t.find(".lwptocCustomize_field_inputDefault").val(0)}),e.on("click",".lwptocCustomize_field_default",function(){var t=d(this).closest(".lwptocCustomize_field");t.addClass("lwptocCustomize_field-default"),t.find(".lwptocCustomize_field_inputDefault").val(1)}),e.on("click",".lwptocCustomize_tab",function(){e.find(".lwptocCustomize_tab-active").removeClass("lwptocCustomize_tab-active"),d(this).addClass("lwptocCustomize_tab-active"),e.find(".lwptocCustomize_fields").hide(),e.find(".lwptocCustomize_fields-"+d(this).data("tab")).show()}),e.lwptocAjaxForm({beforeSend:function(){e.lwptocPreloaderShow()},success:function(t){e.lwptocPreloaderHide(),o()}})},show:function(t,e){t._ajax_nonce=lwptocMain.nonce,d.lwptocModal({url:lwptocMain.ajaxUrl,closeOnOverlayClick:!1,verticalAlign:"top",ajax:{data:t},afterLoadingOnShow:function(t){d.lwptocCustomize.init(t.body.find(".lwptocCustomize"),function(){t.body.lwptocModal("close")})},afterClose:e})}};var o={reload:function(t){var e=d(t);o.$container.replaceWith(e),o.init(e)},setEnabled:function(t){d.ajax({url:lwptocMain.ajaxUrl,data:{_ajax_nonce:lwptocMain.nonce,action:"lwptoc_metabox_set_enabled",postId:o.$container.data("postId"),enabled:t?1:0},beforeSend:function(){o.$container.lwptocPreloaderShow()},success:function(t){o.$container.lwptocPreloaderHide(),o.reload(t)}})},setProcessing:function(t){d.ajax({url:lwptocMain.ajaxUrl,data:{_ajax_nonce:lwptocMain.nonce,action:"lwptoc_metabox_set_processing",postId:o.$container.data("postId"),enabled:t?1:0},beforeSend:function(){o.$container.lwptocPreloaderShow()},success:function(t){o.$container.lwptocPreloaderHide(),o.reload(t)}})},init:function(){o.$container=d(".lwptocMetabox"),o.$container.length&&(o.$container.find(".lwptocMetabox_disable").click(function(){o.setEnabled(!1)}),o.$container.find(".lwptocMetabox_enable").click(function(){o.setEnabled(!0)}),o.$container.find(".lwptocMetabox_disableProcessing").click(function(){o.setProcessing(!1)}),o.$container.find(".lwptocMetabox_enableProcessing").click(function(){o.setProcessing(!0)}),o.$container.find(".lwptocMetabox_customize").click(function(){d.lwptocCustomize.show({action:"lwptoc_metabox_customize",postId:o.$container.data("postId")},d.noop)}),d(document).on("lwptocMetaboxCustomized",function(t,e){d(".lwptocCustomize-metabox").lwptocModal("close"),o.reload(e.metabox)}))}};d(function(){o.init()});var e={oneInited:!1,oneInit:function(){d(document).on("lwptocWidgetCustomized",function(t,e){d(".lwptocCustomize-metabox").lwptocModal("close"),d(".lwptocWidget-"+e.id+" .lwptocWidget_override").html(e.override),d(".lwptocWidget-"+e.id+" .lwptocWidget_input").val(e.value).change()})},init:function(){d(".lwptocWidget").each(function(){var t=d(this);t.data("inited")||(t.find(".lwptocWidget_customize").click(function(){d.lwptocCustomize.show({action:"lwptoc_widget_customize",value:t.find(".lwptocWidget_input").val(),widgetId:t.data("id")},d.noop)}),t.data("inited",1),e.oneInited||e.oneInit())})}};d.lwptocWidget=e;var n={update:function(t){"custom"==t.$typeInput.val()?(t.$input.val(t.$sizeInput.val()+t.$unitInput.val()),t.$custom.show()):(t.$input.val(t.$typeInput.val()),t.$custom.hide())},init:function(t){t.each(function(){var t={$container:d(this)};t.$typeInput=t.$container.find(".lwptocWidthField_typeInput"),t.$sizeInput=t.$container.find(".lwptocWidthField_sizeInput"),t.$unitInput=t.$container.find(".lwptocWidthField_unitInput"),t.$input=t.$container.find(".lwptocWidthField_input"),t.$custom=t.$container.find(".lwptocWidthField_custom"),t.$typeInput.add(t.$sizeInput).add(t.$unitInput).change(function(){n.update(t)})})}};d(function(){n.init(d(".lwptocWidthField"))});var i={update:function(t){"custom"==t.$typeInput.val()?(t.$input.val(t.$sizeInput.val()+t.$unitInput.val()),t.$custom.show()):(t.$input.val(t.$typeInput.val()),t.$custom.hide())},init:function(t){t.each(function(){var t={$container:d(this)};t.$typeInput=t.$container.find(".lwptocFontSizeField_typeInput"),t.$sizeInput=t.$container.find(".lwptocFontSizeField_sizeInput"),t.$unitInput=t.$container.find(".lwptocFontSizeField_unitInput"),t.$input=t.$container.find(".lwptocFontSizeField_input"),t.$custom=t.$container.find(".lwptocFontSizeField_custom"),t.$typeInput.add(t.$sizeInput).add(t.$unitInput).change(function(){i.update(t)})})}};d(function(){i.init(d(".lwptocFontSizeField"))}),d(function(){var t=d(".lwptocRate");t.length&&t.on("click",".button",function(){d.ajax({url:lwptocMain.ajaxUrl,method:"POST",data:{action:d(this).data("action")},beforeSend:function(){t.lwptocPreloaderShow()},success:function(){t.remove()}})})})}(jQuery);
|
1 |
+
!function(e){var o="lwptocPreloader";e.fn[o+"Show"]=function(){var t=e(this);t.addClass(o+"Wrapper"),t.append('<div class="'+o+'Overlay"><div class="lwptocDarkSpinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div></div>')},e.fn[o+"Hide"]=function(){var t=e(this);t.removeClass(o+"Wrapper"),t.find("."+o+"Overlay").remove()}}(jQuery),function(l){var r="lwptocModal",e={type:"html",content:"",url:"",ajax:{},ajaxRequest:null,closeOnEsc:!0,closeOnOverlayClick:!0,clone:!1,overlay:{block:void 0,tpl:'<div class="'+r+'-overlay"></div>',css:{backgroundColor:"#000",opacity:.6,zIndex:1e5}},container:{block:void 0,tpl:'<div class="'+r+'-container"><div class="'+r+'-container_i"><div class="'+r+'-container_i2"></div></div></div>'},preloader:{verticalAlign:void 0,tpl:'<div class="'+r+'-preloader" />'},wrap:void 0,body:void 0,errors:{tpl:'<div class="'+r+"-error "+r+'-close"></div>',autocloseDelay:2e3,ajaxUnsuccessfulLoad:"Error"},openEffect:{type:"fade",speed:400},closeEffect:{type:"fade",speed:400},width:"auto",verticalAlign:"middle",beforeOpen:l.noop,afterOpen:l.noop,beforeClose:l.noop,afterClose:l.noop,afterLoading:l.noop,afterLoadingOnShow:l.noop,errorLoading:l.noop},d=0,s=l([]),u=function(t,e){var o=!0;return l(t).each(function(){l(e.target).get(0)==l(this).get(0)&&(o=!1),0==l(e.target).closest("HTML",l(this).get(0)).length&&(o=!1)}),o},i={getParentEl:function(t){var e=l(t);return e.data(r)?e:(e=l(t).closest("."+r+"-container").data(r+"ParentEl"))||!1},transition:function(t,e,o,n){switch(n=null==n?l.noop:n,o.type){case"fade":"show"==e?t.fadeIn(o.speed,n):t.fadeOut(o.speed,n);break;case"none":"show"==e?t.show():t.hide(),n()}},setWrapMarginRight:function(t,e){t.wrap.css("marginRight",e+"px"),l(document).trigger(r+"_setWrapMarginRight",e)},initEl:function(e,t){var o=e.data(r);if(!o){if(d++,(o=t).modalID=d,o.overlay.block=l(o.overlay.tpl),o.overlay.block.css(o.overlay.css),o.container.block=l(o.container.tpl),o.body=l("."+r+"-container_i2",o.container.block),t.clone?o.body.html(e.clone(!0)):(e.before('<div id="'+r+"Reserve"+o.modalID+'" style="display: none" />'),o.body.html(e)),o.body.on("click","."+r+"-close",function(){return e[r]("close"),!1}),o.closeOnOverlayClick&&o.overlay.block.add(o.container.block).click(function(t){u(l(">*",o.body),t)&&e[r]("close")}),o.container.block.data(r+"ParentEl",e),e.data(r,o),s=l.merge(s,e),l.proxy(p.show,e)(),"html"==o.type)return e;if(null!=o.ajax.beforeSend){var n=o.ajax.beforeSend;delete o.ajax.beforeSend}if(null!=o.ajax.success){var i=o.ajax.success;delete o.ajax.success}if(null!=o.ajax.error){var a=o.ajax.error;delete o.ajax.error}var c=l.extend(!0,{url:o.url,beforeSend:function(){o.body.html(o.preloader.tpl).css("verticalAlign",void 0===o.preloader.verticalAlign?o.verticalAlign:o.preloader.verticalAlign),void 0!==n&&n(o,e)},success:function(t){e.trigger("afterLoading."+r),t=o.afterLoading(o,e,t)||t,o.body.css("verticalAlign",o.verticalAlign),null==i?o.body.html(t):i(o,e,t),e.trigger("afterLoadingOnShow."+r),o.afterLoadingOnShow(o,e,t)},error:function(){e.trigger("errorLoading."+r),o.errorLoading(o,e),null==a?(o.body.html(o.errors.tpl),l("."+r+"-error",o.body).html(o.errors.ajaxUnsuccessfulLoad),l("."+r+"-close",o.body).click(function(){return e[r]("close"),!1}),o.errors.autocloseDelay&&setTimeout(function(){e[r]("close")},o.errors.autocloseDelay)):a(o,e)}},o.ajax);o.ajaxRequest=l.ajax(c),e.data(r,o)}},init:function(t){return t=l.extend(!0,{},e,t),l.isFunction(this)?null==t?void l.error(r+": Uncorrect parameters"):""!=t.url?(t.type="ajax",i.initEl(l("<div />"),t)):""!=t.content?(t.type="html",i.initEl(l(t.content),t)):void l.error(r+': Set parameter "url" or "content"'):this.each(function(){i.initEl(l(this),l.extend(!0,{},t))})}},p={show:function(){var t=i.getParentEl(this);if(!1!==t){var e=t.data(r);if(e.overlay.block.hide(),e.container.block.hide(),l("BODY").append(e.overlay.block),l("BODY").append(e.container.block),e.container.block.css("zIndex",e.overlay.block.css("zIndex")),e.beforeOpen(e,t),t.trigger("beforeOpen."+r),"hidden"!=e.wrap.css("overflow-y")){e.wrap.data(r+"Overflow",e.wrap.css("overflow-y"));var o=e.wrap.outerWidth(!0);e.wrap.css("overflow-y","hidden");var n=e.wrap.outerWidth(!0);n!=o&&i.setWrapMarginRight(e,n-o)}return s.not(t).each(function(){l(this).data(r).overlay.block.hide()}),e.body.css("verticalAlign",e.verticalAlign),e.body.parent().css("width",e.width),i.transition(e.overlay.block,"show",1<s.length?{type:"none"}:e.openEffect),i.transition(e.container.block,"show",1<s.length?{type:"none"}:e.openEffect,function(){e.afterOpen(e,t),t.trigger("afterOpen."+r)}),t}l.error(r+": Uncorrect call")},close:function(){if(!l.isFunction(this))return this.each(function(){var t=i.getParentEl(this);if(!1!==t){var e=t.data(r);!1!==e.beforeClose(e,t)&&(t.trigger("beforeClose."+r),s.not(t).last().each(function(){l(this).data(r).overlay.block.show()}),i.transition(e.overlay.block,"hide",1<s.length?{type:"none"}:e.closeEffect),i.transition(e.container.block,"hide",1<s.length?{type:"none"}:e.closeEffect,function(){e.afterClose(e,t),t.trigger("afterClose."+r),e.clone||l("#"+r+"Reserve"+e.modalID).replaceWith(e.body.find(">*")),e.overlay.block.remove(),e.container.block.remove(),t.data(r,null),l("."+r+"-container").length||(e.wrap.data(r+"Overflow")&&e.wrap.css("overflow-y",e.wrap.data(r+"Overflow")),i.setWrapMarginRight(e,0))}),"ajax"==e.type&&e.ajaxRequest.abort(),s=s.not(t))}else l.error(r+": Uncorrect call")});s.each(function(){l(this)[r]("close")})},getActive:function(){var t=l("."+r+"-container").last();return!!t.length&&t.data(r+"ParentEl").data(r)},setDefault:function(t){l.extend(!0,e,t)}};l(function(){e.wrap=l(document.all&&!document.querySelector?"html":"body")}),l(document).bind("keyup."+r,function(t){var e=s.last();e.length&&e.data(r).closeOnEsc&&27===t.keyCode&&e[r]("close")}),l[r]=l.fn[r]=function(t){return p[t]?p[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void l.error(r+": Method "+t+" does not exist"):i.init.apply(this,arguments)}}(jQuery),function(n){var i="lwptocAjaxForm",e={afterInit:n.noop,beforeSend:n.noop,success:n.noop,error:function(){alert("Failed to execute the query. Reload the page and try again.")},b:{}},a={isForm:function(t){return"form"==t.get(0).tagName.toLowerCase()},makeData:function(t){return a.isForm(t)?t.serialize():(e=t.clone().wrap("<form/>"),t.find("select").each(function(t){e.find("select").eq(t).val(n(this).val())}),e.serialize());var e},submit:function(t,e){n.ajax({type:"POST",cache:!1,data:a.makeData(t),url:a.isForm(t)?t.attr("action"):t.data("action"),beforeSend:function(){e.beforeSend(e,t)},success:function(t){e.b.container.html(t),e.success(e)},error:function(){e.error(e,t)}})},initContainer:function(t,e){var o=t.data(i);o||(o=e,t.data(i,o),(o.b.container=t).on("submit","[data-ajax-form]",function(){return a.submit(n(this),o),!1}),o.afterInit(o))},init:function(t){return t=n.extend(!0,{},e,t),n.isFunction(this)?(n.error(i+": Uncorrect call"),!1):this.each(function(){a.initContainer(n(this),n.extend(!0,{},t))})}},o={setDefault:function(t){n.extend(!0,e,t)}};n[i]=n.fn[i]=function(t){return o[t]?o[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?(n.error(i+": Method "+t+" does not exist"),!1):a.init.apply(this,arguments)}}(jQuery),function(d){d.lwptocModal("setDefault",{preloader:{tpl:'<div class="lwptocLightSpinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>'},overlay:{css:{zIndex:999999}}}),d(function(){var t=d(".js-lwptocSmoothScrollCheckbox");if(t.length){var e=d(".js-lwptocSmoothScrollIOffsetInput").closest("TR");t.change(function(){t.prop("checked")?e.show():e.hide()}).change()}var o=d(".js-lwptocToggleCheckbox");if(o.length){var n=d(".js-lwptocToggleEl").closest("TR");o.change(function(){o.prop("checked")?n.show():n.hide()}).change()}var i=d(".js-lwptocAutoInsertEnableCheckbox");if(i.length){var a=d(".js-lwptocAutoInsertEl").closest("TR");i.change(function(){i.prop("checked")?a.show():a.hide()}).change()}var c=d(".js-lwptocNumerationSelect");if(c.length){var l=d(".js-lwptocNumerationSuffixSelect").closest("TR");c.change(function(){"none"==c.val()?l.hide():l.show()}).change()}var r=d(".lwptoc_colorPicker");r.length&&r.wpColorPicker()}),d.lwptocCustomize={init:function(e,o){n.init(e.find(".lwptocWidthField")),i.init(e.find(".lwptocFontSizeField")),e.find(".lwptoc_colorPicker").wpColorPicker(),e.on("click",".lwptocCustomize_field_override",function(){var t=d(this).closest(".lwptocCustomize_field");t.removeClass("lwptocCustomize_field-default"),t.find("INPUT[type=text]").focus(),t.find(".lwptocCustomize_field_inputDefault").val(0)}),e.on("click",".lwptocCustomize_field_default",function(){var t=d(this).closest(".lwptocCustomize_field");t.addClass("lwptocCustomize_field-default"),t.find(".lwptocCustomize_field_inputDefault").val(1)}),e.on("click",".lwptocCustomize_tab",function(){e.find(".lwptocCustomize_tab-active").removeClass("lwptocCustomize_tab-active"),d(this).addClass("lwptocCustomize_tab-active"),e.find(".lwptocCustomize_fields").hide(),e.find(".lwptocCustomize_fields-"+d(this).data("tab")).show()}),e.lwptocAjaxForm({beforeSend:function(){e.lwptocPreloaderShow()},success:function(t){e.lwptocPreloaderHide(),o()}})},show:function(t,e){t._ajax_nonce=lwptocMain.nonce,d.lwptocModal({url:lwptocMain.ajaxUrl,closeOnOverlayClick:!1,verticalAlign:"top",ajax:{data:t},afterLoadingOnShow:function(t){d.lwptocCustomize.init(t.body.find(".lwptocCustomize"),function(){t.body.lwptocModal("close")})},afterClose:e})}};var o={reload:function(t){var e=d(t);o.$container.replaceWith(e),o.init(e)},setEnabled:function(t){d.ajax({url:lwptocMain.ajaxUrl,data:{_ajax_nonce:lwptocMain.nonce,action:"lwptoc_metabox_set_enabled",postId:o.$container.data("postId"),enabled:t?1:0},beforeSend:function(){o.$container.lwptocPreloaderShow()},success:function(t){o.$container.lwptocPreloaderHide(),o.reload(t)}})},setProcessing:function(t){d.ajax({url:lwptocMain.ajaxUrl,data:{_ajax_nonce:lwptocMain.nonce,action:"lwptoc_metabox_set_processing",postId:o.$container.data("postId"),enabled:t?1:0},beforeSend:function(){o.$container.lwptocPreloaderShow()},success:function(t){o.$container.lwptocPreloaderHide(),o.reload(t)}})},init:function(){o.$container=d(".lwptocMetabox"),o.$container.length&&(o.$container.find(".lwptocMetabox_disable").click(function(){o.setEnabled(!1)}),o.$container.find(".lwptocMetabox_enable").click(function(){o.setEnabled(!0)}),o.$container.find(".lwptocMetabox_disableProcessing").click(function(){o.setProcessing(!1)}),o.$container.find(".lwptocMetabox_enableProcessing").click(function(){o.setProcessing(!0)}),o.$container.find(".lwptocMetabox_customize").click(function(){d.lwptocCustomize.show({action:"lwptoc_metabox_customize",postId:o.$container.data("postId")},d.noop)}),d(document).on("lwptocMetaboxCustomized",function(t,e){d(".lwptocCustomize-metabox").lwptocModal("close"),o.reload(e.metabox)}))}};d(function(){o.init()});var e={oneInited:!1,oneInit:function(){d(document).on("lwptocWidgetCustomized",function(t,e){d(".lwptocCustomize-metabox").lwptocModal("close"),d(".lwptocWidget-"+e.id+" .lwptocWidget_override").html(e.override),d(".lwptocWidget-"+e.id+" .lwptocWidget_input").val(e.value).change()})},init:function(){d(".lwptocWidget").each(function(){var t=d(this);t.data("inited")||(t.find(".lwptocWidget_customize").click(function(){d.lwptocCustomize.show({action:"lwptoc_widget_customize",value:t.find(".lwptocWidget_input").val(),widgetId:t.data("id")},d.noop)}),t.data("inited",1),e.oneInited||e.oneInit())})}};d.lwptocWidget=e;var n={update:function(t){"custom"==t.$typeInput.val()?(t.$input.val(t.$sizeInput.val()+t.$unitInput.val()),t.$custom.show()):(t.$input.val(t.$typeInput.val()),t.$custom.hide())},init:function(t){t.each(function(){var t={$container:d(this)};t.$typeInput=t.$container.find(".lwptocWidthField_typeInput"),t.$sizeInput=t.$container.find(".lwptocWidthField_sizeInput"),t.$unitInput=t.$container.find(".lwptocWidthField_unitInput"),t.$input=t.$container.find(".lwptocWidthField_input"),t.$custom=t.$container.find(".lwptocWidthField_custom"),t.$typeInput.add(t.$sizeInput).add(t.$unitInput).change(function(){n.update(t)})})}};d(function(){n.init(d(".lwptocWidthField"))});var i={update:function(t){"custom"==t.$typeInput.val()?(t.$input.val(t.$sizeInput.val()+t.$unitInput.val()),t.$custom.show()):(t.$input.val(t.$typeInput.val()),t.$custom.hide())},init:function(t){t.each(function(){var t={$container:d(this)};t.$typeInput=t.$container.find(".lwptocFontSizeField_typeInput"),t.$sizeInput=t.$container.find(".lwptocFontSizeField_sizeInput"),t.$unitInput=t.$container.find(".lwptocFontSizeField_unitInput"),t.$input=t.$container.find(".lwptocFontSizeField_input"),t.$custom=t.$container.find(".lwptocFontSizeField_custom"),t.$typeInput.add(t.$sizeInput).add(t.$unitInput).change(function(){i.update(t)})})}};d(function(){i.init(d(".lwptocFontSizeField"))}),d(function(){var t=d(".lwptocRate");t.length&&t.on("click",".button",function(){d.ajax({url:lwptocMain.ajaxUrl,method:"POST",data:{action:d(this).data("action")},beforeSend:function(){t.lwptocPreloaderShow()},success:function(){t.remove()}})})})}(jQuery);
|
admin/widgets/metabox/views/box.php
CHANGED
@@ -15,7 +15,7 @@ use luckywp\tableOfContents\core\Core;
|
|
15 |
</p>
|
16 |
<?php } elseif ($settings->processHeadings) { ?>
|
17 |
<p>
|
18 |
-
<?= __('The headings will be processing in this post for use in
|
19 |
</p>
|
20 |
<?php } ?>
|
21 |
|
15 |
</p>
|
16 |
<?php } elseif ($settings->processHeadings) { ?>
|
17 |
<p>
|
18 |
+
<?= __('The headings will be processing in this post for use in table of contents in widget or custom shortcode.', 'luckywp-table-of-contents') ?>
|
19 |
</p>
|
20 |
<?php } ?>
|
21 |
|
config/settings.php
CHANGED
@@ -391,12 +391,12 @@ return [
|
|
391 |
],
|
392 |
],
|
393 |
'hash' => [
|
394 |
-
/* translators:
|
395 |
'title' => esc_html__('Hash', 'luckywp-table-of-contents'),
|
396 |
'fields' => [
|
397 |
|
398 |
'hashFormat' => [
|
399 |
-
/* translators:
|
400 |
'label' => esc_html__('Hash Format', 'luckywp-table-of-contents'),
|
401 |
'widget' => 'select',
|
402 |
'params' => [
|
@@ -468,8 +468,8 @@ return [
|
|
468 |
],
|
469 |
],
|
470 |
],
|
471 |
-
'
|
472 |
-
'title' => esc_html__('
|
473 |
'fields' => [
|
474 |
'showMetaboxPostTypes' => [
|
475 |
'label' => esc_html__('Show Panel "Table of Contents" in Post Types', 'luckywp-table-of-contents'),
|
@@ -479,8 +479,17 @@ return [
|
|
479 |
]);
|
480 |
},
|
481 |
],
|
482 |
-
|
483 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
484 |
],
|
485 |
],
|
486 |
];
|
391 |
],
|
392 |
],
|
393 |
'hash' => [
|
394 |
+
/* translators: Here, hash is a unique tracking string that is added to the URL after a # character */
|
395 |
'title' => esc_html__('Hash', 'luckywp-table-of-contents'),
|
396 |
'fields' => [
|
397 |
|
398 |
'hashFormat' => [
|
399 |
+
/* translators: Here, hash is a unique tracking string that is added to the URL after a # character */
|
400 |
'label' => esc_html__('Hash Format', 'luckywp-table-of-contents'),
|
401 |
'widget' => 'select',
|
402 |
'params' => [
|
468 |
],
|
469 |
],
|
470 |
],
|
471 |
+
'otherSettings' => [
|
472 |
+
'title' => esc_html__('Other Settings', 'luckywp-table-of-contents'),
|
473 |
'fields' => [
|
474 |
'showMetaboxPostTypes' => [
|
475 |
'label' => esc_html__('Show Panel "Table of Contents" in Post Types', 'luckywp-table-of-contents'),
|
479 |
]);
|
480 |
},
|
481 |
],
|
482 |
+
'listMarkupTags' => [
|
483 |
+
/* translators: User select DIV or UL/LI */
|
484 |
+
'label' => esc_html__('List Markup Tags', 'luckywp-table-of-contents'),
|
485 |
+
'widget' => 'select',
|
486 |
+
'params' => [
|
487 |
+
'items' => Core::$plugin->getListMarkupTagsList(),
|
488 |
+
],
|
489 |
+
'default' => 'div',
|
490 |
+
],
|
491 |
+
],
|
492 |
+
],
|
493 |
],
|
494 |
],
|
495 |
];
|
core/helpers/Html.php
CHANGED
@@ -56,6 +56,18 @@ class Html
|
|
56 |
return "<$name" . static::renderTagAttributes($options) . '>';
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
public static function renderTagAttributes($attributes)
|
60 |
{
|
61 |
$html = '';
|
56 |
return "<$name" . static::renderTagAttributes($options) . '>';
|
57 |
}
|
58 |
|
59 |
+
/**
|
60 |
+
* @param string|false|null $name
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public static function endTag($name)
|
64 |
+
{
|
65 |
+
if ($name === null || $name === false) {
|
66 |
+
return '';
|
67 |
+
}
|
68 |
+
return '</' . $name . '>';
|
69 |
+
}
|
70 |
+
|
71 |
public static function renderTagAttributes($attributes)
|
72 |
{
|
73 |
$html = '';
|
front/Front.php
CHANGED
@@ -143,7 +143,7 @@ class Front extends BaseFront
|
|
143 |
return $count ? $result : ($shortcode . $content);
|
144 |
|
145 |
case 'afterfirstblock':
|
146 |
-
$result = preg_replace($this->generateRegexp('[
|
147 |
return $count ? $result : ($shortcode . $content);
|
148 |
|
149 |
case 'bottom':
|
@@ -160,6 +160,6 @@ class Front extends BaseFront
|
|
160 |
*/
|
161 |
protected function generateRegexp($tagsRe)
|
162 |
{
|
163 |
-
return '#(<(' . $tagsRe . ')[^>]
|
164 |
}
|
165 |
}
|
143 |
return $count ? $result : ($shortcode . $content);
|
144 |
|
145 |
case 'afterfirstblock':
|
146 |
+
$result = preg_replace($this->generateRegexp('p|h[1-6]'), '$1 ' . $shortcode, $content, 1, $count);
|
147 |
return $count ? $result : ($shortcode . $content);
|
148 |
|
149 |
case 'bottom':
|
160 |
*/
|
161 |
protected function generateRegexp($tagsRe)
|
162 |
{
|
163 |
+
return '#(<(' . $tagsRe . ')[^>]*>.*?</\2>)#imsu';
|
164 |
}
|
165 |
}
|
front/Toc.php
CHANGED
@@ -265,6 +265,9 @@ class Toc
|
|
265 |
$colorScheme = str_replace(['_', ' ', '-'], '', strtolower($colorScheme));
|
266 |
if (array_key_exists($colorScheme, Core::$plugin->getColorSchemesList())) {
|
267 |
$containerOptions['class'][] = 'lwptoc-' . $colorScheme;
|
|
|
|
|
|
|
268 |
}
|
269 |
|
270 |
// Запомним цвета для переопределения
|
265 |
$colorScheme = str_replace(['_', ' ', '-'], '', strtolower($colorScheme));
|
266 |
if (array_key_exists($colorScheme, Core::$plugin->getColorSchemesList())) {
|
267 |
$containerOptions['class'][] = 'lwptoc-' . $colorScheme;
|
268 |
+
if ($colorScheme != 'inherit') {
|
269 |
+
$containerOptions['class'][] = 'lwptoc-notInherit';
|
270 |
+
}
|
271 |
}
|
272 |
|
273 |
// Запомним цвета для переопределения
|
front/assets/main.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.lwptoc{margin:32px 0}.lwptoc:first-child{margin-top:16px}.lwptoc_i{padding:14px 18px 18px;text-align:left}.
|
1 |
+
.lwptoc{margin:32px 0}.lwptoc:first-child{margin-top:16px}.lwptoc_i{padding:14px 18px 18px;text-align:left}.lwptoc_header{margin-bottom:6px}.rtl .lwptoc_header{text-align:right}.lwptoc_toggle{margin-left:4px;font-size:80%}.rtl .lwptoc_toggle{margin-left:0;margin-right:4px}.lwptoc_toggle:before{content:'['}.lwptoc_toggle:after{content:']'}.lwptoc_toggle_label{margin:0 1px}.lwptoc_item{margin-top:2px}.rtl .lwptoc_item{text-align:right}LI.lwptoc_item{margin:2px 0 0 0!important;padding:0!important;list-style:none!important}.lwptoc_item:first-child{margin-top:0}LI.lwptoc_item:first-child{margin-top:0!important}.lwptoc_item_number{margin-right:2px}.rtl .lwptoc_item_number{margin-right:0;margin-left:2px}.lwptoc_itemWrap .lwptoc_itemWrap{margin:2px 0 0 14px}.rtl .lwptoc_itemWrap .lwptoc_itemWrap{margin-left:0;margin-right:14px}UL.lwptoc_itemWrap{margin:0!important;padding:0!important;list-style:none!important}UL.lwptoc_itemWrap UL.lwptoc_itemWrap{margin:2px 0 0 14px!important}.rtl UL.lwptoc_itemWrap UL.lwptoc_itemWrap{margin-left:0!important;margin-right:14px!important}.lwptoc-autoWidth .lwptoc_i{display:inline-block}.lwptoc-left{float:left;margin-top:0;margin-right:32px}.lwptoc-right{float:right;margin-top:0;margin-left:32px}.lwptoc-rightwithoutflow{text-align:right}.lwptoc-rightwithoutflow .lwptoc_i{display:inline-block}.lwptoc-center{text-align:center}.lwptoc-center .lwptoc_i{margin-left:auto;margin-right:auto}.lwptoc-baseItems .lwptoc_items{font-size:90%}.lwptoc-notInherit .lwptoc_i DIV A{box-shadow:none!important;border:none!important;text-decoration:none!important}.lwptoc-notInherit .lwptoc_i DIV A:active,.lwptoc-notInherit .lwptoc_i DIV A:focus,.lwptoc-notInherit .lwptoc_i DIV A:hover{box-shadow:none!important;border:none!important;text-decoration:none!important}.lwptoc-notInherit .lwptoc_i DIV A:hover{border-bottom:1px dotted!important}.lwptoc-light .lwptoc_i{color:#333;background:#fafafa}.lwptoc-light .lwptoc_i A{color:#3175e4}.lwptoc-light .lwptoc_i A:active,.lwptoc-light .lwptoc_i A:focus,.lwptoc-light .lwptoc_i A:hover{color:#3175e4;border-color:#3175e4}.lwptoc-light .lwptoc_items A:visited{color:#000394}.lwptoc-dark .lwptoc_i{color:#d3d5d8;background:#2b2b2b}.lwptoc-dark .lwptoc_i A{color:#96c6ff}.lwptoc-dark .lwptoc_i A:active,.lwptoc-dark .lwptoc_i A:focus,.lwptoc-dark .lwptoc_i A:hover{color:#96c6ff;border-color:#71b2ff}.lwptoc-dark .lwptoc_items A:visited{color:#53a1ff}.lwptoc-white .lwptoc_i{color:#333;background:#fff}.lwptoc-white .lwptoc_i A{color:#3175e4}.lwptoc-white .lwptoc_i A:active,.lwptoc-white .lwptoc_i A:focus,.lwptoc-white .lwptoc_i A:hover{color:#3175e4;border-color:#3175e4}.lwptoc-white .lwptoc_items A:visited{color:#000394}.lwptoc-transparent .lwptoc_i{border:1px solid #eee}
|
front/assets/main.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(c){var s={calcScrollOffset:function(t,l){var
|
1 |
+
!function(c){var s={calcScrollOffset:function(t,l){var i=t.offset().top-l;return i<0?0:i},init:function(t){t.each(function(){var e=c(this);1!=e.data("lwptocInitialized")&&(e.find(".lwptoc_toggle_label").click(function(){var t=c(this),l=t.closest(".lwptoc").find(".lwptoc_items"),i=t.data("label");return"none"==l.css("display")?(l.stop(!0).slideDown(300),t.data("label",t.html()).html(i)):l.stop(!0).slideUp(300,function(){t.data("label",t.html()).html(i)}),!1}),e.data("smoothScroll")&&e.find(".lwptoc_items").on("click",'A[href^="#"]',function(t){t.preventDefault();var l=c(this).attr("href"),o=c('[id="'+l.slice(1)+'"]:visible');if(o.length){if(l!=location.hash){var i=o.attr("id"),a=c("<a> </a>").attr("id",i).css({position:"absolute",top:c(window).scrollTop(),left:c(window).scrollLeft(),visibility:"hidden"});o.attr("id",""),c("body").prepend(a),location.hash=l,a.remove(),o.attr("id",i)}var n=e.data("smoothScrollOffset");c("html, body").animate({scrollTop:s.calcScrollOffset(o,n)},{duration:500,step:function(t,l){var i=s.calcScrollOffset(o,n);l.end!==i&&(l.end=i)}})}}),e.data("lwptocInitialized",1))})}};c(function(){s.init(c(".lwptoc"))})}(jQuery);
|
front/views/items.php
CHANGED
@@ -2,18 +2,24 @@
|
|
2 |
/**
|
3 |
* @var $items array
|
4 |
* @var $depth int
|
|
|
|
|
5 |
*/
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* @var $items array
|
4 |
* @var $depth int
|
5 |
+
* @var $containerTag string
|
6 |
+
* @var $itemTag string
|
7 |
*/
|
8 |
+
|
9 |
+
use luckywp\tableOfContents\core\helpers\Html;
|
10 |
+
|
11 |
+
echo Html::beginTag($containerTag, ['class' => 'lwptoc_itemWrap']);
|
12 |
+
foreach ($items as $item) {
|
13 |
+
echo Html::beginTag($itemTag, ['class' => 'lwptoc_item']);
|
14 |
+
?>
|
15 |
+
<a href="#<?= $item['id'] ?>" class="lwptoc_item"<?= $item['relNofollow'] ?>>
|
16 |
+
<?php if ($item['number']) { ?>
|
17 |
+
<span class="lwptoc_item_number"><?= $item['number'] . $item['numberSuffix'] ?></span>
|
18 |
+
<?php } ?>
|
19 |
+
<span class="lwptoc_item_label"><?= $item['label'] ?></span>
|
20 |
+
</a>
|
21 |
+
<?php
|
22 |
+
lwptoc_items($item['childrens']);
|
23 |
+
echo Html::endTag($itemTag);
|
24 |
+
}
|
25 |
+
echo Html::endTag($containerTag);
|
functions.php
CHANGED
@@ -12,10 +12,24 @@ function lwptoc_items($items, $echo = true)
|
|
12 |
{
|
13 |
$html = '';
|
14 |
if ($items) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
Toc::$currentOutputDepth++;
|
16 |
$html = Core::$plugin->front->render('items', [
|
17 |
'items' => $items,
|
18 |
'depth' => Toc::$currentOutputDepth,
|
|
|
|
|
19 |
]);
|
20 |
Toc::$currentOutputDepth--;
|
21 |
}
|
12 |
{
|
13 |
$html = '';
|
14 |
if ($items) {
|
15 |
+
switch (Core::$plugin->settings->getListMarkupTags()) {
|
16 |
+
case 'ul':
|
17 |
+
$containerTag = 'ul';
|
18 |
+
$itemTag = 'li';
|
19 |
+
break;
|
20 |
+
|
21 |
+
case 'div':
|
22 |
+
default:
|
23 |
+
$containerTag = 'div';
|
24 |
+
$itemTag = 'div';
|
25 |
+
}
|
26 |
+
|
27 |
Toc::$currentOutputDepth++;
|
28 |
$html = Core::$plugin->front->render('items', [
|
29 |
'items' => $items,
|
30 |
'depth' => Toc::$currentOutputDepth,
|
31 |
+
'containerTag' => $containerTag,
|
32 |
+
'itemTag' => $itemTag,
|
33 |
]);
|
34 |
Toc::$currentOutputDepth--;
|
35 |
}
|
integrations/BeaverBuilder.php
CHANGED
@@ -8,10 +8,31 @@ use luckywp\tableOfContents\core\Core;
|
|
8 |
class BeaverBuilder extends BaseObject
|
9 |
{
|
10 |
|
|
|
|
|
11 |
public function init()
|
12 |
{
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
}
|
8 |
class BeaverBuilder extends BaseObject
|
9 |
{
|
10 |
|
11 |
+
protected $do = false;
|
12 |
+
|
13 |
public function init()
|
14 |
{
|
15 |
+
if (defined('FL_THEME_BUILDER_VERSION')) {
|
16 |
+
add_action('fl_theme_builder_before_render_content', function () {
|
17 |
+
$this->do = true;
|
18 |
+
});
|
19 |
+
|
20 |
+
add_filter('fl_builder_before_render_shortcodes', function ($content) {
|
21 |
+
return $this->do ? Core::$plugin->onTheContentTrue($content) : $content;
|
22 |
+
}, 1);
|
23 |
+
|
24 |
+
add_filter('lwptoc_need_processing_headings', function ($need) {
|
25 |
+
return $this->do ? false : $need;
|
26 |
+
}, 10000);
|
27 |
+
|
28 |
+
add_filter('fl_builder_after_render_shortcodes', function ($content) {
|
29 |
+
if ($this->do) {
|
30 |
+
$this->do = false;
|
31 |
+
$content = Core::$plugin->shortcode->theContent($content);
|
32 |
+
return Core::$plugin->onTheContentFalse($content);
|
33 |
+
}
|
34 |
+
return $content;
|
35 |
+
}, 10000);
|
36 |
+
}
|
37 |
}
|
38 |
}
|
languages/luckywp-table-of-contents-ru_RU.mo
CHANGED
Binary file
|
languages/luckywp-table-of-contents.pot
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: \n"
|
4 |
-
"POT-Creation-Date: 2019-
|
5 |
-
"PO-Revision-Date: 2019-
|
6 |
"Last-Translator: \n"
|
7 |
"Language-Team: \n"
|
8 |
"Language: ru_RU\n"
|
@@ -23,7 +23,7 @@ msgstr ""
|
|
23 |
|
24 |
#: admin/Admin.php:51 admin/Admin.php:52 admin/Admin.php:72 admin/Admin.php:99
|
25 |
#: admin/controllers/EditorBlockController.php:65
|
26 |
-
#: admin/controllers/ShortcodeController.php:68 plugin/Plugin.php:
|
27 |
#: plugin/WpWidget.php:20
|
28 |
msgid "Table of Contents"
|
29 |
msgstr ""
|
@@ -316,11 +316,11 @@ msgstr ""
|
|
316 |
msgid "Saved!"
|
317 |
msgstr ""
|
318 |
|
319 |
-
#: admin/widgets/fontSizeField/views/widget.php:16 plugin/Plugin.php:
|
320 |
msgid "Default"
|
321 |
msgstr ""
|
322 |
|
323 |
-
#: admin/widgets/fontSizeField/views/widget.php:17 plugin/Plugin.php:
|
324 |
msgid "Custom Value"
|
325 |
msgstr ""
|
326 |
|
@@ -330,7 +330,7 @@ msgstr ""
|
|
330 |
|
331 |
#: admin/widgets/metabox/views/box.php:18
|
332 |
msgid ""
|
333 |
-
"The headings will be processing in this post for use in
|
334 |
"widget or custom shortcode."
|
335 |
msgstr ""
|
336 |
|
@@ -479,13 +479,17 @@ msgid "SEO"
|
|
479 |
msgstr ""
|
480 |
|
481 |
#: config/settings.php:472
|
482 |
-
msgid "
|
483 |
msgstr ""
|
484 |
|
485 |
#: config/settings.php:475
|
486 |
msgid "Show Panel \"Table of Contents\" in Post Types"
|
487 |
msgstr ""
|
488 |
|
|
|
|
|
|
|
|
|
489 |
#: core/admin/AdminController.php:46
|
490 |
msgid "Sorry, you are not allowed to access this page."
|
491 |
msgstr ""
|
@@ -525,7 +529,7 @@ msgstr ""
|
|
525 |
msgid "Roman numbers"
|
526 |
msgstr ""
|
527 |
|
528 |
-
#: plugin/Plugin.php:142 plugin/Plugin.php:229 plugin/Plugin.php:
|
529 |
msgid "None"
|
530 |
msgstr ""
|
531 |
|
@@ -538,7 +542,7 @@ msgid "After first heading"
|
|
538 |
msgstr ""
|
539 |
|
540 |
#: plugin/Plugin.php:156
|
541 |
-
msgid "After first block (paragraph
|
542 |
msgstr ""
|
543 |
|
544 |
#: plugin/Plugin.php:157
|
@@ -617,28 +621,32 @@ msgstr ""
|
|
617 |
msgid "Transparent"
|
618 |
msgstr ""
|
619 |
|
620 |
-
#: plugin/Plugin.php:
|
621 |
-
msgid "
|
622 |
msgstr ""
|
623 |
|
624 |
#: plugin/Plugin.php:257
|
625 |
-
msgid "As heading
|
626 |
msgstr ""
|
627 |
|
628 |
-
#: plugin/Plugin.php:
|
|
|
|
|
|
|
|
|
629 |
#, php-format
|
630 |
msgid "Counter %s"
|
631 |
msgstr ""
|
632 |
|
633 |
-
#: plugin/Plugin.php:
|
634 |
msgid "Auto"
|
635 |
msgstr ""
|
636 |
|
637 |
-
#: plugin/Plugin.php:
|
638 |
msgid "Full Width"
|
639 |
msgstr ""
|
640 |
|
641 |
-
#: plugin/Plugin.php:
|
642 |
msgid ""
|
643 |
"Creates a table of contents for your posts/pages. Works automatically or "
|
644 |
"manually (via shortcode, Gutenberg block or widget)."
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: \n"
|
4 |
+
"POT-Creation-Date: 2019-08-02 22:23+0300\n"
|
5 |
+
"PO-Revision-Date: 2019-08-02 22:25+0300\n"
|
6 |
"Last-Translator: \n"
|
7 |
"Language-Team: \n"
|
8 |
"Language: ru_RU\n"
|
23 |
|
24 |
#: admin/Admin.php:51 admin/Admin.php:52 admin/Admin.php:72 admin/Admin.php:99
|
25 |
#: admin/controllers/EditorBlockController.php:65
|
26 |
+
#: admin/controllers/ShortcodeController.php:68 plugin/Plugin.php:452
|
27 |
#: plugin/WpWidget.php:20
|
28 |
msgid "Table of Contents"
|
29 |
msgstr ""
|
316 |
msgid "Saved!"
|
317 |
msgstr ""
|
318 |
|
319 |
+
#: admin/widgets/fontSizeField/views/widget.php:16 plugin/Plugin.php:311
|
320 |
msgid "Default"
|
321 |
msgstr ""
|
322 |
|
323 |
+
#: admin/widgets/fontSizeField/views/widget.php:17 plugin/Plugin.php:276
|
324 |
msgid "Custom Value"
|
325 |
msgstr ""
|
326 |
|
330 |
|
331 |
#: admin/widgets/metabox/views/box.php:18
|
332 |
msgid ""
|
333 |
+
"The headings will be processing in this post for use in table of contents in "
|
334 |
"widget or custom shortcode."
|
335 |
msgstr ""
|
336 |
|
479 |
msgstr ""
|
480 |
|
481 |
#: config/settings.php:472
|
482 |
+
msgid "Other Settings"
|
483 |
msgstr ""
|
484 |
|
485 |
#: config/settings.php:475
|
486 |
msgid "Show Panel \"Table of Contents\" in Post Types"
|
487 |
msgstr ""
|
488 |
|
489 |
+
#: config/settings.php:484
|
490 |
+
msgid "List Markup Tags"
|
491 |
+
msgstr ""
|
492 |
+
|
493 |
#: core/admin/AdminController.php:46
|
494 |
msgid "Sorry, you are not allowed to access this page."
|
495 |
msgstr ""
|
529 |
msgid "Roman numbers"
|
530 |
msgstr ""
|
531 |
|
532 |
+
#: plugin/Plugin.php:142 plugin/Plugin.php:229 plugin/Plugin.php:373
|
533 |
msgid "None"
|
534 |
msgstr ""
|
535 |
|
542 |
msgstr ""
|
543 |
|
544 |
#: plugin/Plugin.php:156
|
545 |
+
msgid "After first block (paragraph or heading)"
|
546 |
msgstr ""
|
547 |
|
548 |
#: plugin/Plugin.php:157
|
621 |
msgid "Transparent"
|
622 |
msgstr ""
|
623 |
|
624 |
+
#: plugin/Plugin.php:247
|
625 |
+
msgid "Inherit from theme"
|
626 |
msgstr ""
|
627 |
|
628 |
#: plugin/Plugin.php:257
|
629 |
+
msgid "As heading (#Example_Heading_Text)"
|
630 |
msgstr ""
|
631 |
|
632 |
+
#: plugin/Plugin.php:258
|
633 |
+
msgid "As heading without transliterate (#Example_Heading_Text)"
|
634 |
+
msgstr ""
|
635 |
+
|
636 |
+
#: plugin/Plugin.php:261
|
637 |
#, php-format
|
638 |
msgid "Counter %s"
|
639 |
msgstr ""
|
640 |
|
641 |
+
#: plugin/Plugin.php:274
|
642 |
msgid "Auto"
|
643 |
msgstr ""
|
644 |
|
645 |
+
#: plugin/Plugin.php:275
|
646 |
msgid "Full Width"
|
647 |
msgstr ""
|
648 |
|
649 |
+
#: plugin/Plugin.php:457
|
650 |
msgid ""
|
651 |
"Creates a table of contents for your posts/pages. Works automatically or "
|
652 |
"manually (via shortcode, Gutenberg block or widget)."
|
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: 1.
|
7 |
Author: LuckyWP
|
8 |
Author URI: https://theluckywp.com/
|
9 |
Text Domain: luckywp-table-of-contents
|
@@ -29,6 +29,6 @@ $lwptocAutoloader->register();
|
|
29 |
$lwptocAutoloader->addNamespace('luckywp\tableOfContents', __DIR__);
|
30 |
|
31 |
$config = require(__DIR__ . '/config/plugin.php');
|
32 |
-
(new \luckywp\tableOfContents\plugin\Plugin($config))->run('1.
|
33 |
|
34 |
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: 1.9
|
7 |
Author: LuckyWP
|
8 |
Author URI: https://theluckywp.com/
|
9 |
Text Domain: luckywp-table-of-contents
|
29 |
$lwptocAutoloader->addNamespace('luckywp\tableOfContents', __DIR__);
|
30 |
|
31 |
$config = require(__DIR__ . '/config/plugin.php');
|
32 |
+
(new \luckywp\tableOfContents\plugin\Plugin($config))->run('1.9', __FILE__, 'lwptoc_');
|
33 |
|
34 |
require_once __DIR__ . '/functions.php';
|
plugin/Plugin.php
CHANGED
@@ -153,7 +153,7 @@ class Plugin extends BasePlugin
|
|
153 |
return [
|
154 |
'beforefirstheading' => esc_html__('Before first heading', 'luckywp-table-of-contents'),
|
155 |
'afterfirstheading' => esc_html__('After first heading', 'luckywp-table-of-contents'),
|
156 |
-
'afterfirstblock' => esc_html__('After first block (paragraph
|
157 |
'top' => esc_html__('Top', 'luckywp-table-of-contents'),
|
158 |
'bottom' => esc_html__('Bottom', 'luckywp-table-of-contents'),
|
159 |
];
|
@@ -244,6 +244,7 @@ class Plugin extends BasePlugin
|
|
244 |
'dark' => esc_html__('Dark Colors', 'luckywp-table-of-contents'),
|
245 |
'white' => esc_html__('White', 'luckywp-table-of-contents'),
|
246 |
'transparent' => esc_html__('Transparent', 'luckywp-table-of-contents'),
|
|
|
247 |
];
|
248 |
}
|
249 |
|
@@ -254,7 +255,7 @@ class Plugin extends BasePlugin
|
|
254 |
{
|
255 |
return [
|
256 |
'asheading' => esc_html__('As heading (#Example_Heading_Text)', 'luckywp-table-of-contents'),
|
257 |
-
'asheadingwotransliterate' => esc_html__('As heading
|
258 |
'counter' => sprintf(
|
259 |
/* translators: %s: (#lwptoc1, #lwptoc2, …) */
|
260 |
esc_html__('Counter %s', 'luckywp-table-of-contents'),
|
@@ -325,6 +326,17 @@ class Plugin extends BasePlugin
|
|
325 |
];
|
326 |
}
|
327 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
/**
|
329 |
* @param string|array $value
|
330 |
* @return array
|
153 |
return [
|
154 |
'beforefirstheading' => esc_html__('Before first heading', 'luckywp-table-of-contents'),
|
155 |
'afterfirstheading' => esc_html__('After first heading', 'luckywp-table-of-contents'),
|
156 |
+
'afterfirstblock' => esc_html__('After first block (paragraph or heading)', 'luckywp-table-of-contents'),
|
157 |
'top' => esc_html__('Top', 'luckywp-table-of-contents'),
|
158 |
'bottom' => esc_html__('Bottom', 'luckywp-table-of-contents'),
|
159 |
];
|
244 |
'dark' => esc_html__('Dark Colors', 'luckywp-table-of-contents'),
|
245 |
'white' => esc_html__('White', 'luckywp-table-of-contents'),
|
246 |
'transparent' => esc_html__('Transparent', 'luckywp-table-of-contents'),
|
247 |
+
'inherit' => esc_html__('Inherit from theme', 'luckywp-table-of-contents'),
|
248 |
];
|
249 |
}
|
250 |
|
255 |
{
|
256 |
return [
|
257 |
'asheading' => esc_html__('As heading (#Example_Heading_Text)', 'luckywp-table-of-contents'),
|
258 |
+
'asheadingwotransliterate' => esc_html__('As heading without transliterate (#Example_Heading_Text)', 'luckywp-table-of-contents'),
|
259 |
'counter' => sprintf(
|
260 |
/* translators: %s: (#lwptoc1, #lwptoc2, …) */
|
261 |
esc_html__('Counter %s', 'luckywp-table-of-contents'),
|
326 |
];
|
327 |
}
|
328 |
|
329 |
+
/**
|
330 |
+
* @return array
|
331 |
+
*/
|
332 |
+
public function getListMarkupTagsList()
|
333 |
+
{
|
334 |
+
return [
|
335 |
+
'div' => 'DIV',
|
336 |
+
'ul' => 'UL/LI',
|
337 |
+
];
|
338 |
+
}
|
339 |
+
|
340 |
/**
|
341 |
* @param string|array $value
|
342 |
* @return array
|
plugin/Settings.php
CHANGED
@@ -431,4 +431,16 @@ class Settings extends \luckywp\tableOfContents\core\wp\Settings
|
|
431 |
$postTypes = array_merge($postTypes, $this->getProcessingHeadingsAlwaysForPostTypes(), $this->getMiscShowMetaboxPostTypes());
|
432 |
return array_unique($postTypes);
|
433 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
}
|
431 |
$postTypes = array_merge($postTypes, $this->getProcessingHeadingsAlwaysForPostTypes(), $this->getMiscShowMetaboxPostTypes());
|
432 |
return array_unique($postTypes);
|
433 |
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* @return string
|
437 |
+
*/
|
438 |
+
public function getListMarkupTags()
|
439 |
+
{
|
440 |
+
$tags = $this->getValue('misc', 'listMarkupTags');
|
441 |
+
if (!array_key_exists($tags, Core::$plugin->getListMarkupTagsList())) {
|
442 |
+
$tags = 'div';
|
443 |
+
}
|
444 |
+
return $tags;
|
445 |
+
}
|
446 |
}
|
plugin/Shortcode.php
CHANGED
@@ -137,7 +137,7 @@ class Shortcode extends BaseObject
|
|
137 |
*/
|
138 |
public function theContent($content)
|
139 |
{
|
140 |
-
if (
|
141 |
return $content;
|
142 |
}
|
143 |
|
137 |
*/
|
138 |
public function theContent($content)
|
139 |
{
|
140 |
+
if (!apply_filters('lwptoc_need_processing_headings', $this->needProcessHeadings($content), $content)) {
|
141 |
return $content;
|
142 |
}
|
143 |
|
plugin/contentHandling/ContentHandling.php
CHANGED
@@ -23,6 +23,10 @@ class ContentHandling
|
|
23 |
static::$headingIds = [];
|
24 |
$result->content = preg_replace_callback('#<h([1-6])(.*?)>(.*?)</h\d>#imsu', function ($m) use ($dto, $result, $skipRegex) {
|
25 |
$label = trim(strip_tags($m[3]));
|
|
|
|
|
|
|
|
|
26 |
$headingId = static::makeHeadingId($label, $dto);
|
27 |
$headingIndex = (int)$m[1];
|
28 |
|
23 |
static::$headingIds = [];
|
24 |
$result->content = preg_replace_callback('#<h([1-6])(.*?)>(.*?)</h\d>#imsu', function ($m) use ($dto, $result, $skipRegex) {
|
25 |
$label = trim(strip_tags($m[3]));
|
26 |
+
if ($label == '') {
|
27 |
+
return $m[0];
|
28 |
+
}
|
29 |
+
|
30 |
$headingId = static::makeHeadingId($label, $dto);
|
31 |
$headingIndex = (int)$m[1];
|
32 |
|
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.2.2
|
7 |
-
Stable tag: 1.
|
8 |
Requires PHP: 5.6.20
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
@@ -28,7 +28,7 @@ Creates SEO-friendly table of contents for your posts, pages or custom post type
|
|
28 |
* Hierarchical or linear view.
|
29 |
* Numeration items: decimal or roman numbers in order or nested.
|
30 |
* Customizable appearance: width, float, title font size and weight, items font size, colors.
|
31 |
-
* Color schemes (dark, light, white, transparent) and the ability to override colors.
|
32 |
* Toggle Show/Hide (optionally)
|
33 |
* Customizable labels.
|
34 |
* Smooth scroll (optionally).
|
@@ -47,7 +47,7 @@ Supported positions:
|
|
47 |
|
48 |
* before first heading;
|
49 |
* after first heading;
|
50 |
-
* after first block (paragraph
|
51 |
* top of post content;
|
52 |
* bottom of post content.
|
53 |
|
@@ -139,6 +139,16 @@ For non-English websites it is recommended to enable the `Intl` PHP extension.
|
|
139 |
|
140 |
== Changelog ==
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
= 1.8 — 2019-07-29 =
|
143 |
+ Added option "Use rel="nofollow" for links"
|
144 |
+ Added compatibility with Rank Math SEO plugin.
|
@@ -238,4 +248,7 @@ For non-English websites it is recommended to enable the `Intl` PHP extension.
|
|
238 |
* Bug fix
|
239 |
|
240 |
= 1.0.1 — 2019-11-15 =
|
241 |
-
* Bug fix
|
|
|
|
|
|
4 |
Tags: table of contents, toc, navigation, links, seo
|
5 |
Requires at least: 4.7
|
6 |
Tested up to: 5.2.2
|
7 |
+
Stable tag: 1.9
|
8 |
Requires PHP: 5.6.20
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
28 |
* Hierarchical or linear view.
|
29 |
* Numeration items: decimal or roman numbers in order or nested.
|
30 |
* Customizable appearance: width, float, title font size and weight, items font size, colors.
|
31 |
+
* Color schemes (dark, light, white, transparent, inherit from theme) and the ability to override colors.
|
32 |
* Toggle Show/Hide (optionally)
|
33 |
* Customizable labels.
|
34 |
* Smooth scroll (optionally).
|
47 |
|
48 |
* before first heading;
|
49 |
* after first heading;
|
50 |
+
* after first block (paragraph or heading);
|
51 |
* top of post content;
|
52 |
* bottom of post content.
|
53 |
|
139 |
|
140 |
== Changelog ==
|
141 |
|
142 |
+
= 1.9 — 2019-08-04 =
|
143 |
+
+ Added special color scheme "Inherit from theme".
|
144 |
+
+ Added option "List Markup Tags".
|
145 |
+
+ Added support Beaver Builder Themer Add-On.
|
146 |
+
+ Implemented automatic removal of empty headings from table of contents.
|
147 |
+
* Automatic insertion of table of contents "after first block" takes into account only paragraphs and headings.
|
148 |
+
* Improved JS code to prevent reinitialization.
|
149 |
+
* Minor changes in strings, fixed typos.
|
150 |
+
* Added tips for translators in code.
|
151 |
+
|
152 |
= 1.8 — 2019-07-29 =
|
153 |
+ Added option "Use rel="nofollow" for links"
|
154 |
+ Added compatibility with Rank Math SEO plugin.
|
248 |
* Bug fix
|
249 |
|
250 |
= 1.0.1 — 2019-11-15 =
|
251 |
+
* Bug fix
|
252 |
+
|
253 |
+
= 1.0.0 — 2018-11-14 =
|
254 |
+
+ Initial release.
|