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
betterdocs / views / templates / parts / toc.php

toc.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.9.3, at views/templates/parts/toc.php

34 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }
7 if ( ! betterdocs()->settings->get( 'enable_toc', false ) ) {
8 return;
9 }
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
18 $toc_hierarchy = betterdocs()->settings->get( 'toc_hierarchy' );
19 $toc_list_number = betterdocs()->settings->get( 'toc_list_number' );
20 $collapsible_toc_mobile = betterdocs()->settings->get( 'collapsible_toc_mobile' );
21 $supported_tag = betterdocs()->settings->get( 'supported_heading_tag', '' );
22 $htags = $supported_tag ? implode( ',', $supported_tag ) : '';
23
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 );
32
33 echo do_shortcode( '[betterdocs_toc ' . $attributes . ']' );
34