LuckyWP Table of Contents - Version 1.0.3

Version Description

  • Minor appearance changes
  • Bug fix
Download this release

Release Info

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

Code changes from version 1.0.2 to 1.0.3

admin/Admin.php CHANGED
@@ -66,7 +66,7 @@ class Admin extends BaseObject
66
 
67
  public function addMetaBoxes()
68
  {
69
- if (current_user_can('edit_post') && $this->getMetaboxPostTypes()) {
70
  add_meta_box(
71
  Core::$plugin->prefix . '_postSettings',
72
  esc_html__('Table of Contents', 'lwptoc'),
66
 
67
  public function addMetaBoxes()
68
  {
69
+ if (current_user_can('edit_posts') && $this->getMetaboxPostTypes()) {
70
  add_meta_box(
71
  Core::$plugin->prefix . '_postSettings',
72
  esc_html__('Table of Contents', 'lwptoc'),
admin/forms/CustomizeForm.php CHANGED
@@ -6,6 +6,7 @@ use luckywp\tableOfContents\core\base\Model;
6
  use luckywp\tableOfContents\core\Core;
7
  use luckywp\tableOfContents\core\helpers\ArrayHelper;
8
  use luckywp\tableOfContents\plugin\PostSettings;
 
9
 
10
  class CustomizeForm extends Model
11
  {
@@ -180,11 +181,11 @@ class CustomizeForm extends Model
180
  ['smoothScroll', 'boolean'],
181
  ['smoothScrollOffset', 'filter', 'filter' => 'intval'],
182
  ['position', 'in', 'range' => array_keys(Core::$plugin->positionsList)],
183
- ['width', 'filter', 'filter' => [Core::$plugin->settings, 'sanitizeWidth']],
184
  ['float', 'in', 'range' => array_keys(Core::$plugin->floatsList)],
185
- ['titleFontSize', 'filter', 'filter' => [Core::$plugin->settings, 'sanitizeFontSize']],
186
  ['titleFontWeight', 'in', 'range' => array_keys(Core::$plugin->fontWeightsList)],
187
- ['itemsFontSize', 'filter', 'filter' => [Core::$plugin->settings, 'sanitizeFontSize']],
188
  ['colorScheme', 'in', 'range' => array_keys(Core::$plugin->colorSchemesList)],
189
  [
190
  ['backgroundColor', 'borderColor', 'titleColor', 'linkColor', 'hoverLinkColor', 'visitedLinkColor'],
6
  use luckywp\tableOfContents\core\Core;
7
  use luckywp\tableOfContents\core\helpers\ArrayHelper;
8
  use luckywp\tableOfContents\plugin\PostSettings;
9
+ use luckywp\tableOfContents\plugin\Settings;
10
 
11
  class CustomizeForm extends Model
12
  {
181
  ['smoothScroll', 'boolean'],
182
  ['smoothScrollOffset', 'filter', 'filter' => 'intval'],
183
  ['position', 'in', 'range' => array_keys(Core::$plugin->positionsList)],
184
+ ['width', 'filter', 'filter' => [Settings::className(), 'sanitizeWidth']],
185
  ['float', 'in', 'range' => array_keys(Core::$plugin->floatsList)],
186
+ ['titleFontSize', 'filter', 'filter' => [Settings::className(), 'sanitizeFontSize']],
187
  ['titleFontWeight', 'in', 'range' => array_keys(Core::$plugin->fontWeightsList)],
188
+ ['itemsFontSize', 'filter', 'filter' => [Settings::className(), 'sanitizeFontSize']],
189
  ['colorScheme', 'in', 'range' => array_keys(Core::$plugin->colorSchemesList)],
190
  [
191
  ['backgroundColor', 'borderColor', 'titleColor', 'linkColor', 'hoverLinkColor', 'visitedLinkColor'],
config/settings.php CHANGED
@@ -5,6 +5,7 @@ use luckywp\tableOfContents\admin\widgets\widthField\WidthField;
5
  use luckywp\tableOfContents\core\admin\helpers\AdminHtml;
6
  use luckywp\tableOfContents\admin\widgets\PostTypes;
7
  use luckywp\tableOfContents\core\Core;
 
8
 
9
  return [
10
 
@@ -163,7 +164,7 @@ return [
163
  'value' => Core::$plugin->settings->getValue($field['group'], $field['id'], 'auto', false),
164
  ]);
165
  },
166
- 'sanitizeCallback' => [Core::$plugin->settings, 'sanitizeWidth'],
167
  'default' => 'auto',
168
  ],
169
 
@@ -185,7 +186,7 @@ return [
185
  'defaultSize' => 100,
186
  ]);
187
  },
188
- 'sanitizeCallback' => [Core::$plugin->settings, 'sanitizeFontSize'],
189
  'default' => 'default',
190
  ],
191
 
@@ -207,7 +208,7 @@ return [
207
  'defaultSize' => 90,
208
  ]);
209
  },
210
- 'sanitizeCallback' => [Core::$plugin->settings, 'sanitizeFontSize'],
211
  'default' => '90%',
212
  ],
213
 
5
  use luckywp\tableOfContents\core\admin\helpers\AdminHtml;
6
  use luckywp\tableOfContents\admin\widgets\PostTypes;
7
  use luckywp\tableOfContents\core\Core;
8
+ use luckywp\tableOfContents\plugin\Settings;
9
 
10
  return [
11
 
164
  'value' => Core::$plugin->settings->getValue($field['group'], $field['id'], 'auto', false),
165
  ]);
166
  },
