LuckyWP Table of Contents - Version 1.1.0

Version Description

  • Added option "Wrap table of contents with <noindex> tag".
  • Added hook filters lwptoc_before, lwptoc_after, lwptoc_shortcode_tag.
  • Fix: into Gutenberg editor in block "Classic editor" don't loaded CSS for shortcode.
Download this release

Release Info

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

Code changes from version 1.0.4 to 1.1.0

admin/Admin.php CHANGED
@@ -95,6 +95,7 @@ class Admin extends BaseObject
95
  'ajaxUrl' => admin_url('admin-ajax.php'),
96
  'nonce' => wp_create_nonce(Core::$plugin->prefix . 'adminMain'),
97
  'postId' => in_array($hook, ['post.php', 'post-new.php']) ? ArrayHelper::getValue($post, 'ID') : null,
 
98
  'tableOfContents' => esc_html__('Table of Contents', 'lwptoc'),
99
  'Edit' => esc_html__('Edit', 'lwptoc'),
100
  ]);
@@ -188,6 +189,9 @@ class Admin extends BaseObject
188
  $rows[] = [esc_html__($label, 'lwptoc'), OverrideColorBadge::widget(['color' => $v]), false];
189
  }
190
  }
 
 
 
191
  return array_map(function ($row) {
192
  if ($row[1] !== null && ArrayHelper::getValue($row, 2, true) === true) {
193
  $row[1] = esc_html($row[1]);
95
  'ajaxUrl' => admin_url('admin-ajax.php'),
96
  'nonce' => wp_create_nonce(Core::$plugin->prefix . 'adminMain'),
97
  'postId' => in_array($hook, ['post.php', 'post-new.php']) ? ArrayHelper::getValue($post, 'ID') : null,
98
+ 'shortcodeTag' => Core::$plugin->shortcode->getTag(),
99
  'tableOfContents' => esc_html__('Table of Contents', 'lwptoc'),
100
  'Edit' => esc_html__('Edit', 'lwptoc'),
101
  ]);
189
  $rows[] = [esc_html__($label, 'lwptoc'), OverrideColorBadge::widget(['color' => $v]), false];
190
  }
191
  }
