PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.2
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 3.5.1 All 200 releases
← All changes | includes/FrontEnd/TemplateLoader.php +38 -2 4.5.14.9.2 View file →
@@ -1,8 +1,12 @@
1 1 <?php
2 +namespace WPDeveloper\BetterDocs\FrontEnd;
2 3
3 -namespace WPDeveloper\BetterDocs\FrontEnd;
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
4 7
8 +
5 9 use WPDeveloper\BetterDocs\Utils\Base;
6 10 use WPDeveloper\BetterDocs\Utils\Views;
7 11 use WPDeveloper\BetterDocs\Utils\Database;
8 12 use WPDeveloper\BetterDocs\Dependencies\DI\Container;
@@ -24,9 +28,15 @@
24 28 public function init() {
25 29 $this->is_fse_theme = $this->is_fse_theme();
26 30
27 31 if ( $this->is_fse_theme ) {
28 - // @todo: for FSE theme
32 + // Block themes have no PHP template-hierarchy hook for the glossaries
33 + // (encyclopedia) taxonomy, so single glossary entries fall through to the
34 + // theme's default block template and render the generic docs/archive
35 + // output instead of the BetterDocs glossary template (fbs-79870). Force
36 + // the glossary template via template_include, which runs after
37 + // locate_block_template() so it wins over the block-template fallback.
38 + add_filter( 'template_include', [ $this, 'fse_glossaries_template' ], 99 );
29 39 }
30 40
31 41 if ( ! $this->is_fse_theme ) {
32 42 add_filter( 'archive_template', [ $this, 'archive_template' ] );
@@ -31,8 +41,34 @@
31 41 if ( ! $this->is_fse_theme ) {
32 42 add_filter( 'archive_template', [ $this, 'archive_template' ] );
33 43 add_filter( 'single_template', [ $this, 'single_template' ] );
34 44 }
45 + }
46 +
47 + /**
48 + * Load the BetterDocs glossary template for single glossary (encyclopedia)
49 + * taxonomy pages under block (FSE) themes. Mirrors the glossaries branch of
50 + * archive_template() used for classic themes. Runs late on template_include
51 + * so it overrides the block-template fallback that would otherwise render the
52 + * generic docs archive. (fbs-79870)
53 + *
54 + * @param string $template The template path resolved so far.
55 + * @return string
56 + */
57 + public function fse_glossaries_template( $template ) {
58 + if ( ! is_tax( 'glossaries' ) ) {
59 + return $template;
60 + }
61 +
62 + $_default_template = 'templates/single/layout-1';
63 + $layout = 'templates/single/layout-7';
64 + $eligible_template = $this->views->path( $layout, $_default_template );
65 +
66 + if ( file_exists( $eligible_template ) ) {
67 + $template = $eligible_template;
68 + }
69 +
70 + return apply_filters( 'betterdocs_archives_template', $template, $layout, $_default_template, $this->views );
35 71 }
36 72
37 73 /**
38 74 * Render Thrive Header Markup