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 / category-icon.php

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

56 lines 1.8 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 ( ! $show_icon ) {
8 return;
9 }
10
11 $category_icon_meta_key = empty( $term_icon_meta_key ) ? 'doc_category_image-id' : $term_icon_meta_key;
12 $cat_icon_id = get_term_meta( $term_id, $category_icon_meta_key, true );
13
14 $attr['alt'] = 'betterdocs-category-icon';
15
16 if ( isset( $cat_icon_id ) && ( isset( $category_icon ) && ( $category_icon == 'folder' || $category_icon == 'folder-open' ) ) ) {
17 $attr['class'] = [ 'betterdocs-category-folder-img' ];
18 } else {
19 $attr['class'] = [ 'betterdocs-category-icon-img' ];
20 }
21
22 if ( $cat_icon_id ) {
23 $icon_url = wp_get_attachment_image_url( $cat_icon_id, 'thumbnail' );
24 $attr['alt'] = get_post_meta( $cat_icon_id, '_wp_attachment_image_alt', true );
25 } else {
26 $icon_url = betterdocs()->assets->icon( 'betterdocs-cat-icon.svg', true );
27 }
28
29 $attr['src'] = esc_url( $icon_url );
30 $image_attributes = betterdocs()->template_helper->get_html_attributes( $attr );
31 ?>
32
33 <div class="betterdocs-category-icon">
34 <?php
35 if ( isset( $category_icon ) && $category_icon == 'folder' ) {
36 if ( $cat_icon_id ) {
37 echo '<span class="betterdocs-folder-icon">';
38 echo wp_kses_post( '<img ' . $image_attributes . ' />' );
39 echo '</span>';
40 } else {
41 betterdocs()->template_helper->icon( 'folder', true );
42 }
43 } elseif ( isset( $category_icon ) && $category_icon == 'folder-open' ) {
44 if ( $cat_icon_id ) {
45 echo '<span class="betterdocs-folder-icon">';
46 echo wp_kses_post( '<img ' . $image_attributes . ' />' );
47 echo '</span>';
48 } else {
49 betterdocs()->template_helper->icon( 'folder-open', true );
50 }
51 } else {
52 echo wp_kses_post( '<img ' . $image_attributes . ' />' );
53 }
54 ?>
55 </div>
56