192
+ if (null !== $v = $getValue($source, 'wrapNoindex')) {
193
+ $rows[] = [esc_html__('Wrap table of contents with <noindex> tag', 'lwptoc'), $v ? __('Enabled', 'lwptoc') : __('Disabled', 'lwptoc')];
194
+ }
195
  return array_map(function ($row) {
196
  if ($row[1] !== null && ArrayHelper::getValue($row, 2, true) === true) {
197
  $row[1] = esc_html($row[1]);
admin/forms/CustomizeForm.php CHANGED
@@ -83,6 +83,9 @@ class CustomizeForm extends Model
83
  public $defaultVisitedLinkColor;
84
  public $visitedLinkColor;
85
 
 
 
 
86
  /**
87
  * @var PostSettings
88
  */
@@ -117,6 +120,7 @@ class CustomizeForm extends Model
117
  'linkColor',
118
  'hoverLinkColor',
119
  'visitedLinkColor',
 
120
  ];
121
 
122
  /**
@@ -192,6 +196,7 @@ class CustomizeForm extends Model
192
  'filter',
193
  'filter' => [Core::$plugin->settings, 'sanitizeCallbackColor'],
194
  ],
 
195
  ];
196
  }
197
 
@@ -260,6 +265,7 @@ class CustomizeForm extends Model
260
  'linkColor' => $this->defaultLinkColor ? null : ($this->linkColor ? $this->linkColor : ''),
261
  'hoverLinkColor' => $this->defaultHoverLinkColor ? null : ($this->hoverLinkColor ? $this->hoverLinkColor : ''),
262
  'visitedLinkColor' => $this->defaultVisitedLinkColor ? null : ($this->visitedLinkColor ? $this->visitedLinkColor : ''),
 
263
  ];
264
  }
265
  }
83
  public $defaultVisitedLinkColor;
84
  public $visitedLinkColor;
85
 
86
+ public $defaultWrapNoindex;
87
+ public $wrapNoindex;
88
+
89
  /**
90
  * @var PostSettings
91
  */
120
  'linkColor',
121
  'hoverLinkColor',
122
  'visitedLinkColor',
123
+ 'wrapNoindex',
124
  ];
125
 
126
  /**
196
  'filter',
197
  'filter' => [Core::$plugin->settings, 'sanitizeCallbackColor'],
198
  ],
199
+ ['wrapNoindex', 'boolean'],
200
  ];
201
  }
202
 
265
  'linkColor' => $this->defaultLinkColor ? null : ($this->linkColor ? $this->linkColor : ''),
266
  'hoverLinkColor' => $this->defaultHoverLinkColor ? null : ($this->hoverLinkColor ? $this->hoverLinkColor : ''),
267
  'visitedLinkColor' => $this->defaultVisitedLinkColor ? null : ($this->visitedLinkColor ? $this->visitedLinkColor : ''),
268
+ 'wrapNoindex' => $this->defaultWrapNoindex ? null : (bool)$this->wrapNoindex,
269
  ];
270
  }
271
  }
admin/widgets/customizeModal/views/modal.php CHANGED
@@ -37,6 +37,7 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
37
  <div class="lwptocCustomize_tabs">
38
  <div class="lwptocCustomize_tab lwptocCustomize_tab-active" data-tab="general"><?= esc_html__('General', 'lwptoc') ?></div>
39
  <div class="lwptocCustomize_tab" data-tab="appearance"><?= esc_html__('Appearance', 'lwptoc') ?></div>
 
40
  </div>
41
 
42
  <div class="lwptocCustomize_fields lwptocCustomize_fields-general" style="display:block;">
@@ -481,6 +482,33 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
481
 
482
  </div>
483
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484
  </div>
485
  <div class="lwptocModalBox_footer">
486
  <div class="lwptocModalBox_footer_buttons">
37
  <div class="lwptocCustomize_tabs">
38
  <div class="lwptocCustomize_tab lwptocCustomize_tab-active" data-tab="general"><?= esc_html__('General', 'lwptoc') ?></div>
39
  <div class="lwptocCustomize_tab" data-tab="appearance"><?= esc_html__('Appearance', 'lwptoc') ?></div>
40
+ <div class="lwptocCustomize_tab" data-tab="misc"><?= esc_html__('Misc.', 'lwptoc') ?></div>
41
  </div>
42
 
43
  <div class="lwptocCustomize_fields lwptocCustomize_fields-general" style="display:block;">
482
 
483
  </div>
484
 
485
+ <div class="lwptocCustomize_fields lwptocCustomize_fields-misc">
486
+
487
+ <?php $defaultValue = ($model->isPostSettings || is_null($model->postSettings->wrapNoindex)) ? Core::$plugin->settings->miscWrapNoindex : $model->postSettings->wrapNoindex ?>
488
+ <div class="lwptocCustomize_field<?= $model->defaultWrapNoindex ? ' lwptocCustomize_field-default' : '' ?>">
489
+ <div class="lwptocCustomize_field_header">
490
+ <span class="lwptocCustomize_field_label"><?= esc_html__('Wrap table of contents with <noindex> tag', 'lwptoc') ?></span>
491
+ <span class="lwptocCustomize_field_default"><?= __('default', 'lwptoc') ?></span>
492
+ </div>
493
+ <div class="lwptocCustomize_field_override">
494
+ <?= __('Click for override default value', 'lwptoc') ?>
495
+ </div>
496
+ <div class="lwptocCustomize_field_el">
497
+ <label>
498
+ <?= Html::checkbox(Html::getInputName($model, 'wrapNoindex'), $model->defaultWrapNoindex ? $defaultValue : $model->wrapNoindex, ['uncheck' => 0]) ?>
499
+ <?= __('Enable', 'lwptoc') ?>
500
+ </label>
501
+ <?= Html::hiddenInput(Html::getInputName($model, 'defaultWrapNoindex'), $model->defaultWrapNoindex, [
502
+ 'class' => 'lwptocCustomize_field_inputDefault',
503
+ ]) ?>
504
+ </div>
505
+ <div class="lwptocCustomize_field_defaultValue">
506
+ <?= $defaultValue ? __('Enabled', 'lwptoc') : __('Disabled', 'lwptoc') ?>
507
+ </div>
508
+ </div>
509
+
510
+ </div>
511
+
512
  </div>
513
  <div class="lwptocModalBox_footer">
514
  <div class="lwptocModalBox_footer_buttons">
config/settings.php CHANGED
@@ -307,4 +307,25 @@ return [
307
  ],
308
  ],
309
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  ];
307
  ],
308
  ],
309
  ],
310
+
311
+ // Прочее
312
+ 'misc' => [
313
+ 'label' => esc_html__('Misc.', 'lwptoc'),
314
+ 'sections' => [
315
+ 'main' => [
316
+ 'fields' => [
317
+ 'wrapNoindex' => [
318
+ 'label' => '',
319
+ 'widget' => 'checkbox',
320
+ 'params' => [
321
+ 'checkboxOptions' => [
322
+ 'label' => esc_html__('Wrap table of contents with <noindex> tag', 'lwptoc'),
323
+ ],
324
+ ],
325
+ 'default' => false,
326
+ ],
327
+ ],
328
+ ],
329
+ ],
330
+ ],
331
  ];
front/Front.php CHANGED
@@ -91,7 +91,7 @@ class Front extends BaseFront
91
  return $content;
92
  }
93
 
94
- if (has_shortcode($content, Shortcode::TAG)) {
95
  return $content;
96
  }
97
 
91
  return $content;
92
  }
93
 
94
+ if (has_shortcode($content, Core::$plugin->shortcode->getTag())) {
95
  return $content;
96
  }
97
 
front/views/body.php CHANGED
@@ -10,11 +10,13 @@
10
  * @var $titleStyles array
11
  * @var $itemsStyles array
12
  * @var $items array
 
 
13
  */
14
 
15
  use luckywp\tableOfContents\core\helpers\Html;
16
 
17
- echo Html::beginTag('div', $containerOptions);
18
  ?>
19
  <div class="lwptoc_i">
20
  <?php if ($toggle || $title) { ?>
@@ -31,4 +33,4 @@ echo Html::beginTag('div', $containerOptions);
31
  <?php lwptoc_items($items) ?>
32
  </div>
33
  </div>
34
- <?= '</div>' ?>
10
  * @var $titleStyles array
11
  * @var $itemsStyles array
12
  * @var $items array
13
+ * @var $before string
14
+ * @var $after string
15
  */
16
 
17
  use luckywp\tableOfContents\core\helpers\Html;
18
 
19
+ echo $before . Html::beginTag('div', $containerOptions);
20
  ?>
21
  <div class="lwptoc_i">
22
  <?php if ($toggle || $title) { ?>
33
  <?php lwptoc_items($items) ?>
34
  </div>
35
  </div>
36
+ <?= '</div>' . $after ?>
languages/lwptoc-ru_RU.mo CHANGED
Binary file
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.0.4
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.0.4', __FILE__, 'lwptoc_');
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.1.0
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.1.0', __FILE__, 'lwptoc_');
33
 
34
  require_once __DIR__ . '/functions.php';
plugin/PostSettings.php CHANGED
@@ -134,6 +134,11 @@ class PostSettings extends BaseObject
134
  */
135
  public $visitedLinkColor;
136
 
 
 
 
 
 
137
  /**
138
  * @var int
139
  */
@@ -174,6 +179,7 @@ class PostSettings extends BaseObject
174
  $this->linkColor = ArrayHelper::getValue($data, 'linkColor');
175
  $this->hoverLinkColor = ArrayHelper::getValue($data, 'hoverLinkColor');
176
  $this->visitedLinkColor = ArrayHelper::getValue($data, 'visitedLinkColor');
 
177
  }
178
  }
179
  }
