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

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