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

103 lines 3.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
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 'exploremore_btn' => 1,
33 'exploremore_btn_txt' => 'Explore More',
34 'doc_single' => 1,
35 'enable_toc' => 1,
36 'toc_hierarchy' => 1,
37 'enable_sticky_toc' => 1,
38 'sticky_toc_offset' => 100,
39 'collapsible_toc_mobile' => '',
40 'enable_post_title' => 1,
41 'title_link_ctc' => 1,
42 'enable_breadcrumb' => 1,
43 'breadcrumb_doc_title' => 'Docs',
44 'enable_breadcrumb_category' => 1,
45 'enable_breadcrumb_title' => 1,
46 'enable_sidebar_cat_list' => 1,
47 'enable_print_icon' => 1,
48 'enable_tags' => 1,
49 'email_feedback' => 1,
50 'email_address' => get_option('admin_email'),
51 'enable_navigation' => 1,
52 'show_last_update_time' => 1,
53 'enable_comment' => 1,
54 'enable_credit' => 1,
55 'customizer_link' => '',
56 'category_grid' => '[betterdocs_category_grid]',
57 'category_box' => '[betterdocs_category_box]',
58 'search_form' => '[betterdocs_search_form]',
59 'feedback_form' => '[betterdocs_feedback_form]',
60 'supported_heading_tag' => array( 1,2,3,4,5,6 ),
61 'display_ia_pages' => array('all'),
62 'display_ia_archives' => array('all'),
63 'display_ia_texonomy' => array('all'),
64 'display_ia_single' => array('all'),
65 ));
66
67 return $option_default;
68 }
69 /**
70 * Get all settings value from options table.
71 *
72 * @param string $name
73 * @return array
74 */
75 public static function get_settings( $name = '' ){
76 $settings = get_option( 'betterdocs_settings', true );
77 $default = self::default_settings();
78 if( ! empty( $name ) && isset( $settings[ $name ] ) ) {
79 return $settings[ $name ];
80 }
81
82 if( ! empty( $name ) && ! isset( $settings[ $name ] ) && isset( $default[ $name ] ) ) {
83 return $default[ $name ];
84 }
85
86 if( ! empty( $name ) && ! isset( $settings[ $name ] ) && ! isset( $default[ $name ] ) ) {
87 return '';
88 }
89
90 return is_array( $settings ) ? $settings : [];
91 }
92 /**
93 * Update settings
94 * @param array $value
95 * @return boolean
96 */
97 public static function update_settings( $value, $key = '' ){
98 if( ! empty( $key ) ) {
99 return update_option( $key, $value );
100 }
101 return update_option( 'betterdocs_settings', $value );
102 }
103 }