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

117 lines 4.5 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 return apply_filters('betterdocs_option_default_settings', array(
16 'builtin_doc_page' => 1,
17 'docs_slug' => 'docs',
18 'doc_page' => '',
19 'category_slug' => 'docs-category',
20 'tag_slug' => 'docs-tag',
21 'live_search' => 1,
22 'advance_search' => '',
23 'popular_keyword_limit' => 5,
24 'search_placeholder' => esc_html__('Search..', 'betterdocs'),
25 'search_not_found_text' => esc_html__('Sorry, no docs were found.', 'betterdocs'),
26 'search_result_image' => 1,
27 'masonry_layout' => 1,
28 'alphabetically_order_post' => '',
29 'alphabetically_order_term' => '',
30 'nested_subcategory' => '',
31 'column_number' => 3,
32 'posts_number' => 10,
33 'post_count' => 1,
34 'count_text_singular' => esc_html__('article', 'betterdocs'),
35 'count_text' => esc_html__('articles', 'betterdocs'),
36 'exploremore_btn' => 1,
37 'exploremore_btn_txt' => esc_html__('Explore More', 'betterdocs'),
38 'doc_single' => 1,
39 'enable_toc' => 1,
40 'toc_title' => esc_html__('Table of Contents', 'betterdocs'),
41 'toc_hierarchy' => 1,
42 'toc_list_number' => 1,
43 'enable_sticky_toc' => 1,
44 'sticky_toc_offset' => 100,
45 'collapsible_toc_mobile' => '',
46 'enable_post_title' => 1,
47 'title_link_ctc' => 1,
48 'enable_breadcrumb' => 1,
49 'breadcrumb_doc_title' => esc_html__('Docs', 'betterdocs'),
50 'breadcrumb_home_text' => esc_html__('Home', 'betterdocs'),
51 'breadcrumb_home_url' => get_home_url(),
52 'enable_breadcrumb_category' => 1,
53 'enable_breadcrumb_title' => 1,
54 'enable_sidebar_cat_list' => 1,
55 'enable_print_icon' => 1,
56 'enable_tags' => 1,
57 'email_feedback' => 1,
58 'feedback_link_text' => esc_html__('Still stuck? How can we help?', 'betterdocs'),
59 'feedback_form_title' => esc_html__('How can we help?', 'betterdocs'),
60 'email_address' => get_option('admin_email'),
61 'enable_navigation' => 1,
62 'show_last_update_time' => 1,
63 'enable_comment' => 1,
64 'enable_credit' => 1,
65 'enable_archive_sidebar' => 1,
66 'archive_nested_subcategory' => 1,
67 'customizer_link' => '',
68 'category_grid' => '[betterdocs_category_grid]',
69 'category_box' => '[betterdocs_category_box]',
70 'search_form' => '[betterdocs_search_form]',
71 'feedback_form' => '[betterdocs_feedback_form]',
72 'supported_heading_tag' => array( 1,2,3,4,5,6 ),
73 'display_ia_pages' => array('all'),
74 'display_ia_archives' => array('all'),
75 'display_ia_texonomy' => array('all'),
76 'display_ia_single' => array('all'),
77 'enable_content_restriction' => '',
78 'restrict_template' => array('all'),
79 'restrict_category' => array('all'),
80 'restrict_kb' => array('all')
81 ));
82 }
83 /**
84 * Get all settings value from options table.
85 *
86 * @param string $name
87 * @return array
88 */
89 public static function get_settings( $name = '' ){
90 $settings = get_option( 'betterdocs_settings', true );
91 $default = self::default_settings();
92 if( ! empty( $name ) && isset( $settings[ $name ] ) ) {
93 return $settings[ $name ];
94 }
95
96 if( ! empty( $name ) && ! isset( $settings[ $name ] ) && isset( $default[ $name ] ) ) {
97 return $default[ $name ];
98 }
99
100 if( ! empty( $name ) && ! isset( $settings[ $name ] ) && ! isset( $default[ $name ] ) ) {
101 return '';
102 }
103
104 return is_array( $settings ) ? $settings : [];
105 }
106 /**
107 * Update settings
108 * @param array $value
109 * @return boolean
110 */
111 public static function update_settings( $value, $key = '' ){
112 if( ! empty( $key ) ) {
113 return update_option( $key, $value );
114 }
115 return update_option( 'betterdocs_settings', $value );
116 }
117 }