LuckyWP Table of Contents - Version 2.0.3

Version Description

2020-01-19 = + Added support "Twenty Twenty" theme. * Minor code refactoring.

Download this release

Release Info

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

Code changes from version 2.0.2 to 2.0.3

admin/Admin.php CHANGED
@@ -55,7 +55,7 @@ class Admin extends BaseObject
55
  esc_html__('Table of Contents', 'luckywp-table-of-contents'),
56
  'manage_options',
57
  Core::$plugin->prefix . 'settings',
58
- [SettingsController::className(), 'router']
59
  );
60
  }
61
 
55
  esc_html__('Table of Contents', 'luckywp-table-of-contents'),
56
  'manage_options',
57
  Core::$plugin->prefix . 'settings',
58
+ [SettingsController::class, 'router']
59
  );
60
  }
61
 
admin/forms/CustomizeForm.php CHANGED
@@ -208,11 +208,11 @@ class CustomizeForm extends Model
208
  ['smoothScroll', 'boolean'],
209
  ['smoothScrollOffset', 'filter', 'filter' => 'intval'],
210
  ['position', 'in', 'range' => array_keys(Core::$plugin->positionsList)],
211
- ['width', 'filter', 'filter' => [Settings::className(), 'sanitizeWidth']],
212
  ['float', 'in', 'range' => array_keys(Core::$plugin->floatsList)],
213
- ['titleFontSize', 'filter', 'filter' => [Settings::className(), 'sanitizeFontSize']],
214
  ['titleFontWeight', 'in', 'range' => array_keys(Core::$plugin->fontWeightsList)],
215
- ['itemsFontSize', 'filter', 'filter' => [Settings::className(), 'sanitizeFontSize']],
216
  ['colorScheme', 'in', 'range' => array_keys(Core::$plugin->colorSchemesList)],
217
  [
218
  ['backgroundColor', 'borderColor', 'titleColor', 'linkColor', 'hoverLinkColor', 'visitedLinkColor'],
@@ -221,7 +221,7 @@ class CustomizeForm extends Model
221
  ],
222
  ['wrapNoindex', 'boolean'],
223
  ['useNofollow', 'boolean'],
224
- ['skipHeadingLevel', 'filter', 'filter' => [Settings::className(), 'sanitizeSkipHeadingLevel']],
225
  [
226
  'skipHeadingText',
227
  'filter',
208
  ['smoothScroll', 'boolean'],
209
  ['smoothScrollOffset', 'filter', 'filter' => 'intval'],
210
  ['position', 'in', 'range' => array_keys(Core::$plugin->positionsList)],
211
+ ['width', 'filter', 'filter' => [Settings::class, 'sanitizeWidth']],
212
  ['float', 'in', 'range' => array_keys(Core::$plugin->floatsList)],
213
+ ['titleFontSize', 'filter', 'filter' => [Settings::class, 'sanitizeFontSize']],
214
  ['titleFontWeight', 'in', 'range' => array_keys(Core::$plugin->fontWeightsList)],
215
+ ['itemsFontSize', 'filter', 'filter' => [Settings::class, 'sanitizeFontSize']],
216
  ['colorScheme', 'in', 'range' => array_keys(Core::$plugin->colorSchemesList)],
217
  [
218
  ['backgroundColor', 'borderColor', 'titleColor', 'linkColor', 'hoverLinkColor', 'visitedLinkColor'],
221
  ],
222
  ['wrapNoindex', 'boolean'],
223
  ['useNofollow', 'boolean'],
224
+ ['skipHeadingLevel', 'filter', 'filter' => [Settings::class, 'sanitizeSkipHeadingLevel']],
225
  [
226
  'skipHeadingText',
227
  'filter',
config/plugin.php CHANGED
@@ -12,19 +12,19 @@ return [
12
  'settings',
13
  ],
14
  'components' => [
15
- 'activation' => \luckywp\tableOfContents\plugin\Activation::className(),
16
- 'admin' => \luckywp\tableOfContents\admin\Admin::className(),
17
- 'front' => \luckywp\tableOfContents\front\Front::className(),
18
- 'mcePlugin' => \luckywp\tableOfContents\plugin\mcePlugin\McePlugin::className(),
19
- 'options' => \luckywp\tableOfContents\core\wp\Options::className(),
20
- 'rate' => \luckywp\tableOfContents\admin\Rate::className(),
21
- 'request' => \luckywp\tableOfContents\core\base\Request::className(),
22
  'settings' => [
23
- 'class' => \luckywp\tableOfContents\plugin\Settings::className(),
24
  'initGroupsConfigFile' => __DIR__ . '/settings.php',
25
  ],
26
- 'editorBlock' => \luckywp\tableOfContents\plugin\editorBlock\EditorBlock::className(),
27
- 'shortcode' => \luckywp\tableOfContents\plugin\Shortcode::className(),
28
- 'view' => \luckywp\tableOfContents\core\base\View::className(),
29
  ],
30
  ];
12
  'settings',
13
  ],