@@ -253,6 +259,9 @@ class PostSettings extends BaseObject
253
  if ($this->visitedLinkColor !== null) {
254
  $data['visitedLinkColor'] = $this->visitedLinkColor;
255
  }
 
 
 
256
  if ($data || !$this->enabled) {
257
  $data['enabled'] = $this->enabled;
258
  update_post_meta($this->postId, '_lwptoc_settings', $data);
134
  */
135
  public $visitedLinkColor;
136
 
137
+ /**
138
+ * @var bool
139
+ */
140
+ public $wrapNoindex;
141
+
142
  /**
143
  * @var int
144
  */
179
  $this->linkColor = ArrayHelper::getValue($data, 'linkColor');
180
  $this->hoverLinkColor = ArrayHelper::getValue($data, 'hoverLinkColor');
181
  $this->visitedLinkColor = ArrayHelper::getValue($data, 'visitedLinkColor');
182
+ $this->wrapNoindex = ArrayHelper::getValue($data, 'wrapNoindex');
183
  }
184
  }
185
  }
259
  if ($this->visitedLinkColor !== null) {
260
  $data['visitedLinkColor'] = $this->visitedLinkColor;
261
  }
262
+ if ($this->wrapNoindex !== null) {
263
+ $data['wrapNoindex'] = (bool)$this->wrapNoindex;
264
+ }
265
  if ($data || !$this->enabled) {
266
  $data['enabled'] = $this->enabled;
267
  update_post_meta($this->postId, '_lwptoc_settings', $data);
plugin/Settings.php CHANGED
@@ -33,6 +33,8 @@ use luckywp\tableOfContents\core\Core;
33
  * @property bool $autoInsertEnable
34
  * @property string $autoInsertPosition
35
  * @property array $autoInsertPostTypes
 
 
36
  */
37
  class Settings extends \luckywp\tableOfContents\core\wp\Settings
38
  {
@@ -270,6 +272,14 @@ class Settings extends \luckywp\tableOfContents\core\wp\Settings
270
  return is_array($postTypes) ? $postTypes : [];
271
  }
272
 
 
 
 
 
 
 
 
 
273
  /**
274
  * @param string $value
275
  * @return string
33
  * @property bool $autoInsertEnable
34
  * @property string $autoInsertPosition
35
  * @property array $autoInsertPostTypes
36
+ *
37
+ * @property-read bool $miscWrapNoindex
38
  */
39
  class Settings extends \luckywp\tableOfContents\core\wp\Settings
40
  {
272
  return is_array($postTypes) ? $postTypes : [];
273
  }
274
 
275
+ /**
276
+ * @return bool
277
+ */
278
+ public function getMiscWrapNoindex()
279
+ {
280
+ return (bool)$this->getValue('misc', 'wrapNoindex', false);
281
+ }
282
+
283
  /**
284
  * @param string $value
285
  * @return string
plugin/Shortcode.php CHANGED
@@ -8,11 +8,12 @@ use luckywp\tableOfContents\core\helpers\ArrayHelper;
8
  use luckywp\tableOfContents\core\helpers\Html;
9
  use WP_Post;
10
 
 
 
 
11
  class Shortcode extends BaseObject
12
  {
13
 
14
- const TAG = 'lwptoc';
15
-
16
  /**
17
  * @var int
18
  */
@@ -39,7 +40,16 @@ class Shortcode extends BaseObject
39
  public function init()
40
  {
41
  parent::init();
42
- add_shortcode(self::TAG, function ($attrs) {
 
 
 
 
 
 
 
 
 
43
  global $post;
44
  if (!is_single($post) && !is_page($post)) {
45
  return '';
@@ -73,6 +83,7 @@ class Shortcode extends BaseObject
73
  'linkColor',
74
  'hoverLinkColor',
75
  'visitedLinkColor',
 
76
  ] as $var) {
77
  if (!array_key_exists(strtolower($var), $attrs)) {
78
  $attrs[strtolower($var)] = $postSettings->$var;
@@ -81,7 +92,19 @@ class Shortcode extends BaseObject
81
  }
82
  return $this->make($attrs);
83
  });
84
- add_filter('the_content', [$this, 'begin'], 999);
 
 
 
 
 
 
 
 
 
 
 
 
85
  }
86
 
87
  /**
@@ -107,7 +130,7 @@ class Shortcode extends BaseObject
107
  protected function needToc($content)
108
  {
109
  return is_singular() &&
110
- has_shortcode($content, self::TAG);
111
  }
112
 
113
  /**
@@ -140,7 +163,7 @@ class Shortcode extends BaseObject
140
  */
141
  public function doShortcode($m)
142
  {
143
- if ($m[2] == self::TAG) {
144
  return $this->shortcode(shortcode_parse_atts($m[3]));
145
  }
146
  return $m[0];
@@ -360,6 +383,14 @@ class Shortcode extends BaseObject
360
  }
361
  }
