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 / template-parts / archive-nested-categories.php

archive-nested-categories.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.9.3, at views/template-parts/archive-nested-categories.php

58 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Nested subcategory renderer for the Doc Category Archive List widget's
4 * Layout 2 and Layout 3.
5 *
6 * Mirrors the Layout 1 call in template-parts/category-list.php, but buffers
7 * the output so the load-bearing `betterdocs-articles-list` wrapper — the
8 * stylesheet hides the collapsed arrow via
9 * `.betterdocs-articles-list .betterdocs-nested-category-title svg.arrow-down`
10 * — is emitted only when there is something to render. template-parts/
11 * nested-categories returns early for a term with no renderable children,
12 * which would otherwise leave a stray empty <ul> carrying list spacing on
13 * every childless category.
14 *
15 * @var bool $nested_subcategory
16 * @var \WP_Term|null $current_category
17 */
18
19 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- view template receives variables via extract(); prefixing is impractical.
20
21 if ( ! defined( 'ABSPATH' ) ) {
22 exit;
23 }
24
25 if ( empty( $nested_subcategory ) ) {
26 return;
27 }
28
29 $bd_parent_term = isset( $current_category ) ? $current_category : ( isset( $term ) ? $term : null );
30 if ( ! ( $bd_parent_term instanceof \WP_Term ) ) {
31 return;
32 }
33
34 // Forward the accumulated params to the shared partial, exactly like
35 // template-parts/category-list.php does for Layout 1.
36 $_defined = get_defined_vars();
37 $_params = isset( $_defined['params'] ) ? $_defined['params'] : [];
38 $_params = wp_parse_args(
39 [
40 'term' => $bd_parent_term,
41 'term_id' => $bd_parent_term->term_id,
42 'list_icon_url' => isset( $list_icon_url ) ? $list_icon_url : '',
43 ],
44 $_params
45 );
46 if ( isset( $layout_type ) && ( 'widget' === $layout_type || 'block' === $layout_type ) ) {
47 $_params['list_icon_name'] = isset( $list_icon_name ) ? $list_icon_name : '';
48 }
49
50 ob_start();
51 $view_object->get( 'template-parts/nested-categories', $_params );
52 $bd_nested_html = trim( ob_get_clean() );
53
54 if ( '' !== $bd_nested_html ) {
55 // The inner markup is already escaped by template-parts/nested-categories.
56 echo '<ul class="betterdocs-articles-list betterdocs-archive-nested-list">' . $bd_nested_html . '</ul>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
57 }
58