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
← All changes | views/template-parts/category-icon.php +46 -18 3.3.4 → 4.9.3 View file →
@@ -1,27 +1,55 @@
1 1 <?php
2 - if ( ! $show_icon ) {
3 - return;
4 - }
2 +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- view template receives variables via extract(); prefixing is impractical.
5 3
6 - $category_icon_meta_key = empty( $term_icon_meta_key ) ? 'doc_category_image-id' : $term_icon_meta_key;
7 - $cat_icon_id = get_term_meta( $term_id, $category_icon_meta_key, true );
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +if ( ! $show_icon ) {
8 + return;
9 +}
8 10
9 - $attr = [
10 - 'alt' => 'betterdocs-category-icon',
11 - 'class' => ['betterdocs-category-icon-img']
12 - ];
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 13
14 - if ( $cat_icon_id ) {
15 - $icon_url = wp_get_attachment_image_url( $cat_icon_id, 'thumbnail' );
16 - $attr['alt'] = get_post_meta( $cat_icon_id, '_wp_attachment_image_alt', true );
17 - } else {
18 - $icon_url = betterdocs()->assets->icon( 'betterdocs-cat-icon.svg', true );
19 - }
14 + $attr['alt'] = 'betterdocs-category-icon';
20 15
21 - $attr['src'] = esc_url( $icon_url );
22 - $image_attributes = betterdocs()->template_helper->get_html_attributes( $attr );
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 );
23 31 ?>
24 32
25 33 <div class="betterdocs-category-icon">
26 - <?php echo wp_kses_post( '<img ' . $image_attributes . ' />' ); ?>
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 + ?>
27 55 </div>