PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.8.9
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.8.9
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
← All changes | includes/Core/Settings.php +2411 -2114 3.4.23.8.9 View file →
@@ -1,2220 +1,2517 @@
1 1 <?php
2 2
3 3 namespace WPDeveloper\BetterDocs\Core;
4 4
5 +use WP_Error;
5 6 use WP_User;
6 -use WP_Error;
7 +use WPDeveloper\BetterDocs\Admin\Builder\GlobalFields;
8 +use WPDeveloper\BetterDocs\Admin\Builder\Rules;
7 9 use WPDeveloper\BetterDocs\Utils\Base;
8 10 use WPDeveloper\BetterDocs\Utils\Database;
9 -use WPDeveloper\BetterDocs\Admin\Builder\Rules;
10 -use WPDeveloper\BetterDocs\Admin\Builder\GlobalFields;
11 11
12 +
12 13 class Settings extends Base {
13 - public $base_key = 'betterdocs_settings';
14 + public $base_key = 'betterdocs_settings';
14 15
15 - /**
16 - * Database class
17 - * @var Database
18 - */
19 - protected $database;
16 + /**
17 + * Database class
18 + * @var Database
19 + */
20 + protected $database;
20 21
21 - private $deprecated = [];
22 + private $deprecated = [];
22 23
23 - private $cannot_be_empty = [
24 - 'breadcrumb_doc_title',
25 - 'docs_slug',
26 - 'category_slug',
27 - 'tag_slug',
28 - 'permalink_structure',
29 - 'docs_page'
30 - ];
24 + private $cannot_be_empty = [
25 + 'breadcrumb_doc_title',
26 + 'docs_slug',
27 + 'category_slug',
28 + 'tag_slug',
29 + 'permalink_structure',
30 + 'docs_page'
31 + ];
31 32
32 - public function __construct( Database $database ) {
33 - $this->database = $database;
34 - $this->deprecated = $this->deprecated_settings();
33 + public function __construct( Database $database ) {
34 + $this->database = $database;
35 + $this->deprecated = $this->deprecated_settings();
35 36
36 - add_filter( 'betterdocs_settings_tabs', [$this, 'import_export_settings'] );
37 + add_filter( 'betterdocs_settings_tabs', [ $this, 'import_export_settings' ] );
37 38
38 - add_action( 'admin_enqueue_scripts', [$this, 'enqueue'] );
39 + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_old' ], 99 );
40 + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ], 99 );
39 41
40 - if ( isset( $_GET['page'] ) && $_GET['page'] === 'betterdocs-settings' && ! has_action( 'betterdocs_settings_header' ) ) {
41 - add_action( 'betterdocs_settings_header', [$this, 'header'] );
42 - }
42 + // if ( isset( $_GET['page'] ) && $_GET['page'] === 'betterdocs-settings' && ! has_action( 'betterdocs_settings_header' ) ) {
43 + // add_action( 'betterdocs_settings_header', [ $this, 'header' ] );
44 + // }
43 45
44 - add_action( 'wp_ajax_betterdocs_dark_mode', [$this, 'dark_mode'] );
45 - add_filter( 'betterdocs_settings_tab_advance', [$this, 'hide_roles_management'], 11, 1 );
46 - add_action( 'betterdocs::settings::saved', [$this, 'fallback_slugs'], 99, 3 );
47 - }
46 + add_action( 'wp_ajax_betterdocs_dark_mode', [ $this, 'dark_mode' ] );
47 + add_filter( 'betterdocs_settings_tab_advance', [ $this, 'hide_roles_management' ], 11, 1 );
48 + add_action( 'betterdocs::settings::saved', [ $this, 'fallback_slugs' ], 99, 3 );
49 + }
48 50
49 - public function fallback_slugs( $_saved, $_settings, $_old_settings = [] ) {
50 - $_default = $this->get_default();
51 - foreach ( $this->cannot_be_empty as $key ) {
52 - if ( $key === 'docs_page' && ! $_settings['builtin_doc_page'] && empty( $_settings[$key] ) ) {
53 - $this->save( 'builtin_doc_page', true );
54 - continue;
55 - }
51 + public function fallback_slugs( $_saved, $_settings, $_old_settings = [] ) {
52 + $_default = $this->get_default();
53 + foreach ( $this->cannot_be_empty as $key ) {
54 + if ( $key === 'docs_page' && ! $_settings['builtin_doc_page'] && empty( $_settings[ $key ] ) ) {
55 + $this->save( 'builtin_doc_page', true );
56 + continue;
57 + }
56 58
57 - if ( empty( $_settings[$key] ) ) {
58 - $this->save( $key, $_default[$key] );
59 - }
60 - }
61 - }
59 + if ( empty( $_settings[ $key ] ) ) {
60 + $this->save( $key, $_default[ $key ] );
61 + }
62 + }
63 + }
62 64
63 - /**
64 - * Get the settings URL for admin
65 - * @return string
66 - */
67 - public function url() {
68 - return esc_url( admin_url( 'admin.php?page=betterdocs-settings' ) );
69 - }
65 + /**
66 + * Get the settings URL for admin
67 + * @return string
68 + */
69 + public function url() {
70 + return esc_url( admin_url( 'admin.php?page=betterdocs-settings' ) );
71 + }
70 72
71 - /**
72 - * This method is responsible for enqueueing scripts in settings panel
73 - *
74 - * @param string $hook
75 - *
76 - * @return void
77 - * @since 2.5.0
78 - */
79 - public function enqueue( $hook ) {
80 - if ( $hook !== 'betterdocs_page_betterdocs-settings' ) {
81 - return;
82 - }
73 + /**
74 + * This method is responsible for enqueueing scripts in settings panel
75 + *
76 + * @param string $hook
77 + *
78 + * @return void
79 + * @since 2.5.0
80 + */
81 + public function enqueue( $hook ) {
82 + if ( ! betterdocs()->is_betterdocs_screen( $hook ) ) {
83 + return;
84 + }
83 85
84 - wp_enqueue_script( 'betterdocs-admin' );
85 - betterdocs()->assets->enqueue( 'betterdocs-settings', 'admin/css/settings.css' );
86 - betterdocs()->assets->enqueue( 'betterdocs-icons', 'admin/btd-icon/style.css' );
87 - betterdocs()->assets->enqueue( 'betterdocs-settings', 'admin/js/settings.js' );
88 - betterdocs()->assets->localize( 'betterdocs-settings', 'betterdocsAdminSettings', GlobalFields::normalize( $this->settings_args() ) );
89 - }
86 + wp_enqueue_media();
87 + wp_enqueue_script( 'betterdocs-admin' );
88 + betterdocs()->assets->localize( 'betterdocs-admin', 'betterdocsAdminSettings', GlobalFields::normalize( $this->settings_args() ) );
89 + betterdocs()->assets->enqueue( 'betterdocs-icons', 'admin/btd-icon/style.css' );
90 90
91 - /**
92 - * This method is responsible for printing header in dashboard settings page.
93 - *
94 - * @param string $hook
95 - *
96 - * @return void
97 - * @since 2.5.0
98 - */
99 - public function header( $hook ) {
100 - if ( $hook !== 'settings' ) {
101 - return;
102 - }
91 + // betterdocs()->assets->enqueue( 'betterdocs-settings', 'admin/css/settings.css' );
92 + // betterdocs()->assets->enqueue( 'betterdocs-settings', 'admin/js/settings.js' );
93 + }
103 94
104 - betterdocs()->views->get( 'admin/template-parts/settings-header' );
105 - betterdocs()->views->get( 'admin/template-parts/settings-header-2' );
106 - }
95 + public function enqueue_old( $hook ) {
96 + // FREE & Pro Version Compatibility Check
97 + if ( ! betterdocs()->is_betterdocs_screen( $hook ) ) {
98 + return;
99 + }
107 100
108 - /**
109 - * A list of deprecated settings keys.
110 - *
111 - * @return array
112 - * @since 2.5.0
113 - */
114 - public function deprecated_settings() {
115 - return [];
116 - }
101 + $this->enqueue( 'betterdocs_page_betterdocs-settings' );
102 + }
117 103
118 - /**
119 - * Dynamic migration caller.
120 - *
121 - * @return void
122 - * @since 2.5.0
123 - */
124 - public function migration( $version ) {
125 - if ( $version > 250 ) {
126 - for ( $v = 250; $v <= $version; $v++ ) {
127 - $_func = "v{$v}";
128 - if ( method_exists( $this, $_func ) ) {
129 - call_user_func( [$this, $_func] );
130 - }
131 - }
132 - }
133 - }
104 + /**
105 + * This method is responsible for printing header in dashboard settings page.
106 + *
107 + * @param string $hook
108 + *
109 + * @return void
110 + * @since 2.5.0
111 + */
112 + public function header( $hook ) {
113 + if ( $hook !== 'settings' ) {
114 + return;
115 + }
134 116
135 - /**
136 - * Migration for version 2.5.0
137 - *
138 - * @return void
139 - * @since 2.5.0
140 - */
141 - public function v250() {
142 - if ( $this->get( 'alphabetically_order_term', false ) ) {
143 - $this->save( 'terms_orderby', 'name' );
144 - }
117 + betterdocs()->views->get( 'admin/template-parts/settings-header' );
118 + betterdocs()->views->get( 'admin/template-parts/settings-header-2' );
119 + }
145 120
146 - if ( $orderby = $this->get( 'alphabetically_order_post', false ) ) {
147 - if ( $orderby === '1' ) {
148 - $this->save( 'alphabetically_order_post', 'title' );
149 - }
150 - }
151 - }
121 + /**
122 + * A list of deprecated settings keys.
123 + *
124 + * @return array
125 + * @since 2.5.0
126 + */
127 + public function deprecated_settings() {
128 + return [];
129 + }
152 130
153 - /**
154 - * A list of default settings data.
155 - *
156 - * @return array
157 - * @since 1.0.0
158 - *
159 - */
160 - public function get_default() {
161 - $_default = [
162 - 'multiple_kb' => '',
163 - 'builtin_doc_page' => true,
164 - 'breadcrumb_doc_title' => __( 'Docs', 'betterdocs' ),
165 - 'docs_slug' => 'docs',
166 - 'docs_page' => 0,
167 - 'category_slug' => 'docs-category',
168 - 'tag_slug' => 'docs-tag',
169 - 'permalink_structure' => 'docs/',
170 - 'enable_faq_schema' => false,
171 - 'live_search' => true,
172 - 'advance_search' => false,
173 - 'popular_keyword_limit' => 5,
174 - 'search_letter_limit' => 3,
175 - 'search_placeholder' => __( 'Search...', 'betterdocs' ),
176 - 'search_not_found_text' => __( 'Sorry, no docs were found.', 'betterdocs' ),
177 - 'search_result_image' => true,
178 - 'masonry_layout' => true,
179 - 'category_title_link' => false,
180 - 'terms_orderby' => 'betterdocs_order',
181 - 'alphabetically_order_term' => false,
182 - 'terms_order' => 'ASC',
183 - 'alphabetically_order_post' => 'betterdocs_order',
184 - 'docs_order' => 'ASC',
185 - 'nested_subcategory' => false,
186 - 'column_number' => 3,
187 - 'posts_number' => 10,
188 - 'post_count' => true,
189 - 'count_text' => __( 'docs', 'betterdocs' ),
190 - 'count_text_singular' => __( 'doc', 'betterdocs' ),
191 - 'exploremore_btn' => true,
192 - 'exploremore_btn_txt' => __( 'Explore More', 'betterdocs' ),
193 - 'doc_single' => 1,
194 - 'enable_toc' => true,
195 - 'toc_title' => __( 'Table of Contents', 'betterdocs' ),
196 - 'toc_hierarchy' => true,
197 - 'toc_list_number' => true,
198 - 'toc_dynamic_title' => false,
199 - 'enable_sticky_toc' => true,
200 - 'sticky_toc_offset' => 100,
201 - 'collapsible_toc_mobile' => false,
202 - 'supported_heading_tag' => ['1', '2', '3', '4', '5', '6'],
203 - 'enable_post_title' => true,
204 - 'title_link_ctc' => true,
205 - 'enable_breadcrumb' => true,
206 - 'breadcrumb_home_text' => __( 'Home', 'betterdocs' ),
207 - 'breadcrumb_home_url' => get_home_url(),
208 - 'enable_breadcrumb_category' => true,
209 - 'enable_breadcrumb_title' => true,
210 - 'enable_sidebar_cat_list' => true,
211 - 'enable_print_icon' => true,
212 - 'enable_tags' => true,
213 - 'email_feedback' => true,
214 - 'feedback_link_text' => __( 'Still stuck? How can we help?', 'betterdocs' ),
215 - 'feedback_url' => '',
216 - 'feedback_form_title' => __( 'How can we help?', 'betterdocs' ),
217 - 'email_address' => get_option( 'admin_email' ),
218 - 'show_last_update_time' => true,
219 - 'enable_navigation' => true,
220 - 'enable_comment' => true,
221 - 'enable_credit' => true,
222 - 'enable_archive_sidebar' => true,
223 - 'archive_nested_subcategory' => true,
224 - 'enable_content_restriction' => false,
225 - 'enable_reporting' => false,
226 - 'enable_sample_data' => false,
227 - 'reporting_day' => 'monday',
228 - 'reporting_email' => get_option( 'admin_email' ),
229 - 'enable_write_with_ai' => true,
230 - 'enable_faq_write_with_ai' => true,
231 - 'ai_autowrite_api_key' => '',
232 - 'ai_autowrite_max_token' => 1500
233 - ];
131 + /**
132 + * Dynamic migration caller.
133 + *
134 + * @return void
135 + * @since 2.5.0
136 + */
137 + public function migration( $version ) {
138 + if ( $version > 250 ) {
139 + for ( $v = 250; $v <= $version; $v ++ ) {
140 + $_func = "v{$v}";
141 + if ( method_exists( $this, $_func ) ) {
142 + call_user_func( [ $this, $_func ] );
143 + }
144 + }
145 + }
146 + }
234 147
235 - $_default = apply_filters( 'betterdocs_default_settings', $_default );
236 - // $_default = apply_filters_deprecated(
237 - // 'betterdocs_option_default_settings', [$_default], '2.5.0',
238 - // 'betterdocs_default_settings', 'betterdocs_option_default_settings will be removed from v3.5.0.'
239 - // );
148 + /**
149 + * Migration for version 2.5.0
150 + *
151 + * @return void
152 + * @since 2.5.0
153 + */
154 + public function v250() {
155 + if ( $this->get( 'alphabetically_order_term', false ) ) {
156 + $this->save( 'terms_orderby', 'name' );
157 + }
240 158
241 - return $_default;
242 - }
159 + if ( $orderby = $this->get( 'alphabetically_order_post', false ) ) {
160 + if ( $orderby === '1' ) {
161 + $this->save( 'alphabetically_order_post', 'title' );
162 + }
163 + }
164 + }
243 165
244 - /**
245 - * A list of default settings for pro plugins.
246 - *
247 - * @return array
248 - * @since 2.5.0
249 - */
250 - public function get_pro_defaults() {
251 - return [];
252 - }
166 + /**
167 + * A list of default settings data.
168 + *
169 + * @return array
170 + * @since 1.0.0
171 + *
172 + */
173 + public function get_default() {
174 + $_default = [
175 + 'multiple_kb' => '',
176 + 'enable_export_faq' => true,
177 + 'builtin_doc_page' => true,
178 + 'breadcrumb_doc_title' => __( 'Docs', 'betterdocs' ),
179 + 'docs_slug' => 'docs',
180 + 'docs_page' => 0,
181 + 'category_slug' => 'docs-category',
182 + 'tag_slug' => 'docs-tag',
183 + 'permalink_structure' => 'docs/',
184 + 'enable_faq_schema' => false,
185 + 'live_search' => true,
186 + 'advance_search' => false,
187 + 'popular_keyword_limit' => 5,
188 + 'search_letter_limit' => 3,
189 + 'search_placeholder' => __( 'Search...', 'betterdocs' ),
190 + 'search_not_found_text' => __( 'Sorry, no docs were found.', 'betterdocs' ),
191 + 'search_result_image' => true,
192 + 'masonry_layout' => true,
193 + 'docs_list_icon' => [],
194 + 'category_title_link' => false,
195 + 'terms_orderby' => 'betterdocs_order',
196 + 'alphabetically_order_term' => false,
197 + 'terms_order' => 'ASC',
198 + 'alphabetically_order_post' => 'betterdocs_order',
199 + 'docs_order' => 'ASC',
200 + 'nested_subcategory' => false,
201 + 'column_number' => 3,
202 + 'posts_number' => 10,
203 + 'post_count' => true,
204 + 'count_text' => __( 'Docs', 'betterdocs' ),
205 + 'count_text_singular' => __( 'Doc', 'betterdocs' ),
206 + 'exploremore_btn' => true,
207 + 'exploremore_btn_txt' => __( 'Explore More', 'betterdocs' ),
208 + 'doc_single' => 1,
209 + 'enable_toc' => true,
210 + 'toc_title' => __( 'Table of Contents', 'betterdocs' ),
211 + 'toc_hierarchy' => true,
212 + 'toc_list_number' => false,
213 + 'toc_dynamic_title' => false,
214 + 'enable_sticky_toc' => true,
215 + 'sticky_toc_offset' => 100,
216 + 'collapsible_toc_mobile' => false,
217 + 'supported_heading_tag' => [ '1', '2', '3', '4', '5', '6' ],
218 + 'enable_post_title' => true,
219 + 'title_link_ctc' => true,
220 + 'enable_breadcrumb' => true,
221 + 'breadcrumb_home_text' => __( 'Home', 'betterdocs' ),
222 + 'enable_breadcrumb_home_text' => true,
223 + 'breadcrumb_home_url' => get_home_url(),
224 + 'enable_breadcrumb_category' => true,
225 + 'enable_breadcrumb_title' => true,
226 + 'enable_sidebar_cat_list' => true,
227 + 'enable_print_icon' => true,
228 + 'enable_tags' => true,
229 + 'email_feedback' => true,
230 + 'feedback_link_text' => __( 'Still stuck? How can we help?', 'betterdocs' ),
231 + 'reaction_feedback_text' => __( 'Thanks for your feedback', 'betterdocs' ),
232 + 'feedback_url' => '',
233 + 'feedback_form_title' => __( 'How can we help?', 'betterdocs' ),
234 + 'email_address' => get_option( 'admin_email' ),
235 + 'show_last_update_time' => true,
236 + 'enable_navigation' => true,
237 + 'enable_comment' => true,
238 + 'enable_credit' => false,
239 + 'enable_archive_sidebar' => true,
240 + 'archive_nested_subcategory' => true,
241 + 'archive_enable_pagination' => false,
242 + 'enable_content_restriction' => false,
243 + 'enable_reporting' => false,
244 + 'enable_sample_data' => false,
245 + 'reporting_day' => 'monday',
246 + 'reporting_email' => get_option( 'admin_email' ),
247 + 'enable_write_with_ai' => true,
248 + 'enable_faq_write_with_ai' => true,
249 + 'ai_autowrite_api_key' => '',
250 + 'ai_autowrite_max_token' => 1500,
251 + 'enable_estimated_reading_time' => true,
252 + 'enable_encyclopedia' => false,
253 + 'enable_glossaries' => false,
254 + 'show_glossary_suggestions' => true,
255 + 'enable_ai_chatbot' => false,
256 + 'estimated_reading_time_title' => '',
257 + 'estimated_reading_time_text' => __( 'min read', 'betterdocs' ),
258 + 'singular_estimated_reading_time_text' => __( 'min read', 'betterdocs' )
259 + ];
253 260
254 - /**
255 - * Get customizer links for docs page.
256 - *
257 - * @return string
258 - * @since 1.0.0
259 - */
260 - public function customizer_link() {
261 - $query['autofocus[panel]'] = 'betterdocs_customize_options';
262 - $query['return'] = admin_url( 'edit.php?post_type=docs' );
263 - $builtin_doc_page = betterdocs()->settings->get( 'builtin_doc_page' );
264 - $docs_slug = betterdocs()->settings->get( 'docs_slug' );
265 - $docs_page = betterdocs()->settings->get( 'builtin_doc_page' );
261 + $_default = apply_filters( 'betterdocs_default_settings', $_default );
262 + // $_default = apply_filters_deprecated(
263 + // 'betterdocs_option_default_settings', [$_default], '2.5.0',
264 + // 'betterdocs_default_settings', 'betterdocs_option_default_settings will be removed from v3.5.0.'
265 + // );
266 266
267 - if ( $builtin_doc_page == 1 && $docs_slug ) {
268 - $query['url'] = site_url( '/' . $docs_slug );
269 - } elseif ( $builtin_doc_page != 1 && $docs_page ) {
270 - $post_info = get_post( $docs_page );
271 - $query['url'] = site_url( '/' . $post_info->post_name );
272 - }
267 + return $_default;
268 + }
273 269
274 - return add_query_arg( $query, admin_url( 'customize.php' ) );
275 - }
270 + /**
271 + * A list of default settings for pro plugins.
272 + *
273 + * @return array
274 + * @since 2.5.0
275 + */
276 + public function get_pro_defaults() {
277 + return [];
278 + }
276 279
277 - /**
278 - * Get All Roles
279 - * dynamically
280 - *
281 - * @return array
282 - */
283 - public function get_roles() {
284 - $roles = wp_roles()->role_names;
285 - unset( $roles['subscriber'] );
280 + public function is_elementor_pro() {
281 + return is_plugin_active( 'elementor-pro/elementor-pro.php' );
282 + }
286 283
287 - return $roles;
288 - }
284 + /**
285 + * Get full site editor links for docs page.
286 + *
287 + * @return string
288 + * @since 3.5.8
289 + */
290 + public function gutenberg_link() {
291 + if ( betterdocs()->helper->current_theme_is_fse_theme() ) {
292 + return admin_url( 'site-editor.php?postType=wp_template&postId=betterdocs/betterdocs//archive-docs' );
293 + } else {
294 + return 'https://betterdocs.co/docs/betterdocs-provides-full-site-editor-support/';
295 + }
296 + }
289 297
290 - /**
291 - * Set dark mode
292 - *
293 - * @return void
294 - * @since 1.0.0
295 - */
296 - public function dark_mode() {
297 - if ( ! check_ajax_referer( 'doc_cat_order_nonce', 'nonce', false ) ) {
298 - wp_send_json_error();
299 - }
298 + /**
299 + * Get elementor theme builder link for docs page.
300 + *
301 + * @return string
302 + * @since 3.5.8
303 + */
304 + public function elementor_link() {
305 + if ( $this->is_elementor_pro() ) {
306 + return admin_url( 'admin.php?page=elementor-app#/site-editor/templates/doc-archive' );
307 + } else {
308 + return 'https://betterdocs.co/docs/docs-page-with-elementor/';
309 + }
310 + }
300 311
301 - if ( isset( $_POST['mode'] ) ) {
302 - if ( $this->save( 'dark_mode', rest_sanitize_boolean( $_POST['mode'] ) ) ) {
303 - wp_send_json_success();
304 - }
305 - }
312 + public function customizer_link() {
313 + $query['autofocus[panel]'] = 'betterdocs_customize_options';
314 + $query['return'] = admin_url( 'edit.php?post_type=docs' );
315 + $builtin_doc_page = betterdocs()->settings->get( 'builtin_doc_page' );
316 + $docs_slug = betterdocs()->settings->get( 'docs_slug' );
317 + $docs_page = betterdocs()->settings->get( 'builtin_doc_page' );
306 318
307 - wp_send_json_error();
308 - }
319 + if ( $builtin_doc_page == 1 && $docs_slug ) {
320 + $query['url'] = site_url( '/' . $docs_slug );
321 + } elseif ( $builtin_doc_page != 1 && $docs_page ) {
322 + $post_info = get_post( $docs_page );
323 + $query['url'] = site_url( '/' . $post_info->post_name );
324 + }
309 325
310 - public function get_normalized_value( $key, $value, $default = null ) {
311 - $_origin_value = $_value = $value;
326 + return add_query_arg( $query, admin_url( 'customize.php' ) );
327 + }
312 328
313 - if ( in_array( $_value, ['on', 'off', '1', 'false', 'true'], true ) ) {
314 - switch ( $_value ) {
315 - case 'on':
316 - case 'ON':
317 - case '1':
318 - case 'true':
319 - $_value = true;
320 - break;
321 - case 'off':
322 - case 'OFF':
323 - case '':
324 - case 'false':
325 - $_value = false;
326 - break;
327 - }
328 - }
329 + public function design_tab() {
330 + $settings = [];
329 331
330 - $this->type_validation( $_value, $default );
332 + $settings['gutenberg_link'] = [
333 + 'name' => 'gutenberg_link',
334 + 'type' => 'action',
335 + 'action' => 'betterdocs_settings_gutenberg_link',
336 + 'button' => betterdocs()->helper->current_theme_is_fse_theme() ? __( 'Design with Gutenberg', 'betterdocs' ) : __( 'Learn More', 'betterdocs' ),
337 + 'url' => $this->gutenberg_link(),
338 + 'customizer_img' => betterdocs()->assets->icon( 'customizer/gutenberg-preview.png', true ),
339 + 'priority' => 1
340 + ];
331 341
332 - return $_value;
333 - }
342 + $settings['elementor_link'] = [
343 + 'name' => 'elementor_link',
344 + 'type' => 'action',
345 + 'action' => 'betterdocs_settings_elementor_link',
346 + 'button' => $this->is_elementor_pro() ? __( 'Design with Elementor', 'betterdocs' ) : __( 'Learn More', 'betterdocs' ),
347 + 'url' => $this->elementor_link(),
348 + 'customizer_img' => betterdocs()->assets->icon( 'customizer/elementor-preview.png', true ),
349 + 'priority' => 2
350 + ];
334 351
335 - public function get_normalized_values( $values, $default_values = [] ) {
336 - if ( empty( $values ) ) {
337 - return [];
338 - }
352 + if ( ! betterdocs()->helper->current_theme_is_fse_theme() ) {
353 + $settings['customizer_link'] = [
354 + 'name' => 'customizer_link',
355 + 'type' => 'action',
356 + 'action' => 'betterdocs_settings_customizer_link',
357 + 'button' => __( 'Customize in BetterDocs', 'betterdocs' ),
358 + 'url' => $this->customizer_link(),
359 + 'customizer_img' => betterdocs()->assets->icon( 'customizer/customizer-preview.png', true ),
360 + 'priority' => 3
361 + ];
362 + }
339 363
340 - $_settings = [];
341 - foreach ( $values as $key => $value ) {
342 - $_default_value = isset( $default_values[$key] ) ? $default_values[$key] : null;
343 - $_settings[$key] = $this->get_normalized_value( $key, $value, $_default_value );
344 - }
364 + return $settings;
365 + }
345 366
346 - return $_settings;
347 - }
367 + /**
368 + * Get All Roles
369 + * dynamically
370 + *
371 + * @return array
372 + */
373 + public function get_roles() {
374 + $roles = wp_roles()->role_names;
375 + unset( $roles['subscriber'] );
348 376
349 - public function get_all( $raw = false ) {
350 - $_default_settings = $raw ? [] : array_merge( $this->get_default(), $this->get_pro_defaults() );
351 - $_settings = $this->database->get( $this->base_key, $_default_settings );
377 + return $roles;
378 + }
352 379
353 - return $this->get_normalized_values( $_settings, $_default_settings );
354 - }
380 + /**
381 + * Set dark mode
382 + *
383 + * @return void
384 + * @since 1.0.0
385 + */
386 + public function dark_mode() {
387 + if ( ! check_ajax_referer( 'doc_cat_order_nonce', 'nonce', false ) ) {
388 + wp_send_json_error();
389 + }
355 390
356 - public function type_validation( &$value, $defaultValue = null ) {
357 - if ( $defaultValue !== null ) {
358 - /**
359 - * Check if value is not in same type
360 - */
361 - $_default_type = gettype( $defaultValue );
391 + if ( isset( $_POST['mode'] ) ) {
392 + if ( $this->save( 'dark_mode', rest_sanitize_boolean( $_POST['mode'] ) ) ) { // phpcs:ignore
393 + wp_send_json_success();
394 + }
395 + }
362 396
363 - if ( ! ( is_scalar( $defaultValue ) && is_scalar( $value ) ) && empty( $value ) ) {
364 - $value = $defaultValue;
365 - }
397 + wp_send_json_error();
398 + }
366 399
367 - settype( $value, $_default_type );
368 - }
369 - }
400 + public function get_normalized_value( $key, $value, $default = null ) {
401 + $_origin_value = $_value = $value;
370 402
371 - /**
372 - * Get settings value by key
373 - *
374 - * @param string $key
375 - * @param mixed $default
376 - * @param bool $get_all
377 - *
378 - * @return mixed
379 - * @since 2.5.0
380 - *
381 - */
382 - public function get( $key, $default = null ) {
383 - $_default_settings = array_merge( $this->get_default(), $this->get_pro_defaults() );
384 - $_settings = $this->database->get( $this->base_key, $_default_settings );
403 + if ( in_array( $_value, [ 'on', 'off', '1', 'false', 'true' ], true ) ) {
404 + switch ( $_value ) {
405 + case 'on':
406 + case 'ON':
407 + case '1':
408 + case 'true':
409 + $_value = true;
410 + break;
411 + case 'off':
412 + case 'OFF':
413 + case '':
414 + case 'false':
415 + $_value = false;
416 + break;
417 + }
418 + }
385 419
386 - $_value = $default;
387 - switch ( true ) {
388 - // Check if it's a PRO Option
389 - case ! isset( $_default_settings[$key] ):
390 - $_value = $default;
391 - break;
392 - // Check if it's a FREE Option and not in DB.
393 - case ! isset( $_settings[$key] ) && isset( $_default_settings[$key] ):
394 - $_value = $default !== null ? $default : $_default_settings[$key];
395 - break;
396 - // Check if it's a FREE Option
397 - case isset( $_settings[$key] ) && isset( $_default_settings[$key] ):
398 - $_value = $_settings[$key];
399 - break;
400 - }
420 + $this->type_validation( $_value, $default );
401 421
402 - $_value = $this->get_normalized_value( $key, $_value, isset( $_default_settings[$key] ) ? $_default_settings[$key] : null );
422 + return $_value;
423 + }
403 424
404 - if ( gettype( $_value ) === 'string' ) {
405 - if ( empty( $_value ) && $default != null ) {
406 - $_value = $default;
407 - } elseif ( empty( $_value ) && $default === null && isset( $_default_settings[$key] ) ) {
408 - $_value = $_default_settings[$key];
409 - }
410 - }
425 + public function get_normalized_values( $values, $default_values = [] ) {
426 + if ( empty( $values ) ) {
427 + return [];
428 + }
411 429
412 - return $_value;
413 - }
430 + $_settings = [];
431 + foreach ( $values as $key => $value ) {
432 + $_default_value = isset( $default_values[ $key ] ) ? $default_values[ $key ] : null;
433 + $_settings[ $key ] = $this->get_normalized_value( $key, $value, $_default_value );
434 + }
414 435
415 - public function get_raw_field( $key, $default = null ) {
416 - $_settings = $this->database->get( $this->base_key, [] );
436 + return $_settings;
437 + }
417 438
418 - if ( isset( $_settings[$key] ) ) {
419 - return $this->get_normalized_value( $key, $_settings[$key], $default );
420 - }
439 + public function get_all( $raw = false ) {
440 + $_default_settings = $raw ? [] : array_merge( $this->get_default(), $this->get_pro_defaults() );
441 + $_settings = $this->database->get( $this->base_key, $_default_settings );
421 442
422 - return $default;
423 - }
443 + return $this->get_normalized_values( $_settings, $_default_settings );
444 + }
424 445
425 - public function save( $key, $value ) {
426 - $_settings = $this->database->get( $this->base_key, [] );
427 - $_settings[$key] = $value;
446 + public function type_validation( &$value, $defaultValue = null ) {
447 + if ( $defaultValue !== null ) {
448 + /**
449 + * Check if value is not in same type
450 + */
451 + $_default_type = gettype( $defaultValue );
428 452
429 - return $this->database->save( $this->base_key, $_settings );
430 - }
453 + if ( ! ( is_scalar( $defaultValue ) && is_scalar( $value ) ) && empty( $value ) ) {
454 + $value = $defaultValue;
455 + }
431 456
432 - public function save_settings( $settings ) {
433 - $existing_plugins = betterdocs()->kbmigration->knowledge_base_plugins();
434 - if ( ! current_user_can( 'edit_docs_settings' ) ) {
435 - return new WP_Error( 'unauthorized_action', __( 'You don\'t have any rights for saving settings.', 'betterdocs' ) );
436 - }
457 + settype( $value, $_default_type );
458 + }
459 + }
437 460
438 - $_old_settings = $this->database->get( $this->base_key, $this->get_default() );
439 - // @todo: sanitize the data before inject in DB.
440 - $_normalized_settings = $this->get_normalized_values( $settings );
441 - if ( $existing_plugins && isset( $_normalized_settings['migration_step'] ) && $_normalized_settings['migration_step'] == true ) {
442 - betterdocs()->kbmigration->migrate();
443 - }
444 - $_settings = wp_parse_args( $_normalized_settings, $_old_settings );
445 - $_saved = $this->database->save( $this->base_key, $_settings );
461 + /**
462 + * Get settings value by key
463 + *
464 + * @param string $key
465 + * @param mixed $default
466 + * @param bool $get_all
467 + *
468 + * @return mixed
469 + * @since 2.5.0
470 + *
471 + */
472 + public function get( $key, $default = null ) {
473 + $_default_settings = array_merge( $this->get_default(), $this->get_pro_defaults() );
474 + $_settings = $this->database->get( $this->base_key, $_default_settings );
446 475
447 - do_action_ref_array( 'betterdocs::settings::saved', [$_saved, $_settings, $_old_settings, &$this] );
476 + $_value = $default;
477 + switch ( true ) {
478 + // Check if it's a PRO Option
479 + case ! isset( $_default_settings[ $key ] ):
480 + $_value = $default;
481 + break;
482 + // Check if it's a FREE Option and not in DB.
483 + case ! isset( $_settings[ $key ] ) && isset( $_default_settings[ $key ] ):
484 + $_value = $default !== null ? $default : $_default_settings[ $key ];
485 + break;
486 + // Check if it's a FREE Option
487 + case isset( $_settings[ $key ] ) && isset( $_default_settings[ $key ] ):
488 + $_value = $_settings[ $key ];
489 + break;
490 + }
448 491
449 - return $_saved;
450 - }
492 + $_value = $this->get_normalized_value( $key, $_value, isset( $_default_settings[ $key ] ) ? $_default_settings[ $key ] : null );
451 493
452 - public function views( $hook ) {
453 - return betterdocs()->views->get( 'admin/settings' );
454 - }
494 + if ( gettype( $_value ) === 'string' ) {
495 + if ( empty( $_value ) && $default != null ) {
496 + $_value = $default;
497 + } elseif ( empty( $_value ) && $default === null && isset( $_default_settings[ $key ] ) ) {
498 + $_value = $_default_settings[ $key ];
499 + }
500 + }
455 501
456 - public function save_default_settings() {
457 - $_settings = $this->get_all();
502 + return $_value;
503 + }
458 504
459 - return $this->database->save( $this->base_key, $_settings );
460 - }
505 + public function get_raw_field( $key, $default = null ) {
506 + $_settings = $this->database->get( $this->base_key, [] );
461 507
462 - public function get_pages() {
463 - $_pages = betterdocs()->query->get_posts( [
464 - 'post_type' => 'page',
465 - 'numberposts' => -1,
466 - 'post_status' => 'publish',
467 - 'posts_per_page' => -1
468 - ] );
508 + if ( isset( $_settings[ $key ] ) ) {
509 + return $this->get_normalized_value( $key, $_settings[ $key ], $default );
510 + }
469 511
470 - $__pages = [];
512 + return $default;
513 + }
471 514
472 - if ( ! empty( $_pages ) ) {
473 - $__pages[0] = __( 'Select a Page', 'betterdocs' );
474 - foreach ( $_pages->posts as $page ) {
475 - $__pages[$page->ID] = esc_html( $page->post_title );
476 - }
477 - }
515 + public function save( $key, $value ) {
516 + $_settings = $this->database->get( $this->base_key, [] );
517 + $_settings[ $key ] = $value;
478 518
479 - return $__pages;
480 - }
519 + return $this->database->save( $this->base_key, $_settings );
520 + }
481 521
482 - public function settings_args() {
483 - $wp_roles = $this->normalize_options( $this->get_roles() );
522 + public function save_settings( $settings ) {
523 + $existing_plugins = betterdocs()->kbmigration->knowledge_base_plugins();
524 + if ( ! current_user_can( 'edit_docs_settings' ) ) {
525 + return new WP_Error( 'unauthorized_action', __( 'You don\'t have any rights for saving settings.', 'betterdocs' ) );
526 + }
484 527
485 - $settings = [
486 - 'id' => 'betterdocs_settings_metabox_wrapper',
487 - 'title' => __( 'betterdocs', 'betterdocs' ),
488 - 'object_types' => ['betterdocs'],
489 - 'context' => 'normal',
490 - 'priority' => 'high',
491 - 'show_header' => false,
492 - 'tabnumber' => false,
493 - 'is_pro_active' => betterdocs()->is_pro_active(),
494 - 'logoURL' => betterdocs()->assets->icon( 'betterdocs-icon.svg', true ),
495 - 'layout' => 'vertical',
496 - 'config' => [
497 - 'active' => 'tab-general',
498 - 'sidebar' => true,
499 - 'title' => false
500 - ],
501 - 'submit' => [
502 - 'show' => true,
503 - 'label' => __( 'Save', 'betterdocs' ),
504 - 'loadingLabel' => __( 'Saving...', 'betterdocs' ),
505 - 'class' => 'save-settings',
506 - 'rules' => Rules::logicalRule( [
507 - Rules::is( 'config.active', 'tab-design', true ),
508 - Rules::is( 'config.active', 'tab-shortcodes', true ),
509 - Rules::is( 'config.active', 'tab-instant-answer', true ),
510 - Rules::is( 'config.active', 'tab-import-export', true ),
511 - Rules::is( 'config.active', 'tab-migration', true )
512 - ], 'and' )
513 - ],
514 - 'values' => $this->get_all(),
515 - 'tabs' => apply_filters( 'betterdocs_settings_tabs', [
516 - 'tab-general' => apply_filters( 'betterdocs_settings_tab_general', [
517 - 'id' => 'tab-general',
518 - 'label' => __( 'General', 'betterdocs' ),
519 - 'classes' => 'tab-general',
520 - 'priority' => 10,
521 - 'fields' => [
522 - 'title-general' => [
523 - 'name' => 'title-general-tab',
524 - 'type' => 'section',
525 - 'label' => __( 'General Settings', 'betterdocs' ),
526 - 'priority' => 10,
527 - 'fields' => [
528 - 'multiple_kb' => apply_filters( 'betterdocs_multi_kb_settings', [
529 - 'name' => 'multiple_kb',
530 - 'type' => 'toggle',
531 - 'label' => __( 'Multiple Knowledge Base', 'betterdocs' ),
532 - 'enable_disable_text_active' => true,
533 - 'default' => '',
534 - 'priority' => 1,
535 - 'is_pro' => true
536 - ] ),
537 - 'builtin_doc_page' => [
538 - 'name' => 'builtin_doc_page',
539 - 'type' => 'toggle',
540 - 'label' => __( 'Built-in Documentation Page', 'betterdocs' ),
541 - 'enable_disable_text_active' => true,
542 - 'default' => 1,
543 - 'priority' => 2,
544 - 'label_subtitle' => __( 'If you disable root slug for KB Archives, your individual knowledge base URL will be like this: https://example.com/knowledgebase-1', 'betterdocs' )
545 - ],
546 - 'breadcrumb_doc_title' => [
547 - 'name' => 'breadcrumb_doc_title',
548 - 'type' => 'text',
549 - 'label' => __( 'Documentation Page Title', 'betterdocs' ),
550 - 'default' => 'Docs',
551 - 'priority' => 3
552 - ],
553 - 'docs_slug' => [
554 - 'name' => 'docs_slug',
555 - 'type' => 'text',
556 - 'label' => __( 'BetterDocs Root Slug', 'betterdocs' ),
557 - 'default' => 'docs',
558 - 'priority' => 4,
559 - 'rules' => Rules::is( 'builtin_doc_page', true )
560 - ],
561 - 'docs_page' => [
562 - 'name' => 'docs_page',
563 - 'label' => __( 'Docs Page', 'betterdocs' ),
564 - 'type' => 'select',
565 - 'default' => 0,
566 - 'priority' => 5,
567 - 'search' => true,
568 - 'options' => $this->normalize_options( $this->get_pages() ),
569 - 'label_subtitle' => __( 'You will need to insert BetterDocs Shortcode inside the page. This page will be used as docs permalink.', 'betterdocs' ),
570 - 'rules' => Rules::is( 'builtin_doc_page', false )
571 - ],
572 - 'category_slug' => [
573 - 'name' => 'category_slug',
574 - 'type' => 'text',
575 - 'label' => __( 'Custom Category Slug', 'betterdocs' ),
576 - 'default' => 'docs-category',
577 - 'priority' => 6
578 - ],
579 - 'tag_slug' => [
580 - 'name' => 'tag_slug',
581 - 'type' => 'text',
582 - 'label' => __( 'Custom Tag Slug', 'betterdocs' ),
583 - 'default' => 'docs-tag',
584 - 'priority' => 7
585 - ],
586 - 'permalink_structure' => [
587 - 'name' => 'permalink_structure',
588 - 'type' => 'permalink_structure',
589 - 'label' => __( 'Single Docs Permalink', 'betterdocs' ),
590 - 'default' => PostType::permalink_structure(),
591 - 'priority' => 9,
592 - 'tags' => $this->normalize_options( [
593 - '%doc_category%' => '%doc_category%',
594 - '%knowledge_base%' => '%knowledge_base%'
595 - ] ),
596 - 'label_subtitle' => __( 'Make sure to keep Docs Root Slug in the Single Docs Permalink. You are not able to keep it blank. You can use the available tags from below.', 'betterdocs' )
597 - ],
598 - 'enable_faq_schema' => [
599 - 'name' => 'enable_faq_schema',
600 - 'type' => 'toggle',
601 - 'label' => __( 'FAQ Schema', 'betterdocs' ),
602 - 'enable_disable_text_active' => true,
603 - 'default' => '',
604 - 'priority' => 10
605 - ],
606 - 'analytics_from' => [
607 - 'name' => 'analytics_from',
608 - 'type' => 'select',
609 - 'label' => __( 'Analytics From', 'betterdocs' ),
610 - 'options' => $this->normalize_options( [
611 - 'everyone' => __( 'Everyone', 'betterdocs' ),
612 - 'guests' => __( 'Guests Only', 'betterdocs' ),
613 - 'registered_users' => __( 'Registered Users Only', 'betterdocs' )
614 - ] ),
615 - 'default' => 'everyone',
616 - 'priority' => 11,
617 - 'is_pro' => true
618 - ],
619 - 'exclude_bot_analytics' => [
620 - 'name' => 'exclude_bot_analytics',
621 - 'type' => 'toggle',
622 - 'label' => __( 'Exclude Bot Analytics', 'betterdocs' ),
623 - 'enable_disable_text_active' => true,
624 - 'default' => true,
625 - 'priority' => 12,
626 - 'is_pro' => true
627 - ]
628 - ]
629 - ]
630 - ]
631 - ] ),
632 - 'tab-layout' => apply_filters( 'betterdocs_settings_tab_layout', [
633 - 'id' => 'tab-layout',
634 - 'label' => __( 'Layout', 'betterdocs' ),
635 - 'classes' => 'tab-layout',
636 - 'priority' => 20,
637 - 'fields' => [
638 - 'title-layout' => [
639 - 'name' => 'title-layout-tab',
640 - 'type' => 'section',
641 - 'label' => __( 'Layout Settings', 'betterdocs' ),
642 - 'priority' => 20,
643 - 'fields' => [
644 - 'tab-sidebar-layout' => apply_filters( 'betterdocs_settings_tab_sidebar_layout', [
645 - 'id' => 'tab-sidebar-layout',
646 - 'name' => 'tab_sidebar_layout',
647 - 'label' => __( 'Layout Settings', 'betterdocs' ),
648 - 'classes' => 'tab-layout',
649 - 'type' => "tab",
650 - 'active' => "layout_documentation_page",
651 - 'completionTrack' => true,
652 - 'sidebar' => false,
653 - 'save' => false,
654 - 'title' => false,
655 - 'config' => [
656 - 'active' => 'layout_documentation_page',
657 - 'sidebar' => false,
658 - 'title' => false
659 - ],
660 - 'submit' => [
661 - 'show' => false
662 - ],
663 - 'step' => [
664 - 'show' => false
665 - ],
666 - 'priority' => 20,
667 - 'fields' => [
668 - 'layout_documentation_page' => [
669 - 'id' => 'layout_documentation_page',
670 - 'name' => 'layout_documentation_page',
671 - 'type' => 'section',
672 - 'label' => __( 'Documentation Page', 'betterdocs' ),
673 - 'priority' => 1,
674 - 'fields' => [
675 - 'tab-nested-layout-1' => [
676 - 'id' => 'tab-nested-layout-1',
677 - 'name' => 'tab_nested_layout_1',
678 - 'label' => __( 'Documentation Page', 'betterdocs' ),
679 - 'classes' => 'tab-nested-layout',
680 - 'type' => "tab",
681 - 'active' => "layout_documentation_page_general",
682 - 'completionTrack' => true,
683 - 'sidebar' => false,
684 - 'save' => false,
685 - 'title' => false,
686 - 'config' => [
687 - 'active' => 'layout_documentation_page_general',
688 - 'sidebar' => false,
689 - 'title' => false
690 - ],
691 - 'submit' => [
692 - 'show' => false
693 - ],
694 - 'step' => [
695 - 'show' => false
696 - ],
697 - 'priority' => 1,
698 - 'fields' => [
699 - 'layout_documentation_page_general' => [
700 - 'id' => 'layout_documentation_page_general',
701 - 'name' => 'layout_documentation_page_general',
702 - 'type' => 'section',
703 - 'label' => __( 'General', 'betterdocs' ),
704 - 'priority' => 1,
705 - 'fields' => [
706 - 'category_title_link' => [
707 - 'name' => 'category_title_link',
708 - 'type' => 'toggle',
709 - 'label' => __( 'Category Title Link', 'betterdocs' ),
710 - 'label_subtitle' => __( 'This setting is applicable for category grid layout', 'betterdocs' ),
711 - 'enable_disable_text_active' => true,
712 - 'default' => false,
713 - 'priority' => 0
714 - ],
715 - 'masonry_layout' => [
716 - 'name' => 'masonry_layout',
717 - 'type' => 'toggle',
718 - 'label' => __( 'Masonry', 'betterdocs' ),
719 - 'enable_disable_text_active' => true,
720 - 'default' => 1,
721 - 'priority' => 1
722 - ],
723 - 'nested_subcategory' => [
724 - 'name' => 'nested_subcategory',
725 - 'type' => 'toggle',
726 - 'label' => __( 'Nested Sub Category', 'betterdocs' ),
727 - 'enable_disable_text_active' => true,
728 - 'default' => '',
729 - 'priority' => 2
730 - ],
731 - 'column_number' => [
732 - 'name' => 'column_number',
733 - 'type' => 'number',
734 - 'label' => __( 'Number Of Columns', 'betterdocs' ),
735 - 'default' => 3,
736 - 'priority' => 3
737 - ],
738 - 'posts_number' => apply_filters( 'betterdocs_posts_number', [
739 - 'name' => 'posts_number',
740 - 'type' => 'number',
741 - 'label' => __( 'Number Of Docs', 'betterdocs' ),
742 - 'label_subtitle' => __( 'This setting is not applicable for handbook layout.', 'betterdocs' ),
743 - 'default' => 10,
744 - 'priority' => 4
745 - ] ),
746 - 'post_count' => [
747 - 'name' => 'post_count',
748 - 'type' => 'toggle',
749 - 'label' => __( 'Doc Count', 'betterdocs' ),
750 - 'enable_disable_text_active' => true,
751 - 'default' => 1,
752 - 'priority' => 5
753 - ],
754 - 'count_text' => [
755 - 'name' => 'count_text',
756 - 'type' => 'text',
757 - 'label' => __( 'Count Text', 'betterdocs' ),
758 - 'default' => __( 'docs', 'betterdocs' ),
759 - 'priority' => 6
760 - ],
761 - 'count_text_singular' => [
762 - 'name' => 'count_text_singular',
763 - 'type' => 'text',
764 - 'label' => __( 'Count Text Singular', 'betterdocs' ),
765 - 'default' => __( 'doc', 'betterdocs' ),
766 - 'priority' => 7
767 - ],
768 - 'exploremore_btn' => [
769 - 'name' => 'exploremore_btn',
770 - 'type' => 'toggle',
771 - 'label' => __( 'Explore More Button', 'betterdocs' ),
772 - 'enable_disable_text_active' => true,
773 - 'default' => true,
774 - 'priority' => 8
775 - ],
776 - 'exploremore_btn_txt' => [
777 - 'name' => 'exploremore_btn_txt',
778 - 'type' => 'text',
779 - 'label' => __( 'Explore More Button Text', 'betterdocs' ),
780 - 'default' => __( 'Explore More', 'betterdocs' ),
781 - 'priority' => 9,
782 - 'rules' => Rules::is( 'exploremore_btn', true )
783 - ],
784 - 'betterdocs_popular_docs_text' => [
785 - 'name' => 'betterdocs_popular_docs_text',
786 - 'type' => 'text',
787 - 'label' => __( 'Popular Docs Text', 'betterdocs' ),
788 - 'default' => __( 'Popular Docs', 'betterdocs' ),
789 - 'priority' => 10,
790 - "is_pro" => true
791 - ],
792 - 'betterdocs_popular_docs_number' => [
793 - 'name' => 'betterdocs_popular_docs_number',
794 - 'type' => 'number',
795 - 'label' => __( 'Popular Docs Number', 'betterdocs' ),
796 - 'default' => 10,
797 - 'priority' => 11,
798 - "is_pro" => true
799 - ]
800 - ]
801 - ],
802 - 'layout_documentation_page_search' => [
803 - 'id' => 'layout_documentation_page_search',
804 - 'name' => 'layout_documentation_page_search',
805 - 'type' => 'section',
806 - 'label' => __( 'Search', 'betterdocs' ),
807 - 'priority' => 2,
808 - 'fields' => [
809 - 'live_search' => [
810 - 'name' => 'live_search',
811 - 'type' => 'toggle',
812 - 'label' => __( 'Live Search', 'betterdocs' ),
813 - 'enable_disable_text_active' => true,
814 - 'default' => 1,
815 - 'priority' => 1
816 - ],
817 - 'advance_search' => apply_filters( 'betterdocs_advance_search_settings', [
818 - 'name' => 'advance_search',
819 - 'type' => 'toggle',
820 - 'label' => __( 'Advanced Search', 'betterdocs' ),
821 - 'enable_disable_text_active' => true,
822 - 'default' => '',
823 - 'priority' => 2,
824 - 'is_pro' => true
825 - ] ),
826 - 'child_category_exclude' => apply_filters( 'child_category_exclude', [
827 - 'name' => 'child_category_exclude',
828 - 'type' => 'toggle',
829 - 'label' => __( 'Category Search', 'betterdocs' ),
830 - 'enable_disable_text_active' => true,
831 - 'default' => '',
832 - 'priority' => 3,
833 - 'is_pro' => true
834 - ] ),
835 - 'popular_keyword_limit' => apply_filters( 'betterdocs_popular_keyword_limit_settings', [
836 - 'name' => 'popular_keyword_limit',
837 - 'type' => 'number',
838 - 'label' => __( 'Minimum amount of Keywords Search', 'betterdocs' ),
839 - 'default' => 5,
840 - 'priority' => 4,
841 - 'is_pro' => true
842 - ] ),
843 - 'search_letter_limit' => [
844 - 'name' => 'search_letter_limit',
845 - 'type' => 'number',
846 - 'label' => __( 'Minimum Character Limit For Search Result', 'betterdocs' ),
847 - 'priority' => 5,
848 - 'default' => 3
849 - ],
850 - 'search_placeholder' => [
851 - 'name' => 'search_placeholder',
852 - 'type' => 'text',
853 - 'label' => __( 'Search Placeholder', 'betterdocs' ),
854 - 'default' => __( 'Search..', 'betterdocs' ),
855 - 'priority' => 6
856 - ],
857 - 'search_button_text' => apply_filters( 'betterdocs_search_button_text', [
858 - 'name' => 'search_button_text',
859 - 'type' => 'text',
860 - 'label' => __( 'Search Button Text', 'betterdocs' ),
861 - 'priority' => 7,
862 - 'default' => __( 'Search', 'betterdocs' ),
863 - 'is_pro' => true
864 - ] ),
865 - 'search_not_found_text' => [
866 - 'name' => 'search_not_found_text',
867 - 'type' => 'text',
868 - 'label' => __( 'Search Not Found Text', 'betterdocs' ),
869 - 'default' => 'Sorry, no docs were found.',
870 - 'priority' => 8
871 - ],
872 - 'search_result_image' => [
873 - 'name' => 'search_result_image',
874 - 'type' => 'toggle',
875 - 'label' => __( 'Search Result Image', 'betterdocs' ),
876 - 'enable_disable_text_active' => true,
877 - 'default' => 1,
878 - 'priority' => 9
879 - ],
880 - 'kb_based_search' => apply_filters( 'betterdocs_kb_based_search_settings', [
881 - 'name' => 'kb_based_search',
882 - 'type' => 'toggle',
883 - 'label' => __( 'KB Based Search', 'betterdocs' ),
884 - 'enable_disable_text_active' => true,
885 - 'default' => '',
886 - 'priority' => 10,
887 - 'is_pro' => true,
888 - 'rules' => Rules::is( 'multiple_kb', true )
889 - ] )
890 - ]
891 - ],
892 - 'layout_documentation_page_order_by' => [
893 - 'id' => 'layout_documentation_page_order_by',
894 - 'name' => 'layout_documentation_page_order_by',
895 - 'type' => 'section',
896 - 'label' => __( 'Order By', 'betterdocs' ),
897 - 'priority' => 3,
898 - 'fields' => [
899 - 'terms_orderby' => [
900 - 'name' => 'terms_orderby',
901 - 'type' => 'select',
902 - 'label' => __( 'Terms Order By', 'betterdocs' ),
903 - 'default' => 'betterdocs_order',
904 - 'options' => $this->normalize_options( apply_filters( 'betterdocs_terms_orderby_options', [
905 - 'none' => __( 'No order', 'betterdocs' ),
906 - 'name' => __( 'Name', 'betterdocs' ),
907 - 'slug' => __( 'Slug', 'betterdocs' ),
908 - 'term_group' => __( 'Term Group', 'betterdocs' ),
909 - 'term_id' => __( 'Term ID', 'betterdocs' ),
910 - 'id' => __( 'ID', 'betterdocs' ),
911 - 'description' => __( 'Description', 'betterdocs' ),
912 - 'parent' => __( 'Parent', 'betterdocs' ),
913 - 'betterdocs_order' => __( 'BetterDocs Order', 'betterdocs' )
914 - ] ) ),
915 - 'priority' => 1
916 - ],
917 - 'terms_order' => [
918 - 'name' => 'terms_order',
919 - 'type' => 'select',
920 - 'label' => __( 'Terms Order', 'betterdocs' ),
921 - 'default' => 'ASC',
922 - 'options' => $this->normalize_options( [
923 - 'ASC' => 'Ascending',
924 - 'DESC' => 'Descending'
925 - ] ),
926 - 'priority' => 3
927 - ],
928 - 'alphabetically_order_post' => [
929 - 'name' => 'alphabetically_order_post',
930 - 'type' => 'select',
931 - 'label' => __( 'Docs Order By', 'betterdocs' ),
932 - 'default' => 'betterdocs_order',
933 - 'options' => $this->normalize_options( [
934 - 'none' => __( 'No order', 'betterdocs' ),
935 - 'ID' => __( 'Docs ID', 'betterdocs' ),
936 - 'author' => __( 'Docs Author', 'betterdocs' ),
937 - 'title' => __( 'Title', 'betterdocs' ),
938 - 'date' => __( 'Date', 'betterdocs' ),
939 - 'modified' => __( 'Last Modified Date', 'betterdocs' ),
940 - 'parent' => __( 'Parent Id', 'betterdocs' ),
941 - 'rand' => __( 'Random', 'betterdocs' ),
942 - 'comment_count' => __( 'Comment Count', 'betterdocs' ),
943 - 'menu_order' => __( 'Menu Order', 'betterdocs' ),
944 - 'betterdocs_order' => __( 'BetterDocs Order', 'betterdocs' )
945 - ] ),
946 - 'priority' => 4
947 - ],
948 - 'docs_order' => [
949 - 'name' => 'docs_order',
950 - 'type' => 'select',
951 - 'label' => __( 'Docs Order', 'betterdocs' ),
952 - 'default' => 'ASC',
953 - 'options' => $this->normalize_options( [
954 - 'ASC' => 'Ascending',
955 - 'DESC' => 'Descending'
956 - ] ),
957 - 'priority' => 5
958 - ]
959 - ]
960 - ]
961 - ]
962 - ]
963 - ]
964 - ],
965 - 'layout_single_doc' => apply_filters( 'single_doc_setting_section', [
966 - 'id' => 'layout_single_doc',
967 - 'name' => 'layout_single_doc',
968 - 'type' => 'section',
969 - 'label' => __( 'Single Doc', 'betterdocs' ),
970 - 'priority' => 2,
971 - 'fields' => [
972 - 'tab-nested-layout-2' => [
973 - 'id' => 'tab-nested-layout-2',
974 - 'name' => 'tab_nested_layout_2',
975 - 'label' => __( 'Single Doc', 'betterdocs' ),
976 - 'classes' => 'tab-nested-layout',
977 - 'type' => "tab",
978 - 'active' => "layout_single_doc_general",
979 - 'completionTrack' => true,
980 - 'sidebar' => false,
981 - 'save' => false,
982 - 'title' => false,
983 - 'config' => [
984 - 'active' => 'layout_single_doc_general',
985 - 'sidebar' => false,
986 - 'title' => false
987 - ],
988 - 'submit' => [
989 - 'show' => false
990 - ],
991 - 'step' => [
992 - 'show' => false
993 - ],
994 - 'priority' => 20,
995 - 'fields' => [
996 - 'layout_single_doc_general' => [
997 - 'id' => 'layout_single_doc_general',
998 - 'name' => 'layout_single_doc_general',
999 - 'type' => 'section',
1000 - 'label' => __( 'General', 'betterdocs' ),
1001 - 'priority' => 5,
1002 - 'fields' => [
1003 - 'enable_post_title' => [
1004 - 'name' => 'enable_post_title',
1005 - 'type' => 'toggle',
1006 - 'label' => __( 'Doc Title', 'betterdocs' ),
1007 - 'enable_disable_text_active' => true,
1008 - 'default' => 1,
1009 - 'priority' => 1
1010 - ],
1011 - 'enable_sidebar_cat_list' => [
1012 - 'name' => 'enable_sidebar_cat_list',
1013 - 'type' => 'toggle',
1014 - 'label' => __( 'Sidebar Category List', 'betterdocs' ),
1015 - 'enable_disable_text_active' => true,
1016 - 'default' => 1,
1017 - 'priority' => 2
1018 - ],
1019 - 'enable_print_icon' => [
1020 - 'name' => 'enable_print_icon',
1021 - 'type' => 'toggle',
1022 - 'label' => __( 'Print Icon', 'betterdocs' ),
1023 - 'enable_disable_text_active' => true,
1024 - 'default' => 1,
1025 - 'priority' => 3
1026 - ],
1027 - 'enable_tags' => [
1028 - 'name' => 'enable_tags',
1029 - 'type' => 'toggle',
1030 - 'label' => __( 'Tags', 'betterdocs' ),
1031 - 'enable_disable_text_active' => true,
1032 - 'default' => 1,
1033 - 'priority' => 4
1034 - ],
1035 - 'show_last_update_time' => [
1036 - 'name' => 'show_last_update_time',
1037 - 'type' => 'toggle',
1038 - 'label' => __( 'Last Update Time', 'betterdocs' ),
1039 - 'enable_disable_text_active' => true,
1040 - 'default' => 1,
1041 - 'priority' => 5
1042 - ],
1043 - 'enable_navigation' => [
1044 - 'name' => 'enable_navigation',
1045 - 'type' => 'toggle',
1046 - 'label' => __( 'Navigation', 'betterdocs' ),
1047 - 'enable_disable_text_active' => true,
1048 - 'default' => 1,
1049 - 'priority' => 6
1050 - ],
1051 - 'enable_comment' => [
1052 - 'name' => 'enable_comment',
1053 - 'type' => 'toggle',
1054 - 'label' => __( 'Comment', 'betterdocs' ),
1055 - 'enable_disable_text_active' => true,
1056 - 'default' => '',
1057 - 'priority' => 7
1058 - ],
1059 - 'enable_credit' => [
1060 - 'name' => 'enable_credit',
1061 - 'type' => 'toggle',
1062 - 'label' => __( 'Credit', 'betterdocs' ),
1063 - 'enable_disable_text_active' => true,
1064 - 'default' => 1,
1065 - 'priority' => 8
1066 - ]
1067 - ]
1068 - ],
1069 - 'layout_single_doc_TOC' => [
1070 - 'id' => 'layout_single_doc_TOC',
1071 - 'name' => 'layout_single_doc_TOC',
1072 - 'type' => 'section',
1073 - 'label' => __( 'TOC', 'betterdocs' ),
1074 - 'priority' => 5,
1075 - 'fields' => [
1076 - 'enable_toc' => [
1077 - 'name' => 'enable_toc',
1078 - 'type' => 'toggle',
1079 - 'label' => __( 'Table of Contents', 'betterdocs' ),
1080 - 'enable_disable_text_active' => true,
1081 - 'default' => 1,
1082 - 'priority' => 1
1083 - ],
1084 - 'toc_title' => [
1085 - 'name' => 'toc_title',
1086 - 'type' => 'text',
1087 - 'label' => __( 'TOC Title', 'betterdocs' ),
1088 - 'default' => __( 'Table of Contents', 'betterdocs' ),
1089 - 'priority' => 2,
1090 - 'rules' => Rules::is( 'enable_toc', true )
528 + $_old_settings = $this->database->get( $this->base_key, $this->get_default() );
529 + // @todo: sanitize the data before inject in DB.
530 + $_normalized_settings = $this->get_normalized_values( $settings );
531 + if ( $existing_plugins && isset( $_normalized_settings['migration_step'] ) && $_normalized_settings['migration_step'] == true ) {
532 + betterdocs()->kbmigration->migrate();
533 + }
534 + $_settings = wp_parse_args( $_normalized_settings, $_old_settings );
535 + $_saved = $this->database->save( $this->base_key, $_settings );
1091 536
1092 - ],
1093 - 'toc_hierarchy' => [
1094 - 'name' => 'toc_hierarchy',
1095 - 'type' => 'toggle',
1096 - 'label' => __( 'TOC Hierarchy', 'betterdocs' ),
1097 - 'enable_disable_text_active' => true,
1098 - 'default' => 1,
1099 - 'priority' => 3,
1100 - 'rules' => Rules::is( 'enable_toc', true )
1101 - ],
1102 - 'toc_list_number' => [
1103 - 'name' => 'toc_list_number',
1104 - 'type' => 'toggle',
1105 - 'label' => __( 'TOC List Number', 'betterdocs' ),
1106 - 'enable_disable_text_active' => true,
1107 - 'default' => 1,
1108 - 'priority' => 4,
1109 - 'rules' => Rules::is( 'enable_toc', true )
1110 - ],
1111 - 'toc_dynamic_title' => [
1112 - 'name' => 'toc_dynamic_title',
1113 - 'type' => 'toggle',
1114 - 'label' => __( 'Show TOC Title in Anchor Links', 'betterdocs' ),
1115 - 'enable_disable_text_active' => true,
1116 - 'default' => 0,
1117 - 'priority' => 5,
1118 - 'rules' => Rules::is( 'enable_toc', true )
1119 - ],
1120 - 'enable_sticky_toc' => [
1121 - 'name' => 'enable_sticky_toc',
1122 - 'type' => 'toggle',
1123 - 'label' => __( 'Sticky TOC', 'betterdocs' ),
1124 - 'enable_disable_text_active' => true,
1125 - 'default' => 1,
1126 - 'priority' => 6,
1127 - 'rules' => Rules::is( 'enable_toc', true )
1128 - ],
1129 - 'collapsible_toc_mobile' => [
1130 - 'name' => 'collapsible_toc_mobile',
1131 - 'type' => 'toggle',
1132 - 'label' => __( 'Collapsible TOC on small devices', 'betterdocs' ),
1133 - 'enable_disable_text_active' => true,
1134 - 'default' => '',
1135 - 'priority' => 7,
1136 - 'rules' => Rules::is( 'enable_toc', true )
1137 - ],
1138 - 'title_link_ctc' => [
1139 - 'name' => 'title_link_ctc',
1140 - 'type' => 'toggle',
1141 - 'label' => __( 'Title Link Copy To Clipboard', 'betterdocs' ),
1142 - 'enable_disable_text_active' => true,
1143 - 'default' => 1,
1144 - 'priority' => 8
1145 - ],
1146 - 'supported_heading_tag' => [
1147 - 'name' => 'supported_heading_tag',
1148 - 'label' => __( 'TOC Supported Heading Tag', 'betterdocs' ),
1149 - 'type' => 'checkbox-select',
1150 - 'multiple' => true,
1151 - 'priority' => 10,
1152 - 'default' => ['1', '2', '3', '4', '5', '6'],
1153 - 'options' => $this->normalize_options( [
1154 - '1' => 'H1',
1155 - '2' => 'H2',
1156 - '3' => 'H3',
1157 - '4' => 'H4',
1158 - '5' => 'H5',
1159 - '6' => 'H6'
1160 - ] ),
1161 - 'priority' => 9,
1162 - 'rules' => Rules::is( 'enable_toc', true )
1163 - ],
1164 - 'sticky_toc_offset' => [
1165 - 'name' => 'sticky_toc_offset',
1166 - 'type' => 'number',
1167 - 'label' => __( 'Content Offset', 'betterdocs' ),
1168 - 'default' => 100,
1169 - 'priority' => 10,
1170 - 'label_subtitle' => __( 'content offset from top on scroll.', 'betterdocs' ),
1171 - 'rules' => Rules::is( 'enable_toc', true )
1172 - ]
1173 - ]
1174 - ],
1175 - 'layout_single_doc_breadcrumb' => [
1176 - 'id' => 'layout_single_doc_breadcrumb',
1177 - 'name' => 'layout_single_doc_breadcrumb',
1178 - 'type' => 'section',
1179 - 'label' => __( 'Breadcrumb', 'betterdocs' ),
1180 - 'priority' => 5,
1181 - 'fields' => [
1182 - 'enable_breadcrumb' => [
1183 - 'name' => 'enable_breadcrumb',
1184 - 'type' => 'toggle',
1185 - 'label' => __( 'Breadcrumb', 'betterdocs' ),
1186 - 'enable_disable_text_active' => true,
1187 - 'default' => 1,
1188 - 'priority' => 1
1189 - ],
1190 - 'breadcrumb_home_text' => [
1191 - 'name' => 'breadcrumb_home_text',
1192 - 'type' => 'text',
1193 - 'label' => __( 'Breadcrumb Home Text', 'betterdocs' ),
1194 - 'default' => __( 'Home', 'betterdocs' ),
1195 - 'priority' => 2,
1196 - 'rules' => Rules::is( 'enable_breadcrumb', true )
1197 - ],
1198 - 'breadcrumb_home_url' => [
1199 - 'name' => 'breadcrumb_home_url',
1200 - 'type' => 'text',
1201 - 'label' => __( 'Breadcrumb Home URL', 'betterdocs' ),
1202 - 'priority' => 3,
1203 - 'default' => get_home_url(),
1204 - 'rules' => Rules::is( 'enable_breadcrumb', true )
1205 - ],
1206 - 'enable_breadcrumb_category' => [
1207 - 'name' => 'enable_breadcrumb_category',
1208 - 'type' => 'toggle',
1209 - 'label' => __( 'Category on Breadcrumb', 'betterdocs' ),
1210 - 'enable_disable_text_active' => true,
1211 - 'default' => 1,
1212 - 'priority' => 4,
1213 - 'rules' => Rules::is( 'enable_breadcrumb', true )
1214 - ],
1215 - 'enable_breadcrumb_title' => [
1216 - 'name' => 'enable_breadcrumb_title',
1217 - 'type' => 'toggle',
1218 - 'label' => __( 'Title on Breadcrumb', 'betterdocs' ),
1219 - 'enable_disable_text_active' => true,
1220 - 'default' => 1,
1221 - 'priority' => 5,
1222 - 'rules' => Rules::is( 'enable_breadcrumb', true )
1223 - ]
1224 - ]
1225 - ],
1226 - 'layout_single_doc_email_feedback' => [
1227 - 'id' => 'layout_single_doc_email_feedback',
1228 - 'name' => 'layout_single_doc_email_feedback',
1229 - 'type' => 'section',
1230 - 'label' => __( 'Email Feedback', 'betterdocs' ),
1231 - 'priority' => 5,
1232 - 'fields' => [
1233 - 'email_feedback' => [
1234 - 'name' => 'email_feedback',
1235 - 'type' => 'toggle',
1236 - 'label' => __( 'Email Feedback', 'betterdocs' ),
1237 - 'enable_disable_text_active' => true,
1238 - 'default' => 1,
1239 - 'priority' => 1
1240 - ],
1241 - 'feedback_link_text' => [
1242 - 'name' => 'feedback_link_text',
1243 - 'type' => 'text',
1244 - 'label' => __( 'Feedback Link Text', 'betterdocs' ),
1245 - 'default' => __( 'Still stuck? How can we help?', 'betterdocs' ),
1246 - 'priority' => 2,
1247 - 'rules' => Rules::is( 'email_feedback', true )
1248 - ],
1249 - 'feedback_form_title' => [
1250 - 'name' => 'feedback_form_title',
1251 - 'type' => 'text',
1252 - 'label' => __( 'Feedback Form Title', 'betterdocs' ),
1253 - 'default' => __( 'Still stuck? How can we help?', 'betterdocs' ),
1254 - 'priority' => 3,
1255 - 'rules' => Rules::is( 'email_feedback', true )
1256 - ],
1257 - 'email_address' => [
1258 - 'name' => 'email_address',
1259 - 'type' => 'text',
1260 - 'label' => __( 'Email Address', 'betterdocs' ),
1261 - 'default' => get_option( 'admin_email' ),
1262 - 'priority' => 4,
1263 - 'label_subtitle' => __( 'The email address where the Feedback form will be sent', 'betterdocs' ),
1264 - 'rules' => Rules::is( 'email_feedback', true )
1265 - ],
1266 - 'feedback_url' => [
1267 - 'name' => 'feedback_url',
1268 - 'type' => 'text',
1269 - 'label' => __( 'Feedback URL', 'betterdocs' ),
1270 - 'default' => '',
1271 - 'priority' => 5,
1272 - 'rules' => Rules::is( 'email_feedback', true )
1273 - ]
1274 - ]
1275 - ],
1276 - [
1277 - 'id' => 'layout_single_doc_attachments',
1278 - 'name' => 'layout_single_doc_attachments',
1279 - 'type' => 'section',
1280 - 'label' => __( 'Attachments', 'betterdocs-pro' ),
1281 - 'priority' => 6,
1282 - 'fields' => apply_filters( 'betterdocs_single_doc_attachments', [
1283 - 'show_attachment' => [
1284 - 'name' => 'show_attachment',
1285 - 'type' => 'toggle',
1286 - 'is_pro' => true,
1287 - 'priority' => 1,
1288 - 'label' => __( 'Show Attachment', 'betterdocs-pro' ),
1289 - 'enable_disable_text_active' => true,
1290 - 'default' => false
1291 - ]
1292 - ] )
1293 - ],
1294 - [
1295 - 'id' => 'layout_single_doc_related_docs',
1296 - 'name' => 'layout_single_doc_related_docs',
1297 - 'type' => 'section',
1298 - 'label' => __( 'Related Docs', 'betterdocs-pro' ),
1299 - 'priority' => 7,
1300 - 'fields' => apply_filters( 'betterdocs_single_doc_related_docs', [
1301 - 'show_related_docs' => [
1302 - 'name' => 'show_related_docs',
1303 - 'type' => 'toggle',
1304 - 'is_pro' => true,
1305 - 'priority' => 1,
1306 - 'label' => __( 'Show Related Docs', 'betterdocs-pro' ),
1307 - 'enable_disable_text_active' => true,
1308 - 'default' => false
1309 - ]
1310 - ] )
1311 - ]
1312 - ]
1313 - ]
1314 - ]
1315 - ] ),
1316 - 'layout_archive_page' => [
1317 - 'id' => 'layout_archive_page',
1318 - 'name' => 'layout_archive_page',
1319 - 'type' => 'section',
1320 - 'label' => __( 'Archive Page', 'betterdocs' ),
1321 - 'priority' => 3,
1322 - 'fields' => [
1323 - 'enable_archive_sidebar' => [
1324 - 'name' => 'enable_archive_sidebar',
1325 - 'type' => 'toggle',
1326 - 'label' => __( 'Sidebar Category List', 'betterdocs' ),
1327 - 'enable_disable_text_active' => true,
1328 - 'default' => 1,
1329 - 'priority' => 31
1330 - ],
1331 - 'archive_nested_subcategory' => [
1332 - 'name' => 'archive_nested_subcategory',
1333 - 'type' => 'toggle',
1334 - 'label' => __( 'Nested Subcategory', 'betterdocs' ),
1335 - 'enable_disable_text_active' => true,
1336 - 'default' => 1,
1337 - 'priority' => 32
1338 - ]
1339 - ]
1340 - ]
1341 - ]
1342 - ] )
1343 - ]
1344 - ]
1345 - ]
1346 - ] ),
1347 - 'tab-design' => apply_filters( 'betterdocs_settings_tab_design', [
1348 - 'id' => 'tab-design',
1349 - 'label' => __( 'Design', 'betterdocs' ),
1350 - 'priority' => 30,
1351 - 'fields' => [
1352 - 'title-design' => [
1353 - 'name' => 'title-design-tab',
1354 - 'type' => 'section',
1355 - 'label' => __( 'Design', 'betterdocs' ),
1356 - 'priority' => 30,
1357 - 'fields' => [
1358 - 'customizer_link' => [
1359 - 'name' => 'customizer_link',
1360 - 'type' => 'action',
1361 - 'action' => 'betterdocs_settings_customizer_link',
1362 - 'label' => __( 'Customize BetterDocs', 'betterdocs' ),
1363 - 'url' => $this->customizer_link(),
1364 - 'customizer_img' => betterdocs()->assets->icon( 'customizer/betterdocs-customize.png', true ),
1365 - 'priority' => 1
1366 - ]
1367 - ]
1368 - ]
1369 - ]
1370 - ] ),
1371 - 'tab-shortcodes' => apply_filters( 'betterdocs_settings_tab_shortcodes', [
1372 - 'label' => __( 'Shortcodes', 'betterdocs' ),
1373 - 'id' => 'tab-shortcodes',
1374 - 'classes' => 'tab-shortcodes',
1375 - 'priority' => 40,
1376 - 'fields' => [
1377 - 'title-shortcodes' => [
1378 - 'name' => 'title-shortcodes-tab',
1379 - 'type' => 'section',
1380 - 'label' => __( 'Shortcodes', 'betterdocs' ),
1381 - 'priority' => 40,
1382 - 'searchable' => true,
1383 - 'searchPlaceholder' => __( 'Search for shortcode', 'betterdocs' ),
1384 - 'searchNotFoundMessage' => '<img src="' . betterdocs()->assets->icon( 'not-found.svg', true ) . '"/><p>' . __( 'No Shortcodes Found with these keywords', 'betterdocs' ) . '</p>',
1385 - 'fields' => apply_filters( 'betterdocs_shortcode_fields', [
1386 - 'search_form' => [
1387 - 'name' => 'search_form',
1388 - 'type' => 'copy-to-clipboard',
1389 - 'label' => __( 'Search Form', 'betterdocs' ),
1390 - 'default' => '[betterdocs_search_form]',
1391 - 'readOnly' => true,
1392 - 'priority' => 1,
1393 - 'description' => __( '[betterdocs_search_form placeholder="Search..." heading="Heading" subheading="Subheading" category_search="true" search_button="true" popular_search="true"]', 'betterdocs' ),
1394 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1395 - 'descriptionCopyable' => true
1396 - ],
1397 - 'feedback_form' => [
1398 - 'name' => 'feedback_form',
1399 - 'type' => 'copy-to-clipboard',
1400 - 'label' => __( 'Feedback Form', 'betterdocs' ),
1401 - 'default' => '[betterdocs_feedback_form]',
1402 - 'readOnly' => true,
1403 - 'priority' => 2,
1404 - 'description' => __( '[betterdocs_feedback_form button_text="Send"]', 'betterdocs' ),
1405 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1406 - 'descriptionCopyable' => true
1407 - ],
1408 - 'category_grid' => [
1409 - 'name' => 'category_grid',
1410 - 'type' => 'copy-to-clipboard',
1411 - 'label' => __( 'Category Grid- Layout 1', 'betterdocs' ),
1412 - 'default' => '[betterdocs_category_grid]',
1413 - 'readOnly' => true,
1414 - 'priority' => 3,
1415 - 'description' => __( '[betterdocs_category_grid post_counter="true" show_icon="true" masonry="true" column="3" posts_per_page="5" nested_subcategory="true" terms="term_ID, term_ID" terms_orderby="" terms_order="" multiple_knowledge_base="" kb_slug="" title_tag="h2" orderby="" order="" ]', 'betterdocs' ),
1416 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1417 - 'descriptionCopyable' => true
1418 - ],
1419 - 'category_box' => [
1420 - 'name' => 'category_box',
1421 - 'type' => 'copy-to-clipboard',
1422 - 'label' => __( 'Category Box- Layout 2', 'betterdocs' ),
1423 - 'default' => '[betterdocs_category_box]',
1424 - 'readOnly' => true,
1425 - 'priority' => 4,
1426 - 'description' => __( '[betterdocs_category_box orderby="" column="" nested_subcategory="" terms="" terms_orderby="" show_icon="" kb_slug="" title_tag="h2" multiple_knowledge_base="false" border_bottom="false"]', 'betterdocs' ),
1427 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1428 - 'descriptionCopyable' => true
1429 - ],
1430 - 'category_list' => [
1431 - 'name' => 'category_list',
1432 - 'type' => 'copy-to-clipboard',
1433 - 'label' => __( 'Category List', 'betterdocs' ),
1434 - 'default' => '[betterdocs_category_list]',
1435 - 'readOnly' => true,
1436 - 'priority' => 5,
1437 - 'description' => __( '[betterdocs_category_list orderby="" order="" posts_per_page="" nested_subcategory="" terms="" terms_orderby="" terms_order="" kb_slug="" multiple_knowledge_base="false" title_tag="h2"]', 'betterdocs' ),
1438 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1439 - 'descriptionCopyable' => true
1440 - ],
1441 - 'faq_modern_layout' => [
1442 - 'name' => 'faq_modern_layout',
1443 - 'type' => 'copy-to-clipboard',
1444 - 'label' => __( 'FAQ Layout - 1', 'betterdocs' ),
1445 - 'default' => '[betterdocs_faq_list_modern]',
1446 - 'readOnly' => true,
1447 - 'priority' => 13,
1448 - 'description' => __( '[betterdocs_faq_list_modern groups="group_id" class="" group_exclude="group_id" faq_heading="Frequently Asked Questions"]', 'betterdocs' ),
1449 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1450 - 'descriptionCopyable' => true
1451 - ],
1452 - 'faq_classic_layout' => [
1453 - 'name' => 'faq_classic_layout',
1454 - 'type' => 'copy-to-clipboard',
1455 - 'label' => __( 'FAQ Layout - 2', 'betterdocs' ),
1456 - 'default' => '[betterdocs_faq_list_classic]',
1457 - 'readOnly' => true,
1458 - 'priority' => 14,
1459 - 'description' => __( '[betterdocs_faq_list_classic groups="group_id" class="" group_exclude="group_id" faq_heading="Frequently Asked Questions"]', 'betterdocs' ),
1460 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1461 - 'descriptionCopyable' => true
1462 - ]
1463 - ] )
1464 - ]
1465 - ]
1466 - ] ),
1467 - 'tab-advance-settings' => apply_filters( 'betterdocs_settings_tab_advance', [
1468 - 'id' => 'tab-advance-settings',
1469 - 'label' => __( 'Advanced Settings', 'betterdocs' ),
1470 - 'priority' => 50,
1471 - 'fields' => [
1472 - 'title-advance-settings' => [
1473 - 'name' => 'title-advance-settings-tab',
1474 - 'type' => 'section',
1475 - 'label' => __( 'Advanced Settings', 'betterdocs' ),
1476 - 'priority' => 50,
1477 - 'fields' => apply_filters( 'betterdocs_internal_kb_fields', [
1478 - 'article_roles' => [
1479 - 'name' => 'article_roles',
1480 - 'type' => 'checkbox-select',
1481 - 'label' => __( 'Who Can Write Docs?', 'betterdocs' ),
1482 - 'priority' => 1,
1483 - 'multiple' => true,
1484 - 'search' => true,
1485 - 'is_pro' => true,
1486 - 'default' => ['administrator'],
1487 - 'options' => $wp_roles
1488 - ],
1489 - 'settings_roles' => [
1490 - 'name' => 'settings_roles',
1491 - 'type' => 'checkbox-select',
1492 - 'label' => __( 'Who Can Edit Settings?', 'betterdocs' ),
1493 - 'priority' => 2,
1494 - 'multiple' => true,
1495 - 'is_pro' => true,
1496 - 'search' => true,
1497 - 'default' => ['administrator'],
1498 - 'options' => $wp_roles
1499 - ],
1500 - 'analytics_roles' => [
1501 - 'name' => 'analytics_roles',
1502 - 'type' => 'checkbox-select',
1503 - 'label' => __( 'Who Can Check Analytics?', 'betterdocs' ),
1504 - 'priority' => 3,
1505 - 'multiple' => true,
1506 - 'is_pro' => true,
1507 - 'search' => true,
1508 - 'default' => ['administrator'],
1509 - 'options' => $wp_roles
1510 - ],
1511 - 'enable_content_restriction' => [
1512 - 'name' => 'enable_content_restriction',
1513 - 'type' => 'toggle',
1514 - 'is_pro' => true,
1515 - 'priority' => 4,
1516 - 'label' => __( 'Internal Knowledge Base', 'betterdocs' ),
1517 - 'enable_disable_text_active' => true,
1518 - 'default' => ['all']
1519 - ],
1520 - 'content_visibility' => [
1521 - 'name' => 'content_visibility',
1522 - 'type' => 'checkbox-select',
1523 - 'label' => __( 'Restrict Access to', 'betterdocs' ),
1524 - 'label_subtitle' => __( 'Only selected User Roles will be able to view your Knowledge Base', 'betterdocs' ),
1525 - 'is_pro' => true,
1526 - 'priority' => 5,
1527 - 'multiple' => true,
1528 - 'search' => true,
1529 - 'default' => ['all'],
1530 - 'placeholder' => __( 'Select any', 'betterdocs' ),
1531 - 'options' => $this->normalize_options( array_merge( [
1532 - 'all' => __( 'All logged in users', 'betterdocs' )
1533 - ], wp_roles()->role_names ) ),
1534 - 'rules' => Rules::is( 'enable_content_restriction', true ),
1535 - 'filterValue' => 'all'
1536 - ],
1537 - 'restrict_template' => [
1538 - 'name' => 'restrict_template',
1539 - 'type' => 'checkbox-select',
1540 - 'label' => __( 'Restriction on Docs', 'betterdocs' ),
1541 - 'label_subtitle' => __( 'Selected Docs pages will be restricted', 'betterdocs' ),
1542 - 'is_pro' => true,
1543 - 'priority' => 6,
1544 - 'multiple' => true,
1545 - 'search' => true,
1546 - 'default' => ['all'],
1547 - 'placeholder' => __( 'Select any', 'betterdocs' ),
1548 - 'options' => $this->get_texanomy(),
1549 - 'rules' => Rules::is( 'enable_content_restriction', true ),
1550 - 'filterValue' => 'all'
1551 - ],
1552 - 'restrict_category' => [
1553 - 'name' => 'restrict_category',
1554 - 'type' => 'checkbox-select',
1555 - 'label' => __( 'Restriction on Docs Categories', 'betterdocs' ),
1556 - 'label_subtitle' => __( 'Selected Docs categories will be restricted', 'betterdocs' ),
1557 - 'is_pro' => true,
1558 - 'priority' => 7,
1559 - 'multiple' => true,
1560 - 'search' => true,
1561 - 'default' => ['all'],
1562 - 'placeholder' => __( 'Select any', 'betterdocs' ),
1563 - 'options' => $this->get_terms( 'doc_category' ),
1564 - 'rules' => Rules::is( 'enable_content_restriction', true ),
1565 - 'filterValue' => 'all'
1566 - ],
1567 - 'restricted_redirect_url' => [
1568 - 'name' => 'restricted_redirect_url',
1569 - 'type' => 'text',
1570 - 'label' => __( 'Redirect URL', 'betterdocs' ),
1571 - 'label_subtitle' => __( 'Set a custom URL to redirect users without permissions when they try to access internal knowledge base. By default, restricted content will redirect to the "404 not found" page', 'betterdocs' ),
1572 - 'default' => '',
1573 - 'placeholder' => 'https://',
1574 - 'is_pro' => true,
1575 - 'priority' => 9,
1576 - 'rules' => Rules::is( 'enable_content_restriction', true )
1577 - ]
1578 - ] )
1579 - ]
1580 - ]
1581 - ] ),
1582 - 'tab-email-reporting' => apply_filters( 'betterdocs_settings_tab_email_reporting', [
1583 - 'id' => 'tab-email-reporting',
1584 - 'label' => __( 'Email Reporting', 'betterdocs' ),
1585 - 'priority' => 60,
1586 - 'fields' => [
1587 - 'title-email-reporting' => [
1588 - 'name' => 'title-email-reporting-tab',
1589 - 'type' => 'section',
1590 - 'label' => __( 'Email Reporting', 'betterdocs' ),
1591 - 'priority' => 60,
1592 - 'fields' => [
1593 - 'enable_reporting' => [
1594 - 'name' => 'enable_reporting',
1595 - 'label' => __( 'Email Reporting', 'betterdocs' ),
1596 - 'enable_disable_text_active' => true,
1597 - 'type' => 'toggle',
1598 - 'priority' => 1,
1599 - 'default' => 0
1600 - ],
1601 - 'reporting_frequency' => apply_filters( 'betterdocs_reporting_frequency_settings', [
1602 - 'name' => 'reporting_frequency',
1603 - 'type' => 'select',
1604 - 'label' => __( 'Reporting Frequency', 'betterdocs' ),
1605 - 'default' => 'betterdocs_weekly',
1606 - 'priority' => 2,
1607 - 'is_pro' => true,
1608 - 'options' => $this->normalize_options( [
1609 - 'betterdocs_daily' => __( 'Once Daily', 'betterdocs' ),
1610 - 'betterdocs_weekly' => __( 'Once Weekly', 'betterdocs' ),
1611 - 'betterdocs_monthly' => __( 'Once Monthly', 'betterdocs' )
1612 - ] ),
1613 - 'rules' => Rules::is( 'enable_reporting', true )
1614 - ] ),
1615 - 'reporting_day' => [
1616 - 'name' => 'reporting_day',
1617 - 'type' => 'select',
1618 - 'label' => __( 'Reporting Day', 'betterdocs' ),
1619 - 'default' => 'monday',
1620 - 'rules' => Rules::logicalRule( [
1621 - Rules::is( 'enable_reporting', true ),
1622 - Rules::is( 'reporting_frequency', 'betterdocs_weekly' )
1623 - ], 'and' ),
1624 - 'priority' => 3,
1625 - 'options' => $this->normalize_options( [
1626 - 'sunday' => __( 'Sunday', 'betterdocs' ),
1627 - 'monday' => __( 'Monday', 'betterdocs' ),
1628 - 'tuesday' => __( 'Tuesday', 'betterdocs' ),
1629 - 'wednesday' => __( 'Wednesday', 'betterdocs' ),
1630 - 'thursday' => __( 'Thursday', 'betterdocs' ),
1631 - 'friday' => __( 'Friday', 'betterdocs' ),
1632 - 'saturday' => __( 'Saturday', 'betterdocs' )
1633 - ] ),
1634 - 'label_subtitle' => __( 'This is only applicable for the “Weekly” report', 'betterdocs' )
1635 - ],
1636 - 'select_reporting_data' => apply_filters( 'betterdocs_select_reporting_data_settings', [
1637 - 'name' => 'select_reporting_data',
1638 - 'type' => 'checkbox-select',
1639 - 'label' => __( 'Select Reporting Data', 'betterdocs' ),
1640 - 'priority' => 4,
1641 - 'multiple' => true,
1642 - 'options' => $this->normalize_options( [
1643 - 'overview' => 'Overview',
1644 - 'top-docs' => 'Top Docs',
1645 - 'most-search' => 'Most Searched Keywords'
1646 - ] ),
1647 - 'default' => ['overview', 'top-docs', 'most-search'],
1648 - 'is_pro' => true,
1649 - 'rules' => Rules::is( 'enable_reporting', true )
1650 - ] ),
1651 - 'reporting_email' => [
1652 - 'name' => 'reporting_email',
1653 - 'type' => 'text',
1654 - 'label' => __( 'Reporting Email', 'betterdocs' ),
1655 - 'default' => get_option( 'admin_email' ),
1656 - 'priority' => 5,
1657 - 'rules' => Rules::is( 'enable_reporting', true )
1658 - ],
1659 - 'reporting_subject' => apply_filters( 'betterdocs_reporting_subject_settings', [
1660 - 'name' => 'reporting_subject',
1661 - 'type' => 'textarea',
1662 - 'label' => __( 'Reporting Email Subject', 'betterdocs' ),
1663 - 'default' => wp_sprintf( __( 'Your Documentation Performance of %s Website', 'betterdocs' ), get_bloginfo( 'name' ) ),
1664 - 'priority' => 6,
1665 - 'is_pro' => true,
1666 - 'rules' => Rules::is( 'enable_reporting', true )
1667 - ] ),
1668 - 'test_report' => [
1669 - 'name' => 'test_report',
1670 - 'label' => __( 'Reporting Test', 'betterdocs' ),
1671 - 'text' => __( 'Test Report', 'betterdocs' ),
1672 - 'type' => 'button',
1673 - 'priority' => 7,
1674 - 'rules' => Rules::is( 'enable_reporting', true ),
1675 - 'ajax' => [
1676 - 'on' => 'click',
1677 - 'api' => '/betterdocs/v1/reporting-test',
1678 - 'data' => [
1679 - 'enable_reporting' => '@enable_reporting',
1680 - 'select_reporting_data' => '@select_reporting_data',
1681 - 'reporting_subject' => '@reporting_subject',
1682 - 'reporting_email' => '@reporting_email',
1683 - 'reporting_day' => '@reporting_day',
1684 - 'reporting_frequency' => '@reporting_frequency'
1685 - ],
1686 - 'swal' => [
1687 - 'text' => __( 'Successfully Sent a Test Report in Your Email.', 'betterdocs' ),
1688 - 'icon' => 'success',
1689 - 'autoClose' => 2000
1690 - ]
1691 - ]
1692 - ]
1693 - ]
1694 - ]
1695 - ]
1696 - ] ),
1697 - 'tab-instant-answer' => apply_filters( 'betterdocs_settings_tab_instant_answer', [
1698 - 'id' => 'tab-instant-answer',
1699 - 'name' => 'tab-instant-answer',
1700 - 'type' => 'section',
1701 - 'label' => __( 'Instant Answer', 'betterdocs' ),
1702 - 'save' => false,
1703 - 'priority' => 70,
1704 - 'fields' => [
1705 - 'title-instant-answer' => [
1706 - 'name' => 'title-instant-answer-tab',
1707 - 'type' => 'section',
1708 - 'label' => __( 'Instant Answer', 'betterdocs' ),
1709 - 'priority' => 80,
1710 - 'save' => false,
1711 - 'showSubmit' => false,
1712 - 'fields' => apply_filters( 'betterdocs_instant_answer_fields', [
1713 - 'enable_disable_wrapper' => [
1714 - 'name' => 'enable_disable_wrapper',
1715 - 'type' => 'section',
1716 - 'priority' => 0,
1717 - 'save' => false,
1718 - 'fields' => [
1719 - 'enable_disable' => [
1720 - 'name' => 'enable_disable',
1721 - 'type' => 'toggle',
1722 - 'priority' => 100,
1723 - 'description' => __( 'Enable Instant Answer', 'betterdocs' ),
1724 - 'enable_disable_text_active' => false,
1725 - 'default' => true,
1726 - 'is_pro' => true
1727 - ]
1728 - ]
1729 - ]
1730 - ] )
1731 - ]
1732 - ]
1733 - ] ),
1734 - 'tab-ai-autowrite' => [
1735 - 'id' => 'tab-ai-autowrite',
1736 - 'name' => 'tab-ai-autowrite',
1737 - 'type' => 'section',
1738 - 'label' => __( 'Write with AI', 'betterdocs' ),
1739 - 'priority' => 75,
1740 - 'fields' => [
1741 - 'title-ai-autowrite' => apply_filters( 'betterdocs_settings_ai_autowrite_fields', [
1742 - 'name' => 'title-ai-autowrite-tab',
1743 - 'type' => 'section',
1744 - 'label' => __( 'Write with AI', 'betterdocs' ),
1745 - 'priority' => 60,
1746 - 'fields' => [
1747 - 'enable_write_with_ai' => [
1748 - 'name' => 'enable_write_with_ai',
1749 - 'type' => 'toggle',
1750 - 'priority' => 0,
1751 - 'label' => __( 'Write Docs with AI', 'betterdocs' ),
1752 - 'label_subtitle' => __( 'Generate AI based Documentation in your Gutenberg Editor', 'betterdocs' ),
1753 - 'enable_disable_text_active' => true,
1754 - 'default' => true
1755 - ],
1756 - 'enable_faq_write_with_ai' => [
1757 - 'name' => 'enable_faq_write_with_ai',
1758 - 'type' => 'toggle',
1759 - 'priority' => 5,
1760 - 'label' => __( 'Write FAQ with AI', 'betterdocs' ),
1761 - 'label_subtitle' => __( 'Generate AI based FAQ in your Editor', 'betterdocs' ),
1762 - 'enable_disable_text_active' => true,
1763 - 'default' => true
1764 - ],
1765 - 'ai_autowrite_api_key' => [
1766 - 'name' => 'ai_autowrite_api_key',
1767 - 'type' => 'text',
1768 - 'label' => __( 'API Key', 'betterdocs' ),
1769 - 'label_subtitle' => __( 'Check out this <a target="_blank" href="' . esc_url( 'https://betterdocs.co/docs/write-with-ai/' ) . '">documentation</a> to find out to generate your OpenAI API Key', 'betterdocs' ),
1770 - 'default' => '',
1771 - 'priority' => 10
1772 - ],
1773 - 'ai_autowrite_max_token' => [
1774 - 'name' => 'ai_autowrite_max_token',
1775 - 'type' => 'number',
1776 - 'label' => __( 'Set Max Tokens', 'betterdocs' ),
1777 - 'label_subtitle' => __( 'Documentation will be generated based on the Token Limits you have set. For more information on Token Limits, you can check out this <a target="_blank" href="' . esc_url( 'https://platform.openai.com/account/limits' ) . '">link</a>.', 'betterdocs' ),
1778 - 'default' => 1500,
1779 - 'priority' => 15
1780 - ]
1781 - ]
1782 - ] )
1783 - ]
1784 - ]
1785 - ] )
1786 - ];
537 + do_action_ref_array( 'betterdocs::settings::saved', [ $_saved, $_settings, $_old_settings, &$this ] );
1787 538
1788 - return apply_filters( 'betterdocs_settings_args', $settings );
1789 - }
539 + return $_saved;
540 + }
1790 541
1791 - public function import_export_settings( $settings ) {
1792 - if ( ! current_user_can( 'import' ) ) {
1793 - return $settings;
1794 - }
542 + public function views( $hook ) {
543 + return betterdocs()->views->get( 'admin/settings' );
544 + }
1795 545
1796 - $settings['tab-import-export'] = apply_filters( 'betterdocs_settings_tab_import_export', [
1797 - 'id' => 'tab-import-export',
1798 - 'name' => 'tab-import-export',
1799 - 'classes' => 'tab-import-export',
1800 - 'label' => __( 'Import / Export', 'betterdocs' ),
1801 - 'priority' => 80,
1802 - 'fields' => [
1803 - 'sections-import-export' => [
1804 - 'name' => 'sections-import-export',
1805 - 'type' => 'section',
1806 - 'label' => __( 'Import / Export', 'betterdocs' ),
1807 - 'priority' => 30,
1808 - 'fields' => [
1809 - 'all-tab-import-export' => [
1810 - 'id' => 'all-tab-import-export',
1811 - 'name' => 'all-tab-import-export',
1812 - 'label' => __( 'Import Export Settings', 'betterdocs' ),
1813 - 'classes' => 'tab-layout',
1814 - 'type' => "tab",
1815 - 'active' => "import",
1816 - 'completionTrack' => true,
1817 - 'sidebar' => false,
1818 - 'save' => false,
1819 - 'title' => false,
1820 - 'config' => [
1821 - 'active' => 'import',
1822 - 'sidebar' => false,
1823 - 'title' => false
1824 - ],
1825 - 'submit' => [
1826 - 'show' => false
1827 - ],
1828 - 'step' => [
1829 - 'show' => false
1830 - ],
1831 - 'priority' => 20,
1832 - 'fields' => [
1833 - 'import' => [
1834 - 'id' => 'import',
1835 - 'name' => 'import',
1836 - 'type' => 'section',
1837 - 'label' => __( 'Import', 'betterdocs' ),
1838 - 'priority' => 1,
1839 - 'fields' => [
1840 - 'import_tab_nested' => [
1841 - 'id' => 'import_tab_nested',
1842 - 'name' => 'import_tab_nested',
1843 - 'label' => __( 'Import', 'betterdocs' ),
1844 - 'classes' => 'tab-nested-layout',
1845 - 'type' => "tab",
1846 - 'active' => "import_docs_nested",
1847 - 'completionTrack' => true,
1848 - 'sidebar' => false,
1849 - 'save' => false,
1850 - 'title' => false,
1851 - 'config' => [
1852 - 'active' => 'import_docs_nested',
1853 - 'sidebar' => false,
1854 - 'title' => false
1855 - ],
1856 - 'submit' => [
1857 - 'show' => false
1858 - ],
1859 - 'step' => [
1860 - 'show' => false
1861 - ],
1862 - 'priority' => 1,
1863 - 'fields' => [
1864 - 'import_docs_nested' => [
1865 - 'id' => 'import_docs_nested',
1866 - 'name' => 'import_docs_nested',
1867 - 'type' => 'section',
1868 - 'label' => __( 'Import Docs', 'betterdocs' ),
1869 - 'priority' => 1,
1870 - 'fields' => [
1871 - 'import_docs' => [
1872 - 'name' => 'import_docs',
1873 - 'type' => 'importerupload',
1874 - 'label' => __( 'Import Docs', 'betterdocs' ),
1875 - 'label_subtitle' => wp_sprintf( __( 'To import your Docs, please upload the .xml / .csv file here. <a href="%1$s">Download sample csv file</a>', 'betterdocs' ), betterdocs()->assets->icon( 'BetterDocs-sample-data.csv', true ) ),
1876 - 'text' => [
1877 - 'normal' => __( 'Proceed', 'betterdocs' ),
1878 - 'saved' => __( 'Proceed', 'betterdocs' ),
1879 - 'loading' => __( 'Importing...', 'betterdocs' ),
1880 - 'exists_notice' => __( 'It seems like documentations with same slugs already exist on your website. What would you like to do?', 'betterdocs' )
1881 - ],
1882 - 'ajax' => [
1883 - 'on' => 'click',
1884 - 'api' => '/betterdocs/v1/import-docs',
1885 - 'swal' => [
1886 - 'text' => __( 'Import completed successfully.', 'betterdocs' ),
1887 - 'icon' => 'success',
1888 - 'autoClose' => 2000
1889 - ]
1890 - ],
1891 - 'file_type' => '.xml, .csv',
1892 - 'priority' => 1
1893 - ]
1894 - ]
1895 - ],
546 + public function save_default_settings() {
547 + $_settings = $this->get_all();
1896 548
1897 - 'import_settings_nested' => [
1898 - 'id' => 'import_settings_nested',
1899 - 'name' => 'import_settings_nested',
1900 - 'type' => 'section',
1901 - 'label' => __( 'Import Settings', 'betterdocs' ),
1902 - 'priority' => 1,
1903 - 'fields' => [
1904 - 'settings_importer' => [
1905 - 'name' => 'settings_importer',
1906 - 'type' => 'settingsuploader',
1907 - 'label' => __( 'Import Settings', 'notificationx' ),
1908 - 'label_subtitle' => __( 'To import BetterDocs Settings, please upload BetterDocs settings you have exported from another website in .json format', 'betterdocs' ),
1909 - 'reset' => __( 'Change', 'notificationx' ),
1910 - 'priority' => 1
1911 - ],
1912 - 'import_settings' => [
1913 - 'name' => 'import_settings',
1914 - 'type' => 'button',
1915 - 'rules' => Rules::is( 'settings_importer', null, true ),
1916 - 'text' => [
1917 - 'normal' => __( 'Proceed', 'betterdocs' ),
1918 - 'saved' => __( 'Proceed', 'betterdocs' ),
1919 - 'loading' => __( 'Importing...', 'betterdocs' )
1920 - ],
1921 - 'ajax' => [
1922 - 'on' => 'click',
1923 - 'api' => '/betterdocs/v1/import-settings',
1924 - 'data' => [
1925 - 'settings' => '@settings_importer'
1926 - ],
1927 - 'swal' => [
1928 - 'text' => __( 'Import completed successfully.', 'betterdocs' ),
1929 - 'icon' => 'success',
1930 - 'autoClose' => 1000
1931 - ],
1932 - 'reload' => true
1933 - ],
1934 - 'priority' => 2
1935 - ]
1936 - ]
1937 - ]
1938 - ]
1939 - ]
1940 - ]
1941 - ],
1942 - 'export' => [
1943 - 'id' => 'export',
1944 - 'name' => 'export',
1945 - 'type' => 'section',
1946 - 'label' => __( 'Export', 'betterdocs' ),
1947 - 'priority' => 1,
1948 - 'fields' => [
1949 - 'export_tab_nested' => [
1950 - 'id' => 'export_tab_nested',
1951 - 'name' => 'export_tab_nested',
1952 - 'label' => __( 'Export', 'betterdocs' ),
1953 - 'classes' => 'tab-nested-layout',
1954 - 'type' => "tab",
1955 - 'active' => "export_docs_nested",
1956 - 'completionTrack' => true,
1957 - 'sidebar' => false,
1958 - 'save' => false,
1959 - 'title' => false,
1960 - 'config' => [
1961 - 'active' => 'export_docs_nested',
1962 - 'sidebar' => false,
1963 - 'title' => false
1964 - ],
1965 - 'submit' => [
1966 - 'show' => false
1967 - ],
1968 - 'step' => [
1969 - 'show' => false
1970 - ],
1971 - 'priority' => 1,
1972 - 'fields' => [
1973 - 'export_docs_nested' => [
1974 - 'id' => 'export_docs_nested',
1975 - 'name' => 'export_docs_nested',
1976 - 'type' => 'section',
1977 - 'label' => __( 'Export Docs', 'betterdocs' ),
1978 - 'priority' => 1,
1979 - 'fields' => apply_filters( 'betterdocs_export_fields', [
1980 - 'export_type' => [
1981 - 'name' => 'export_type',
1982 - 'label' => __( 'Select Docs Type', 'betterdocs' ),
1983 - 'label_subtitle' => __( 'Choose an export type: All Docs, a specific Knowledge Base, or a Doc Category', 'betterdocs' ),
1984 - 'type' => 'select',
1985 - 'default' => 'docs',
1986 - 'priority' => 3,
1987 - 'search' => true,
1988 - 'options' => $this->normalize_options( apply_filters( 'betterdocs_export_type_options', [
1989 - 'docs' => __( 'Docs', 'betterdocs' ),
1990 - 'doc_category' => __( 'Docs Category', 'betterdocs' )
1991 - ] ) )
1992 - ],
1993 - 'export_docs' => [
1994 - 'name' => 'export_docs',
1995 - 'type' => 'checkbox-select',
1996 - 'label' => __( 'Select Docs', 'betterdocs' ),
1997 - 'label_subtitle' => __( 'Selected docs will be included in the export.', 'betterdocs' ),
1998 - 'priority' => 4,
1999 - 'multiple' => true,
2000 - 'search' => true,
2001 - 'default' => ['all'],
2002 - 'placeholder' => __( 'Select any', 'betterdocs' ),
2003 - 'options' => array_merge( [
2004 - [
2005 - 'value' => 'all',
2006 - 'label' => 'All'
2007 - ]
2008 - ], $this->docs() ),
2009 - 'filterValue' => 'all',
2010 - 'rules' => Rules::is( 'export_type', 'docs' )
2011 - ],
2012 - 'export_categories' => [
2013 - 'name' => 'export_categories',
2014 - 'type' => 'checkbox-select',
2015 - 'label' => __( 'Select Categories', 'betterdocs' ),
2016 - 'label_subtitle' => __( 'Selected categories and its docs will be included in the export.', 'betterdocs' ),
2017 - 'priority' => 6,
2018 - 'multiple' => true,
2019 - 'search' => true,
2020 - 'default' => ['all'],
2021 - 'placeholder' => __( 'Select any', 'betterdocs' ),
2022 - 'options' => $this->get_terms( 'doc_category' ),
2023 - 'filterValue' => 'all',
2024 - 'rules' => Rules::is( 'export_type', 'doc_category' )
2025 - ],
2026 - 'file_type' => [
2027 - 'name' => 'file_type',
2028 - 'label' => __( 'Select File Type', 'betterdocs' ),
2029 - 'label_subtitle' => __( 'Choose a file type', 'betterdocs' ),
2030 - 'type' => 'select',
2031 - 'default' => 'xml',
2032 - 'priority' => 7,
2033 - 'search' => true,
2034 - 'options' => $this->normalize_options( apply_filters( 'betterdocs_export_file_type_options', [
2035 - 'xml' => __( '.xml', 'betterdocs' ),
2036 - 'csv' => __( '.csv', 'betterdocs' )
2037 - ] ) )
2038 - ],
2039 - 'export_docs_btn' => [
2040 - 'name' => 'export_docs_btn',
2041 - 'text' => [
2042 - 'normal' => __( 'Proceed', 'betterdocs' ),
2043 - 'saved' => __( 'Proceed', 'betterdocs' ),
2044 - 'loading' => __( 'Exporting...', 'betterdocs' )
2045 - ],
2046 - 'type' => 'button',
2047 - 'priority' => 8,
2048 - 'ajax' => [
2049 - 'on' => 'click',
2050 - 'api' => '/betterdocs/v1/export-docs',
2051 - 'data' => [
2052 - 'export_type' => '@export_type',
2053 - 'export_docs' => '@export_docs',
2054 - 'export_kbs' => '@export_kbs',
2055 - 'export_categories' => '@export_categories',
2056 - 'file_type' => '@file_type'
2057 - ],
2058 - 'swal' => [
2059 - 'text' => __( 'Exported Successfully.', 'betterdocs' ),
2060 - 'icon' => 'success',
2061 - 'autoClose' => 2000
2062 - ]
2063 - ]
2064 - ]
2065 - ] )
2066 - ],
549 + return $this->database->save( $this->base_key, $_settings );
550 + }
2067 551
2068 - 'export_settings_nested' => [
2069 - 'id' => 'export_settings_nested',
2070 - 'name' => 'export_settings_nested',
2071 - 'type' => 'section',
2072 - 'label' => __( 'Export Settings', 'betterdocs' ),
2073 - 'priority' => 1,
2074 - 'fields' => [
2075 - 'export_settings' => [
2076 - 'name' => 'export_settings',
2077 - 'label' => __( 'Export Settings', 'betterdocs' ),
2078 - 'label_subtitle' => __( 'Simply click on “Export Settings” button to download your BetterDocs settings in .json format', 'betterdocs' ),
2079 - 'text' => [
2080 - 'normal' => __( 'Export Settings', 'betterdocs' ),
2081 - 'saved' => __( 'Export Settings', 'betterdocs' ),
2082 - 'loading' => __( 'Exporting...', 'betterdocs' )
2083 - ],
2084 - 'type' => 'button',
2085 - 'priority' => 8,
2086 - 'ajax' => [
2087 - 'on' => 'click',
2088 - 'api' => '/betterdocs/v1/export-settings',
2089 - 'data' => [
2090 - 'betterdocs_settings' => get_option( 'betterdocs_settings' )
2091 - ],
2092 - 'swal' => [
2093 - 'text' => __( 'File downloaded successfully.', 'betterdocs' ),
2094 - 'icon' => 'success',
2095 - 'autoClose' => 2000
2096 - ]
2097 - ]
2098 - ]
2099 - ]
2100 - ]
2101 - ]
2102 - ]
2103 - ]
2104 - ]
2105 - ]
2106 - ]
2107 - ]
2108 - ]
2109 - ]
2110 - ] );
552 + public function get_pages() {
553 + $_pages = betterdocs()->query->get_posts( [
554 + 'post_type' => 'page',
555 + 'numberposts' => - 1,
556 + 'post_status' => 'publish',
557 + 'posts_per_page' => - 1
558 + ] );
2111 559
2112 - return $settings;
2113 - }
560 + $__pages = [];
2114 561
2115 - public function normalize_options( $options ) {
2116 - return GlobalFields::normalize_fields( $options );
2117 - }
562 + if ( ! empty( $_pages ) ) {
563 + $__pages[0] = __( 'Select a Page', 'betterdocs' );
564 + foreach ( $_pages->posts as $page ) {
565 + $__pages[ $page->ID ] = esc_html( $page->post_title );
566 + }
567 + }
2118 568
2119 - public function get_texanomy() {
2120 - $docs_tax = $this->database->get_cache( 'betterdocs::settings::taxonomies' );
569 + return $__pages;
570 + }
2121 571
2122 - if ( $docs_tax ) {
2123 - return $docs_tax;
2124 - }
572 + public function settings_args() {
573 + $wp_roles = $this->normalize_options( $this->get_roles() );
2125 574
2126 - $taxonomies = get_taxonomies( [
2127 - 'object_type' => ['docs']
2128 - ], 'objects' );
575 + $settings = [
576 + 'id' => 'betterdocs_settings_metabox_wrapper',
577 + 'title' => __( 'betterdocs', 'betterdocs' ),
578 + 'object_types' => [ 'betterdocs' ],
579 + 'context' => 'normal',
580 + 'priority' => 'high',
581 + 'show_header' => false,
582 + 'tabnumber' => false,
583 + 'is_pro_active' => betterdocs()->is_pro_active(),
584 + 'logoURL' => betterdocs()->assets->icon( 'betterdocs-icon.svg', true ),
585 + 'layout' => 'vertical',
586 + 'config' => [
587 + 'active' => 'tab-general',
588 + 'sidebar' => true,
589 + 'title' => false
590 + ],
591 + 'submit' => [
592 + 'show' => true,
593 + 'label' => __( 'Save', 'betterdocs' ),
594 + 'loadingLabel' => __( 'Saving...', 'betterdocs' ),
595 + 'class' => 'save-settings',
596 + 'rules' => Rules::logicalRule( [
597 + Rules::is( 'config.active', 'tab-design', true ),
598 + Rules::is( 'config.active', 'tab-shortcodes', true ),
599 + Rules::is( 'config.active', 'tab-instant-answer', true ),
600 + Rules::is( 'config.active', 'tab-import-export', true ),
601 + Rules::is( 'config.active', 'tab-migration', true )
602 + ], 'and' )
603 + ],
604 + 'values' => betterdocs()->is_pro_active() ? $this->get_all() : array_merge( $this->get_all(), $this->pro_settings_default_values() ),
605 + 'tabs' => apply_filters( 'betterdocs_settings_tabs', [
606 + 'tab-general' => apply_filters( 'betterdocs_settings_tab_general', [
607 + 'id' => 'tab-general',
608 + 'label' => __( 'General', 'betterdocs' ),
609 + 'classes' => 'tab-general',
610 + 'priority' => 10,
611 + 'fields' => [
612 + 'title-general' => apply_filters( 'betterdocs_encyclopedia_settings', [
613 + 'name' => 'title-general-tab',
614 + 'type' => 'section',
615 + 'label' => __( 'General Settings', 'betterdocs' ),
616 + 'priority' => 10,
617 + 'fields' => [
618 + 'multiple_kb' => apply_filters( 'betterdocs_multi_kb_settings', [
619 + 'name' => 'multiple_kb',
620 + 'type' => 'toggle',
621 + 'label' => __( 'Multiple Knowledge Base', 'betterdocs' ),
622 + 'enable_disable_text_active' => true,
623 + 'default' => '',
624 + 'priority' => 1,
625 + 'is_pro' => true
626 + ] ),
627 + 'builtin_doc_page' => [
628 + 'name' => 'builtin_doc_page',
629 + 'type' => 'toggle',
630 + 'label' => __( 'Built-in Documentation Page', 'betterdocs' ),
631 + 'enable_disable_text_active' => true,
632 + 'default' => 1,
633 + 'priority' => 2
634 + ],
635 + 'breadcrumb_doc_title' => [
636 + 'name' => 'breadcrumb_doc_title',
637 + 'type' => 'text',
638 + 'label' => __( 'Documentation Page Title', 'betterdocs' ),
639 + 'default' => __( 'Docs', 'betterdocs' ),
640 + 'priority' => 3,
641 + 'rules' => Rules::is( 'builtin_doc_page', true )
642 + ],
643 + 'docs_slug' => [
644 + 'name' => 'docs_slug',
645 + 'type' => 'text',
646 + 'label' => __( 'BetterDocs Root Slug', 'betterdocs' ),
647 + 'default' => 'docs',
648 + 'priority' => 4,
649 + 'rules' => Rules::is( 'builtin_doc_page', true )
650 + ],
651 + 'docs_page' => [
652 + 'name' => 'docs_page',
653 + 'label' => __( 'Docs Page', 'betterdocs' ),
654 + 'type' => 'select',
655 + 'default' => 0,
656 + 'priority' => 5,
657 + 'search' => true,
658 + 'options' => $this->normalize_options( $this->get_pages() ),
659 + 'label_subtitle' => __( 'You will need to insert BetterDocs Shortcode inside the page. This page will be used as docs permalink.', 'betterdocs' ),
660 + 'rules' => Rules::is( 'builtin_doc_page', false )
661 + ],
2129 662
2130 - $docs_tax = [
2131 - 'all' => 'All Docs Archive',
2132 - 'docs' => 'Docs Page'
2133 - ];
2134 - foreach ( $taxonomies as $key => $value ) {
2135 - $docs_tax[$key] = $value->label;
2136 - }
2137 - unset( $docs_tax['doc_tag'] );
663 + 'category_slug' => [
664 + 'name' => 'category_slug',
665 + 'type' => 'text',
666 + 'label' => __( 'Custom Category Slug', 'betterdocs' ),
667 + 'default' => 'docs-category',
668 + 'priority' => 6
669 + ],
670 + 'tag_slug' => [
671 + 'name' => 'tag_slug',
672 + 'type' => 'text',
673 + 'label' => __( 'Custom Tag Slug', 'betterdocs' ),
674 + 'default' => 'docs-tag',
675 + 'priority' => 7
676 + ],
677 + 'permalink_structure' => [
678 + 'name' => 'permalink_structure',
679 + 'type' => 'permalink_structure',
680 + 'label' => __( 'Single Docs Permalink', 'betterdocs' ),
681 + 'default' => PostType::permalink_structure(),
682 + 'priority' => 8,
683 + 'tags' => $this->normalize_options( [
684 + '%doc_category%' => '%doc_category%',
685 + '%knowledge_base%' => '%knowledge_base%'
686 + ] ),
687 + 'label_subtitle' => __( 'Make sure to keep Docs Root Slug in the Single Docs Permalink. You are not able to keep it blank. You can use the available tags from below.', 'betterdocs' )
688 + ],
689 + 'enable_glossaries' => [
690 + 'name' => 'enable_glossaries',
691 + 'type' => 'toggle',
692 + 'label' => __( 'Show Glossary', 'betterdocs' ),
693 + 'label_subtitle' => __( 'Enable the glossary feature to allow users to look up definitions for terms used within your encyclopedia or glossaries themselves.', 'betterdocs' ),
694 + 'enable_disable_text_active' => true,
695 + 'default' => false,
696 + 'priority' => 9,
697 + 'is_pro' => true
698 + ],
699 + 'enable_encyclopedia' => [
700 + 'name' => 'enable_encyclopedia',
701 + 'type' => 'toggle',
702 + 'label' => __( 'Built-in Encyclopedia Page', 'betterdocs' ),
703 + 'enable_disable_text_active' => true,
704 + 'default' => false,
705 + 'priority' => 10,
706 + 'is_pro' => true
707 + ],
708 + 'enable_faq_schema' => [
709 + 'name' => 'enable_faq_schema',
710 + 'type' => 'toggle',
711 + 'label' => __( 'FAQ Schema', 'betterdocs' ),
712 + 'enable_disable_text_active' => true,
713 + 'default' => '',
714 + 'priority' => 14
715 + ],
716 + 'analytics_from' => [
717 + 'name' => 'analytics_from',
718 + 'type' => 'select',
719 + 'label' => __( 'Analytics From', 'betterdocs' ),
720 + 'options' => $this->normalize_options( [
721 + 'everyone' => __( 'Everyone', 'betterdocs' ),
722 + 'guests' => __( 'Guests Only', 'betterdocs' ),
723 + 'registered_users' => __( 'Registered Users Only', 'betterdocs' )
724 + ] ),
725 + 'default' => 'everyone',
726 + 'priority' => 15,
727 + 'is_pro' => true
728 + ],
729 + 'unique_visitor_count' => [
730 + 'name' => 'unique_visitor_count',
731 + 'type' => 'toggle',
732 + 'label' => __( 'Unique Visitor Count', 'betterdocs' ),
733 + 'enable_disable_text_active' => true,
734 + 'default' => false,
735 + 'priority' => 16,
736 + 'is_pro' => true
737 + ],
738 + 'exclude_bot_analytics' => [
739 + 'name' => 'exclude_bot_analytics',
740 + 'type' => 'toggle',
741 + 'label' => __( 'Exclude Bot Analytics', 'betterdocs' ),
742 + 'enable_disable_text_active' => true,
743 + 'default' => false,
744 + 'priority' => 17,
745 + 'is_pro' => true
746 + ]
2138 747
2139 - $docs_tax = $this->normalize_options( $docs_tax );
2140 - if ( count( $docs_tax ) > 2 ) {
2141 - $this->database->set_cache( 'betterdocs::settings::taxonomies', $docs_tax );
2142 - }
748 + ]
749 + ] )
750 + ]
751 + ] ),
752 + 'tab-layout' => apply_filters( 'betterdocs_settings_tab_layout', [
753 + 'id' => 'tab-layout',
754 + 'label' => __( 'Layout', 'betterdocs' ),
755 + 'classes' => 'tab-layout',
756 + 'priority' => 20,
757 + 'fields' => [
758 + 'title-layout' => [
759 + 'name' => 'title-layout-tab',
760 + 'type' => 'section',
761 + 'label' => __( 'Layout Settings', 'betterdocs' ),
762 + 'priority' => 20,
763 + 'fields' => [
764 + 'tab-sidebar-layout' => apply_filters( 'betterdocs_settings_tab_sidebar_layout', [
765 + 'id' => 'tab-sidebar-layout',
766 + 'name' => 'tab_sidebar_layout',
767 + 'label' => __( 'Layout Settings', 'betterdocs' ),
768 + 'classes' => 'tab-layout',
769 + 'type' => 'tab',
770 + 'active' => 'layout_documentation_page',
771 + 'completionTrack' => true,
772 + 'sidebar' => false,
773 + 'save' => false,
774 + 'title' => false,
775 + 'config' => [
776 + 'active' => 'layout_documentation_page',
777 + 'sidebar' => false,
778 + 'title' => false
779 + ],
780 + 'submit' => [
781 + 'show' => false
782 + ],
783 + 'step' => [
784 + 'show' => false
785 + ],
786 + 'priority' => 20,
787 + 'fields' => [
788 + 'layout_documentation_page' => [
789 + 'id' => 'layout_documentation_page',
790 + 'name' => 'layout_documentation_page',
791 + 'type' => 'section',
792 + 'label' => __( 'Documentation Page', 'betterdocs' ),
793 + 'priority' => 1,
794 + 'fields' => [
795 + 'tab-nested-layout-1' => [
796 + 'id' => 'tab-nested-layout-1',
797 + 'name' => 'tab_nested_layout_1',
798 + 'label' => __( 'Documentation Page', 'betterdocs' ),
799 + 'classes' => 'tab-nested-layout',
800 + 'type' => 'tab',
801 + 'active' => 'layout_documentation_page_general',
802 + 'completionTrack' => true,
803 + 'sidebar' => false,
804 + 'save' => false,
805 + 'title' => false,
806 + 'config' => [
807 + 'active' => 'layout_documentation_page_general',
808 + 'sidebar' => false,
809 + 'title' => false
810 + ],
811 + 'submit' => [
812 + 'show' => false
813 + ],
814 + 'step' => [
815 + 'show' => false
816 + ],
817 + 'priority' => 1,
818 + 'fields' => [
819 + 'layout_documentation_page_general' => [
820 + 'id' => 'layout_documentation_page_general',
821 + 'name' => 'layout_documentation_page_general',
822 + 'type' => 'section',
823 + 'label' => __( 'General', 'betterdocs' ),
824 + 'priority' => 1,
825 + 'fields' => [
826 + 'docs_list_icon' => [
827 + 'name' => 'docs_list_icon',
828 + 'type' => 'media',
829 + 'value' => '',
830 + 'label' => __( 'Docs List Icon', 'betterdocs' ),
831 + 'label_subtitle' => __( 'Upload your own preferred document list icon', 'betterdocs' ),
832 + 'priority' => 0
833 + ],
834 + 'category_title_link' => [
835 + 'name' => 'category_title_link',
836 + 'type' => 'toggle',
837 + 'label' => __( 'Category Title Link', 'betterdocs' ),
838 + 'label_subtitle' => __( 'This setting is applicable for category grid layout', 'betterdocs' ),
839 + 'enable_disable_text_active' => true,
840 + 'default' => false,
841 + 'priority' => 0
842 + ],
843 + 'masonry_layout' => [
844 + 'name' => 'masonry_layout',
845 + 'type' => 'toggle',
846 + 'label' => __( 'Masonry', 'betterdocs' ),
847 + 'enable_disable_text_active' => true,
848 + 'default' => 1,
849 + 'priority' => 1
850 + ],
851 + 'nested_subcategory' => [
852 + 'name' => 'nested_subcategory',
853 + 'type' => 'toggle',
854 + 'label' => __( 'Nested Sub Category', 'betterdocs' ),
855 + 'enable_disable_text_active' => true,
856 + 'default' => '',
857 + 'priority' => 2
858 + ],
859 + 'column_number' => [
860 + 'name' => 'column_number',
861 + 'type' => 'number',
862 + 'label' => __( 'Number Of Columns', 'betterdocs' ),
863 + 'label_subtitle' => __( 'This setting is not applicable for sleek layout.', 'betterdocs' ),
864 + 'default' => 3,
865 + 'priority' => 3
866 + ],
867 + 'posts_number' => apply_filters( 'betterdocs_posts_number', [
868 + 'name' => 'posts_number',
869 + 'type' => 'number',
870 + 'label' => __( 'Number Of Docs', 'betterdocs' ),
871 + 'label_subtitle' => __( 'This setting is not applicable for handbook layout.', 'betterdocs' ),
872 + 'default' => 10,
873 + 'priority' => 4
874 + ] ),
875 + 'post_count' => [
876 + 'name' => 'post_count',
877 + 'type' => 'toggle',
878 + 'label' => __( 'Doc Count', 'betterdocs' ),
879 + 'enable_disable_text_active' => true,
880 + 'default' => 1,
881 + 'priority' => 5
882 + ],
883 + 'count_text' => [
884 + 'name' => 'count_text',
885 + 'type' => 'text',
886 + 'label' => __( 'Count Text', 'betterdocs' ),
887 + 'default' => __( 'Docs', 'betterdocs' ),
888 + 'priority' => 6
889 + ],
890 + 'count_text_singular' => [
891 + 'name' => 'count_text_singular',
892 + 'type' => 'text',
893 + 'label' => __( 'Count Text Singular', 'betterdocs' ),
894 + 'default' => __( 'Doc', 'betterdocs' ),
895 + 'priority' => 7
896 + ],
897 + 'exploremore_btn' => [
898 + 'name' => 'exploremore_btn',
899 + 'type' => 'toggle',
900 + 'label' => __( 'Explore More Button', 'betterdocs' ),
901 + 'enable_disable_text_active' => true,
902 + 'default' => true,
903 + 'priority' => 8
904 + ],
905 + 'exploremore_btn_txt' => [
906 + 'name' => 'exploremore_btn_txt',
907 + 'type' => 'text',
908 + 'label' => __( 'Explore More Button Text', 'betterdocs' ),
909 + 'default' => __( 'Explore More', 'betterdocs' ),
910 + 'priority' => 9,
911 + 'rules' => Rules::is( 'exploremore_btn', true )
912 + ],
913 + 'betterdocs_popular_docs_text' => [
914 + 'name' => 'betterdocs_popular_docs_text',
915 + 'type' => 'text',
916 + 'label' => __( 'Popular Docs Text', 'betterdocs' ),
917 + 'default' => __( 'Popular Docs', 'betterdocs' ),
918 + 'priority' => 10,
919 + 'is_pro' => true
920 + ],
921 + 'betterdocs_popular_docs_number' => [
922 + 'name' => 'betterdocs_popular_docs_number',
923 + 'type' => 'number',
924 + 'label' => __( 'Popular Docs Number', 'betterdocs' ),
925 + 'default' => 10,
926 + 'priority' => 11,
927 + 'is_pro' => true
928 + ]
929 + ]
930 + ],
931 + 'layout_documentation_page_search' => [
932 + 'id' => 'layout_documentation_page_search',
933 + 'name' => 'layout_documentation_page_search',
934 + 'type' => 'section',
935 + 'label' => __( 'Search', 'betterdocs' ),
936 + 'priority' => 2,
937 + 'fields' => [
938 + 'live_search' => [
939 + 'name' => 'live_search',
940 + 'type' => 'toggle',
941 + 'label' => __( 'Live Search', 'betterdocs' ),
942 + 'enable_disable_text_active' => true,
943 + 'default' => 1,
944 + 'priority' => 1
945 + ],
946 + 'advance_search' => apply_filters( 'betterdocs_advance_search_settings', [
947 + 'name' => 'advance_search',
948 + 'type' => 'toggle',
949 + 'label' => __( 'Advanced Search', 'betterdocs' ),
950 + 'enable_disable_text_active' => true,
951 + 'default' => '',
952 + 'priority' => 2,
953 + 'is_pro' => true
954 + ] ),
955 + 'child_category_exclude' => apply_filters( 'child_category_exclude', [
956 + 'name' => 'child_category_exclude',
957 + 'type' => 'toggle',
958 + 'label' => __( 'Exclude Child Terms In Category Search', 'betterdocs' ),
959 + 'enable_disable_text_active' => true,
960 + 'default' => '',
961 + 'priority' => 3,
962 + 'is_pro' => true
963 + ] ),
964 + 'popular_keyword_limit' => apply_filters( 'betterdocs_popular_keyword_limit_settings', [
965 + 'name' => 'popular_keyword_limit',
966 + 'type' => 'number',
967 + 'label' => __( 'Minimum amount of Keywords Search', 'betterdocs' ),
968 + 'default' => 5,
969 + 'priority' => 4,
970 + 'is_pro' => true
971 + ] ),
972 + 'search_letter_limit' => [
973 + 'name' => 'search_letter_limit',
974 + 'type' => 'number',
975 + 'label' => __( 'Minimum Character Limit For Search Result', 'betterdocs' ),
976 + 'priority' => 5,
977 + 'default' => 3
978 + ],
979 + 'search_placeholder' => [
980 + 'name' => 'search_placeholder',
981 + 'type' => 'text',
982 + 'label' => __( 'Search Placeholder', 'betterdocs' ),
983 + 'default' => __( 'Search..', 'betterdocs' ),
984 + 'priority' => 6
985 + ],
986 + 'search_button_text' => apply_filters( 'betterdocs_search_button_text', [
987 + 'name' => 'search_button_text',
988 + 'type' => 'text',
989 + 'label' => __( 'Search Button Text', 'betterdocs' ),
990 + 'priority' => 7,
991 + 'default' => __( 'Search', 'betterdocs' ),
992 + 'is_pro' => true
993 + ] ),
994 + 'search_not_found_text' => [
995 + 'name' => 'search_not_found_text',
996 + 'type' => 'text',
997 + 'label' => __( 'Search Not Found Text', 'betterdocs' ),
998 + 'default' => 'Sorry, no docs were found.',
999 + 'priority' => 8
1000 + ],
1001 + 'search_result_image' => [
1002 + 'name' => 'search_result_image',
1003 + 'type' => 'toggle',
1004 + 'label' => __( 'Search Result Image', 'betterdocs' ),
1005 + 'enable_disable_text_active' => true,
1006 + 'default' => 1,
1007 + 'priority' => 9
1008 + ],
1009 + 'kb_based_search' => apply_filters( 'betterdocs_kb_based_search_settings', [
1010 + 'name' => 'kb_based_search',
1011 + 'type' => 'toggle',
1012 + 'label' => __( 'KB Based Search', 'betterdocs' ),
1013 + 'enable_disable_text_active' => true,
1014 + 'default' => '',
1015 + 'priority' => 10,
1016 + 'is_pro' => true,
1017 + 'rules' => Rules::is( 'multiple_kb', true )
1018 + ] )
1019 + ]
1020 + ],
1021 + 'layout_documentation_page_order_by' => [
1022 + 'id' => 'layout_documentation_page_order_by',
1023 + 'name' => 'layout_documentation_page_order_by',
1024 + 'type' => 'section',
1025 + 'label' => __( 'Order By', 'betterdocs' ),
1026 + 'priority' => 3,
1027 + 'fields' => [
1028 + 'terms_orderby' => [
1029 + 'name' => 'terms_orderby',
1030 + 'type' => 'select',
1031 + 'label' => __( 'Terms Order By', 'betterdocs' ),
1032 + 'default' => 'betterdocs_order',
1033 + 'options' => $this->normalize_options( apply_filters( 'betterdocs_terms_orderby_options', [
1034 + 'none' => __( 'No order', 'betterdocs' ),
1035 + 'name' => __( 'Name', 'betterdocs' ),
1036 + 'slug' => __( 'Slug', 'betterdocs' ),
1037 + 'term_group' => __( 'Term Group', 'betterdocs' ),
1038 + 'term_id' => __( 'Term ID', 'betterdocs' ),
1039 + 'id' => __( 'ID', 'betterdocs' ),
1040 + 'description' => __( 'Description', 'betterdocs' ),
1041 + 'parent' => __( 'Parent', 'betterdocs' ),
1042 + 'betterdocs_order' => __( 'BetterDocs Order', 'betterdocs' )
1043 + ] ) ),
1044 + 'priority' => 1
1045 + ],
1046 + 'terms_order' => [
1047 + 'name' => 'terms_order',
1048 + 'type' => 'select',
1049 + 'label' => __( 'Terms Order', 'betterdocs' ),
1050 + 'default' => 'ASC',
1051 + 'options' => $this->normalize_options( [
1052 + 'ASC' => 'Ascending',
1053 + 'DESC' => 'Descending'
1054 + ] ),
1055 + 'priority' => 3,
1056 + 'rules' => Rules::includes( 'terms_orderby', 'betterdocs_order', true )
1057 + ],
1058 + 'alphabetically_order_post' => [
1059 + 'name' => 'alphabetically_order_post',
1060 + 'type' => 'select',
1061 + 'label' => __( 'Docs Order By', 'betterdocs' ),
1062 + 'default' => 'betterdocs_order',
1063 + 'options' => $this->normalize_options( [
1064 + 'none' => __( 'No order', 'betterdocs' ),
1065 + 'ID' => __( 'Docs ID', 'betterdocs' ),
1066 + 'author' => __( 'Docs Author', 'betterdocs' ),
1067 + 'title' => __( 'Title', 'betterdocs' ),
1068 + 'date' => __( 'Date', 'betterdocs' ),
1069 + 'modified' => __( 'Last Modified Date', 'betterdocs' ),
1070 + 'parent' => __( 'Parent Id', 'betterdocs' ),
1071 + 'rand' => __( 'Random', 'betterdocs' ),
1072 + 'comment_count' => __( 'Comment Count', 'betterdocs' ),
1073 + 'menu_order' => __( 'Menu Order', 'betterdocs' ),
1074 + 'betterdocs_order' => __( 'BetterDocs Order', 'betterdocs' )
1075 + ] ),
1076 + 'priority' => 4
1077 + ],
1078 + 'docs_order' => [
1079 + 'name' => 'docs_order',
1080 + 'type' => 'select',
1081 + 'label' => __( 'Docs Order', 'betterdocs' ),
1082 + 'default' => 'ASC',
1083 + 'options' => $this->normalize_options( [
1084 + 'ASC' => 'Ascending',
1085 + 'DESC' => 'Descending'
1086 + ] ),
1087 + 'priority' => 5,
1088 + 'rules' => Rules::includes( 'alphabetically_order_post', 'betterdocs_order', true )
1089 + ]
1090 + ]
1091 + ]
1092 + ]
1093 + ]
1094 + ]
1095 + ],
1096 + 'layout_single_doc' => apply_filters( 'single_doc_setting_section', [
1097 + 'id' => 'layout_single_doc',
1098 + 'name' => 'layout_single_doc',
1099 + 'type' => 'section',
1100 + 'label' => __( 'Single Doc', 'betterdocs' ),
1101 + 'priority' => 2,
1102 + 'fields' => [
1103 + 'tab-nested-layout-2' => [
1104 + 'id' => 'tab-nested-layout-2',
1105 + 'name' => 'tab_nested_layout_2',
1106 + 'label' => __( 'Single Doc', 'betterdocs' ),
1107 + 'classes' => 'tab-nested-layout',
1108 + 'type' => 'tab',
1109 + 'active' => 'layout_single_doc_general',
1110 + 'completionTrack' => true,
1111 + 'sidebar' => false,
1112 + 'save' => false,
1113 + 'title' => false,
1114 + 'config' => [
1115 + 'active' => 'layout_single_doc_general',
1116 + 'sidebar' => false,
1117 + 'title' => false
1118 + ],
1119 + 'submit' => [
1120 + 'show' => false
1121 + ],
1122 + 'step' => [
1123 + 'show' => false
1124 + ],
1125 + 'priority' => 20,
1126 + 'fields' => [
1127 + 'layout_single_doc_general' => [
1128 + 'id' => 'layout_single_doc_general',
1129 + 'name' => 'layout_single_doc_general',
1130 + 'type' => 'section',
1131 + 'label' => __( 'General', 'betterdocs' ),
1132 + 'priority' => 5,
1133 + 'fields' => [
1134 + 'enable_post_title' => [
1135 + 'name' => 'enable_post_title',
1136 + 'type' => 'toggle',
1137 + 'label' => __( 'Doc Title', 'betterdocs' ),
1138 + 'enable_disable_text_active' => true,
1139 + 'default' => 1,
1140 + 'priority' => 1
1141 + ],
1142 + 'enable_sidebar_cat_list' => [
1143 + 'name' => 'enable_sidebar_cat_list',
1144 + 'type' => 'toggle',
1145 + 'label' => __( 'Sidebar Category List', 'betterdocs' ),
1146 + 'enable_disable_text_active' => true,
1147 + 'default' => 1,
1148 + 'priority' => 2
1149 + ],
1150 + 'enable_print_icon' => [
1151 + 'name' => 'enable_print_icon',
1152 + 'type' => 'toggle',
1153 + 'label' => __( 'Print Icon', 'betterdocs' ),
1154 + 'enable_disable_text_active' => true,
1155 + 'default' => 1,
1156 + 'priority' => 3
1157 + ],
1158 + 'enable_tags' => [
1159 + 'name' => 'enable_tags',
1160 + 'type' => 'toggle',
1161 + 'label' => __( 'Tags', 'betterdocs' ),
1162 + 'enable_disable_text_active' => true,
1163 + 'default' => 1,
1164 + 'priority' => 4
1165 + ],
1166 + 'show_last_update_time' => [
1167 + 'name' => 'show_last_update_time',
1168 + 'type' => 'toggle',
1169 + 'label' => __( 'Last Update Time', 'betterdocs' ),
1170 + 'enable_disable_text_active' => true,
1171 + 'default' => 1,
1172 + 'priority' => 5
1173 + ],
1174 + 'enable_navigation' => [
1175 + 'name' => 'enable_navigation',
1176 + 'type' => 'toggle',
1177 + 'label' => __( 'Navigation', 'betterdocs' ),
1178 + 'enable_disable_text_active' => true,
1179 + 'default' => 1,
1180 + 'priority' => 6
1181 + ],
1182 + 'enable_comment' => [
1183 + 'name' => 'enable_comment',
1184 + 'type' => 'toggle',
1185 + 'label' => __( 'Comment', 'betterdocs' ),
1186 + 'enable_disable_text_active' => true,
1187 + 'default' => '',
1188 + 'priority' => 7
1189 + ],
1190 + 'enable_credit' => [
1191 + 'name' => 'enable_credit',
1192 + 'type' => 'toggle',
1193 + 'label' => __( 'Show Powered by BetterDocs', 'betterdocs' ),
1194 + 'enable_disable_text_active' => true,
1195 + 'default' => '',
1196 + 'priority' => 8
1197 + ],
1198 + 'reaction_feedback_text' => [
1199 + 'name' => 'reaction_feedback_text',
1200 + 'type' => 'text',
1201 + 'label' => __( 'Reaction Feedback Text', 'betterdocs' ),
1202 + 'default' => __( 'Thanks for your feedback.', 'betterdocs' ),
1203 + 'priority' => 9
1204 + ],
1205 + 'enable_estimated_reading_time' => [
1206 + 'name' => 'enable_estimated_reading_time',
1207 + 'type' => 'toggle',
1208 + 'label' => __( 'Estimated Reading Time', 'betterdocs' ),
1209 + 'enable_disable_text_active' => true,
1210 + 'default' => 0,
1211 + 'priority' => 10
1212 + ],
1213 + 'estimated_reading_time_title' => [
1214 + 'name' => 'estimated_reading_time_title',
1215 + 'type' => 'text',
1216 + 'label' => __( 'Estimated Reading Time Title', 'betterdocs' ),
1217 + 'default' => '',
1218 + 'priority' => 11,
1219 + 'rules' => Rules::is( 'enable_estimated_reading_time', true )
1220 + ],
1221 + 'estimated_reading_time_text' => [
1222 + 'name' => 'estimated_reading_time_text',
1223 + 'type' => 'text',
1224 + 'label' => __( 'Estimated Reading Time Text', 'betterdocs' ),
1225 + 'default' => __( 'min read', 'betterdocs' ),
1226 + 'priority' => 12,
1227 + 'rules' => Rules::is( 'enable_estimated_reading_time', true )
1228 + ],
1229 + 'singular_estimated_reading_time_text' => [
1230 + 'name' => 'singular_estimated_reading_time_text',
1231 + 'type' => 'text',
1232 + 'label' => __( 'Estimated Reading Time Text Singular', 'betterdocs' ),
1233 + 'default' => __( 'min read', 'betterdocs' ),
1234 + 'priority' => 13,
1235 + 'rules' => Rules::is( 'enable_estimated_reading_time', true )
1236 + ]
1237 + ]
1238 + ],
1239 + 'layout_single_doc_TOC' => [
1240 + 'id' => 'layout_single_doc_TOC',
1241 + 'name' => 'layout_single_doc_TOC',
1242 + 'type' => 'section',
1243 + 'label' => __( 'TOC', 'betterdocs' ),
1244 + 'priority' => 5,
1245 + 'fields' => [
1246 + 'enable_toc' => [
1247 + 'name' => 'enable_toc',
1248 + 'type' => 'toggle',
1249 + 'label' => __( 'Table of Contents', 'betterdocs' ),
1250 + 'enable_disable_text_active' => true,
1251 + 'default' => 1,
1252 + 'priority' => 1
1253 + ],
1254 + 'toc_title' => [
1255 + 'name' => 'toc_title',
1256 + 'type' => 'text',
1257 + 'label' => __( 'TOC Title', 'betterdocs' ),
1258 + 'default' => __( 'Table of Contents', 'betterdocs' ),
1259 + 'priority' => 2,
1260 + 'rules' => Rules::is( 'enable_toc', true )
2143 1261
2144 - return $docs_tax;
2145 - }
1262 + ],
1263 + 'toc_hierarchy' => [
1264 + 'name' => 'toc_hierarchy',
1265 + 'type' => 'toggle',
1266 + 'label' => __( 'TOC Hierarchy', 'betterdocs' ),
1267 + 'enable_disable_text_active' => true,
1268 + 'default' => 1,
1269 + 'priority' => 3,
1270 + 'rules' => Rules::is( 'enable_toc', true )
1271 + ],
1272 + 'toc_list_number' => [
1273 + 'name' => 'toc_list_number',
1274 + 'type' => 'toggle',
1275 + 'label' => __( 'TOC List Number', 'betterdocs' ),
1276 + 'enable_disable_text_active' => true,
1277 + 'default' => 1,
1278 + 'priority' => 4,
1279 + 'rules' => Rules::is( 'enable_toc', true )
1280 + ],
1281 + 'toc_dynamic_title' => [
1282 + 'name' => 'toc_dynamic_title',
1283 + 'type' => 'toggle',
1284 + 'label' => __( 'Show TOC Title in Anchor Links', 'betterdocs' ),
1285 + 'enable_disable_text_active' => true,
1286 + 'default' => 0,
1287 + 'priority' => 5,
1288 + 'rules' => Rules::is( 'enable_toc', true )
1289 + ],
1290 + 'enable_sticky_toc' => [
1291 + 'name' => 'enable_sticky_toc',
1292 + 'type' => 'toggle',
1293 + 'label' => __( 'Sticky TOC', 'betterdocs' ),
1294 + 'enable_disable_text_active' => true,
1295 + 'default' => 1,
1296 + 'priority' => 6,
1297 + 'rules' => Rules::is( 'enable_toc', true )
1298 + ],
1299 + 'collapsible_toc_mobile' => [
1300 + 'name' => 'collapsible_toc_mobile',
1301 + 'type' => 'toggle',
1302 + 'label' => __( 'Collapsible TOC on small devices', 'betterdocs' ),
1303 + 'enable_disable_text_active' => true,
1304 + 'default' => '',
1305 + 'priority' => 7,
1306 + 'rules' => Rules::is( 'enable_toc', true )
1307 + ],
1308 + 'title_link_ctc' => [
1309 + 'name' => 'title_link_ctc',
1310 + 'type' => 'toggle',
1311 + 'label' => __( 'Title Link Copy To Clipboard', 'betterdocs' ),
1312 + 'enable_disable_text_active' => true,
1313 + 'default' => 1,
1314 + 'priority' => 8
1315 + ],
1316 + 'supported_heading_tag' => [
1317 + 'name' => 'supported_heading_tag',
1318 + 'label' => __( 'TOC Supported Heading Tag', 'betterdocs' ),
1319 + 'type' => 'checkbox-select',
1320 + 'multiple' => true,
1321 + 'priority' => 10,
1322 + 'default' => [
1323 + '1',
1324 + '2',
1325 + '3',
1326 + '4',
1327 + '5',
1328 + '6'
1329 + ],
1330 + 'options' => $this->normalize_options( [
1331 + '1' => 'H1',
1332 + '2' => 'H2',
1333 + '3' => 'H3',
1334 + '4' => 'H4',
1335 + '5' => 'H5',
1336 + '6' => 'H6'
1337 + ] ),
1338 + 'priority' => 9,
1339 + 'rules' => Rules::is( 'enable_toc', true )
1340 + ],
1341 + 'sticky_toc_offset' => [
1342 + 'name' => 'sticky_toc_offset',
1343 + 'type' => 'number',
1344 + 'label' => __( 'Content Offset', 'betterdocs' ),
1345 + 'default' => 100,
1346 + 'priority' => 10,
1347 + 'label_subtitle' => __( 'content offset from top on scroll.', 'betterdocs' ),
1348 + 'rules' => Rules::is( 'enable_toc', true )
1349 + ]
1350 + ]
1351 + ],
1352 + 'layout_single_doc_breadcrumb' => [
1353 + 'id' => 'layout_single_doc_breadcrumb',
1354 + 'name' => 'layout_single_doc_breadcrumb',
1355 + 'type' => 'section',
1356 + 'label' => __( 'Breadcrumb', 'betterdocs' ),
1357 + 'priority' => 5,
1358 + 'fields' => [
1359 + 'enable_breadcrumb' => [
1360 + 'name' => 'enable_breadcrumb',
1361 + 'type' => 'toggle',
1362 + 'label' => __( 'Breadcrumb', 'betterdocs' ),
1363 + 'enable_disable_text_active' => true,
1364 + 'default' => 1,
1365 + 'priority' => 1
1366 + ],
1367 + 'enable_breadcrumb_home_text' => [
1368 + 'name' => 'enable_breadcrumb_home_text',
1369 + 'type' => 'toggle',
1370 + 'label' => __( 'Enable Breadcrumb Home Text', 'betterdocs' ),
1371 + 'enable_disable_text_active' => true,
1372 + 'default' => true,
1373 + 'priority' => 2,
1374 + 'rules' => Rules::is( 'enable_breadcrumb', true )
1375 + ],
1376 + 'breadcrumb_home_text' => [
1377 + 'name' => 'breadcrumb_home_text',
1378 + 'type' => 'text',
1379 + 'label' => __( 'Breadcrumb Home Text', 'betterdocs' ),
1380 + 'default' => __( 'Home', 'betterdocs' ),
1381 + 'priority' => 3,
1382 + 'rules' => Rules::logicalRule(
1383 + [
1384 + Rules::is( 'enable_breadcrumb', true ),
1385 + Rules::is( 'enable_breadcrumb_home_text', true )
1386 + ],
1387 + 'and'
1388 + )
1389 + ],
1390 + 'breadcrumb_home_url' => [
1391 + 'name' => 'breadcrumb_home_url',
1392 + 'type' => 'text',
1393 + 'label' => __( 'Breadcrumb Home URL', 'betterdocs' ),
1394 + 'priority' => 4,
1395 + 'default' => get_home_url(),
1396 + 'rules' => Rules::is( 'enable_breadcrumb', true )
1397 + ],
1398 + 'enable_breadcrumb_category' => [
1399 + 'name' => 'enable_breadcrumb_category',
1400 + 'type' => 'toggle',
1401 + 'label' => __( 'Category on Breadcrumb', 'betterdocs' ),
1402 + 'enable_disable_text_active' => true,
1403 + 'default' => 1,
1404 + 'priority' => 5,
1405 + 'rules' => Rules::is( 'enable_breadcrumb', true )
1406 + ],
1407 + 'enable_breadcrumb_title' => [
1408 + 'name' => 'enable_breadcrumb_title',
1409 + 'type' => 'toggle',
1410 + 'label' => __( 'Title on Breadcrumb', 'betterdocs' ),
1411 + 'enable_disable_text_active' => true,
1412 + 'default' => 1,
1413 + 'priority' => 6,
1414 + 'rules' => Rules::is( 'enable_breadcrumb', true )
1415 + ]
1416 + ]
1417 + ],
1418 + 'layout_single_doc_email_feedback' => [
1419 + 'id' => 'layout_single_doc_email_feedback',
1420 + 'name' => 'layout_single_doc_email_feedback',
1421 + 'type' => 'section',
1422 + 'label' => __( 'Email Feedback', 'betterdocs' ),
1423 + 'priority' => 5,
1424 + 'fields' => [
1425 + 'email_feedback' => [
1426 + 'name' => 'email_feedback',
1427 + 'type' => 'toggle',
1428 + 'label' => __( 'Email Feedback', 'betterdocs' ),
1429 + 'enable_disable_text_active' => true,
1430 + 'default' => 1,
1431 + 'priority' => 1
1432 + ],
1433 + 'feedback_link_text' => [
1434 + 'name' => 'feedback_link_text',
1435 + 'type' => 'text',
1436 + 'label' => __( 'Feedback Link Text', 'betterdocs' ),
1437 + 'default' => __( 'Still stuck? How can we help?', 'betterdocs' ),
1438 + 'priority' => 2,
1439 + 'rules' => Rules::is( 'email_feedback', true )
1440 + ],
1441 + 'feedback_form_title' => [
1442 + 'name' => 'feedback_form_title',
1443 + 'type' => 'text',
1444 + 'label' => __( 'Feedback Form Title', 'betterdocs' ),
1445 + 'default' => __( 'Still stuck? How can we help?', 'betterdocs' ),
1446 + 'priority' => 3,
1447 + 'rules' => Rules::is( 'email_feedback', true )
1448 + ],
1449 + 'email_address' => [
1450 + 'name' => 'email_address',
1451 + 'type' => 'text',
1452 + 'label' => __( 'Email Address', 'betterdocs' ),
1453 + 'default' => get_option( 'admin_email' ),
1454 + 'priority' => 4,
1455 + 'label_subtitle' => __( 'The email address where the Feedback form will be sent', 'betterdocs' ),
1456 + 'rules' => Rules::is( 'email_feedback', true )
1457 + ],
1458 + 'feedback_url' => [
1459 + 'name' => 'feedback_url',
1460 + 'type' => 'text',
1461 + 'label' => __( 'Feedback URL', 'betterdocs' ),
1462 + 'default' => '',
1463 + 'priority' => 5,
1464 + 'rules' => Rules::is( 'email_feedback', true )
1465 + ]
1466 + ]
1467 + ],
1468 + [
1469 + 'id' => 'layout_single_doc_attachments',
1470 + 'name' => 'layout_single_doc_attachments',
1471 + 'type' => 'section',
1472 + 'label' => __( 'Attachments', 'betterdocs' ),
1473 + 'priority' => 6,
1474 + 'fields' => apply_filters( 'betterdocs_single_doc_attachments', [
1475 + 'show_attachment' => [
1476 + 'name' => 'show_attachment',
1477 + 'type' => 'toggle',
1478 + 'is_pro' => true,
1479 + 'priority' => 1,
1480 + 'label' => __( 'Show Attachment', 'betterdocs' ),
1481 + 'enable_disable_text_active' => true,
1482 + 'default' => false
1483 + ]
1484 + ] )
1485 + ],
1486 + [
1487 + 'id' => 'layout_single_doc_related_docs',
1488 + 'name' => 'layout_single_doc_related_docs',
1489 + 'type' => 'section',
1490 + 'label' => __( 'Related Docs', 'betterdocs' ),
1491 + 'priority' => 7,
1492 + 'fields' => apply_filters( 'betterdocs_single_doc_related_docs', [
1493 + 'show_related_docs' => [
1494 + 'name' => 'show_related_docs',
1495 + 'type' => 'toggle',
1496 + 'is_pro' => true,
1497 + 'priority' => 1,
1498 + 'label' => __( 'Show Related Docs', 'betterdocs' ),
1499 + 'enable_disable_text_active' => true,
1500 + 'default' => false
1501 + ]
1502 + ] )
1503 + ]
1504 + ]
1505 + ]
1506 + ]
1507 + ] ),
1508 + 'layout_archive_page' => [
1509 + 'id' => 'layout_archive_page',
1510 + 'name' => 'layout_archive_page',
1511 + 'type' => 'section',
1512 + 'label' => __( 'Archive Page', 'betterdocs' ),
1513 + 'priority' => 3,
1514 + 'fields' => [
1515 + 'enable_archive_sidebar' => [
1516 + 'name' => 'enable_archive_sidebar',
1517 + 'type' => 'toggle',
1518 + 'label' => __( 'Sidebar Category List', 'betterdocs' ),
1519 + 'enable_disable_text_active' => true,
1520 + 'default' => 1,
1521 + 'priority' => 31
1522 + ],
1523 + 'archive_nested_subcategory' => [
1524 + 'name' => 'archive_nested_subcategory',
1525 + 'type' => 'toggle',
1526 + 'label' => __( 'Nested Subcategory', 'betterdocs' ),
1527 + 'enable_disable_text_active' => true,
1528 + 'default' => 1,
1529 + 'priority' => 32
1530 + ],
1531 + 'archive_enable_pagination' => [
1532 + 'name' => 'archive_enable_pagination',
1533 + 'type' => 'toggle',
1534 + 'label' => __( 'Enable Pagination', 'betterdocs' ),
1535 + 'enable_disable_text_active' => true,
1536 + 'default' => false,
1537 + 'priority' => 33
1538 + ]
1539 + ]
1540 + ]
1541 + ]
1542 + ] )
1543 + ]
1544 + ]
1545 + ]
1546 + ] ),
1547 + 'tab-design' => apply_filters( 'betterdocs_settings_tab_design', [
1548 + 'id' => 'tab-design',
1549 + 'label' => __( 'Design', 'betterdocs' ),
1550 + 'priority' => 30,
1551 + 'fields' => [
1552 + 'title-design' => [
1553 + 'name' => 'title-design-tab',
1554 + 'type' => 'section',
1555 + 'label' => __( 'Design', 'betterdocs' ),
1556 + 'priority' => 30,
1557 + 'fields' => $this->design_tab()
1558 + ]
1559 + ]
1560 + ] ),
1561 + 'tab-shortcodes' => apply_filters( 'betterdocs_settings_tab_shortcodes', [
1562 + 'label' => __( 'Shortcodes', 'betterdocs' ),
1563 + 'id' => 'tab-shortcodes',
1564 + 'classes' => 'tab-shortcodes',
1565 + 'priority' => 40,
1566 + 'fields' => [
1567 + 'title-shortcodes' => [
1568 + 'name' => 'title-shortcodes-tab',
1569 + 'type' => 'section',
1570 + 'label' => __( 'Shortcodes', 'betterdocs' ),
1571 + 'priority' => 40,
1572 + 'searchable' => true,
1573 + 'searchPlaceholder' => __( 'Search for shortcode', 'betterdocs' ),
1574 + 'searchNotFoundMessage' => '<img src="' . betterdocs()->assets->icon( 'not-found.svg', true ) . '"/><p>' . __( 'No Shortcodes Found with these keywords', 'betterdocs' ) . '</p>',
1575 + 'fields' => apply_filters( 'betterdocs_shortcode_fields', [
1576 + 'search_form' => [
1577 + 'name' => 'search_form',
1578 + 'type' => 'copy-to-clipboard',
1579 + 'label' => __( 'Search Form', 'betterdocs' ),
1580 + 'default' => '[betterdocs_search_form]',
1581 + 'readOnly' => true,
1582 + 'priority' => 1,
1583 + 'description' => __( '[betterdocs_search_form placeholder="Search..." heading="Heading" subheading="Subheading" category_search="true" search_button="true" popular_search="true"]', 'betterdocs' ),
1584 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1585 + 'descriptionCopyable' => true
1586 + ],
1587 + 'feedback_form' => [
1588 + 'name' => 'feedback_form',
1589 + 'type' => 'copy-to-clipboard',
1590 + 'label' => __( 'Feedback Form', 'betterdocs' ),
1591 + 'default' => '[betterdocs_feedback_form]',
1592 + 'readOnly' => true,
1593 + 'priority' => 2,
1594 + 'description' => __( '[betterdocs_feedback_form button_text="Send"]', 'betterdocs' ),
1595 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1596 + 'descriptionCopyable' => true
1597 + ],
1598 + 'category_grid' => [
1599 + 'name' => 'category_grid',
1600 + 'type' => 'copy-to-clipboard',
1601 + 'label' => __( 'Category Grid- Layout 1', 'betterdocs' ),
1602 + 'default' => '[betterdocs_category_grid]',
1603 + 'readOnly' => true,
1604 + 'priority' => 3,
1605 + 'description' => __( '[betterdocs_category_grid show_count="true" show_icon="true" masonry="true" column="3" posts_per_page="5" nested_subcategory="true" terms="term_ID, term_ID" terms_orderby="" terms_order="" multiple_knowledge_base="" kb_slug="" title_tag="h2" orderby="" order="" ]', 'betterdocs' ),
1606 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1607 + 'descriptionCopyable' => true
1608 + ],
1609 + 'category_box' => [
1610 + 'name' => 'category_box',
1611 + 'type' => 'copy-to-clipboard',
1612 + 'label' => __( 'Category Box- Layout 2', 'betterdocs' ),
1613 + 'default' => '[betterdocs_category_box]',
1614 + 'readOnly' => true,
1615 + 'priority' => 4,
1616 + 'description' => __( '[betterdocs_category_box orderby="" column="" nested_subcategory="" terms="" terms_orderby="" show_icon="" kb_slug="" title_tag="h2" multiple_knowledge_base="false" border_bottom="false"]', 'betterdocs' ),
1617 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1618 + 'descriptionCopyable' => true
1619 + ],
1620 + 'category_list' => [
1621 + 'name' => 'category_list',
1622 + 'type' => 'copy-to-clipboard',
1623 + 'label' => __( 'Category List', 'betterdocs' ),
1624 + 'default' => '[betterdocs_category_list]',
1625 + 'readOnly' => true,
1626 + 'priority' => 5,
1627 + 'description' => __( '[betterdocs_category_list orderby="" order="" posts_per_page="" nested_subcategory="" terms="" terms_orderby="" terms_order="" kb_slug="" multiple_knowledge_base="false" title_tag="h2"]', 'betterdocs' ),
1628 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1629 + 'descriptionCopyable' => true
1630 + ],
1631 + 'faq_modern_layout' => [
1632 + 'name' => 'faq_modern_layout',
1633 + 'type' => 'copy-to-clipboard',
1634 + 'label' => __( 'FAQ Layout - 1', 'betterdocs' ),
1635 + 'default' => '[betterdocs_faq_list_modern]',
1636 + 'readOnly' => true,
1637 + 'priority' => 13,
1638 + 'description' => __( '[betterdocs_faq_list_modern groups="group_id" class="" group_exclude="group_id" faq_heading="Frequently Asked Questions"]', 'betterdocs' ),
1639 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1640 + 'descriptionCopyable' => true
1641 + ],
1642 + 'faq_classic_layout' => [
1643 + 'name' => 'faq_classic_layout',
1644 + 'type' => 'copy-to-clipboard',
1645 + 'label' => __( 'FAQ Layout - 2', 'betterdocs' ),
1646 + 'default' => '[betterdocs_faq_list_classic]',
1647 + 'readOnly' => true,
1648 + 'priority' => 14,
1649 + 'description' => __( '[betterdocs_faq_list_classic groups="group_id" class="" group_exclude="group_id" faq_heading="Frequently Asked Questions"]', 'betterdocs' ),
1650 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1651 + 'descriptionCopyable' => true
1652 + ]
1653 + ] )
1654 + ]
1655 + ]
1656 + ] ),
1657 + 'tab-advance-settings' => apply_filters( 'betterdocs_settings_tab_advance', [
1658 + 'id' => 'tab-advance-settings',
1659 + 'label' => __( 'Advanced Settings', 'betterdocs' ),
1660 + 'priority' => 50,
1661 + 'fields' => [
1662 + 'title-advance-settings' => [
1663 + 'name' => 'title-advance-settings-tab',
1664 + 'type' => 'section',
1665 + 'label' => __( 'Advanced Settings', 'betterdocs' ),
1666 + 'priority' => 50,
1667 + 'fields' => apply_filters( 'betterdocs_internal_kb_fields', [
1668 + 'article_roles' => [
1669 + 'name' => 'article_roles',
1670 + 'type' => 'checkbox-select',
1671 + 'label' => __( 'Who Can Write Docs?', 'betterdocs' ),
1672 + 'priority' => 1,
1673 + 'multiple' => true,
1674 + 'search' => true,
1675 + 'is_pro' => true,
1676 + 'default' => [ 'administrator' ],
1677 + 'options' => $wp_roles
1678 + ],
1679 + 'settings_roles' => [
1680 + 'name' => 'settings_roles',
1681 + 'type' => 'checkbox-select',
1682 + 'label' => __( 'Who Can Edit Settings?', 'betterdocs' ),
1683 + 'priority' => 2,
1684 + 'multiple' => true,
1685 + 'is_pro' => true,
1686 + 'search' => true,
1687 + 'default' => [ 'administrator' ],
1688 + 'options' => $wp_roles
1689 + ],
1690 + 'analytics_roles' => [
1691 + 'name' => 'analytics_roles',
1692 + 'type' => 'checkbox-select',
1693 + 'label' => __( 'Who Can Check Analytics?', 'betterdocs' ),
1694 + 'priority' => 3,
1695 + 'multiple' => true,
1696 + 'is_pro' => true,
1697 + 'search' => true,
1698 + 'default' => [ 'administrator' ],
1699 + 'options' => $wp_roles
1700 + ],
1701 + 'enable_content_restriction' => [
1702 + 'name' => 'enable_content_restriction',
1703 + 'type' => 'toggle',
1704 + 'is_pro' => true,
1705 + 'priority' => 4,
1706 + 'label' => __( 'Internal Knowledge Base', 'betterdocs' ),
1707 + 'enable_disable_text_active' => true,
1708 + 'default' => [ 'all' ]
1709 + ],
1710 + 'content_visibility' => [
1711 + 'name' => 'content_visibility',
1712 + 'type' => 'checkbox-select',
1713 + 'label' => __( 'Restrict Access to', 'betterdocs' ),
1714 + 'label_subtitle' => __( 'Only selected User Roles will be able to view your Knowledge Base', 'betterdocs' ),
1715 + 'is_pro' => true,
1716 + 'priority' => 5,
1717 + 'multiple' => true,
1718 + 'search' => true,
1719 + 'default' => [ 'all' ],
1720 + 'placeholder' => __( 'Select any', 'betterdocs' ),
1721 + 'options' => $this->normalize_options( array_merge( [
1722 + 'all' => __( 'All logged in users', 'betterdocs' )
1723 + ], wp_roles()->role_names ) ),
1724 + 'rules' => Rules::is( 'enable_content_restriction', true ),
1725 + 'filterValue' => 'all'
1726 + ],
1727 + 'restrict_template' => [
1728 + 'name' => 'restrict_template',
1729 + 'type' => 'checkbox-select',
1730 + 'label' => __( 'Restriction on Docs', 'betterdocs' ),
1731 + 'label_subtitle' => __( 'Selected Docs pages will be restricted', 'betterdocs' ),
1732 + 'is_pro' => true,
1733 + 'priority' => 6,
1734 + 'multiple' => true,
1735 + 'search' => true,
1736 + 'default' => [ 'all' ],
1737 + 'placeholder' => __( 'Select any', 'betterdocs' ),
1738 + 'options' => $this->get_texanomy(),
1739 + 'rules' => Rules::is( 'enable_content_restriction', true ),
1740 + 'filterValue' => 'all'
1741 + ],
1742 + 'restrict_category' => [
1743 + 'name' => 'restrict_category',
1744 + 'type' => 'checkbox-select',
1745 + 'label' => __( 'Restriction on Docs Categories', 'betterdocs' ),
1746 + 'label_subtitle' => __( 'Selected Docs categories will be restricted', 'betterdocs' ),
1747 + 'is_pro' => true,
1748 + 'priority' => 7,
1749 + 'multiple' => true,
1750 + 'search' => true,
1751 + 'default' => [ 'all' ],
1752 + 'placeholder' => __( 'Select any', 'betterdocs' ),
1753 + 'options' => $this->get_terms( 'doc_category' ),
1754 + 'rules' => Rules::is( 'enable_content_restriction', true ),
1755 + 'filterValue' => 'all'
1756 + ],
1757 + 'restricted_redirect_url' => [
1758 + 'name' => 'restricted_redirect_url',
1759 + 'type' => 'text',
1760 + 'label' => __( 'Redirect URL', 'betterdocs' ),
1761 + 'label_subtitle' => __( 'Set a custom URL to redirect users without permissions when they try to access internal knowledge base. By default, restricted content will redirect to the "404 not found" page', 'betterdocs' ),
1762 + 'default' => '',
1763 + 'placeholder' => 'https://',
1764 + 'is_pro' => true,
1765 + 'priority' => 9,
1766 + 'rules' => Rules::is( 'enable_content_restriction', true )
1767 + ]
1768 + ] )
1769 + ]
1770 + ]
1771 + ] ),
1772 + 'tab-email-reporting' => apply_filters( 'betterdocs_settings_tab_email_reporting', [
1773 + 'id' => 'tab-email-reporting',
1774 + 'label' => __( 'Email Reporting', 'betterdocs' ),
1775 + 'priority' => 60,
1776 + 'fields' => [
1777 + 'title-email-reporting' => [
1778 + 'name' => 'title-email-reporting-tab',
1779 + 'type' => 'section',
1780 + 'label' => __( 'Email Reporting', 'betterdocs' ),
1781 + 'priority' => 60,
1782 + 'fields' => [
1783 + 'enable_reporting' => [
1784 + 'name' => 'enable_reporting',
1785 + 'label' => __( 'Email Reporting', 'betterdocs' ),
1786 + 'enable_disable_text_active' => true,
1787 + 'type' => 'toggle',
1788 + 'priority' => 1,
1789 + 'default' => 0
1790 + ],
1791 + 'reporting_frequency' => apply_filters( 'betterdocs_reporting_frequency_settings', [
1792 + 'name' => 'reporting_frequency',
1793 + 'type' => 'select',
1794 + 'label' => __( 'Reporting Frequency', 'betterdocs' ),
1795 + 'default' => 'betterdocs_weekly',
1796 + 'priority' => 2,
1797 + 'is_pro' => true,
1798 + 'options' => $this->normalize_options( [
1799 + 'betterdocs_daily' => __( 'Once Daily', 'betterdocs' ),
1800 + 'betterdocs_weekly' => __( 'Once Weekly', 'betterdocs' ),
1801 + 'betterdocs_monthly' => __( 'Once Monthly', 'betterdocs' )
1802 + ] ),
1803 + 'rules' => Rules::is( 'enable_reporting', true )
1804 + ] ),
1805 + 'reporting_day' => [
1806 + 'name' => 'reporting_day',
1807 + 'type' => 'select',
1808 + 'label' => __( 'Reporting Day', 'betterdocs' ),
1809 + 'default' => 'monday',
1810 + 'rules' => Rules::logicalRule( [
1811 + Rules::is( 'enable_reporting', true ),
1812 + Rules::is( 'reporting_frequency', 'betterdocs_weekly' )
1813 + ], 'and' ),
1814 + 'priority' => 3,
1815 + 'options' => $this->normalize_options( [
1816 + 'sunday' => __( 'Sunday', 'betterdocs' ),
1817 + 'monday' => __( 'Monday', 'betterdocs' ),
1818 + 'tuesday' => __( 'Tuesday', 'betterdocs' ),
1819 + 'wednesday' => __( 'Wednesday', 'betterdocs' ),
1820 + 'thursday' => __( 'Thursday', 'betterdocs' ),
1821 + 'friday' => __( 'Friday', 'betterdocs' ),
1822 + 'saturday' => __( 'Saturday', 'betterdocs' )
1823 + ] ),
1824 + 'label_subtitle' => __( 'This is only applicable for the “Weekly” report', 'betterdocs' )
1825 + ],
1826 + 'select_reporting_data' => apply_filters( 'betterdocs_select_reporting_data_settings', [
1827 + 'name' => 'select_reporting_data',
1828 + 'type' => 'checkbox-select',
1829 + 'label' => __( 'Select Reporting Data', 'betterdocs' ),
1830 + 'priority' => 4,
1831 + 'multiple' => true,
1832 + 'options' => $this->normalize_options( [
1833 + 'overview' => 'Overview',
1834 + 'top-docs' => 'Top Docs',
1835 + 'most-search' => 'Most Searched Keywords'
1836 + ] ),
1837 + 'default' => [ 'overview', 'top-docs', 'most-search' ],
1838 + 'is_pro' => true,
1839 + 'rules' => Rules::is( 'enable_reporting', true )
1840 + ] ),
1841 + 'reporting_email' => [
1842 + 'name' => 'reporting_email',
1843 + 'type' => 'text',
1844 + 'label' => __( 'Reporting Email', 'betterdocs' ),
1845 + 'default' => get_option( 'admin_email' ),
1846 + 'priority' => 5,
1847 + 'rules' => Rules::is( 'enable_reporting', true )
1848 + ],
1849 + 'reporting_subject' => apply_filters( 'betterdocs_reporting_subject_settings', [
1850 + 'name' => 'reporting_subject',
1851 + 'type' => 'textarea',
1852 + 'label' => __( 'Reporting Email Subject', 'betterdocs' ),
1853 + 'default' => wp_sprintf( // Translators: %s is replaced with the website name.
1854 + __( 'Your Documentation Performance of %s Website', 'betterdocs' ), get_bloginfo( 'name' ) ),
1855 + 'priority' => 6,
1856 + 'is_pro' => true,
1857 + 'rules' => Rules::is( 'enable_reporting', true )
1858 + ] ),
1859 + 'test_report' => [
1860 + 'name' => 'test_report',
1861 + 'label' => __( 'Reporting Test', 'betterdocs' ),
1862 + 'text' => __( 'Test Report', 'betterdocs' ),
1863 + 'type' => 'button',
1864 + 'priority' => 7,
1865 + 'rules' => Rules::is( 'enable_reporting', true ),
1866 + 'ajax' => [
1867 + 'on' => 'click',
1868 + 'api' => '/betterdocs/v1/reporting-test',
1869 + 'data' => [
1870 + 'enable_reporting' => '@enable_reporting',
1871 + 'select_reporting_data' => '@select_reporting_data',
1872 + 'reporting_subject' => '@reporting_subject',
1873 + 'reporting_email' => '@reporting_email',
1874 + 'reporting_day' => '@reporting_day',
1875 + 'reporting_frequency' => '@reporting_frequency'
1876 + ],
1877 + 'swal' => [
1878 + 'text' => __( 'Successfully Sent a Test Report in Your Email.', 'betterdocs' ),
1879 + 'icon' => 'success',
1880 + 'autoClose' => 2000
1881 + ]
1882 + ]
1883 + ]
1884 + ]
1885 + ]
1886 + ]
1887 + ] ),
1888 + 'tab-instant-answer' => apply_filters( 'betterdocs_settings_tab_instant_answer', [
1889 + 'id' => 'tab-instant-answer',
1890 + 'name' => 'tab-instant-answer',
1891 + 'type' => 'section',
1892 + 'label' => __( 'Instant Answer', 'betterdocs' ),
1893 + 'save' => false,
1894 + 'priority' => 70,
1895 + 'fields' => [
1896 + 'title-instant-answer' => [
1897 + 'name' => 'title-instant-answer-tab',
1898 + 'type' => 'section',
1899 + 'label' => __( 'Instant Answer', 'betterdocs' ),
1900 + 'priority' => 80,
1901 + 'save' => false,
1902 + 'showSubmit' => false,
1903 + 'fields' => apply_filters( 'betterdocs_instant_answer_fields', [
1904 + 'enable_disable_wrapper' => [
1905 + 'name' => 'enable_disable_wrapper',
1906 + 'type' => 'section',
1907 + 'priority' => 0,
1908 + 'save' => false,
1909 + 'fields' => [
1910 + 'enable_disable' => [
1911 + 'name' => 'enable_disable',
1912 + 'type' => 'toggle',
1913 + 'priority' => 100,
1914 + 'description' => __( 'Enable Instant Answer', 'betterdocs' ),
1915 + 'enable_disable_text_active' => false,
1916 + 'default' => false,
1917 + 'is_pro' => true
1918 + ]
1919 + ]
1920 + ]
1921 + ] )
1922 + ]
1923 + ]
1924 + ] ),
1925 + 'tab-ai-chatbot' => [
1926 + 'id' => 'tab-ai-chatbot',
1927 + 'name' => 'tab-ai-chatbot',
1928 + 'type' => 'section',
1929 + 'label' => __( 'AI Chatbot', 'betterdocs' ),
1930 + // 'is_pro' => ! defined('BETTERDOCS_PRO_VERSION'),
1931 + 'priority' => 75,
1932 + 'save' => false,
1933 + 'submit' => [
1934 + 'show' => false
1935 + ],
2146 1936
2147 - public function get_terms( $taxonomy ) {
2148 - $_cache_key = 'betterdocs::settings::terms::' . trim( $taxonomy );
2149 - $docs_tax = $this->database->get_cache( $_cache_key );
1937 + 'fields' => [
1938 + 'title-ai-chatbot' => apply_filters( 'betterdocs_settings_ai_chatbot_fields', [
1939 + 'name' => 'title-ai-chatbot-tab',
1940 + 'type' => 'section',
1941 + 'label' => __( 'AI Chatbot', 'betterdocs' ),
1942 + 'priority' => 60,
1943 + 'save' => false,
1944 + 'submit' => [
1945 + 'show' => false
1946 + ],
2150 1947
2151 - if ( $docs_tax ) {
2152 - return $docs_tax;
2153 - }
1948 + 'fields' => [
1949 + 'enable_ai_chatbot' => [
1950 + 'name' => 'enable_ai_chatbot',
1951 + 'label' => __( 'AI Chatbot', 'betterdocs' ),
1952 + 'description' => __( 'Enable AI Chatbot', 'betterdocs' ),
1953 + 'type' => 'toggle',
1954 + 'priority' => 5,
1955 + 'default' => 0,
1956 + 'is_pro' => true,
1957 + 'is_license_active' => false,
1958 + 'disabled' => ! betterdocs()->is_pro_active() || ! defined( 'BETTERDOCS_CHATBOT_FILE' )
1959 + ],
1960 + ]
1961 + ] ),
1962 + ]
1963 + ],
1964 + 'tab-ai-autowrite' => [
1965 + 'id' => 'tab-ai-autowrite',
1966 + 'name' => 'tab-ai-autowrite',
1967 + 'type' => 'section',
1968 + 'label' => __( 'Write with AI', 'betterdocs' ),
1969 + 'priority' => 75,
1970 + 'fields' => [
1971 + 'title-ai-autowrite' => apply_filters( 'betterdocs_settings_ai_autowrite_fields', [
1972 + 'name' => 'title-ai-autowrite-tab',
1973 + 'type' => 'section',
1974 + 'label' => __( 'Write with AI', 'betterdocs' ),
1975 + 'priority' => 60,
1976 + 'fields' => [
1977 + 'enable_write_with_ai' => [
1978 + 'name' => 'enable_write_with_ai',
1979 + 'type' => 'toggle',
1980 + 'priority' => 0,
1981 + 'label' => __( 'Write Docs with AI', 'betterdocs' ),
1982 + 'label_subtitle' => __( 'Generate AI based Documentation in your Gutenberg Editor', 'betterdocs' ),
1983 + 'enable_disable_text_active' => true,
1984 + 'default' => true
1985 + ],
1986 + 'enable_faq_write_with_ai' => [
1987 + 'name' => 'enable_faq_write_with_ai',
1988 + 'type' => 'toggle',
1989 + 'priority' => 5,
1990 + 'label' => __( 'Write FAQ with AI', 'betterdocs' ),
1991 + 'label_subtitle' => __( 'Generate AI based FAQ in your Editor', 'betterdocs' ),
1992 + 'enable_disable_text_active' => true,
1993 + 'default' => true
1994 + ],
1995 + 'ai_autowrite_api_key' => [
1996 + 'name' => 'ai_autowrite_api_key',
1997 + 'type' => 'text',
1998 + 'label' => __( 'API Key', 'betterdocs' ),
1999 + 'label_subtitle' => sprintf( /* translators: %s is a link to the documentation about generating an OpenAI API key. */ __( 'Check out this <a target="_blank" href="%s">documentation</a> to find out how to generate your OpenAI API Key.', 'betterdocs' ), esc_url( 'https://betterdocs.co/docs/write-with-ai/' ) ),
2000 + 'default' => '',
2001 + 'priority' => 10
2002 + ],
2003 + 'ai_autowrite_max_token' => [
2004 + 'name' => 'ai_autowrite_max_token',
2005 + 'type' => 'number',
2006 + 'label' => __( 'Set Max Tokens', 'betterdocs' ),
2007 + 'label_subtitle' => sprintf( // translators: %s is a link to more information about token limits.
2008 + __( 'Documentation will be generated based on the Token Limits you have set. For more information on Token Limits, you can check out this <a target="_blank" href="%s">link</a>.', 'betterdocs' ), esc_url( 'https://platform.openai.com/account/limits' ) ),
2009 + 'default' => 1500,
2010 + 'priority' => 15
2011 + ]
2012 + ]
2013 + ] )
2014 + ]
2015 + ]
2016 + ] ),
2017 + 'TAB_AI_CHATBOT' => get_option( 'enable_ai_chatbot' ),
2018 + 'CHATBOT_LICENSE' => get_option( 'betterdocs_chatbot_software__license_status' ),
2019 + 'PRO_ACTIVE' => is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' ),
2020 + 'PRO_LICENSE' => get_option( 'betterdocs_pro_software__license_status' ),
2021 + ];
2154 2022
2155 - $get_terms = get_terms( [
2156 - 'taxonomy' => $taxonomy,
2157 - 'hide_empty' => false
2158 - ] );
2023 + $settings = array_merge( $settings, $this->chatbot_active_localize() );
2159 2024
2160 - $terms = [
2161 - 'all' => 'All'
2162 - ];
2025 + return apply_filters( 'betterdocs_settings_args', $settings );
2026 + }
2163 2027
2164 - if ( ! empty( $get_terms ) && ! is_wp_error( $get_terms ) ) {
2165 - foreach ( $get_terms as $value ) {
2166 - if ( isset( $value->slug ) && isset( $value->name ) ) {
2167 - $terms[$value->slug] = $value->name;
2168 - }
2169 - }
2170 - }
2028 + /**
2029 + * @return array
2030 + */
2031 + public function chatbot_active_localize() {
2032 + return [
2033 + 'CHATBOT_ACTIVE' => is_plugin_active( 'betterdocs-ai-chatbot/betterdocs-ai-chatbot.php' )
2034 + ];
2035 + }
2171 2036
2172 - $terms = $this->normalize_options( $terms );
2173 - if ( count( $terms ) > 1 ) {
2174 - $this->database->set_cache( $_cache_key, $terms );
2175 - }
2037 + /**
2038 + * Call This Function As Helper, When Pro Is Deactivated, To Be Used As Settings Default Values, When Betterdocs Pro Is Deactivated
2039 + *
2040 + * @return array
2041 + */
2042 + public function pro_settings_default_values() {
2043 + return [
2044 + 'multiple_kb' => false,
2045 + 'enable_glossaries' => false,
2046 + 'enable_encyclopedia' => false,
2047 + 'analytics_from' => false,
2048 + 'unique_visitor_count' => false,
2049 + 'exclude_bot_analytics' => false,
2050 + 'show_attachment' => false,
2051 + 'show_related_docs' => false,
2052 + 'advance_search' => false,
2053 + 'child_category_exclude' => false,
2054 + 'kb_based_search' => false,
2055 + 'enable_disable' => false,
2056 + 'enable_content_restriction' => false
2057 + ];
2058 + }
2176 2059
2177 - return $terms;
2178 - }
2060 + public function import_export_settings( $settings ) {
2061 + if ( ! current_user_can( 'import' ) ) {
2062 + return $settings;
2063 + }
2179 2064
2180 - /**
2181 - * Get all docs
2182 - */
2183 - public function docs() {
2184 - $docs = $this->database->get_cache( 'betterdocs::settings::all_docs' );
2065 + $settings['tab-import-export'] = apply_filters( 'betterdocs_settings_tab_import_export', [
2066 + 'id' => 'tab-import-export',
2067 + 'name' => 'tab-import-export',
2068 + 'classes' => 'tab-import-export',
2069 + 'label' => __( 'Import / Export', 'betterdocs' ),
2070 + 'priority' => 80,
2071 + 'fields' => [
2072 + 'sections-import-export' => [
2073 + 'name' => 'sections-import-export',
2074 + 'type' => 'section',
2075 + 'label' => __( 'Import / Export', 'betterdocs' ),
2076 + 'priority' => 30,
2077 + 'fields' => [
2078 + 'all-tab-import-export' => [
2079 + 'id' => 'all-tab-import-export',
2080 + 'name' => 'all-tab-import-export',
2081 + 'label' => __( 'Import Export Settings', 'betterdocs' ),
2082 + 'classes' => 'tab-layout',
2083 + 'type' => 'tab',
2084 + 'active' => 'import',
2085 + 'completionTrack' => true,
2086 + 'sidebar' => false,
2087 + 'save' => false,
2088 + 'title' => false,
2089 + 'config' => [
2090 + 'active' => 'import',
2091 + 'sidebar' => false,
2092 + 'title' => false
2093 + ],
2094 + 'submit' => [
2095 + 'show' => false
2096 + ],
2097 + 'step' => [
2098 + 'show' => false
2099 + ],
2100 + 'priority' => 20,
2101 + 'fields' => [
2102 + 'import' => [
2103 + 'id' => 'import',
2104 + 'name' => 'import',
2105 + 'type' => 'section',
2106 + 'label' => __( 'Import', 'betterdocs' ),
2107 + 'priority' => 1,
2108 + 'fields' => [
2109 + 'import_tab_nested' => [
2110 + 'id' => 'import_tab_nested',
2111 + 'name' => 'import_tab_nested',
2112 + 'label' => __( 'Import', 'betterdocs' ),
2113 + 'classes' => 'tab-nested-layout',
2114 + 'type' => 'tab',
2115 + 'active' => 'import_docs_nested',
2116 + 'completionTrack' => true,
2117 + 'sidebar' => false,
2118 + 'save' => false,
2119 + 'title' => false,
2120 + 'config' => [
2121 + 'active' => 'import_docs_nested',
2122 + 'sidebar' => false,
2123 + 'title' => false
2124 + ],
2125 + 'submit' => [
2126 + 'show' => false
2127 + ],
2128 + 'step' => [
2129 + 'show' => false
2130 + ],
2131 + 'priority' => 1,
2132 + 'fields' => [
2133 + 'import_docs_nested' => [
2134 + 'id' => 'import_docs_nested',
2135 + 'name' => 'import_docs_nested',
2136 + 'type' => 'section',
2137 + 'label' => __( 'Import Docs', 'betterdocs' ),
2138 + 'priority' => 1,
2139 + 'fields' => [
2140 + 'import_docs' => [
2141 + 'name' => 'import_docs',
2142 + 'type' => 'importerupload',
2143 + 'label' => __( 'Import Docs', 'betterdocs' ),
2144 + 'label_subtitle' => wp_sprintf( // Translators: %1$s is a link to download a sample CSV file.
2145 + __( 'To import your Docs, please upload the .xml / .csv file here. <a href="%1$s">Download sample csv file</a>', 'betterdocs' ), betterdocs()->assets->icon( 'BetterDocs-sample-data.csv', true ) ),
2146 + 'text' => [
2147 + 'normal' => __( 'Proceed', 'betterdocs' ),
2148 + 'saved' => __( 'Proceed', 'betterdocs' ),
2149 + 'loading' => __( 'Importing...', 'betterdocs' ),
2150 + 'exists_notice' => __( 'It seems like documentations with same slugs already exist on your website. What would you like to do?', 'betterdocs' )
2151 + ],
2152 + 'ajax' => [
2153 + 'on' => 'click',
2154 + 'api' => '/betterdocs/v1/import-docs',
2155 + 'swal' => [
2156 + 'text' => __( 'Import completed successfully.', 'betterdocs' ),
2157 + 'icon' => 'success',
2158 + 'autoClose' => 2000
2159 + ]
2160 + ],
2161 + 'file_type' => '.xml, .csv',
2162 + 'priority' => 1
2163 + ]
2164 + ]
2165 + ],
2185 2166
2186 - if ( $docs ) {
2187 - return $docs;
2188 - }
2167 + 'import_settings_nested' => [
2168 + 'id' => 'import_settings_nested',
2169 + 'name' => 'import_settings_nested',
2170 + 'type' => 'section',
2171 + 'label' => __( 'Import Settings', 'betterdocs' ),
2172 + 'priority' => 1,
2173 + 'fields' => [
2174 + 'settings_importer' => [
2175 + 'name' => 'settings_importer',
2176 + 'type' => 'settingsuploader',
2177 + 'label' => __( 'Import Settings', 'betterdocs' ),
2178 + 'label_subtitle' => __( 'To import BetterDocs Settings, please upload BetterDocs settings you have exported from another website in .json format', 'betterdocs' ),
2179 + 'reset' => __( 'Change', 'betterdocs' ),
2180 + 'priority' => 1
2181 + ],
2182 + 'import_settings' => [
2183 + 'name' => 'import_settings',
2184 + 'type' => 'button',
2185 + 'rules' => Rules::is( 'settings_importer', null, true ),
2186 + 'text' => [
2187 + 'normal' => __( 'Proceed', 'betterdocs' ),
2188 + 'saved' => __( 'Proceed', 'betterdocs' ),
2189 + 'loading' => __( 'Importing...', 'betterdocs' )
2190 + ],
2191 + 'ajax' => [
2192 + 'on' => 'click',
2193 + 'api' => '/betterdocs/v1/import-settings',
2194 + 'data' => [
2195 + 'settings' => '@settings_importer'
2196 + ],
2197 + 'swal' => [
2198 + 'text' => __( 'Import completed successfully.', 'betterdocs' ),
2199 + 'icon' => 'success',
2200 + 'autoClose' => 1000
2201 + ],
2202 + 'reload' => true
2203 + ],
2204 + 'priority' => 2
2205 + ]
2206 + ]
2207 + ]
2208 + ]
2209 + ]
2210 + ]
2211 + ],
2212 + 'export' => [
2213 + 'id' => 'export',
2214 + 'name' => 'export',
2215 + 'type' => 'section',
2216 + 'label' => __( 'Export', 'betterdocs' ),
2217 + 'priority' => 1,
2218 + 'fields' => [
2219 + 'export_tab_nested' => [
2220 + 'id' => 'export_tab_nested',
2221 + 'name' => 'export_tab_nested',
2222 + 'label' => __( 'Export', 'betterdocs' ),
2223 + 'classes' => 'tab-nested-layout',
2224 + 'type' => 'tab',
2225 + 'active' => 'export_docs_nested',
2226 + 'completionTrack' => true,
2227 + 'sidebar' => false,
2228 + 'save' => false,
2229 + 'title' => false,
2230 + 'config' => [
2231 + 'active' => 'export_docs_nested',
2232 + 'sidebar' => false,
2233 + 'title' => false
2234 + ],
2235 + 'submit' => [
2236 + 'show' => false
2237 + ],
2238 + 'step' => [
2239 + 'show' => false
2240 + ],
2241 + 'priority' => 1,
2242 + 'fields' => [
2243 + 'export_docs_nested' => [
2244 + 'id' => 'export_docs_nested',
2245 + 'name' => 'export_docs_nested',
2246 + 'type' => 'section',
2247 + 'label' => __( 'Export Docs', 'betterdocs' ),
2248 + 'priority' => 1,
2249 + 'fields' => apply_filters( 'betterdocs_export_fields', [
2250 + 'export_type' => [
2251 + 'name' => 'export_type',
2252 + 'label' => __( 'Select Docs Type', 'betterdocs' ),
2253 + 'label_subtitle' => __( 'Choose an export type: All Docs, a specific Knowledge Base, or a Doc Category', 'betterdocs' ),
2254 + 'type' => 'select',
2255 + 'default' => 'docs',
2256 + 'priority' => 3,
2257 + 'search' => true,
2258 + 'options' => $this->normalize_options( apply_filters( 'betterdocs_export_type_options', [
2259 + 'docs' => __( 'Docs', 'betterdocs' ),
2260 + 'doc_category' => __( 'Docs Category', 'betterdocs' ),
2261 + 'glossaries' => __( 'Glossaries', 'betterdocs' )
2262 + ] ) )
2263 + ],
2264 + 'export_docs' => [
2265 + 'name' => 'export_docs',
2266 + 'type' => 'checkbox-select',
2267 + 'label' => __( 'Select Docs', 'betterdocs' ),
2268 + 'label_subtitle' => __( 'Selected docs will be included in the export.', 'betterdocs' ),
2269 + 'priority' => 4,
2270 + 'multiple' => true,
2271 + 'search' => true,
2272 + 'default' => [ 'all' ],
2273 + 'placeholder' => __( 'Select any', 'betterdocs' ),
2274 + 'options' => array_merge( [
2275 + [
2276 + 'value' => 'all',
2277 + 'label' => 'All'
2278 + ]
2279 + ], $this->docs() ),
2280 + 'filterValue' => 'all',
2281 + 'rules' => Rules::is( 'export_type', 'docs' )
2282 + ],
2283 + 'export_categories' => [
2284 + 'name' => 'export_categories',
2285 + 'type' => 'checkbox-select',
2286 + 'label' => __( 'Select Categories', 'betterdocs' ),
2287 + 'label_subtitle' => __( 'Selected categories and its docs will be included in the export.', 'betterdocs' ),
2288 + 'priority' => 6,
2289 + 'multiple' => true,
2290 + 'search' => true,
2291 + 'default' => [ 'all' ],
2292 + 'placeholder' => __( 'Select any', 'betterdocs' ),
2293 + 'options' => $this->get_terms( 'doc_category' ),
2294 + 'filterValue' => 'all',
2295 + 'rules' => Rules::is( 'export_type', 'doc_category' )
2296 + ],
2297 + 'export_glossaries' => [
2298 + 'name' => 'export_glossaries',
2299 + 'type' => 'checkbox-select',
2300 + 'label' => __( 'Select Glossaries', 'betterdocs' ),
2301 + 'label_subtitle' => __( 'Selected glossary terms will be exported.', 'betterdocs' ),
2302 + 'priority' => 7,
2303 + 'multiple' => true,
2304 + 'search' => true,
2305 + 'default' => [ 'all' ],
2306 + 'placeholder' => __( 'Select any', 'betterdocs' ),
2307 + 'options' => $this->get_terms( 'glossaries' ),
2308 + 'filterValue' => 'all',
2309 + 'rules' => Rules::is( 'export_type', 'glossaries' )
2310 + ],
2311 + 'file_type' => [
2312 + 'name' => 'file_type',
2313 + 'label' => __( 'Select File Type', 'betterdocs' ),
2314 + 'label_subtitle' => __( 'Choose a file type', 'betterdocs' ),
2315 + 'type' => 'select',
2316 + 'default' => 'xml',
2317 + 'priority' => 8,
2318 + 'search' => true,
2319 + 'options' => $this->normalize_options( apply_filters( 'betterdocs_export_file_type_options', [
2320 + 'xml' => __( '.xml', 'betterdocs' ),
2321 + 'csv' => __( '.csv', 'betterdocs' )
2322 + ] ) )
2323 + ],
2324 + 'enable_export_faq' => [
2325 + 'name' => 'enable_export_faq',
2326 + 'type' => 'toggle',
2327 + 'priority' => 9,
2328 + 'label' => __( 'Export FAQ', 'betterdocs' ),
2329 + 'label_subtitle' => __( 'Export FAQ Related Terms & Posts', 'betterdocs' ),
2330 + 'enable_disable_text_active' => true,
2331 + 'default' => true,
2332 + 'rules' => Rules::is( 'export_type', 'glossaries', true )
2333 + ],
2334 + 'export_docs_btn' => [
2335 + 'name' => 'export_docs_btn',
2336 + 'text' => [
2337 + 'normal' => __( 'Proceed', 'betterdocs' ),
2338 + 'saved' => __( 'Proceed', 'betterdocs' ),
2339 + 'loading' => __( 'Exporting...', 'betterdocs' )
2340 + ],
2341 + 'type' => 'button',
2342 + 'priority' => 10,
2343 + 'ajax' => [
2344 + 'on' => 'click',
2345 + 'api' => '/betterdocs/v1/export-docs',
2346 + 'data' => [
2347 + 'export_type' => '@export_type',
2348 + 'export_docs' => '@export_docs',
2349 + 'export_kbs' => '@export_kbs',
2350 + 'export_categories' => '@export_categories',
2351 + 'export_glossaries' => '@export_glossaries',
2352 + 'file_type' => '@file_type',
2353 + 'enable_export_faq' => '@enable_export_faq'
2354 + ],
2355 + 'swal' => [
2356 + 'text' => __( 'Exported Successfully.', 'betterdocs' ),
2357 + 'icon' => 'success',
2358 + 'autoClose' => 2000
2359 + ]
2360 + ]
2361 + ]
2362 + ] )
2363 + ],
2189 2364
2190 - $docs = [];
2365 + 'export_settings_nested' => [
2366 + 'id' => 'export_settings_nested',
2367 + 'name' => 'export_settings_nested',
2368 + 'type' => 'section',
2369 + 'label' => __( 'Export Settings', 'betterdocs' ),
2370 + 'priority' => 1,
2371 + 'fields' => [
2372 + 'export_settings' => [
2373 + 'name' => 'export_settings',
2374 + 'label' => __( 'Export Settings', 'betterdocs' ),
2375 + 'label_subtitle' => __( 'Simply click on “Export Settings” button to download your BetterDocs settings in .json format', 'betterdocs' ),
2376 + 'text' => [
2377 + 'normal' => __( 'Export Settings', 'betterdocs' ),
2378 + 'saved' => __( 'Export Settings', 'betterdocs' ),
2379 + 'loading' => __( 'Exporting...', 'betterdocs' )
2380 + ],
2381 + 'type' => 'button',
2382 + 'priority' => 8,
2383 + 'ajax' => [
2384 + 'on' => 'click',
2385 + 'api' => '/betterdocs/v1/export-settings',
2386 + 'data' => [
2387 + 'betterdocs_settings' => get_option( 'betterdocs_settings' )
2388 + ],
2389 + 'swal' => [
2390 + 'text' => __( 'File downloaded successfully.', 'betterdocs' ),
2391 + 'icon' => 'success',
2392 + 'autoClose' => 2000
2393 + ]
2394 + ]
2395 + ]
2396 + ]
2397 + ]
2398 + ]
2399 + ]
2400 + ]
2401 + ]
2402 + ]
2403 + ]
2404 + ]
2405 + ]
2406 + ]
2407 + ] );
2191 2408
2192 - $_docs = get_posts( [
2193 - 'post_type' => 'docs',
2194 - 'numberposts' => -1,
2195 - 'posts_per_page' => -1
2196 - ] );
2409 + return $settings;
2410 + }
2197 2411
2198 - if ( ! empty( $_docs ) ) {
2199 - foreach ( $_docs as $doc ) {
2200 - $docs[$doc->ID] = betterdocs()->template_helper->kses( $doc->post_title );
2201 - }
2202 - $docs = GlobalFields::normalize_fields( $docs );
2203 - $this->database->set_cache( 'betterdocs::settings::all_docs', $docs );
2204 - }
2412 + public function normalize_options( $options ) {
2413 + return GlobalFields::normalize_fields( $options );
2414 + }
2205 2415
2206 - return $docs;
2207 - }
2416 + public function get_texanomy() {
2417 + $docs_tax = $this->database->get_cache( 'betterdocs::settings::taxonomies' );
2208 2418
2209 - public function hide_roles_management( $tabData = [] ) {
2210 - global $current_user;
2419 + if ( $docs_tax ) {
2420 + return $docs_tax;
2421 + }
2211 2422
2212 - if ( $current_user instanceof WP_User && ! in_array( 'administrator', $current_user->roles ) ) {
2213 - unset( $tabData['fields']['title-advance-settings']['fields']['article_roles'] );
2214 - unset( $tabData['fields']['title-advance-settings']['fields']['settings_roles'] );
2215 - unset( $tabData['fields']['title-advance-settings']['fields']['analytics_roles'] );
2216 - }
2423 + $taxonomies = get_taxonomies( [
2424 + 'object_type' => [ 'docs' ]
2425 + ], 'objects' );
2217 2426
2218 - return $tabData;
2219 - }
2427 + $docs_tax = [
2428 + 'all' => 'All Docs Archive',
2429 + 'docs' => 'Docs Page'
2430 + ];
2431 + foreach ( $taxonomies as $key => $value ) {
2432 + $docs_tax[ $key ] = $value->label;
2433 + }
2434 + unset( $docs_tax['doc_tag'] );
2435 +
2436 + $docs_tax = $this->normalize_options( $docs_tax );
2437 + if ( count( $docs_tax ) > 2 ) {
2438 + $this->database->set_cache( 'betterdocs::settings::taxonomies', $docs_tax );
2439 + }
2440 +
2441 + return $docs_tax;
2442 + }
2443 +
2444 + public function get_terms( $taxonomy ) {
2445 + $_cache_key = 'betterdocs::settings::terms::' . trim( $taxonomy );
2446 + $docs_tax = $this->database->get_cache( $_cache_key );
2447 +
2448 + if ( $docs_tax ) {
2449 + return $docs_tax;
2450 + }
2451 +
2452 + $get_terms = get_terms( [
2453 + 'taxonomy' => $taxonomy,
2454 + 'hide_empty' => false
2455 + ] );
2456 +
2457 + $terms = [
2458 + 'all' => 'All'
2459 + ];
2460 +
2461 + if ( ! empty( $get_terms ) && ! is_wp_error( $get_terms ) ) {
2462 + foreach ( $get_terms as $value ) {
2463 + if ( isset( $value->slug ) && isset( $value->name ) ) {
2464 + $terms[ $value->slug ] = $value->name;
2465 + }
2466 + }
2467 + }
2468 +
2469 + $terms = $this->normalize_options( $terms );
2470 + if ( count( $terms ) > 1 ) {
2471 + $this->database->set_cache( $_cache_key, $terms );
2472 + }
2473 +
2474 + return $terms;
2475 + }
2476 +
2477 + /**
2478 + * Get all docs
2479 + */
2480 + public function docs() {
2481 + $docs = $this->database->get_cache( 'betterdocs::settings::all_docs' );
2482 +
2483 + if ( $docs ) {
2484 + return $docs;
2485 + }
2486 +
2487 + $docs = [];
2488 +
2489 + $_docs = get_posts( [
2490 + 'post_type' => 'docs',
2491 + 'numberposts' => - 1,
2492 + 'posts_per_page' => - 1
2493 + ] );
2494 +
2495 + if ( ! empty( $_docs ) ) {
2496 + foreach ( $_docs as $doc ) {
2497 + $docs[ $doc->ID ] = betterdocs()->template_helper->kses( $doc->post_title );
2498 + }
2499 + $docs = GlobalFields::normalize_fields( $docs );
2500 + $this->database->set_cache( 'betterdocs::settings::all_docs', $docs );
2501 + }
2502 +
2503 + return $docs;
2504 + }
2505 +
2506 + public function hide_roles_management( $tabData = [] ) {
2507 + global $current_user;
2508 +
2509 + if ( $current_user instanceof WP_User && ! in_array( 'administrator', $current_user->roles ) ) {
2510 + unset( $tabData['fields']['title-advance-settings']['fields']['article_roles'] );
2511 + unset( $tabData['fields']['title-advance-settings']['fields']['settings_roles'] );
2512 + unset( $tabData['fields']['title-advance-settings']['fields']['analytics_roles'] );
2513 + }
2514 +
2515 + return $tabData;
2516 + }
2220 2517 }