Version Description
2020-02-23 =
+ Added hook filter lwptoc_active
.
+ Added tab "LuckyWP Plugins" to settings.
* Improvement work option "Skip headings by text".
* Fixed: in some cases shortcode incorrectly processed.
* Fixed: in some cases auto insert work incorrectly.
* Fixed: headings in table of contents not escaping.
* Minor fixes in customize window.
Download this release
Release Info
Developer | theluckywp |
Plugin | LuckyWP Table of Contents |
Version | 2.0.8 |
Comparing to | |
See all releases |
Code changes from version 2.0.7 to 2.0.8
- admin/controllers/SettingsController.php +32 -0
- admin/controllers/ShortcodeController.php +14 -10
- admin/views/settings/plugins.php +9 -0
- admin/widgets/customizeModal/views/modal.php +1 -1
- config/settings.php +6 -1
- core/wp/Settings.php +8 -3
- front/Front.php +5 -5
- front/views/items.php +1 -1
- integrations/ToolsetViews.php +1 -1
- languages/luckywp-table-of-contents-ru_RU.mo +0 -0
- languages/luckywp-table-of-contents.pot +66 -53
- luckywp-table-of-contents.php +2 -2
- plugin/Plugin.php +6 -2
- plugin/Shortcode.php +41 -8
- plugin/contentHandling/ContentHandling.php +2 -1
- plugin/dom/Dom.php +19 -10
- readme.txt +11 -2
admin/controllers/SettingsController.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
namespace luckywp\tableOfContents\admin\controllers;
|
4 |
|
5 |
use luckywp\tableOfContents\core\admin\AdminController;
|
|
|
6 |
|
7 |
class SettingsController extends AdminController
|
8 |
{
|
@@ -11,4 +12,35 @@ class SettingsController extends AdminController
|
|
11 |
{
|
12 |
$this->render('index');
|
13 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
3 |
namespace luckywp\tableOfContents\admin\controllers;
|
4 |
|
5 |
use luckywp\tableOfContents\core\admin\AdminController;
|
6 |
+
use WP_Plugin_Install_List_Table;
|
7 |
|
8 |
class SettingsController extends AdminController
|
9 |
{
|
12 |
{
|
13 |
$this->render('index');
|
14 |
}
|
15 |
+
|
16 |
+
public function plugins()
|
17 |
+
{
|
18 |
+
require_once ABSPATH . 'wp-admin/includes/class-wp-plugin-install-list-table.php';
|
19 |
+
|
20 |
+
add_filter('install_plugins_nonmenu_tabs', function ($tabs) {
|
21 |
+
$tabs[] = 'luckywp';
|
22 |
+
return $tabs;
|
23 |
+
});
|
24 |
+
add_filter('install_plugins_table_api_args_luckywp', function ($args) {
|
25 |
+
global $paged;
|
26 |
+
return [
|
27 |
+
'page' => $paged,
|
28 |
+
'per_page' => 12,
|
29 |
+
'locale' => get_user_locale(),
|
30 |
+
'search' => 'LuckyWP',
|
31 |
+
];
|
32 |
+
});
|
33 |
+
|
34 |
+
$_POST['tab'] = 'luckywp';
|
35 |
+
$table = new WP_Plugin_Install_List_Table();
|
36 |
+
$table->prepare_items();
|
37 |
+
|
38 |
+
wp_enqueue_script('plugin-install');
|
39 |
+
add_thickbox();
|
40 |
+
wp_enqueue_script('updates');
|
41 |
+
|
42 |
+
$this->render('plugins', [
|
43 |
+
'table' => $table,
|
44 |
+
]);
|
45 |
+
}
|
46 |
}
|
admin/controllers/ShortcodeController.php
CHANGED
@@ -29,14 +29,10 @@ class ShortcodeController extends AdminController
|
|
29 |
{
|
30 |
Core::$plugin->admin->checkAjaxReferer();
|
31 |
$post = get_post((int)Core::$plugin->request->get('postId'));
|
32 |
-
$attrs = Core::$plugin->request->get('attrs');
|
33 |
-
if (!is_array($attrs)) {
|
34 |
-
$attrs = [];
|
35 |
-
}
|
36 |
$onlyBody = false;
|
37 |
|
38 |
$postSettings = new PostSettings($post->ID);
|
39 |
-
$model = new CustomizeForm($postSettings, $
|
40 |
if ($model->load(Core::$plugin->request->post())) {
|
41 |
if ($model->validate()) {
|
42 |
echo CustomizeSuccess::widget([
|
@@ -59,11 +55,7 @@ class ShortcodeController extends AdminController
|
|
59 |
public function ajaxView()
|
60 |
{
|
61 |
Core::$plugin->admin->checkAjaxReferer();
|
62 |
-
$
|
63 |
-
if (!is_array($attrs)) {
|
64 |
-
$attrs = [];
|
65 |
-
}
|
66 |
-
$rows = Core::$plugin->admin->overrideSettingsToRows($attrs);
|
67 |
echo '<div class="lwptocShortcode">';
|
68 |
echo '<div class="lwptocShortcode_title">' . esc_html__('Table of Contents', 'luckywp-table-of-contents') . '</div>';
|
69 |
if ($rows) {
|
@@ -79,4 +71,16 @@ class ShortcodeController extends AdminController
|
|
79 |
echo '</div>';
|
80 |
wp_die();
|
81 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
29 |
{
|
30 |
Core::$plugin->admin->checkAjaxReferer();
|
31 |
$post = get_post((int)Core::$plugin->request->get('postId'));
|
|
|
|
|
|
|
|
|
32 |
$onlyBody = false;
|
33 |
|
34 |
$postSettings = new PostSettings($post->ID);
|
35 |
+
$model = new CustomizeForm($postSettings, $this->getAttrsFromRequest());
|
36 |
if ($model->load(Core::$plugin->request->post())) {
|
37 |
if ($model->validate()) {
|
38 |
echo CustomizeSuccess::widget([
|
55 |
public function ajaxView()
|
56 |
{
|
57 |
Core::$plugin->admin->checkAjaxReferer();
|
58 |
+
$rows = Core::$plugin->admin->overrideSettingsToRows($this->getAttrsFromRequest());
|
|
|
|
|
|
|
|
|
59 |
echo '<div class="lwptocShortcode">';
|
60 |
echo '<div class="lwptocShortcode_title">' . esc_html__('Table of Contents', 'luckywp-table-of-contents') . '</div>';
|
61 |
if ($rows) {
|
71 |
echo '</div>';
|
72 |
wp_die();
|
73 |
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @return array
|
77 |
+
*/
|
78 |
+
protected function getAttrsFromRequest()
|
79 |
+
{
|
80 |
+
$attrs = Core::$plugin->request->get('attrs');
|
81 |
+
if (!is_array($attrs)) {
|
82 |
+
$attrs = [];
|
83 |
+
}
|
84 |
+
return wp_unslash($attrs);
|
85 |
+
}
|
86 |
}
|
admin/views/settings/plugins.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @var $table \WP_Plugin_Install_List_Table
|
4 |
+
*/
|
5 |
+
?>
|
6 |
+
<br>
|
7 |
+
<div id="plugin-filter">
|
8 |
+
<?php $table->display() ?>
|
9 |
+
</div>
|
admin/widgets/customizeModal/views/modal.php
CHANGED
@@ -569,7 +569,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
|
|
569 |
if ('' == $defaultValue) {
|
570 |
echo '<i>' . esc_html__('empty', 'luckywp-table-of-contents') . '</i>';
|
571 |
} else {
|
572 |
-
echo $defaultValue;
|
573 |
}
|
574 |
?>
|
575 |
</div>
|
569 |
if ('' == $defaultValue) {
|
570 |
echo '<i>' . esc_html__('empty', 'luckywp-table-of-contents') . '</i>';
|
571 |
} else {
|
572 |
+
echo esc_html($defaultValue);
|
573 |
}
|
574 |
?>
|
575 |
</div>
|
config/settings.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
|
|
|
3 |
use luckywp\tableOfContents\admin\widgets\fontSizeField\FontSizeField;
|
4 |
use luckywp\tableOfContents\admin\widgets\skipHeadingLevelField\SkipHeadingLevelField;
|
5 |
use luckywp\tableOfContents\admin\widgets\widthField\WidthField;
|
@@ -80,7 +81,6 @@ return [
|
|
80 |
],
|
81 |
],
|
82 |
],
|
83 |
-
|
84 |
'header' => [
|
85 |
'title' => esc_html__('Header', 'luckywp-table-of-contents'),
|
86 |
'fields' => [
|
@@ -492,4 +492,9 @@ return [
|
|
492 |
],
|
493 |
],
|
494 |
],
|
|
|
|
|
|
|
|
|
|
|
495 |
];
|
1 |
<?php
|
2 |
|
3 |
+
use luckywp\tableOfContents\admin\controllers\SettingsController;
|
4 |
use luckywp\tableOfContents\admin\widgets\fontSizeField\FontSizeField;
|
5 |
use luckywp\tableOfContents\admin\widgets\skipHeadingLevelField\SkipHeadingLevelField;
|
6 |
use luckywp\tableOfContents\admin\widgets\widthField\WidthField;
|
81 |
],
|
82 |
],
|
83 |
],
|
|
|
84 |
'header' => [
|
85 |
'title' => esc_html__('Header', 'luckywp-table-of-contents'),
|
86 |
'fields' => [
|
492 |
],
|
493 |
],
|
494 |
],
|
495 |
+
|
496 |
+
'plugins' => [
|
497 |
+
'label' => esc_html__('LuckyWP Plugins', 'luckywp-table-of-contents'),
|
498 |
+
'callback' => [SettingsController::getInstance(), 'plugins'],
|
499 |
+
],
|
500 |
];
|
core/wp/Settings.php
CHANGED
@@ -165,7 +165,13 @@ class Settings extends BaseObject
|
|
165 |
'id' => $this->prefix . $groupId,
|
166 |
'name' => $groupId,
|
167 |
'label' => ArrayHelper::getValue($config, 'label', $groupId),
|
|
|
168 |
];
|
|
|
|
|
|
|
|
|
|
|
169 |
$this->groups[$group['id']] = $group;
|
170 |
$this->addSections($groupId, ArrayHelper::getValue($config, 'sections', []));
|
171 |
return $this;
|
@@ -398,8 +404,7 @@ class Settings extends BaseObject
|
|
398 |
}
|
399 |
|
400 |
reset($this->groups);
|
401 |
-
|
402 |
-
return $group;
|
403 |
}
|
404 |
|
405 |
/**
|
@@ -456,7 +461,7 @@ class Settings extends BaseObject
|
|
456 |
if (count($this->groups) > 1) {
|
457 |
$this->showTabs();
|
458 |
}
|
459 |
-
$this->
|
460 |
}
|
461 |
|
462 |
|
165 |
'id' => $this->prefix . $groupId,
|
166 |
'name' => $groupId,
|
167 |
'label' => ArrayHelper::getValue($config, 'label', $groupId),
|
168 |
+
'callback' => ArrayHelper::getValue($config, 'callback'),
|
169 |
];
|
170 |
+
|
171 |
+
if (!is_callable($group['callback'])) {
|
172 |
+
$group['callback'] = [$this, 'showForm'];
|
173 |
+
}
|
174 |
+
|
175 |
$this->groups[$group['id']] = $group;
|
176 |
$this->addSections($groupId, ArrayHelper::getValue($config, 'sections', []));
|
177 |
return $this;
|
404 |
}
|
405 |
|
406 |
reset($this->groups);
|
407 |
+
return current($this->groups);
|
|
|
408 |
}
|
409 |
|
410 |
/**
|
461 |
if (count($this->groups) > 1) {
|
462 |
$this->showTabs();
|
463 |
}
|
464 |
+
call_user_func($this->getCurrentGroup()['callback']);
|
465 |
}
|
466 |
|
467 |
|
front/Front.php
CHANGED
@@ -101,7 +101,7 @@ class Front extends BaseFront
|
|
101 |
return $content;
|
102 |
}
|
103 |
|
104 |
-
if (
|
105 |
return $content;
|
106 |
}
|
107 |
|
@@ -144,7 +144,7 @@ class Front extends BaseFront
|
|
144 |
$attrs['skipHeadingLevel'] = $settings->skipHeadingLevel;
|
145 |
$attrs['skipHeadingText'] = $settings->skipHeadingText;
|
146 |
|
147 |
-
$shortcode = Core::$plugin->shortcode->make($attrs);
|
148 |
|
149 |
$position = $settings->position ? $settings->position : Core::$plugin->settings->autoInsertPosition;
|
150 |
switch ($position) {
|
@@ -163,9 +163,9 @@ class Front extends BaseFront
|
|
163 |
}
|
164 |
|
165 |
if ($position == 'afterfirstheading') {
|
166 |
-
Dom::
|
167 |
} else {
|
168 |
-
Dom::
|
169 |
}
|
170 |
|
171 |
return Dom::getBody($dom);
|
@@ -182,7 +182,7 @@ class Front extends BaseFront
|
|
182 |
return $shortcode . $content;
|
183 |
}
|
184 |
|
185 |
-
Dom::
|
186 |
|
187 |
return Dom::getBody($dom);
|
188 |
|
101 |
return $content;
|
102 |
}
|
103 |
|
104 |
+
if (Core::$plugin->shortcode->hasShorcode($content)) {
|
105 |
return $content;
|
106 |
}
|
107 |
|
144 |
$attrs['skipHeadingLevel'] = $settings->skipHeadingLevel;
|
145 |
$attrs['skipHeadingText'] = $settings->skipHeadingText;
|
146 |
|
147 |
+
$shortcode = Core::$plugin->shortcode->make($attrs, true);
|
148 |
|
149 |
$position = $settings->position ? $settings->position : Core::$plugin->settings->autoInsertPosition;
|
150 |
switch ($position) {
|
163 |
}
|
164 |
|
165 |
if ($position == 'afterfirstheading') {
|
166 |
+
Dom::afterNodeInsertShortcode($nodes->item(0), $shortcode);
|
167 |
} else {
|
168 |
+
Dom::beforeNodeInsertShortcode($nodes->item(0), $shortcode);
|
169 |
}
|
170 |
|
171 |
return Dom::getBody($dom);
|
182 |
return $shortcode . $content;
|
183 |
}
|
184 |
|
185 |
+
Dom::afterNodeInsertShortcode($nodes->item(0), $shortcode);
|
186 |
|
187 |
return Dom::getBody($dom);
|
188 |
|
front/views/items.php
CHANGED
@@ -16,7 +16,7 @@ foreach ($items as $item) {
|
|
16 |
<?php if ($item['number']) { ?>
|
17 |
<span class="lwptoc_item_number"><?= $item['number'] . $item['numberSuffix'] ?></span>
|
18 |
<?php } ?>
|
19 |
-
<span class="lwptoc_item_label"><?= $item['label'] ?></span>
|
20 |
</a>
|
21 |
<?php
|
22 |
lwptoc_items($item['childrens']);
|
16 |
<?php if ($item['number']) { ?>
|
17 |
<span class="lwptoc_item_number"><?= $item['number'] . $item['numberSuffix'] ?></span>
|
18 |
<?php } ?>
|
19 |
+
<span class="lwptoc_item_label"><?= esc_html($item['label']) ?></span>
|
20 |
</a>
|
21 |
<?php
|
22 |
lwptoc_items($item['childrens']);
|
integrations/ToolsetViews.php
CHANGED
@@ -30,7 +30,7 @@ class ToolsetViews extends BaseObject
|
|
30 |
|
31 |
public function theContent($content)
|
32 |
{
|
33 |
-
$this->hasShortcode =
|
34 |
return $content;
|
35 |
}
|
36 |
}
|
30 |
|
31 |
public function theContent($content)
|
32 |
{
|
33 |
+
$this->hasShortcode = Core::$plugin->shortcode->hasShorcode($content);
|
34 |
return $content;
|
35 |
}
|
36 |
}
|
languages/luckywp-table-of-contents-ru_RU.mo
CHANGED
Binary file
|
languages/luckywp-table-of-contents.pot
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: \n"
|
4 |
-
"POT-Creation-Date: 2020-
|
5 |
-
"PO-Revision-Date: 2020-
|
6 |
"Last-Translator: \n"
|
7 |
"Language-Team: \n"
|
8 |
"Language: ru_RU\n"
|
@@ -17,13 +17,13 @@ msgstr ""
|
|
17 |
"X-Poedit-SearchPath-0: .\n"
|
18 |
"X-Poedit-SearchPathExcluded-0: plugin/editorBlock/src\n"
|
19 |
|
20 |
-
#: admin/Admin.php:34 admin/SiteHealth.php:
|
21 |
msgid "Settings"
|
22 |
msgstr ""
|
23 |
|
24 |
#: admin/Admin.php:54 admin/Admin.php:55 admin/Admin.php:75 admin/Admin.php:113
|
25 |
#: admin/controllers/EditorBlockController.php:65
|
26 |
-
#: admin/controllers/ShortcodeController.php:
|
27 |
#: plugin/WpWidget.php:22
|
28 |
msgid "Table of Contents"
|
29 |
msgstr ""
|
@@ -38,17 +38,17 @@ msgid "Position"
|
|
38 |
msgstr ""
|
39 |
|
40 |
#: admin/Admin.php:145 admin/widgets/customizeModal/views/modal.php:76
|
41 |
-
#: config/settings.php:
|
42 |
msgid "Minimal Count of Headings"
|
43 |
msgstr ""
|
44 |
|
45 |
#: admin/Admin.php:148 admin/forms/CustomizeForm.php:241
|
46 |
-
#: admin/widgets/customizeModal/views/modal.php:99 config/settings.php:
|
47 |
msgid "Depth"
|
48 |
msgstr ""
|
49 |
|
50 |
#: admin/Admin.php:151 admin/widgets/customizeModal/views/modal.php:121
|
51 |
-
#: config/settings.php:
|
52 |
msgid "Hierarchical View"
|
53 |
msgstr ""
|
54 |
|
@@ -75,12 +75,12 @@ msgid "Disabled"
|
|
75 |
msgstr ""
|
76 |
|
77 |
#: admin/Admin.php:154 admin/forms/CustomizeForm.php:242
|
78 |
-
#: admin/widgets/customizeModal/views/modal.php:144 config/settings.php:
|
79 |
msgid "Numeration"
|
80 |
msgstr ""
|
81 |
|
82 |
#: admin/Admin.php:157 admin/forms/CustomizeForm.php:243
|
83 |
-
#: admin/widgets/customizeModal/views/modal.php:166 config/settings.php:
|
84 |
msgid "Numeration Suffix"
|
85 |
msgstr ""
|
86 |
|
@@ -167,7 +167,8 @@ msgstr ""
|
|
167 |
msgid "DOM/XML Version"
|
168 |
msgstr ""
|
169 |
|
170 |
-
#: admin/SiteHealth.php:27 admin/SiteHealth.php:31
|
|
|
171 |
msgid "not loaded"
|
172 |
msgstr ""
|
173 |
|
@@ -175,12 +176,20 @@ msgstr ""
|
|
175 |
msgid "libXML Version"
|
176 |
msgstr ""
|
177 |
|
178 |
-
#: admin/SiteHealth.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
msgid "encoded data to copy"
|
180 |
msgstr ""
|
181 |
|
182 |
#: admin/controllers/EditorBlockController.php:71
|
183 |
-
#: admin/controllers/ShortcodeController.php:
|
184 |
#: admin/widgets/customizeModal/views/modal.php:570
|
185 |
#: admin/widgets/metabox/views/box.php:33
|
186 |
#: admin/widgets/widget/views/_override.php:18
|
@@ -243,7 +252,7 @@ msgstr ""
|
|
243 |
msgid "Customize Table of Contents"
|
244 |
msgstr ""
|
245 |
|
246 |
-
#: admin/widgets/customizeModal/views/modal.php:43 config/settings.php:
|
247 |
msgid "General"
|
248 |
msgstr ""
|
249 |
|
@@ -282,7 +291,7 @@ msgstr ""
|
|
282 |
msgid "default"
|
283 |
msgstr ""
|
284 |
|
285 |
-
#: admin/widgets/customizeModal/views/modal.php:89 config/settings.php:
|
286 |
msgid ""
|
287 |
"If the count of headings in the post is less, then table of contents is not "
|
288 |
"displayed."
|
@@ -293,7 +302,7 @@ msgstr ""
|
|
293 |
#: admin/widgets/customizeModal/views/modal.php:286
|
294 |
#: admin/widgets/customizeModal/views/modal.php:309
|
295 |
#: admin/widgets/customizeModal/views/modal.php:594
|
296 |
-
#: admin/widgets/customizeModal/views/modal.php:621 config/settings.php:
|
297 |
#: config/settings.php:99 config/settings.php:150 config/settings.php:297
|
298 |
msgid "Enable"
|
299 |
msgstr ""
|
@@ -332,11 +341,11 @@ msgstr ""
|
|
332 |
msgid "Saved!"
|
333 |
msgstr ""
|
334 |
|
335 |
-
#: admin/widgets/fontSizeField/views/widget.php:16 plugin/Plugin.php:
|
336 |
msgid "Default"
|
337 |
msgstr ""
|
338 |
|
339 |
-
#: admin/widgets/fontSizeField/views/widget.php:17 plugin/Plugin.php:
|
340 |
msgid "Custom Value"
|
341 |
msgstr ""
|
342 |
|
@@ -384,7 +393,7 @@ msgstr ""
|
|
384 |
msgid "Enable TOC"
|
385 |
msgstr ""
|
386 |
|
387 |
-
#: config/settings.php:
|
388 |
#, php-format
|
389 |
msgid "The symbol will be added after numeration. For example, %s"
|
390 |
msgstr ""
|
@@ -506,6 +515,10 @@ msgstr ""
|
|
506 |
msgid "List Markup Tags"
|
507 |
msgstr ""
|
508 |
|
|
|
|
|
|
|
|
|
509 |
#: core/admin/AdminController.php:46
|
510 |
msgid "Sorry, you are not allowed to access this page."
|
511 |
msgstr ""
|
@@ -530,144 +543,144 @@ msgstr ""
|
|
530 |
msgid "%1$s plugin require PHP extension %2$s to work."
|
531 |
msgstr ""
|
532 |
|
533 |
-
#: plugin/Plugin.php:
|
534 |
msgid "Without numeration"
|
535 |
msgstr ""
|
536 |
|
537 |
-
#: plugin/Plugin.php:
|
538 |
msgid "Decimal numbers (nested)"
|
539 |
msgstr ""
|
540 |
|
541 |
-
#: plugin/Plugin.php:
|
542 |
msgid "Decimal numbers"
|
543 |
msgstr ""
|
544 |
|
545 |
-
#: plugin/Plugin.php:
|
546 |
msgid "Roman numbers (nested)"
|
547 |
msgstr ""
|
548 |
|
549 |
-
#: plugin/Plugin.php:
|
550 |
msgid "Roman numbers"
|
551 |
msgstr ""
|
552 |
|
553 |
-
#: plugin/Plugin.php:
|
554 |
msgid "None"
|
555 |
msgstr ""
|
556 |
|
557 |
-
#: plugin/Plugin.php:
|
558 |
msgid "Before first heading"
|
559 |
msgstr ""
|
560 |
|
561 |
-
#: plugin/Plugin.php:
|
562 |
msgid "After first heading"
|
563 |
msgstr ""
|
564 |
|
565 |
-
#: plugin/Plugin.php:
|
566 |
msgid "After first block (paragraph or heading)"
|
567 |
msgstr ""
|
568 |
|
569 |
-
#: plugin/Plugin.php:
|
570 |
msgid "Top"
|
571 |
msgstr ""
|
572 |
|
573 |
-
#: plugin/Plugin.php:
|
574 |
msgid "Bottom"
|
575 |
msgstr ""
|
576 |
|
577 |
-
#: plugin/Plugin.php:
|
578 |
msgid "Thin"
|
579 |
msgstr ""
|
580 |
|
581 |
-
#: plugin/Plugin.php:
|
582 |
msgid "Extra Light"
|
583 |
msgstr ""
|
584 |
|
585 |
-
#: plugin/Plugin.php:
|
586 |
msgid "Light"
|
587 |
msgstr ""
|
588 |
|
589 |
-
#: plugin/Plugin.php:
|
590 |
msgid "Normal"
|
591 |
msgstr ""
|
592 |
|
593 |
-
#: plugin/Plugin.php:
|
594 |
msgid "Medium"
|
595 |
msgstr ""
|
596 |
|
597 |
-
#: plugin/Plugin.php:
|
598 |
msgid "Semi Bold"
|
599 |
msgstr ""
|
600 |
|
601 |
-
#: plugin/Plugin.php:
|
602 |
msgid "Bold"
|
603 |
msgstr ""
|
604 |
|
605 |
-
#: plugin/Plugin.php:
|
606 |
msgid "Extra Bold"
|
607 |
msgstr ""
|
608 |
|
609 |
-
#: plugin/Plugin.php:
|
610 |
msgid "Heavy"
|
611 |
msgstr ""
|
612 |
|
613 |
-
#: plugin/Plugin.php:
|
614 |
msgid "Left"
|
615 |
msgstr ""
|
616 |
|
617 |
-
#: plugin/Plugin.php:
|
618 |
msgid "Right"
|
619 |
msgstr ""
|
620 |
|
621 |
-
#: plugin/Plugin.php:
|
622 |
msgid "Right without flow"
|
623 |
msgstr ""
|
624 |
|
625 |
-
#: plugin/Plugin.php:
|
626 |
msgid "Center"
|
627 |
msgstr ""
|
628 |
|
629 |
-
#: plugin/Plugin.php:
|
630 |
msgid "Light Colors"
|
631 |
msgstr ""
|
632 |
|
633 |
-
#: plugin/Plugin.php:
|
634 |
msgid "Dark Colors"
|
635 |
msgstr ""
|
636 |
|
637 |
-
#: plugin/Plugin.php:
|
638 |
msgid "White"
|
639 |
msgstr ""
|
640 |
|
641 |
-
#: plugin/Plugin.php:
|
642 |
msgid "Transparent"
|
643 |
msgstr ""
|
644 |
|
645 |
-
#: plugin/Plugin.php:
|
646 |
msgid "Inherit from theme"
|
647 |
msgstr ""
|
648 |
|
649 |
-
#: plugin/Plugin.php:
|
650 |
msgid "As heading (#Example_Heading_Text)"
|
651 |
msgstr ""
|
652 |
|
653 |
-
#: plugin/Plugin.php:
|
654 |
msgid "As heading without transliterate (#Example_Heading_Text)"
|
655 |
msgstr ""
|
656 |
|
657 |
-
#: plugin/Plugin.php:
|
658 |
#, php-format
|
659 |
msgid "Counter %s"
|
660 |
msgstr ""
|
661 |
|
662 |
-
#: plugin/Plugin.php:
|
663 |
msgid "Auto"
|
664 |
msgstr ""
|
665 |
|
666 |
-
#: plugin/Plugin.php:
|
667 |
msgid "Full Width"
|
668 |
msgstr ""
|
669 |
|
670 |
-
#: plugin/Plugin.php:
|
671 |
msgid ""
|
672 |
"Creates a table of contents for your posts/pages. Works automatically or "
|
673 |
"manually (via shortcode, Gutenberg block or widget)."
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: \n"
|
4 |
+
"POT-Creation-Date: 2020-02-23 18:48+0300\n"
|
5 |
+
"PO-Revision-Date: 2020-02-23 18:48+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:34 admin/SiteHealth.php:42
|
21 |
msgid "Settings"
|
22 |
msgstr ""
|
23 |
|
24 |
#: admin/Admin.php:54 admin/Admin.php:55 admin/Admin.php:75 admin/Admin.php:113
|
25 |
#: admin/controllers/EditorBlockController.php:65
|
26 |
+
#: admin/controllers/ShortcodeController.php:60 plugin/Plugin.php:476
|
27 |
#: plugin/WpWidget.php:22
|
28 |
msgid "Table of Contents"
|
29 |
msgstr ""
|
38 |
msgstr ""
|
39 |
|
40 |
#: admin/Admin.php:145 admin/widgets/customizeModal/views/modal.php:76
|
41 |
+
#: config/settings.php:23
|
42 |
msgid "Minimal Count of Headings"
|
43 |
msgstr ""
|
44 |
|
45 |
#: admin/Admin.php:148 admin/forms/CustomizeForm.php:241
|
46 |
+
#: admin/widgets/customizeModal/views/modal.php:99 config/settings.php:35
|
47 |
msgid "Depth"
|
48 |
msgstr ""
|
49 |
|
50 |
#: admin/Admin.php:151 admin/widgets/customizeModal/views/modal.php:121
|
51 |
+
#: config/settings.php:44
|
52 |
msgid "Hierarchical View"
|
53 |
msgstr ""
|
54 |
|
75 |
msgstr ""
|
76 |
|
77 |
#: admin/Admin.php:154 admin/forms/CustomizeForm.php:242
|
78 |
+
#: admin/widgets/customizeModal/views/modal.php:144 config/settings.php:55
|
79 |
msgid "Numeration"
|
80 |
msgstr ""
|
81 |
|
82 |
#: admin/Admin.php:157 admin/forms/CustomizeForm.php:243
|
83 |
+
#: admin/widgets/customizeModal/views/modal.php:166 config/settings.php:67
|
84 |
msgid "Numeration Suffix"
|
85 |
msgstr ""
|
86 |
|
167 |
msgid "DOM/XML Version"
|
168 |
msgstr ""
|
169 |
|
170 |
+
#: admin/SiteHealth.php:27 admin/SiteHealth.php:31 admin/SiteHealth.php:35
|
171 |
+
#: admin/SiteHealth.php:39
|
172 |
msgid "not loaded"
|
173 |
msgstr ""
|
174 |
|
176 |
msgid "libXML Version"
|
177 |
msgstr ""
|
178 |
|
179 |
+
#: admin/SiteHealth.php:34
|
180 |
+
msgid "intl Version"
|
181 |
+
msgstr ""
|
182 |
+
|
183 |
+
#: admin/SiteHealth.php:38
|
184 |
+
msgid "ICU Version"
|
185 |
+
msgstr ""
|
186 |
+
|
187 |
+
#: admin/SiteHealth.php:43
|
188 |
msgid "encoded data to copy"
|
189 |
msgstr ""
|
190 |
|
191 |
#: admin/controllers/EditorBlockController.php:71
|
192 |
+
#: admin/controllers/ShortcodeController.php:66
|
193 |
#: admin/widgets/customizeModal/views/modal.php:570
|
194 |
#: admin/widgets/metabox/views/box.php:33
|
195 |
#: admin/widgets/widget/views/_override.php:18
|
252 |
msgid "Customize Table of Contents"
|
253 |
msgstr ""
|
254 |
|
255 |
+
#: admin/widgets/customizeModal/views/modal.php:43 config/settings.php:17
|
256 |
msgid "General"
|
257 |
msgstr ""
|
258 |
|
291 |
msgid "default"
|
292 |
msgstr ""
|
293 |
|
294 |
+
#: admin/widgets/customizeModal/views/modal.php:89 config/settings.php:31
|
295 |
msgid ""
|
296 |
"If the count of headings in the post is less, then table of contents is not "
|
297 |
"displayed."
|
302 |
#: admin/widgets/customizeModal/views/modal.php:286
|
303 |
#: admin/widgets/customizeModal/views/modal.php:309
|
304 |
#: admin/widgets/customizeModal/views/modal.php:594
|
305 |
+
#: admin/widgets/customizeModal/views/modal.php:621 config/settings.php:48
|
306 |
#: config/settings.php:99 config/settings.php:150 config/settings.php:297
|
307 |
msgid "Enable"
|
308 |
msgstr ""
|
341 |
msgid "Saved!"
|
342 |
msgstr ""
|
343 |
|
344 |
+
#: admin/widgets/fontSizeField/views/widget.php:16 plugin/Plugin.php:331
|
345 |
msgid "Default"
|
346 |
msgstr ""
|
347 |
|
348 |
+
#: admin/widgets/fontSizeField/views/widget.php:17 plugin/Plugin.php:296
|
349 |
msgid "Custom Value"
|
350 |
msgstr ""
|
351 |
|
393 |
msgid "Enable TOC"
|
394 |
msgstr ""
|
395 |
|
396 |
+
#: config/settings.php:78
|
397 |
#, php-format
|
398 |
msgid "The symbol will be added after numeration. For example, %s"
|
399 |
msgstr ""
|
515 |
msgid "List Markup Tags"
|
516 |
msgstr ""
|
517 |
|
518 |
+
#: config/settings.php:497
|
519 |
+
msgid "LuckyWP Plugins"
|
520 |
+
msgstr ""
|
521 |
+
|
522 |
#: core/admin/AdminController.php:46
|
523 |
msgid "Sorry, you are not allowed to access this page."
|
524 |
msgstr ""
|
543 |
msgid "%1$s plugin require PHP extension %2$s to work."
|
544 |
msgstr ""
|
545 |
|
546 |
+
#: plugin/Plugin.php:148
|
547 |
msgid "Without numeration"
|
548 |
msgstr ""
|
549 |
|
550 |
+
#: plugin/Plugin.php:149
|
551 |
msgid "Decimal numbers (nested)"
|
552 |
msgstr ""
|
553 |
|
554 |
+
#: plugin/Plugin.php:150
|
555 |
msgid "Decimal numbers"
|
556 |
msgstr ""
|
557 |
|
558 |
+
#: plugin/Plugin.php:151
|
559 |
msgid "Roman numbers (nested)"
|
560 |
msgstr ""
|
561 |
|
562 |
+
#: plugin/Plugin.php:152
|
563 |
msgid "Roman numbers"
|
564 |
msgstr ""
|
565 |
|
566 |
+
#: plugin/Plugin.php:162 plugin/Plugin.php:249 plugin/Plugin.php:393
|
567 |
msgid "None"
|
568 |
msgstr ""
|
569 |
|
570 |
+
#: plugin/Plugin.php:174
|
571 |
msgid "Before first heading"
|
572 |
msgstr ""
|
573 |
|
574 |
+
#: plugin/Plugin.php:175
|
575 |
msgid "After first heading"
|
576 |
msgstr ""
|
577 |
|
578 |
+
#: plugin/Plugin.php:176
|
579 |
msgid "After first block (paragraph or heading)"
|
580 |
msgstr ""
|
581 |
|
582 |
+
#: plugin/Plugin.php:177
|
583 |
msgid "Top"
|
584 |
msgstr ""
|
585 |
|
586 |
+
#: plugin/Plugin.php:178
|
587 |
msgid "Bottom"
|
588 |
msgstr ""
|
589 |
|
590 |
+
#: plugin/Plugin.php:212
|
591 |
msgid "Thin"
|
592 |
msgstr ""
|
593 |
|
594 |
+
#: plugin/Plugin.php:213
|
595 |
msgid "Extra Light"
|
596 |
msgstr ""
|
597 |
|
598 |
+
#: plugin/Plugin.php:214
|
599 |
msgid "Light"
|
600 |
msgstr ""
|
601 |
|
602 |
+
#: plugin/Plugin.php:215
|
603 |
msgid "Normal"
|
604 |
msgstr ""
|
605 |
|
606 |
+
#: plugin/Plugin.php:216
|
607 |
msgid "Medium"
|
608 |
msgstr ""
|
609 |
|
610 |
+
#: plugin/Plugin.php:217
|
611 |
msgid "Semi Bold"
|
612 |
msgstr ""
|
613 |
|
614 |
+
#: plugin/Plugin.php:218
|
615 |
msgid "Bold"
|
616 |
msgstr ""
|
617 |
|
618 |
+
#: plugin/Plugin.php:219
|
619 |
msgid "Extra Bold"
|
620 |
msgstr ""
|
621 |
|
622 |
+
#: plugin/Plugin.php:220
|
623 |
msgid "Heavy"
|
624 |
msgstr ""
|
625 |
|
626 |
+
#: plugin/Plugin.php:250
|
627 |
msgid "Left"
|
628 |
msgstr ""
|
629 |
|
630 |
+
#: plugin/Plugin.php:251
|
631 |
msgid "Right"
|
632 |
msgstr ""
|
633 |
|
634 |
+
#: plugin/Plugin.php:252
|
635 |
msgid "Right without flow"
|
636 |
msgstr ""
|
637 |
|
638 |
+
#: plugin/Plugin.php:253
|
639 |
msgid "Center"
|
640 |
msgstr ""
|
641 |
|
642 |
+
#: plugin/Plugin.php:263
|
643 |
msgid "Light Colors"
|
644 |
msgstr ""
|
645 |
|
646 |
+
#: plugin/Plugin.php:264
|
647 |
msgid "Dark Colors"
|
648 |
msgstr ""
|
649 |
|
650 |
+
#: plugin/Plugin.php:265
|
651 |
msgid "White"
|
652 |
msgstr ""
|
653 |
|
654 |
+
#: plugin/Plugin.php:266
|
655 |
msgid "Transparent"
|
656 |
msgstr ""
|
657 |
|
658 |
+
#: plugin/Plugin.php:267
|
659 |
msgid "Inherit from theme"
|
660 |
msgstr ""
|
661 |
|
662 |
+
#: plugin/Plugin.php:277
|
663 |
msgid "As heading (#Example_Heading_Text)"
|
664 |
msgstr ""
|
665 |
|
666 |
+
#: plugin/Plugin.php:278
|
667 |
msgid "As heading without transliterate (#Example_Heading_Text)"
|
668 |
msgstr ""
|
669 |
|
670 |
+
#: plugin/Plugin.php:281
|
671 |
#, php-format
|
672 |
msgid "Counter %s"
|
673 |
msgstr ""
|
674 |
|
675 |
+
#: plugin/Plugin.php:294
|
676 |
msgid "Auto"
|
677 |
msgstr ""
|
678 |
|
679 |
+
#: plugin/Plugin.php:295
|
680 |
msgid "Full Width"
|
681 |
msgstr ""
|
682 |
|
683 |
+
#: plugin/Plugin.php:481
|
684 |
msgid ""
|
685 |
"Creates a table of contents for your posts/pages. Works automatically or "
|
686 |
"manually (via shortcode, Gutenberg block or widget)."
|
luckywp-table-of-contents.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: LuckyWP Table of Contents
|
4 |
Plugin URI: https://theluckywp.com/product/table-of-contents/
|
5 |
Description: Creates a table of contents for your posts/pages. Works automatically or manually (via shortcode, Gutenberg block or widget).
|
6 |
-
Version: 2.0.
|
7 |
Author: LuckyWP
|
8 |
Author URI: https://theluckywp.com/
|
9 |
Text Domain: luckywp-table-of-contents
|
@@ -47,6 +47,6 @@ $lwptocAutoloader->register();
|
|
47 |
$lwptocAutoloader->addNamespace('luckywp\tableOfContents', __DIR__);
|
48 |
|
49 |
$config = require(__DIR__ . '/config/plugin.php');
|
50 |
-
(new \luckywp\tableOfContents\plugin\Plugin($config))->run('2.0.
|
51 |
|
52 |
require_once __DIR__ . '/functions.php';
|
3 |
Plugin Name: LuckyWP Table of Contents
|
4 |
Plugin URI: https://theluckywp.com/product/table-of-contents/
|
5 |
Description: Creates a table of contents for your posts/pages. Works automatically or manually (via shortcode, Gutenberg block or widget).
|
6 |
+
Version: 2.0.8
|
7 |
Author: LuckyWP
|
8 |
Author URI: https://theluckywp.com/
|
9 |
Text Domain: luckywp-table-of-contents
|
47 |
$lwptocAutoloader->addNamespace('luckywp\tableOfContents', __DIR__);
|
48 |
|
49 |
$config = require(__DIR__ . '/config/plugin.php');
|
50 |
+
(new \luckywp\tableOfContents\plugin\Plugin($config))->run('2.0.8', __FILE__, 'lwptoc_');
|
51 |
|
52 |
require_once __DIR__ . '/functions.php';
|
plugin/Plugin.php
CHANGED
@@ -83,7 +83,7 @@ class Plugin extends BasePlugin
|
|
83 |
|
84 |
// Интеграция с темами
|
85 |
add_action('init', function () {
|
86 |
-
|
87 |
Core::createObject(TwentyTwentyTheme::class);
|
88 |
}
|
89 |
});
|
@@ -448,8 +448,12 @@ class Plugin extends BasePlugin
|
|
448 |
}
|
449 |
$regex = [];
|
450 |
foreach ($src as $t) {
|
|
|
|
|
|
|
|
|
451 |
$t = strtr($t, [
|
452 |
-
'
|
453 |
'\*' => '%%lwptocstar%%',
|
454 |
]);
|
455 |
$t = str_replace('*', '___lwptocany___', $t);
|
83 |
|
84 |
// Интеграция с темами
|
85 |
add_action('init', function () {
|
86 |
+
if (get_template() == 'twentytwenty') {
|
87 |
Core::createObject(TwentyTwentyTheme::class);
|
88 |
}
|
89 |
});
|
448 |
}
|
449 |
$regex = [];
|
450 |
foreach ($src as $t) {
|
451 |
+
$t = trim(preg_replace('/\s+/u', ' ', $t));
|
452 |
+
if ($t == '') {
|
453 |
+
continue;
|
454 |
+
}
|
455 |
$t = strtr($t, [
|
456 |
+
'\\' => '%%lwptocslash%%',
|
457 |
'\*' => '%%lwptocstar%%',
|
458 |
]);
|
459 |
$t = str_replace('*', '___lwptocany___', $t);
|
plugin/Shortcode.php
CHANGED
@@ -59,7 +59,8 @@ class Shortcode extends BaseObject
|
|
59 |
public function shortcode($attrs)
|
60 |
{
|
61 |
global $post;
|
62 |
-
if (
|
|
|
63 |
(!is_single($post) && !is_page($post)) ||
|
64 |
!$this->isMainQueryPost()
|
65 |
) {
|
@@ -110,7 +111,7 @@ class Shortcode extends BaseObject
|
|
110 |
}
|
111 |
|
112 |
if (Core::$plugin->isTheContent) {
|
113 |
-
return $this->make($attrs);
|
114 |
}
|
115 |
|
116 |
if (!$this->theContentApplied) {
|
@@ -138,7 +139,9 @@ class Shortcode extends BaseObject
|
|
138 |
*/
|
139 |
public function theContent($content)
|
140 |
{
|
141 |
-
if (
|
|
|
|
|
142 |
return $content;
|
143 |
}
|
144 |
|
@@ -147,7 +150,7 @@ class Shortcode extends BaseObject
|
|
147 |
$dto->modify = true;
|
148 |
|
149 |
$shortcodesAttrs = [];
|
150 |
-
preg_match_all($this->getShortcodeRegex(), $content, $matches);
|
151 |
foreach ($matches[3] as $match) {
|
152 |
$shortcodesAttrs[] = ValueHelper::assertArray(shortcode_parse_atts($match));
|
153 |
}
|
@@ -193,7 +196,7 @@ class Shortcode extends BaseObject
|
|
193 |
|
194 |
return preg_replace_callback($this->getShortcodeRegex(), function ($m) use ($result) {
|
195 |
return Toc::render($result->headings, shortcode_parse_atts($m[3]));
|
196 |
-
}, $result->content);
|
197 |
}
|
198 |
|
199 |
/**
|
@@ -230,7 +233,7 @@ class Shortcode extends BaseObject
|
|
230 |
return false;
|
231 |
}
|
232 |
|
233 |
-
if (
|
234 |
return true;
|
235 |
}
|
236 |
|
@@ -262,9 +265,10 @@ class Shortcode extends BaseObject
|
|
262 |
|
263 |
/**
|
264 |
* @param array $attrs
|
|
|
265 |
* @return string
|
266 |
*/
|
267 |
-
public function make($attrs)
|
268 |
{
|
269 |
$shortcode = '[' . $this->getTag();
|
270 |
foreach ($attrs as $k => $v) {
|
@@ -278,7 +282,28 @@ class Shortcode extends BaseObject
|
|
278 |
}
|
279 |
}
|
280 |
$shortcode .= ']';
|
281 |
-
return $shortcode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
}
|
283 |
|
284 |
/**
|
@@ -297,4 +322,12 @@ class Shortcode extends BaseObject
|
|
297 |
{
|
298 |
return ValueHelper::assertArray(Json::decode($json));
|
299 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
}
|
59 |
public function shortcode($attrs)
|
60 |
{
|
61 |
global $post;
|
62 |
+
if ($this->isDiactivated() ||
|
63 |
+
($this->theContentApplied && $this->headingsCache === null) ||
|
64 |
(!is_single($post) && !is_page($post)) ||
|
65 |
!$this->isMainQueryPost()
|
66 |
) {
|
111 |
}
|
112 |
|
113 |
if (Core::$plugin->isTheContent) {
|
114 |
+
return $this->make($attrs, true);
|
115 |
}
|
116 |
|
117 |
if (!$this->theContentApplied) {
|
139 |
*/
|
140 |
public function theContent($content)
|
141 |
{
|
142 |
+
if ($this->isDiactivated() ||
|
143 |
+
!apply_filters('lwptoc_need_processing_headings', $this->needProcessHeadings($content), $content)
|
144 |
+
) {
|
145 |
return $content;
|
146 |
}
|
147 |
|
150 |
$dto->modify = true;
|
151 |
|
152 |
$shortcodesAttrs = [];
|
153 |
+
preg_match_all($this->getShortcodeRegex(), $this->decodeShorcode($content), $matches);
|
154 |
foreach ($matches[3] as $match) {
|
155 |
$shortcodesAttrs[] = ValueHelper::assertArray(shortcode_parse_atts($match));
|
156 |
}
|
196 |
|
197 |
return preg_replace_callback($this->getShortcodeRegex(), function ($m) use ($result) {
|
198 |
return Toc::render($result->headings, shortcode_parse_atts($m[3]));
|
199 |
+
}, $this->decodeShorcode($result->content));
|
200 |
}
|
201 |
|
202 |
/**
|
233 |
return false;
|
234 |
}
|
235 |
|
236 |
+
if ($this->hasShorcode($content)) {
|
237 |
return true;
|
238 |
}
|
239 |
|
265 |
|
266 |
/**
|
267 |
* @param array $attrs
|
268 |
+
* @param bool $encode
|
269 |
* @return string
|
270 |
*/
|
271 |
+
public function make($attrs, $encode = false)
|
272 |
{
|
273 |
$shortcode = '[' . $this->getTag();
|
274 |
foreach ($attrs as $k => $v) {
|
282 |
}
|
283 |
}
|
284 |
$shortcode .= ']';
|
285 |
+
return $encode ? '<!-- lwptocEncodedToc ' . base64_encode($shortcode) . ' -->' : $shortcode;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* @param string $content
|
290 |
+
* @return string
|
291 |
+
*/
|
292 |
+
protected function decodeShorcode($content)
|
293 |
+
{
|
294 |
+
return preg_replace_callback('#<!-- lwptocEncodedToc (.*?) -->#imsu', function ($matches) {
|
295 |
+
return base64_decode($matches[1]);
|
296 |
+
}, $content);
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* @param string $content
|
301 |
+
* @return bool
|
302 |
+
*/
|
303 |
+
public function hasShorcode($content)
|
304 |
+
{
|
305 |
+
return has_shortcode($content, $this->getTag()) ||
|
306 |
+
preg_match('#<!-- lwptocEncodedToc (.*?) -->#imsu', $content) === 1;
|
307 |
}
|
308 |
|
309 |
/**
|
322 |
{
|
323 |
return ValueHelper::assertArray(Json::decode($json));
|
324 |
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* @return bool
|
328 |
+
*/
|
329 |
+
protected function isDiactivated()
|
330 |
+
{
|
331 |
+
return !apply_filters('lwptoc_active', true);
|
332 |
+
}
|
333 |
}
|
plugin/contentHandling/ContentHandling.php
CHANGED
@@ -36,11 +36,12 @@ class ContentHandling
|
|
36 |
/** @var $node \DOMElement */
|
37 |
|
38 |
$label = Dom::getNodeValue($node);
|
|
|
|
|
39 |
$label = trim($label);
|
40 |
if ($label == '') {
|
41 |
continue;
|
42 |
}
|
43 |
-
$label = html_entity_decode($label, ENT_HTML5, 'UTF-8');
|
44 |
|
45 |
$id = static::makeHeadingId($label, $dto);
|
46 |
|
36 |
/** @var $node \DOMElement */
|
37 |
|
38 |
$label = Dom::getNodeValue($node);
|
39 |
+
$label = html_entity_decode($label, ENT_HTML5, 'UTF-8');
|
40 |
+
$label = preg_replace('/\s+/u', ' ', $label);
|
41 |
$label = trim($label);
|
42 |
if ($label == '') {
|
43 |
continue;
|
44 |
}
|
|
|
45 |
|
46 |
$id = static::makeHeadingId($label, $dto);
|
47 |
|
plugin/dom/Dom.php
CHANGED
@@ -39,30 +39,30 @@ class Dom
|
|
39 |
|
40 |
/**
|
41 |
* @param \DOMNode $node
|
42 |
-
* @param string $
|
43 |
*/
|
44 |
-
public static function
|
45 |
{
|
46 |
-
static::
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
* @param \DOMNode $node
|
51 |
-
* @param string $
|
52 |
*/
|
53 |
-
public static function
|
54 |
{
|
55 |
-
static::
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
* @param \DOMNode $node
|
60 |
-
* @param string $
|
61 |
* @param bool $before
|
62 |
*/
|
63 |
-
protected static function
|
64 |
{
|
65 |
-
$dom = static::make($
|
66 |
if ($dom !== false) {
|
67 |
foreach ($dom->getElementById(static::BODY_ID)->childNodes as $newNode) {
|
68 |
$node->parentNode->insertBefore($node->ownerDocument->importNode($newNode, true), $before ? $node : $node->nextSibling);
|
@@ -111,10 +111,19 @@ class Dom
|
|
111 |
protected static function encode($pattern, $content)
|
112 |
{
|
113 |
return preg_replace_callback($pattern, function ($matches) {
|
114 |
-
return
|
115 |
}, $content);
|
116 |
}
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
/**
|
119 |
* @param string $content
|
120 |
* @return string
|
39 |
|
40 |
/**
|
41 |
* @param \DOMNode $node
|
42 |
+
* @param string $shortcode
|
43 |
*/
|
44 |
+
public static function beforeNodeInsertShortcode($node, $shortcode)
|
45 |
{
|
46 |
+
static::nodeInsertShortcode($node, $shortcode, true);
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
* @param \DOMNode $node
|
51 |
+
* @param string $shortcode
|
52 |
*/
|
53 |
+
public static function afterNodeInsertShortcode($node, $shortcode)
|
54 |
{
|
55 |
+
static::nodeInsertShortcode($node, $shortcode, false);
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
* @param \DOMNode $node
|
60 |
+
* @param string $shortcode
|
61 |
* @param bool $before
|
62 |
*/
|
63 |
+
protected static function nodeInsertShortcode($node, $shortcode, $before)
|
64 |
{
|
65 |
+
$dom = static::make(static::makeEncodedComment($shortcode));
|
66 |
if ($dom !== false) {
|
67 |
foreach ($dom->getElementById(static::BODY_ID)->childNodes as $newNode) {
|
68 |
$node->parentNode->insertBefore($node->ownerDocument->importNode($newNode, true), $before ? $node : $node->nextSibling);
|
111 |
protected static function encode($pattern, $content)
|
112 |
{
|
113 |
return preg_replace_callback($pattern, function ($matches) {
|
114 |
+
return static::makeEncodedComment($matches[0]);
|
115 |
}, $content);
|
116 |
}
|
117 |
|
118 |
+
/**
|
119 |
+
* @param string $s
|
120 |
+
* @return string
|
121 |
+
*/
|
122 |
+
protected static function makeEncodedComment($s)
|
123 |
+
{
|
124 |
+
return '<!-- lwptocEncodedData ' . base64_encode($s) . ' -->';
|
125 |
+
}
|
126 |
+
|
127 |
/**
|
128 |
* @param string $content
|
129 |
* @return string
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://theluckywp.com/product/table-of-contents/
|
|
4 |
Tags: table of contents, toc, navigation, links, seo
|
5 |
Requires at least: 4.7
|
6 |
Tested up to: 5.3.2
|
7 |
-
Stable tag: 2.0.
|
8 |
Requires PHP: 5.6.20
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
@@ -159,6 +159,15 @@ For non-English websites it is recommended to enable the `Intl` PHP extension.
|
|
159 |
|
160 |
== Changelog ==
|
161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
= 2.0.7 — 2020-01-31 =
|
163 |
+ Added support child themes of "Twenty Twenty".
|
164 |
* Fixed: incorrect smooth scroll behavior when on page use CSS `html {scroll-behavior: smooth;}`.
|
@@ -269,7 +278,7 @@ For non-English websites it is recommended to enable the `Intl` PHP extension.
|
|
269 |
* Improved Beaver Builder plugin support.
|
270 |
|
271 |
= 1.5.7 — 2019-07-10 =
|
272 |
-
*
|
273 |
* Fix: in some cases, incorrectly worked smooth scroll to headings.
|
274 |
|
275 |
= 1.5.6 — 2019-07-06 =
|
4 |
Tags: table of contents, toc, navigation, links, seo
|
5 |
Requires at least: 4.7
|
6 |
Tested up to: 5.3.2
|
7 |
+
Stable tag: 2.0.8
|
8 |
Requires PHP: 5.6.20
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
159 |
|
160 |
== Changelog ==
|
161 |
|
162 |
+
= 2.0.8 — 2020-02-23 =
|
163 |
+
+ Added hook filter `lwptoc_active`.
|
164 |
+
+ Added tab "LuckyWP Plugins" to settings.
|
165 |
+
* Improvement work option "Skip headings by text".
|
166 |
+
* Fixed: in some cases shortcode incorrectly processed.
|
167 |
+
* Fixed: in some cases auto insert work incorrectly.
|
168 |
+
* Fixed: headings in table of contents not escaping.
|
169 |
+
* Minor fixes in customize window.
|
170 |
+
|
171 |
= 2.0.7 — 2020-01-31 =
|
172 |
+ Added support child themes of "Twenty Twenty".
|
173 |
* Fixed: incorrect smooth scroll behavior when on page use CSS `html {scroll-behavior: smooth;}`.
|
278 |
* Improved Beaver Builder plugin support.
|
279 |
|
280 |
= 1.5.7 — 2019-07-10 =
|
281 |
+
* Improvement smooth scroll implementation for support lazy loading images in content.
|
282 |
* Fix: in some cases, incorrectly worked smooth scroll to headings.
|
283 |
|
284 |
= 1.5.6 — 2019-07-06 =
|