14
  'components' => [
15
+ 'activation' => \luckywp\tableOfContents\plugin\Activation::class,
16
+ 'admin' => \luckywp\tableOfContents\admin\Admin::class,
17
+ 'front' => \luckywp\tableOfContents\front\Front::class,
18
+ 'mcePlugin' => \luckywp\tableOfContents\plugin\mcePlugin\McePlugin::class,
19
+ 'options' => \luckywp\tableOfContents\core\wp\Options::class,
20
+ 'rate' => \luckywp\tableOfContents\admin\Rate::class,
21
+ 'request' => \luckywp\tableOfContents\core\base\Request::class,
22
  'settings' => [
23
+ 'class' => \luckywp\tableOfContents\plugin\Settings::class,
24
  'initGroupsConfigFile' => __DIR__ . '/settings.php',
25
  ],
26
+ 'editorBlock' => \luckywp\tableOfContents\plugin\editorBlock\EditorBlock::class,
27
+ 'shortcode' => \luckywp\tableOfContents\plugin\Shortcode::class,
28
+ 'view' => \luckywp\tableOfContents\core\base\View::class,
29
  ],
30
  ];
config/settings.php CHANGED
@@ -186,7 +186,7 @@ return [
186
  'value' => Core::$plugin->settings->getValue($field['group'], $field['id'], 'auto', false),
187
  ]);
188
  },
189
- 'sanitizeCallback' => [Settings::className(), 'sanitizeWidth'],
190
  'default' => 'auto',
191
  ],
192
 
@@ -208,7 +208,7 @@ return [
208
  'defaultSize' => 100,
209
  ]);
210
  },
211
- 'sanitizeCallback' => [Settings::className(), 'sanitizeFontSize'],
212
  'default' => 'default',
213
  ],
214
 
@@ -230,7 +230,7 @@ return [
230
  'defaultSize' => 90,
231
  ]);
232
  },
233
- 'sanitizeCallback' => [Settings::className(), 'sanitizeFontSize'],
234
  'default' => '90%',
235
  ],
236
 
@@ -364,7 +364,7 @@ return [
364
  'value' => Core::$plugin->settings->getValue($field['group'], $field['id'], [], false),
365
  ]);
366
  },
367
- 'sanitizeCallback' => [Settings::className(), 'sanitizeSkipHeadingLevel'],
368
  ],
369
  'skipHeadingText' => [
370
  'label' => esc_html__('By Text', 'luckywp-table-of-contents'),
186
  'value' => Core::$plugin->settings->getValue($field['group'], $field['id'], 'auto', false),
187
  ]);
188
  },
189
+ 'sanitizeCallback' => [Settings::class, 'sanitizeWidth'],
190
  'default' => 'auto',
191
  ],
192
 
208
  'defaultSize' => 100,
209
  ]);
210
  },
211
+ 'sanitizeCallback' => [Settings::class, 'sanitizeFontSize'],
212
  'default' => 'default',
213
  ],
214
 
230
  'defaultSize' => 90,
231
  ]);
232
  },
233
+ 'sanitizeCallback' => [Settings::class, 'sanitizeFontSize'],
234
  'default' => '90%',
235
  ],
236
 
364
  'value' => Core::$plugin->settings->getValue($field['group'], $field['id'], [], false),
