| @@ -7,9 +7,8 @@ | ||
| 7 | 7 | use WPDeveloper\BetterDocs\Admin\Builder\GlobalFields; |
| 8 | 8 | use WPDeveloper\BetterDocs\Admin\Builder\Rules; |
| 9 | 9 | use WPDeveloper\BetterDocs\Utils\Base; |
| 10 | 10 | use WPDeveloper\BetterDocs\Utils\Database; |
| 11 | -use WPDeveloper\BetterDocs\Utils\Helper; | |
| 12 | 11 | |
| 13 | 12 | |
| 14 | 13 | class Settings extends Base { |
| 15 | 14 | public $base_key = 'betterdocs_settings'; |
| @@ -35,9 +34,8 @@ | ||
| 35 | 34 | $this->database = $database; |
| 36 | 35 | $this->deprecated = $this->deprecated_settings(); |
| 37 | 36 | |
| 38 | 37 | add_filter( 'betterdocs_settings_tabs', [ $this, 'import_export_settings' ] ); |
| 39 | - add_filter( 'betterdocs_settings_tabs', [ $this, 'maybe_remove_git_tab' ], 20 ); | |
| 40 | 38 | |
| 41 | 39 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_old' ], 99 ); |
| 42 | 40 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ], 99 ); |
| 43 | 41 | |
| @@ -86,37 +84,13 @@ | ||
| 86 | 84 | } |
| 87 | 85 | |
| 88 | 86 | wp_enqueue_media(); |
| 89 | 87 | wp_enqueue_script( 'betterdocs-admin' ); |
| 90 | - | |
| 91 | - $settings = GlobalFields::normalize( $this->settings_args() ); | |
| 88 | + betterdocs()->assets->localize( 'betterdocs-admin', 'betterdocsAdminSettings', GlobalFields::normalize( $this->settings_args() ) ); | |
| 89 | + betterdocs()->assets->enqueue( 'betterdocs-icons', 'admin/btd-icon/style.css' ); | |
| 92 | 90 | |
| 93 | - // Mask sensitive API keys before they reach the browser. Non-admins still get them stripped entirely below. | |
| 94 | - $sensitive_api_keys = [ 'ai_autowrite_api_key', 'ai_chatbot_api_key' ]; | |
| 95 | - foreach ( $sensitive_api_keys as $api_key_field ) { | |
| 96 | - if ( ! empty( $settings['values'][ $api_key_field ] ) ) { | |
| 97 | - $settings['values'][ $api_key_field ] = Helper::mask_api_key( $settings['values'][ $api_key_field ] ); | |
| 98 | - } | |
| 99 | - } | |
| 100 | - | |
| 101 | - if ( ! current_user_can( 'edit_docs_settings' ) ) { | |
| 102 | - foreach ( $sensitive_api_keys as $api_key_field ) { | |
| 103 | - if ( isset( $settings['values'][ $api_key_field ] ) ) { | |
| 104 | - unset( $settings['values'][ $api_key_field ] ); | |
| 105 | - } | |
| 106 | - } | |
| 107 | - } | |
| 108 | - | |
| 109 | - // Inject raw git settings to bypass get() fallback (e.g., '' -> 'docs') | |
| 110 | - if ( isset( $settings['values'] ) ) { | |
| 111 | - $settings['values']['git_provider'] = $this->get_raw_field( 'git_provider', 'github' ); | |
| 112 | - $settings['values']['git_repository_url'] = $this->get_raw_field( 'git_repository_url', '' ); | |
| 113 | - $settings['values']['git_branch'] = $this->get_raw_field( 'git_branch', '' ); | |
| 114 | - $settings['values']['git_docs_directory'] = $this->get_raw_field( 'git_docs_directory', '' ); | |
| 115 | - } | |
| 116 | - | |
| 117 | - betterdocs()->assets->localize( 'betterdocs-admin', 'betterdocsAdminSettings', $settings ); | |
| 118 | - betterdocs()->assets->enqueue( 'betterdocs-icons', 'admin/btd-icon/style.css' ); | |
| 91 | + // betterdocs()->assets->enqueue( 'betterdocs-settings', 'admin/css/settings.css' ); | |
| 92 | + // betterdocs()->assets->enqueue( 'betterdocs-settings', 'admin/js/settings.js' ); | |
| 119 | 93 | } |
| 120 | 94 | |
| 121 | 95 | public function enqueue_old( $hook ) { |
| 122 | 96 | // FREE & Pro Version Compatibility Check |
| @@ -201,9 +175,8 @@ | ||
| 201 | 175 | 'multiple_kb' => '', |
| 202 | 176 | 'enable_export_faq' => true, |
| 203 | 177 | 'builtin_doc_page' => true, |
| 204 | 178 | 'breadcrumb_doc_title' => __( 'Docs', 'betterdocs' ), |
| 205 | - 'enable_category_hierarchy_slugs' => false, | |
| 206 | 179 | 'docs_slug' => 'docs', |
| 207 | 180 | 'docs_page' => 0, |
| 208 | 181 | 'category_slug' => 'docs-category', |
| 209 | 182 | 'tag_slug' => 'docs-tag', |
| @@ -215,9 +188,8 @@ | ||
| 215 | 188 | 'search_letter_limit' => 3, |
| 216 | 189 | 'search_placeholder' => __( 'Search...', 'betterdocs' ), |
| 217 | 190 | 'search_not_found_text' => __( 'Sorry, no docs were found.', 'betterdocs' ), |
| 218 | 191 | 'search_result_image' => true, |
| 219 | - 'search_modal_search_type' => 'all', | |
| 220 | 192 | 'masonry_layout' => true, |
| 221 | 193 | 'docs_list_icon' => [], |
| 222 | 194 | 'category_title_link' => false, |
| 223 | 195 | 'terms_orderby' => 'betterdocs_order', |
| @@ -273,14 +245,10 @@ | ||
| 273 | 245 | 'reporting_day' => 'monday', |
| 274 | 246 | 'reporting_email' => get_option( 'admin_email' ), |
| 275 | 247 | 'enable_write_with_ai' => true, |
| 276 | 248 | 'enable_faq_write_with_ai' => true, |
| 277 | - 'write_with_ai_model' => 'gpt-4o-mini', | |
| 278 | 249 | 'ai_autowrite_api_key' => '', |
| 279 | 250 | 'ai_autowrite_max_token' => 1500, |
| 280 | - 'enable_article_summary' => false, | |
| 281 | - 'article_summary_model' => 'gpt-4o-mini', | |
| 282 | - 'article_summary_max_token' => 1500, | |
| 283 | 251 | 'enable_estimated_reading_time' => true, |
| 284 | 252 | 'enable_encyclopedia' => false, |
| 285 | 253 | 'enable_glossaries' => false, |
| 286 | 254 | 'show_glossary_suggestions' => true, |
| @@ -286,13 +254,9 @@ | ||
| 286 | 254 | 'show_glossary_suggestions' => true, |
| 287 | 255 | 'enable_ai_chatbot' => false, |
| 288 | 256 | 'estimated_reading_time_title' => '', |
| 289 | 257 | 'estimated_reading_time_text' => __( 'min read', 'betterdocs' ), |
| 290 | - 'singular_estimated_reading_time_text' => __( 'min read', 'betterdocs' ), | |
| 291 | - 'betterdocs_access_control_repeater' => [], | |
| 292 | - 'internal_knowledge_base_type' => 'basic', | |
| 293 | - 'betterdocs_access_control_repeater_kb' => [], | |
| 294 | - 'enable_git_integration' => false, | |
| 258 | + 'singular_estimated_reading_time_text' => __( 'min read', 'betterdocs' ) | |
| 295 | 259 | ]; |
| 296 | 260 | |
| 297 | 261 | $_default = apply_filters( 'betterdocs_default_settings', $_default ); |
| 298 | 262 | // $_default = apply_filters_deprecated( |
| @@ -560,37 +524,9 @@ | ||
| 560 | 524 | if ( ! current_user_can( 'edit_docs_settings' ) ) { |
| 561 | 525 | return new WP_Error( 'unauthorized_action', __( 'You don\'t have any rights for saving settings.', 'betterdocs' ) ); |
| 562 | 526 | } |
| 563 | 527 | |
| 564 | - // Quickbuilder sends back the full UI-loaded payload. To avoid overwriting values that we | |
| 565 | - // asynchronously updated in the DB via AJAX (like Git integration fields), we strictly remove them | |
| 566 | - // from the incoming save payload so that the freshly loaded `$_old_settings` values persist. | |
| 567 | - $exclude_ajax_keys = [ 'git_provider', 'git_repository_url', 'git_branch', 'git_docs_directory' ]; | |
| 568 | - foreach ( $exclude_ajax_keys as $key ) { | |
| 569 | - if ( array_key_exists( $key, $settings ) ) { | |
| 570 | - unset( $settings[ $key ] ); | |
| 571 | - } | |
| 572 | - if ( isset( $settings['values'] ) && is_array( $settings['values'] ) && array_key_exists( $key, $settings['values'] ) ) { | |
| 573 | - unset( $settings['values'][ $key ] ); | |
| 574 | - } | |
| 575 | - } | |
| 576 | - | |
| 577 | 528 | $_old_settings = $this->database->get( $this->base_key, $this->get_default() ); |
| 578 | - | |
| 579 | - // The frontend only ever sees masked API keys. If a submitted value matches the mask of | |
| 580 | - // the stored value, the user did not change it — restore the original so the mask string | |
| 581 | - // is never persisted. | |
| 582 | - $sensitive_api_keys = [ 'ai_autowrite_api_key', 'ai_chatbot_api_key' ]; | |
| 583 | - foreach ( $sensitive_api_keys as $api_key_field ) { | |
| 584 | - if ( ! isset( $settings[ $api_key_field ] ) ) { | |
| 585 | - continue; | |
| 586 | - } | |
| 587 | - $stored = isset( $_old_settings[ $api_key_field ] ) ? $_old_settings[ $api_key_field ] : ''; | |
| 588 | - if ( $stored !== '' && trim( (string) $settings[ $api_key_field ] ) === Helper::mask_api_key( $stored ) ) { | |
| 589 | - $settings[ $api_key_field ] = $stored; | |
| 590 | - } | |
| 591 | - } | |
| 592 | - | |
| 593 | 529 | // @todo: sanitize the data before inject in DB. |
| 594 | 530 | $_normalized_settings = $this->get_normalized_values( $settings ); |
| 595 | 531 | if ( $existing_plugins && isset( $_normalized_settings['migration_step'] ) && $_normalized_settings['migration_step'] == true ) { |
| 596 | 532 | betterdocs()->kbmigration->migrate(); |
| @@ -595,22 +531,13 @@ | ||
| 595 | 531 | if ( $existing_plugins && isset( $_normalized_settings['migration_step'] ) && $_normalized_settings['migration_step'] == true ) { |
| 596 | 532 | betterdocs()->kbmigration->migrate(); |
| 597 | 533 | } |
| 598 | 534 | $_settings = wp_parse_args( $_normalized_settings, $_old_settings ); |
| 535 | + $_saved = $this->database->save( $this->base_key, $_settings ); | |
| 599 | 536 | |
| 600 | - // Check if there are actual changes before saving. | |
| 601 | - // update_option returns false when values serialize identically, which can happen | |
| 602 | - // due to object caching or type normalization even when user made changes. | |
| 603 | - $_has_changes = $_settings != $_old_settings; | |
| 604 | - | |
| 605 | - $_saved = $this->database->save( $this->base_key, $_settings ); | |
| 606 | - | |
| 607 | 537 | do_action_ref_array( 'betterdocs::settings::saved', [ $_saved, $_settings, $_old_settings, &$this ] ); |
| 608 | 538 | |
| 609 | - // Return true if save succeeded OR if there were changes to attempt saving. | |
| 610 | - // This handles cases where update_option returns false due to identical serialization | |
| 611 | - // (e.g., object caching, type coercion during serialization). | |
| 612 | - return $_saved || $_has_changes; | |
| 539 | + return $_saved; | |
| 613 | 540 | } |
| 614 | 541 | |
| 615 | 542 | public function views( $hook ) { |
| 616 | 543 | return betterdocs()->views->get( 'admin/settings' ); |
| @@ -644,12 +571,8 @@ | ||
| 644 | 571 | |
| 645 | 572 | public function settings_args() { |
| 646 | 573 | $wp_roles = $this->normalize_options( $this->get_roles() ); |
| 647 | 574 | |
| 648 | - $roles_for_ikb = $this->normalize_options( array_merge( [ 'all' => __( 'All logged in users', 'betterdocs' ) ], wp_roles()->role_names ) ); | |
| 649 | - | |
| 650 | - unset( $roles_for_ikb['administrator'] ); | |
| 651 | - | |
| 652 | 575 | $settings = [ |
| 653 | 576 | 'id' => 'betterdocs_settings_metabox_wrapper', |
| 654 | 577 | 'title' => __( 'betterdocs', 'betterdocs' ), |
| 655 | 578 | 'object_types' => [ 'betterdocs' ], |
| @@ -708,23 +631,14 @@ | ||
| 708 | 631 | 'enable_disable_text_active' => true, |
| 709 | 632 | 'default' => 1, |
| 710 | 633 | 'priority' => 2 |
| 711 | 634 | ], |
| 712 | - 'enable_category_hierarchy_slugs' => [ | |
| 713 | - 'name' => 'enable_category_hierarchy_slugs', | |
| 714 | - 'type' => 'toggle', | |
| 715 | - 'label' => __( 'Enable Category Hierarchy Slug', 'betterdocs' ), | |
| 716 | - 'enable_disable_text_active' => true, | |
| 717 | - 'default' => false, | |
| 718 | - 'priority' => 3, | |
| 719 | - 'label_subtitle' => __( "Shows Hierarchy Based Permalink Slugs For Doc Categories & Single Doc Page", 'betterdocs' ) | |
| 720 | - ], | |
| 721 | 635 | 'breadcrumb_doc_title' => [ |
| 722 | 636 | 'name' => 'breadcrumb_doc_title', |
| 723 | 637 | 'type' => 'text', |
| 724 | 638 | 'label' => __( 'Documentation Page Title', 'betterdocs' ), |
| 725 | 639 | 'default' => __( 'Docs', 'betterdocs' ), |
| 726 | - 'priority' => 4, | |
| 640 | + 'priority' => 3, | |
| 727 | 641 | 'rules' => Rules::is( 'builtin_doc_page', true ) |
| 728 | 642 | ], |
| 729 | 643 | 'docs_slug' => [ |
| 730 | 644 | 'name' => 'docs_slug', |
| @@ -730,9 +644,9 @@ | ||
| 730 | 644 | 'name' => 'docs_slug', |
| 731 | 645 | 'type' => 'text', |
| 732 | 646 | 'label' => __( 'BetterDocs Root Slug', 'betterdocs' ), |
| 733 | 647 | 'default' => 'docs', |
| 734 | - 'priority' => 5, | |
| 648 | + 'priority' => 4, | |
| 735 | 649 | 'rules' => Rules::is( 'builtin_doc_page', true ) |
| 736 | 650 | ], |
| 737 | 651 | 'docs_page' => [ |
| 738 | 652 | 'name' => 'docs_page', |
| @@ -738,9 +652,9 @@ | ||
| 738 | 652 | 'name' => 'docs_page', |
| 739 | 653 | 'label' => __( 'Docs Page', 'betterdocs' ), |
| 740 | 654 | 'type' => 'select', |
| 741 | 655 | 'default' => 0, |
| 742 | - 'priority' => 6, | |
| 656 | + 'priority' => 5, | |
| 743 | 657 | 'search' => true, |
| 744 | 658 | 'options' => $this->normalize_options( $this->get_pages() ), |
| 745 | 659 | 'label_subtitle' => __( 'You will need to insert BetterDocs Shortcode inside the page. This page will be used as docs permalink.', 'betterdocs' ), |
| 746 | 660 | 'rules' => Rules::is( 'builtin_doc_page', false ) |
| @@ -750,9 +664,9 @@ | ||
| 750 | 664 | 'name' => 'category_slug', |
| 751 | 665 | 'type' => 'text', |
| 752 | 666 | 'label' => __( 'Custom Category Slug', 'betterdocs' ), |
| 753 | 667 | 'default' => 'docs-category', |
| 754 | - 'priority' => 7 | |
| 668 | + 'priority' => 6 | |
| 755 | 669 | ], |
| 756 | 670 | 'tag_slug' => [ |
| 757 | 671 | 'name' => 'tag_slug', |
| 758 | 672 | 'type' => 'text', |
| @@ -757,9 +671,9 @@ | ||
| 757 | 671 | 'name' => 'tag_slug', |
| 758 | 672 | 'type' => 'text', |
| 759 | 673 | 'label' => __( 'Custom Tag Slug', 'betterdocs' ), |
| 760 | 674 | 'default' => 'docs-tag', |
| 761 | - 'priority' => 8 | |
| 675 | + 'priority' => 7 | |
| 762 | 676 | ], |
| 763 | 677 | 'permalink_structure' => [ |
| 764 | 678 | 'name' => 'permalink_structure', |
| 765 | 679 | 'type' => 'permalink_structure', |
| @@ -764,9 +678,9 @@ | ||
| 764 | 678 | 'name' => 'permalink_structure', |
| 765 | 679 | 'type' => 'permalink_structure', |
| 766 | 680 | 'label' => __( 'Single Docs Permalink', 'betterdocs' ), |
| 767 | 681 | 'default' => PostType::permalink_structure(), |
| 768 | - 'priority' => 9, | |
| 682 | + 'priority' => 8, | |
| 769 | 683 | 'tags' => $this->normalize_options( [ |
| 770 | 684 | '%doc_category%' => '%doc_category%', |
| 771 | 685 | '%knowledge_base%' => '%knowledge_base%' |
| 772 | 686 | ] ), |
| @@ -778,9 +692,9 @@ | ||
| 778 | 692 | 'label' => __( 'Show Glossary', 'betterdocs' ), |
| 779 | 693 | 'label_subtitle' => __( 'Enable the glossary feature to allow users to look up definitions for terms used within your encyclopedia or glossaries themselves.', 'betterdocs' ), |
| 780 | 694 | 'enable_disable_text_active' => true, |
| 781 | 695 | 'default' => false, |
| 782 | - 'priority' => 10, | |
| 696 | + 'priority' => 9, | |
| 783 | 697 | 'is_pro' => true |
| 784 | 698 | ], |
| 785 | 699 | 'enable_encyclopedia' => [ |
| 786 | 700 | 'name' => 'enable_encyclopedia', |
| @@ -787,9 +701,9 @@ | ||
| 787 | 701 | 'type' => 'toggle', |
| 788 | 702 | 'label' => __( 'Built-in Encyclopedia Page', 'betterdocs' ), |
| 789 | 703 | 'enable_disable_text_active' => true, |
| 790 | 704 | 'default' => false, |
| 791 | - 'priority' => 11, | |
| 705 | + 'priority' => 10, | |
| 792 | 706 | 'is_pro' => true |
| 793 | 707 | ], |
| 794 | 708 | 'enable_faq_schema' => [ |
| 795 | 709 | 'name' => 'enable_faq_schema', |
| @@ -796,9 +710,9 @@ | ||
| 796 | 710 | 'type' => 'toggle', |
| 797 | 711 | 'label' => __( 'FAQ Schema', 'betterdocs' ), |
| 798 | 712 | 'enable_disable_text_active' => true, |
| 799 | 713 | 'default' => '', |
| 800 | - 'priority' => 12 | |
| 714 | + 'priority' => 14 | |
| 801 | 715 | ], |
| 802 | 716 | 'analytics_from' => [ |
| 803 | 717 | 'name' => 'analytics_from', |
| 804 | 718 | 'type' => 'select', |
| @@ -808,9 +722,9 @@ | ||
| 808 | 722 | 'guests' => __( 'Guests Only', 'betterdocs' ), |
| 809 | 723 | 'registered_users' => __( 'Registered Users Only', 'betterdocs' ) |
| 810 | 724 | ] ), |
| 811 | 725 | 'default' => 'everyone', |
| 812 | - 'priority' => 13, | |
| 726 | + 'priority' => 15, | |
| 813 | 727 | 'is_pro' => true |
| 814 | 728 | ], |
| 815 | 729 | 'unique_visitor_count' => [ |
| 816 | 730 | 'name' => 'unique_visitor_count', |
| @@ -817,9 +731,9 @@ | ||
| 817 | 731 | 'type' => 'toggle', |
| 818 | 732 | 'label' => __( 'Unique Visitor Count', 'betterdocs' ), |
| 819 | 733 | 'enable_disable_text_active' => true, |
| 820 | 734 | 'default' => false, |
| 821 | - 'priority' => 14, | |
| 735 | + 'priority' => 16, | |
| 822 | 736 | 'is_pro' => true |
| 823 | 737 | ], |
| 824 | 738 | 'exclude_bot_analytics' => [ |
| 825 | 739 | 'name' => 'exclude_bot_analytics', |
| @@ -826,9 +740,9 @@ | ||
| 826 | 740 | 'type' => 'toggle', |
| 827 | 741 | 'label' => __( 'Exclude Bot Analytics', 'betterdocs' ), |
| 828 | 742 | 'enable_disable_text_active' => true, |
| 829 | 743 | 'default' => false, |
| 830 | - 'priority' => 15, | |
| 744 | + 'priority' => 17, | |
| 831 | 745 | 'is_pro' => true |
| 832 | 746 | ] |
| 833 | 747 | |
| 834 | 748 | ] |
| @@ -1073,9 +987,10 @@ | ||
| 1073 | 987 | 'name' => 'search_button_text', |
| 1074 | 988 | 'type' => 'text', |
| 1075 | 989 | 'label' => __( 'Search Button Text', 'betterdocs' ), |
| 1076 | 990 | 'priority' => 7, |
| 1077 | - 'default' => __( 'Search', 'betterdocs' ) | |
| 991 | + 'default' => __( 'Search', 'betterdocs' ), | |
| 992 | + 'is_pro' => true | |
| 1078 | 993 | ] ), |
| 1079 | 994 | 'search_not_found_text' => [ |
| 1080 | 995 | 'name' => 'search_not_found_text', |
| 1081 | 996 | 'type' => 'text', |
| @@ -1099,22 +1014,9 @@ | ||
| 1099 | 1014 | 'default' => '', |
| 1100 | 1015 | 'priority' => 10, |
| 1101 | 1016 | 'is_pro' => true, |
| 1102 | 1017 | 'rules' => Rules::is( 'multiple_kb', true ) |
| 1103 | - ] ), | |
| 1104 | - 'search_modal_search_type' => [ | |
| 1105 | - 'name' => 'search_modal_search_type', | |
| 1106 | - 'type' => 'select', | |
| 1107 | - 'label' => __( 'Search Modal Source', 'betterdocs' ), | |
| 1108 | - 'label_subtitle' => __( 'Choose the content type to be shown in the search modal. <br> <b>Note:</b> This is only applicable on Modal Search.', 'betterdocs' ), | |
| 1109 | - 'default' => 'all', | |
| 1110 | - 'options' => $this->normalize_options( [ | |
| 1111 | - 'all' => __('Both (Docs + FAQs)', 'betterdocs'), | |
| 1112 | - 'docs' => __('Docs only', 'betterdocs'), | |
| 1113 | - 'faq' => __('FAQs only', 'betterdocs') | |
| 1114 | - ] ), | |
| 1115 | - 'priority' => 11, | |
| 1116 | - ] | |
| 1018 | + ] ) | |
| 1117 | 1019 | ] |
| 1118 | 1020 | ], |
| 1119 | 1021 | 'layout_documentation_page_order_by' => [ |
| 1120 | 1022 | 'id' => 'layout_documentation_page_order_by', |
| @@ -1746,30 +1648,8 @@ | ||
| 1746 | 1648 | 'priority' => 14, |
| 1747 | 1649 | 'description' => __( '[betterdocs_faq_list_classic groups="group_id" class="" group_exclude="group_id" faq_heading="Frequently Asked Questions"]', 'betterdocs' ), |
| 1748 | 1650 | 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ), |
| 1749 | 1651 | 'descriptionCopyable' => true |
| 1750 | - ], | |
| 1751 | - 'betterdocs_faq_list_layout_3' => [ | |
| 1752 | - 'name' => 'betterdocs_faq_list_layout_3', | |
| 1753 | - 'type' => 'copy-to-clipboard', | |
| 1754 | - 'label' => __( 'FAQ Layout - 3', 'betterdocs' ), | |
| 1755 | - 'default' => '[betterdocs_faq_list_layout_3 class="faq-doc betterdocs-faq-layout-3"]', | |
| 1756 | - 'readOnly' => true, | |
| 1757 | - 'priority' => 15, | |
| 1758 | - 'description' => __( '[betterdocs_faq_list_layout_3 class="faq-doc betterdocs-faq-layout-3" groups="group_id" class="" group_exclude="group_id" faq_heading="Frequently Asked Questions"]', 'betterdocs' ), | |
| 1759 | - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ), | |
| 1760 | - 'descriptionCopyable' => true | |
| 1761 | - ], | |
| 1762 | - 'betterdocs_faq_tab' => [ | |
| 1763 | - 'name' => 'betterdocs_faq_tab', | |
| 1764 | - 'type' => 'copy-to-clipboard', | |
| 1765 | - 'label' => __( 'FAQ Layout - 4', 'betterdocs' ), | |
| 1766 | - 'default' => '[betterdocs_faq_tab class="faq-doc betterdocs-faq-layout-4"]', | |
| 1767 | - 'readOnly' => true, | |
| 1768 | - 'priority' => 16, | |
| 1769 | - 'description' => __( '[betterdocs_faq_tab class="faq-doc betterdocs-faq-layout-4" groups="group_id" group_exclude="group_id" faq_heading="Frequently Asked Questions"]', 'betterdocs' ), | |
| 1770 | - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ), | |
| 1771 | - 'descriptionCopyable' => true | |
| 1772 | 1652 | ] |
| 1773 | 1653 | ] ) |
| 1774 | 1654 | ] |
| 1775 | 1655 | ] |
| @@ -1775,219 +1655,118 @@ | ||
| 1775 | 1655 | ] |
| 1776 | 1656 | ] ), |
| 1777 | 1657 | 'tab-advance-settings' => apply_filters( 'betterdocs_settings_tab_advance', [ |
| 1778 | 1658 | 'id' => 'tab-advance-settings', |
| 1779 | - 'label' => __( 'Access & Restrictions', 'betterdocs' ), | |
| 1780 | - 'classes' => 'tab-layout', | |
| 1659 | + 'label' => __( 'Advanced Settings', 'betterdocs' ), | |
| 1781 | 1660 | 'priority' => 50, |
| 1782 | 1661 | 'fields' => [ |
| 1783 | - 'title_advance_settings' => [ | |
| 1662 | + 'title-advance-settings' => [ | |
| 1784 | 1663 | 'name' => 'title-advance-settings-tab', |
| 1785 | 1664 | 'type' => 'section', |
| 1786 | - 'label' => __( 'Access & Restrictions', 'betterdocs' ), | |
| 1665 | + 'label' => __( 'Advanced Settings', 'betterdocs' ), | |
| 1787 | 1666 | 'priority' => 50, |
| 1788 | - 'fields' => [ | |
| 1789 | - 'tab-advanced-settings' => [ | |
| 1790 | - 'id' => 'tab-advanced-settings', | |
| 1791 | - 'name' => 'tab-advanced-settings', | |
| 1792 | - 'label' => __( 'Access & Restrictions', 'betterdocs' ), | |
| 1793 | - 'classes' => 'tab-layout', | |
| 1794 | - 'type' => 'tab', | |
| 1795 | - 'active' => 'global_role_management', | |
| 1796 | - 'completionTrack' => true, | |
| 1797 | - 'sidebar' => false, | |
| 1798 | - 'save' => false, | |
| 1799 | - 'title' => false, | |
| 1800 | - 'config' => [ | |
| 1801 | - 'active' => '', | |
| 1802 | - 'sidebar' => false, | |
| 1803 | - 'title' => false | |
| 1804 | - ], | |
| 1805 | - 'submit' => [ | |
| 1806 | - 'show' => false | |
| 1807 | - ], | |
| 1808 | - 'step' => [ | |
| 1809 | - 'show' => false | |
| 1810 | - ], | |
| 1811 | - 'priority' => 50, | |
| 1812 | - 'fields' => [ | |
| 1813 | - 'global_role_management' => [ | |
| 1814 | - 'id' => 'global_role_management', | |
| 1815 | - 'name' => 'global_role_management', | |
| 1816 | - 'type' => 'section', | |
| 1817 | - 'label' => __( 'Global Role Management', 'betterdocs' ), | |
| 1818 | - 'priority' => 1, | |
| 1819 | - 'fields' => [ | |
| 1820 | - 'article_roles' => [ | |
| 1821 | - 'name' => 'article_roles', | |
| 1822 | - 'type' => 'checkbox-select', | |
| 1823 | - 'label' => __( 'Who Can Write Docs?', 'betterdocs' ), | |
| 1824 | - 'priority' => 1, | |
| 1825 | - 'multiple' => true, | |
| 1826 | - 'search' => true, | |
| 1827 | - 'is_pro' => true, | |
| 1828 | - 'default' => [ 'administrator' ], | |
| 1829 | - 'options' => $wp_roles | |
| 1830 | - ], | |
| 1831 | - 'settings_roles' => [ | |
| 1832 | - 'name' => 'settings_roles', | |
| 1833 | - 'type' => 'checkbox-select', | |
| 1834 | - 'label' => __( 'Who Can Edit Settings?', 'betterdocs' ), | |
| 1835 | - 'priority' => 2, | |
| 1836 | - 'multiple' => true, | |
| 1837 | - 'is_pro' => true, | |
| 1838 | - 'search' => true, | |
| 1839 | - 'default' => [ 'administrator' ], | |
| 1840 | - 'options' => $wp_roles | |
| 1841 | - ], | |
| 1842 | - 'analytics_roles' => [ | |
| 1843 | - 'name' => 'analytics_roles', | |
| 1844 | - 'type' => 'checkbox-select', | |
| 1845 | - 'label' => __( 'Who Can Check Analytics?', 'betterdocs' ), | |
| 1846 | - 'priority' => 3, | |
| 1847 | - 'multiple' => true, | |
| 1848 | - 'is_pro' => true, | |
| 1849 | - 'search' => true, | |
| 1850 | - 'default' => [ 'administrator' ], | |
| 1851 | - 'options' => $wp_roles | |
| 1852 | - ], | |
| 1853 | - 'faq_roles' => [ | |
| 1854 | - 'name' => 'faq_roles', | |
| 1855 | - 'type' => 'checkbox-select', | |
| 1856 | - 'label' => __( 'Who Can Check FAQ Builder?', 'betterdocs' ), | |
| 1857 | - 'priority' => 4, | |
| 1858 | - 'multiple' => true, | |
| 1859 | - 'is_pro' => true, | |
| 1860 | - 'search' => true, | |
| 1861 | - 'default' => [ 'administrator' ], | |
| 1862 | - 'options' => $wp_roles | |
| 1863 | - ], | |
| 1864 | - | |
| 1865 | - ] | |
| 1866 | - ], | |
| 1867 | - 'internal_knowledge_base' => [ | |
| 1868 | - 'id' => 'internal_knowledge_base', | |
| 1869 | - 'name' => 'internal_knowledge_base', | |
| 1870 | - 'type' => 'section', | |
| 1871 | - 'label' => __('Internal Knowledge Base', 'betterdocs'), | |
| 1872 | - 'priority' => 1, | |
| 1873 | - 'fields' => apply_filters('betterdocs_settings_content_restriction_fields', [ | |
| 1874 | - 'enable_content_restriction' => [ | |
| 1875 | - 'name' => 'enable_content_restriction', | |
| 1876 | - 'type' => 'toggle', | |
| 1877 | - 'is_pro' => true, | |
| 1878 | - 'priority' => 5, | |
| 1879 | - 'label' => __( 'Internal Knowledge Base', 'betterdocs' ), | |
| 1880 | - 'enable_disable_text_active' => true, | |
| 1881 | - 'default' => [ 'all' ] | |
| 1882 | - ], | |
| 1883 | - 'internal_knowledge_base_type' => [ | |
| 1884 | - 'name' => 'internal_knowledge_base_type', | |
| 1885 | - 'type' => 'radio-card', | |
| 1886 | - 'label' => __( 'Choose a Rule Type', 'betterdocs' ), | |
| 1887 | - 'label_subtitle' => __( 'Choose a rule type: apply access globally (Basic), or configure detailed restrictions (Advanced) for docs, categories, and KBs.', 'betterdocs' ), | |
| 1888 | - 'priority' => 6, | |
| 1889 | - 'multiple' => true, | |
| 1890 | - 'search' => true, | |
| 1891 | - 'default' => [ 'all' ], | |
| 1892 | - 'placeholder' => __( 'Select any', 'betterdocs' ), | |
| 1893 | - 'options' => [ | |
| 1894 | - [ | |
| 1895 | - 'label' => 'Basic', | |
| 1896 | - 'value' => 'basic' | |
| 1897 | - ], | |
| 1898 | - [ | |
| 1899 | - 'label' => 'Advanced', | |
| 1900 | - 'value' => 'advanced' | |
| 1901 | - ] | |
| 1902 | - ], | |
| 1903 | - 'filterValue' => 'all', | |
| 1904 | - 'rules' => Rules::is( 'enable_content_restriction', true ) | |
| 1905 | - ], | |
| 1906 | - 'content_visibility' => [ | |
| 1907 | - 'name' => 'content_visibility', | |
| 1908 | - 'type' => 'checkbox-select', | |
| 1909 | - 'label' => __( 'Restrict Access to', 'betterdocs' ), | |
| 1910 | - 'label_subtitle' => __( 'Only selected User Roles will be able to view your Knowledge Base', 'betterdocs' ), | |
| 1911 | - 'is_pro' => true, | |
| 1912 | - 'priority' => 7, | |
| 1913 | - 'multiple' => true, | |
| 1914 | - 'search' => true, | |
| 1915 | - 'default' => [ 'all' ], | |
| 1916 | - 'placeholder' => __( 'Select any', 'betterdocs' ), | |
| 1917 | - 'options' => $roles_for_ikb, | |
| 1918 | - 'rules' => Rules::logicalRule( | |
| 1919 | - [ | |
| 1920 | - Rules::is( 'enable_content_restriction', true ), | |
| 1921 | - Rules::is( 'internal_knowledge_base_type', 'basic' ) | |
| 1922 | - ], | |
| 1923 | - 'and' | |
| 1924 | - ), | |
| 1925 | - 'filterValue' => 'all' | |
| 1926 | - ], | |
| 1927 | - 'restrict_template' => [ | |
| 1928 | - 'name' => 'restrict_template', | |
| 1929 | - 'type' => 'checkbox-select', | |
| 1930 | - 'label' => __( 'Restriction on Docs', 'betterdocs' ), | |
| 1931 | - 'label_subtitle' => __( 'Selected Docs pages will be restricted', 'betterdocs' ), | |
| 1932 | - 'is_pro' => true, | |
| 1933 | - 'priority' => 8, | |
| 1934 | - 'multiple' => true, | |
| 1935 | - 'search' => true, | |
| 1936 | - 'default' => [ 'all' ], | |
| 1937 | - 'placeholder' => __( 'Select any', 'betterdocs' ), | |
| 1938 | - 'options' => $this->get_texanomy(), | |
| 1939 | - 'rules' => Rules::logicalRule( | |
| 1940 | - [ | |
| 1941 | - Rules::is( 'enable_content_restriction', true ), | |
| 1942 | - Rules::is( 'internal_knowledge_base_type', 'basic' ) | |
| 1943 | - ], | |
| 1944 | - 'and' | |
| 1945 | - ), | |
| 1946 | - 'filterValue' => 'all' | |
| 1947 | - ], | |
| 1948 | - 'restrict_category' => [ | |
| 1949 | - 'name' => 'restrict_category', | |
| 1950 | - 'type' => 'checkbox-select', | |
| 1951 | - 'label' => __( 'Restriction on Docs Categories', 'betterdocs' ), | |
| 1952 | - 'label_subtitle' => __( 'Selected Docs categories will be restricted', 'betterdocs' ), | |
| 1953 | - 'is_pro' => true, | |
| 1954 | - 'priority' => 9, | |
| 1955 | - 'multiple' => true, | |
| 1956 | - 'search' => true, | |
| 1957 | - 'default' => [ 'all' ], | |
| 1958 | - 'placeholder' => __( 'Select any', 'betterdocs' ), | |
| 1959 | - 'options' => $this->get_terms( 'doc_category' ), | |
| 1960 | - 'rules' => Rules::logicalRule( | |
| 1961 | - [ | |
| 1962 | - Rules::is( 'enable_content_restriction', true ), | |
| 1963 | - Rules::is( 'internal_knowledge_base_type', 'basic' ) | |
| 1964 | - ], | |
| 1965 | - 'and' | |
| 1966 | - ), | |
| 1967 | - 'filterValue' => 'all' | |
| 1968 | - ], | |
| 1969 | - 'restricted_redirect_url' => [ | |
| 1970 | - 'name' => 'restricted_redirect_url', | |
| 1971 | - 'type' => 'text', | |
| 1972 | - 'label' => __( 'Redirect URL', 'betterdocs' ), | |
| 1973 | - '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' ), | |
| 1974 | - 'default' => '', | |
| 1975 | - 'placeholder' => 'https://', | |
| 1976 | - 'is_pro' => true, | |
| 1977 | - 'priority' => 20, | |
| 1978 | - 'rules' => Rules::logicalRule( | |
| 1979 | - [ | |
| 1980 | - Rules::is( 'enable_content_restriction', true ), | |
| 1981 | - ], | |
| 1982 | - 'and' | |
| 1983 | - ) | |
| 1984 | - ] | |
| 1985 | - ] ) | |
| 1986 | - ] | |
| 1987 | - ] | |
| 1667 | + 'fields' => apply_filters( 'betterdocs_internal_kb_fields', [ | |
| 1668 | + 'article_roles' => [ | |
| 1669 | + 'name' => 'article_roles', | |
| 1670 | + 'type' => 'checkbox-select', | |
| 1671 | + 'label' => __( 'Who Can Write Docs?', 'betterdocs' ), | |
| 1672 | + 'priority' => 1, | |
| 1673 | + 'multiple' => true, | |
| 1674 | + 'search' => true, | |
| 1675 | + 'is_pro' => true, | |
| 1676 | + 'default' => [ 'administrator' ], | |
| 1677 | + 'options' => $wp_roles | |
| 1678 | + ], | |
| 1679 | + 'settings_roles' => [ | |
| 1680 | + 'name' => 'settings_roles', | |
| 1681 | + 'type' => 'checkbox-select', | |
| 1682 | + 'label' => __( 'Who Can Edit Settings?', 'betterdocs' ), | |
| 1683 | + 'priority' => 2, | |
| 1684 | + 'multiple' => true, | |
| 1685 | + 'is_pro' => true, | |
| 1686 | + 'search' => true, | |
| 1687 | + 'default' => [ 'administrator' ], | |
| 1688 | + 'options' => $wp_roles | |
| 1689 | + ], | |
| 1690 | + 'analytics_roles' => [ | |
| 1691 | + 'name' => 'analytics_roles', | |
| 1692 | + 'type' => 'checkbox-select', | |
| 1693 | + 'label' => __( 'Who Can Check Analytics?', 'betterdocs' ), | |
| 1694 | + 'priority' => 3, | |
| 1695 | + 'multiple' => true, | |
| 1696 | + 'is_pro' => true, | |
| 1697 | + 'search' => true, | |
| 1698 | + 'default' => [ 'administrator' ], | |
| 1699 | + 'options' => $wp_roles | |
| 1700 | + ], | |
| 1701 | + 'enable_content_restriction' => [ | |
| 1702 | + 'name' => 'enable_content_restriction', | |
| 1703 | + 'type' => 'toggle', | |
| 1704 | + 'is_pro' => true, | |
| 1705 | + 'priority' => 4, | |
| 1706 | + 'label' => __( 'Internal Knowledge Base', 'betterdocs' ), | |
| 1707 | + 'enable_disable_text_active' => true, | |
| 1708 | + 'default' => [ 'all' ] | |
| 1709 | + ], | |
| 1710 | + 'content_visibility' => [ | |
| 1711 | + 'name' => 'content_visibility', | |
| 1712 | + 'type' => 'checkbox-select', | |
| 1713 | + 'label' => __( 'Restrict Access to', 'betterdocs' ), | |
| 1714 | + 'label_subtitle' => __( 'Only selected User Roles will be able to view your Knowledge Base', 'betterdocs' ), | |
| 1715 | + 'is_pro' => true, | |
| 1716 | + 'priority' => 5, | |
| 1717 | + 'multiple' => true, | |
| 1718 | + 'search' => true, | |
| 1719 | + 'default' => [ 'all' ], | |
| 1720 | + 'placeholder' => __( 'Select any', 'betterdocs' ), | |
| 1721 | + 'options' => $this->normalize_options( array_merge( [ | |
| 1722 | + 'all' => __( 'All logged in users', 'betterdocs' ) | |
| 1723 | + ], wp_roles()->role_names ) ), | |
| 1724 | + 'rules' => Rules::is( 'enable_content_restriction', true ), | |
| 1725 | + 'filterValue' => 'all' | |
| 1726 | + ], | |
| 1727 | + 'restrict_template' => [ | |
| 1728 | + 'name' => 'restrict_template', | |
| 1729 | + 'type' => 'checkbox-select', | |
| 1730 | + 'label' => __( 'Restriction on Docs', 'betterdocs' ), | |
| 1731 | + 'label_subtitle' => __( 'Selected Docs pages will be restricted', 'betterdocs' ), | |
| 1732 | + 'is_pro' => true, | |
| 1733 | + 'priority' => 6, | |
| 1734 | + 'multiple' => true, | |
| 1735 | + 'search' => true, | |
| 1736 | + 'default' => [ 'all' ], | |
| 1737 | + 'placeholder' => __( 'Select any', 'betterdocs' ), | |
| 1738 | + 'options' => $this->get_texanomy(), | |
| 1739 | + 'rules' => Rules::is( 'enable_content_restriction', true ), | |
| 1740 | + 'filterValue' => 'all' | |
| 1741 | + ], | |
| 1742 | + 'restrict_category' => [ | |
| 1743 | + 'name' => 'restrict_category', | |
| 1744 | + 'type' => 'checkbox-select', | |
| 1745 | + 'label' => __( 'Restriction on Docs Categories', 'betterdocs' ), | |
| 1746 | + 'label_subtitle' => __( 'Selected Docs categories will be restricted', 'betterdocs' ), | |
| 1747 | + 'is_pro' => true, | |
| 1748 | + 'priority' => 7, | |
| 1749 | + 'multiple' => true, | |
| 1750 | + 'search' => true, | |
| 1751 | + 'default' => [ 'all' ], | |
| 1752 | + 'placeholder' => __( 'Select any', 'betterdocs' ), | |
| 1753 | + 'options' => $this->get_terms( 'doc_category' ), | |
| 1754 | + 'rules' => Rules::is( 'enable_content_restriction', true ), | |
| 1755 | + 'filterValue' => 'all' | |
| 1756 | + ], | |
| 1757 | + 'restricted_redirect_url' => [ | |
| 1758 | + 'name' => 'restricted_redirect_url', | |
| 1759 | + 'type' => 'text', | |
| 1760 | + 'label' => __( 'Redirect URL', 'betterdocs' ), | |
| 1761 | + 'label_subtitle' => __( 'Set a custom URL to redirect users without permissions when they try to access internal knowledge base. By default, restricted content will redirect to the "404 not found" page', 'betterdocs' ), | |
| 1762 | + 'default' => '', | |
| 1763 | + 'placeholder' => 'https://', | |
| 1764 | + 'is_pro' => true, | |
| 1765 | + 'priority' => 9, | |
| 1766 | + 'rules' => Rules::is( 'enable_content_restriction', true ) | |
| 1988 | 1767 | ] |
| 1989 | - ] | |
| 1768 | + ] ) | |
| 1990 | 1769 | ] |
| 1991 | 1770 | ] |
| 1992 | 1771 | ] ), |
| 1993 | 1772 | 'tab-email-reporting' => apply_filters( 'betterdocs_settings_tab_email_reporting', [ |
| @@ -2105,33 +1884,8 @@ | ||
| 2105 | 1884 | ] |
| 2106 | 1885 | ] |
| 2107 | 1886 | ] |
| 2108 | 1887 | ] ), |
| 2109 | - 'tab-github-integration' => apply_filters( 'betterdocs_settings_tab_github_integration', [ | |
| 2110 | - 'id' => 'tab-github-integration', | |
| 2111 | - 'label' => __( 'Git Sync', 'betterdocs' ), | |
| 2112 | - 'priority' => 60, | |
| 2113 | - 'fields' => [ | |
| 2114 | - 'title-git-integration' => [ | |
| 2115 | - 'name' => 'title-git-integration-tab', | |
| 2116 | - 'type' => 'section', | |
| 2117 | - 'label' => __( 'Git Sync Settings', 'betterdocs' ), | |
| 2118 | - 'priority' => 60, | |
| 2119 | - 'fields' => [ | |
| 2120 | - 'enable_git_integration' => [ | |
| 2121 | - 'name' => 'enable_git_integration', | |
| 2122 | - 'type' => 'toggle', | |
| 2123 | - 'label' => __( 'Enable Git Sync', 'betterdocs' ), | |
| 2124 | - 'enable_disable_text_active' => true, | |
| 2125 | - 'default' => false, | |
| 2126 | - 'priority' => 1, | |
| 2127 | - 'is_pro' => true, | |
| 2128 | - 'label_subtitle' => __( 'Enable bidirectional synchronization between BetterDocs and Git repositories', 'betterdocs' ) | |
| 2129 | - ] | |
| 2130 | - ] | |
| 2131 | - ] | |
| 2132 | - ] | |
| 2133 | - ] ), | |
| 2134 | 1888 | 'tab-instant-answer' => apply_filters( 'betterdocs_settings_tab_instant_answer', [ |
| 2135 | 1889 | 'id' => 'tab-instant-answer', |
| 2136 | 1890 | 'name' => 'tab-instant-answer', |
| 2137 | 1891 | 'type' => 'section', |
| @@ -2167,201 +1921,99 @@ | ||
| 2167 | 1921 | ] ) |
| 2168 | 1922 | ] |
| 2169 | 1923 | ] |
| 2170 | 1924 | ] ), |
| 2171 | - 'tab-betterdocs-ai' => [ | |
| 2172 | - 'id' => 'tab-betterdocs-ai', | |
| 2173 | - 'name' => 'tab-betterdocs-ai', | |
| 2174 | - 'type' => 'section', | |
| 2175 | - 'label' => __( 'AI Content Suite', 'betterdocs' ), | |
| 2176 | - 'priority' => 74, | |
| 2177 | - 'fields' => [ | |
| 2178 | - 'sections-betterdocs-ai' => [ | |
| 2179 | - 'name' => 'sections-betterdocs-ai', | |
| 2180 | - 'type' => 'section', | |
| 2181 | - 'label' => __( 'AI Content Suite', 'betterdocs' ), | |
| 2182 | - 'priority' => 10, | |
| 2183 | - 'fields' => [ | |
| 2184 | - 'all-betterdocs-ai' => [ | |
| 2185 | - 'id' => 'all-tab-betterdocs-ai', | |
| 2186 | - 'name' => 'all-tab-betterdocs-ai', | |
| 2187 | - 'label' => __( 'AI Content Suite Settings', 'betterdocs' ), | |
| 2188 | - 'classes' => 'tab-layout', | |
| 2189 | - 'type' => 'tab', | |
| 2190 | - 'active' => 'open-ai-settings', | |
| 2191 | - 'completionTrack' => true, | |
| 2192 | - 'sidebar' => false, | |
| 2193 | - 'save' => false, | |
| 2194 | - 'title' => false, | |
| 2195 | - 'config' => [ | |
| 2196 | - 'active' => 'open-ai-settings', | |
| 2197 | - 'sidebar' => false, | |
| 2198 | - 'title' => false | |
| 2199 | - ], | |
| 2200 | - 'submit' => [ | |
| 2201 | - 'show' => false | |
| 2202 | - ], | |
| 2203 | - 'step' => [ | |
| 2204 | - 'show' => false | |
| 2205 | - ], | |
| 2206 | - 'priority' => 20, | |
| 2207 | - 'fields' => apply_filters( | |
| 2208 | - 'betterdocs_migration_tab_sections', | |
| 2209 | - [ | |
| 2210 | - 'open-ai-settings' => [ | |
| 2211 | - 'id' => 'open-ai-settings', | |
| 2212 | - 'name' => 'open-ai-settings', | |
| 2213 | - 'type' => 'section', | |
| 2214 | - 'label' => __( 'API Settings', 'betterdocs' ), | |
| 2215 | - 'priority' => 1, | |
| 2216 | - 'fields' => [ | |
| 2217 | - 'ai_autowrite_api_key' => [ | |
| 2218 | - 'name' => 'ai_autowrite_api_key', | |
| 2219 | - 'type' => 'text', | |
| 2220 | - 'label' => __( 'API Key', 'betterdocs' ), | |
| 2221 | - 'label_subtitle' => sprintf( /* translators: %s is a link to the documentation about generating an OpenAI API key. */ __( 'Check out this <a target="_blank" href="%s">documentation</a> to find out how to generate your OpenAI API Key.', 'betterdocs' ), esc_url( 'https://betterdocs.co/docs/write-with-ai/' ) ), | |
| 2222 | - 'default' => '', | |
| 2223 | - 'priority' => 1 | |
| 2224 | - ], | |
| 2225 | - ] | |
| 2226 | - ], | |
| 2227 | - 'write-with-ai' => [ | |
| 2228 | - 'id' => 'write-with-ai', | |
| 2229 | - 'name' => 'write-with-ai', | |
| 2230 | - 'type' => 'section', | |
| 2231 | - 'label' => __( 'Write with AI', 'betterdocs' ), | |
| 2232 | - 'priority' => 5, | |
| 2233 | - 'fields' => [ | |
| 2234 | - 'enable_write_with_ai' => [ | |
| 2235 | - 'name' => 'enable_write_with_ai', | |
| 2236 | - 'type' => 'toggle', | |
| 2237 | - 'priority' => 0, | |
| 2238 | - 'label' => __( 'Write Docs with AI', 'betterdocs' ), | |
| 2239 | - 'label_subtitle' => __( 'Generate AI based Documentation in your Gutenberg Editor', 'betterdocs' ), | |
| 2240 | - 'enable_disable_text_active' => true, | |
| 2241 | - 'default' => true | |
| 2242 | - ], | |
| 2243 | - 'enable_faq_write_with_ai' => [ | |
| 2244 | - 'name' => 'enable_faq_write_with_ai', | |
| 2245 | - 'type' => 'toggle', | |
| 2246 | - 'priority' => 5, | |
| 2247 | - 'label' => __( 'Write FAQ with AI', 'betterdocs' ), | |
| 2248 | - 'label_subtitle' => __( 'Generate AI based FAQ in your Editor', 'betterdocs' ), | |
| 2249 | - 'enable_disable_text_active' => true, | |
| 2250 | - 'default' => true | |
| 2251 | - ], | |
| 2252 | - 'write_with_ai_model' => [ | |
| 2253 | - 'name' => 'write_with_ai_model', | |
| 2254 | - 'type' => 'select', | |
| 2255 | - 'label' => __( 'OpenAI Model*', 'betterdocs' ), | |
| 2256 | - 'priority' => 20, | |
| 2257 | - 'multiple' => false, | |
| 2258 | - 'default' => 'gpt-4o-mini', | |
| 2259 | - 'options' => GlobalFields::normalize_fields( [ | |
| 2260 | - 'gpt-4o-mini' => 'GPT-4o Mini', | |
| 2261 | - 'gpt-4o' => 'GPT-4o', | |
| 2262 | - ] ), | |
| 2263 | - ], | |
| 2264 | - 'ai_autowrite_max_token' => [ | |
| 2265 | - 'name' => 'ai_autowrite_max_token', | |
| 2266 | - 'type' => 'number', | |
| 2267 | - 'label' => __( 'Set Max Tokens', 'betterdocs' ), | |
| 2268 | - 'label_subtitle' => sprintf( // translators: %s is a link to more information about token limits. | |
| 2269 | - __( 'Documentation will be generated based on the Token Limits you have set. For more information on Token Limits, you can check out this <a target="_blank" href="%s">link</a>.', 'betterdocs' ), esc_url( 'https://platform.openai.com/account/limits' ) ), | |
| 2270 | - 'default' => 1500, | |
| 2271 | - 'priority' => 10 | |
| 2272 | - ], | |
| 2273 | - ] | |
| 2274 | - ], | |
| 2275 | - 'article-summary' => [ | |
| 2276 | - 'id' => 'article-summary', | |
| 2277 | - 'name' => 'article-summary', | |
| 2278 | - 'type' => 'section', | |
| 2279 | - 'label' => __( 'AI Doc Summarizer', 'betterdocs' ), | |
| 2280 | - 'priority' => 10, | |
| 2281 | - 'fields' => [ | |
| 2282 | - 'enable_article_summary' => [ | |
| 2283 | - 'name' => 'enable_article_summary', | |
| 2284 | - 'type' => 'toggle', | |
| 2285 | - 'priority' => 1, | |
| 2286 | - 'label' => __( 'AI Powered Doc Summarizer', 'betterdocs' ), | |
| 2287 | - 'label_subtitle' => __( 'Enable AI-powered article summaries on single doc pages. Requires OpenAI API key.', 'betterdocs' ), | |
| 2288 | - 'enable_disable_text_active' => true, | |
| 2289 | - 'default' => false | |
| 2290 | - ], | |
| 2291 | - 'article_summary_max_token' => [ | |
| 2292 | - 'name' => 'article_summary_max_token', | |
| 2293 | - 'type' => 'number', | |
| 2294 | - 'label' => __( 'Set Max Tokens', 'betterdocs' ), | |
| 2295 | - 'label_subtitle' => sprintf( // translators: %s is a link to more information about token limits. | |
| 2296 | - __( 'Single Doc summarizer will be generated based on the token limits you have set. For more information on Token Limits, you can check out this <a target="_blank" href="%s">link</a>.', 'betterdocs' ), esc_url( 'https://platform.openai.com/account/limits' ) ), | |
| 2297 | - 'default' => 1500, | |
| 2298 | - 'priority' => 5 | |
| 2299 | - ], | |
| 2300 | - 'article_summary_model' => [ | |
| 2301 | - 'name' => 'article_summary_model', | |
| 2302 | - 'type' => 'select', | |
| 2303 | - 'label' => __( 'OpenAI Model*', 'betterdocs' ), | |
| 2304 | - 'priority' => 10, | |
| 2305 | - 'multiple' => false, | |
| 2306 | - 'default' => 'gpt-4o-mini', | |
| 2307 | - 'options' => GlobalFields::normalize_fields( [ | |
| 2308 | - 'gpt-4o-mini' => 'GPT-4o Mini', | |
| 2309 | - 'gpt-4o' => 'GPT-4o', | |
| 2310 | - ] ), | |
| 2311 | - ], | |
| 2312 | - ] | |
| 2313 | - ], | |
| 2314 | - ] | |
| 2315 | - ) | |
| 2316 | - ] | |
| 2317 | - ] | |
| 2318 | - ] | |
| 2319 | - ], | |
| 2320 | - ], | |
| 2321 | - 'tab-ai-chatbot' => apply_filters( 'betterdocs_settings_tab_ai_chatbot', [ | |
| 1925 | + 'tab-ai-chatbot' => [ | |
| 2322 | 1926 | 'id' => 'tab-ai-chatbot', |
| 2323 | 1927 | 'name' => 'tab-ai-chatbot', |
| 2324 | 1928 | 'type' => 'section', |
| 2325 | 1929 | 'label' => __( 'AI Chatbot', 'betterdocs' ), |
| 1930 | + // 'is_pro' => ! defined('BETTERDOCS_PRO_VERSION'), | |
| 1931 | + 'priority' => 75, | |
| 1932 | + 'save' => false, | |
| 2326 | 1933 | 'submit' => [ |
| 2327 | 1934 | 'show' => false |
| 2328 | 1935 | ], |
| 2329 | - 'save' => false, | |
| 2330 | - 'priority' => 75, | |
| 2331 | - 'fields' => [ | |
| 2332 | - 'title-ai-chatbot-tab' => [ | |
| 2333 | - 'name' => 'title-ai-chatbot-tab', | |
| 2334 | - 'type' => 'section', | |
| 2335 | - 'label' => __( 'AI Chatbot', 'betterdocs' ), | |
| 2336 | - 'priority' => 80, | |
| 1936 | + | |
| 1937 | + 'fields' => [ | |
| 1938 | + 'title-ai-chatbot' => apply_filters( 'betterdocs_settings_ai_chatbot_fields', [ | |
| 1939 | + 'name' => 'title-ai-chatbot-tab', | |
| 1940 | + 'type' => 'section', | |
| 1941 | + 'label' => __( 'AI Chatbot', 'betterdocs' ), | |
| 1942 | + 'priority' => 60, | |
| 1943 | + 'save' => false, | |
| 2337 | 1944 | 'submit' => [ |
| 2338 | 1945 | 'show' => false |
| 2339 | 1946 | ], |
| 2340 | - 'save' => false, | |
| 2341 | - 'fields' => apply_filters( 'betterdocs_ai_chatbot_fields', [ | |
| 2342 | - 'ai_chatbot_fields' => [ | |
| 2343 | - 'name' => 'ai_chatbot_fields', | |
| 2344 | - 'type' => 'section', | |
| 2345 | - 'priority' => 0, | |
| 2346 | - 'fields' => [ | |
| 2347 | - 'enable_ai_chatbot' => [ | |
| 2348 | - 'name' => 'enable_ai_chatbot', | |
| 2349 | - 'label' => __( 'AI Chatbot', 'betterdocs' ), | |
| 2350 | - 'description' => __( 'Enable AI Chatbot', 'betterdocs' ), | |
| 2351 | - 'type' => 'toggle', | |
| 2352 | - 'priority' => 5, | |
| 2353 | - 'default' => 0, | |
| 2354 | - 'is_pro' => true, | |
| 2355 | - 'is_license_active' => false, | |
| 2356 | - 'disabled' => ! betterdocs()->is_pro_active() || ! defined( 'BETTERDOCS_CHATBOT_FILE' ) | |
| 2357 | - ], | |
| 2358 | - ] | |
| 1947 | + | |
| 1948 | + 'fields' => [ | |
| 1949 | + 'enable_ai_chatbot' => [ | |
| 1950 | + 'name' => 'enable_ai_chatbot', | |
| 1951 | + 'label' => __( 'AI Chatbot', 'betterdocs' ), | |
| 1952 | + 'description' => __( 'Enable AI Chatbot', 'betterdocs' ), | |
| 1953 | + 'type' => 'toggle', | |
| 1954 | + 'priority' => 5, | |
| 1955 | + 'default' => 0, | |
| 1956 | + 'is_pro' => true, | |
| 1957 | + 'is_license_active' => false, | |
| 1958 | + 'disabled' => ! betterdocs()->is_pro_active() || ! defined( 'BETTERDOCS_CHATBOT_FILE' ) | |
| 1959 | + ], | |
| 1960 | + ] | |
| 1961 | + ] ), | |
| 1962 | + ] | |
| 1963 | + ], | |
| 1964 | + 'tab-ai-autowrite' => [ | |
| 1965 | + 'id' => 'tab-ai-autowrite', | |
| 1966 | + 'name' => 'tab-ai-autowrite', | |
| 1967 | + 'type' => 'section', | |
| 1968 | + 'label' => __( 'Write with AI', 'betterdocs' ), | |
| 1969 | + 'priority' => 75, | |
| 1970 | + 'fields' => [ | |
| 1971 | + 'title-ai-autowrite' => apply_filters( 'betterdocs_settings_ai_autowrite_fields', [ | |
| 1972 | + 'name' => 'title-ai-autowrite-tab', | |
| 1973 | + 'type' => 'section', | |
| 1974 | + 'label' => __( 'Write with AI', 'betterdocs' ), | |
| 1975 | + 'priority' => 60, | |
| 1976 | + 'fields' => [ | |
| 1977 | + 'enable_write_with_ai' => [ | |
| 1978 | + 'name' => 'enable_write_with_ai', | |
| 1979 | + 'type' => 'toggle', | |
| 1980 | + 'priority' => 0, | |
| 1981 | + 'label' => __( 'Write Docs with AI', 'betterdocs' ), | |
| 1982 | + 'label_subtitle' => __( 'Generate AI based Documentation in your Gutenberg Editor', 'betterdocs' ), | |
| 1983 | + 'enable_disable_text_active' => true, | |
| 1984 | + 'default' => true | |
| 1985 | + ], | |
| 1986 | + 'enable_faq_write_with_ai' => [ | |
| 1987 | + 'name' => 'enable_faq_write_with_ai', | |
| 1988 | + 'type' => 'toggle', | |
| 1989 | + 'priority' => 5, | |
| 1990 | + 'label' => __( 'Write FAQ with AI', 'betterdocs' ), | |
| 1991 | + 'label_subtitle' => __( 'Generate AI based FAQ in your Editor', 'betterdocs' ), | |
| 1992 | + 'enable_disable_text_active' => true, | |
| 1993 | + 'default' => true | |
| 1994 | + ], | |
| 1995 | + 'ai_autowrite_api_key' => [ | |
| 1996 | + 'name' => 'ai_autowrite_api_key', | |
| 1997 | + 'type' => 'text', | |
| 1998 | + 'label' => __( 'API Key', 'betterdocs' ), | |
| 1999 | + 'label_subtitle' => sprintf( /* translators: %s is a link to the documentation about generating an OpenAI API key. */ __( 'Check out this <a target="_blank" href="%s">documentation</a> to find out how to generate your OpenAI API Key.', 'betterdocs' ), esc_url( 'https://betterdocs.co/docs/write-with-ai/' ) ), | |
| 2000 | + 'default' => '', | |
| 2001 | + 'priority' => 10 | |
| 2002 | + ], | |
| 2003 | + 'ai_autowrite_max_token' => [ | |
| 2004 | + 'name' => 'ai_autowrite_max_token', | |
| 2005 | + 'type' => 'number', | |
| 2006 | + 'label' => __( 'Set Max Tokens', 'betterdocs' ), | |
| 2007 | + 'label_subtitle' => sprintf( // translators: %s is a link to more information about token limits. | |
| 2008 | + __( 'Documentation will be generated based on the Token Limits you have set. For more information on Token Limits, you can check out this <a target="_blank" href="%s">link</a>.', 'betterdocs' ), esc_url( 'https://platform.openai.com/account/limits' ) ), | |
| 2009 | + 'default' => 1500, | |
| 2010 | + 'priority' => 15 | |
| 2359 | 2011 | ] |
| 2360 | - ] ) | |
| 2361 | - ] | |
| 2012 | + ] | |
| 2013 | + ] ) | |
| 2362 | 2014 | ] |
| 2363 | - ] ), | |
| 2015 | + ] | |
| 2364 | 2016 | ] ), |
| 2365 | 2017 | 'TAB_AI_CHATBOT' => get_option( 'enable_ai_chatbot' ), |
| 2366 | 2018 | 'CHATBOT_LICENSE' => get_option( 'betterdocs_chatbot_software__license_status' ), |
| 2367 | 2019 | 'PRO_ACTIVE' => is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' ), |
| @@ -2376,20 +2028,10 @@ | ||
| 2376 | 2028 | /** |
| 2377 | 2029 | * @return array |
| 2378 | 2030 | */ |
| 2379 | 2031 | public function chatbot_active_localize() { |
| 2380 | - $chatbot_active = is_plugin_active( 'betterdocs-ai-chatbot/betterdocs-ai-chatbot.php' ); | |
| 2381 | - $chatbot_license_valid = get_option( 'betterdocs_chatbot_software__license_status' ) === 'valid'; | |
| 2382 | - $chatbot_enabled = $this->get( 'enable_ai_chatbot', false ); | |
| 2383 | - | |
| 2384 | - // AI Search Suggestions are enabled if all conditions are met | |
| 2385 | - $ai_search_suggestions_enabled = betterdocs()->helper->is_ai_chatbot_enabled(); | |
| 2386 | - | |
| 2387 | 2032 | return [ |
| 2388 | - 'CHATBOT_ACTIVE' => $chatbot_active, | |
| 2389 | - 'CHATBOT_LICENSE_VALID' => $chatbot_license_valid, | |
| 2390 | - 'CHATBOT_ENABLED' => $chatbot_enabled, | |
| 2391 | - 'AI_SEARCH_SUGGESTIONS_ENABLED' => $ai_search_suggestions_enabled | |
| 2033 | + 'CHATBOT_ACTIVE' => is_plugin_active( 'betterdocs-ai-chatbot/betterdocs-ai-chatbot.php' ) | |
| 2392 | 2034 | ]; |
| 2393 | 2035 | } |
| 2394 | 2036 | |
| 2395 | 2037 | /** |
| @@ -2647,9 +2289,9 @@ | ||
| 2647 | 2289 | 'multiple' => true, |
| 2648 | 2290 | 'search' => true, |
| 2649 | 2291 | 'default' => [ 'all' ], |
| 2650 | 2292 | 'placeholder' => __( 'Select any', 'betterdocs' ), |
| 2651 | - 'options' => $this->get_terms( 'doc_category', false ), | |
| 2293 | + 'options' => $this->get_terms( 'doc_category' ), | |
| 2652 | 2294 | 'filterValue' => 'all', |
| 2653 | 2295 | 'rules' => Rules::is( 'export_type', 'doc_category' ) |
| 2654 | 2296 | ], |
| 2655 | 2297 | 'export_glossaries' => [ |
| @@ -2766,19 +2408,8 @@ | ||
| 2766 | 2408 | |
| 2767 | 2409 | return $settings; |
| 2768 | 2410 | } |
| 2769 | 2411 | |
| 2770 | - public function maybe_remove_git_tab( $tabs ) { | |
| 2771 | - $pro_active = is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' ); | |
| 2772 | - $pro_has_git = apply_filters( 'betterdocs_pro_has_git_integration', false ); | |
| 2773 | - | |
| 2774 | - if ( $pro_active && ! $pro_has_git ) { | |
| 2775 | - unset( $tabs['tab-github-integration'] ); | |
| 2776 | - } | |
| 2777 | - | |
| 2778 | - return $tabs; | |
| 2779 | - } | |
| 2780 | - | |
| 2781 | 2412 | public function normalize_options( $options ) { |
| 2782 | 2413 | return GlobalFields::normalize_fields( $options ); |
| 2783 | 2414 | } |
| 2784 | 2415 | |
| @@ -2809,9 +2440,9 @@ | ||
| 2809 | 2440 | |
| 2810 | 2441 | return $docs_tax; |
| 2811 | 2442 | } |
| 2812 | 2443 | |
| 2813 | - public function get_terms( $taxonomy, $hide_empty = true ) { | |
| 2444 | + public function get_terms( $taxonomy ) { | |
| 2814 | 2445 | $_cache_key = 'betterdocs::settings::terms::' . trim( $taxonomy ); |
| 2815 | 2446 | $docs_tax = $this->database->get_cache( $_cache_key ); |
| 2816 | 2447 | |
| 2817 | 2448 | if ( $docs_tax ) { |
| @@ -2819,9 +2450,9 @@ | ||
| 2819 | 2450 | } |
| 2820 | 2451 | |
| 2821 | 2452 | $get_terms = get_terms( [ |
| 2822 | 2453 | 'taxonomy' => $taxonomy, |
| 2823 | - 'hide_empty' => $hide_empty | |
| 2454 | + 'hide_empty' => false | |
| 2824 | 2455 | ] ); |
| 2825 | 2456 | |
| 2826 | 2457 | $terms = [ |
| 2827 | 2458 | 'all' => 'All' |
| @@ -2842,40 +2473,8 @@ | ||
| 2842 | 2473 | |
| 2843 | 2474 | return $terms; |
| 2844 | 2475 | } |
| 2845 | 2476 | |
| 2846 | - public function get_terms_with_ids( $taxonomy ) { | |
| 2847 | - $_cache_key = 'betterdocs::settings::terms::ids' . trim( $taxonomy ); | |
| 2848 | - $docs_tax = $this->database->get_cache( $_cache_key ); | |
| 2849 | - | |
| 2850 | - if ( $docs_tax ) { | |
| 2851 | - return $docs_tax; | |
| 2852 | - } | |
| 2853 | - | |
| 2854 | - $get_terms = get_terms( [ | |
| 2855 | - 'taxonomy' => $taxonomy, | |
| 2856 | - 'hide_empty' => false, | |
| 2857 | - 'suppress_filter' => true, | |
| 2858 | - ] ); | |
| 2859 | - | |
| 2860 | - $terms = []; | |
| 2861 | - | |
| 2862 | - if ( ! empty( $get_terms ) && ! is_wp_error( $get_terms ) ) { | |
| 2863 | - foreach ( $get_terms as $value ) { | |
| 2864 | - if ( isset( $value->term_id ) && isset( $value->name ) ) { | |
| 2865 | - $terms[ $value->term_id ] = $value->name; | |
| 2866 | - } | |
| 2867 | - } | |
| 2868 | - } | |
| 2869 | - | |
| 2870 | - $terms = $this->normalize_options( $terms ); | |
| 2871 | - if ( count( $terms ) > 1 ) { | |
| 2872 | - $this->database->set_cache( $_cache_key, $terms ); | |
| 2873 | - } | |
| 2874 | - | |
| 2875 | - return $terms; | |
| 2876 | - } | |
| 2877 | - | |
| 2878 | 2477 | /** |
| 2879 | 2478 | * Get all docs |
| 2880 | 2479 | */ |
| 2881 | 2480 | public function docs() { |
| @@ -2910,9 +2509,8 @@ | ||
| 2910 | 2509 | if ( $current_user instanceof WP_User && ! in_array( 'administrator', $current_user->roles ) ) { |
| 2911 | 2510 | unset( $tabData['fields']['title-advance-settings']['fields']['article_roles'] ); |
| 2912 | 2511 | unset( $tabData['fields']['title-advance-settings']['fields']['settings_roles'] ); |
| 2913 | 2512 | unset( $tabData['fields']['title-advance-settings']['fields']['analytics_roles'] ); |
| 2914 | - unset( $tabData['fields']['title-advance-settings']['fields']['faq_roles'] ); | |
| 2915 | 2513 | } |
| 2916 | 2514 | |
| 2917 | 2515 | return $tabData; |
| 2918 | 2516 | } |