PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.5.1
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.5.1
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 3.5.2 All 199 releases
betterdocs / includes / REST / CategoryField.php

CategoryField.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 3.5.1, at includes/REST/CategoryField.php

38 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPDeveloper\BetterDocs\REST;
4 use WPDeveloper\BetterDocs\Core\BaseAPI;
5
6 class CategoryField extends BaseAPI {
7 /**
8 * @return mixed
9 */
10 public function register() {
11 $this->register_field( 'doc_category', 'thumbnail', [
12 'get_callback' => [$this, 'thumbnail_image']
13 ] );
14 $this->register_field( 'doc_category', 'handbookthumbnail', [
15 'get_callback' => [$this, 'handbook_thumbnail_image']
16 ] );
17 }
18
19 public function thumbnail_image( $object ) {
20 $attachment_id = get_term_meta( $object['id'], 'doc_category_image-id', true );
21 if ( ! $attachment_id ) {
22 return;
23 }
24
25 return wp_get_attachment_url( $attachment_id );
26 }
27
28 public function handbook_thumbnail_image( $object ) {
29 $handbook_img_id = get_term_meta( $object['id'], 'doc_category_thumb-id', true );
30
31 if ( ! $handbook_img_id ) {
32 return;
33 }
34
35 return wp_get_attachment_url( $handbook_img_id );
36 }
37 }
38