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 +25 -0 4.9.0 → 4.9.4 View file →
@@ -38,9 +38,34 @@
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' );
47 + }
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' );
43 68 }
44 69
45 70 public function view_params() {
46 71 return [