PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.8.1
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.8.1
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.8.1, at includes/Core/Settings.php

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