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

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