PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 1.1.7
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v1.1.7
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 / admin / includes / class-betterdocs-db.php

class-betterdocs-db.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 1.1.7, at admin/includes/class-betterdocs-db.php

92 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This class responsible for database work
4 * using wordpress functionality
5 * get_option and update_option.
6 */
7 class BetterDocs_DB {
8 /**
9 * Get all default settings value.
10 *
11 * @param string $name
12 * @return array
13 */
14 public static function default_settings(){
15
16 $option_default = apply_filters('betterdocs_option_default_settings', array(
17 'builtin_doc_page' => 1,
18 'docs_slug' => 'docs',
19 'doc_page' => '',
20 'category_slug' => 'docs-category',
21 'tag_slug' => 'docs-tag',
22 'live_search' => 1,
23 'search_result_image' => 1,
24 'masonry_layout' => 1,
25 'nested_subcategory' => '',
26 'column_number' => 3,
27 'posts_number' => 10,
28 'post_count' => 1,
29 'exploremore_btn' => 1,
30 'exploremore_btn_txt' => 'Explore More',
31 'doc_single' => 1,
32 'enable_toc' => 1,
33 'enable_sticky_toc' => 1,
34 'title_link_ctc' => 1,
35 'enable_breadcrumb' => 1,
36 'breadcrumb_doc_title' => 'Docs',
37 'enable_breadcrumb_category' => 1,
38 'enable_breadcrumb_title' => 1,
39 'enable_sidebar_cat_list' => 1,
40 'enable_print_icon' => 1,
41 'enable_tags' => 1,
42 'email_feedback' => 1,
43 'email_address' => get_option('admin_email'),
44 'enable_navigation' => 1,
45 'show_last_update_time' => 1,
46 'enable_comment' => 1,
47 'enable_credit' => 1,
48 'customizer_link' => '',
49 'category_grid' => '[betterdocs_category_grid]',
50 'category_box' => '[betterdocs_category_box]',
51 'search_form' => '[betterdocs_search_form]',
52 'feedback_form' => '[betterdocs_feedback_form]',
53 'supported_heading_tag' => array( 1,2,3,4,5,6 )
54 ));
55
56 return $option_default;
57 }
58 /**
59 * Get all settings value from options table.
60 *
61 * @param string $name
62 * @return array
63 */
64 public static function get_settings( $name = '' ){
65 $settings = get_option( 'betterdocs_settings', true );
66 $default = self::default_settings();
67 if( ! empty( $name ) && isset( $settings[ $name ] ) ) {
68 return $settings[ $name ];
69 }
70
71 if( ! empty( $name ) && ! isset( $settings[ $name ] ) && isset( $default[ $name ] ) ) {
72 return $default[ $name ];
73 }
74
75 if( ! empty( $name ) && ! isset( $settings[ $name ] ) && ! isset( $default[ $name ] ) ) {
76 return '';
77 }
78
79 return is_array( $settings ) ? $settings : [];
80 }
81 /**
82 * Update settings
83 * @param array $value
84 * @return boolean
85 */
86 public static function update_settings( $value, $key = '' ){
87 if( ! empty( $key ) ) {
88 return update_option( $key, $value );
89 }
90 return update_option( 'betterdocs_settings', $value );
91 }
92 }