Version Description
- Added widget "Table of Contents".
- Added support output table of contents via
do_shortcode('[lwptoc]')
. - Enhancements for more compatible with themes.
Download this release
Release Info
Developer | theluckywp |
Plugin | LuckyWP Table of Contents |
Version | 1.4 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.4
- admin/Admin.php +4 -6
- admin/assets/main.min.css +1 -1
- admin/assets/main.min.js +1 -1
- admin/controllers/MetaboxController.php +14 -0
- admin/controllers/WidgetController.php +70 -0
- admin/forms/CustomizeForm.php +8 -2
- admin/widgets/customizeModal/CustomizeModal.php +7 -1
- admin/widgets/customizeModal/views/modal.php +24 -23
- admin/widgets/metabox/views/box.php +36 -6
- admin/widgets/widget/Widget.php +50 -0
- admin/widgets/widget/views/_override.php +23 -0
- admin/widgets/widget/views/form.php +27 -0
- config/settings.php +32 -0
- core/helpers/Json.php +13 -0
- core/helpers/ValueHelper.php +13 -0
- front/Front.php +9 -11
- front/Toc.php +314 -0
- functions.php +4 -3
- languages/lwptoc-ru_RU.mo +0 -0
- languages/lwptoc.pot +202 -163
- luckywp-table-of-contents.php +2 -2
- plugin/Plugin.php +23 -0
- plugin/PostSettings.php +27 -4
- plugin/Settings.php +32 -0
- plugin/Shortcode.php +118 -462
- plugin/WpWidget.php +56 -0
- plugin/contentHandling/ContentHandling.php +97 -0
- plugin/contentHandling/ContentHandlingDto.php +32 -0
- plugin/contentHandling/ContentHandlingResult.php +17 -0
- readme.txt +15 -8
admin/Admin.php
CHANGED
@@ -6,6 +6,7 @@ use luckywp\tableOfContents\admin\controllers\EditorBlockController;
|
|
6 |
use luckywp\tableOfContents\admin\controllers\MetaboxController;
|
7 |
use luckywp\tableOfContents\admin\controllers\SettingsController;
|
8 |
use luckywp\tableOfContents\admin\controllers\ShortcodeController;
|
|
|
9 |
use luckywp\tableOfContents\admin\widgets\metabox\Metabox;
|
10 |
use luckywp\tableOfContents\admin\widgets\OverrideColorBadge;
|
11 |
use luckywp\tableOfContents\core\admin\helpers\AdminUrl;
|
@@ -37,6 +38,7 @@ class Admin extends BaseObject
|
|
37 |
MetaboxController::getInstance();
|
38 |
ShortcodeController::getInstance();
|
39 |
EditorBlockController::getInstance();
|
|
|
40 |
}
|
41 |
}
|
42 |
|
@@ -57,11 +59,7 @@ class Admin extends BaseObject
|
|
57 |
*/
|
58 |
public function getMetaboxPostTypes()
|
59 |
{
|
60 |
-
|
61 |
-
$postTypes = Core::$plugin->settings->autoInsertPostTypes) {
|
62 |
-
return $postTypes;
|
63 |
-
}
|
64 |
-
return [];
|
65 |
}
|
66 |
|
67 |
public function addMetaBoxes()
|
@@ -85,7 +83,7 @@ class Admin extends BaseObject
|
|
85 |
public function assets($hook)
|
86 |
{
|
87 |
global $post;
|
88 |
-
if (in_array($hook, [$this->pageSettingsHook, 'post.php', 'post-new.php'])) {
|
89 |
wp_enqueue_style('wp-color-picker');
|
90 |
wp_enqueue_script('wp-color-picker');
|
91 |
}
|
6 |
use luckywp\tableOfContents\admin\controllers\MetaboxController;
|
7 |
use luckywp\tableOfContents\admin\controllers\SettingsController;
|
8 |
use luckywp\tableOfContents\admin\controllers\ShortcodeController;
|
9 |
+
use luckywp\tableOfContents\admin\controllers\WidgetController;
|
10 |
use luckywp\tableOfContents\admin\widgets\metabox\Metabox;
|
11 |
use luckywp\tableOfContents\admin\widgets\OverrideColorBadge;
|
12 |
use luckywp\tableOfContents\core\admin\helpers\AdminUrl;
|
38 |
MetaboxController::getInstance();
|
39 |
ShortcodeController::getInstance();
|
40 |
EditorBlockController::getInstance();
|
41 |
+
WidgetController::getInstance();
|
42 |
}
|
43 |
}
|
44 |
|
59 |
*/
|
60 |
public function getMetaboxPostTypes()
|
61 |
{
|
62 |
+
return Core::$plugin->settings->getPostTypesForProcessingHeadings();
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
|
65 |
public function addMetaBoxes()
|
83 |
public function assets($hook)
|
84 |
{
|
85 |
global $post;
|
86 |
+
if (in_array($hook, [$this->pageSettingsHook, 'post.php', 'post-new.php', 'widgets.php', 'settings_page_lwptoc_settings'])) {
|
87 |
wp_enqueue_style('wp-color-picker');
|
88 |
wp_enqueue_script('wp-color-picker');
|
89 |
}
|
admin/assets/main.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
@keyframes lwptocLightSpinnerKeyFrames{0%,100%,20%,80%{transform:scale(.7)}50%{transform:scale(1.5)}}.lwptocLightSpinner{display:inline-block;position:relative;width:64px;height:64px}.lwptocLightSpinner div{position:absolute;width:5px;height:5px;background:#fff;border-radius:50%;animation:lwptocLightSpinnerKeyFrames 1.2s linear infinite}.lwptocLightSpinner div:nth-child(1){animation-delay:0s;top:29px;left:53px}.lwptocLightSpinner div:nth-child(2){animation-delay:-.1s;top:18px;left:50px}.lwptocLightSpinner div:nth-child(3){animation-delay:-.2s;top:9px;left:41px}.lwptocLightSpinner div:nth-child(4){animation-delay:-.3s;top:6px;left:29px}.lwptocLightSpinner div:nth-child(5){animation-delay:-.4s;top:9px;left:18px}.lwptocLightSpinner div:nth-child(6){animation-delay:-.5s;top:18px;left:9px}.lwptocLightSpinner div:nth-child(7){animation-delay:-.6s;top:29px;left:6px}.lwptocLightSpinner div:nth-child(8){animation-delay:-.7s;top:41px;left:9px}.lwptocLightSpinner div:nth-child(9){animation-delay:-.8s;top:50px;left:18px}.lwptocLightSpinner div:nth-child(10){animation-delay:-.9s;top:53px;left:29px}.lwptocLightSpinner div:nth-child(11){animation-delay:-1s;top:50px;left:41px}.lwptocLightSpinner div:nth-child(12){animation-delay:-1.1s;top:41px;left:50px}@keyframes lwptocDarkSpinnerKeyFrames{0%,100%,20%,80%{transform:scale(.7)}50%{transform:scale(1.5)}}.lwptocDarkSpinner{display:inline-block;position:relative;width:64px;height:64px}.lwptocDarkSpinner div{position:absolute;width:5px;height:5px;background:#aaa;border-radius:50%;animation:lwptocDarkSpinnerKeyFrames 1.2s linear infinite}.lwptocDarkSpinner div:nth-child(1){animation-delay:0s;top:29px;left:53px}.lwptocDarkSpinner div:nth-child(2){animation-delay:-.1s;top:18px;left:50px}.lwptocDarkSpinner div:nth-child(3){animation-delay:-.2s;top:9px;left:41px}.lwptocDarkSpinner div:nth-child(4){animation-delay:-.3s;top:6px;left:29px}.lwptocDarkSpinner div:nth-child(5){animation-delay:-.4s;top:9px;left:18px}.lwptocDarkSpinner div:nth-child(6){animation-delay:-.5s;top:18px;left:9px}.lwptocDarkSpinner div:nth-child(7){animation-delay:-.6s;top:29px;left:6px}.lwptocDarkSpinner div:nth-child(8){animation-delay:-.7s;top:41px;left:9px}.lwptocDarkSpinner div:nth-child(9){animation-delay:-.8s;top:50px;left:18px}.lwptocDarkSpinner div:nth-child(10){animation-delay:-.9s;top:53px;left:29px}.lwptocDarkSpinner div:nth-child(11){animation-delay:-1s;top:50px;left:41px}.lwptocDarkSpinner div:nth-child(12){animation-delay:-1.1s;top:41px;left:50px}.lwptocPreloaderWrapper{position:relative!important}.lwptocPreloaderOverlay{position:absolute;top:0;left:0;width:100%;height:100%;z-index:50;background:rgba(255,255,255,.7)}.lwptocPreloaderOverlay>DIV{position:absolute;top:50%;left:50%;margin-left:-32px;margin-top:-32px}.lwptocModal-container,.lwptocModal-overlay{position:fixed;left:0;top:0;right:0;bottom:0;z-index:1000}.lwptocModal-container{overflow:auto}.lwptocModal-container_i{display:table;height:100%;margin:0 auto}.lwptocModal-container_i2{display:table-cell;padding:24px}.lwptocModal-error{padding:20px;border-radius:10px;background:#000;color:#fff}.lwptocModal-preloader{width:80px;height:80px;border-radius:10px;background:#000 url(preloader.gif) no-repeat 50% 50%}.lwptocModalBox{position:relative;width:500px;background:#fff;color:#000;box-shadow:0 3px 6px rgba(0,0,0,.3)}.lwptocModalBox_close{position:absolute;top:4px;right:8px;color:#666;text-align:center;line-height:29px;width:29px;height:29px;cursor:pointer}.lwptocModalBox_close:before{content:'\f158';font:normal 20px/29px dashicons}.lwptocModalBox_close:hover{color:#00a0d2}.lwptocModalBox_title{background:#fcfcfc;border-bottom:1px solid #dfdfdf;font-weight:600;font-size:13px;line-height:19px;padding:8px 29px 10px 18px}.lwptocModalBox_body{padding:18px 18px 22px 18px}.lwptocModalBox_footer{padding:18px;border-top:1px solid #dfdfdf}.lwptocModalBox_footer_buttons{text-align:right}.lwptocModalBox_footer_buttons .button{margin-left:4px}.lwptocModalBox_footer_buttons .button:first-child{margin-left:0}.lwptocModalBox_footer_buttons:after{content:".";display:block;height:0;font-size:0;line-height:0;clear:both;visibility:hidden}.lwptocMetabox P{padding:0;margin:12px 0 0!important}.lwptocMetabox P:first-child{margin-top:0}.lwptocMetabox .button-link{margin-left:12px}.lwptocMetabox_settings{margin:6px 0 18px;padding:6px 0 6px 4px;box-shadow:-2px 0 0 #fafafa,-4px 0 0 #ddd,4px 0 0 #fafafa;background:#fafafa}.lwptocMetabox_settings_item{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-top:4px}.lwptocMetabox_settings_item:first-child{margin-top:0}.lwptocMetabox_settings_item B{font-weight:400;color:#888}.lwptocMetabox_settings_item .lwptocColorBadge B{position:relative;top:1px;margin-left:2px}.lwptocCustomize .lwptocModalBox_body{padding:0 0 22px}.lwptocCustomize_errors{margin:14px;border-left:2px solid red;background:#fff4f6;padding:4px 12px 6px;color:red}.lwptocCustomize_errors P{margin:2px 0 0 0}.lwptocCustomize_errors P:first-child{margin-top:0}.lwptocCustomize_tabs{padding:0 14px;margin-top:12px;background:#f1f1f1}.lwptocCustomize_tabs:after{content:".";display:block;height:0;font-size:0;line-height:0;clear:both;visibility:hidden}.lwptocCustomize_tab{float:left;white-space:nowrap;padding:6px 12px 7px;cursor:pointer}.lwptocCustomize_tab:hover{background:#ddd}.lwptocCustomize_tab-active{background:#0073aa!important;color:#fff;cursor:default}.lwptocCustomize_fields{display:none;padding:16px 18px 0}.lwptocCustomize_field{position:relative;margin-top:12px}.lwptocCustomize_field:first-child{margin-top:0}.lwptocCustomize_field_label{font-weight:700}.lwptocCustomize_field_default{float:right;margin-left:4px;cursor:pointer;color:#0073aa;border-bottom:1px dotted #0073aa}.lwptocCustomize_field_default:hover{color:#00a0d2;border-color:#00a0d2}.lwptocCustomize_field_override{display:none;position:absolute;left:-4px;top:-4px;right:-4px;bottom:-4px;background:rgba(42,150,204,.8);color:#fff;font-size:16px;font-weight:700;text-align:center;padding-top:12px;cursor:pointer;-webkit-transition:.1s linear;-moz-transition:.1s linear;-o-transition:.1s linear;transition:.1s linear;opacity:0}.lwptocCustomize_field_defaultValue{display:none;font-size:16px;line-height:20px;font-style:italic;color:#aaa}.lwptocCustomize_field_el{margin-top:4px}.lwptocCustomize_field_el_select,.lwptocCustomize_field_el_textInput{width:100%}.lwptocCustomize_field_desc{margin-top:2px;font-size:90%;color:#888}.lwptocCustomize_field-default .lwptocCustomize_field_default,.lwptocCustomize_field-default .lwptocCustomize_field_el{display:none}.lwptocCustomize_field-default .lwptocCustomize_field_defaultValue,.lwptocCustomize_field-default .lwptocCustomize_field_override{display:block}.lwptocCustomize_field-default .lwptocCustomize_field_desc{margin-top:0}.lwptocCustomize_field-default:hover .lwptocCustomize_field_override{opacity:1}.lwptocWidthField_custom{display:inline}.lwptocWidthField_sizeInput{vertical-align:top;width:64px;padding-bottom:4px;text-align:center}.lwptocWidthField_unitInput{vertical-align:top}.lwptocFontSizeField_custom{display:inline}.lwptocFontSizeField_sizeInput{vertical-align:top;width:64px;padding-bottom:4px;text-align:center}.lwptocFontSizeField_unitInput{vertical-align:top}.lwptocSkipHeadingLevelField LABEL{margin-right:12px}.lwptocModalSuccess{text-align:center;cursor:default;color:#8bc34a}.lwptocModalSuccess_ico{font-family:dashicons;font-size:160px;line-height:124px}.lwptocModalSuccess_text{color:#fff;font-size:24px;line-height:30px}.lwptocColorBadge B{display:inline-block;margin-right:4px;width:12px;height:12px;border-radius:6px}.lwptocFloatLeft{float:left}.lwptocEditorBlock{display:block;padding:12px 16px 13px;border:2px dashed #ddd;background:#fff;color:#333;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif}.lwptocEditorBlock_title{font-size:14px;line-height:18px;font-weight:700}.lwptocEditorBlock_title-loading{color:#aaa}.lwptocEditorBlock_items{margin-top:4px;font-size:12px;line-height:16px}.lwptocEditorBlock_item{margin-top:2px}.lwptocEditorBlock_item:first-child{margin-top:0}.lwptocEditorBlock_item_label{color:#888}.lwptocEditorBlock .lwptocColorBadge B{position:relative;top:1px;margin-left:2px}.mce-i-lwptocButton:before{font:400 20px/1 dashicons;content:"\f163"}
|
1 |
+
@keyframes lwptocLightSpinnerKeyFrames{0%,100%,20%,80%{transform:scale(.7)}50%{transform:scale(1.5)}}.lwptocLightSpinner{display:inline-block;position:relative;width:64px;height:64px}.lwptocLightSpinner div{position:absolute;width:5px;height:5px;background:#fff;border-radius:50%;animation:lwptocLightSpinnerKeyFrames 1.2s linear infinite}.lwptocLightSpinner div:nth-child(1){animation-delay:0s;top:29px;left:53px}.lwptocLightSpinner div:nth-child(2){animation-delay:-.1s;top:18px;left:50px}.lwptocLightSpinner div:nth-child(3){animation-delay:-.2s;top:9px;left:41px}.lwptocLightSpinner div:nth-child(4){animation-delay:-.3s;top:6px;left:29px}.lwptocLightSpinner div:nth-child(5){animation-delay:-.4s;top:9px;left:18px}.lwptocLightSpinner div:nth-child(6){animation-delay:-.5s;top:18px;left:9px}.lwptocLightSpinner div:nth-child(7){animation-delay:-.6s;top:29px;left:6px}.lwptocLightSpinner div:nth-child(8){animation-delay:-.7s;top:41px;left:9px}.lwptocLightSpinner div:nth-child(9){animation-delay:-.8s;top:50px;left:18px}.lwptocLightSpinner div:nth-child(10){animation-delay:-.9s;top:53px;left:29px}.lwptocLightSpinner div:nth-child(11){animation-delay:-1s;top:50px;left:41px}.lwptocLightSpinner div:nth-child(12){animation-delay:-1.1s;top:41px;left:50px}@keyframes lwptocDarkSpinnerKeyFrames{0%,100%,20%,80%{transform:scale(.7)}50%{transform:scale(1.5)}}.lwptocDarkSpinner{display:inline-block;position:relative;width:64px;height:64px}.lwptocDarkSpinner div{position:absolute;width:5px;height:5px;background:#aaa;border-radius:50%;animation:lwptocDarkSpinnerKeyFrames 1.2s linear infinite}.lwptocDarkSpinner div:nth-child(1){animation-delay:0s;top:29px;left:53px}.lwptocDarkSpinner div:nth-child(2){animation-delay:-.1s;top:18px;left:50px}.lwptocDarkSpinner div:nth-child(3){animation-delay:-.2s;top:9px;left:41px}.lwptocDarkSpinner div:nth-child(4){animation-delay:-.3s;top:6px;left:29px}.lwptocDarkSpinner div:nth-child(5){animation-delay:-.4s;top:9px;left:18px}.lwptocDarkSpinner div:nth-child(6){animation-delay:-.5s;top:18px;left:9px}.lwptocDarkSpinner div:nth-child(7){animation-delay:-.6s;top:29px;left:6px}.lwptocDarkSpinner div:nth-child(8){animation-delay:-.7s;top:41px;left:9px}.lwptocDarkSpinner div:nth-child(9){animation-delay:-.8s;top:50px;left:18px}.lwptocDarkSpinner div:nth-child(10){animation-delay:-.9s;top:53px;left:29px}.lwptocDarkSpinner div:nth-child(11){animation-delay:-1s;top:50px;left:41px}.lwptocDarkSpinner div:nth-child(12){animation-delay:-1.1s;top:41px;left:50px}.lwptocPreloaderWrapper{position:relative!important}.lwptocPreloaderOverlay{position:absolute;top:0;left:0;width:100%;height:100%;z-index:50;background:rgba(255,255,255,.7)}.lwptocPreloaderOverlay>DIV{position:absolute;top:50%;left:50%;margin-left:-32px;margin-top:-32px}.lwptocModal-container,.lwptocModal-overlay{position:fixed;left:0;top:0;right:0;bottom:0;z-index:1000}.lwptocModal-container{overflow:auto}.lwptocModal-container_i{display:table;height:100%;margin:0 auto}.lwptocModal-container_i2{display:table-cell;padding:24px}.lwptocModal-error{padding:20px;border-radius:10px;background:#000;color:#fff}.lwptocModal-preloader{width:80px;height:80px;border-radius:10px;background:#000 url(preloader.gif) no-repeat 50% 50%}.lwptocModalBox{position:relative;width:500px;background:#fff;color:#000;box-shadow:0 3px 6px rgba(0,0,0,.3)}.lwptocModalBox_close{position:absolute;top:4px;right:8px;color:#666;text-align:center;line-height:29px;width:29px;height:29px;cursor:pointer}.lwptocModalBox_close:before{content:'\f158';font:normal 20px/29px dashicons}.lwptocModalBox_close:hover{color:#00a0d2}.lwptocModalBox_title{background:#fcfcfc;border-bottom:1px solid #dfdfdf;font-weight:600;font-size:13px;line-height:19px;padding:8px 29px 10px 18px}.lwptocModalBox_body{padding:18px 18px 22px 18px}.lwptocModalBox_footer{padding:18px;border-top:1px solid #dfdfdf}.lwptocModalBox_footer_buttons{text-align:right}.lwptocModalBox_footer_buttons .button{margin-left:4px}.lwptocModalBox_footer_buttons .button:first-child{margin-left:0}.lwptocModalBox_footer_buttons:after{content:".";display:block;height:0;font-size:0;line-height:0;clear:both;visibility:hidden}.lwptocMetabox P{padding:0;margin:12px 0 0!important}.lwptocMetabox P:first-child{margin-top:0}.lwptocMetabox .button-link{margin-left:12px}.lwptocMetabox_settings{margin:6px 0 18px;padding:6px 0 6px 4px;box-shadow:-2px 0 0 #fafafa,-4px 0 0 #ddd,4px 0 0 #fafafa;background:#fafafa}.lwptocMetabox_settings_item{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-top:4px}.lwptocMetabox_settings_item:first-child{margin-top:0}.lwptocMetabox_settings_item B{font-weight:400;color:#888}.lwptocMetabox_settings_item .lwptocColorBadge B{position:relative;top:1px;margin-left:2px}.lwptocWidget{padding-bottom:12px}.lwptocWidget P{padding:0;margin:12px 0 0!important}.lwptocWidget P:first-child{margin-top:0}.lwptocWidget_settings{margin:6px 0 18px;padding:6px 0 6px 4px;box-shadow:-2px 0 0 #fafafa,-4px 0 0 #ddd,4px 0 0 #fafafa;background:#fafafa}.lwptocWidget_settings_item{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-top:4px}.lwptocWidget_settings_item:first-child{margin-top:0}.lwptocWidget_settings_item B{font-weight:400;color:#888}.lwptocWidget_settings_item .lwptocColorBadge B{position:relative;top:1px;margin-left:2px}.lwptocCustomize .lwptocModalBox_body{padding:0 0 22px}.lwptocCustomize_errors{margin:14px;border-left:2px solid red;background:#fff4f6;padding:4px 12px 6px;color:red}.lwptocCustomize_errors P{margin:2px 0 0 0}.lwptocCustomize_errors P:first-child{margin-top:0}.lwptocCustomize_tabs{padding:0 14px;margin-top:12px;background:#f1f1f1}.lwptocCustomize_tabs:after{content:".";display:block;height:0;font-size:0;line-height:0;clear:both;visibility:hidden}.lwptocCustomize_tab{float:left;white-space:nowrap;padding:6px 12px 7px;cursor:pointer}.lwptocCustomize_tab:hover{background:#ddd}.lwptocCustomize_tab-active{background:#0073aa!important;color:#fff;cursor:default}.lwptocCustomize_fields{display:none;padding:16px 18px 0}.lwptocCustomize_field{position:relative;margin-top:12px}.lwptocCustomize_field:first-child{margin-top:0}.lwptocCustomize_field_label{font-weight:700}.lwptocCustomize_field_default{float:right;margin-left:4px;cursor:pointer;color:#0073aa;border-bottom:1px dotted #0073aa}.lwptocCustomize_field_default:hover{color:#00a0d2;border-color:#00a0d2}.lwptocCustomize_field_override{display:none;position:absolute;left:-4px;top:-4px;right:-4px;bottom:-4px;background:rgba(42,150,204,.8);color:#fff;font-size:16px;font-weight:700;text-align:center;padding-top:12px;cursor:pointer;-webkit-transition:.1s linear;-moz-transition:.1s linear;-o-transition:.1s linear;transition:.1s linear;opacity:0}.lwptocCustomize_field_defaultValue{display:none;font-size:16px;line-height:20px;font-style:italic;color:#aaa}.lwptocCustomize_field_el{margin-top:4px}.lwptocCustomize_field_el_select,.lwptocCustomize_field_el_textInput{width:100%}.lwptocCustomize_field_desc{margin-top:2px;font-size:90%;color:#888}.lwptocCustomize_field-default .lwptocCustomize_field_default,.lwptocCustomize_field-default .lwptocCustomize_field_el{display:none}.lwptocCustomize_field-default .lwptocCustomize_field_defaultValue,.lwptocCustomize_field-default .lwptocCustomize_field_override{display:block}.lwptocCustomize_field-default .lwptocCustomize_field_desc{margin-top:0}.lwptocCustomize_field-default:hover .lwptocCustomize_field_override{opacity:1}.lwptocWidthField_custom{display:inline}.lwptocWidthField_sizeInput{vertical-align:top;width:64px;padding-bottom:4px;text-align:center}.lwptocWidthField_unitInput{vertical-align:top}.lwptocFontSizeField_custom{display:inline}.lwptocFontSizeField_sizeInput{vertical-align:top;width:64px;padding-bottom:4px;text-align:center}.lwptocFontSizeField_unitInput{vertical-align:top}.lwptocSkipHeadingLevelField LABEL{margin-right:12px}.lwptocModalSuccess{text-align:center;cursor:default;color:#8bc34a}.lwptocModalSuccess_ico{font-family:dashicons;font-size:160px;line-height:124px}.lwptocModalSuccess_text{color:#fff;font-size:24px;line-height:30px}.lwptocColorBadge B{display:inline-block;margin-right:4px;width:12px;height:12px;border-radius:6px}.lwptocFloatLeft{float:left}.lwptocEditorBlock{display:block;padding:12px 16px 13px;border:2px dashed #ddd;background:#fff;color:#333;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif}.lwptocEditorBlock_title{font-size:14px;line-height:18px;font-weight:700}.lwptocEditorBlock_title-loading{color:#aaa}.lwptocEditorBlock_items{margin-top:4px;font-size:12px;line-height:16px}.lwptocEditorBlock_item{margin-top:2px}.lwptocEditorBlock_item:first-child{margin-top:0}.lwptocEditorBlock_item_label{color:#888}.lwptocEditorBlock .lwptocColorBadge B{position:relative;top:1px;margin-left:2px}.mce-i-lwptocButton:before{font:400 20px/1 dashicons;content:"\f163"}
|
admin/assets/main.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t,e){var o="lwptocPreloader";t.fn[o+"Show"]=function(){var e=t(this);e.addClass(o+"Wrapper"),e.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>')},t.fn[o+"Hide"]=function(){var e=t(this);e.removeClass(o+"Wrapper"),e.find("."+o+"Overlay").remove()}}(jQuery),function(r,e){var l="lwptocModal",t={type:"html",content:"",url:"",ajax:{},ajaxRequest:null,closeOnEsc:!0,closeOnOverlayClick:!0,clone:!1,overlay:{block:void 0,tpl:'<div class="'+l+'-overlay"></div>',css:{backgroundColor:"#000",opacity:.6,zIndex:1e5}},container:{block:void 0,tpl:'<div class="'+l+'-container"><div class="'+l+'-container_i"><div class="'+l+'-container_i2"></div></div></div>'},preloader:{verticalAlign:void 0,tpl:'<div class="'+l+'-preloader" />'},wrap:void 0,body:void 0,errors:{tpl:'<div class="'+l+"-error "+l+'-close"></div>',autocloseDelay:2e3,ajaxUnsuccessfulLoad:"Error"},openEffect:{type:"fade",speed:400},closeEffect:{type:"fade",speed:400},width:"auto",verticalAlign:"middle",beforeOpen:r.noop,afterOpen:r.noop,beforeClose:r.noop,afterClose:r.noop,afterLoading:r.noop,afterLoadingOnShow:r.noop,errorLoading:r.noop},d=0,s=r([]),u=function(e,t){var o=!0;return r(e).each(function(){r(t.target).get(0)==r(this).get(0)&&(o=!1),0==r(t.target).closest("HTML",r(this).get(0)).length&&(o=!1)}),o},i={getParentEl:function(e){var t=r(e);return t.data(l)?t:(t=r(e).closest("."+l+"-container").data(l+"ParentEl"))||!1},transition:function(e,t,o,n){switch(n=null==n?r.noop:n,o.type){case"fade":"show"==t?e.fadeIn(o.speed,n):e.fadeOut(o.speed,n);break;case"none":"show"==t?e.show():e.hide(),n()}},setWrapMarginRight:function(e,t){e.wrap.css("marginRight",t+"px"),r(document).trigger(l+"_setWrapMarginRight",t)},initEl:function(t,e){var o=t.data(l);if(!o){if(d++,(o=e).modalID=d,o.overlay.block=r(o.overlay.tpl),o.overlay.block.css(o.overlay.css),o.container.block=r(o.container.tpl),o.body=r("."+l+"-container_i2",o.container.block),e.clone?o.body.html(t.clone(!0)):(t.before('<div id="'+l+"Reserve"+o.modalID+'" style="display: none" />'),o.body.html(t)),o.body.on("click","."+l+"-close",function(){return t[l]("close"),!1}),o.closeOnOverlayClick&&o.overlay.block.add(o.container.block).click(function(e){u(r(">*",o.body),e)&&t[l]("close")}),o.container.block.data(l+"ParentEl",t),t.data(l,o),s=r.merge(s,t),r.proxy(p.show,t)(),"html"==o.type)return t;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=r.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,t)},success:function(e){t.trigger("afterLoading."+l),e=o.afterLoading(o,t,e)||e,o.body.css("verticalAlign",o.verticalAlign),null==i?o.body.html(e):i(o,t,e),t.trigger("afterLoadingOnShow."+l),o.afterLoadingOnShow(o,t,e)},error:function(){t.trigger("errorLoading."+l),o.errorLoading(o,t),null==a?(o.body.html(o.errors.tpl),r("."+l+"-error",o.body).html(o.errors.ajaxUnsuccessfulLoad),r("."+l+"-close",o.body).click(function(){return t[l]("close"),!1}),o.errors.autocloseDelay&&setTimeout(function(){t[l]("close")},o.errors.autocloseDelay)):a(o,t)}},o.ajax);o.ajaxRequest=r.ajax(c),t.data(l,o)}},init:function(e){return e=r.extend(!0,{},t,e),r.isFunction(this)?null==e?void r.error(l+": Uncorrect parameters"):""!=e.url?(e.type="ajax",i.initEl(r("<div />"),e)):""!=e.content?(e.type="html",i.initEl(r(e.content),e)):void r.error(l+': Set parameter "url" or "content"'):this.each(function(){i.initEl(r(this),r.extend(!0,{},e))})}},p={show:function(){var e=i.getParentEl(this);if(!1!==e){var t=e.data(l);if(t.overlay.block.hide(),t.container.block.hide(),r("BODY").append(t.overlay.block),r("BODY").append(t.container.block),t.container.block.css("zIndex",t.overlay.block.css("zIndex")),t.beforeOpen(t,e),e.trigger("beforeOpen."+l),"hidden"!=t.wrap.css("overflow-y")){t.wrap.data(l+"Overflow",t.wrap.css("overflow-y"));var o=t.wrap.outerWidth(!0);t.wrap.css("overflow-y","hidden");var n=t.wrap.outerWidth(!0);n!=o&&i.setWrapMarginRight(t,n-o)}return s.not(e).each(function(){r(this).data(l).overlay.block.hide()}),t.body.css("verticalAlign",t.verticalAlign),t.body.parent().css("width",t.width),i.transition(t.overlay.block,"show",1<s.length?{type:"none"}:t.openEffect),i.transition(t.container.block,"show",1<s.length?{type:"none"}:t.openEffect,function(){t.afterOpen(t,e),e.trigger("afterOpen."+l)}),e}r.error(l+": Uncorrect call")},close:function(){if(!r.isFunction(this))return this.each(function(){var e=i.getParentEl(this);if(!1!==e){var t=e.data(l);!1!==t.beforeClose(t,e)&&(e.trigger("beforeClose."+l),s.not(e).last().each(function(){r(this).data(l).overlay.block.show()}),i.transition(t.overlay.block,"hide",1<s.length?{type:"none"}:t.closeEffect),i.transition(t.container.block,"hide",1<s.length?{type:"none"}:t.closeEffect,function(){t.afterClose(t,e),e.trigger("afterClose."+l),t.clone||r("#"+l+"Reserve"+t.modalID).replaceWith(t.body.find(">*")),t.overlay.block.remove(),t.container.block.remove(),e.data(l,null),r("."+l+"-container").length||(t.wrap.data(l+"Overflow")&&t.wrap.css("overflow-y",t.wrap.data(l+"Overflow")),i.setWrapMarginRight(t,0))}),"ajax"==t.type&&t.ajaxRequest.abort(),s=s.not(e))}else r.error(l+": Uncorrect call")});s.each(function(){r(this)[l]("close")})},getActive:function(){var e=r("."+l+"-container").last();return!!e.length&&e.data(l+"ParentEl").data(l)},setDefault:function(e){r.extend(!0,t,e)}};r(function(){t.wrap=r(document.all&&!document.querySelector?"html":"body")}),r(document).bind("keyup."+l,function(e){var t=s.last();t.length&&(t.data(l).closeOnEsc&&27===e.keyCode&&t[l]("close"))}),r[l]=r.fn[l]=function(e){return p[e]?p[e].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof e&&e?void r.error(l+": Method "+e+" does not exist"):i.init.apply(this,arguments)}}(jQuery),function(n,e){var i="lwptocAjaxForm",t={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(e){return"form"==e.get(0).tagName.toLowerCase()},makeData:function(e){return a.isForm(e)?e.serialize():(t=e.clone().wrap("<form/>"),e.find("select").each(function(e){t.find("select").eq(e).val(n(this).val())}),t.serialize());var t},submit:function(e,t){n.ajax({type:"POST",cache:!1,data:a.makeData(e),url:a.isForm(e)?e.attr("action"):e.data("action"),beforeSend:function(){t.beforeSend(t,e)},success:function(e){t.b.container.html(e),t.success(t)},error:function(){t.error(t,e)}})},initContainer:function(e,t){var o=e.data(i);o||(o=t,e.data(i,o),(o.b.container=e).on("submit","[data-ajax-form]",function(){return a.submit(n(this),o),!1}),o.afterInit(o))},init:function(e){return e=n.extend(!0,{},t,e),n.isFunction(this)?(n.error(i+": Uncorrect call"),!1):this.each(function(){a.initContainer(n(this),n.extend(!0,{},e))})}},o={setDefault:function(e){n.extend(!0,t,e)}};n[i]=n.fn[i]=function(e){return o[e]?o[e].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof e&&e?(n.error(i+": Method "+e+" does not exist"),!1):a.init.apply(this,arguments)}}(jQuery),function(r){r.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}}}),r(function(){var e=r(".js-lwptocSmoothScrollCheckbox");if(e.length){var t=r(".js-lwptocSmoothScrollIOffsetInput").closest("TR");e.change(function(){e.prop("checked")?t.show():t.hide()}).change()}var o=r(".js-lwptocToggleCheckbox");if(o.length){var n=r(".js-lwptocToggleEl").closest("TR");o.change(function(){o.prop("checked")?n.show():n.hide()}).change()}var i=r(".js-lwptocAutoInsertEnableCheckbox");if(i.length){var a=r(".js-lwptocAutoInsertEl").closest("TR");i.change(function(){i.prop("checked")?a.show():a.hide()}).change()}var c=r(".lwptoc_colorPicker");c.length&&c.wpColorPicker()}),r.lwptocCustomize={init:function(t,o){n.init(t.find(".lwptocWidthField")),i.init(t.find(".lwptocFontSizeField")),t.find(".lwptoc_colorPicker").wpColorPicker(),t.on("click",".lwptocCustomize_field_override",function(){var e=r(this).closest(".lwptocCustomize_field");e.removeClass("lwptocCustomize_field-default"),e.find("INPUT[type=text]").focus(),e.find(".lwptocCustomize_field_inputDefault").val(0)}),t.on("click",".lwptocCustomize_field_default",function(){var e=r(this).closest(".lwptocCustomize_field");e.addClass("lwptocCustomize_field-default"),e.find(".lwptocCustomize_field_inputDefault").val(1)}),t.on("click",".lwptocCustomize_tab",function(){t.find(".lwptocCustomize_tab-active").removeClass("lwptocCustomize_tab-active"),r(this).addClass("lwptocCustomize_tab-active"),t.find(".lwptocCustomize_fields").hide(),t.find(".lwptocCustomize_fields-"+r(this).data("tab")).show()}),t.lwptocAjaxForm({beforeSend:function(){t.lwptocPreloaderShow()},success:function(e){t.lwptocPreloaderHide(),o()}})},show:function(e,t){e._ajax_nonce=lwptocMain.nonce,r.lwptocModal({url:lwptocMain.ajaxUrl,closeOnOverlayClick:!1,verticalAlign:"top",ajax:{data:e},afterLoadingOnShow:function(e){r.lwptocCustomize.init(e.body.find(".lwptocCustomize"),function(){e.body.lwptocModal("close")})},afterClose:t})}};var o={reload:function(e){var t=r(e);o.$container.replaceWith(t),o.init(t)},setEnabled:function(e){r.ajax({url:lwptocMain.ajaxUrl,data:{_ajax_nonce:lwptocMain.nonce,action:"lwptoc_metabox_set_enabled",postId:o.$container.data("postId"),enabled:e?1:0},beforeSend:function(){o.$container.lwptocPreloaderShow()},success:function(e){o.$container.lwptocPreloaderHide(),o.reload(e)}})},init:function(){o.$container=r(".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_customize").click(function(){r.lwptocCustomize.show({action:"lwptoc_metabox_customize",postId:o.$container.data("postId")},r.noop)}),r(document).on("lwptocMetaboxCustomized",function(e,t){r(".lwptocCustomize-metabox").lwptocModal("close"),o.reload(t.metabox)}))}};r(function(){o.init()});var n={update:function(e){"custom"==e.$typeInput.val()?(e.$input.val(e.$sizeInput.val()+e.$unitInput.val()),e.$custom.show()):(e.$input.val(e.$typeInput.val()),e.$custom.hide())},init:function(e){e.each(function(){var e={$container:r(this)};e.$typeInput=e.$container.find(".lwptocWidthField_typeInput"),e.$sizeInput=e.$container.find(".lwptocWidthField_sizeInput"),e.$unitInput=e.$container.find(".lwptocWidthField_unitInput"),e.$input=e.$container.find(".lwptocWidthField_input"),e.$custom=e.$container.find(".lwptocWidthField_custom"),e.$typeInput.add(e.$sizeInput).add(e.$unitInput).change(function(){n.update(e)})})}};r(function(){n.init(r(".lwptocWidthField"))});var i={update:function(e){"custom"==e.$typeInput.val()?(e.$input.val(e.$sizeInput.val()+e.$unitInput.val()),e.$custom.show()):(e.$input.val(e.$typeInput.val()),e.$custom.hide())},init:function(e){e.each(function(){var e={$container:r(this)};e.$typeInput=e.$container.find(".lwptocFontSizeField_typeInput"),e.$sizeInput=e.$container.find(".lwptocFontSizeField_sizeInput"),e.$unitInput=e.$container.find(".lwptocFontSizeField_unitInput"),e.$input=e.$container.find(".lwptocFontSizeField_input"),e.$custom=e.$container.find(".lwptocFontSizeField_custom"),e.$typeInput.add(e.$sizeInput).add(e.$unitInput).change(function(){i.update(e)})})}};r(function(){i.init(r(".lwptocFontSizeField"))})}(jQuery);
|
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(r,t){var l="lwptocModal",e={type:"html",content:"",url:"",ajax:{},ajaxRequest:null,closeOnEsc:!0,closeOnOverlayClick:!0,clone:!1,overlay:{block:void 0,tpl:'<div class="'+l+'-overlay"></div>',css:{backgroundColor:"#000",opacity:.6,zIndex:1e5}},container:{block:void 0,tpl:'<div class="'+l+'-container"><div class="'+l+'-container_i"><div class="'+l+'-container_i2"></div></div></div>'},preloader:{verticalAlign:void 0,tpl:'<div class="'+l+'-preloader" />'},wrap:void 0,body:void 0,errors:{tpl:'<div class="'+l+"-error "+l+'-close"></div>',autocloseDelay:2e3,ajaxUnsuccessfulLoad:"Error"},openEffect:{type:"fade",speed:400},closeEffect:{type:"fade",speed:400},width:"auto",verticalAlign:"middle",beforeOpen:r.noop,afterOpen:r.noop,beforeClose:r.noop,afterClose:r.noop,afterLoading:r.noop,afterLoadingOnShow:r.noop,errorLoading:r.noop},d=0,s=r([]),u=function(t,e){var o=!0;return r(t).each(function(){r(e.target).get(0)==r(this).get(0)&&(o=!1),0==r(e.target).closest("HTML",r(this).get(0)).length&&(o=!1)}),o},i={getParentEl:function(t){var e=r(t);return e.data(l)?e:(e=r(t).closest("."+l+"-container").data(l+"ParentEl"))||!1},transition:function(t,e,o,n){switch(n=null==n?r.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"),r(document).trigger(l+"_setWrapMarginRight",e)},initEl:function(e,t){var o=e.data(l);if(!o){if(d++,(o=t).modalID=d,o.overlay.block=r(o.overlay.tpl),o.overlay.block.css(o.overlay.css),o.container.block=r(o.container.tpl),o.body=r("."+l+"-container_i2",o.container.block),t.clone?o.body.html(e.clone(!0)):(e.before('<div id="'+l+"Reserve"+o.modalID+'" style="display: none" />'),o.body.html(e)),o.body.on("click","."+l+"-close",function(){return e[l]("close"),!1}),o.closeOnOverlayClick&&o.overlay.block.add(o.container.block).click(function(t){u(r(">*",o.body),t)&&e[l]("close")}),o.container.block.data(l+"ParentEl",e),e.data(l,o),s=r.merge(s,e),r.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=r.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."+l),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."+l),o.afterLoadingOnShow(o,e,t)},error:function(){e.trigger("errorLoading."+l),o.errorLoading(o,e),null==a?(o.body.html(o.errors.tpl),r("."+l+"-error",o.body).html(o.errors.ajaxUnsuccessfulLoad),r("."+l+"-close",o.body).click(function(){return e[l]("close"),!1}),o.errors.autocloseDelay&&setTimeout(function(){e[l]("close")},o.errors.autocloseDelay)):a(o,e)}},o.ajax);o.ajaxRequest=r.ajax(c),e.data(l,o)}},init:function(t){return t=r.extend(!0,{},e,t),r.isFunction(this)?null==t?void r.error(l+": Uncorrect parameters"):""!=t.url?(t.type="ajax",i.initEl(r("<div />"),t)):""!=t.content?(t.type="html",i.initEl(r(t.content),t)):void r.error(l+': Set parameter "url" or "content"'):this.each(function(){i.initEl(r(this),r.extend(!0,{},t))})}},p={show:function(){var t=i.getParentEl(this);if(!1!==t){var e=t.data(l);if(e.overlay.block.hide(),e.container.block.hide(),r("BODY").append(e.overlay.block),r("BODY").append(e.container.block),e.container.block.css("zIndex",e.overlay.block.css("zIndex")),e.beforeOpen(e,t),t.trigger("beforeOpen."+l),"hidden"!=e.wrap.css("overflow-y")){e.wrap.data(l+"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(){r(this).data(l).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."+l)}),t}r.error(l+": Uncorrect call")},close:function(){if(!r.isFunction(this))return this.each(function(){var t=i.getParentEl(this);if(!1!==t){var e=t.data(l);!1!==e.beforeClose(e,t)&&(t.trigger("beforeClose."+l),s.not(t).last().each(function(){r(this).data(l).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."+l),e.clone||r("#"+l+"Reserve"+e.modalID).replaceWith(e.body.find(">*")),e.overlay.block.remove(),e.container.block.remove(),t.data(l,null),r("."+l+"-container").length||(e.wrap.data(l+"Overflow")&&e.wrap.css("overflow-y",e.wrap.data(l+"Overflow")),i.setWrapMarginRight(e,0))}),"ajax"==e.type&&e.ajaxRequest.abort(),s=s.not(t))}else r.error(l+": Uncorrect call")});s.each(function(){r(this)[l]("close")})},getActive:function(){var t=r("."+l+"-container").last();return!!t.length&&t.data(l+"ParentEl").data(l)},setDefault:function(t){r.extend(!0,e,t)}};r(function(){e.wrap=r(document.all&&!document.querySelector?"html":"body")}),r(document).bind("keyup."+l,function(t){var e=s.last();e.length&&(e.data(l).closeOnEsc&&27===t.keyCode&&e[l]("close"))}),r[l]=r.fn[l]=function(t){return p[t]?p[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void r.error(l+": 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(r){r.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}}}),r(function(){var t=r(".js-lwptocSmoothScrollCheckbox");if(t.length){var e=r(".js-lwptocSmoothScrollIOffsetInput").closest("TR");t.change(function(){t.prop("checked")?e.show():e.hide()}).change()}var o=r(".js-lwptocToggleCheckbox");if(o.length){var n=r(".js-lwptocToggleEl").closest("TR");o.change(function(){o.prop("checked")?n.show():n.hide()}).change()}var i=r(".js-lwptocAutoInsertEnableCheckbox");if(i.length){var a=r(".js-lwptocAutoInsertEl").closest("TR");i.change(function(){i.prop("checked")?a.show():a.hide()}).change()}var c=r(".lwptoc_colorPicker");c.length&&c.wpColorPicker()}),r.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=r(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=r(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"),r(this).addClass("lwptocCustomize_tab-active"),e.find(".lwptocCustomize_fields").hide(),e.find(".lwptocCustomize_fields-"+r(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,r.lwptocModal({url:lwptocMain.ajaxUrl,closeOnOverlayClick:!1,verticalAlign:"top",ajax:{data:t},afterLoadingOnShow:function(t){r.lwptocCustomize.init(t.body.find(".lwptocCustomize"),function(){t.body.lwptocModal("close")})},afterClose:e})}};var o={reload:function(t){var e=r(t);o.$container.replaceWith(e),o.init(e)},setEnabled:function(t){r.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){r.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=r(".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(){r.lwptocCustomize.show({action:"lwptoc_metabox_customize",postId:o.$container.data("postId")},r.noop)}),r(document).on("lwptocMetaboxCustomized",function(t,e){r(".lwptocCustomize-metabox").lwptocModal("close"),o.reload(e.metabox)}))}};r(function(){o.init()});var e={oneInited:!1,oneInit:function(){r(document).on("lwptocWidgetCustomized",function(t,e){r(".lwptocCustomize-metabox").lwptocModal("close"),r(".lwptocWidget-"+e.id+" .lwptocWidget_override").html(e.override),r(".lwptocWidget-"+e.id+" .lwptocWidget_input").val(e.value).change()})},init:function(){r(".lwptocWidget").each(function(){var t=r(this);t.data("inited")||(t.find(".lwptocWidget_customize").click(function(){r.lwptocCustomize.show({action:"lwptoc_widget_customize",value:t.find(".lwptocWidget_input").val(),widgetId:t.data("id")},r.noop)}),t.data("inited",1),e.oneInited||e.oneInit())})}};r.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:r(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)})})}};r(function(){n.init(r(".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:r(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)})})}};r(function(){i.init(r(".lwptocFontSizeField"))})}(jQuery);
|
admin/controllers/MetaboxController.php
CHANGED
@@ -23,6 +23,7 @@ class MetaboxController extends AdminController
|
|
23 |
public function initAjax()
|
24 |
{
|
25 |
add_action('wp_ajax_lwptoc_metabox_set_enabled', [$this, 'ajaxSetEnabled']);
|
|
|
26 |
add_action('wp_ajax_lwptoc_metabox_customize', [$this, 'ajaxCustomize']);
|
27 |
}
|
28 |
|
@@ -50,6 +51,19 @@ class MetaboxController extends AdminController
|
|
50 |
wp_die();
|
51 |
}
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
public function ajaxCustomize()
|
54 |
{
|
55 |
$post = get_post((int)Core::$plugin->request->get('postId'));
|
23 |
public function initAjax()
|
24 |
{
|
25 |
add_action('wp_ajax_lwptoc_metabox_set_enabled', [$this, 'ajaxSetEnabled']);
|
26 |
+
add_action('wp_ajax_lwptoc_metabox_set_processing', [$this, 'ajaxSetProcessing']);
|
27 |
add_action('wp_ajax_lwptoc_metabox_customize', [$this, 'ajaxCustomize']);
|
28 |
}
|
29 |
|
51 |
wp_die();
|
52 |
}
|
53 |
|
54 |
+
public function ajaxSetProcessing()
|
55 |
+
{
|
56 |
+
$post = get_post((int)Core::$plugin->request->get('postId'));
|
57 |
+
$this->checkAccess($post);
|
58 |
+
|
59 |
+
$settings = new PostSettings($post->ID);
|
60 |
+
$settings->processHeadings = (bool)Core::$plugin->request->get('enabled', true);
|
61 |
+
$settings->save();
|
62 |
+
|
63 |
+
echo Metabox::widget(['post' => $post]);
|
64 |
+
wp_die();
|
65 |
+
}
|
66 |
+
|
67 |
public function ajaxCustomize()
|
68 |
{
|
69 |
$post = get_post((int)Core::$plugin->request->get('postId'));
|
admin/controllers/WidgetController.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace luckywp\tableOfContents\admin\controllers;
|
4 |
+
|
5 |
+
use luckywp\tableOfContents\admin\forms\CustomizeForm;
|
6 |
+
use luckywp\tableOfContents\admin\widgets\customizeModal\CustomizeModal;
|
7 |
+
use luckywp\tableOfContents\admin\widgets\customizeSuccess\CustomizeSuccess;
|
8 |
+
use luckywp\tableOfContents\admin\widgets\widget\Widget;
|
9 |
+
use luckywp\tableOfContents\core\admin\AdminController;
|
10 |
+
use luckywp\tableOfContents\core\Core;
|
11 |
+
use luckywp\tableOfContents\core\helpers\Json;
|
12 |
+
use luckywp\tableOfContents\plugin\Shortcode;
|
13 |
+
|
14 |
+
class WidgetController extends AdminController
|
15 |
+
{
|
16 |
+
|
17 |
+
public function init()
|
18 |
+
{
|
19 |
+
parent::init();
|
20 |
+
add_action('plugins_loaded', [$this, 'initAjax']);
|
21 |
+
}
|
22 |
+
|
23 |
+
public function initAjax()
|
24 |
+
{
|
25 |
+
add_action('wp_ajax_lwptoc_widget_customize', [$this, 'ajaxCustomize']);
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function checkAccess()
|
29 |
+
{
|
30 |
+
Core::$plugin->admin->checkAjaxReferer();
|
31 |
+
}
|
32 |
+
|
33 |
+
public function ajaxCustomize()
|
34 |
+
{
|
35 |
+
$this->checkAccess();
|
36 |
+
|
37 |
+
$value = (string)Core::$plugin->request->get('value');
|
38 |
+
$widgetId = (string)Core::$plugin->request->get('widgetId');
|
39 |
+
|
40 |
+
$attrs = Shortcode::attrsFromJson($value);
|
41 |
+
|
42 |
+
$onlyBody = false;
|
43 |
+
|
44 |
+
$model = new CustomizeForm(null, $attrs);
|
45 |
+
if ($model->load(Core::$plugin->request->post())) {
|
46 |
+
if ($model->validate()) {
|
47 |
+
$attrs = array_filter($model->getAttrs(), function ($v) {
|
48 |
+
return $v !== null;
|
49 |
+
});
|
50 |
+
echo CustomizeSuccess::widget([
|
51 |
+
'after' => '<script>$(document).trigger("lwptocWidgetCustomized", ' . Json::encode([
|
52 |
+
'id' => $widgetId,
|
53 |
+
'override' => Widget::overrideHtml($attrs),
|
54 |
+
'value' => Json::encode($attrs),
|
55 |
+
]) . ');</script>',
|
56 |
+
]);
|
57 |
+
wp_die();
|
58 |
+
}
|
59 |
+
$onlyBody = true;
|
60 |
+
}
|
61 |
+
|
62 |
+
echo CustomizeModal::widget([
|
63 |
+
'onlyBody' => $onlyBody,
|
64 |
+
'action' => 'lwptoc_widget_customize',
|
65 |
+
'widgetId' => $widgetId,
|
66 |
+
'model' => $model,
|
67 |
+
]);
|
68 |
+
wp_die();
|
69 |
+
}
|
70 |
+
}
|
admin/forms/CustomizeForm.php
CHANGED
@@ -93,7 +93,7 @@ class CustomizeForm extends Model
|
|
93 |
public $skipHeadingText;
|
94 |
|
95 |
/**
|
96 |
-
* @var PostSettings
|
97 |
*/
|
98 |
public $postSettings;
|
99 |
|
@@ -102,6 +102,11 @@ class CustomizeForm extends Model
|
|
102 |
*/
|
103 |
public $isPostSettings;
|
104 |
|
|
|
|
|
|
|
|
|
|
|
105 |
protected $vars = [
|
106 |
'min',
|
107 |
'depth',
|
@@ -132,7 +137,7 @@ class CustomizeForm extends Model
|
|
132 |
];
|
133 |
|
134 |
/**
|
135 |
-
* @param PostSettings $postSettings
|
136 |
* @param array|null $attrs
|
137 |
* @param array $config
|
138 |
*/
|
@@ -140,6 +145,7 @@ class CustomizeForm extends Model
|
|
140 |
{
|
141 |
$this->postSettings = $postSettings;
|
142 |
$this->isPostSettings = $attrs === null;
|
|
|
143 |
if ($this->isPostSettings) {
|
144 |
$this->vars[] = 'position';
|
145 |
}
|
93 |
public $skipHeadingText;
|
94 |
|
95 |
/**
|
96 |
+
* @var PostSettings|null
|
97 |
*/
|
98 |
public $postSettings;
|
99 |
|
102 |
*/
|
103 |
public $isPostSettings;
|
104 |
|
105 |
+
/**
|
106 |
+
* @var bool
|
107 |
+
*/
|
108 |
+
public $isPostOrWidgetSettings;
|
109 |
+
|
110 |
protected $vars = [
|
111 |
'min',
|
112 |
'depth',
|
137 |
];
|
138 |
|
139 |
/**
|
140 |
+
* @param PostSettings|null $postSettings
|
141 |
* @param array|null $attrs
|
142 |
* @param array $config
|
143 |
*/
|
145 |
{
|
146 |
$this->postSettings = $postSettings;
|
147 |
$this->isPostSettings = $attrs === null;
|
148 |
+
$this->isPostOrWidgetSettings = $this->isPostSettings || $postSettings === null;
|
149 |
if ($this->isPostSettings) {
|
150 |
$this->vars[] = 'position';
|
151 |
}
|
admin/widgets/customizeModal/CustomizeModal.php
CHANGED
@@ -10,10 +10,15 @@ class CustomizeModal extends Widget
|
|
10 |
{
|
11 |
|
12 |
/**
|
13 |
-
* @var WP_Post
|
14 |
*/
|
15 |
public $post;
|
16 |
|
|
|
|
|
|
|
|
|
|
|
17 |
/**
|
18 |
* @var string
|
19 |
*/
|
@@ -33,6 +38,7 @@ class CustomizeModal extends Widget
|
|
33 |
{
|
34 |
return $this->render('modal', [
|
35 |
'post' => $this->post,
|
|
|
36 |
'action' => $this->action,
|
37 |
'model' => $this->model,
|
38 |
'onlyBody' => $this->onlyBody,
|
10 |
{
|
11 |
|
12 |
/**
|
13 |
+
* @var WP_Post|null
|
14 |
*/
|
15 |
public $post;
|
16 |
|
17 |
+
/**
|
18 |
+
* @var string|null
|
19 |
+
*/
|
20 |
+
public $widgetId;
|
21 |
+
|
22 |
/**
|
23 |
* @var string
|
24 |
*/
|
38 |
{
|
39 |
return $this->render('modal', [
|
40 |
'post' => $this->post,
|
41 |
+
'widgetId' => $this->widgetId,
|
42 |
'action' => $this->action,
|
43 |
'model' => $this->model,
|
44 |
'onlyBody' => $this->onlyBody,
|
admin/widgets/customizeModal/views/modal.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @var $post WP_Post
|
|
|
4 |
* @var $action string
|
5 |
* @var $model \luckywp\tableOfContents\admin\forms\CustomizeForm
|
6 |
* @var $onlyBody bool
|
@@ -17,7 +18,7 @@ use luckywp\tableOfContents\core\helpers\Html;
|
|
17 |
echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
18 |
?>
|
19 |
<form
|
20 |
-
action="<?= admin_url('admin-ajax.php?_ajax_nonce=' . wp_create_nonce(Core::$plugin->prefix . 'adminMain') . '&action=' . $action . '&postId=' . $post->ID) ?>"
|
21 |
data-ajax-form="1"
|
22 |
class="lwptocModalBox"
|
23 |
>
|
@@ -66,7 +67,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
66 |
</div>
|
67 |
<?php } ?>
|
68 |
|
69 |
-
<?php $defaultValue = ($model->
|
70 |
<div class="lwptocCustomize_field<?= $model->defaultMin ? ' lwptocCustomize_field-default' : '' ?>">
|
71 |
<div class="lwptocCustomize_field_header">
|
72 |
<span class="lwptocCustomize_field_label"><?= __('Minimal Count of Headers', 'lwptoc') ?></span>
|
@@ -89,7 +90,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
89 |
</div>
|
90 |
</div>
|
91 |
|
92 |
-
<?php $defaultValue = ($model->
|
93 |
<div class="lwptocCustomize_field<?= $model->defaultDepth ? ' lwptocCustomize_field-default' : '' ?>">
|
94 |
<div class="lwptocCustomize_field_header">
|
95 |
<span class="lwptocCustomize_field_label"><?= __('Depth', 'lwptoc') ?></span>
|
@@ -111,7 +112,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
111 |
</div>
|
112 |
</div>
|
113 |
|
114 |
-
<?php $defaultValue = ($model->
|
115 |
<div class="lwptocCustomize_field<?= $model->defaultHierarchical ? ' lwptocCustomize_field-default' : '' ?>">
|
116 |
<div class="lwptocCustomize_field_header">
|
117 |
<span class="lwptocCustomize_field_label"><?= __('Hierarchical View', 'lwptoc') ?></span>
|
@@ -134,7 +135,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
134 |
</div>
|
135 |
</div>
|
136 |
|
137 |
-
<?php $defaultValue = ($model->
|
138 |
<div class="lwptocCustomize_field<?= $model->defaultNumeration ? ' lwptocCustomize_field-default' : '' ?>">
|
139 |
<div class="lwptocCustomize_field_header">
|
140 |
<span class="lwptocCustomize_field_label"><?= __('Numeration', 'lwptoc') ?></span>
|
@@ -156,7 +157,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
156 |
</div>
|
157 |
</div>
|
158 |
|
159 |
-
<?php $defaultValue = ($model->
|
160 |
<div class="lwptocCustomize_field<?= $model->defaultTitle ? ' lwptocCustomize_field-default' : '' ?>">
|
161 |
<div class="lwptocCustomize_field_header">
|
162 |
<span class="lwptocCustomize_field_label"><?= __('Title', 'lwptoc') ?></span>
|
@@ -182,7 +183,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
182 |
</div>
|
183 |
</div>
|
184 |
|
185 |
-
<?php $defaultValue = ($model->
|
186 |
<div class="lwptocCustomize_field<?= $model->defaultToggle ? ' lwptocCustomize_field-default' : '' ?>">
|
187 |
<div class="lwptocCustomize_field_header">
|
188 |
<span class="lwptocCustomize_field_label"><?= __('Toggle Show/Hide', 'lwptoc') ?></span>
|
@@ -205,7 +206,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
205 |
</div>
|
206 |
</div>
|
207 |
|
208 |
-
<?php $defaultValue = ($model->
|
209 |
<div class="lwptocCustomize_field<?= $model->defaultLabelShow ? ' lwptocCustomize_field-default' : '' ?>">
|
210 |
<div class="lwptocCustomize_field_header">
|
211 |
<span class="lwptocCustomize_field_label"><?= __('Label Show', 'lwptoc') ?></span>
|
@@ -225,7 +226,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
225 |
</div>
|
226 |
</div>
|
227 |
|
228 |
-
<?php $defaultValue = ($model->
|
229 |
<div class="lwptocCustomize_field<?= $model->defaultLabelHide ? ' lwptocCustomize_field-default' : '' ?>">
|
230 |
<div class="lwptocCustomize_field_header">
|
231 |
<span class="lwptocCustomize_field_label"><?= __('Label Hide', 'lwptoc') ?></span>
|
@@ -245,7 +246,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
245 |
</div>
|
246 |
</div>
|
247 |
|
248 |
-
<?php $defaultValue = ($model->
|
249 |
<div class="lwptocCustomize_field<?= $model->defaultHideItems ? ' lwptocCustomize_field-default' : '' ?>">
|
250 |
<div class="lwptocCustomize_field_header">
|
251 |
<span class="lwptocCustomize_field_label"><?= __('By default, items of contents will be hidden', 'lwptoc') ?></span>
|
@@ -268,7 +269,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
268 |
</div>
|
269 |
</div>
|
270 |
|
271 |
-
<?php $defaultValue = ($model->
|
272 |
<div class="lwptocCustomize_field<?= $model->defaultSmoothScroll ? ' lwptocCustomize_field-default' : '' ?>">
|
273 |
<div class="lwptocCustomize_field_header">
|
274 |
<span class="lwptocCustomize_field_label"><?= __('Smooth Scroll', 'lwptoc') ?></span>
|
@@ -291,7 +292,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
291 |
</div>
|
292 |
</div>
|
293 |
|
294 |
-
<?php $defaultValue = ($model->
|
295 |
<div class="lwptocCustomize_field<?= $model->defaultSmoothScrollOffset ? ' lwptocCustomize_field-default' : '' ?>">
|
296 |
<div class="lwptocCustomize_field_header">
|
297 |
<span class="lwptocCustomize_field_label"><?= __('Smooth Scroll Offset Top', 'lwptoc') ?></span>
|
@@ -315,7 +316,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
315 |
|
316 |
<div class="lwptocCustomize_fields lwptocCustomize_fields-appearance">
|
317 |
|
318 |
-
<?php $defaultValue = ($model->
|
319 |
<div class="lwptocCustomize_field<?= $model->defaultWidth ? ' lwptocCustomize_field-default' : '' ?>">
|
320 |
<div class="lwptocCustomize_field_header">
|
321 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Width', 'lwptoc') ?></span>
|
@@ -338,7 +339,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
338 |
</div>
|
339 |
</div>
|
340 |
|
341 |
-
<?php $defaultValue = ($model->
|
342 |
<div class="lwptocCustomize_field<?= $model->defaultFloat ? ' lwptocCustomize_field-default' : '' ?>">
|
343 |
<div class="lwptocCustomize_field_header">
|
344 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Float', 'lwptoc') ?></span>
|
@@ -360,7 +361,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
360 |
</div>
|
361 |
</div>
|
362 |
|
363 |
-
<?php $defaultValue = ($model->
|
364 |
<div class="lwptocCustomize_field<?= $model->defaultTitleFontSize ? ' lwptocCustomize_field-default' : '' ?>">
|
365 |
<div class="lwptocCustomize_field_header">
|
366 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Title Font Size', 'lwptoc') ?></span>
|
@@ -384,7 +385,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
384 |
</div>
|
385 |
</div>
|
386 |
|
387 |
-
<?php $defaultValue = ($model->
|
388 |
<div class="lwptocCustomize_field<?= $model->defaultTitleFontWeight ? ' lwptocCustomize_field-default' : '' ?>">
|
389 |
<div class="lwptocCustomize_field_header">
|
390 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Title Font Weight', 'lwptoc') ?></span>
|
@@ -406,7 +407,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
406 |
</div>
|
407 |
</div>
|
408 |
|
409 |
-
<?php $defaultValue = ($model->
|
410 |
<div class="lwptocCustomize_field<?= $model->defaultItemsFontSize ? ' lwptocCustomize_field-default' : '' ?>">
|
411 |
<div class="lwptocCustomize_field_header">
|
412 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Items Font Size', 'lwptoc') ?></span>
|
@@ -430,7 +431,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
430 |
</div>
|
431 |
</div>
|
432 |
|
433 |
-
<?php $defaultValue = ($model->
|
434 |
<div class="lwptocCustomize_field<?= $model->defaultColorScheme ? ' lwptocCustomize_field-default' : '' ?>">
|
435 |
<div class="lwptocCustomize_field_header">
|
436 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Color Scheme', 'lwptoc') ?></span>
|
@@ -460,7 +461,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
460 |
'hoverLinkColor' => 'Hover Link Color',
|
461 |
'visitedLinkColor' => 'Visited Link Color',
|
462 |
] as $var => $label) { ?>
|
463 |
-
<?php $defaultValue = ($model->
|
464 |
<div class="lwptocCustomize_field<?= $model->{'default' . ucfirst($var)} ? ' lwptocCustomize_field-default' : '' ?>">
|
465 |
<div class="lwptocCustomize_field_header">
|
466 |
<span class="lwptocCustomize_field_label"><?= esc_html__($label, 'lwptoc') ?></span>
|
@@ -485,7 +486,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
485 |
|
486 |
<div class="lwptocCustomize_fields lwptocCustomize_fields-misc">
|
487 |
|
488 |
-
<?php $defaultValue = ($model->
|
489 |
<div class="lwptocCustomize_field<?= $model->defaultWrapNoindex ? ' lwptocCustomize_field-default' : '' ?>">
|
490 |
<div class="lwptocCustomize_field_header">
|
491 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Wrap table of contents with <!--noindex--> tag', 'lwptoc') ?></span>
|
@@ -508,7 +509,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
508 |
</div>
|
509 |
</div>
|
510 |
|
511 |
-
<?php $defaultValue = ($model->
|
512 |
<div class="lwptocCustomize_field<?= $model->defaultSkipHeadingLevel ? ' lwptocCustomize_field-default' : '' ?>">
|
513 |
<div class="lwptocCustomize_field_header">
|
514 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Skip heading by level', 'lwptoc') ?></span>
|
@@ -531,7 +532,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
531 |
</div>
|
532 |
</div>
|
533 |
|
534 |
-
<?php $defaultValue = ($model->
|
535 |
<div class="lwptocCustomize_field<?= $model->defaultSkipHeadingText ? ' lwptocCustomize_field-default' : '' ?>">
|
536 |
<div class="lwptocCustomize_field_header">
|
537 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Skip heading by text', 'lwptoc') ?></span>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @var $post WP_Post|null
|
4 |
+
* @var $widgetId string|null
|
5 |
* @var $action string
|
6 |
* @var $model \luckywp\tableOfContents\admin\forms\CustomizeForm
|
7 |
* @var $onlyBody bool
|
18 |
echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
19 |
?>
|
20 |
<form
|
21 |
+
action="<?= admin_url('admin-ajax.php?_ajax_nonce=' . wp_create_nonce(Core::$plugin->prefix . 'adminMain') . '&action=' . $action . ($post ? '&postId=' . $post->ID : '') . ($widgetId ? '&widgetId=' . $widgetId : '')) ?>"
|
22 |
data-ajax-form="1"
|
23 |
class="lwptocModalBox"
|
24 |
>
|
67 |
</div>
|
68 |
<?php } ?>
|
69 |
|
70 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->min)) ? Core::$plugin->settings->generalMin : $model->postSettings->min ?>
|
71 |
<div class="lwptocCustomize_field<?= $model->defaultMin ? ' lwptocCustomize_field-default' : '' ?>">
|
72 |
<div class="lwptocCustomize_field_header">
|
73 |
<span class="lwptocCustomize_field_label"><?= __('Minimal Count of Headers', 'lwptoc') ?></span>
|
90 |
</div>
|
91 |
</div>
|
92 |
|
93 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->depth)) ? Core::$plugin->settings->generalDepth : $model->postSettings->depth ?>
|
94 |
<div class="lwptocCustomize_field<?= $model->defaultDepth ? ' lwptocCustomize_field-default' : '' ?>">
|
95 |
<div class="lwptocCustomize_field_header">
|
96 |
<span class="lwptocCustomize_field_label"><?= __('Depth', 'lwptoc') ?></span>
|
112 |
</div>
|
113 |
</div>
|
114 |
|
115 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->hierarchical)) ? Core::$plugin->settings->generalHierarchical : $model->postSettings->hierarchical ?>
|
116 |
<div class="lwptocCustomize_field<?= $model->defaultHierarchical ? ' lwptocCustomize_field-default' : '' ?>">
|
117 |
<div class="lwptocCustomize_field_header">
|
118 |
<span class="lwptocCustomize_field_label"><?= __('Hierarchical View', 'lwptoc') ?></span>
|
135 |
</div>
|
136 |
</div>
|
137 |
|
138 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->numeration)) ? Core::$plugin->settings->generalNumeration : $model->postSettings->numeration ?>
|
139 |
<div class="lwptocCustomize_field<?= $model->defaultNumeration ? ' lwptocCustomize_field-default' : '' ?>">
|
140 |
<div class="lwptocCustomize_field_header">
|
141 |
<span class="lwptocCustomize_field_label"><?= __('Numeration', 'lwptoc') ?></span>
|
157 |
</div>
|
158 |
</div>
|
159 |
|
160 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->title)) ? Core::$plugin->settings->generalTitle : $model->postSettings->title ?>
|
161 |
<div class="lwptocCustomize_field<?= $model->defaultTitle ? ' lwptocCustomize_field-default' : '' ?>">
|
162 |
<div class="lwptocCustomize_field_header">
|
163 |
<span class="lwptocCustomize_field_label"><?= __('Title', 'lwptoc') ?></span>
|
183 |
</div>
|
184 |
</div>
|
185 |
|
186 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->toggle)) ? Core::$plugin->settings->generalToggle : $model->postSettings->toggle ?>
|
187 |
<div class="lwptocCustomize_field<?= $model->defaultToggle ? ' lwptocCustomize_field-default' : '' ?>">
|
188 |
<div class="lwptocCustomize_field_header">
|
189 |
<span class="lwptocCustomize_field_label"><?= __('Toggle Show/Hide', 'lwptoc') ?></span>
|
206 |
</div>
|
207 |
</div>
|
208 |
|
209 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->labelShow)) ? Core::$plugin->settings->generalLabelShow : $model->postSettings->labelShow ?>
|
210 |
<div class="lwptocCustomize_field<?= $model->defaultLabelShow ? ' lwptocCustomize_field-default' : '' ?>">
|
211 |
<div class="lwptocCustomize_field_header">
|
212 |
<span class="lwptocCustomize_field_label"><?= __('Label Show', 'lwptoc') ?></span>
|
226 |
</div>
|
227 |
</div>
|
228 |
|
229 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->labelHide)) ? Core::$plugin->settings->generalLabelHide : $model->postSettings->labelHide ?>
|
230 |
<div class="lwptocCustomize_field<?= $model->defaultLabelHide ? ' lwptocCustomize_field-default' : '' ?>">
|
231 |
<div class="lwptocCustomize_field_header">
|
232 |
<span class="lwptocCustomize_field_label"><?= __('Label Hide', 'lwptoc') ?></span>
|
246 |
</div>
|
247 |
</div>
|
248 |
|
249 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->hideItems)) ? Core::$plugin->settings->generalHideItems : $model->postSettings->hideItems ?>
|
250 |
<div class="lwptocCustomize_field<?= $model->defaultHideItems ? ' lwptocCustomize_field-default' : '' ?>">
|
251 |
<div class="lwptocCustomize_field_header">
|
252 |
<span class="lwptocCustomize_field_label"><?= __('By default, items of contents will be hidden', 'lwptoc') ?></span>
|
269 |
</div>
|
270 |
</div>
|
271 |
|
272 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->smoothScroll)) ? Core::$plugin->settings->generalSmoothScroll : $model->postSettings->smoothScroll ?>
|
273 |
<div class="lwptocCustomize_field<?= $model->defaultSmoothScroll ? ' lwptocCustomize_field-default' : '' ?>">
|
274 |
<div class="lwptocCustomize_field_header">
|
275 |
<span class="lwptocCustomize_field_label"><?= __('Smooth Scroll', 'lwptoc') ?></span>
|
292 |
</div>
|
293 |
</div>
|
294 |
|
295 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->smoothScrollOffset)) ? Core::$plugin->settings->generalSmoothScrollOffset : $model->postSettings->smoothScrollOffset ?>
|
296 |
<div class="lwptocCustomize_field<?= $model->defaultSmoothScrollOffset ? ' lwptocCustomize_field-default' : '' ?>">
|
297 |
<div class="lwptocCustomize_field_header">
|
298 |
<span class="lwptocCustomize_field_label"><?= __('Smooth Scroll Offset Top', 'lwptoc') ?></span>
|
316 |
|
317 |
<div class="lwptocCustomize_fields lwptocCustomize_fields-appearance">
|
318 |
|
319 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->width)) ? Core::$plugin->settings->appearanceWidth : $model->postSettings->width ?>
|
320 |
<div class="lwptocCustomize_field<?= $model->defaultWidth ? ' lwptocCustomize_field-default' : '' ?>">
|
321 |
<div class="lwptocCustomize_field_header">
|
322 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Width', 'lwptoc') ?></span>
|
339 |
</div>
|
340 |
</div>
|
341 |
|
342 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->float)) ? Core::$plugin->settings->appearanceFloat : $model->postSettings->float ?>
|
343 |
<div class="lwptocCustomize_field<?= $model->defaultFloat ? ' lwptocCustomize_field-default' : '' ?>">
|
344 |
<div class="lwptocCustomize_field_header">
|
345 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Float', 'lwptoc') ?></span>
|
361 |
</div>
|
362 |
</div>
|
363 |
|
364 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->titleFontSize)) ? Core::$plugin->settings->appearanceTitleFontSize : $model->postSettings->titleFontSize ?>
|
365 |
<div class="lwptocCustomize_field<?= $model->defaultTitleFontSize ? ' lwptocCustomize_field-default' : '' ?>">
|
366 |
<div class="lwptocCustomize_field_header">
|
367 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Title Font Size', 'lwptoc') ?></span>
|
385 |
</div>
|
386 |
</div>
|
387 |
|
388 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->titleFontWeight)) ? Core::$plugin->settings->appearanceTitleFontWeight : $model->postSettings->titleFontWeight ?>
|
389 |
<div class="lwptocCustomize_field<?= $model->defaultTitleFontWeight ? ' lwptocCustomize_field-default' : '' ?>">
|
390 |
<div class="lwptocCustomize_field_header">
|
391 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Title Font Weight', 'lwptoc') ?></span>
|
407 |
</div>
|
408 |
</div>
|
409 |
|
410 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->itemsFontSize)) ? Core::$plugin->settings->appearanceItemsFontSize : $model->postSettings->itemsFontSize ?>
|
411 |
<div class="lwptocCustomize_field<?= $model->defaultItemsFontSize ? ' lwptocCustomize_field-default' : '' ?>">
|
412 |
<div class="lwptocCustomize_field_header">
|
413 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Items Font Size', 'lwptoc') ?></span>
|
431 |
</div>
|
432 |
</div>
|
433 |
|
434 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->colorScheme)) ? Core::$plugin->settings->appearanceColorScheme : $model->postSettings->colorScheme ?>
|
435 |
<div class="lwptocCustomize_field<?= $model->defaultColorScheme ? ' lwptocCustomize_field-default' : '' ?>">
|
436 |
<div class="lwptocCustomize_field_header">
|
437 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Color Scheme', 'lwptoc') ?></span>
|
461 |
'hoverLinkColor' => 'Hover Link Color',
|
462 |
'visitedLinkColor' => 'Visited Link Color',
|
463 |
] as $var => $label) { ?>
|
464 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->$var)) ? Core::$plugin->settings->{'appearance' . ucfirst($var)} : $model->postSettings->$var ?>
|
465 |
<div class="lwptocCustomize_field<?= $model->{'default' . ucfirst($var)} ? ' lwptocCustomize_field-default' : '' ?>">
|
466 |
<div class="lwptocCustomize_field_header">
|
467 |
<span class="lwptocCustomize_field_label"><?= esc_html__($label, 'lwptoc') ?></span>
|
486 |
|
487 |
<div class="lwptocCustomize_fields lwptocCustomize_fields-misc">
|
488 |
|
489 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->wrapNoindex)) ? Core::$plugin->settings->miscWrapNoindex : $model->postSettings->wrapNoindex ?>
|
490 |
<div class="lwptocCustomize_field<?= $model->defaultWrapNoindex ? ' lwptocCustomize_field-default' : '' ?>">
|
491 |
<div class="lwptocCustomize_field_header">
|
492 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Wrap table of contents with <!--noindex--> tag', 'lwptoc') ?></span>
|
509 |
</div>
|
510 |
</div>
|
511 |
|
512 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->skipHeadingLevel)) ? Core::$plugin->settings->getMiscSkipHeadingLevel() : $model->postSettings->skipHeadingLevel ?>
|
513 |
<div class="lwptocCustomize_field<?= $model->defaultSkipHeadingLevel ? ' lwptocCustomize_field-default' : '' ?>">
|
514 |
<div class="lwptocCustomize_field_header">
|
515 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Skip heading by level', 'lwptoc') ?></span>
|
532 |
</div>
|
533 |
</div>
|
534 |
|
535 |
+
<?php $defaultValue = ($model->isPostOrWidgetSettings || is_null($model->postSettings->skipHeadingText)) ? Core::$plugin->settings->getMiscSkipHeadingText() : $model->postSettings->skipHeadingText ?>
|
536 |
<div class="lwptocCustomize_field<?= $model->defaultSkipHeadingText ? ' lwptocCustomize_field-default' : '' ?>">
|
537 |
<div class="lwptocCustomize_field_header">
|
538 |
<span class="lwptocCustomize_field_label"><?= esc_html__('Skip heading by text', 'lwptoc') ?></span>
|
admin/widgets/metabox/views/box.php
CHANGED
@@ -13,6 +13,13 @@ use luckywp\tableOfContents\core\Core;
|
|
13 |
<p>
|
14 |
<?= __('The table of contents will be automatic added to this post.', 'lwptoc') ?>
|
15 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
<?php
|
17 |
$rows = Core::$plugin->admin->overrideSettingsToRows($settings);
|
18 |
if ($rows) { ?>
|
@@ -32,17 +39,40 @@ use luckywp\tableOfContents\core\Core;
|
|
32 |
<?= AdminHtml::button(__('Customize', 'lwptoc'), [
|
33 |
'class' => 'lwptocMetabox_customize',
|
34 |
]) ?>
|
35 |
-
|
36 |
-
|
37 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
]) ?>
|
39 |
</p>
|
40 |
-
<?php }
|
|
|
|
|
41 |
<p>
|
42 |
-
<?= __('Click "Enable" for automatic add table of contents to this post.', 'lwptoc') ?>
|
43 |
</p>
|
44 |
<p>
|
45 |
-
<?= AdminHtml::button(__('Enable', 'lwptoc'), [
|
46 |
'class' => 'lwptocMetabox_enable',
|
47 |
]) ?>
|
48 |
</p>
|
13 |
<p>
|
14 |
<?= __('The table of contents will be automatic added to this post.', 'lwptoc') ?>
|
15 |
</p>
|
16 |
+
<?php } elseif ($settings->processHeadings) { ?>
|
17 |
+
<p>
|
18 |
+
<?= __('The headings will be processing in this post for use in Table of Contens in widget or custom shortcode.', 'lwptoc') ?>
|
19 |
+
</p>
|
20 |
+
<?php } ?>
|
21 |
+
|
22 |
+
<?php if ($settings->enabled || $settings->processHeadings) { ?>
|
23 |
<?php
|
24 |
$rows = Core::$plugin->admin->overrideSettingsToRows($settings);
|
25 |
if ($rows) { ?>
|
39 |
<?= AdminHtml::button(__('Customize', 'lwptoc'), [
|
40 |
'class' => 'lwptocMetabox_customize',
|
41 |
]) ?>
|
42 |
+
<?php
|
43 |
+
if ($settings->enabled) {
|
44 |
+
echo AdminHtml::button(__('Disable TOC', 'lwptoc'), [
|
45 |
+
'theme' => AdminHtml::BUTTON_THEME_LINK_DELETE,
|
46 |
+
'class' => 'lwptocMetabox_disable',
|
47 |
+
]);
|
48 |
+
} elseif ($settings->processHeadings) {
|
49 |
+
echo AdminHtml::button(__('Disable Processing', 'lwptoc'), [
|
50 |
+
'theme' => AdminHtml::BUTTON_THEME_LINK_DELETE,
|
51 |
+
'class' => 'lwptocMetabox_disableProcessing',
|
52 |
+
]);
|
53 |
+
}
|
54 |
+
?>
|
55 |
+
</p>
|
56 |
+
<?php } ?>
|
57 |
+
|
58 |
+
|
59 |
+
<?php if (!$settings->processHeadings && !$settings->enabled) { ?>
|
60 |
+
<p>
|
61 |
+
<?= __('Click "Enable Processing" for headings processing in this post.', 'lwptoc') ?>
|
62 |
+
</p>
|
63 |
+
<p>
|
64 |
+
<?= AdminHtml::button(__('Enable Processing', 'lwptoc'), [
|
65 |
+
'class' => 'lwptocMetabox_enableProcessing',
|
66 |
]) ?>
|
67 |
</p>
|
68 |
+
<?php } ?>
|
69 |
+
|
70 |
+
<?php if (!$settings->enabled) { ?>
|
71 |
<p>
|
72 |
+
<?= __('Click "Enable TOC" for automatic add table of contents to this post.', 'lwptoc') ?>
|
73 |
</p>
|
74 |
<p>
|
75 |
+
<?= AdminHtml::button(__('Enable TOC', 'lwptoc'), [
|
76 |
'class' => 'lwptocMetabox_enable',
|
77 |
]) ?>
|
78 |
</p>
|
admin/widgets/widget/Widget.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace luckywp\tableOfContents\admin\widgets\widget;
|
4 |
+
|
5 |
+
use luckywp\tableOfContents\plugin\Shortcode;
|
6 |
+
|
7 |
+
class Widget extends \luckywp\tableOfContents\core\base\Widget
|
8 |
+
{
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @var string
|
12 |
+
*/
|
13 |
+
public $id;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $inputName;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
public $value;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var array
|
27 |
+
*/
|
28 |
+
public $instance;
|
29 |
+
|
30 |
+
public function run()
|
31 |
+
{
|
32 |
+
return $this->render('form', [
|
33 |
+
'id' => $this->id,
|
34 |
+
'inputName' => $this->inputName,
|
35 |
+
'value' => $this->value,
|
36 |
+
'attrs' => Shortcode::attrsFromJson($this->value),
|
37 |
+
]);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @param array $attrs
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
public static function overrideHtml($attrs)
|
45 |
+
{
|
46 |
+
return (new self())->render('_override', [
|
47 |
+
'attrs' => $attrs,
|
48 |
+
]);
|
49 |
+
}
|
50 |
+
}
|
admin/widgets/widget/views/_override.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @var array $attrs
|
4 |
+
*/
|
5 |
+
|
6 |
+
use luckywp\tableOfContents\core\Core;
|
7 |
+
|
8 |
+
$rows = Core::$plugin->admin->overrideSettingsToRows($attrs);
|
9 |
+
if ($rows) {
|
10 |
+
?>
|
11 |
+
<p>
|
12 |
+
<?= __('Overridden settings:', 'lwptoc') ?>
|
13 |
+
</p>
|
14 |
+
<div class="lwptocWidget_settings">
|
15 |
+
<?php foreach ($rows as $row) { ?>
|
16 |
+
<div class="lwptocWidget_settings_item">
|
17 |
+
<b><?= $row[0] ?>:</b>
|
18 |
+
<?= $row[1] === null ? '<i>' . __('empty', 'lwptoc') . '</i>' : $row[1] ?>
|
19 |
+
</div>
|
20 |
+
<?php } ?>
|
21 |
+
</div>
|
22 |
+
<?php
|
23 |
+
}
|
admin/widgets/widget/views/form.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @var $id string
|
4 |
+
* @var $inputName string
|
5 |
+
* @var $value string
|
6 |
+
* @var $attrs array
|
7 |
+
*/
|
8 |
+
|
9 |
+
use luckywp\tableOfContents\admin\widgets\widget\Widget;
|
10 |
+
use luckywp\tableOfContents\core\admin\helpers\AdminHtml;
|
11 |
+
use luckywp\tableOfContents\core\helpers\Html;
|
12 |
+
|
13 |
+
?>
|
14 |
+
<div class="lwptocWidget lwptocWidget-<?= $id ?>" data-id="<?= $id ?>">
|
15 |
+
<div class="lwptocWidget_override">
|
16 |
+
<?= Widget::overrideHtml($attrs) ?>
|
17 |
+
</div>
|
18 |
+
<p>
|
19 |
+
<?= AdminHtml::button(__('Customize', 'lwptoc'), [
|
20 |
+
'class' => 'lwptocWidget_customize',
|
21 |
+
]) ?>
|
22 |
+
</p>
|
23 |
+
<?= Html::hiddenInput($inputName, $value, ['class' => 'lwptocWidget_input']) ?>
|
24 |
+
</div>
|
25 |
+
<script>
|
26 |
+
$.lwptocWidget.init();
|
27 |
+
</script>
|
config/settings.php
CHANGED
@@ -310,6 +310,25 @@ return [
|
|
310 |
],
|
311 |
],
|
312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
// Прочее
|
314 |
'misc' => [
|
315 |
'label' => esc_html__('Misc.', 'lwptoc'),
|
@@ -373,6 +392,19 @@ return [
|
|
373 |
],
|
374 |
],
|
375 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
],
|
377 |
],
|
378 |
];
|
310 |
],
|
311 |
],
|
312 |
|
313 |
+
// Обработка заголовков
|
314 |
+
'processingHeadings' => [
|
315 |
+
'label' => esc_html__('Processing Headings', 'lwptoc'),
|
316 |
+
'sections' => [
|
317 |
+
'main' => [
|
318 |
+
'fields' => [
|
319 |
+
'postTypes' => [
|
320 |
+
'label' => esc_html__('Always for Post Types', 'lwptoc'),
|
321 |
+
'widget' => function ($field) {
|
322 |
+
echo PostTypes::widget([
|
323 |
+
'field' => $field,
|
324 |
+
]);
|
325 |
+
},
|
326 |
+
],
|
327 |
+
],
|
328 |
+
],
|
329 |
+
],
|
330 |
+
],
|
331 |
+
|
332 |
// Прочее
|
333 |
'misc' => [
|
334 |
'label' => esc_html__('Misc.', 'lwptoc'),
|
392 |
],
|
393 |
],
|
394 |
],
|
395 |
+
'postSettings' => [
|
396 |
+
'title' => esc_html__('Post Settings', 'lwptoc'),
|
397 |
+
'fields' => [
|
398 |
+
'showMetaboxPostTypes' => [
|
399 |
+
'label' => esc_html__('Show Panel "Table of Contents" in Post Types', 'lwptoc'),
|
400 |
+
'widget' => function ($field) {
|
401 |
+
echo PostTypes::widget([
|
402 |
+
'field' => $field,
|
403 |
+
]);
|
404 |
+
},
|
405 |
+
],
|
406 |
+
]
|
407 |
+
]
|
408 |
],
|
409 |
],
|
410 |
];
|
core/helpers/Json.php
CHANGED
@@ -5,6 +5,19 @@ namespace luckywp\tableOfContents\core\helpers;
|
|
5 |
class Json
|
6 |
{
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
/**
|
9 |
* @see http://php.net/manual/ru/function.json-encode.php
|
10 |
* @param mixed $value Данные для кодирования
|
5 |
class Json
|
6 |
{
|
7 |
|
8 |
+
/**
|
9 |
+
* @param string $json
|
10 |
+
* @param bool $asArray
|
11 |
+
* @return mixed
|
12 |
+
*/
|
13 |
+
public static function decode($json, $asArray = true)
|
14 |
+
{
|
15 |
+
if ($json === null || $json === '') {
|
16 |
+
return null;
|
17 |
+
}
|
18 |
+
return json_decode((string)$json, $asArray);
|
19 |
+
}
|
20 |
+
|
21 |
/**
|
22 |
* @see http://php.net/manual/ru/function.json-encode.php
|
23 |
* @param mixed $value Данные для кодирования
|
core/helpers/ValueHelper.php
CHANGED
@@ -13,4 +13,17 @@ class ValueHelper
|
|
13 |
{
|
14 |
return is_array($value) ? $value : [];
|
15 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
13 |
{
|
14 |
return is_array($value) ? $value : [];
|
15 |
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param $v
|
19 |
+
* @return bool
|
20 |
+
*/
|
21 |
+
public static function assertBool($v)
|
22 |
+
{
|
23 |
+
if (is_bool($v)) {
|
24 |
+
return $v;
|
25 |
+
}
|
26 |
+
$v = strtolower((string)$v);
|
27 |
+
return in_array($v, ['1', 'true', 'yes', 'y'], true);
|
28 |
+
}
|
29 |
}
|
front/Front.php
CHANGED
@@ -6,7 +6,6 @@ use luckywp\tableOfContents\core\Core;
|
|
6 |
use luckywp\tableOfContents\core\front\BaseFront;
|
7 |
use luckywp\tableOfContents\core\helpers\ArrayHelper;
|
8 |
use luckywp\tableOfContents\plugin\PostSettings;
|
9 |
-
use luckywp\tableOfContents\plugin\Shortcode;
|
10 |
|
11 |
class Front extends BaseFront
|
12 |
{
|
@@ -19,7 +18,7 @@ class Front extends BaseFront
|
|
19 |
if (Core::isFront()) {
|
20 |
add_action('wp_enqueue_scripts', [$this, 'assets']);
|
21 |
add_action('init', function () {
|
22 |
-
if (Core::$plugin->settings->
|
23 |
add_filter('the_content', [$this, 'autoInsert'], 998);
|
24 |
}
|
25 |
});
|
@@ -41,31 +40,31 @@ class Front extends BaseFront
|
|
41 |
|
42 |
public function overrideColors()
|
43 |
{
|
44 |
-
if (
|
45 |
$styles = [];
|
46 |
|
47 |
$iStyles = [];
|
48 |
-
if ($color = ArrayHelper::getValue(
|
49 |
$iStyles[] = 'background-color:' . $color . ';';
|
50 |
}
|
51 |
-
if ($color = ArrayHelper::getValue(
|
52 |
$iStyles[] = 'border:1px solid ' . $color . ';';
|
53 |
}
|
54 |
if ($iStyles) {
|
55 |
$styles[] = '.lwptoc .lwptoc_i{' . implode($iStyles) . '}';
|
56 |
}
|
57 |
|
58 |
-
if ($color = ArrayHelper::getValue(
|
59 |
$styles[] = '.lwptoc_header{color:' . $color . ';}';
|
60 |
}
|
61 |
|
62 |
-
if ($color = ArrayHelper::getValue(
|
63 |
$styles[] = '.lwptoc .lwptoc_i A{color:' . $color . ';}';
|
64 |
}
|
65 |
-
if ($color = ArrayHelper::getValue(
|
66 |
$styles[] = '.lwptoc .lwptoc_i A:hover,.lwptoc .lwptoc_i A:focus,.lwptoc .lwptoc_i A:active{color:' . $color . ';border-color:' . $color . ';}';
|
67 |
}
|
68 |
-
if ($color = ArrayHelper::getValue(
|
69 |
$styles[] = '.lwptoc .lwptoc_i A:visited{color:' . $color . ';}';
|
70 |
}
|
71 |
|
@@ -87,7 +86,7 @@ class Front extends BaseFront
|
|
87 |
return $content;
|
88 |
}
|
89 |
|
90 |
-
if (!in_array($post->post_type, Core::$plugin->settings->
|
91 |
return $content;
|
92 |
}
|
93 |
|
@@ -96,7 +95,6 @@ class Front extends BaseFront
|
|
96 |
}
|
97 |
|
98 |
$settings = new PostSettings($post->ID);
|
99 |
-
|
100 |
if (!$settings->enabled) {
|
101 |
return $content;
|
102 |
}
|
6 |
use luckywp\tableOfContents\core\front\BaseFront;
|
7 |
use luckywp\tableOfContents\core\helpers\ArrayHelper;
|
8 |
use luckywp\tableOfContents\plugin\PostSettings;
|
|
|
9 |
|
10 |
class Front extends BaseFront
|
11 |
{
|
18 |
if (Core::isFront()) {
|
19 |
add_action('wp_enqueue_scripts', [$this, 'assets']);
|
20 |
add_action('init', function () {
|
21 |
+
if (Core::$plugin->settings->getPostTypesForProcessingHeadings()) {
|
22 |
add_filter('the_content', [$this, 'autoInsert'], 998);
|
23 |
}
|
24 |
});
|
40 |
|
41 |
public function overrideColors()
|
42 |
{
|
43 |
+
if (Toc::$overrideColors) {
|
44 |
$styles = [];
|
45 |
|
46 |
$iStyles = [];
|
47 |
+
if ($color = ArrayHelper::getValue(Toc::$overrideColors, 'backgroundColor')) {
|
48 |
$iStyles[] = 'background-color:' . $color . ';';
|
49 |
}
|
50 |
+
if ($color = ArrayHelper::getValue(Toc::$overrideColors, 'borderColor')) {
|
51 |
$iStyles[] = 'border:1px solid ' . $color . ';';
|
52 |
}
|
53 |
if ($iStyles) {
|
54 |
$styles[] = '.lwptoc .lwptoc_i{' . implode($iStyles) . '}';
|
55 |
}
|
56 |
|
57 |
+
if ($color = ArrayHelper::getValue(Toc::$overrideColors, 'titleColor')) {
|
58 |
$styles[] = '.lwptoc_header{color:' . $color . ';}';
|
59 |
}
|
60 |
|
61 |
+
if ($color = ArrayHelper::getValue(Toc::$overrideColors, 'linkColor')) {
|
62 |
$styles[] = '.lwptoc .lwptoc_i A{color:' . $color . ';}';
|
63 |
}
|
64 |
+
if ($color = ArrayHelper::getValue(Toc::$overrideColors, 'hoverLinkColor')) {
|
65 |
$styles[] = '.lwptoc .lwptoc_i A:hover,.lwptoc .lwptoc_i A:focus,.lwptoc .lwptoc_i A:active{color:' . $color . ';border-color:' . $color . ';}';
|
66 |
}
|
67 |
+
if ($color = ArrayHelper::getValue(Toc::$overrideColors, 'visitedLinkColor')) {
|
68 |
$styles[] = '.lwptoc .lwptoc_i A:visited{color:' . $color . ';}';
|
69 |
}
|
70 |
|
86 |
return $content;
|
87 |
}
|
88 |
|
89 |
+
if (!in_array($post->post_type, Core::$plugin->settings->getPostTypesForProcessingHeadings())) {
|
90 |
return $content;
|
91 |
}
|
92 |
|
95 |
}
|
96 |
|
97 |
$settings = new PostSettings($post->ID);
|
|
|
98 |
if (!$settings->enabled) {
|
99 |
return $content;
|
100 |
}
|
front/Toc.php
ADDED
@@ -0,0 +1,314 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace luckywp\tableOfContents\front;
|
4 |
+
|
5 |
+
use luckywp\tableOfContents\core\Core;
|
6 |
+
use luckywp\tableOfContents\core\helpers\ArrayHelper;
|
7 |
+
use luckywp\tableOfContents\core\helpers\ValueHelper;
|
8 |
+
use luckywp\tableOfContents\plugin\Settings;
|
9 |
+
|
10 |
+
class Toc
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var int
|
15 |
+
*/
|
16 |
+
public static $currentOutputDepth;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var array
|
20 |
+
*/
|
21 |
+
public static $overrideColors = [];
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @param array $headings
|
25 |
+
* @param array|string|null $attrs
|
26 |
+
* @return string
|
27 |
+
*/
|
28 |
+
public static function render($headings, $attrs)
|
29 |
+
{
|
30 |
+
$attrs = ValueHelper::assertArray($attrs);
|
31 |
+
|
32 |
+
$headerStyles = [];
|
33 |
+
$titleStyles = [];
|
34 |
+
$itemsStyles = [];
|
35 |
+
|
36 |
+
$min = (int)ArrayHelper::getValue($attrs, 'min', Core::$plugin->settings->getGeneralMin());
|
37 |
+
if ($min < 1) {
|
38 |
+
$min = 1;
|
39 |
+
}
|
40 |
+
if (count($headings) < $min) {
|
41 |
+
return '';
|
42 |
+
}
|
43 |
+
|
44 |
+
$skipHeadingLevels = Core::$plugin->skipHeadingLevelToArray(ArrayHelper::getValue($attrs, 'skipheadinglevel', Core::$plugin->settings->getMiscSkipHeadingLevel()));
|
45 |
+
$skipHeadingRegex = Core::$plugin->skipHeadingTextToRegex(ArrayHelper::getValue($attrs, 'skipheadingtext', Core::$plugin->settings->getMiscSkipHeadingText()));
|
46 |
+
|
47 |
+
$items = [];
|
48 |
+
$tree = [];
|
49 |
+
foreach ($headings as $heading) {
|
50 |
+
if (in_array('h' . $heading['index'], $skipHeadingLevels) ||
|
51 |
+
($skipHeadingRegex && preg_match($skipHeadingRegex, $heading['label']))
|
52 |
+
) {
|
53 |
+
continue;
|
54 |
+
}
|
55 |
+
$node = null;
|
56 |
+
while (count($tree) && ($node === null)) {
|
57 |
+
end($tree);
|
58 |
+
$key = key($tree);
|
59 |
+
if ($heading['index'] > $tree[$key]['index']) {
|
60 |
+
$node = $key;
|
61 |
+
} else {
|
62 |
+
unset($tree[$key]);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
$item = [
|
67 |
+
'id' => $heading['id'],
|
68 |
+
'index' => $heading['index'],
|
69 |
+
'number' => null,
|
70 |
+
'label' => $heading['label'],
|
71 |
+
'childrens' => [],
|
72 |
+
];
|
73 |
+
|
74 |
+
if ($node === null) {
|
75 |
+
$items[] = $item;
|
76 |
+
$tree[] = &$items[count($items) - 1];
|
77 |
+
} else {
|
78 |
+
$tree[$node]['childrens'][] = $item;
|
79 |
+
$tree[] = &$tree[$node]['childrens'][count($tree[$node]['childrens']) - 1];
|
80 |
+
}
|
81 |
+
}
|
82 |
+
unset($tree);
|
83 |
+
|
84 |
+
// Вложенность
|
85 |
+
$depth = (int)ArrayHelper::getValue($attrs, 'depth', Core::$plugin->settings->getGeneralDepth());
|
86 |
+
if (!array_key_exists($depth, Core::$plugin->getDepthsList())) {
|
87 |
+
$depth = 6;
|
88 |
+
}
|
89 |
+
|
90 |
+
// Уберём все элменты, не подходящие по вложенности
|
91 |
+
$currentDepth = 0;
|
92 |
+
$fn = function (&$items, $depth) use (&$fn, &$currentDepth) {
|
93 |
+
$currentDepth++;
|
94 |
+
foreach ($items as $key => $item) {
|
95 |
+
if ($currentDepth == $depth) {
|
96 |
+
$items[$key]['childrens'] = [];
|
97 |
+
}
|
98 |
+
$fn($items[$key]['childrens'], $depth);
|
99 |
+
}
|
100 |
+
$currentDepth--;
|
101 |
+
};
|
102 |
+
$fn($items, $depth);
|
103 |
+
|
104 |
+
// Нумерация
|
105 |
+
$numeration = ArrayHelper::getValue($attrs, 'numeration', Core::$plugin->settings->getGeneralNumeration());
|
106 |
+
$numeration = str_replace(['_', ' ', '-'], '', strtolower($numeration));
|
107 |
+
if (in_array($numeration, ['decimalnested', 'decimal', 'roman', 'romannested'])) {
|
108 |
+
if (in_array($numeration, ['decimalnested', 'romannested'])) {
|
109 |
+
$fn = function (&$items, $numbers) use (&$fn, $numeration) {
|
110 |
+
foreach ($items as $key => $item) {
|
111 |
+
$numbers[count($numbers) - 1]++;
|
112 |
+
$items[$key]['number'] = implode('.', $numeration == 'decimalnested' ? $numbers : array_map([$this, 'decimalToRoman'], $numbers));
|
113 |
+
$fn($items[$key]['childrens'], array_merge($numbers, [0]));
|
114 |
+
}
|
115 |
+
};
|
116 |
+
$fn($items, [0]);
|
117 |
+
} else {
|
118 |
+
$number = 0;
|
119 |
+
$fn = function (&$items) use (&$fn, &$number, $numeration) {
|
120 |
+
foreach ($items as $key => $item) {
|
121 |
+
$number++;
|
122 |
+
$items[$key]['number'] = $numeration == 'decimal' ? $number : static::decimalToRoman($number);
|
123 |
+
$fn($items[$key]['childrens']);
|
124 |
+
}
|
125 |
+
};
|
126 |
+
$fn($items);
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
// Без иерархии
|
131 |
+
$hierarchical = ValueHelper::assertBool(ArrayHelper::getValue($attrs, 'hierarchical', Core::$plugin->settings->getGeneralHierarchical()));
|
132 |
+
if (!$hierarchical) {
|
133 |
+
$newItems = [];
|
134 |
+
$fn = function ($items) use (&$fn, &$newItems) {
|
135 |
+
foreach ($items as $item) {
|
136 |
+
$newItem = $item;
|
137 |
+
$newItem['childrens'] = [];
|
138 |
+
$newItems[] = $newItem;
|
139 |
+
$fn($item['childrens']);
|
140 |
+
}
|
141 |
+
};
|
142 |
+
$fn($items);
|
143 |
+
$items = $newItems;
|
144 |
+
}
|
145 |
+
|
146 |
+
$toggle = ValueHelper::assertBool(ArrayHelper::getValue($attrs, 'toggle', Core::$plugin->settings->getGeneralToggle()));
|
147 |
+
$labelShow = null;
|
148 |
+
$labelHide = null;
|
149 |
+
$hideItems = false;
|
150 |
+
if ($toggle) {
|
151 |
+
$labelShow = ArrayHelper::getValue($attrs, 'labelshow', Core::$plugin->settings->getGeneralLabelShow());
|
152 |
+
$labelHide = ArrayHelper::getValue($attrs, 'labelhide', Core::$plugin->settings->getGeneralLabelHide());
|
153 |
+
$hideItems = ValueHelper::assertBool(ArrayHelper::getValue($attrs, 'hideitems', Core::$plugin->settings->getGeneralHideItems()));
|
154 |
+
}
|
155 |
+
if ($hideItems) {
|
156 |
+
$itemsStyles[] = 'display:none;';
|
157 |
+
}
|
158 |
+
|
159 |
+
$containerOptions = [
|
160 |
+
'class' => ['lwptoc'],
|
161 |
+
'data' => [],
|
162 |
+
];
|
163 |
+
$innerContainerOptions = [
|
164 |
+
'class' => ['lwptoc_i'],
|
165 |
+
];
|
166 |
+
|
167 |
+
// Плавная прокрутка
|
168 |
+
$smoothScroll = ValueHelper::assertBool(ArrayHelper::getValue($attrs, 'smoothscroll', Core::$plugin->settings->getGeneralSmoothScroll()));
|
169 |
+
$containerOptions['data']['smooth-scroll'] = $smoothScroll ? 1 : 0;
|
170 |
+
if ($smoothScroll) {
|
171 |
+
$containerOptions['data']['smooth-scroll-offset'] = (int)ArrayHelper::getValue($attrs, 'smoothscrolloffset', Core::$plugin->settings->getGeneralSmoothScrollOffset());
|
172 |
+
}
|
173 |
+
|
174 |
+
// Выравнивание
|
175 |
+
$float = ArrayHelper::getValue($attrs, 'float', Core::$plugin->settings->getAppearanceFloat());
|
176 |
+
$float = strtolower($float);
|
177 |
+
|
178 |
+
// Ширина
|
179 |
+
$width = ArrayHelper::getValue($attrs, 'width');
|
180 |
+
if ($width === null) {
|
181 |
+
$width = Core::$plugin->settings->getAppearanceWidth();
|
182 |
+
} else {
|
183 |
+
$width = Settings::sanitizeWidth($width);
|
184 |
+
}
|
185 |
+
|
186 |
+
// Опции для выравнивания и ширины
|
187 |
+
if (in_array($float, ['left', 'right', 'center', 'rightwithoutflow']) &&
|
188 |
+
(!in_array($float, ['left', 'right', 'rightwithoutflow']) || $width != 'full')) {
|
189 |
+
$containerOptions['class'][] = 'lwptoc-' . $float;
|
190 |
+
}
|
191 |
+
if ($width != 'full') {
|
192 |
+
if ($width == 'auto') {
|
193 |
+
$containerOptions['class'][] = 'lwptoc-autoWidth';
|
194 |
+
} else {
|
195 |
+
if (in_array($float, ['left', 'right'])) {
|
196 |
+
$containerOptions['style'] = 'width:' . $width;
|
197 |
+
} else {
|
198 |
+
$innerContainerOptions['style'] = 'width:' . $width;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
// Размер шрифта заголовка
|
204 |
+
$titleFontSize = ArrayHelper::getValue($attrs, 'titlefontsize');
|
205 |
+
if ($titleFontSize === null) {
|
206 |
+
$titleFontSize = Core::$plugin->settings->getAppearanceTitleFontSize();
|
207 |
+
} else {
|
208 |
+
$titleFontSize = Settings::sanitizeFontSize($titleFontSize);
|
209 |
+
}
|
210 |
+
if ($titleFontSize != 'default') {
|
211 |
+
$headerStyles[] = 'font-size:' . $titleFontSize . ';';
|
212 |
+
}
|
213 |
+
|
214 |
+
// Толщина шрифта заголовка
|
215 |
+
$titleFontWeight = ArrayHelper::getValue($attrs, 'titlefontweight', Core::$plugin->settings->getAppearanceTitleFontWeight());
|
216 |
+
$titleFontWeight = str_replace(['_', ' ', '-'], '', strtolower($titleFontWeight));
|
217 |
+
if ($titleFontWeight != 'bold' && array_key_exists($titleFontWeight, Core::$plugin->getFontWeightsList())) {
|
218 |
+
$titleStyles[] = 'font-weight:' . Core::$plugin->fontWeightToValue($titleFontWeight) . ';';
|
219 |
+
}
|
220 |
+
|
221 |
+
// Размер шрифта элементов
|
222 |
+
$itemsFontSize = ArrayHelper::getValue($attrs, 'itemsfontsize');
|
223 |
+
if ($itemsFontSize === null) {
|
224 |
+
$itemsFontSize = Core::$plugin->settings->getAppearanceItemsFontSize();
|
225 |
+
} else {
|
226 |
+
$itemsFontSize = Settings::sanitizeFontSize($itemsFontSize);
|
227 |
+
}
|
228 |
+
if ($itemsFontSize == '90%') {
|
229 |
+
$containerOptions['class'][] = 'lwptoc-baseItems';
|
230 |
+
} elseif ($itemsFontSize != 'default') {
|
231 |
+
$itemsStyles[] = 'font-size:' . $itemsFontSize . ';';
|
232 |
+
}
|
233 |
+
|
234 |
+
// Цветовая схема
|
235 |
+
$colorScheme = ArrayHelper::getValue($attrs, 'colorscheme', Core::$plugin->settings->getAppearanceColorScheme());
|
236 |
+
$colorScheme = str_replace(['_', ' ', '-'], '', strtolower($colorScheme));
|
237 |
+
if (array_key_exists($colorScheme, Core::$plugin->getColorSchemesList())) {
|
238 |
+
$containerOptions['class'][] = 'lwptoc-' . $colorScheme;
|
239 |
+
}
|
240 |
+
|
241 |
+
// Запомним цвета для переопределения
|
242 |
+
static::$overrideColors = [];
|
243 |
+
foreach ([
|
244 |
+
'backgroundColor',
|
245 |
+
'borderColor',
|
246 |
+
'titleColor',
|
247 |
+
'linkColor',
|
248 |
+
'hoverLinkColor',
|
249 |
+
'visitedLinkColor',
|
250 |
+
] as $var) {
|
251 |
+
$color = ArrayHelper::getValue($attrs, strtolower($var), Core::$plugin->settings->{'appearance' . ucfirst($var)});
|
252 |
+
$color = Core::$plugin->settings->sanitizeCallbackColor($color);
|
253 |
+
if ($color) {
|
254 |
+
static::$overrideColors[$var] = $color;
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
$before = (string)apply_filters('lwptoc_before', '');
|
259 |
+
$after = (string)apply_filters('lwptoc_after', '');
|
260 |
+
|
261 |
+
if (ValueHelper::assertBool(ArrayHelper::getValue($attrs, 'wrapnoindex', Core::$plugin->settings->getMiscWrapNoindex()))) {
|
262 |
+
$before = '<!--noindex-->' . $before;
|
263 |
+
$after = $after . '<!--/noindex-->';
|
264 |
+
}
|
265 |
+
|
266 |
+
// Вывод
|
267 |
+
static::$currentOutputDepth = -1;
|
268 |
+
return Core::$plugin->front->render('body', [
|
269 |
+
'title' => ArrayHelper::getValue($attrs, 'title', Core::$plugin->settings->getGeneralTitle()),
|
270 |
+
'toggle' => $toggle,
|
271 |
+
'labelShow' => $labelShow,
|
272 |
+
'labelHide' => $labelHide,
|
273 |
+
'hideItems' => $hideItems,
|
274 |
+
'containerOptions' => $containerOptions,
|
275 |
+
'innerContainerOptions' => $innerContainerOptions,
|
276 |
+
'headerStyles' => $headerStyles,
|
277 |
+
'titleStyles' => $titleStyles,
|
278 |
+
'itemsStyles' => $itemsStyles,
|
279 |
+
'items' => $items,
|
280 |
+
'before' => $before,
|
281 |
+
'after' => $after,
|
282 |
+
]);
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* @param int $decimal
|
287 |
+
* @return string
|
288 |
+
*/
|
289 |
+
protected static function decimalToRoman($decimal)
|
290 |
+
{
|
291 |
+
$roman = '';
|
292 |
+
$map = [
|
293 |
+
'M' => 1000,
|
294 |
+
'CM' => 900,
|
295 |
+
'D' => 500,
|
296 |
+
'CD' => 400,
|
297 |
+
'C' => 100,
|
298 |
+
'XC' => 90,
|
299 |
+
'L' => 50,
|
300 |
+
'XL' => 40,
|
301 |
+
'X' => 10,
|
302 |
+
'IX' => 9,
|
303 |
+
'V' => 5,
|
304 |
+
'IV' => 4,
|
305 |
+
'I' => 1
|
306 |
+
];
|
307 |
+
foreach ($map as $number => $value) {
|
308 |
+
$matches = intval($decimal / $value);
|
309 |
+
$roman .= str_repeat($number, $matches);
|
310 |
+
$decimal = $decimal % $value;
|
311 |
+
}
|
312 |
+
return $roman;
|
313 |
+
}
|
314 |
+
}
|
functions.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
use luckywp\tableOfContents\core\Core;
|
|
|
4 |
|
5 |
/**
|
6 |
* @param array $items
|
@@ -11,12 +12,12 @@ function lwptoc_items($items, $echo = true)
|
|
11 |
{
|
12 |
$html = '';
|
13 |
if ($items) {
|
14 |
-
|
15 |
$html = Core::$plugin->front->render('items', [
|
16 |
'items' => $items,
|
17 |
-
'depth' =>
|
18 |
]);
|
19 |
-
|
20 |
}
|
21 |
if ($echo) {
|
22 |
echo $html;
|
1 |
<?php
|
2 |
|
3 |
use luckywp\tableOfContents\core\Core;
|
4 |
+
use luckywp\tableOfContents\front\Toc;
|
5 |
|
6 |
/**
|
7 |
* @param array $items
|
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 |
}
|
22 |
if ($echo) {
|
23 |
echo $html;
|
languages/lwptoc-ru_RU.mo
CHANGED
Binary file
|
languages/lwptoc.pot
CHANGED
@@ -1,9 +1,8 @@
|
|
1 |
-
#, fuzzy
|
2 |
msgid ""
|
3 |
msgstr ""
|
4 |
"Project-Id-Version: \n"
|
5 |
-
"POT-Creation-Date: 2019-
|
6 |
-
"PO-Revision-Date: 2019-
|
7 |
"Last-Translator: \n"
|
8 |
"Language-Team: \n"
|
9 |
"Language: ru_RU\n"
|
@@ -18,141 +17,142 @@ msgstr ""
|
|
18 |
"X-Poedit-SearchPath-0: .\n"
|
19 |
"X-Poedit-SearchPathExcluded-0: plugin/editorBlock/src\n"
|
20 |
|
21 |
-
#: admin/Admin.php:
|
22 |
msgid "Settings"
|
23 |
msgstr ""
|
24 |
|
25 |
-
#: admin/Admin.php:
|
26 |
#: admin/controllers/EditorBlockController.php:65
|
27 |
-
#: admin/controllers/ShortcodeController.php:68
|
28 |
msgid "Table of Contents"
|
29 |
msgstr ""
|
30 |
|
31 |
-
#: admin/Admin.php:
|
32 |
msgid "Edit"
|
33 |
msgstr ""
|
34 |
|
35 |
-
#: admin/Admin.php:
|
36 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
37 |
msgid "Position"
|
38 |
msgstr ""
|
39 |
|
40 |
-
#: admin/Admin.php:
|
41 |
#: config/settings.php:22
|
42 |
msgid "Minimal Count of Headers"
|
43 |
msgstr ""
|
44 |
|
45 |
-
#: admin/Admin.php:
|
46 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
47 |
msgid "Depth"
|
48 |
msgstr ""
|
49 |
|
50 |
-
#: admin/Admin.php:
|
51 |
#: config/settings.php:43
|
52 |
msgid "Hierarchical View"
|
53 |
msgstr ""
|
54 |
|
55 |
-
#: admin/Admin.php:
|
56 |
-
#: admin/Admin.php:
|
57 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
58 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
59 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
60 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
61 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
62 |
msgid "Enabled"
|
63 |
msgstr ""
|
64 |
|
65 |
-
#: admin/Admin.php:
|
66 |
-
#: admin/Admin.php:
|
67 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
68 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
69 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
70 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
71 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
72 |
msgid "Disabled"
|
73 |
msgstr ""
|
74 |
|
75 |
-
#: admin/Admin.php:
|
76 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
77 |
msgid "Numeration"
|
78 |
msgstr ""
|
79 |
|
80 |
-
#: admin/Admin.php:
|
81 |
#: config/settings.php:69
|
82 |
msgid "Title"
|
83 |
msgstr ""
|
84 |
|
85 |
-
#: admin/Admin.php:
|
86 |
#: config/settings.php:75
|
87 |
msgid "Toggle Show/Hide"
|
88 |
msgstr ""
|
89 |
|
90 |
-
#: admin/Admin.php:
|
91 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
92 |
msgid "Label Show"
|
93 |
msgstr ""
|
94 |
|
95 |
-
#: admin/Admin.php:
|
96 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
97 |
msgid "Label Hide"
|
98 |
msgstr ""
|
99 |
|
100 |
-
#: admin/Admin.php:
|
101 |
msgid "Hide Items"
|
102 |
msgstr ""
|
103 |
|
104 |
-
#: admin/Admin.php:
|
105 |
#: config/settings.php:126
|
106 |
msgid "Smooth Scroll"
|
107 |
msgstr ""
|
108 |
|
109 |
-
#: admin/Admin.php:
|
110 |
msgid "Smooth Scroll Offset Top"
|
111 |
msgstr ""
|
112 |
|
113 |
-
#: admin/Admin.php:
|
114 |
#: config/settings.php:162
|
115 |
msgid "Width"
|
116 |
msgstr ""
|
117 |
|
118 |
-
#: admin/Admin.php:
|
119 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
120 |
msgid "Float"
|
121 |
msgstr ""
|
122 |
|
123 |
-
#: admin/Admin.php:
|
124 |
#: config/settings.php:183
|
125 |
msgid "Title Font Size"
|
126 |
msgstr ""
|
127 |
|
128 |
-
#: admin/Admin.php:
|
129 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
130 |
msgid "Title Font Weight"
|
131 |
msgstr ""
|
132 |
|
133 |
-
#: admin/Admin.php:
|
134 |
#: config/settings.php:205
|
135 |
msgid "Items Font Size"
|
136 |
msgstr ""
|
137 |
|
138 |
-
#: admin/Admin.php:
|
139 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
140 |
msgid "Color Scheme"
|
141 |
msgstr ""
|
142 |
|
143 |
-
#: admin/Admin.php:
|
144 |
-
#: config/settings.php:
|
145 |
msgid "Wrap table of contents with <!--noindex--> tag"
|
146 |
msgstr ""
|
147 |
|
148 |
-
#: admin/Admin.php:
|
149 |
msgid "Skip headings"
|
150 |
msgstr ""
|
151 |
|
152 |
#: admin/controllers/EditorBlockController.php:71
|
153 |
#: admin/controllers/ShortcodeController.php:74
|
154 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
155 |
-
#: admin/widgets/metabox/views/box.php:
|
|
|
156 |
msgid "empty"
|
157 |
msgstr ""
|
158 |
|
@@ -164,120 +164,119 @@ msgstr ""
|
|
164 |
msgid "from scheme"
|
165 |
msgstr ""
|
166 |
|
167 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
168 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
169 |
msgid "Cancel"
|
170 |
msgstr ""
|
171 |
|
172 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
173 |
msgid "Customize Table of Contents"
|
174 |
msgstr ""
|
175 |
|
176 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
177 |
msgid "General"
|
178 |
msgstr ""
|
179 |
|
180 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
181 |
msgid "Appearance"
|
182 |
msgstr ""
|
183 |
|
184 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
185 |
msgid "Misc."
|
186 |
msgstr ""
|
187 |
|
188 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
189 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
190 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
191 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
192 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
193 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
194 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
195 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
196 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
197 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
198 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
199 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
200 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
201 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
202 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
203 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
204 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
205 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
206 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
207 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
208 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
209 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
210 |
msgid "default"
|
211 |
msgstr ""
|
212 |
|
213 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
214 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
215 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
216 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
217 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
218 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
219 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
220 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
221 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
222 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
223 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
224 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
225 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
226 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
227 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
228 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
229 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
230 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
231 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
232 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
233 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
234 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
235 |
msgid "Click for override default value"
|
236 |
msgstr ""
|
237 |
|
238 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
239 |
msgid ""
|
240 |
"If the count of headers in the post is less, then table of contents is not "
|
241 |
"displayed."
|
242 |
msgstr ""
|
243 |
|
244 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
245 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
246 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
247 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
248 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
249 |
-
#: admin/widgets/metabox/views/box.php:45 config/settings.php:47
|
250 |
#: config/settings.php:79 config/settings.php:130 config/settings.php:277
|
251 |
msgid "Enable"
|
252 |
msgstr ""
|
253 |
|
254 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
255 |
msgid "Without title"
|
256 |
msgstr ""
|
257 |
|
258 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
259 |
msgid "By default, items of contents will be hidden"
|
260 |
msgstr ""
|
261 |
|
262 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
263 |
msgid "Skip heading by level"
|
264 |
msgstr ""
|
265 |
|
266 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
267 |
msgid "Skip heading by text"
|
268 |
msgstr ""
|
269 |
|
270 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
271 |
msgid ""
|
272 |
"Specify headings (one per line) to be excluded from the table of contents."
|
273 |
msgstr ""
|
274 |
|
275 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
276 |
#, php-format
|
277 |
msgid "Use an asterisk %s as a wildcard to match any text."
|
278 |
msgstr ""
|
279 |
|
280 |
-
#: admin/widgets/customizeModal/views/modal.php:
|
281 |
msgid "Save"
|
282 |
msgstr ""
|
283 |
|
@@ -285,11 +284,11 @@ msgstr ""
|
|
285 |
msgid "Saved!"
|
286 |
msgstr ""
|
287 |
|
288 |
-
#: admin/widgets/fontSizeField/views/widget.php:16 plugin/Plugin.php:
|
289 |
msgid "Default"
|
290 |
msgstr ""
|
291 |
|
292 |
-
#: admin/widgets/fontSizeField/views/widget.php:17 plugin/Plugin.php:
|
293 |
msgid "Custom Value"
|
294 |
msgstr ""
|
295 |
|
@@ -297,35 +296,59 @@ msgstr ""
|
|
297 |
msgid "The table of contents will be automatic added to this post."
|
298 |
msgstr ""
|
299 |
|
300 |
-
#: admin/widgets/metabox/views/box.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
msgid "Overridden settings:"
|
302 |
msgstr ""
|
303 |
|
304 |
-
#: admin/widgets/metabox/views/box.php:
|
|
|
305 |
msgid "Customize"
|
306 |
msgstr ""
|
307 |
|
308 |
-
#: admin/widgets/metabox/views/box.php:
|
309 |
-
msgid "Disable"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
msgstr ""
|
311 |
|
312 |
-
#: admin/widgets/metabox/views/box.php:
|
313 |
-
msgid "Click \"Enable\" for automatic add table of contents to this post."
|
|
|
|
|
|
|
|
|
314 |
msgstr ""
|
315 |
|
316 |
#: config/settings.php:65
|
317 |
msgid "Header"
|
318 |
msgstr ""
|
319 |
|
320 |
-
#: config/settings.php:71 plugin/Settings.php:
|
321 |
msgid "Contents"
|
322 |
msgstr ""
|
323 |
|
324 |
-
#: config/settings.php:94 plugin/Settings.php:
|
325 |
msgid "show"
|
326 |
msgstr ""
|
327 |
|
328 |
-
#: config/settings.php:105 plugin/Settings.php:
|
329 |
msgid "hide"
|
330 |
msgstr ""
|
331 |
|
@@ -377,22 +400,38 @@ msgstr ""
|
|
377 |
msgid "Post Types"
|
378 |
msgstr ""
|
379 |
|
|
|
|
|
|
|
|
|
380 |
#: config/settings.php:320
|
|
|
|
|
|
|
|
|
381 |
msgid "Hash Format"
|
382 |
msgstr ""
|
383 |
|
384 |
-
#: config/settings.php:
|
385 |
msgid "Skip Headings"
|
386 |
msgstr ""
|
387 |
|
388 |
-
#: config/settings.php:
|
389 |
msgid "By Level"
|
390 |
msgstr ""
|
391 |
|
392 |
-
#: config/settings.php:
|
393 |
msgid "By Text"
|
394 |
msgstr ""
|
395 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
#: core/admin/AdminController.php:46
|
397 |
msgid "Sorry, you are not allowed to access this page."
|
398 |
msgstr ""
|
@@ -409,135 +448,135 @@ msgstr ""
|
|
409 |
msgid "{attribute} cannot be blank."
|
410 |
msgstr ""
|
411 |
|
412 |
-
#: plugin/Plugin.php:
|
413 |
msgid "Without numeration"
|
414 |
msgstr ""
|
415 |
|
416 |
-
#: plugin/Plugin.php:
|
417 |
msgid "Decimal numbers (nested)"
|
418 |
msgstr ""
|
419 |
|
420 |
-
#: plugin/Plugin.php:
|
421 |
msgid "Decimal numbers"
|
422 |
msgstr ""
|
423 |
|
424 |
-
#: plugin/Plugin.php:
|
425 |
msgid "Roman numbers (nested)"
|
426 |
msgstr ""
|
427 |
|
428 |
-
#: plugin/Plugin.php:
|
429 |
msgid "Roman numbers"
|
430 |
msgstr ""
|
431 |
|
432 |
-
#: plugin/Plugin.php:
|
433 |
msgid "Before first heading"
|
434 |
msgstr ""
|
435 |
|
436 |
-
#: plugin/Plugin.php:
|
437 |
msgid "After first heading"
|
438 |
msgstr ""
|
439 |
|
440 |
-
#: plugin/Plugin.php:
|
441 |
msgid "After first block (paragraph, list or heading)"
|
442 |
msgstr ""
|
443 |
|
444 |
-
#: plugin/Plugin.php:
|
445 |
msgid "Top"
|
446 |
msgstr ""
|
447 |
|
448 |
-
#: plugin/Plugin.php:
|
449 |
msgid "Bottom"
|
450 |
msgstr ""
|
451 |
|
452 |
-
#: plugin/Plugin.php:
|
453 |
msgid "Thin"
|
454 |
msgstr ""
|
455 |
|
456 |
-
#: plugin/Plugin.php:
|
457 |
msgid "Extra Light"
|
458 |
msgstr ""
|
459 |
|
460 |
-
#: plugin/Plugin.php:
|
461 |
msgid "Light"
|
462 |
msgstr ""
|
463 |
|
464 |
-
#: plugin/Plugin.php:
|
465 |
msgid "Normal"
|
466 |
msgstr ""
|
467 |
|
468 |
-
#: plugin/Plugin.php:
|
469 |
msgid "Medium"
|
470 |
msgstr ""
|
471 |
|
472 |
-
#: plugin/Plugin.php:
|
473 |
msgid "Semi Bold"
|
474 |
msgstr ""
|
475 |
|
476 |
-
#: plugin/Plugin.php:
|
477 |
msgid "Bold"
|
478 |
msgstr ""
|
479 |
|
480 |
-
#: plugin/Plugin.php:
|
481 |
msgid "Extra Bold"
|
482 |
msgstr ""
|
483 |
|
484 |
-
#: plugin/Plugin.php:
|
485 |
msgid "Heavy"
|
486 |
msgstr ""
|
487 |
|
488 |
-
#: plugin/Plugin.php:
|
489 |
msgid "None"
|
490 |
msgstr ""
|
491 |
|
492 |
-
#: plugin/Plugin.php:
|
493 |
msgid "Left"
|
494 |
msgstr ""
|
495 |
|
496 |
-
#: plugin/Plugin.php:
|
497 |
msgid "Right"
|
498 |
msgstr ""
|
499 |
|
500 |
-
#: plugin/Plugin.php:
|
501 |
msgid "Right without flow"
|
502 |
msgstr ""
|
503 |
|
504 |
-
#: plugin/Plugin.php:
|
505 |
msgid "Center"
|
506 |
msgstr ""
|
507 |
|
508 |
-
#: plugin/Plugin.php:
|
509 |
msgid "Light Colors"
|
510 |
msgstr ""
|
511 |
|
512 |
-
#: plugin/Plugin.php:
|
513 |
msgid "Dark Colors"
|
514 |
msgstr ""
|
515 |
|
516 |
-
#: plugin/Plugin.php:
|
517 |
msgid "White"
|
518 |
msgstr ""
|
519 |
|
520 |
-
#: plugin/Plugin.php:
|
521 |
msgid "Transparent"
|
522 |
msgstr ""
|
523 |
|
524 |
-
#: plugin/Plugin.php:
|
525 |
msgid "As heading (#Example_Heading_Text)"
|
526 |
msgstr ""
|
527 |
|
528 |
-
#: plugin/Plugin.php:
|
529 |
msgid "Counter (#lpwtoc1, #lwptoc2, …)"
|
530 |
msgstr ""
|
531 |
|
532 |
-
#: plugin/Plugin.php:
|
533 |
msgid "Auto"
|
534 |
msgstr ""
|
535 |
|
536 |
-
#: plugin/Plugin.php:
|
537 |
msgid "Full Width"
|
538 |
msgstr ""
|
539 |
|
540 |
-
#: plugin/Plugin.php:
|
541 |
msgid ""
|
542 |
"Creates a table of contents for your posts/pages. Works automatically or "
|
543 |
"manually (via shortcode or Gutenberg block)."
|
|
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: \n"
|
4 |
+
"POT-Creation-Date: 2019-06-01 18:08+0300\n"
|
5 |
+
"PO-Revision-Date: 2019-06-01 18:09+0300\n"
|
6 |
"Last-Translator: \n"
|
7 |
"Language-Team: \n"
|
8 |
"Language: ru_RU\n"
|
17 |
"X-Poedit-SearchPath-0: .\n"
|
18 |
"X-Poedit-SearchPathExcluded-0: plugin/editorBlock/src\n"
|
19 |
|
20 |
+
#: admin/Admin.php:33
|
21 |
msgid "Settings"
|
22 |
msgstr ""
|
23 |
|
24 |
+
#: admin/Admin.php:49 admin/Admin.php:50 admin/Admin.php:70 admin/Admin.php:97
|
25 |
#: admin/controllers/EditorBlockController.php:65
|
26 |
+
#: admin/controllers/ShortcodeController.php:68 plugin/WpWidget.php:20
|
27 |
msgid "Table of Contents"
|
28 |
msgstr ""
|
29 |
|
30 |
+
#: admin/Admin.php:98
|
31 |
msgid "Edit"
|
32 |
msgstr ""
|
33 |
|
34 |
+
#: admin/Admin.php:125 admin/forms/CustomizeForm.php:235
|
35 |
+
#: admin/widgets/customizeModal/views/modal.php:50 config/settings.php:285
|
36 |
msgid "Position"
|
37 |
msgstr ""
|
38 |
|
39 |
+
#: admin/Admin.php:128 admin/widgets/customizeModal/views/modal.php:73
|
40 |
#: config/settings.php:22
|
41 |
msgid "Minimal Count of Headers"
|
42 |
msgstr ""
|
43 |
|
44 |
+
#: admin/Admin.php:131 admin/forms/CustomizeForm.php:231
|
45 |
+
#: admin/widgets/customizeModal/views/modal.php:96 config/settings.php:34
|
46 |
msgid "Depth"
|
47 |
msgstr ""
|
48 |
|
49 |
+
#: admin/Admin.php:134 admin/widgets/customizeModal/views/modal.php:118
|
50 |
#: config/settings.php:43
|
51 |
msgid "Hierarchical View"
|
52 |
msgstr ""
|
53 |
|
54 |
+
#: admin/Admin.php:134 admin/Admin.php:143 admin/Admin.php:152
|
55 |
+
#: admin/Admin.php:155 admin/Admin.php:191
|
56 |
+
#: admin/widgets/customizeModal/views/modal.php:134
|
57 |
+
#: admin/widgets/customizeModal/views/modal.php:205
|
58 |
+
#: admin/widgets/customizeModal/views/modal.php:268
|
59 |
+
#: admin/widgets/customizeModal/views/modal.php:291
|
60 |
+
#: admin/widgets/customizeModal/views/modal.php:508
|
61 |
msgid "Enabled"
|
62 |
msgstr ""
|
63 |
|
64 |
+
#: admin/Admin.php:134 admin/Admin.php:143 admin/Admin.php:152
|
65 |
+
#: admin/Admin.php:155 admin/Admin.php:191
|
66 |
+
#: admin/widgets/customizeModal/views/modal.php:134
|
67 |
+
#: admin/widgets/customizeModal/views/modal.php:205
|
68 |
+
#: admin/widgets/customizeModal/views/modal.php:268
|
69 |
+
#: admin/widgets/customizeModal/views/modal.php:291
|
70 |
+
#: admin/widgets/customizeModal/views/modal.php:508
|
71 |
msgid "Disabled"
|
72 |
msgstr ""
|
73 |
|
74 |
+
#: admin/Admin.php:137 admin/forms/CustomizeForm.php:232
|
75 |
+
#: admin/widgets/customizeModal/views/modal.php:141 config/settings.php:54
|
76 |
msgid "Numeration"
|
77 |
msgstr ""
|
78 |
|
79 |
+
#: admin/Admin.php:140 admin/widgets/customizeModal/views/modal.php:163
|
80 |
#: config/settings.php:69
|
81 |
msgid "Title"
|
82 |
msgstr ""
|
83 |
|
84 |
+
#: admin/Admin.php:143 admin/widgets/customizeModal/views/modal.php:189
|
85 |
#: config/settings.php:75
|
86 |
msgid "Toggle Show/Hide"
|
87 |
msgstr ""
|
88 |
|
89 |
+
#: admin/Admin.php:146 admin/forms/CustomizeForm.php:233
|
90 |
+
#: admin/widgets/customizeModal/views/modal.php:212 config/settings.php:87
|
91 |
msgid "Label Show"
|
92 |
msgstr ""
|
93 |
|
94 |
+
#: admin/Admin.php:149 admin/forms/CustomizeForm.php:234
|
95 |
+
#: admin/widgets/customizeModal/views/modal.php:232 config/settings.php:98
|
96 |
msgid "Label Hide"
|
97 |
msgstr ""
|
98 |
|
99 |
+
#: admin/Admin.php:152
|
100 |
msgid "Hide Items"
|
101 |
msgstr ""
|
102 |
|
103 |
+
#: admin/Admin.php:155 admin/widgets/customizeModal/views/modal.php:275
|
104 |
#: config/settings.php:126
|
105 |
msgid "Smooth Scroll"
|
106 |
msgstr ""
|
107 |
|
108 |
+
#: admin/Admin.php:158 admin/widgets/customizeModal/views/modal.php:298
|
109 |
msgid "Smooth Scroll Offset Top"
|
110 |
msgstr ""
|
111 |
|
112 |
+
#: admin/Admin.php:161 admin/widgets/customizeModal/views/modal.php:322
|
113 |
#: config/settings.php:162
|
114 |
msgid "Width"
|
115 |
msgstr ""
|
116 |
|
117 |
+
#: admin/Admin.php:164 admin/forms/CustomizeForm.php:236
|
118 |
+
#: admin/widgets/customizeModal/views/modal.php:345 config/settings.php:174
|
119 |
msgid "Float"
|
120 |
msgstr ""
|
121 |
|
122 |
+
#: admin/Admin.php:167 admin/widgets/customizeModal/views/modal.php:367
|
123 |
#: config/settings.php:183
|
124 |
msgid "Title Font Size"
|
125 |
msgstr ""
|
126 |
|
127 |
+
#: admin/Admin.php:170 admin/forms/CustomizeForm.php:237
|
128 |
+
#: admin/widgets/customizeModal/views/modal.php:391 config/settings.php:196
|
129 |
msgid "Title Font Weight"
|
130 |
msgstr ""
|
131 |
|
132 |
+
#: admin/Admin.php:173 admin/widgets/customizeModal/views/modal.php:413
|
133 |
#: config/settings.php:205
|
134 |
msgid "Items Font Size"
|
135 |
msgstr ""
|
136 |
|
137 |
+
#: admin/Admin.php:176 admin/forms/CustomizeForm.php:238
|
138 |
+
#: admin/widgets/customizeModal/views/modal.php:437 config/settings.php:218
|
139 |
msgid "Color Scheme"
|
140 |
msgstr ""
|
141 |
|
142 |
+
#: admin/Admin.php:191 admin/widgets/customizeModal/views/modal.php:492
|
143 |
+
#: config/settings.php:352
|
144 |
msgid "Wrap table of contents with <!--noindex--> tag"
|
145 |
msgstr ""
|
146 |
|
147 |
+
#: admin/Admin.php:194 admin/Admin.php:197
|
148 |
msgid "Skip headings"
|
149 |
msgstr ""
|
150 |
|
151 |
#: admin/controllers/EditorBlockController.php:71
|
152 |
#: admin/controllers/ShortcodeController.php:74
|
153 |
+
#: admin/widgets/customizeModal/views/modal.php:567
|
154 |
+
#: admin/widgets/metabox/views/box.php:33
|
155 |
+
#: admin/widgets/widget/views/_override.php:18
|
156 |
msgid "empty"
|
157 |
msgstr ""
|
158 |
|
164 |
msgid "from scheme"
|
165 |
msgstr ""
|
166 |
|
167 |
+
#: admin/widgets/customizeModal/views/modal.php:25
|
168 |
+
#: admin/widgets/customizeModal/views/modal.php:580
|
169 |
msgid "Cancel"
|
170 |
msgstr ""
|
171 |
|
172 |
+
#: admin/widgets/customizeModal/views/modal.php:26
|
173 |
msgid "Customize Table of Contents"
|
174 |
msgstr ""
|
175 |
|
176 |
+
#: admin/widgets/customizeModal/views/modal.php:40 config/settings.php:16
|
177 |
msgid "General"
|
178 |
msgstr ""
|
179 |
|
180 |
+
#: admin/widgets/customizeModal/views/modal.php:41 config/settings.php:156
|
181 |
msgid "Appearance"
|
182 |
msgstr ""
|
183 |
|
184 |
+
#: admin/widgets/customizeModal/views/modal.php:42 config/settings.php:334
|
185 |
msgid "Misc."
|
186 |
msgstr ""
|
187 |
|
188 |
+
#: admin/widgets/customizeModal/views/modal.php:51
|
189 |
+
#: admin/widgets/customizeModal/views/modal.php:74
|
190 |
+
#: admin/widgets/customizeModal/views/modal.php:97
|
191 |
+
#: admin/widgets/customizeModal/views/modal.php:119
|
192 |
+
#: admin/widgets/customizeModal/views/modal.php:142
|
193 |
+
#: admin/widgets/customizeModal/views/modal.php:164
|
194 |
+
#: admin/widgets/customizeModal/views/modal.php:190
|
195 |
+
#: admin/widgets/customizeModal/views/modal.php:213
|
196 |
+
#: admin/widgets/customizeModal/views/modal.php:233
|
197 |
+
#: admin/widgets/customizeModal/views/modal.php:253
|
198 |
+
#: admin/widgets/customizeModal/views/modal.php:276
|
199 |
+
#: admin/widgets/customizeModal/views/modal.php:299
|
200 |
+
#: admin/widgets/customizeModal/views/modal.php:323
|
201 |
+
#: admin/widgets/customizeModal/views/modal.php:346
|
202 |
+
#: admin/widgets/customizeModal/views/modal.php:368
|
203 |
+
#: admin/widgets/customizeModal/views/modal.php:392
|
204 |
+
#: admin/widgets/customizeModal/views/modal.php:414
|
205 |
+
#: admin/widgets/customizeModal/views/modal.php:438
|
206 |
+
#: admin/widgets/customizeModal/views/modal.php:468
|
207 |
+
#: admin/widgets/customizeModal/views/modal.php:493
|
208 |
+
#: admin/widgets/customizeModal/views/modal.php:516
|
209 |
+
#: admin/widgets/customizeModal/views/modal.php:539
|
210 |
msgid "default"
|
211 |
msgstr ""
|
212 |
|
213 |
+
#: admin/widgets/customizeModal/views/modal.php:54
|
214 |
+
#: admin/widgets/customizeModal/views/modal.php:77
|
215 |
+
#: admin/widgets/customizeModal/views/modal.php:100
|
216 |
+
#: admin/widgets/customizeModal/views/modal.php:122
|
217 |
+
#: admin/widgets/customizeModal/views/modal.php:145
|
218 |
+
#: admin/widgets/customizeModal/views/modal.php:167
|
219 |
+
#: admin/widgets/customizeModal/views/modal.php:193
|
220 |
+
#: admin/widgets/customizeModal/views/modal.php:216
|
221 |
+
#: admin/widgets/customizeModal/views/modal.php:236
|
222 |
+
#: admin/widgets/customizeModal/views/modal.php:256
|
223 |
+
#: admin/widgets/customizeModal/views/modal.php:279
|
224 |
+
#: admin/widgets/customizeModal/views/modal.php:302
|
225 |
+
#: admin/widgets/customizeModal/views/modal.php:326
|
226 |
+
#: admin/widgets/customizeModal/views/modal.php:349
|
227 |
+
#: admin/widgets/customizeModal/views/modal.php:371
|
228 |
+
#: admin/widgets/customizeModal/views/modal.php:395
|
229 |
+
#: admin/widgets/customizeModal/views/modal.php:417
|
230 |
+
#: admin/widgets/customizeModal/views/modal.php:441
|
231 |
+
#: admin/widgets/customizeModal/views/modal.php:471
|
232 |
+
#: admin/widgets/customizeModal/views/modal.php:496
|
233 |
+
#: admin/widgets/customizeModal/views/modal.php:519
|
234 |
+
#: admin/widgets/customizeModal/views/modal.php:542
|
235 |
msgid "Click for override default value"
|
236 |
msgstr ""
|
237 |
|
238 |
+
#: admin/widgets/customizeModal/views/modal.php:86 config/settings.php:30
|
239 |
msgid ""
|
240 |
"If the count of headers in the post is less, then table of contents is not "
|
241 |
"displayed."
|
242 |
msgstr ""
|
243 |
|
244 |
+
#: admin/widgets/customizeModal/views/modal.php:127
|
245 |
+
#: admin/widgets/customizeModal/views/modal.php:198
|
246 |
+
#: admin/widgets/customizeModal/views/modal.php:261
|
247 |
+
#: admin/widgets/customizeModal/views/modal.php:284
|
248 |
+
#: admin/widgets/customizeModal/views/modal.php:501 config/settings.php:47
|
|
|
249 |
#: config/settings.php:79 config/settings.php:130 config/settings.php:277
|
250 |
msgid "Enable"
|
251 |
msgstr ""
|
252 |
|
253 |
+
#: admin/widgets/customizeModal/views/modal.php:178
|
254 |
msgid "Without title"
|
255 |
msgstr ""
|
256 |
|
257 |
+
#: admin/widgets/customizeModal/views/modal.php:252 config/settings.php:113
|
258 |
msgid "By default, items of contents will be hidden"
|
259 |
msgstr ""
|
260 |
|
261 |
+
#: admin/widgets/customizeModal/views/modal.php:515
|
262 |
msgid "Skip heading by level"
|
263 |
msgstr ""
|
264 |
|
265 |
+
#: admin/widgets/customizeModal/views/modal.php:538
|
266 |
msgid "Skip heading by text"
|
267 |
msgstr ""
|
268 |
|
269 |
+
#: admin/widgets/customizeModal/views/modal.php:552 config/settings.php:381
|
270 |
msgid ""
|
271 |
"Specify headings (one per line) to be excluded from the table of contents."
|
272 |
msgstr ""
|
273 |
|
274 |
+
#: admin/widgets/customizeModal/views/modal.php:555 config/settings.php:384
|
275 |
#, php-format
|
276 |
msgid "Use an asterisk %s as a wildcard to match any text."
|
277 |
msgstr ""
|
278 |
|
279 |
+
#: admin/widgets/customizeModal/views/modal.php:583
|
280 |
msgid "Save"
|
281 |
msgstr ""
|
282 |
|
284 |
msgid "Saved!"
|
285 |
msgstr ""
|
286 |
|
287 |
+
#: admin/widgets/fontSizeField/views/widget.php:16 plugin/Plugin.php:262
|
288 |
msgid "Default"
|
289 |
msgstr ""
|
290 |
|
291 |
+
#: admin/widgets/fontSizeField/views/widget.php:17 plugin/Plugin.php:227
|
292 |
msgid "Custom Value"
|
293 |
msgstr ""
|
294 |
|
296 |
msgid "The table of contents will be automatic added to this post."
|
297 |
msgstr ""
|
298 |
|
299 |
+
#: admin/widgets/metabox/views/box.php:18
|
300 |
+
msgid ""
|
301 |
+
"The headings will be processing in this post for use in Table of Contens in "
|
302 |
+
"widget or custom shortcode."
|
303 |
+
msgstr ""
|
304 |
+
|
305 |
+
#: admin/widgets/metabox/views/box.php:27
|
306 |
+
#: admin/widgets/widget/views/_override.php:12
|
307 |
msgid "Overridden settings:"
|
308 |
msgstr ""
|
309 |
|
310 |
+
#: admin/widgets/metabox/views/box.php:39
|
311 |
+
#: admin/widgets/widget/views/form.php:19
|
312 |
msgid "Customize"
|
313 |
msgstr ""
|
314 |
|
315 |
+
#: admin/widgets/metabox/views/box.php:44
|
316 |
+
msgid "Disable TOC"
|
317 |
+
msgstr ""
|
318 |
+
|
319 |
+
#: admin/widgets/metabox/views/box.php:49
|
320 |
+
msgid "Disable Processing"
|
321 |
+
msgstr ""
|
322 |
+
|
323 |
+
#: admin/widgets/metabox/views/box.php:61
|
324 |
+
msgid "Click \"Enable Processing\" for headings processing in this post."
|
325 |
+
msgstr ""
|
326 |
+
|
327 |
+
#: admin/widgets/metabox/views/box.php:64
|
328 |
+
msgid "Enable Processing"
|
329 |
msgstr ""
|
330 |
|
331 |
+
#: admin/widgets/metabox/views/box.php:72
|
332 |
+
msgid "Click \"Enable TOC\" for automatic add table of contents to this post."
|
333 |
+
msgstr ""
|
334 |
+
|
335 |
+
#: admin/widgets/metabox/views/box.php:75
|
336 |
+
msgid "Enable TOC"
|
337 |
msgstr ""
|
338 |
|
339 |
#: config/settings.php:65
|
340 |
msgid "Header"
|
341 |
msgstr ""
|
342 |
|
343 |
+
#: config/settings.php:71 plugin/Settings.php:88
|
344 |
msgid "Contents"
|
345 |
msgstr ""
|
346 |
|
347 |
+
#: config/settings.php:94 plugin/Settings.php:104
|
348 |
msgid "show"
|
349 |
msgstr ""
|
350 |
|
351 |
+
#: config/settings.php:105 plugin/Settings.php:112
|
352 |
msgid "hide"
|
353 |
msgstr ""
|
354 |
|
400 |
msgid "Post Types"
|
401 |
msgstr ""
|
402 |
|
403 |
+
#: config/settings.php:315
|
404 |
+
msgid "Processing Headings"
|
405 |
+
msgstr ""
|
406 |
+
|
407 |
#: config/settings.php:320
|
408 |
+
msgid "Always for Post Types"
|
409 |
+
msgstr ""
|
410 |
+
|
411 |
+
#: config/settings.php:339
|
412 |
msgid "Hash Format"
|
413 |
msgstr ""
|
414 |
|
415 |
+
#: config/settings.php:360
|
416 |
msgid "Skip Headings"
|
417 |
msgstr ""
|
418 |
|
419 |
+
#: config/settings.php:363
|
420 |
msgid "By Level"
|
421 |
msgstr ""
|
422 |
|
423 |
+
#: config/settings.php:373
|
424 |
msgid "By Text"
|
425 |
msgstr ""
|
426 |
|
427 |
+
#: config/settings.php:396
|
428 |
+
msgid "Post Settings"
|
429 |
+
msgstr ""
|
430 |
+
|
431 |
+
#: config/settings.php:399
|
432 |
+
msgid "Show Panel \"Table of Contents\" in Post Types"
|
433 |
+
msgstr ""
|
434 |
+
|
435 |
#: core/admin/AdminController.php:46
|
436 |
msgid "Sorry, you are not allowed to access this page."
|
437 |
msgstr ""
|
448 |
msgid "{attribute} cannot be blank."
|
449 |
msgstr ""
|
450 |
|
451 |
+
#: plugin/Plugin.php:97
|
452 |
msgid "Without numeration"
|
453 |
msgstr ""
|
454 |
|
455 |
+
#: plugin/Plugin.php:98
|
456 |
msgid "Decimal numbers (nested)"
|
457 |
msgstr ""
|
458 |
|
459 |
+
#: plugin/Plugin.php:99
|
460 |
msgid "Decimal numbers"
|
461 |
msgstr ""
|
462 |
|
463 |
+
#: plugin/Plugin.php:100
|
464 |
msgid "Roman numbers (nested)"
|
465 |
msgstr ""
|
466 |
|
467 |
+
#: plugin/Plugin.php:101
|
468 |
msgid "Roman numbers"
|
469 |
msgstr ""
|
470 |
|
471 |
+
#: plugin/Plugin.php:111
|
472 |
msgid "Before first heading"
|
473 |
msgstr ""
|
474 |
|
475 |
+
#: plugin/Plugin.php:112
|
476 |
msgid "After first heading"
|
477 |
msgstr ""
|
478 |
|
479 |
+
#: plugin/Plugin.php:113
|
480 |
msgid "After first block (paragraph, list or heading)"
|
481 |
msgstr ""
|
482 |
|
483 |
+
#: plugin/Plugin.php:114
|
484 |
msgid "Top"
|
485 |
msgstr ""
|
486 |
|
487 |
+
#: plugin/Plugin.php:115
|
488 |
msgid "Bottom"
|
489 |
msgstr ""
|
490 |
|
491 |
+
#: plugin/Plugin.php:149
|
492 |
msgid "Thin"
|
493 |
msgstr ""
|
494 |
|
495 |
+
#: plugin/Plugin.php:150
|
496 |
msgid "Extra Light"
|
497 |
msgstr ""
|
498 |
|
499 |
+
#: plugin/Plugin.php:151
|
500 |
msgid "Light"
|
501 |
msgstr ""
|
502 |
|
503 |
+
#: plugin/Plugin.php:152
|
504 |
msgid "Normal"
|
505 |
msgstr ""
|
506 |
|
507 |
+
#: plugin/Plugin.php:153
|
508 |
msgid "Medium"
|
509 |
msgstr ""
|
510 |
|
511 |
+
#: plugin/Plugin.php:154
|
512 |
msgid "Semi Bold"
|
513 |
msgstr ""
|
514 |
|
515 |
+
#: plugin/Plugin.php:155
|
516 |
msgid "Bold"
|
517 |
msgstr ""
|
518 |
|
519 |
+
#: plugin/Plugin.php:156
|
520 |
msgid "Extra Bold"
|
521 |
msgstr ""
|
522 |
|
523 |
+
#: plugin/Plugin.php:157
|
524 |
msgid "Heavy"
|
525 |
msgstr ""
|
526 |
|
527 |
+
#: plugin/Plugin.php:186 plugin/Plugin.php:313
|
528 |
msgid "None"
|
529 |
msgstr ""
|
530 |
|
531 |
+
#: plugin/Plugin.php:187
|
532 |
msgid "Left"
|
533 |
msgstr ""
|
534 |
|
535 |
+
#: plugin/Plugin.php:188
|
536 |
msgid "Right"
|
537 |
msgstr ""
|
538 |
|
539 |
+
#: plugin/Plugin.php:189
|
540 |
msgid "Right without flow"
|
541 |
msgstr ""
|
542 |
|
543 |
+
#: plugin/Plugin.php:190
|
544 |
msgid "Center"
|
545 |
msgstr ""
|
546 |
|
547 |
+
#: plugin/Plugin.php:200
|
548 |
msgid "Light Colors"
|
549 |
msgstr ""
|
550 |
|
551 |
+
#: plugin/Plugin.php:201
|
552 |
msgid "Dark Colors"
|
553 |
msgstr ""
|
554 |
|
555 |
+
#: plugin/Plugin.php:202
|
556 |
msgid "White"
|
557 |
msgstr ""
|
558 |
|
559 |
+
#: plugin/Plugin.php:203
|
560 |
msgid "Transparent"
|
561 |
msgstr ""
|
562 |
|
563 |
+
#: plugin/Plugin.php:213
|
564 |
msgid "As heading (#Example_Heading_Text)"
|
565 |
msgstr ""
|
566 |
|
567 |
+
#: plugin/Plugin.php:214
|
568 |
msgid "Counter (#lpwtoc1, #lwptoc2, …)"
|
569 |
msgstr ""
|
570 |
|
571 |
+
#: plugin/Plugin.php:225
|
572 |
msgid "Auto"
|
573 |
msgstr ""
|
574 |
|
575 |
+
#: plugin/Plugin.php:226
|
576 |
msgid "Full Width"
|
577 |
msgstr ""
|
578 |
|
579 |
+
#: plugin/Plugin.php:389
|
580 |
msgid ""
|
581 |
"Creates a table of contents for your posts/pages. Works automatically or "
|
582 |
"manually (via shortcode or Gutenberg block)."
|
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 or Gutenberg block).
|
6 |
-
Version: 1.
|
7 |
Author: LuckyWP
|
8 |
Author URI: https://theluckywp.com/
|
9 |
Text Domain: lwptoc
|
@@ -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 or Gutenberg block).
|
6 |
+
Version: 1.4
|
7 |
Author: LuckyWP
|
8 |
Author URI: https://theluckywp.com/
|
9 |
Text Domain: lwptoc
|
29 |
$lwptocAutoloader->addNamespace('luckywp\tableOfContents', __DIR__);
|
30 |
|
31 |
$config = require(__DIR__ . '/config/plugin.php');
|
32 |
+
(new \luckywp\tableOfContents\plugin\Plugin($config))->run('1.4', __FILE__, 'lwptoc_');
|
33 |
|
34 |
require_once __DIR__ . '/functions.php';
|
plugin/Plugin.php
CHANGED
@@ -35,6 +35,29 @@ use WP_Post_Type;
|
|
35 |
class Plugin extends BasePlugin
|
36 |
{
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
private $_postTypes;
|
39 |
|
40 |
/**
|
35 |
class Plugin extends BasePlugin
|
36 |
{
|
37 |
|
38 |
+
/**
|
39 |
+
* @var bool
|
40 |
+
*/
|
41 |
+
public $isTheContent = false;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Инициализация
|
45 |
+
*/
|
46 |
+
public function init()
|
47 |
+
{
|
48 |
+
add_filter('the_content', function ($content) {
|
49 |
+
$this->isTheContent = true;
|
50 |
+
return $content;
|
51 |
+
}, 1);
|
52 |
+
add_filter('the_content', function ($content) {
|
53 |
+
$this->isTheContent = false;
|
54 |
+
return $content;
|
55 |
+
}, 10000);
|
56 |
+
add_action('widgets_init', function () {
|
57 |
+
register_widget(WpWidget::class);
|
58 |
+
});
|
59 |
+
}
|
60 |
+
|
61 |
private $_postTypes;
|
62 |
|
63 |
/**
|
plugin/PostSettings.php
CHANGED
@@ -12,7 +12,22 @@ class PostSettings extends BaseObject
|
|
12 |
/**
|
13 |
* @var bool
|
14 |
*/
|
15 |
-
public $enabled
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
/**
|
18 |
* @var int|null
|
@@ -160,11 +175,15 @@ class PostSettings extends BaseObject
|
|
160 |
public function __construct($postId)
|
161 |
{
|
162 |
parent::__construct();
|
163 |
-
|
|
|
|
|
|
|
164 |
$this->postId = $postId;
|
165 |
$data = get_post_meta($postId, '_lwptoc_settings', true);
|
166 |
if ($data && is_array($data)) {
|
167 |
-
$this->enabled = ArrayHelper::getValue($data, 'enabled',
|
|
|
168 |
$this->min = ArrayHelper::getValue($data, 'min');
|
169 |
$this->depth = ArrayHelper::getValue($data, 'depth');
|
170 |
$this->hierarchical = ArrayHelper::getValue($data, 'hierarchical');
|
@@ -280,8 +299,12 @@ class PostSettings extends BaseObject
|
|
280 |
if ($this->skipHeadingText !== null) {
|
281 |
$data['skipHeadingText'] = wp_slash($this->skipHeadingText);
|
282 |
}
|
283 |
-
if ($data ||
|
|
|
|
|
|
|
284 |
$data['enabled'] = $this->enabled;
|
|
|
285 |
update_post_meta($this->postId, '_lwptoc_settings', $data);
|
286 |
} else {
|
287 |
delete_post_meta($this->postId, '_lwptoc_settings');
|
12 |
/**
|
13 |
* @var bool
|
14 |
*/
|
15 |
+
public $enabled;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var bool
|
19 |
+
*/
|
20 |
+
protected $defaultEnabled;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @var bool
|
24 |
+
*/
|
25 |
+
public $processHeadings;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var bool
|
29 |
+
*/
|
30 |
+
protected $defaulProcessHeadings;
|
31 |
|
32 |
/**
|
33 |
* @var int|null
|
175 |
public function __construct($postId)
|
176 |
{
|
177 |
parent::__construct();
|
178 |
+
$postType = get_post_type($postId);
|
179 |
+
$this->enabled = $this->defaultEnabled = Core::$plugin->settings->getAutoInsertEnable() ? in_array($postType, Core::$plugin->settings->getAutoInsertPostTypes()) : false;
|
180 |
+
$this->processHeadings = $this->defaulProcessHeadings = in_array($postType, Core::$plugin->settings->getProcessingHeadingsAlwaysForPostTypes());
|
181 |
+
if (in_array($postType, Core::$plugin->admin->getMetaboxPostTypes())) {
|
182 |
$this->postId = $postId;
|
183 |
$data = get_post_meta($postId, '_lwptoc_settings', true);
|
184 |
if ($data && is_array($data)) {
|
185 |
+
$this->enabled = ArrayHelper::getValue($data, 'enabled', $this->enabled);
|
186 |
+
$this->processHeadings = ArrayHelper::getValue($data, 'processHeadings', $this->processHeadings);
|
187 |
$this->min = ArrayHelper::getValue($data, 'min');
|
188 |
$this->depth = ArrayHelper::getValue($data, 'depth');
|
189 |
$this->hierarchical = ArrayHelper::getValue($data, 'hierarchical');
|
299 |
if ($this->skipHeadingText !== null) {
|
300 |
$data['skipHeadingText'] = wp_slash($this->skipHeadingText);
|
301 |
}
|
302 |
+
if ($data ||
|
303 |
+
$this->enabled != $this->defaultEnabled ||
|
304 |
+
$this->processHeadings != $this->defaulProcessHeadings
|
305 |
+
) {
|
306 |
$data['enabled'] = $this->enabled;
|
307 |
+
$data['processHeadings'] = $this->processHeadings;
|
308 |
update_post_meta($this->postId, '_lwptoc_settings', $data);
|
309 |
} else {
|
310 |
delete_post_meta($this->postId, '_lwptoc_settings');
|
plugin/Settings.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
namespace luckywp\tableOfContents\plugin;
|
4 |
|
5 |
use luckywp\tableOfContents\core\Core;
|
|
|
6 |
|
7 |
/**
|
8 |
* @property int $generalMin
|
@@ -272,6 +273,15 @@ class Settings extends \luckywp\tableOfContents\core\wp\Settings
|
|
272 |
return is_array($postTypes) ? $postTypes : [];
|
273 |
}
|
274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
/**
|
276 |
* @return string
|
277 |
*/
|
@@ -317,6 +327,15 @@ class Settings extends \luckywp\tableOfContents\core\wp\Settings
|
|
317 |
return (string)$this->getValue('misc', 'skipHeadingText', false);
|
318 |
}
|
319 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
/**
|
321 |
* @param string $value
|
322 |
* @return string
|
@@ -363,4 +382,17 @@ class Settings extends \luckywp\tableOfContents\core\wp\Settings
|
|
363 |
}
|
364 |
return 'default';
|
365 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
}
|
3 |
namespace luckywp\tableOfContents\plugin;
|
4 |
|
5 |
use luckywp\tableOfContents\core\Core;
|
6 |
+
use luckywp\tableOfContents\core\helpers\ValueHelper;
|
7 |
|
8 |
/**
|
9 |
* @property int $generalMin
|
273 |
return is_array($postTypes) ? $postTypes : [];
|
274 |
}
|
275 |
|
276 |
+
/**
|
277 |
+
* @return array
|
278 |
+
*/
|
279 |
+
public function getProcessingHeadingsAlwaysForPostTypes()
|
280 |
+
{
|
281 |
+
$postTypes = $this->getValue('processingHeadings', 'postTypes', []);
|
282 |
+
return ValueHelper::assertArray($postTypes);
|
283 |
+
}
|
284 |
+
|
285 |
/**
|
286 |
* @return string
|
287 |
*/
|
327 |
return (string)$this->getValue('misc', 'skipHeadingText', false);
|
328 |
}
|
329 |
|
330 |
+
/**
|
331 |
+
* @return array
|
332 |
+
*/
|
333 |
+
public function getMiscShowMetaboxPostTypes()
|
334 |
+
{
|
335 |
+
$postTypes = $this->getValue('misc', 'showMetaboxPostTypes', []);
|
336 |
+
return ValueHelper::assertArray($postTypes);
|
337 |
+
}
|
338 |
+
|
339 |
/**
|
340 |
* @param string $value
|
341 |
* @return string
|
382 |
}
|
383 |
return 'default';
|
384 |
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* @return array
|
388 |
+
*/
|
389 |
+
public function getPostTypesForProcessingHeadings()
|
390 |
+
{
|
391 |
+
$postTypes = [];
|
392 |
+
if ($this->getAutoInsertEnable()) {
|
393 |
+
$postTypes = $this->getAutoInsertPostTypes();
|
394 |
+
}
|
395 |
+
$postTypes = array_merge($postTypes, $this->getProcessingHeadingsAlwaysForPostTypes(), $this->getMiscShowMetaboxPostTypes());
|
396 |
+
return array_unique($postTypes);
|
397 |
+
}
|
398 |
}
|
plugin/Shortcode.php
CHANGED
@@ -4,72 +4,71 @@ namespace luckywp\tableOfContents\plugin;
|
|
4 |
|
5 |
use luckywp\tableOfContents\core\base\BaseObject;
|
6 |
use luckywp\tableOfContents\core\Core;
|
7 |
-
use luckywp\tableOfContents\core\helpers\
|
8 |
-
use luckywp\tableOfContents\core\helpers\Html;
|
9 |
use luckywp\tableOfContents\core\helpers\ValueHelper;
|
|
|
|
|
|
|
10 |
use WP_Post;
|
11 |
|
12 |
-
/**
|
13 |
-
* @property-read string $tag
|
14 |
-
*/
|
15 |
class Shortcode extends BaseObject
|
16 |
{
|
17 |
|
18 |
/**
|
19 |
-
*
|
20 |
*/
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
/**
|
24 |
-
* @var
|
25 |
*/
|
26 |
-
protected $
|
27 |
|
28 |
/**
|
29 |
-
* @var
|
30 |
*/
|
31 |
-
protected $
|
32 |
|
33 |
/**
|
34 |
-
* @var array
|
35 |
*/
|
36 |
-
protected $
|
37 |
|
38 |
/**
|
39 |
-
* @var
|
40 |
*/
|
41 |
-
|
42 |
|
43 |
/**
|
44 |
* @var array
|
45 |
*/
|
46 |
-
|
47 |
|
48 |
/**
|
49 |
-
*
|
|
|
|
|
50 |
*/
|
51 |
-
public function
|
52 |
{
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
{
|
63 |
-
add_shortcode($this->getTag(), function ($attrs) {
|
64 |
-
global $post;
|
65 |
-
if (!is_single($post) && !is_page($post)) {
|
66 |
-
return '';
|
67 |
-
}
|
68 |
-
if (!is_array($attrs)) {
|
69 |
-
$attrs = [];
|
70 |
-
}
|
71 |
-
if ($post instanceof WP_Post) {
|
72 |
-
$postSettings = new PostSettings($post->ID);
|
73 |
foreach ([
|
74 |
'min',
|
75 |
'depth',
|
@@ -98,91 +97,61 @@ class Shortcode extends BaseObject
|
|
98 |
'skipHeadingLevel',
|
99 |
'skipHeadingText',
|
100 |
] as $var) {
|
101 |
-
if (!array_key_exists(strtolower($var), $attrs)
|
|
|
|
|
102 |
$attrs[strtolower($var)] = $postSettings->$var;
|
103 |
}
|
104 |
}
|
105 |
}
|
|
|
|
|
|
|
106 |
return $this->make($attrs);
|
107 |
-
}
|
108 |
-
}
|
109 |
|
110 |
-
|
|
|
|
|
|
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
$this->
|
|
|
|
|
119 |
}
|
120 |
-
return $this->_tag;
|
121 |
-
}
|
122 |
|
123 |
-
|
124 |
-
* @return string
|
125 |
-
*/
|
126 |
-
protected function getShortcodeRegex()
|
127 |
-
{
|
128 |
-
return '/' . get_shortcode_regex([$this->getTag()]) . '/s';
|
129 |
}
|
130 |
|
131 |
/**
|
132 |
* @param string $content
|
133 |
* @return string
|
134 |
*/
|
135 |
-
public function
|
136 |
{
|
137 |
-
if (
|
138 |
-
$
|
139 |
-
|
140 |
-
$this->headers = [];
|
141 |
-
|
142 |
-
$this->shortcodesAttrs = [];
|
143 |
-
preg_match_all($this->getShortcodeRegex(), $content, $matches);
|
144 |
-
foreach ($matches[3] as $match) {
|
145 |
-
$this->shortcodesAttrs[] = ValueHelper::assertArray(shortcode_parse_atts($match));
|
146 |
-
}
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
if (array_key_exists('skipheadingtext', $attrs)) {
|
153 |
-
$skipText[] = Core::$plugin->skipHeadingTextToArray($attrs['skipheadingtext']);
|
154 |
-
} else {
|
155 |
-
$skipText[] = Core::$plugin->skipHeadingTextToArray(Core::$plugin->settings->getMiscSkipHeadingText());
|
156 |
-
}
|
157 |
-
}
|
158 |
-
if (!$skipText) {
|
159 |
-
$skipText[] = Core::$plugin->skipHeadingTextToArray(Core::$plugin->settings->getMiscSkipHeadingText());
|
160 |
-
}
|
161 |
-
if (count($skipText) > 1) {
|
162 |
-
$skipText = call_user_func_array('array_intersect', $skipText);
|
163 |
-
} else {
|
164 |
-
$skipText = reset($skipText);
|
165 |
-
}
|
166 |
-
$skipRegex = Core::$plugin->skipHeadingTextToRegex($skipText);
|
167 |
-
$content = preg_replace_callback($headingsRegex, function ($m) use ($skipRegex) {
|
168 |
-
return $this->processHeaders($m, $skipRegex);
|
169 |
-
}, $content);
|
170 |
-
}
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
175 |
}
|
176 |
-
return $content;
|
177 |
-
}
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
*/
|
182 |
-
protected function makeHeadingsRegex()
|
183 |
-
{
|
184 |
-
$skipLevels = [];
|
185 |
-
foreach ($this->shortcodesAttrs as $attrs) {
|
186 |
if (array_key_exists('skipheadinglevel', $attrs)) {
|
187 |
$skipLevels[] = Core::$plugin->skipHeadingLevelToArray($attrs['skipheadinglevel']);
|
188 |
} else {
|
@@ -193,358 +162,74 @@ class Shortcode extends BaseObject
|
|
193 |
$skipLevels[] = Core::$plugin->skipHeadingLevelToArray(Core::$plugin->settings->getMiscSkipHeadingLevel());
|
194 |
}
|
195 |
if (count($skipLevels) > 1) {
|
196 |
-
$skipLevels = call_user_func_array('array_intersect', $skipLevels);
|
197 |
} else {
|
198 |
-
$skipLevels = reset($skipLevels);
|
199 |
}
|
200 |
|
201 |
-
$
|
202 |
-
foreach (
|
203 |
-
if (
|
204 |
-
|
|
|
|
|
205 |
}
|
206 |
-
$levels[] = $level;
|
207 |
}
|
208 |
-
if (!$
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
210 |
}
|
211 |
|
212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
}
|
214 |
|
215 |
/**
|
216 |
-
* Выводить ли содержание?
|
217 |
* @param string $content
|
218 |
* @return bool
|
219 |
*/
|
220 |
-
protected function
|
221 |
{
|
222 |
-
|
223 |
-
has_shortcode($content, $this->getTag());
|
224 |
-
}
|
225 |
|
226 |
-
|
227 |
-
|
228 |
-
* @param array $m
|
229 |
-
* @param string|false $skipRegex
|
230 |
-
* @return string
|
231 |
-
*/
|
232 |
-
public function processHeaders($m, $skipRegex)
|
233 |
-
{
|
234 |
-
$label = trim(strip_tags($m[3]));
|
235 |
-
if ($skipRegex && preg_match($skipRegex, $label)) {
|
236 |
-
return $m[0];
|
237 |
}
|
238 |
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
case 'asheading':
|
245 |
-
default:
|
246 |
-
$id = $baseId = $this->makeId($m[3]);
|
247 |
-
$c = 0;
|
248 |
-
while (in_array($id, $this->ids)) {
|
249 |
-
$c++;
|
250 |
-
$id = $baseId . $c;
|
251 |
-
}
|
252 |
-
$this->ids[] = $id;
|
253 |
-
break;
|
254 |
}
|
255 |
|
256 |
-
$
|
257 |
-
|
258 |
-
|
259 |
-
'label' => $label,
|
260 |
-
];
|
261 |
-
$this->headers[] = $header;
|
262 |
-
|
263 |
-
$content = '';
|
264 |
-
$htmlOptions = [
|
265 |
-
'id' => $header['id'],
|
266 |
-
];
|
267 |
-
$anchor = Html::a($content, null, $htmlOptions);
|
268 |
|
269 |
-
return
|
270 |
}
|
271 |
|
272 |
-
|
273 |
-
* @param string $label
|
274 |
-
* @return string
|
275 |
-
*/
|
276 |
-
protected function makeId($label)
|
277 |
-
{
|
278 |
-
$id = strip_tags($label);
|
279 |
-
$id = html_entity_decode($id, ENT_QUOTES, get_option('blog_charset'));
|
280 |
-
if (function_exists('transliterator_transliterate')) {
|
281 |
-
$id = transliterator_transliterate('Any-Latin; Latin-ASCII;', $id);
|
282 |
-
}
|
283 |
-
$id = preg_replace('/[^\d\-_A-Za-z ]+/', '', $id);
|
284 |
-
$id = preg_replace('/ +/', ' ', $id);
|
285 |
-
$id = trim($id);
|
286 |
-
$id = str_replace(' ', '_', $id);
|
287 |
-
$id = preg_replace('/__+/', '_', $id);
|
288 |
-
return $id ? $id : 'lwptoc';
|
289 |
-
}
|
290 |
|
291 |
/**
|
292 |
-
* @param array $attrs
|
293 |
* @return string
|
294 |
*/
|
295 |
-
|
296 |
{
|
297 |
-
$
|
298 |
-
|
299 |
-
$itemsStyles = [];
|
300 |
-
|
301 |
-
$min = (int)ArrayHelper::getValue($attrs, 'min', Core::$plugin->settings->generalMin);
|
302 |
-
if ($min < 1) {
|
303 |
-
$min = 1;
|
304 |
-
}
|
305 |
-
if (count($this->headers) < $min) {
|
306 |
-
return '';
|
307 |
-
}
|
308 |
-
|
309 |
-
$skipHeadingLevels = Core::$plugin->skipHeadingLevelToArray(ArrayHelper::getValue($attrs, 'skipheadinglevel', Core::$plugin->settings->getMiscSkipHeadingLevel()));
|
310 |
-
$skipHeadingRegex = Core::$plugin->skipHeadingTextToRegex(ArrayHelper::getValue($attrs, 'skipheadingtext', Core::$plugin->settings->getMiscSkipHeadingText()));
|
311 |
-
|
312 |
-
$items = [];
|
313 |
-
$tree = [];
|
314 |
-
foreach ($this->headers as $header) {
|
315 |
-
if (in_array('h' . $header['index'], $skipHeadingLevels) ||
|
316 |
-
($skipHeadingRegex && preg_match($skipHeadingRegex, $header['label']))
|
317 |
-
) {
|
318 |
-
continue;
|
319 |
-
}
|
320 |
-
$node = null;
|
321 |
-
while (count($tree) && ($node === null)) {
|
322 |
-
end($tree);
|
323 |
-
$key = key($tree);
|
324 |
-
if ($header['index'] > $tree[$key]['index']) {
|
325 |
-
$node = $key;
|
326 |
-
} else {
|
327 |
-
unset($tree[$key]);
|
328 |
-
}
|
329 |
-
}
|
330 |
-
|
331 |
-
$item = [
|
332 |
-
'id' => $header['id'],
|
333 |
-
'index' => $header['index'],
|
334 |
-
'number' => null,
|
335 |
-
'label' => $header['label'],
|
336 |
-
'childrens' => [],
|
337 |
-
];
|
338 |
-
|
339 |
-
if ($node === null) {
|
340 |
-
$items[] = $item;
|
341 |
-
$tree[] = &$items[count($items) - 1];
|
342 |
-
} else {
|
343 |
-
$tree[$node]['childrens'][] = $item;
|
344 |
-
$tree[] = &$tree[$node]['childrens'][count($tree[$node]['childrens']) - 1];
|
345 |
-
}
|
346 |
-
}
|
347 |
-
unset($tree);
|
348 |
-
|
349 |
-
// Вложенность
|
350 |
-
$depth = (int)ArrayHelper::getValue($attrs, 'depth', Core::$plugin->settings->generalDepth);
|
351 |
-
if (!array_key_exists($depth, Core::$plugin->depthsList)) {
|
352 |
-
$depth = 6;
|
353 |
-
}
|
354 |
-
|
355 |
-
// Уберём все элменты, не подходящие по вложенности
|
356 |
-
$currentDepth = 0;
|
357 |
-
$fn = function (&$items, $depth) use (&$fn, &$currentDepth) {
|
358 |
-
$currentDepth++;
|
359 |
-
foreach ($items as $key => $item) {
|
360 |
-
if ($currentDepth == $depth) {
|
361 |
-
$items[$key]['childrens'] = [];
|
362 |
-
}
|
363 |
-
$fn($items[$key]['childrens'], $depth);
|
364 |
-
}
|
365 |
-
$currentDepth--;
|
366 |
-
};
|
367 |
-
$fn($items, $depth);
|
368 |
-
|
369 |
-
// Нумерация
|
370 |
-
$numeration = ArrayHelper::getValue($attrs, 'numeration', Core::$plugin->settings->generalNumeration);
|
371 |
-
$numeration = str_replace(['_', ' ', '-'], '', strtolower($numeration));
|
372 |
-
if (in_array($numeration, ['decimalnested', 'decimal', 'roman', 'romannested'])) {
|
373 |
-
if (in_array($numeration, ['decimalnested', 'romannested'])) {
|
374 |
-
$fn = function (&$items, $numbers) use (&$fn, $numeration) {
|
375 |
-
foreach ($items as $key => $item) {
|
376 |
-
$numbers[count($numbers) - 1]++;
|
377 |
-
$items[$key]['number'] = implode('.', $numeration == 'decimalnested' ? $numbers : array_map([$this, 'decimalToRoman'], $numbers));
|
378 |
-
$fn($items[$key]['childrens'], array_merge($numbers, [0]));
|
379 |
-
}
|
380 |
-
};
|
381 |
-
$fn($items, [0]);
|
382 |
-
} else {
|
383 |
-
$number = 0;
|
384 |
-
$fn = function (&$items) use (&$fn, &$number, $numeration) {
|
385 |
-
foreach ($items as $key => $item) {
|
386 |
-
$number++;
|
387 |
-
$items[$key]['number'] = $numeration == 'decimal' ? $number : $this->decimalToRoman($number);
|
388 |
-
$fn($items[$key]['childrens']);
|
389 |
-
}
|
390 |
-
};
|
391 |
-
$fn($items);
|
392 |
-
}
|
393 |
-
}
|
394 |
-
|
395 |
-
// Без иерархии
|
396 |
-
$hierarchical = $this->assertBool(ArrayHelper::getValue($attrs, 'hierarchical', Core::$plugin->settings->generalHierarchical));
|
397 |
-
if (!$hierarchical) {
|
398 |
-
$newItems = [];
|
399 |
-
$fn = function ($items) use (&$fn, &$newItems) {
|
400 |
-
foreach ($items as $item) {
|
401 |
-
$newItem = $item;
|
402 |
-
$newItem['childrens'] = [];
|
403 |
-
$newItems[] = $newItem;
|
404 |
-
$fn($item['childrens']);
|
405 |
-
}
|
406 |
-
};
|
407 |
-
$fn($items);
|
408 |
-
$items = $newItems;
|
409 |
-
}
|
410 |
-
|
411 |
-
$toggle = $this->assertBool(ArrayHelper::getValue($attrs, 'toggle', Core::$plugin->settings->generalToggle));
|
412 |
-
$labelShow = null;
|
413 |
-
$labelHide = null;
|
414 |
-
$hideItems = false;
|
415 |
-
if ($toggle) {
|
416 |
-
$labelShow = ArrayHelper::getValue($attrs, 'labelshow', Core::$plugin->settings->generalLabelShow);
|
417 |
-
$labelHide = ArrayHelper::getValue($attrs, 'labelhide', Core::$plugin->settings->generalLabelHide);
|
418 |
-
$hideItems = $this->assertBool(ArrayHelper::getValue($attrs, 'hideitems', Core::$plugin->settings->generalHideItems));
|
419 |
-
}
|
420 |
-
if ($hideItems) {
|
421 |
-
$itemsStyles[] = 'display:none;';
|
422 |
-
}
|
423 |
-
|
424 |
-
$containerOptions = [
|
425 |
-
'class' => ['lwptoc'],
|
426 |
-
'data' => [],
|
427 |
-
];
|
428 |
-
$innerContainerOptions = [
|
429 |
-
'class' => ['lwptoc_i'],
|
430 |
-
];
|
431 |
-
|
432 |
-
// Плавная прокрутка
|
433 |
-
$smoothScroll = $this->assertBool(ArrayHelper::getValue($attrs, 'smoothscroll', Core::$plugin->settings->generalSmoothScroll));
|
434 |
-
$containerOptions['data']['smooth-scroll'] = $smoothScroll ? 1 : 0;
|
435 |
-
if ($smoothScroll) {
|
436 |
-
$containerOptions['data']['smooth-scroll-offset'] = (int)ArrayHelper::getValue($attrs, 'smoothscrolloffset', Core::$plugin->settings->generalSmoothScrollOffset);
|
437 |
-
}
|
438 |
-
|
439 |
-
// Выравнивание
|
440 |
-
$float = ArrayHelper::getValue($attrs, 'float', Core::$plugin->settings->appearanceFloat);
|
441 |
-
$float = strtolower($float);
|
442 |
-
|
443 |
-
// Ширина
|
444 |
-
$width = ArrayHelper::getValue($attrs, 'width');
|
445 |
-
if ($width === null) {
|
446 |
-
$width = Core::$plugin->settings->appearanceWidth;
|
447 |
-
} else {
|
448 |
-
$width = Settings::sanitizeWidth($width);
|
449 |
-
}
|
450 |
-
|
451 |
-
// Опции для выравнивания и ширины
|
452 |
-
if (in_array($float, ['left', 'right', 'center', 'rightwithoutflow']) &&
|
453 |
-
(!in_array($float, ['left', 'right', 'rightwithoutflow']) || $width != 'full')) {
|
454 |
-
$containerOptions['class'][] = 'lwptoc-' . $float;
|
455 |
-
}
|
456 |
-
if ($width != 'full') {
|
457 |
-
if ($width == 'auto') {
|
458 |
-
$containerOptions['class'][] = 'lwptoc-autoWidth';
|
459 |
-
} else {
|
460 |
-
if (in_array($float, ['left', 'right'])) {
|
461 |
-
$containerOptions['style'] = 'width:' . $width;
|
462 |
-
} else {
|
463 |
-
$innerContainerOptions['style'] = 'width:' . $width;
|
464 |
-
}
|
465 |
-
}
|
466 |
-
}
|
467 |
-
|
468 |
-
// Размер шрифта заголовка
|
469 |
-
$titleFontSize = ArrayHelper::getValue($attrs, 'titlefontsize');
|
470 |
-
if ($titleFontSize === null) {
|
471 |
-
$titleFontSize = Core::$plugin->settings->appearanceTitleFontSize;
|
472 |
-
} else {
|
473 |
-
$titleFontSize = Settings::sanitizeFontSize($titleFontSize);
|
474 |
-
}
|
475 |
-
if ($titleFontSize != 'default') {
|
476 |
-
$headerStyles[] = 'font-size:' . $titleFontSize . ';';
|
477 |
-
}
|
478 |
-
|
479 |
-
// Толщина шрифта заголовка
|
480 |
-
$titleFontWeight = ArrayHelper::getValue($attrs, 'titlefontweight', Core::$plugin->settings->appearanceTitleFontWeight);
|
481 |
-
$titleFontWeight = str_replace(['_', ' ', '-'], '', strtolower($titleFontWeight));
|
482 |
-
if ($titleFontWeight != 'bold' && array_key_exists($titleFontWeight, Core::$plugin->fontWeightsList)) {
|
483 |
-
$titleStyles[] = 'font-weight:' . Core::$plugin->fontWeightToValue($titleFontWeight) . ';';
|
484 |
-
}
|
485 |
-
|
486 |
-
// Размер шрифта элементов
|
487 |
-
$itemsFontSize = ArrayHelper::getValue($attrs, 'itemsfontsize');
|
488 |
-
if ($itemsFontSize === null) {
|
489 |
-
$itemsFontSize = Core::$plugin->settings->appearanceItemsFontSize;
|
490 |
-
} else {
|
491 |
-
$itemsFontSize = Settings::sanitizeFontSize($itemsFontSize);
|
492 |
-
}
|
493 |
-
if ($itemsFontSize == '90%') {
|
494 |
-
$containerOptions['class'][] = 'lwptoc-baseItems';
|
495 |
-
} elseif ($itemsFontSize != 'default') {
|
496 |
-
$itemsStyles[] = 'font-size:' . $itemsFontSize . ';';
|
497 |
-
}
|
498 |
-
|
499 |
-
// Цветовая схема
|
500 |
-
$colorScheme = ArrayHelper::getValue($attrs, 'colorscheme', Core::$plugin->settings->appearanceColorScheme);
|
501 |
-
$colorScheme = str_replace(['_', ' ', '-'], '', strtolower($colorScheme));
|
502 |
-
if (array_key_exists($colorScheme, Core::$plugin->colorSchemesList)) {
|
503 |
-
$containerOptions['class'][] = 'lwptoc-' . $colorScheme;
|
504 |
-
}
|
505 |
-
|
506 |
-
// Запомним цвета для переопределения
|
507 |
-
$this->overrideColors = [];
|
508 |
-
foreach ([
|
509 |
-
'backgroundColor',
|
510 |
-
'borderColor',
|
511 |
-
'titleColor',
|
512 |
-
'linkColor',
|
513 |
-
'hoverLinkColor',
|
514 |
-
'visitedLinkColor',
|
515 |
-
] as $var) {
|
516 |
-
$color = ArrayHelper::getValue($attrs, strtolower($var), Core::$plugin->settings->{'appearance' . ucfirst($var)});
|
517 |
-
$color = Core::$plugin->settings->sanitizeCallbackColor($color);
|
518 |
-
if ($color) {
|
519 |
-
$this->overrideColors[$var] = $color;
|
520 |
-
}
|
521 |
-
}
|
522 |
-
|
523 |
-
$before = (string)apply_filters('lwptoc_before', '');
|
524 |
-
$after = (string)apply_filters('lwptoc_after', '');
|
525 |
-
|
526 |
-
if ($this->assertBool(ArrayHelper::getValue($attrs, 'wrapnoindex', Core::$plugin->settings->miscWrapNoindex))) {
|
527 |
-
$before = '<!--noindex-->' . $before;
|
528 |
-
$after = $after . '<!--/noindex-->';
|
529 |
}
|
530 |
-
|
531 |
-
// Вывод
|
532 |
-
$this->currentOutputDepth = -1;
|
533 |
-
return Core::$plugin->front->render('body', [
|
534 |
-
'title' => ArrayHelper::getValue($attrs, 'title', Core::$plugin->settings->generalTitle),
|
535 |
-
'toggle' => $toggle,
|
536 |
-
'labelShow' => $labelShow,
|
537 |
-
'labelHide' => $labelHide,
|
538 |
-
'hideItems' => $hideItems,
|
539 |
-
'containerOptions' => $containerOptions,
|
540 |
-
'innerContainerOptions' => $innerContainerOptions,
|
541 |
-
'headerStyles' => $headerStyles,
|
542 |
-
'titleStyles' => $titleStyles,
|
543 |
-
'itemsStyles' => $itemsStyles,
|
544 |
-
'items' => $items,
|
545 |
-
'before' => $before,
|
546 |
-
'after' => $after,
|
547 |
-
]);
|
548 |
}
|
549 |
|
550 |
/**
|
@@ -569,48 +254,19 @@ class Shortcode extends BaseObject
|
|
569 |
}
|
570 |
|
571 |
/**
|
572 |
-
* @
|
573 |
-
* @return bool
|
574 |
*/
|
575 |
-
protected function
|
576 |
{
|
577 |
-
|
578 |
-
return $v;
|
579 |
-
}
|
580 |
-
$v = strtolower((string)$v);
|
581 |
-
if (in_array($v, ['1', 'true', 'yes', 'y'], true)) {
|
582 |
-
return true;
|
583 |
-
}
|
584 |
-
return false;
|
585 |
}
|
586 |
|
587 |
/**
|
588 |
-
* @param
|
589 |
-
* @return
|
590 |
*/
|
591 |
-
|
592 |
{
|
593 |
-
$
|
594 |
-
$map = [
|
595 |
-
'M' => 1000,
|
596 |
-
'CM' => 900,
|
597 |
-
'D' => 500,
|
598 |
-
'CD' => 400,
|
599 |
-
'C' => 100,
|
600 |
-
'XC' => 90,
|
601 |
-
'L' => 50,
|
602 |
-
'XL' => 40,
|
603 |
-
'X' => 10,
|
604 |
-
'IX' => 9,
|
605 |
-
'V' => 5,
|
606 |
-
'IV' => 4,
|
607 |
-
'I' => 1
|
608 |
-
];
|
609 |
-
foreach ($map as $number => $value) {
|
610 |
-
$matches = intval($decimal / $value);
|
611 |
-
$roman .= str_repeat($number, $matches);
|
612 |
-
$decimal = $decimal % $value;
|
613 |
-
}
|
614 |
-
return $roman;
|
615 |
}
|
616 |
}
|
4 |
|
5 |
use luckywp\tableOfContents\core\base\BaseObject;
|
6 |
use luckywp\tableOfContents\core\Core;
|
7 |
+
use luckywp\tableOfContents\core\helpers\Json;
|
|
|
8 |
use luckywp\tableOfContents\core\helpers\ValueHelper;
|
9 |
+
use luckywp\tableOfContents\front\Toc;
|
10 |
+
use luckywp\tableOfContents\plugin\contentHandling\ContentHandling;
|
11 |
+
use luckywp\tableOfContents\plugin\contentHandling\ContentHandlingDto;
|
12 |
use WP_Post;
|
13 |
|
|
|
|
|
|
|
14 |
class Shortcode extends BaseObject
|
15 |
{
|
16 |
|
17 |
/**
|
18 |
+
* Инициализация
|
19 |
*/
|
20 |
+
public function init()
|
21 |
+
{
|
22 |
+
parent::init();
|
23 |
+
add_action('init', function () {
|
24 |
+
add_shortcode($this->getTag(), [$this, 'shortcode']);
|
25 |
+
});
|
26 |
+
add_filter('the_content', [$this, 'theContent'], 9999);
|
27 |
+
}
|
28 |
|
29 |
/**
|
30 |
+
* @var bool
|
31 |
*/
|
32 |
+
protected $isTheContentEmulate = false;
|
33 |
|
34 |
/**
|
35 |
+
* @var bool
|
36 |
*/
|
37 |
+
protected $theContentApplied = false;
|
38 |
|
39 |
/**
|
40 |
+
* @var array|null
|
41 |
*/
|
42 |
+
protected $headingsCache;
|
43 |
|
44 |
/**
|
45 |
+
* @var array
|
46 |
*/
|
47 |
+
protected $skipLevels = [];
|
48 |
|
49 |
/**
|
50 |
* @var array
|
51 |
*/
|
52 |
+
protected $skipText = [];
|
53 |
|
54 |
/**
|
55 |
+
* Обработка шорткода
|
56 |
+
* @param $attrs
|
57 |
+
* @return string
|
58 |
*/
|
59 |
+
public function shortcode($attrs)
|
60 |
{
|
61 |
+
global $post;
|
62 |
+
if (($this->theContentApplied && $this->headingsCache === null) ||
|
63 |
+
(!is_single($post) && !is_page($post))
|
64 |
+
) {
|
65 |
+
return '';
|
66 |
+
}
|
67 |
|
68 |
+
$attrs = ValueHelper::assertArray($attrs);
|
69 |
+
if ($post instanceof WP_Post) {
|
70 |
+
$postSettings = new PostSettings($post->ID);
|
71 |
+
if ($postSettings->enabled || $postSettings->processHeadings) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
foreach ([
|
73 |
'min',
|
74 |
'depth',
|
97 |
'skipHeadingLevel',
|
98 |
'skipHeadingText',
|
99 |
] as $var) {
|
100 |
+
if (!array_key_exists(strtolower($var), $attrs) &&
|
101 |
+
$postSettings->$var !== null
|
102 |
+
) {
|
103 |
$attrs[strtolower($var)] = $postSettings->$var;
|
104 |
}
|
105 |
}
|
106 |
}
|
107 |
+
}
|
108 |
+
|
109 |
+
if (Core::$plugin->isTheContent) {
|
110 |
return $this->make($attrs);
|
111 |
+
}
|
|
|
112 |
|
113 |
+
if (!$this->theContentApplied) {
|
114 |
+
$this->skipLevels[] = Core::$plugin->skipHeadingLevelToArray(array_key_exists('skipheadinglevel', $attrs) ? $attrs['skipheadinglevel'] : Core::$plugin->settings->getMiscSkipHeadingLevel());
|
115 |
+
$this->skipText[] = Core::$plugin->skipHeadingTextToArray(array_key_exists('skipheadingtext', $attrs) ? $attrs['skipheadingtext'] : Core::$plugin->settings->getMiscSkipHeadingText());
|
116 |
+
}
|
117 |
|
118 |
+
if ($this->headingsCache === null) {
|
119 |
+
$dto = new ContentHandlingDto();
|
120 |
+
$dto->modify = false;
|
121 |
+
|
122 |
+
$this->isTheContentEmulate = true;
|
123 |
+
$dto->content = apply_filters('the_content', $post->post_content);
|
124 |
+
$this->isTheContentEmulate = false;
|
125 |
+
|
126 |
+
$this->headingsCache = ContentHandling::go($dto)->headings;
|
127 |
}
|
|
|
|
|
128 |
|
129 |
+
return Toc::render($this->headingsCache, $attrs);
|
|
|
|
|
|
|
|
|
|
|
130 |
}
|
131 |
|
132 |
/**
|
133 |
* @param string $content
|
134 |
* @return string
|
135 |
*/
|
136 |
+
public function theContent($content)
|
137 |
{
|
138 |
+
if (!$this->needProcessHeadings($content)) {
|
139 |
+
return $content;
|
140 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
+
$dto = new ContentHandlingDto();
|
143 |
+
$dto->content = $content;
|
144 |
+
$dto->modify = true;
|
145 |
+
$dto->hashFormat = Core::$plugin->settings->getMiscHashFormat();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
+
$shortcodesAttrs = [];
|
148 |
+
preg_match_all($this->getShortcodeRegex(), $content, $matches);
|
149 |
+
foreach ($matches[3] as $match) {
|
150 |
+
$shortcodesAttrs[] = ValueHelper::assertArray(shortcode_parse_atts($match));
|
151 |
}
|
|
|
|
|
152 |
|
153 |
+
$skipLevels = $this->skipLevels;
|
154 |
+
foreach ($shortcodesAttrs as $attrs) {
|
|
|
|
|
|
|
|
|
|
|
155 |
if (array_key_exists('skipheadinglevel', $attrs)) {
|
156 |
$skipLevels[] = Core::$plugin->skipHeadingLevelToArray($attrs['skipheadinglevel']);
|
157 |
} else {
|
162 |
$skipLevels[] = Core::$plugin->skipHeadingLevelToArray(Core::$plugin->settings->getMiscSkipHeadingLevel());
|
163 |
}
|
164 |
if (count($skipLevels) > 1) {
|
165 |
+
$dto->skipLevels = call_user_func_array('array_intersect', $skipLevels);
|
166 |
} else {
|
167 |
+
$dto->skipLevels = reset($skipLevels);
|
168 |
}
|
169 |
|
170 |
+
$skipText = $this->skipText;
|
171 |
+
foreach ($shortcodesAttrs as $attrs) {
|
172 |
+
if (array_key_exists('skipheadingtext', $attrs)) {
|
173 |
+
$skipText[] = Core::$plugin->skipHeadingTextToArray($attrs['skipheadingtext']);
|
174 |
+
} else {
|
175 |
+
$skipText[] = Core::$plugin->skipHeadingTextToArray(Core::$plugin->settings->getMiscSkipHeadingText());
|
176 |
}
|
|
|
177 |
}
|
178 |
+
if (!$skipText) {
|
179 |
+
$skipText[] = Core::$plugin->skipHeadingTextToArray(Core::$plugin->settings->getMiscSkipHeadingText());
|
180 |
+
}
|
181 |
+
if (count($skipText) > 1) {
|
182 |
+
$dto->skipText = call_user_func_array('array_intersect', $skipText);
|
183 |
+
} else {
|
184 |
+
$dto->skipText = reset($skipText);
|
185 |
}
|
186 |
|
187 |
+
$result = ContentHandling::go($dto);
|
188 |
+
$this->headingsCache = $result->headings;
|
189 |
+
|
190 |
+
$this->theContentApplied = true;
|
191 |
+
|
192 |
+
return preg_replace_callback($this->getShortcodeRegex(), function ($m) use ($result) {
|
193 |
+
return Toc::render($result->headings, shortcode_parse_atts($m[3]));
|
194 |
+
}, $result->content);
|
195 |
}
|
196 |
|
197 |
/**
|
|
|
198 |
* @param string $content
|
199 |
* @return bool
|
200 |
*/
|
201 |
+
protected function needProcessHeadings($content)
|
202 |
{
|
203 |
+
global $post;
|
|
|
|
|
204 |
|
205 |
+
if ($this->headingsCache !== null) {
|
206 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
}
|
208 |
|
209 |
+
if ($this->isTheContentEmulate ||
|
210 |
+
!is_singular()
|
211 |
+
) {
|
212 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
}
|
214 |
|
215 |
+
if (has_shortcode($content, $this->getTag())) {
|
216 |
+
return true;
|
217 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
|
219 |
+
return (new PostSettings($post->ID))->processHeadings;
|
220 |
}
|
221 |
|
222 |
+
private $_tag;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
|
224 |
/**
|
|
|
225 |
* @return string
|
226 |
*/
|
227 |
+
public function getTag()
|
228 |
{
|
229 |
+
if ($this->_tag === null) {
|
230 |
+
$this->_tag = apply_filters('lwptoc_shortcode_tag', 'lwptoc');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
}
|
232 |
+
return $this->_tag;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
}
|
234 |
|
235 |
/**
|
254 |
}
|
255 |
|
256 |
/**
|
257 |
+
* @return string
|
|
|
258 |
*/
|
259 |
+
protected function getShortcodeRegex()
|
260 |
{
|
261 |
+
return '/' . get_shortcode_regex([$this->getTag()]) . '/s';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
}
|
263 |
|
264 |
/**
|
265 |
+
* @param string $json
|
266 |
+
* @return array
|
267 |
*/
|
268 |
+
public static function attrsFromJson($json)
|
269 |
{
|
270 |
+
return ValueHelper::assertArray(Json::decode($json));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
}
|
272 |
}
|
plugin/WpWidget.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace luckywp\tableOfContents\plugin;
|
4 |
+
|
5 |
+
use luckywp\tableOfContents\admin\widgets\widget\Widget;
|
6 |
+
use luckywp\tableOfContents\core\Core;
|
7 |
+
use luckywp\tableOfContents\core\helpers\ArrayHelper;
|
8 |
+
use WP_Widget;
|
9 |
+
|
10 |
+
class WpWidget extends WP_Widget
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Конструктор
|
15 |
+
*/
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct(
|
19 |
+
'lpwtoc_widget',
|
20 |
+
esc_html__('Table of Contents', 'lwptoc')
|
21 |
+
);
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @param array $args
|
26 |
+
* @param array $instance
|
27 |
+
*/
|
28 |
+
public function widget($args, $instance)
|
29 |
+
{
|
30 |
+
$attrs = Shortcode::attrsFromJson(ArrayHelper::getValue($instance, 'config', ''));
|
31 |
+
echo do_shortcode(Core::$plugin->shortcode->make($attrs));
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @param array $instance The widget options
|
36 |
+
*/
|
37 |
+
public function form($instance)
|
38 |
+
{
|
39 |
+
echo Widget::widget([
|
40 |
+
'id' => $this->id,
|
41 |
+
'inputName' => $this->get_field_name('config'),
|
42 |
+
'value' => ArrayHelper::getValue($instance, 'config', ''),
|
43 |
+
'instance' => $instance,
|
44 |
+
]);
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @param array $newInstance
|
49 |
+
* @param array $oldInstance
|
50 |
+
* @return array
|
51 |
+
*/
|
52 |
+
public function update($newInstance, $oldInstance)
|
53 |
+
{
|
54 |
+
return ['config' => ArrayHelper::getValue($newInstance, 'config', '')];
|
55 |
+
}
|
56 |
+
}
|
plugin/contentHandling/ContentHandling.php
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace luckywp\tableOfContents\plugin\contentHandling;
|
4 |
+
|
5 |
+
use luckywp\tableOfContents\core\Core;
|
6 |
+
use luckywp\tableOfContents\core\helpers\Html;
|
7 |
+
|
8 |
+
class ContentHandling
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param ContentHandlingDto $dto
|
13 |
+
* @return ContentHandlingResult
|
14 |
+
*/
|
15 |
+
public static function go($dto)
|
16 |
+
{
|
17 |
+
$result = new ContentHandlingResult();
|
18 |
+
$result->content = $dto->content;
|
19 |
+
|
20 |
+
$skipRegex = Core::$plugin->skipHeadingTextToRegex($dto->skipText);
|
21 |
+
|
22 |
+
static::$headingIdCounter = 0;
|
23 |
+
static::$headingIds = [];
|
24 |
+
$result->content = preg_replace_callback('#<h([1-6])(.*?)>(.*?)</h\d>#', function ($m) use ($dto, $result, $skipRegex) {
|
25 |
+
$label = trim(strip_tags($m[3]));
|
26 |
+
$headingId = static::makeHeadingId($label, $dto->hashFormat);
|
27 |
+
$headingIndex = (int)$m[1];
|
28 |
+
|
29 |
+
$result->headings[] = [
|
30 |
+
'id' => $headingId,
|
31 |
+
'index' => $headingIndex,
|
32 |
+
'label' => $label,
|
33 |
+
];
|
34 |
+
|
35 |
+
if (!$dto->modify ||
|
36 |
+
in_array('h' . $headingIndex, $dto->skipLevels) ||
|
37 |
+
($skipRegex && preg_match($skipRegex, $label))
|
38 |
+
) {
|
39 |
+
return $m[0];
|
40 |
+
}
|
41 |
+
|
42 |
+
$anchor = Html::a('', null, ['id' => $headingId]);
|
43 |
+
|
44 |
+
return $anchor . $m[0];
|
45 |
+
}, $dto->content);
|
46 |
+
|
47 |
+
return $result;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @var int
|
52 |
+
*/
|
53 |
+
protected static $headingIdCounter;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @var string[]
|
57 |
+
*/
|
58 |
+
protected static $headingIds;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @param string $label
|
62 |
+
* @param string $hashFormat
|
63 |
+
* @return string
|
64 |
+
*/
|
65 |
+
protected static function makeHeadingId($label, $hashFormat)
|
66 |
+
{
|
67 |
+
switch ($hashFormat) {
|
68 |
+
case 'counter':
|
69 |
+
return 'lwptoc' . ++static::$headingIdCounter;
|
70 |
+
|
71 |
+
case 'asheading':
|
72 |
+
default:
|
73 |
+
$id = html_entity_decode($label, ENT_QUOTES, get_option('blog_charset'));
|
74 |
+
if (function_exists('transliterator_transliterate')) {
|
75 |
+
$id = transliterator_transliterate('Any-Latin; Latin-ASCII;', $id);
|
76 |
+
}
|
77 |
+
$id = preg_replace('/[^\d\-_A-Za-z ]+/', '', $id);
|
78 |
+
$id = preg_replace('/ +/', ' ', $id);
|
79 |
+
$id = trim($id);
|
80 |
+
$id = str_replace(' ', '_', $id);
|
81 |
+
$id = preg_replace('/__+/', '_', $id);
|
82 |
+
if (!$id) {
|
83 |
+
$id = 'lwptoc';
|
84 |
+
}
|
85 |
+
|
86 |
+
$baseId = $id;
|
87 |
+
$c = 0;
|
88 |
+
while (in_array($id, static::$headingIds)) {
|
89 |
+
$c++;
|
90 |
+
$id = $baseId . $c;
|
91 |
+
}
|
92 |
+
static::$headingIds[] = $id;
|
93 |
+
|
94 |
+
return $id;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
plugin/contentHandling/ContentHandlingDto.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace luckywp\tableOfContents\plugin\contentHandling;
|
4 |
+
|
5 |
+
class ContentHandlingDto
|
6 |
+
{
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @var string
|
10 |
+
*/
|
11 |
+
public $content;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var bool
|
15 |
+
*/
|
16 |
+
public $modify = false;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
public $skipText = '';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
public $skipLevels = [];
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var string
|
30 |
+
*/
|
31 |
+
public $hashFormat = 'asheading';
|
32 |
+
}
|
plugin/contentHandling/ContentHandlingResult.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace luckywp\tableOfContents\plugin\contentHandling;
|
4 |
+
|
5 |
+
class ContentHandlingResult
|
6 |
+
{
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @var string
|
10 |
+
*/
|
11 |
+
public $content;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var array
|
15 |
+
*/
|
16 |
+
public $headings = [];
|
17 |
+
}
|
readme.txt
CHANGED
@@ -3,13 +3,13 @@ Contributors: theluckywp
|
|
3 |
Donate link: https://theluckywp.com/product/table-of-contents/
|
4 |
Tags: table of contents, toc, navigation, links, heading
|
5 |
Requires at least: 4.7
|
6 |
-
Tested up to: 5.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
|
11 |
|
12 |
-
Creates a table of contents for your posts/pages. Works automatically or manually (via shortcode
|
13 |
|
14 |
== Description ==
|
15 |
|
@@ -18,7 +18,7 @@ Creates a table of contents for your posts, pages or custom post types. Great cu
|
|
18 |
#### Features
|
19 |
|
20 |
* Automatical insertion a table of contents (configure post types and position).
|
21 |
-
* Insert by shortcode
|
22 |
* Button on toolbar of the classic editor.
|
23 |
* Gutenberg block into "Common Blocks".
|
24 |
* Setting the minimum number of headings to display table of contents.
|
@@ -118,13 +118,20 @@ For non-English websites it is recommended to enable the `Intl` PHP extension.
|
|
118 |
3. Classic Editor Support
|
119 |
4. Customize Window
|
120 |
5. Examples of Color Solutions
|
121 |
-
6.
|
122 |
-
7.
|
123 |
-
8.
|
124 |
-
9.
|
|
|
|
|
125 |
|
126 |
== Changelog ==
|
127 |
|
|
|
|
|
|
|
|
|
|
|
128 |
= 1.3.1 =
|
129 |
* Bug fix
|
130 |
|
3 |
Donate link: https://theluckywp.com/product/table-of-contents/
|
4 |
Tags: table of contents, toc, navigation, links, heading
|
5 |
Requires at least: 4.7
|
6 |
+
Tested up to: 5.2.1
|
7 |
+
Stable tag: 1.4
|
8 |
Requires PHP: 5.6.20
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
12 |
+
Creates a table of contents for your posts/pages. Works automatically or manually (via shortcode, Gutenberg block or widget).
|
13 |
|
14 |
== Description ==
|
15 |
|
18 |
#### Features
|
19 |
|
20 |
* Automatical insertion a table of contents (configure post types and position).
|
21 |
+
* Insert by shortcode, Gutenberg block or widget.
|
22 |
* Button on toolbar of the classic editor.
|
23 |
* Gutenberg block into "Common Blocks".
|
24 |
* Setting the minimum number of headings to display table of contents.
|
118 |
3. Classic Editor Support
|
119 |
4. Customize Window
|
120 |
5. Examples of Color Solutions
|
121 |
+
6. Widget Settings
|
122 |
+
7. General Settings
|
123 |
+
8. Appearance Settings
|
124 |
+
9. Auto Insert Settings
|
125 |
+
10. Processing Headings Settings
|
126 |
+
11. Miscellaneous Settings
|
127 |
|
128 |
== Changelog ==
|
129 |
|
130 |
+
= 1.4 =
|
131 |
+
+ Added widget "Table of Contents".
|
132 |
+
+ Added support output table of contents via `do_shortcode('[lwptoc]')`.
|
133 |
+
* Enhancements for more compatible with themes.
|
134 |
+
|
135 |
= 1.3.1 =
|
136 |
* Bug fix
|
137 |
|