362
 
 
 
 
 
 
 
 
 
363
  // Вывод
364
  $this->currentOutputDepth = -1;
365
  return Core::$plugin->front->render('body', [
@@ -373,6 +404,8 @@ class Shortcode extends BaseObject
373
  'titleStyles' => $titleStyles,
374
  'itemsStyles' => $itemsStyles,
375
  'items' => $items,
 
 
376
  ]);
377
  }
378
 
@@ -382,7 +415,7 @@ class Shortcode extends BaseObject
382
  */
383
  public function make($attrs)
384
  {
385
- $shortcode = '[' . static::TAG;
386
  foreach ($attrs as $k => $v) {
387
  if ($v !== null) {
388
  if (is_string($v)) {
8
  use luckywp\tableOfContents\core\helpers\Html;
9
  use WP_Post;
10
 
11
+ /**
12
+ * @property-read string $tag
13
+ */
14
  class Shortcode extends BaseObject
15
  {
16
 
 
 
17
  /**
18
  * @var int
19
  */
40
  public function init()
41
  {
42
  parent::init();
43
+ add_action('init', [$this, 'registerShortcode']);
44
+ add_filter('the_content', [$this, 'begin'], 999);
45
+ }
46
+
47
+ /**
48
+ * Регистрация шорткода
49
+ */
50
+ public function registerShortcode()
51
+ {
52
+ add_shortcode($this->getTag(), function ($attrs) {
53
  global $post;
54
  if (!is_single($post) && !is_page($post)) {
55
  return '';
83
  'linkColor',
84
  'hoverLinkColor',
85
  'visitedLinkColor',
86
+ 'wrapNoindex',
87
  ] as $var) {
88
  if (!array_key_exists(strtolower($var), $attrs)) {
89
  $attrs[strtolower($var)] = $postSettings->$var;
92
  }
93
  return $this->make($attrs);
94
  });
95
+ }
96
+
97
+ private $_tag;
98
+
99
+ /**
100
+ * @return string
101
+ */
102
+ public function getTag()
103
+ {
104
+ if ($this->_tag === null) {
105
+ $this->_tag = apply_filters('lwptoc_shortcode_tag', 'lwptoc');
106
+ }
107
+ return $this->_tag;
108
  }
109
 
110
  /**
130
  protected function needToc($content)
131
  {
132
  return is_singular() &&
133
+ has_shortcode($content, $this->getTag());
134
  }
135
 
136
  /**
163
  */
164
  public function doShortcode($m)
165
  {
166
+ if ($m[2] == $this->getTag()) {
167
  return $this->shortcode(shortcode_parse_atts($m[3]));
168
  }
169
  return $m[0];
383
  }
384
  }
385
 
386
+ $before = (string)apply_filters('lwptoc_before', '');
387
+ $after = (string)apply_filters('lwptoc_after', '');
388
+
389
+ if ($this->assertBool(ArrayHelper::getValue($attrs, 'wrapnoindex', Core::$plugin->settings->miscWrapNoindex))) {
390
+ $before = '<noindex>' . $before;
391
+ $after = $after . '</noindex>';
392
+ }
393
+
394
  // Вывод
395
  $this->currentOutputDepth = -1;
396
  return Core::$plugin->front->render('body', [
404
  'titleStyles' => $titleStyles,
405
  'itemsStyles' => $itemsStyles,
406
  'items' => $items,
407
+ 'before' => $before,
408
+ 'after' => $after,
409
  ]);
410
  }
411
 
415
  */
416
  public function make($attrs)
417
  {
418
+ $shortcode = '[' . $this->getTag();
419
  foreach ($attrs as $k => $v) {
420
  if ($v !== null) {
421
  if (is_string($v)) {
plugin/editorBlock/editorBlock.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){var o={};function e(n){if(o[n])return o[n].exports;var r=o[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,e),r.l=!0,r.exports}e.m=t,e.c=o,e.d=function(t,o,n){e.o(t,o)||Object.defineProperty(t,o,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,o){if(1&o&&(t=e(t)),8&o)return t;if(4&o&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&o&&"string"!=typeof t)for(var r in t)e.d(n,r,function(o){return t[o]}.bind(null,r));return n},e.n=function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(o,"a",o),o},e.o=function(t,o){return Object.prototype.hasOwnProperty.call(t,o)},e.p="",e(e.s=1)}([function(t,o){function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(o){return"function"==typeof Symbol&&"symbol"===e(Symbol.iterator)?t.exports=n=function(t){return e(t)}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":e(t)},n(o)}t.exports=n},function(t,o,e){"use strict";e.r(o);var n=e(0),r=e.n(n),i=wp.blocks.registerBlockType,l=wp.element,c=l.createElement,u=l.Fragment,p=wp.editor.BlockControls,s=wp.components,a=s.Toolbar,y=s.IconButton,f=0,d={};i("luckywp/tableofcontents",{title:lwptocMain.tableOfContents,icon:"list-view",category:"common",supports:{customClassName:!1,html:!1},attributes:{min:{type:"integer"},depth:{type:"integer"},hierarchical:{type:"boolean"},numeration:{type:"string"},title:{type:"string"},toggle:{type:"boolean"},labelShow:{type:"string"},labelHide:{type:"string"},hideItems:{type:"boolean"},smoothScroll:{type:"boolean"},smoothScrollOffset:{type:"integer"},width:{type:"string"},float:{type:"string"},titleFontSize:{type:"string"},titleFontWeight:{type:"string"},itemsFontSize:{type:"string"},colorScheme:{type:"string"},backgroundColor:{type:"string"},borderColor:{type:"string"},titleColor:{type:"string"},linkColor:{type:"string"},hoverLinkColor:{type:"string"},visitedLinkColor:{type:"string"}},edit:function(t){var o=t.attributes,e=t.setAttributes,n={};$.each(o,function(t,o){r()(o)==r()(!0)&&(o=o?1:0),n[t]=o});var i="lwptocEditorBlock"+ ++f,l=JSON.stringify(o);return void 0===d[l]&&($.ajax({url:lwptocMain.ajaxUrl,data:{_ajax_nonce:lwptocMain.nonce,action:"lwptoc_block_view",attrs:n},success:function(t){d[l]=t,$("#"+i).replaceWith(t)}}),d[l]='<div class="lwptocEditorBlock_title lwptocEditorBlock_title-loading" id="'+i+'">'+lwptocMain.tableOfContents+"</div>"),c(u,null,c(p,null,c(a,null,c(y,{label:lwptocMain.Edit,icon:"edit",onClick:function(){$(document).one("lwptocEditorBlockChanged",function(t,o){_.each(o,function(t,e){null===t&&(o[e]=void 0)}),e(o)}),$.lwptocCustomize.show({action:"lwptoc_block_edit",attrs:n,postId:lwptocMain.postId},function(){$(document).off("lwptocEditorBlockChanged")})}}))),c("div",{class:"lwptocEditorBlock",dangerouslySetInnerHTML:{__html:d[l]}}))},save:function(t){return t.attributes.shortcode}})}]);
1
+ !function(t){var o={};function e(n){if(o[n])return o[n].exports;var r=o[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,e),r.l=!0,r.exports}e.m=t,e.c=o,e.d=function(t,o,n){e.o(t,o)||Object.defineProperty(t,o,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,o){if(1&o&&(t=e(t)),8&o)return t;if(4&o&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&o&&"string"!=typeof t)for(var r in t)e.d(n,r,function(o){return t[o]}.bind(null,r));return n},e.n=function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(o,"a",o),o},e.o=function(t,o){return Object.prototype.hasOwnProperty.call(t,o)},e.p="",e(e.s=1)}([function(t,o){function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(o){return"function"==typeof Symbol&&"symbol"===e(Symbol.iterator)?t.exports=n=function(t){return e(t)}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":e(t)},n(o)}t.exports=n},function(t,o,e){"use strict";e.r(o);var n=e(0),r=e.n(n),i=wp.blocks.registerBlockType,l=wp.element,c=l.createElement,u=l.Fragment,p=wp.editor.BlockControls,s=wp.components,a=s.Toolbar,y=s.IconButton,f=0,d={};i("luckywp/tableofcontents",{title:lwptocMain.tableOfContents,icon:"list-view",category:"common",supports:{customClassName:!1,html:!1},attributes:{min:{type:"integer"},depth:{type:"integer"},hierarchical:{type:"boolean"},numeration:{type:"string"},title:{type:"string"},toggle:{type:"boolean"},labelShow:{type:"string"},labelHide:{type:"string"},hideItems:{type:"boolean"},smoothScroll:{type:"boolean"},smoothScrollOffset:{type:"integer"},width:{type:"string"},float:{type:"string"},titleFontSize:{type:"string"},titleFontWeight:{type:"string"},itemsFontSize:{type:"string"},colorScheme:{type:"string"},backgroundColor:{type:"string"},borderColor:{type:"string"},titleColor:{type:"string"},linkColor:{type:"string"},hoverLinkColor:{type:"string"},visitedLinkColor:{type:"string"},wrapNoindex:{type:"boolean"}},edit:function(t){var o=t.attributes,e=t.setAttributes,n={};$.each(o,function(t,o){r()(o)==r()(!0)&&(o=o?1:0),n[t]=o});var i="lwptocEditorBlock"+ ++f,l=JSON.stringify(o);return void 0===d[l]&&($.ajax({url:lwptocMain.ajaxUrl,data:{_ajax_nonce:lwptocMain.nonce,action:"lwptoc_block_view",attrs:n},success:function(t){d[l]=t,$("#"+i).replaceWith(t)}}),d[l]='<div class="lwptocEditorBlock_title lwptocEditorBlock_title-loading" id="'+i+'">'+lwptocMain.tableOfContents+"</div>"),c(u,null,c(p,null,c(a,null,c(y,{label:lwptocMain.Edit,icon:"edit",onClick:function(){$(document).one("lwptocEditorBlockChanged",function(t,o){_.each(o,function(t,e){null===t&&(o[e]=void 0)}),e(o)}),$.lwptocCustomize.show({action:"lwptoc_block_edit",attrs:n,postId:lwptocMain.postId},function(){$(document).off("lwptocEditorBlockChanged")})}}))),c("div",{class:"lwptocEditorBlock",dangerouslySetInnerHTML:{__html:d[l]}}))},save:function(t){return t.attributes.shortcode}})}]);
plugin/mcePlugin/McePlugin.php CHANGED
@@ -17,7 +17,8 @@ class McePlugin extends BaseObject
17
  public function adminInit()
18
  {
19
  if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
20
- add_filter('mce_css', [$this, 'css']);
 
21
  add_filter('mce_external_plugins', [$this, 'plugin']);
22
  add_filter('mce_buttons', [$this, 'button']);
23
  }
@@ -27,7 +28,7 @@ class McePlugin extends BaseObject
27
  * @param string $css
28
  * @return string
29
  */
30
- public function css($css)
31
  {
32
  if (!empty($css)) {
33
  $css .= ',';
@@ -36,6 +37,14 @@ class McePlugin extends BaseObject
36
  return $css;
37
  }
38
 
 
 
 
 
 
 
 
 
39
  /**
40
  * @param array $plugins
41
  * @return array
17
  public function adminInit()
18
  {
19
  if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
20
+ add_filter('mce_css', [$this, 'mceCss']);
21
+ add_action('enqueue_block_editor_assets', [$this, 'editorCss']);
22
  add_filter('mce_external_plugins', [$this, 'plugin']);
23
  add_filter('mce_buttons', [$this, 'button']);
24
  }
28
  * @param string $css
29
  * @return string
30
  */
31
+ public function mceCss($css)
32
  {
33
  if (!empty($css)) {
34
  $css .= ',';
37
  return $css;
38
  }
39
 
40
+ /**
41
+ * CSS для Gutenberg
42
+ */
43
+ public function editorCss()
44
+ {
45
+ wp_enqueue_style('lwptoc-editor-css', Core::$plugin->mcePlugin->getUrl() . '/mce.min.css');
46
+ }
47
+
48
  /**
49
  * @param array $plugins
50
  * @return array
plugin/mcePlugin/mce.min.css CHANGED
@@ -1 +1 @@
1
- .lwptocShortcode{display:block;padding:12px 16px;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}.lwptocShortcode-loading{color:#aaa}.lwptocShortcode_title{font-size:14px;line-height:18px;font-weight:700}.lwptocShortcode_items{margin-top:4px;font-size:12px;line-height:16px}.lwptocShortcode_item{margin-top:2px}.lwptocShortcode_item:first-child{margin-top:0}.lwptocShortcode_item_label{color:#888}.lwptocShortcode .lwptocColorBadge B{position:relative;top:1px;margin-left:2px;display:inline-block;margin-right:4px;width:12px;height:12px;border-radius:6px}
1
+ .lwptocShortcode{display:block;padding:12px 16px;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}.block-editor .lwptocShortcode{margin-bottom:1.5em}.lwptocShortcode-loading{color:#aaa}.lwptocShortcode_title{font-size:14px;line-height:18px;font-weight:700}.lwptocShortcode_items{margin-top:4px;font-size:12px;line-height:16px}.lwptocShortcode_item{margin-top:2px}.lwptocShortcode_item:first-child{margin-top:0}.lwptocShortcode_item_label{color:#888}.lwptocShortcode .lwptocColorBadge B{position:relative;top:1px;margin-left:2px;display:inline-block;margin-right:4px;width:12px;height:12px;border-radius:6px}
plugin/mcePlugin/plugin.min.js CHANGED
@@ -1 +1 @@
1
- !function(n){lwptocMain.postId&&(tinymce.PluginManager.add("lwptoc",function(t){t.addButton("lwptocButton",{icon:"lwptocButton",tooltip:lwptocMain.tableOfContents,onclick:function(){wp.mce.lwptoc.popupWindow(t,!1,{})}})}),wp.mce.lwptoc={viewCounter:0,cache:{},getContent:function(){var t=this,c="lwptocShortcode"+ ++wp.mce.lwptoc.viewCounter,e=JSON.stringify(this.shortcode.attrs.named);return void 0===wp.mce.lwptoc[e]?(n.ajax({url:lwptocMain.ajaxUrl,data:{_ajax_nonce:lwptocMain.nonce,action:"lwptoc_shortcode_view",attrs:this.shortcode.attrs.named},success:function(o){wp.mce.lwptoc[e]=o,t.getEditors(function(t){n(t.getBody()).find("#"+c).replaceWith(o)})}}),'<div class="lwptocShortcode lwptocShortcode-loading" id="'+c+'"><div class="lwptocShortcode_title">'+lwptocMain.tableOfContents+"</div></div>"):wp.mce.lwptoc[e]},edit:function(t,o){wp.mce.lwptoc.popupWindow(tinyMCE.activeEditor,o,wp.shortcode.next("lwptoc",t).shortcode.attrs.named)},popupWindow:function(c,e,t){n(document).one("lwptocShortcodeGenerated",function(t,o){!1===e?c.insertContent(o.shortcode):e(o.shortcode)}),n.lwptocCustomize.show({action:"lwptoc_shortcode_customize",attrs:t,postId:lwptocMain.postId},function(){n(document).off("lwptocShortcodeGenerated")})}},wp.mce.views.register("lwptoc",wp.mce.lwptoc))}(jQuery);
1
+ !function(n){lwptocMain.postId&&(tinymce.PluginManager.add("lwptoc",function(t){t.addButton("lwptocButton",{icon:"lwptocButton",tooltip:lwptocMain.tableOfContents,onclick:function(){wp.mce.lwptoc.popupWindow(t,!1,{})}})}),wp.mce.lwptoc={viewCounter:0,cache:{},getContent:function(){var t=this,c="lwptocShortcode"+ ++wp.mce.lwptoc.viewCounter,e=JSON.stringify(this.shortcode.attrs.named);return void 0===wp.mce.lwptoc[e]?(n.ajax({url:lwptocMain.ajaxUrl,data:{_ajax_nonce:lwptocMain.nonce,action:"lwptoc_shortcode_view",attrs:this.shortcode.attrs.named},success:function(o){wp.mce.lwptoc[e]=o,t.getEditors(function(t){n(t.getBody()).find("#"+c).replaceWith(o)})}}),'<div class="lwptocShortcode lwptocShortcode-loading" id="'+c+'"><div class="lwptocShortcode_title">'+lwptocMain.tableOfContents+"</div></div>"):wp.mce.lwptoc[e]},edit:function(t,o){wp.mce.lwptoc.popupWindow(tinyMCE.activeEditor,o,wp.shortcode.next(lwptocMain.shortcodeTag,t).shortcode.attrs.named)},popupWindow:function(c,e,t){n(document).one("lwptocShortcodeGenerated",function(t,o){!1===e?c.insertContent(o.shortcode):e(o.shortcode)}),n.lwptocCustomize.show({action:"lwptoc_shortcode_customize",attrs:t,postId:lwptocMain.postId},function(){n(document).off("lwptocShortcodeGenerated")})}},wp.mce.views.register(lwptocMain.shortcodeTag,wp.mce.lwptoc))}(jQuery);
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.1.1
7
- Stable tag: 1.0.4
8
  Requires PHP: 5.6.20
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -31,6 +31,7 @@ Creates a table of contents for your posts, pages or custom post types. Great cu
31
  * Customizalbe labels.
32
  * Smooth scroll (optionally).
33
  * Setting offset top for smooth scroll.
 
34
  * Available override global settings for a particular post.
35
  * Highly compatible with WordPress themes and plugins.
36
 
@@ -48,18 +49,40 @@ Supported positions:
48
 
49
  You can also select post types to which the table of contents will be automatically added.
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  == Installation ==
52
 
53
  #### Installing from the WordPress control panel
54
 
55
- 1. Go to the page "Plugins > Add New".
56
  2. Input the name "LuckyWP Table of Contents" in the search field
57
  3. Find the "LuckyWP Table of Contents" plugin in the search result and click on the "Install Now" button, the installation process of plugin will begin.
58
  4. Click "Activate" when the installation is complete.
59
 
60
  #### Installing with the archive
61
 
62
- 1. Go to the page "Plugins > Add New" on the WordPress control panel
63
  2. Click on the "Upload Plugin" button, the form to upload the archive will be opened.
64
  3. Select the archive with the plugin and click "Install Now".
65
  4. Click on the "Activate Plugin" button when the installation is complete.
@@ -67,7 +90,7 @@ You can also select post types to which the table of contents will be automatica
67
  #### Manual installation
68
 
69
  1. Upload the folder `luckywp-table-of-contents` to a directory with the plugin, usually it is `/wp-content/plugins/`.
70
- 2. Go to the page "Plugins > Add New" on the WordPress control panel
71
  3. Find "LuckyWP Table of Contents" in the plugins list and click "Activate".
72
 
73
  ### After activation
@@ -86,9 +109,15 @@ The menu item "Table of Contents" will appear in the menu "Settings" of the Word
86
  6. General Settings
87
  7. Appearance Settings
88
  8. Auto Insert Settings
 
89
 
90
  == Changelog ==
91
 
 
 
 
 
 
92
  = 1.0.4 =
93
  * Bug fix
94
 
4
  Tags: table of contents, toc, navigation, links, heading
5
  Requires at least: 4.7
6
  Tested up to: 5.1.1
7
+ Stable tag: 1.1.0
8
  Requires PHP: 5.6.20
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
31
  * Customizalbe labels.
32
  * Smooth scroll (optionally).
33
  * Setting offset top for smooth scroll.
34
+ * Wrap table of contents with &lt;noindex&gt; tag (optionally).
35
  * Available override global settings for a particular post.
36
  * Highly compatible with WordPress themes and plugins.
37
 
49
 
50
  You can also select post types to which the table of contents will be automatically added.
51
 
52
+ ### Hooks
53
+
54
+ #### Filters `lwptoc_before`, `lwptoc_after`
55
+
56
+ Use for add custom HTML before/after the table of contents.
57
+
58
+ Example:
59
+
60
+ add_filter('lwptoc_before', function ($before) {
61
+ return '<p>Example text before TOC.</p>' . $before;
62
+ });
63
+
64
+ #### Filter `lwptoc_shortcode_tag`
65
+
66
+ Use this filter for change shortcode tag name `[lwptoc]`.
67
+
68
+ Example:
69
+
70
+ add_filter('lwptoc_shortcode_tag', function ($tag) {
71
+ return 'toc';
72
+ });
73
+
74
  == Installation ==
75
 
76
  #### Installing from the WordPress control panel
77
 
78
+ 1. Go to the page "Plugins &gt; Add New".
79
  2. Input the name "LuckyWP Table of Contents" in the search field
80
  3. Find the "LuckyWP Table of Contents" plugin in the search result and click on the "Install Now" button, the installation process of plugin will begin.
81
  4. Click "Activate" when the installation is complete.
82
 
83
  #### Installing with the archive
84
 
85
+ 1. Go to the page "Plugins &gt; Add New" on the WordPress control panel
86
  2. Click on the "Upload Plugin" button, the form to upload the archive will be opened.
87
  3. Select the archive with the plugin and click "Install Now".
88
  4. Click on the "Activate Plugin" button when the installation is complete.
90
  #### Manual installation
91
 
92
  1. Upload the folder `luckywp-table-of-contents` to a directory with the plugin, usually it is `/wp-content/plugins/`.
93
+ 2. Go to the page "Plugins &gt; Add New" on the WordPress control panel
94
  3. Find "LuckyWP Table of Contents" in the plugins list and click "Activate".
95
 
96
  ### After activation
109
  6. General Settings
110
  7. Appearance Settings
111
  8. Auto Insert Settings
112
+ 9. Miscellaneous Settings
113
 
114
  == Changelog ==
115
 
116
+ = 1.1.0 =
117
+ + Added option "Wrap table of contents with &lt;noindex&gt; tag".
118
+ + Added hook filters `lwptoc_before`, `lwptoc_after`, `lwptoc_shortcode_tag`.
119
+ * Fix: into Gutenberg editor in block "Classic editor" don't loaded CSS for shortcode.
120
+
121
  = 1.0.4 =
122
  * Bug fix
123
 
uninstall.php CHANGED
@@ -7,3 +7,4 @@ if (!defined('WP_UNINSTALL_PLUGIN')) {
7
  delete_option('lwptoc_general');
8
  delete_option('lwptoc_appearance');
9
  delete_option('lwptoc_autoInsert');
 
7
  delete_option('lwptoc_general');
8
  delete_option('lwptoc_appearance');
9
  delete_option('lwptoc_autoInsert');
10
+ delete_option('lwptoc_misc');