PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.4
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.4
4.9.4 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 All 202 releases
← All changes | includes/Shortcodes/ToC.php +26 -0 4.4.0 → 4.9.4 View file →
@@ -38,11 +38,36 @@
38 38 // Don't show ToC for password-protected posts until password is provided
39 39 return '';
40 40 }
41 41
42 + if ( '1' == $this->attributes['collapsible_on_mobile'] && false === has_action( 'wp_footer', [ __CLASS__, 'print_collapsible_toggle' ] ) ) {
43 + add_action( 'wp_footer', [ __CLASS__, 'print_collapsible_toggle' ], 5 );
44 + }
45 +
42 46 $this->views( 'shortcodes/toc' );
43 47 }
44 48
49 + /**
50 + * "Collapsible on small devices" is toggled by betterdocs.js, which only
51 + * docs pages load. On other pages (the shortcode, block or widget placed
52 + * on a page) the title did nothing and the list stayed hidden on phones,
53 + * so add the same toggle there. The CSS limits it to small screens.
54 + */
55 + public static function print_collapsible_toggle() {
56 + if ( wp_script_is( 'betterdocs', 'enqueued' ) ) {
57 + return;
58 + }
59 +
60 + $js = <<<'JS'
61 +document.addEventListener('click',function(e){var t=e.target.closest?e.target.closest('.betterdocs-toc.collapsible-sm .toc-title'):null;if(!t)return;e.preventDefault();
62 +function s(el){el.style.display=getComputedStyle(el).display==='none'?'block':'none';}
63 +t.querySelectorAll('.angle-icon').forEach(s);var l=t.nextElementSibling;if(l&&l.classList.contains('toc-list'))s(l);});
64 +JS;
65 + wp_register_script( 'betterdocs-toc-collapsible', false, [], BETTERDOCS_VERSION, true );
66 + wp_add_inline_script( 'betterdocs-toc-collapsible', $js );
67 + wp_enqueue_script( 'betterdocs-toc-collapsible' );
68 + }
69 +
45 70 public function view_params() {
46 71 return [
47 72 'post' => get_post( $this->attributes['post_id'] )
48 73 ];
@@ -60,8 +85,9 @@
60 85 $use_full_filter = apply_filters( 'betterdocs_toc_use_full_content_filter', false );
61 86
62 87 if ( $use_full_filter ) {
63 88 // Use the full content filter if explicitly enabled
89 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- intentional WP core filter integration to render content as the platform would.
64 90 return apply_filters( 'the_content', $content );
65 91 }
66 92
67 93 // Apply only essential content processing filters that handle special characters