PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.7.3
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.7.3
4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.5.2 All 199 releases
betterdocs / includes / Core / Settings.php

Settings.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 3.7.3, at includes/Core/Settings.php

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