LuckyWP Table of Contents - Version 1.9.11

Version Description

2019-11-18 = + Added hook filters lwptoc_force_wp_transliterate and lwptoc_transliterator. * Fixed: in some cases for table of contents used a non-current post.

Download this release

Release Info

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

Code changes from version 1.9.10 to 1.9.11

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: 1.9.10
7
  Author: LuckyWP
8
  Author URI: https://theluckywp.com/
9
  Text Domain: luckywp-table-of-contents
@@ -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.9.10', __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, Gutenberg block or widget).
6
+ Version: 1.9.11
7
  Author: LuckyWP
8
  Author URI: https://theluckywp.com/
9
  Text Domain: luckywp-table-of-contents
29
  $lwptocAutoloader->addNamespace('luckywp\tableOfContents', __DIR__);
30
 
31
  $config = require(__DIR__ . '/config/plugin.php');
32
+ (new \luckywp\tableOfContents\plugin\Plugin($config))->run('1.9.11', __FILE__, 'lwptoc_');
33
 
34
  require_once __DIR__ . '/functions.php';
plugin/Shortcode.php CHANGED
@@ -60,7 +60,8 @@ class Shortcode extends BaseObject
60
  {
61
  global $post;
62
  if (($this->theContentApplied && $this->headingsCache === null) ||
63
- (!is_single($post) && !is_page($post))
 
64
  ) {
65
  return '';
66
  }
@@ -215,6 +216,10 @@ class Shortcode extends BaseObject
215
  {
216
  global $post;
217
 
 
 
 
 
218
  if ($this->headingsCache !== null) {
219
  return true;
220
  }
@@ -232,6 +237,16 @@ class Shortcode extends BaseObject
232
  return (new PostSettings($post->ID))->processHeadings;
233
  }
234
 
 
 
 
 
 
 
 
 
 
 
235
  private $_tag;
236
 
237
  /**
60
  {
61
  global $post;
62
  if (($this->theContentApplied && $this->headingsCache === null) ||
63
+ (!is_single($post) && !is_page($post)) ||
64
+ !$this->isMainQueryPost()
65
  ) {
66
  return '';
67
  }
216
  {
217
  global $post;
218
 
219
+ if (!$this->isMainQueryPost()) {
220
+ return false;
221
+ }
222
+
223
  if ($this->headingsCache !== null) {
224
  return true;
225
  }
237
  return (new PostSettings($post->ID))->processHeadings;
238
  }
239
 
240
+ /**
241
+ * @return bool
242
+ */
243
+ protected function isMainQueryPost()
244
+ {
245
+ global $post, $wp_query;
246
+ return ($post instanceof WP_Post) &&
247
+ $post->ID == $wp_query->get_queried_object_id();
248
+ }
249
+
250
  private $_tag;
251
 
252
  /**
plugin/contentHandling/ContentHandling.php CHANGED
@@ -81,8 +81,8 @@ class ContentHandling
81
  $id = html_entity_decode($id, ENT_QUOTES, get_option('blog_charset'));
82
  } else {
83
  $id = html_entity_decode($id, ENT_QUOTES, get_option('blog_charset'));
84
- if (function_exists('transliterator_transliterate')) {
85
- $id = transliterator_transliterate('Any-Latin; Latin-ASCII;', $id);
86
  } else {
87
  $id = remove_accents($id);
88
  }
81
  $id = html_entity_decode($id, ENT_QUOTES, get_option('blog_charset'));
82
  } else {
83
  $id = html_entity_decode($id, ENT_QUOTES, get_option('blog_charset'));
84
+ if (function_exists('transliterator_transliterate') && !apply_filters('lwptoc_force_wp_transliterate', false)) {
85
+ $id = transliterator_transliterate(apply_filters('lwptoc_transliterator', 'Any-Latin; Latin-ASCII;'), $id);
86
  } else {
87
  $id = remove_accents($id);
88
  }
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
7
- Stable tag: 1.9.10
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
  = 1.9.10 — 2019-11-10 =
155
  * Fixed: in some cases hash for heading without transliteration was generated incorrectly.
156
 
4
  Tags: table of contents, toc, navigation, links, seo
5
  Requires at least: 4.7
6
  Tested up to: 5.3
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
 
152
  == Changelog ==
153
 
154
+ = 1.9.11 — 2019-11-18 =
155
+ + Added hook filters `lwptoc_force_wp_transliterate` and `lwptoc_transliterator`.
156
+ * Fixed: in some cases for table of contents used a non-current post.
157
+
158
  = 1.9.10 — 2019-11-10 =
159
  * Fixed: in some cases hash for heading without transliteration was generated incorrectly.
160