167
+ 'sanitizeCallback' => [Settings::className(), 'sanitizeWidth'],
168
  'default' => 'auto',
169
  ],
170
 
186
  'defaultSize' => 100,
187
  ]);
188
  },
189
+ 'sanitizeCallback' => [Settings::className(), 'sanitizeFontSize'],
190
  'default' => 'default',
191
  ],
192
 
208
  'defaultSize' => 90,
209
  ]);
210
  },
211
+ 'sanitizeCallback' => [Settings::className(), 'sanitizeFontSize'],
212
  'default' => '90%',
213
  ],
214
 
front/views/body.php CHANGED
@@ -22,9 +22,7 @@ echo Html::beginTag('div', $containerOptions);
22
  <?= $title ? '<b class="lwptoc_title"' . ($titleStyles ? ' style="' . implode('', $titleStyles) . '"' : '') . '>' . $title . '</b>' : '' ?>
23
  <?php if ($toggle) { ?>
24
  <span class="lwptoc_toggle">
25
- <a href="#" class="lwptoc_toggle_label" data-label="<?= $hideItems ? $labelHide : $labelShow ?>">
26
- <?= $hideItems ? $labelShow : $labelHide ?>
27
- </a>
28
  </span>
29
  <?php } ?>
30
  </div>
22
  <?= $title ? '<b class="lwptoc_title"' . ($titleStyles ? ' style="' . implode('', $titleStyles) . '"' : '') . '>' . $title . '</b>' : '' ?>
23
  <?php if ($toggle) { ?>
24
  <span class="lwptoc_toggle">
25
+ <a href="#" class="lwptoc_toggle_label" data-label="<?= $hideItems ? $labelHide : $labelShow ?>"><?= $hideItems ? $labelShow : $labelHide ?></a>
 
 
26
  </span>
27
  <?php } ?>
28
  </div>
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.2
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.2', __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.0.3
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.0.3', __FILE__, 'lwptoc_');
33
 
34
  require_once __DIR__ . '/functions.php';
plugin/Settings.php CHANGED
@@ -138,7 +138,7 @@ class Settings extends \luckywp\tableOfContents\core\wp\Settings
138
  */
139
  public function getAppearanceWidth()
140
  {
141
- return $this->sanitizeWidth((string)$this->getValue('appearance', 'width', 'auto'));
142
  }
143
 
144
  /**
@@ -158,7 +158,7 @@ class Settings extends \luckywp\tableOfContents\core\wp\Settings
158
  */
159
  public function getAppearanceTitleFontSize()
160
  {
161
- return $this->sanitizeFontSize((string)$this->getValue('appearance', 'titleFontSize', 'default'));
162
  }
163
 
164
  /**
@@ -178,7 +178,7 @@ class Settings extends \luckywp\tableOfContents\core\wp\Settings
178
  */
179
  public function getAppearanceItemsFontSize()
180
  {
181
- return $this->sanitizeFontSize((string)$this->getValue('appearance', 'itemsFontSize', 'default'));
182
  }
183
 
184
  /**
@@ -274,9 +274,9 @@ class Settings extends \luckywp\tableOfContents\core\wp\Settings
274
  * @param string $value
275
  * @return string
276
  */
277
- public function sanitizeWidth($value)
278
  {
279
- return $this->prepareWidth($value, $matches);
280
  }
281
 
282
  /**
@@ -299,9 +299,9 @@ class Settings extends \luckywp\tableOfContents\core\wp\Settings
299
  * @param string $value
300
  * @return string
301
  */