365
  ]);
366
  },
367
+ 'sanitizeCallback' => [Settings::class, 'sanitizeSkipHeadingLevel'],
368
  ],
369
  'skipHeadingText' => [
370
  'label' => esc_html__('By Text', 'luckywp-table-of-contents'),
core/base/BaseObject.php CHANGED
@@ -20,11 +20,6 @@ abstract class BaseObject
20
  {
21
  }
22
 
23
- public static function className()
24
- {
25
- return get_called_class();
26
- }
27
-
28
  public function __get($name)
29
  {
30
  $getter = 'get' . $name;
20
  {
21
  }
22
 
 
 
 
 
 
23
  public function __get($name)
24
  {
25
  $getter = 'get' . $name;
core/base/Container.php CHANGED
@@ -145,7 +145,7 @@ class Container
145
  $this->_reflections[$class] = $reflection;
146
  }
147
 
148
- if ($reflection->isSubclassOf(BaseObject::className())) {
149
  $params[] = $config;
150
  $object = $reflection->newInstanceArgs($params);
151
  } else {
145
  $this->_reflections[$class] = $reflection;
146
  }
147
 
148
+ if ($reflection->isSubclassOf(BaseObject::class)) {
149
  $params[] = $config;
150
  $object = $reflection->newInstanceArgs($params);
151
  } else {
core/base/Controller.php CHANGED
@@ -65,7 +65,7 @@ abstract class Controller extends BaseObject implements ViewContextInterface
65
  public static function getInstance()
66
  {
67
  static $instances = [];
68
- $className = static::className();
69
  if (!isset($instances[$className])) {
70
  $instances[$className] = Core::createObject($className);
71
  }
65
  public static function getInstance()
66
  {
67
  static $instances = [];
68
+ $className = static::class;
69
  if (!isset($instances[$className])) {
70
  $instances[$className] = Core::createObject($className);
71
  }
core/validators/Validator.php CHANGED
@@ -41,10 +41,10 @@ abstract class Validator extends BaseObject
41
  public static function builtInValidators()
42
  {
43
  return [
44
- 'boolean' => BooleanValidator::className(),
45
- 'filter' => FilterValidator::className(),
46
- 'in' => RangeValidator::className(),
47
- 'required' => RequiredValidator::className(),
48
  ];
49
  }
50
 
@@ -60,7 +60,7 @@ abstract class Validator extends BaseObject
60
  {
61
  $params['attributes'] = $attributes;
62
  if (is_callable($name) || method_exists($model, $name)) {
63
- $params['class'] = InlineValidator::className();
64
  $params['method'] = $name;
65
  } else {
66
  if (isset(static::builtInValidators()[$name])) {
41
  public static function builtInValidators()
42
  {
43
  return [
44
+ 'boolean' => BooleanValidator::class,
45
+ 'filter' => FilterValidator::class,
46
+ 'in' => RangeValidator::class,
47
+ 'required' => RequiredValidator::class,
48
  ];
49
  }
50
 
60
  {
61
  $params['attributes'] = $attributes;
62
  if (is_callable($name) || method_exists($model, $name)) {
63
+ $params['class'] = InlineValidator::class;
64
  $params['method'] = $name;
65
  } else {
66
  if (isset(static::builtInValidators()[$name])) {
integrations/TwentyTwentyTheme.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace luckywp\tableOfContents\integrations;
4
+
5
+ use luckywp\tableOfContents\core\base\BaseObject;
6
+
7
+ class TwentyTwentyTheme extends BaseObject
8
+ {
9
+
10
+ public function init()
11
+ {
12
+ add_action('lwptoc_before', function ($s) {
13
+ return '<div>' . $s;
14
+ });
15
+ add_action('lwptoc_after', function ($s) {
16
+ return $s . '</div>';
17
+ });
18
+ }
19
+ }
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.2
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.2', __FILE__, 'lwptoc_');
51
 
52
  require_once __DIR__ . '/functions.php';
3
  Plugin Name: LuckyWP Table of Contents
4
  Plugin URI: https://theluckywp.com/product/table-of-contents/
5
  Description: Creates a table of contents for your posts/pages. Works automatically or manually (via shortcode, Gutenberg block or widget).
6
+ Version: 2.0.3
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.3', __FILE__, 'lwptoc_');
51
 
52
  require_once __DIR__ . '/functions.php';
plugin/Plugin.php CHANGED
@@ -15,6 +15,7 @@ use luckywp\tableOfContents\integrations\BeaverBuilder;
15
  use luckywp\tableOfContents\integrations\elementor\Elementor;
16
  use luckywp\tableOfContents\integrations\RankMath;
17
  use luckywp\tableOfContents\integrations\ToolsetViews;
 
18
  use luckywp\tableOfContents\integrations\Wpml;
19
  use luckywp\tableOfContents\plugin\editorBlock\EditorBlock;
20
  use luckywp\tableOfContents\plugin\mcePlugin\McePlugin;
@@ -64,19 +65,26 @@ class Plugin extends BasePlugin
64
  // Интеграции с другими плагинами
65
  add_action('plugins_loaded', function () {
66
  if (defined('FL_BUILDER_VERSION')) {
67
- Core::createObject(BeaverBuilder::className());
68
  }
69
  if (class_exists('\RankMath')) {
70
- Core::createObject(RankMath::className());
71
  }
72
  if (defined('WPV_VERSION')) {
73
- Core::createObject(ToolsetViews::className());
74
  }
75
  if (defined('ELEMENTOR_VERSION')) {
76
- Core::createObject(Elementor::className());
77
  }
78
  if (class_exists('\SitePress')) {
79
- Core::createObject(Wpml::className());
 
 
 
 
 
 
 
80
  }
81
  });
82
  }
15
  use luckywp\tableOfContents\integrations\elementor\Elementor;
16
  use luckywp\tableOfContents\integrations\RankMath;
17
  use luckywp\tableOfContents\integrations\ToolsetViews;
18
+ use luckywp\tableOfContents\integrations\TwentyTwentyTheme;
19
  use luckywp\tableOfContents\integrations\Wpml;
20
  use luckywp\tableOfContents\plugin\editorBlock\EditorBlock;
21
  use luckywp\tableOfContents\plugin\mcePlugin\McePlugin;
65
  // Интеграции с другими плагинами
66
  add_action('plugins_loaded', function () {
67
  if (defined('FL_BUILDER_VERSION')) {
68
+ Core::createObject(BeaverBuilder::class);
69
  }
70
  if (class_exists('\RankMath')) {
71
+ Core::createObject(RankMath::class);
72
  }
73
  if (defined('WPV_VERSION')) {
74
+ Core::createObject(ToolsetViews::class);
75
  }
76
  if (defined('ELEMENTOR_VERSION')) {
77
+ Core::createObject(Elementor::class);
78
  }
79
  if (class_exists('\SitePress')) {
80
+ Core::createObject(Wpml::class);
81
+ }
82
+ });
83
+
84
+ // Интеграция с темами
85
+ add_action('init', function () {
86
+ if (get_stylesheet() == 'twentytwenty') {
87
+ Core::createObject(TwentyTwentyTheme::class);
88
  }
89
  });
90
  }
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: 1.9.11
8
  Requires PHP: 5.6.20
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -151,6 +151,10 @@ For non-English websites it is recommended to enable the `Intl` PHP extension.
151
 
152
  == Changelog ==
153
 
 
 
 
 
154
  = 2.0.2 — 2020-01-10 =
155
  * Fixed: in some cases plugin incorrectly work with UTF-8.
156
  * Fixed: on automatically insertion table of contents with option “Before/after first heading” to posts without headings occurred error.
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.3
8
  Requires PHP: 5.6.20
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
151
 
152
  == Changelog ==
153
 
154
+ = 2.0.3 — 2020-01-19 =
155
+ + Added support "Twenty Twenty" theme.
156
+ * Minor code refactoring.
157
+
158
  = 2.0.2 — 2020-01-10 =
159
  * Fixed: in some cases plugin incorrectly work with UTF-8.
160
  * Fixed: on automatically insertion table of contents with option “Before/after first heading” to posts without headings occurred error.