PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.3
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.3
4.9.3 4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 All 201 releases
← All changes | views/templates/parts/toc.php +22 -8 3.4.0 → 4.9.3 View file →
@@ -1,9 +1,21 @@
1 1 <?php
2 +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- view template receives variables via extract(); prefixing is impractical.
3 +
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
2 7 if ( ! betterdocs()->settings->get( 'enable_toc', false ) ) {
3 - return;
8 + return;
4 9 }
5 10
11 +// Check if post is password protected and user hasn't provided correct password
12 +// This applies to all contexts: templates, Gutenberg blocks, and Elementor widgets
13 +if ( post_password_required() ) {
14 + // Don't show ToC for password-protected posts until password is provided
15 + return;
16 +}
17 +
6 18 $toc_hierarchy = betterdocs()->settings->get( 'toc_hierarchy' );
7 19 $toc_list_number = betterdocs()->settings->get( 'toc_list_number' );
8 20 $collapsible_toc_mobile = betterdocs()->settings->get( 'collapsible_toc_mobile' );
9 21 $supported_tag = betterdocs()->settings->get( 'supported_heading_tag', '' );
@@ -8,12 +20,14 @@
8 20 $collapsible_toc_mobile = betterdocs()->settings->get( 'collapsible_toc_mobile' );
9 21 $supported_tag = betterdocs()->settings->get( 'supported_heading_tag', '' );
10 22 $htags = $supported_tag ? implode( ',', $supported_tag ) : '';
11 23
12 -$attributes = betterdocs()->template_helper->get_html_attributes([
13 - 'htags' => "{$htags}",
14 - 'hierarchy' => "{$toc_hierarchy}",
15 - 'list_number' => "{$toc_list_number}",
16 - 'collapsible_on_mobile' => "{$collapsible_toc_mobile}"
17 -]);
24 +$attributes = betterdocs()->template_helper->get_html_attributes(
25 + [
26 + 'htags' => "{$htags}",
27 + 'hierarchy' => "{$toc_hierarchy}",
28 + 'list_number' => "{$toc_list_number}",
29 + 'collapsible_on_mobile' => "{$collapsible_toc_mobile}"
30 + ]
31 +);
18 32
19 -echo do_shortcode( "[betterdocs_toc ". $attributes ."]" );
33 +echo do_shortcode( '[betterdocs_toc ' . $attributes . ']' );