302
- public function sanitizeFontSize($value)
303
  {
304
- return $this->prepareFontSize($value, $matches);
305
  }
306
 
307
  /**
138
  */
139
  public function getAppearanceWidth()
140
  {
141
+ return static::sanitizeWidth((string)$this->getValue('appearance', 'width', 'auto'));
142
  }
143
 
144
  /**
158
  */
159
  public function getAppearanceTitleFontSize()
160
  {
161
+ return static::sanitizeFontSize((string)$this->getValue('appearance', 'titleFontSize', 'default'));
162
  }
163
 
164
  /**
178
  */
179
  public function getAppearanceItemsFontSize()
180
  {
181
+ return static::sanitizeFontSize((string)$this->getValue('appearance', 'itemsFontSize', 'default'));
182
  }
183
 
184
  /**
274
  * @param string $value
275
  * @return string
276
  */
277
+ public static function sanitizeWidth($value)
278
  {
279
+ return Core::$plugin->settings->prepareWidth($value, $matches);
280
  }
281
 
282
  /**
299
  * @param string $value
300
  * @return string
301
  */
302
+ public static function sanitizeFontSize($value)
303
  {
304
+ return Core::$plugin->settings->prepareFontSize($value, $matches);
305
  }
306
 
307
  /**
plugin/Shortcode.php CHANGED
@@ -285,7 +285,7 @@ class Shortcode extends BaseObject
285
  if ($width === null) {
286
  $width = Core::$plugin->settings->appearanceWidth;
287
  } else {
288
- $width = Core::$plugin->settings->sanitizeWidth($width);
289
  }
290
  if ($width != 'full') {
291
  if ($width == 'auto') {
@@ -307,7 +307,7 @@ class Shortcode extends BaseObject
307
  if ($titleFontSize === null) {
308
  $titleFontSize = Core::$plugin->settings->appearanceTitleFontSize;
309
  } else {
310
- $titleFontSize = Core::$plugin->settings->sanitizeFontSize($titleFontSize);
311
  }
312
  if ($titleFontSize != 'default') {
313
  $headerStyles[] = 'font-size:' . $titleFontSize . ';';
@@ -325,7 +325,7 @@ class Shortcode extends BaseObject
325
  if ($itemsFontSize === null) {
326
  $itemsFontSize = Core::$plugin->settings->appearanceItemsFontSize;
327
  } else {
328
- $itemsFontSize = Core::$plugin->settings->sanitizeFontSize($itemsFontSize);
329
  }
330
  if ($itemsFontSize == '90%') {
331
  $containerOptions['class'][] = 'lwptoc-baseItems';
285
  if ($width === null) {
286
  $width = Core::$plugin->settings->appearanceWidth;
287
  } else {
288
+ $width = Settings::sanitizeWidth($width);
289
  }
290
  if ($width != 'full') {
291
  if ($width == 'auto') {
307
  if ($titleFontSize === null) {
308
  $titleFontSize = Core::$plugin->settings->appearanceTitleFontSize;
309
  } else {
310
+ $titleFontSize = Settings::sanitizeFontSize($titleFontSize);
311
  }
312
  if ($titleFontSize != 'default') {
313
  $headerStyles[] = 'font-size:' . $titleFontSize . ';';
325
  if ($itemsFontSize === null) {
326
  $itemsFontSize = Core::$plugin->settings->appearanceItemsFontSize;
327
  } else {
328
+ $itemsFontSize = Settings::sanitizeFontSize($itemsFontSize);
329
  }
330
  if ($itemsFontSize == '90%') {
331
  $containerOptions['class'][] = 'lwptoc-baseItems';
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.0
7
- Stable tag: 1.0.2
8
  Requires PHP: 5.4.45
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -89,6 +89,10 @@ The menu item "Table of Contents" will appear in the menu "Settings" of the Word
89
 
90
  == Changelog ==
91
 
 
 
 
 
92
  = 1.0.2 =
93
  * Bug fix
94
 
4
  Tags: table of contents, toc, navigation, links, heading
5
  Requires at least: 4.7
6
  Tested up to: 5.0
7
+ Stable tag: 1.0.3
8
  Requires PHP: 5.4.45
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
89
 
90
  == Changelog ==
91
 
92
+ = 1.0.3 =
93
+ * Minor appearance changes
94
+ * Bug fix
95
+
96
  = 1.0.2 =
97
  * Bug fix
98