LuckyWP Table of Contents - Version 2.1.3

Version Description

2020-06-07 = + Added hook filter lwptoc_allow.

Download this release

Release Info

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

Code changes from version 2.1.2 to 2.1.3

front/Front.php CHANGED
@@ -8,6 +8,7 @@ use luckywp\tableOfContents\core\front\BaseFront;
8
  use luckywp\tableOfContents\core\helpers\ArrayHelper;
9
  use luckywp\tableOfContents\plugin\dom\Dom;
10
  use luckywp\tableOfContents\plugin\PostSettings;
 
11
 
12
  class Front extends BaseFront
13
  {
@@ -99,7 +100,7 @@ class Front extends BaseFront
99
  {
100
  global $post;
101
 
102
- if (!is_single($post) && !is_page($post)) {
103
  return $content;
104
  }
105
 
8
  use luckywp\tableOfContents\core\helpers\ArrayHelper;
9
  use luckywp\tableOfContents\plugin\dom\Dom;
10
  use luckywp\tableOfContents\plugin\PostSettings;
11
+ use luckywp\tableOfContents\plugin\Shortcode;
12
 
13
  class Front extends BaseFront
14
  {
100
  {
101
  global $post;
102
 
103
+ if (!Shortcode::allow()) {
104
  return $content;
105
  }
106
 
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.1.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.1.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.1.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.1.3', __FILE__, 'lwptoc_');
51
 
52
  require_once __DIR__ . '/functions.php';
plugin/Shortcode.php CHANGED
@@ -61,8 +61,7 @@ class Shortcode extends BaseObject
61
  global $post;
62
  if ($this->isDiactivated() ||
63
  ($this->theContentApplied && $this->headingsCache === null) ||
64
- (!is_single($post) && !is_page($post)) ||
65
- !$this->isMainQueryPost()
66
  ) {
67
  return '';
68
  }
@@ -220,7 +219,7 @@ class Shortcode extends BaseObject
220
  {
221
  global $post;
222
 
223
- if (!$this->isMainQueryPost()) {
224
  return false;
225
  }
226
 
@@ -244,11 +243,17 @@ class Shortcode extends BaseObject
244
  /**
245
  * @return bool
246
  */
247
- protected function isMainQueryPost()
248
  {
249
  global $post, $wp_query;
250
- return ($post instanceof WP_Post) &&
251
- $post->ID == $wp_query->get_queried_object_id();
 
 
 
 
 
 
252
  }
253
 
254
  private $_tag;
61
  global $post;
62
  if ($this->isDiactivated() ||
63
  ($this->theContentApplied && $this->headingsCache === null) ||
64
+ !static::allow()
 
65
  ) {
66
  return '';
67
  }
219
  {
220
  global $post;
221
 
222
+ if (!static::allow()) {
223
  return false;
224
  }
225
 
243
  /**
244
  * @return bool
245
  */
246
+ public static function allow()
247
  {
248
  global $post, $wp_query;
249
+ if (!($post instanceof WP_Post)) {
250
+ return false;
251
+ }
252
+
253
+ $allow = (is_single($post->ID) || is_page($post->ID)) && // Это страница записи
254
+ ($post->ID == $wp_query->get_queried_object_id()); // Это главный запрос на странице
255
+
256
+ return apply_filters('lwptoc_allow', $allow, $post);
257
  }
258
 
259
  private $_tag;
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.4
7
- Stable tag: 2.1.2
8
  Requires PHP: 5.6.20
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -160,6 +160,9 @@ For non-English websites it is recommended to enable the `Intl` PHP extension.
160
 
161
  == Changelog ==
162
 
 
 
 
163
  = 2.1.2 — 2020-05-08 =
164
  + Added hook filter `lwptoc_title_tag`.
165
 
4
  Tags: table of contents, toc, navigation, links, seo
5
  Requires at least: 4.7
6
  Tested up to: 5.4
7
+ Stable tag: 2.1.3
8
  Requires PHP: 5.6.20
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
160
 
161
  == Changelog ==
162
 
163
+ = 2.1.3 — 2020-06-07 =
164
+ + Added hook filter `lwptoc_allow`.
165
+
166
  = 2.1.2 — 2020-05-08 =
167
  + Added hook filter `lwptoc_title_tag`.
168