PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.5
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.5
4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 All 203 releases
← All changes | includes/Core/Settings.php +3347 -2748 4.4.0 → 4.9.5 View file →
@@ -1,2888 +1,3487 @@
1 1 <?php
2 +namespace WPDeveloper\BetterDocs\Core;
2 3
3 -namespace WPDeveloper\BetterDocs\Core;
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
4 7
8 +
5 9 use WP_Error;
6 10 use WP_User;
7 11 use WPDeveloper\BetterDocs\Admin\Builder\GlobalFields;
8 12 use WPDeveloper\BetterDocs\Admin\Builder\Rules;
13 +use WPDeveloper\BetterDocs\AI\ModelRegistry;
14 +use WPDeveloper\BetterDocs\AI\ProviderFactory;
15 +use WPDeveloper\BetterDocs\REST\AIEdit;
16 +use WPDeveloper\BetterDocs\Utils\AIHelper;
9 17 use WPDeveloper\BetterDocs\Utils\Base;
10 18 use WPDeveloper\BetterDocs\Utils\Database;
19 +use WPDeveloper\BetterDocs\Utils\Helper;
11 20
21 +class Settings extends Base {
22 + public $base_key = 'betterdocs_settings';
12 23
13 -class Settings extends Base {
14 - public $base_key = 'betterdocs_settings';
24 + /**
25 + * Database class
26 + * @var Database
27 + */
28 + protected $database;
15 29
16 - /**
17 - * Database class
18 - * @var Database
19 - */
20 - protected $database;
30 + private $deprecated = array();
21 31
22 - private $deprecated = [];
32 + private $cannot_be_empty = array(
33 + 'breadcrumb_doc_title',
34 + 'docs_slug',
35 + 'category_slug',
36 + 'tag_slug',
37 + 'permalink_structure',
38 + 'docs_page'
39 + );
23 40
24 - private $cannot_be_empty = [
25 - 'breadcrumb_doc_title',
26 - 'docs_slug',
27 - 'category_slug',
28 - 'tag_slug',
29 - 'permalink_structure',
30 - 'docs_page'
31 - ];
41 + public function __construct( Database $database ) {
42 + $this->database = $database;
43 + $this->deprecated = $this->deprecated_settings();
32 44
33 - public function __construct( Database $database ) {
34 - $this->database = $database;
35 - $this->deprecated = $this->deprecated_settings();
45 + add_filter( 'betterdocs_settings_tabs', array( $this, 'import_export_settings' ) );
46 + add_filter( 'betterdocs_settings_tabs', array( $this, 'maybe_remove_git_tab' ), 20 );
36 47
37 - add_filter( 'betterdocs_settings_tabs', [ $this, 'import_export_settings' ] );
38 - add_filter( 'betterdocs_settings_tabs', [ $this, 'maybe_remove_git_tab' ], 20 );
48 + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_old' ), 99 );
49 + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 99 );
39 50
40 - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_old' ], 99 );
41 - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ], 99 );
51 + // if ( isset( $_GET['page'] ) && $_GET['page'] === 'betterdocs-settings' && ! has_action( 'betterdocs_settings_header' ) ) {
52 + // add_action( 'betterdocs_settings_header', [ $this, 'header' ] );
53 + // }
42 54
43 - // if ( isset( $_GET['page'] ) && $_GET['page'] === 'betterdocs-settings' && ! has_action( 'betterdocs_settings_header' ) ) {
44 - // add_action( 'betterdocs_settings_header', [ $this, 'header' ] );
45 - // }
55 + add_action( 'wp_ajax_betterdocs_dark_mode', array( $this, 'dark_mode' ) );
56 + add_filter( 'betterdocs_settings_tab_advance', array( $this, 'hide_roles_management' ), 11, 1 );
57 + add_action( 'betterdocs::settings::saved', array( $this, 'fallback_slugs' ), 99, 3 );
58 + }
46 59
47 - add_action( 'wp_ajax_betterdocs_dark_mode', [ $this, 'dark_mode' ] );
48 - add_filter( 'betterdocs_settings_tab_advance', [ $this, 'hide_roles_management' ], 11, 1 );
49 - add_action( 'betterdocs::settings::saved', [ $this, 'fallback_slugs' ], 99, 3 );
50 - }
60 + public function fallback_slugs( $_saved, $_settings, $_old_settings = array() ) {
61 + $_default = $this->get_default();
62 + foreach ( $this->cannot_be_empty as $key ) {
63 + if ( 'docs_page' === $key && ! $_settings[ 'builtin_doc_page' ] && empty( $_settings[ $key ] ) ) {
64 + $this->save( 'builtin_doc_page', true );
65 + continue;
66 + }
51 67
52 - public function fallback_slugs( $_saved, $_settings, $_old_settings = [] ) {
53 - $_default = $this->get_default();
54 - foreach ( $this->cannot_be_empty as $key ) {
55 - if ( $key === 'docs_page' && ! $_settings['builtin_doc_page'] && empty( $_settings[ $key ] ) ) {
56 - $this->save( 'builtin_doc_page', true );
57 - continue;
58 - }
68 + if ( empty( $_settings[ $key ] ) ) {
69 + $this->save( $key, $_default[ $key ] );
70 + }
71 + }
72 + }
59 73
60 - if ( empty( $_settings[ $key ] ) ) {
61 - $this->save( $key, $_default[ $key ] );
62 - }
63 - }
64 - }
74 + /**
75 + * Get the settings URL for admin
76 + * @return string
77 + */
78 + public function url() {
79 + return esc_url( admin_url( 'admin.php?page=betterdocs-settings' ) );
80 + }
65 81
66 - /**
67 - * Get the settings URL for admin
68 - * @return string
69 - */
70 - public function url() {
71 - return esc_url( admin_url( 'admin.php?page=betterdocs-settings' ) );
72 - }
82 + /**
83 + * Settings keys holding secret API keys. These are masked before reaching
84 + * the browser, stripped for non-admins, and never persisted as their mask.
85 + *
86 + * Covers the AI Chatbot key plus every content-suite platform key. OpenAI's
87 + * is `ai_autowrite_api_key` (see ProviderFactory::key_field_for), hence the
88 + * dedupe.
89 + *
90 + * @return array<int,string>
91 + */
92 + public static function sensitive_api_key_fields() {
93 + $fields = array(
94 + ProviderFactory::OPENAI_KEY_FIELD,
95 + 'ai_chatbot_api_key',
96 + );
97 + foreach ( array_keys( ModelRegistry::platforms() ) as $platform ) {
98 + $fields[] = ProviderFactory::key_field_for( $platform );
99 + }
100 + // Add-ons (e.g. the AI Chatbot) register their own per-platform keys here
101 + // so they are masked in the browser and stripped for non-admins.
102 + return apply_filters( 'betterdocs_sensitive_api_key_fields', array_values( array_unique( $fields ) ) );
103 + }
73 104
74 - /**
75 - * This method is responsible for enqueueing scripts in settings panel
76 - *
77 - * @param string $hook
78 - *
79 - * @return void
80 - * @since 2.5.0
81 - */
82 - public function enqueue( $hook ) {
83 - if ( ! betterdocs()->is_betterdocs_screen( $hook ) ) {
84 - return;
85 - }
105 + /**
106 + * This method is responsible for enqueueing scripts in settings panel
107 + *
108 + * @param string $hook
109 + *
110 + * @return void
111 + * @since 2.5.0
112 + */
113 + public function enqueue( $hook ) {
114 + if ( ! betterdocs()->is_betterdocs_screen( $hook ) ) {
115 + return;
116 + }
86 117
87 - wp_enqueue_media();
88 - wp_enqueue_script( 'betterdocs-admin' );
89 -
90 - $settings = GlobalFields::normalize( $this->settings_args() );
91 -
92 - // Remove sensitive API keys if user doesn't have permission to edit settings
93 - if ( ! current_user_can( 'edit_docs_settings' ) ) {
94 - if ( isset( $settings['values']['ai_autowrite_api_key'] ) ) {
95 - unset( $settings['values']['ai_autowrite_api_key'] );
96 - }
97 - if ( isset( $settings['values']['ai_chatbot_api_key'] ) ) {
98 - unset( $settings['values']['ai_chatbot_api_key'] );
99 - }
100 - }
118 + wp_enqueue_media();
119 + wp_enqueue_script( 'betterdocs-admin' );
101 120
102 - // Inject raw git settings to bypass get() fallback (e.g., '' -> 'docs')
103 - if ( isset( $settings['values'] ) ) {
104 - $settings['values']['git_provider'] = $this->get_raw_field( 'git_provider', 'github' );
105 - $settings['values']['git_repository_url'] = $this->get_raw_field( 'git_repository_url', '' );
106 - $settings['values']['git_branch'] = $this->get_raw_field( 'git_branch', '' );
107 - $settings['values']['git_docs_directory'] = $this->get_raw_field( 'git_docs_directory', '' );
108 - }
109 -
110 - betterdocs()->assets->localize( 'betterdocs-admin', 'betterdocsAdminSettings', $settings );
111 - betterdocs()->assets->enqueue( 'betterdocs-icons', 'admin/btd-icon/style.css' );
112 - }
121 + $settings = GlobalFields::normalize( $this->settings_args() );
113 122
114 - public function enqueue_old( $hook ) {
115 - // FREE & Pro Version Compatibility Check
116 - if ( ! betterdocs()->is_betterdocs_screen( $hook ) ) {
117 - return;
118 - }
123 + // Mask sensitive API keys before they reach the browser. Non-admins still get them stripped entirely below.
124 + $sensitive_api_keys = self::sensitive_api_key_fields();
125 + foreach ( $sensitive_api_keys as $api_key_field ) {
126 + if ( ! empty( $settings[ 'values' ][ $api_key_field ] ) ) {
127 + $settings[ 'values' ][ $api_key_field ] = Helper::mask_api_key( $settings[ 'values' ][ $api_key_field ] );
128 + }
129 + }
119 130
120 - $this->enqueue( 'betterdocs_page_betterdocs-settings' );
121 - }
131 + if ( ! current_user_can( 'edit_docs_settings' ) ) {
132 + foreach ( $sensitive_api_keys as $api_key_field ) {
133 + if ( isset( $settings[ 'values' ][ $api_key_field ] ) ) {
134 + unset( $settings[ 'values' ][ $api_key_field ] );
135 + }
136 + }
137 + }
122 138
123 - /**
124 - * This method is responsible for printing header in dashboard settings page.
125 - *
126 - * @param string $hook
127 - *
128 - * @return void
129 - * @since 2.5.0
130 - */
131 - public function header( $hook ) {
132 - if ( $hook !== 'settings' ) {
133 - return;
134 - }
139 + // Inject raw git settings to bypass get() fallback (e.g., '' -> 'docs')
140 + if ( isset( $settings[ 'values' ] ) ) {
141 + $settings[ 'values' ][ 'git_provider' ] = $this->get_raw_field( 'git_provider', 'github' );
142 + $settings[ 'values' ][ 'git_repository_url' ] = $this->get_raw_field( 'git_repository_url', '' );
143 + $settings[ 'values' ][ 'git_branch' ] = $this->get_raw_field( 'git_branch', '' );
144 + $settings[ 'values' ][ 'git_docs_directory' ] = $this->get_raw_field( 'git_docs_directory', '' );
145 + }
135 146
136 - betterdocs()->views->get( 'admin/template-parts/settings-header' );
137 - betterdocs()->views->get( 'admin/template-parts/settings-header-2' );
138 - }
147 + betterdocs()->assets->localize( 'betterdocs-admin', 'betterdocsAdminSettings', $settings );
148 + betterdocs()->assets->enqueue( 'betterdocs-icons', 'admin/btd-icon/style.css' );
149 + }
139 150
140 - /**
141 - * A list of deprecated settings keys.
142 - *
143 - * @return array
144 - * @since 2.5.0
145 - */
146 - public function deprecated_settings() {
147 - return [];
148 - }
151 + public function enqueue_old( $hook ) {
152 + // FREE & Pro Version Compatibility Check
153 + if ( ! betterdocs()->is_betterdocs_screen( $hook ) ) {
154 + return;
155 + }
149 156
150 - /**
151 - * Dynamic migration caller.
152 - *
153 - * @return void
154 - * @since 2.5.0
155 - */
156 - public function migration( $version ) {
157 - if ( $version > 250 ) {
158 - for ( $v = 250; $v <= $version; $v ++ ) {
159 - $_func = "v{$v}";
160 - if ( method_exists( $this, $_func ) ) {
161 - call_user_func( [ $this, $_func ] );
162 - }
163 - }
164 - }
165 - }
157 + $this->enqueue( 'betterdocs_page_betterdocs-settings' );
158 + }
166 159
167 - /**
168 - * Migration for version 2.5.0
169 - *
170 - * @return void
171 - * @since 2.5.0
172 - */
173 - public function v250() {
174 - if ( $this->get( 'alphabetically_order_term', false ) ) {
175 - $this->save( 'terms_orderby', 'name' );
176 - }
160 + /**
161 + * This method is responsible for printing header in dashboard settings page.
162 + *
163 + * @param string $hook
164 + *
165 + * @return void
166 + * @since 2.5.0
167 + */
168 + public function header( $hook ) {
169 + if ( 'settings' !== $hook ) {
170 + return;
171 + }
177 172
178 - if ( $orderby = $this->get( 'alphabetically_order_post', false ) ) {
179 - if ( $orderby === '1' ) {
180 - $this->save( 'alphabetically_order_post', 'title' );
181 - }
182 - }
183 - }
173 + betterdocs()->views->get( 'admin/template-parts/settings-header' );
174 + betterdocs()->views->get( 'admin/template-parts/settings-header-2' );
175 + }
184 176
185 - /**
186 - * A list of default settings data.
187 - *
188 - * @return array
189 - * @since 1.0.0
190 - *
191 - */
192 - public function get_default() {
193 - $_default = [
194 - 'multiple_kb' => '',
195 - 'enable_export_faq' => true,
196 - 'builtin_doc_page' => true,
197 - 'breadcrumb_doc_title' => __( 'Docs', 'betterdocs' ),
198 - 'enable_category_hierarchy_slugs' => false,
199 - 'docs_slug' => 'docs',
200 - 'docs_page' => 0,
201 - 'category_slug' => 'docs-category',
202 - 'tag_slug' => 'docs-tag',
203 - 'permalink_structure' => 'docs/',
204 - 'enable_faq_schema' => false,
205 - 'live_search' => true,
206 - 'advance_search' => false,
207 - 'popular_keyword_limit' => 5,
208 - 'search_letter_limit' => 3,
209 - 'search_placeholder' => __( 'Search...', 'betterdocs' ),
210 - 'search_not_found_text' => __( 'Sorry, no docs were found.', 'betterdocs' ),
211 - 'search_result_image' => true,
212 - 'search_modal_search_type' => 'all',
213 - 'masonry_layout' => true,
214 - 'docs_list_icon' => [],
215 - 'category_title_link' => false,
216 - 'terms_orderby' => 'betterdocs_order',
217 - 'alphabetically_order_term' => false,
218 - 'terms_order' => 'ASC',
219 - 'alphabetically_order_post' => 'betterdocs_order',
220 - 'docs_order' => 'ASC',
221 - 'nested_subcategory' => false,
222 - 'column_number' => 3,
223 - 'posts_number' => 10,
224 - 'post_count' => true,
225 - 'count_text' => __( 'Docs', 'betterdocs' ),
226 - 'count_text_singular' => __( 'Doc', 'betterdocs' ),
227 - 'exploremore_btn' => true,
228 - 'exploremore_btn_txt' => __( 'Explore More', 'betterdocs' ),
229 - 'doc_single' => 1,
230 - 'enable_toc' => true,
231 - 'toc_title' => __( 'Table of Contents', 'betterdocs' ),
232 - 'toc_hierarchy' => true,
233 - 'toc_list_number' => false,
234 - 'toc_dynamic_title' => false,
235 - 'enable_sticky_toc' => true,
236 - 'sticky_toc_offset' => 100,
237 - 'collapsible_toc_mobile' => false,
238 - 'supported_heading_tag' => [ '1', '2', '3', '4', '5', '6' ],
239 - 'enable_post_title' => true,
240 - 'title_link_ctc' => true,
241 - 'enable_breadcrumb' => true,
242 - 'breadcrumb_home_text' => __( 'Home', 'betterdocs' ),
243 - 'enable_breadcrumb_home_text' => true,
244 - 'breadcrumb_home_url' => get_home_url(),
245 - 'enable_breadcrumb_category' => true,
246 - 'enable_breadcrumb_title' => true,
247 - 'enable_sidebar_cat_list' => true,
248 - 'enable_print_icon' => true,
249 - 'enable_tags' => true,
250 - 'email_feedback' => true,
251 - 'feedback_link_text' => __( 'Still stuck? How can we help?', 'betterdocs' ),
252 - 'reaction_feedback_text' => __( 'Thanks for your feedback', 'betterdocs' ),
253 - 'feedback_url' => '',
254 - 'feedback_form_title' => __( 'How can we help?', 'betterdocs' ),
255 - 'email_address' => get_option( 'admin_email' ),
256 - 'show_last_update_time' => true,
257 - 'enable_navigation' => true,
258 - 'enable_comment' => true,
259 - 'enable_credit' => false,
260 - 'enable_archive_sidebar' => true,
261 - 'archive_nested_subcategory' => true,
262 - 'archive_enable_pagination' => false,
263 - 'enable_content_restriction' => false,
264 - 'enable_reporting' => false,
265 - 'enable_sample_data' => false,
266 - 'reporting_day' => 'monday',
267 - 'reporting_email' => get_option( 'admin_email' ),
268 - 'enable_write_with_ai' => true,
269 - 'enable_faq_write_with_ai' => true,
270 - 'write_with_ai_model' => 'gpt-4o-mini',
271 - 'ai_autowrite_api_key' => '',
272 - 'ai_autowrite_max_token' => 1500,
273 - 'enable_article_summary' => false,
274 - 'article_summary_model' => 'gpt-4o-mini',
275 - 'article_summary_max_token' => 1500,
276 - 'enable_estimated_reading_time' => true,
277 - 'enable_encyclopedia' => false,
278 - 'enable_glossaries' => false,
279 - 'show_glossary_suggestions' => true,
280 - 'enable_ai_chatbot' => false,
281 - 'estimated_reading_time_title' => '',
282 - 'estimated_reading_time_text' => __( 'min read', 'betterdocs' ),
283 - 'singular_estimated_reading_time_text' => __( 'min read', 'betterdocs' ),
284 - 'betterdocs_access_control_repeater' => [],
285 - 'internal_knowledge_base_type' => 'basic',
286 - 'betterdocs_access_control_repeater_kb' => [],
287 - 'enable_git_integration' => false,
288 - ];
177 + /**
178 + * A list of deprecated settings keys.
179 + *
180 + * @return array
181 + * @since 2.5.0
182 + */
183 + public function deprecated_settings() {
184 + return array();
185 + }
289 186
290 - $_default = apply_filters( 'betterdocs_default_settings', $_default );
291 - // $_default = apply_filters_deprecated(
292 - // 'betterdocs_option_default_settings', [$_default], '2.5.0',
293 - // 'betterdocs_default_settings', 'betterdocs_option_default_settings will be removed from v3.5.0.'
294 - // );
187 + /**
188 + * Dynamic migration caller.
189 + *
190 + * @return void
191 + * @since 2.5.0
192 + */
193 + public function migration( $version ) {
194 + if ( $version > 250 ) {
195 + for ( $v = 250; $v <= $version; ++$v ) {
196 + $_func = "v{$v}";
197 + if ( method_exists( $this, $_func ) ) {
198 + call_user_func( array( $this, $_func ) );
199 + }
200 + }
201 + }
202 + }
295 203
296 - return $_default;
297 - }
204 + /**
205 + * Migration for version 2.5.0
206 + *
207 + * @return void
208 + * @since 2.5.0
209 + */
210 + public function v250() {
211 + if ( $this->get( 'alphabetically_order_term', false ) ) {
212 + $this->save( 'terms_orderby', 'name' );
213 + }
298 214
299 - /**
300 - * A list of default settings for pro plugins.
301 - *
302 - * @return array
303 - * @since 2.5.0
304 - */
305 - public function get_pro_defaults() {
306 - return [];
307 - }
215 + if ( $orderby = $this->get( 'alphabetically_order_post', false ) ) {
216 + if ( '1' === $orderby ) {
217 + $this->save( 'alphabetically_order_post', 'title' );
218 + }
219 + }
220 + }
308 221
309 - public function is_elementor_pro() {
310 - return is_plugin_active( 'elementor-pro/elementor-pro.php' );
311 - }
222 + /**
223 + * A list of default settings data.
224 + *
225 + * @return array
226 + * @since 1.0.0
227 + *
228 + */
229 + public function get_default() {
230 + $_default = array(
231 + 'multiple_kb' => '',
232 + 'enable_ai_sample_docs' => true,
233 + 'enable_export_faq' => true,
234 + 'builtin_doc_page' => true,
235 + 'breadcrumb_doc_title' => __( 'Docs', 'betterdocs' ),
236 + 'enable_category_hierarchy_slugs' => false,
237 + 'docs_slug' => 'docs',
238 + 'docs_page' => 0,
239 + 'category_slug' => 'docs-category',
240 + 'tag_slug' => 'docs-tag',
241 + 'permalink_structure' => 'docs/',
242 + 'enable_faq_schema' => false,
243 + 'analytics_from' => 'everyone',
244 + 'unique_visitor_count' => true,
245 + 'exclude_bot_analytics' => true,
246 + 'child_category_exclude' => false,
247 + 'live_search' => true,
248 + 'advance_search' => false,
249 + 'popular_keyword_limit' => 5,
250 + 'search_letter_limit' => 3,
251 + 'search_placeholder' => __( 'Search...', 'betterdocs' ),
252 + 'search_not_found_text' => __( 'Sorry, no docs were found.', 'betterdocs' ),
253 + 'search_result_image' => true,
254 + 'search_modal_search_type' => 'all',
255 + 'masonry_layout' => true,
256 + 'docs_list_icon' => array(),
257 + 'category_title_link' => false,
258 + 'terms_orderby' => 'betterdocs_order',
259 + 'alphabetically_order_term' => false,
260 + 'terms_order' => 'ASC',
261 + 'alphabetically_order_post' => 'betterdocs_order',
262 + 'docs_order' => 'ASC',
263 + 'nested_subcategory' => false,
264 + 'column_number' => 3,
265 + 'posts_number' => 10,
266 + 'post_count' => true,
267 + 'count_text' => __( 'Docs', 'betterdocs' ),
268 + 'count_text_singular' => __( 'Doc', 'betterdocs' ),
269 + 'exploremore_btn' => true,
270 + 'exploremore_btn_txt' => __( 'Explore More', 'betterdocs' ),
271 + 'doc_single' => 1,
272 + 'enable_toc' => true,
273 + 'toc_title' => __( 'Table of Contents', 'betterdocs' ),
274 + 'toc_hierarchy' => true,
275 + 'toc_list_number' => false,
276 + 'toc_dynamic_title' => false,
277 + 'enable_sticky_toc' => true,
278 + 'sticky_toc_offset' => 100,
279 + 'collapsible_toc_mobile' => false,
280 + 'supported_heading_tag' => array( '1', '2', '3', '4', '5', '6' ),
281 + 'enable_post_title' => true,
282 + 'title_link_ctc' => true,
283 + 'enable_breadcrumb' => true,
284 + 'breadcrumb_home_text' => __( 'Home', 'betterdocs' ),
285 + 'enable_breadcrumb_home_text' => true,
286 + 'breadcrumb_home_url' => get_home_url(),
287 + 'enable_breadcrumb_category' => true,
288 + 'enable_breadcrumb_title' => true,
289 + 'enable_sidebar_cat_list' => true,
290 + 'enable_print_icon' => true,
291 + 'print_enable_logo' => false,
292 + 'print_logo' => array(),
293 + 'print_enable_footer' => false,
294 + 'print_footer_text' => '',
295 + 'enable_tags' => true,
296 + 'email_feedback' => true,
297 + 'feedback_link_text' => __( 'Still stuck? How can we help?', 'betterdocs' ),
298 + 'reaction_feedback_text' => __( 'Thanks for your feedback', 'betterdocs' ),
299 + 'feedback_url' => '',
300 + 'feedback_form_title' => __( 'How can we help?', 'betterdocs' ),
301 + 'email_address' => get_option( 'admin_email' ),
302 + 'show_last_update_time' => true,
303 + 'enable_navigation' => true,
304 + 'enable_comment' => true,
305 + 'enable_credit' => false,
306 + 'enable_archive_sidebar' => true,
307 + 'archive_nested_subcategory' => true,
308 + 'archive_enable_pagination' => false,
309 + 'archive_lazy_load_descendants' => false,
310 + 'enable_content_restriction' => false,
311 + 'enable_reporting' => false,
312 + 'enable_sample_data' => false,
313 + 'reporting_day' => 'monday',
314 + 'reporting_email' => get_option( 'admin_email' ),
315 + 'enable_write_with_ai' => true,
316 + 'enable_faq_write_with_ai' => true,
317 + 'enable_glossaries_write_with_ai' => true,
318 + 'enable_docs_ai_suite' => true,
319 + 'write_with_ai_model' => 'gpt-4o-mini',
320 + 'ai_autowrite_api_key' => '',
321 + 'ai_autowrite_max_token' => 2500,
322 + 'write_with_ai_instructions' => array(
323 + array(
324 + 'id' => 'default',
325 + 'title' => __( 'Default/Core', 'betterdocs' ),
326 + 'content' => WriteWithAI::default_instruction_content()
327 + )
328 + ),
329 + 'ai_edit_actions' => AIEdit::default_actions(),
330 + 'enable_article_summary' => false,
331 + 'article_summary_model' => 'gpt-4o-mini',
332 + 'article_summary_max_token' => 1500,
333 + // Multi-platform AI (content suite). `ai_platform` selects the active
334 + // provider; `ai_model` is the single global model; keys are stored
335 + // per platform so switching never loses a saved key. OpenAI reuses
336 + // `ai_autowrite_api_key` above — it has always held an OpenAI key,
337 + // so nothing needs migrating.
338 + 'ai_platform' => 'openai',
339 + 'ai_model' => 'gpt-4o-mini',
340 + 'ai_api_key_gemini' => '',
341 + 'ai_api_key_claude' => '',
342 + 'ai_api_key_deepseek' => '',
343 + 'ai_api_key_openrouter' => '',
344 + 'enable_estimated_reading_time' => true,
345 + 'enable_encyclopedia' => false,
346 + 'enable_glossaries' => false,
347 + 'show_glossary_suggestions' => true,
348 + 'enable_ai_chatbot' => false,
349 + 'estimated_reading_time_title' => '',
350 + 'estimated_reading_time_text' => __( 'min read', 'betterdocs' ),
351 + 'singular_estimated_reading_time_text' => __( 'min read', 'betterdocs' ),
352 + 'betterdocs_access_control_repeater' => array(),
353 + 'internal_knowledge_base_type' => 'basic',
354 + 'betterdocs_access_control_repeater_kb' => array(),
355 + 'enable_git_integration' => false,
356 + 'enable_ai_actions' => true,
357 + 'enable_markdown_endpoint' => true,
358 + 'ai_actions_button_label' => __( 'Copy page', 'betterdocs' ),
359 + 'ai_actions_prompt_template' => __( 'Read from {URL} so I can ask questions about it.', 'betterdocs' ),
360 + 'ai_actions_copy_page' => true,
361 + 'ai_actions_view_markdown' => true,
362 + 'ai_actions_chatgpt' => true,
363 + 'ai_actions_claude' => true,
364 + 'ai_actions_gemini' => true,
365 + 'ai_actions_perplexity' => false,
366 + 'ai_actions_grok' => false,
367 + 'enable_listen' => true,
368 + 'listen_button_label' => __( 'Listen', 'betterdocs' ),
369 + 'listen_show_speed' => true,
370 + // Words a synthetic voice gets through in a minute at rate 1.
371 + // Deliberately lower than the 200 the reading-time pill assumes — that
372 + // number describes silent reading. Only the player's duration estimate
373 + // uses this; see Core\Listen::WORDS_PER_MINUTE.
374 + 'listen_words_per_minute' => 180,
375 + /**
376 + * MCP master switch. Off by default; the toggle lives on the
377 + * BetterDocs → MCP page, not in the settings tree, and writes
378 + * through POST betterdocs/v1/settings.
379 + *
380 + * The key has to be listed here or `get()` cannot see it at all:
381 + * it answers `$default` for anything absent from the defaults
382 + * array, whatever the stored option holds.
383 + *
384 + * @since 4.9.0
385 + */
386 + 'enable_mcp' => ''
387 + );
312 388
313 - /**
314 - * Get full site editor links for docs page.
315 - *
316 - * @return string
317 - * @since 3.5.8
318 - */
319 - public function gutenberg_link() {
320 - if ( betterdocs()->helper->current_theme_is_fse_theme() ) {
321 - return admin_url( 'site-editor.php?postType=wp_template&postId=betterdocs/betterdocs//archive-docs' );
322 - } else {
323 - return 'https://betterdocs.co/docs/betterdocs-provides-full-site-editor-support/';
324 - }
325 - }
389 + $_default = apply_filters( 'betterdocs_default_settings', $_default );
390 + // $_default = apply_filters_deprecated(
391 + // 'betterdocs_option_default_settings', [$_default], '2.5.0',
392 + // 'betterdocs_default_settings', 'betterdocs_option_default_settings will be removed from v3.5.0.'
393 + // );
326 394
327 - /**
328 - * Get elementor theme builder link for docs page.
329 - *
330 - * @return string
331 - * @since 3.5.8
332 - */
333 - public function elementor_link() {
334 - if ( $this->is_elementor_pro() ) {
335 - return admin_url( 'admin.php?page=elementor-app#/site-editor/templates/doc-archive' );
336 - } else {
337 - return 'https://betterdocs.co/docs/docs-page-with-elementor/';
338 - }
339 - }
395 + return $_default;
396 + }
340 397
341 - public function customizer_link() {
342 - $query['autofocus[panel]'] = 'betterdocs_customize_options';
343 - $query['return'] = admin_url( 'edit.php?post_type=docs' );
344 - $builtin_doc_page = betterdocs()->settings->get( 'builtin_doc_page' );
345 - $docs_slug = betterdocs()->settings->get( 'docs_slug' );
346 - $docs_page = betterdocs()->settings->get( 'builtin_doc_page' );
398 + /**
399 + * A list of default settings for pro plugins.
400 + *
401 + * @return array
402 + * @since 2.5.0
403 + */
404 + public function get_pro_defaults() {
405 + return array();
406 + }
347 407
348 - if ( $builtin_doc_page == 1 && $docs_slug ) {
349 - $query['url'] = site_url( '/' . $docs_slug );
350 - } elseif ( $builtin_doc_page != 1 && $docs_page ) {
351 - $post_info = get_post( $docs_page );
352 - $query['url'] = site_url( '/' . $post_info->post_name );
353 - }
408 + public function is_elementor_pro() {
409 + return is_plugin_active( 'elementor-pro/elementor-pro.php' );
410 + }
354 411
355 - return add_query_arg( $query, admin_url( 'customize.php' ) );
356 - }
412 + /**
413 + * Get full site editor links for docs page.
414 + *
415 + * @return string
416 + * @since 3.5.8
417 + */
418 + public function gutenberg_link() {
419 + if ( betterdocs()->helper->current_theme_is_fse_theme() ) {
420 + return admin_url( 'site-editor.php?postType=wp_template&postId=betterdocs/betterdocs//archive-docs' );
421 + } else {
422 + return 'https://betterdocs.co/docs/betterdocs-provides-full-site-editor-support/';
423 + }
424 + }
357 425
358 - public function design_tab() {
359 - $settings = [];
426 + /**
427 + * Get elementor theme builder link for docs page.
428 + *
429 + * @return string
430 + * @since 3.5.8
431 + */
432 + public function elementor_link() {
433 + if ( $this->is_elementor_pro() ) {
434 + return admin_url( 'admin.php?page=elementor-app#/site-editor/templates/doc-archive' );
435 + } else {
436 + return 'https://betterdocs.co/docs/docs-page-with-elementor/';
437 + }
438 + }
360 439
361 - $settings['gutenberg_link'] = [
362 - 'name' => 'gutenberg_link',
363 - 'type' => 'action',
364 - 'action' => 'betterdocs_settings_gutenberg_link',
365 - 'button' => betterdocs()->helper->current_theme_is_fse_theme() ? __( 'Design with Gutenberg', 'betterdocs' ) : __( 'Learn More', 'betterdocs' ),
366 - 'url' => $this->gutenberg_link(),
367 - 'customizer_img' => betterdocs()->assets->icon( 'customizer/gutenberg-preview.png', true ),
368 - 'priority' => 1
369 - ];
440 + public function customizer_link() {
441 + $query[ 'autofocus[panel]' ] = 'betterdocs_customize_options';
442 + $query[ 'return' ] = admin_url( 'edit.php?post_type=docs' );
443 + $builtin_doc_page = betterdocs()->settings->get( 'builtin_doc_page' );
444 + $docs_slug = betterdocs()->settings->get( 'docs_slug' );
445 + $docs_page = betterdocs()->settings->get( 'builtin_doc_page' );
370 446
371 - $settings['elementor_link'] = [
372 - 'name' => 'elementor_link',
373 - 'type' => 'action',
374 - 'action' => 'betterdocs_settings_elementor_link',
375 - 'button' => $this->is_elementor_pro() ? __( 'Design with Elementor', 'betterdocs' ) : __( 'Learn More', 'betterdocs' ),
376 - 'url' => $this->elementor_link(),
377 - 'customizer_img' => betterdocs()->assets->icon( 'customizer/elementor-preview.png', true ),
378 - 'priority' => 2
379 - ];
447 + if ( 1 == $builtin_doc_page && $docs_slug ) {
448 + $query[ 'url' ] = site_url( '/' . $docs_slug );
449 + } elseif ( 1 != $builtin_doc_page && $docs_page ) {
450 + $post_info = get_post( $docs_page );
451 + $query[ 'url' ] = site_url( '/' . $post_info->post_name );
452 + }
380 453
381 - if ( ! betterdocs()->helper->current_theme_is_fse_theme() ) {
382 - $settings['customizer_link'] = [
383 - 'name' => 'customizer_link',
384 - 'type' => 'action',
385 - 'action' => 'betterdocs_settings_customizer_link',
386 - 'button' => __( 'Customize in BetterDocs', 'betterdocs' ),
387 - 'url' => $this->customizer_link(),
388 - 'customizer_img' => betterdocs()->assets->icon( 'customizer/customizer-preview.png', true ),
389 - 'priority' => 3
390 - ];
391 - }
454 + return add_query_arg( $query, admin_url( 'customize.php' ) );
455 + }
392 456
393 - return $settings;
394 - }
457 + public function design_tab() {
458 + $settings = array();
395 459
396 - /**
397 - * Get All Roles
398 - * dynamically
399 - *
400 - * @return array
401 - */
402 - public function get_roles() {
403 - $roles = wp_roles()->role_names;
404 - unset( $roles['subscriber'] );
460 + $settings[ 'gutenberg_link' ] = array(
461 + 'name' => 'gutenberg_link',
462 + 'type' => 'action',
463 + 'action' => 'betterdocs_settings_gutenberg_link',
464 + 'button' => betterdocs()->helper->current_theme_is_fse_theme() ? __( 'Design with Gutenberg', 'betterdocs' ) : __( 'Learn More', 'betterdocs' ),
465 + 'url' => $this->gutenberg_link(),
466 + 'customizer_img' => betterdocs()->assets->icon( 'customizer/gutenberg-preview.png', true ),
467 + 'priority' => 1
468 + );
405 469
406 - return $roles;
407 - }
470 + $settings[ 'elementor_link' ] = array(
471 + 'name' => 'elementor_link',
472 + 'type' => 'action',
473 + 'action' => 'betterdocs_settings_elementor_link',
474 + 'button' => $this->is_elementor_pro() ? __( 'Design with Elementor', 'betterdocs' ) : __( 'Learn More', 'betterdocs' ),
475 + 'url' => $this->elementor_link(),
476 + 'customizer_img' => betterdocs()->assets->icon( 'customizer/elementor-preview.png', true ),
477 + 'priority' => 2
478 + );
408 479
409 - /**
410 - * Set dark mode
411 - *
412 - * @return void
413 - * @since 1.0.0
414 - */
415 - public function dark_mode() {
416 - if ( ! check_ajax_referer( 'doc_cat_order_nonce', 'nonce', false ) ) {
417 - wp_send_json_error();
418 - }
480 + if ( ! betterdocs()->helper->current_theme_is_fse_theme() ) {
481 + $settings[ 'customizer_link' ] = array(
482 + 'name' => 'customizer_link',
483 + 'type' => 'action',
484 + 'action' => 'betterdocs_settings_customizer_link',
485 + 'button' => __( 'Customize in BetterDocs', 'betterdocs' ),
486 + 'url' => $this->customizer_link(),
487 + 'customizer_img' => betterdocs()->assets->icon( 'customizer/customizer-preview.png', true ),
488 + 'priority' => 3
489 + );
490 + }
419 491
420 - if ( isset( $_POST['mode'] ) ) {
421 - if ( $this->save( 'dark_mode', rest_sanitize_boolean( $_POST['mode'] ) ) ) { // phpcs:ignore
422 - wp_send_json_success();
423 - }
424 - }
492 + return $settings;
493 + }
425 494
426 - wp_send_json_error();
427 - }
495 + /**
496 + * Get All Roles
497 + * dynamically
498 + *
499 + * @return array
500 + */
501 + public function get_roles() {
502 + $roles = wp_roles()->role_names;
503 + unset( $roles[ 'subscriber' ] );
428 504
429 - public function get_normalized_value( $key, $value, $default = null ) {
430 - $_origin_value = $_value = $value;
505 + return $roles;
506 + }
431 507
432 - if ( in_array( $_value, [ 'on', 'off', '1', 'false', 'true' ], true ) ) {
433 - switch ( $_value ) {
434 - case 'on':
435 - case 'ON':
436 - case '1':
437 - case 'true':
438 - $_value = true;
439 - break;
440 - case 'off':
441 - case 'OFF':
442 - case '':
443 - case 'false':
444 - $_value = false;
445 - break;
446 - }
447 - }
508 + /**
509 + * Set dark mode
510 + *
511 + * @return void
512 + * @since 1.0.0
513 + */
514 + public function dark_mode() {
515 + if ( ! check_ajax_referer( 'doc_cat_order_nonce', 'nonce', false ) ) {
516 + wp_send_json_error();
517 + }
448 518
449 - $this->type_validation( $_value, $default );
519 + if ( isset( $_POST[ 'mode' ] ) ) {
520 + $mode = sanitize_text_field( wp_unslash( $_POST[ 'mode' ] ) );
521 + if ( $this->save( 'dark_mode', rest_sanitize_boolean( $mode ) ) ) {
522 + wp_send_json_success();
523 + }
524 + }
450 525
451 - return $_value;
452 - }
526 + wp_send_json_error();
527 + }
453 528
454 - public function get_normalized_values( $values, $default_values = [] ) {
455 - if ( empty( $values ) ) {
456 - return [];
457 - }
529 + public function get_normalized_value( $key, $value, $default = null ) {
530 + $_origin_value = $_value = $value;
458 531
459 - $_settings = [];
460 - foreach ( $values as $key => $value ) {
461 - $_default_value = isset( $default_values[ $key ] ) ? $default_values[ $key ] : null;
462 - $_settings[ $key ] = $this->get_normalized_value( $key, $value, $_default_value );
463 - }
532 + if ( in_array( $_value, array( 'on', 'off', '1', 'false', 'true' ), true ) ) {
533 + switch ( $_value ) {
534 + case 'on':
535 + case 'ON':
536 + case '1':
537 + case 'true':
538 + $_value = true;
539 + break;
540 + case 'off':
541 + case 'OFF':
542 + case '':
543 + case 'false':
544 + $_value = false;
545 + break;
546 + }
547 + }
464 548
465 - return $_settings;
466 - }
549 + $this->type_validation( $_value, $default );
467 550
468 - public function get_all( $raw = false ) {
469 - $_default_settings = $raw ? [] : array_merge( $this->get_default(), $this->get_pro_defaults() );
470 - $_settings = $this->database->get( $this->base_key, $_default_settings );
551 + return $_value;
552 + }
471 553
472 - return $this->get_normalized_values( $_settings, $_default_settings );
473 - }
554 + public function get_normalized_values( $values, $default_values = array() ) {
555 + if ( empty( $values ) ) {
556 + return array();
557 + }
474 558
475 - public function type_validation( &$value, $defaultValue = null ) {
476 - if ( $defaultValue !== null ) {
477 - /**
478 - * Check if value is not in same type
479 - */
480 - $_default_type = gettype( $defaultValue );
559 + $_settings = array();
560 + foreach ( $values as $key => $value ) {
561 + $_default_value = isset( $default_values[ $key ] ) ? $default_values[ $key ] : null;
562 + $_settings[ $key ] = $this->get_normalized_value( $key, $value, $_default_value );
563 + }
481 564
482 - if ( ! ( is_scalar( $defaultValue ) && is_scalar( $value ) ) && empty( $value ) ) {
483 - $value = $defaultValue;
484 - }
565 + return $_settings;
566 + }
485 567
486 - settype( $value, $_default_type );
487 - }
488 - }
568 + public function get_all( $raw = false ) {
569 + $_default_settings = $raw ? array() : array_merge( $this->get_default(), $this->get_pro_defaults() );
570 + $_settings = $this->database->get( $this->base_key, $_default_settings );
489 571
490 - /**
491 - * Get settings value by key
492 - *
493 - * @param string $key
494 - * @param mixed $default
495 - * @param bool $get_all
496 - *
497 - * @return mixed
498 - * @since 2.5.0
499 - *
500 - */
501 - public function get( $key, $default = null ) {
502 - $_default_settings = array_merge( $this->get_default(), $this->get_pro_defaults() );
503 - $_settings = $this->database->get( $this->base_key, $_default_settings );
572 + return $this->get_normalized_values( $_settings, $_default_settings );
573 + }
504 574
505 - $_value = $default;
506 - switch ( true ) {
507 - // Check if it's a PRO Option
508 - case ! isset( $_default_settings[ $key ] ):
509 - $_value = $default;
510 - break;
511 - // Check if it's a FREE Option and not in DB.
512 - case ! isset( $_settings[ $key ] ) && isset( $_default_settings[ $key ] ):
513 - $_value = $default !== null ? $default : $_default_settings[ $key ];
514 - break;
515 - // Check if it's a FREE Option
516 - case isset( $_settings[ $key ] ) && isset( $_default_settings[ $key ] ):
517 - $_value = $_settings[ $key ];
518 - break;
519 - }
575 + public function type_validation( &$value, $defaultValue = null ) {
576 + if ( null !== $defaultValue ) {
577 + /**
578 + * Check if value is not in same type
579 + */
580 + $_default_type = gettype( $defaultValue );
520 581
521 - $_value = $this->get_normalized_value( $key, $_value, isset( $_default_settings[ $key ] ) ? $_default_settings[ $key ] : null );
582 + if ( ! ( is_scalar( $defaultValue ) && is_scalar( $value ) ) && empty( $value ) ) {
583 + $value = $defaultValue;
584 + }
522 585
523 - if ( gettype( $_value ) === 'string' ) {
524 - if ( empty( $_value ) && $default != null ) {
525 - $_value = $default;
526 - } elseif ( empty( $_value ) && $default === null && isset( $_default_settings[ $key ] ) ) {
527 - $_value = $_default_settings[ $key ];
528 - }
529 - }
586 + settype( $value, $_default_type );
587 + }
588 + }
530 589
531 - return $_value;
532 - }
590 + /**
591 + * Get settings value by key
592 + *
593 + * @param string $key
594 + * @param mixed $default
595 + * @param bool $get_all
596 + *
597 + * @return mixed
598 + * @since 2.5.0
599 + *
600 + */
601 + public function get( $key, $default = null ) {
602 + $_default_settings = array_merge( $this->get_default(), $this->get_pro_defaults() );
603 + $_settings = $this->database->get( $this->base_key, $_default_settings );
533 604
534 - public function get_raw_field( $key, $default = null ) {
535 - $_settings = $this->database->get( $this->base_key, [] );
605 + $_value = $default;
606 + switch ( true ) {
607 + // Check if it's a PRO Option
608 + case ! isset( $_default_settings[ $key ] ):
609 + $_value = $default;
610 + break;
611 + // Check if it's a FREE Option and not in DB.
612 + case ! isset( $_settings[ $key ] ) && isset( $_default_settings[ $key ] ):
613 + $_value = null !== $default ? $default : $_default_settings[ $key ];
614 + break;
615 + // Check if it's a FREE Option
616 + case isset( $_settings[ $key ] ) && isset( $_default_settings[ $key ] ):
617 + $_value = $_settings[ $key ];
618 + break;
619 + }
536 620
537 - if ( isset( $_settings[ $key ] ) ) {
538 - return $this->get_normalized_value( $key, $_settings[ $key ], $default );
539 - }
621 + $_value = $this->get_normalized_value( $key, $_value, isset( $_default_settings[ $key ] ) ? $_default_settings[ $key ] : null );
540 622
541 - return $default;
542 - }
623 + if ( gettype( $_value ) === 'string' ) {
624 + if ( empty( $_value ) && null != $default ) {
625 + $_value = $default;
626 + } elseif ( empty( $_value ) && null === $default && isset( $_default_settings[ $key ] ) ) {
627 + $_value = $_default_settings[ $key ];
628 + }
629 + }
543 630
544 - public function save( $key, $value ) {
545 - $_settings = $this->database->get( $this->base_key, [] );
546 - $_settings[ $key ] = $value;
631 + return $_value;
632 + }
547 633
548 - return $this->database->save( $this->base_key, $_settings );
549 - }
634 + public function get_raw_field( $key, $default = null ) {
635 + $_settings = $this->database->get( $this->base_key, array() );
550 636
551 - public function save_settings( $settings ) {
552 - $existing_plugins = betterdocs()->kbmigration->knowledge_base_plugins();
553 - if ( ! current_user_can( 'edit_docs_settings' ) ) {
554 - return new WP_Error( 'unauthorized_action', __( 'You don\'t have any rights for saving settings.', 'betterdocs' ) );
555 - }
637 + if ( isset( $_settings[ $key ] ) ) {
638 + return $this->get_normalized_value( $key, $_settings[ $key ], $default );
639 + }
556 640
557 - // Quickbuilder sends back the full UI-loaded payload. To avoid overwriting values that we
558 - // asynchronously updated in the DB via AJAX (like Git integration fields), we strictly remove them
559 - // from the incoming save payload so that the freshly loaded `$_old_settings` values persist.
560 - $exclude_ajax_keys = [ 'git_provider', 'git_repository_url', 'git_branch', 'git_docs_directory' ];
561 - foreach ( $exclude_ajax_keys as $key ) {
562 - if ( array_key_exists( $key, $settings ) ) {
563 - unset( $settings[ $key ] );
564 - }
565 - if ( isset( $settings['values'] ) && is_array( $settings['values'] ) && array_key_exists( $key, $settings['values'] ) ) {
566 - unset( $settings['values'][ $key ] );
567 - }
568 - }
641 + return $default;
642 + }
569 643
570 - $_old_settings = $this->database->get( $this->base_key, $this->get_default() );
571 - // @todo: sanitize the data before inject in DB.
572 - $_normalized_settings = $this->get_normalized_values( $settings );
573 - if ( $existing_plugins && isset( $_normalized_settings['migration_step'] ) && $_normalized_settings['migration_step'] == true ) {
574 - betterdocs()->kbmigration->migrate();
575 - }
576 - $_settings = wp_parse_args( $_normalized_settings, $_old_settings );
577 - $_saved = $this->database->save( $this->base_key, $_settings );
644 + public function save( $key, $value ) {
645 + $_settings = $this->database->get( $this->base_key, array() );
646 + $_settings[ $key ] = $value;
578 647
579 - do_action_ref_array( 'betterdocs::settings::saved', [ $_saved, $_settings, $_old_settings, &$this ] );
648 + return $this->database->save( $this->base_key, $_settings );
649 + }
580 650
581 - return $_saved;
582 - }
651 + public function save_settings( $settings ) {
652 + $existing_plugins = betterdocs()->kbmigration->knowledge_base_plugins();
653 + if ( ! current_user_can( 'edit_docs_settings' ) ) {
654 + return new WP_Error( 'unauthorized_action', __( 'You don\'t have any rights for saving settings.', 'betterdocs' ) );
655 + }
583 656
584 - public function views( $hook ) {
585 - return betterdocs()->views->get( 'admin/settings' );
586 - }
657 + // The frontend sends the currently-active settings tab as a transport-only hint so
658 + // tab-scoped validation (the AI min-token floor below) only runs when that tab is being
659 + // saved. It must never be persisted into the settings option.
660 + $active_tab = '';
661 + if ( array_key_exists( '_active_tab', $settings ) ) {
662 + $active_tab = (string) $settings[ '_active_tab' ];
663 + unset( $settings[ '_active_tab' ] );
664 + }
587 665
588 - public function save_default_settings() {
589 - $_settings = $this->get_all();
666 + // Quickbuilder sends back the full UI-loaded payload. To avoid overwriting values that we
667 + // asynchronously updated in the DB via AJAX (like Git integration fields), we strictly remove them
668 + // from the incoming save payload so that the freshly loaded `$_old_settings` values persist.
669 + $exclude_ajax_keys = array( 'git_provider', 'git_repository_url', 'git_branch', 'git_docs_directory' );
670 + foreach ( $exclude_ajax_keys as $key ) {
671 + if ( array_key_exists( $key, $settings ) ) {
672 + unset( $settings[ $key ] );
673 + }
674 + if ( isset( $settings[ 'values' ] ) && is_array( $settings[ 'values' ] ) && array_key_exists( $key, $settings[ 'values' ] ) ) {
675 + unset( $settings[ 'values' ][ $key ] );
676 + }
677 + }
590 678
591 - return $this->database->save( $this->base_key, $_settings );
592 - }
679 + $_old_settings = $this->database->get( $this->base_key, $this->get_default() );
593 680
594 - public function get_pages() {
595 - $_pages = betterdocs()->query->get_posts( [
596 - 'post_type' => 'page',
597 - 'numberposts' => - 1,
598 - 'post_status' => 'publish',
599 - 'posts_per_page' => - 1
600 - ] );
681 + // The frontend only ever sees masked API keys. A submitted value that still looks like a
682 + // mask (contains a run of asterisks — no real key does) means "unchanged": restore the
683 + // stored original so a mask string is never persisted. Guarding on the mask SHAPE rather
684 + // than strict equality with mask(stored) closes the corruption loop QA hit: once a mask
685 + // slips into storage, mask(mask) === mask, so an equality-only guard would faithfully
686 + // preserve the corrupted value forever (round-2 follow-up #1). When the stored value is
687 + // itself mask-shaped it is unrecoverable — clear it so the UI and the GeoIP/GA4 status
688 + // surfaces honestly report a missing key instead of failing downstream with 401s.
689 + $sensitive_api_keys = self::sensitive_api_key_fields();
690 + foreach ( $sensitive_api_keys as $api_key_field ) {
691 + if ( ! isset( $settings[ $api_key_field ] ) ) {
692 + continue;
693 + }
694 + $incoming = trim( (string) $settings[ $api_key_field ] );
695 + $stored = isset( $_old_settings[ $api_key_field ] ) ? (string) $_old_settings[ $api_key_field ] : '';
696 + $stored_is_mask = '' !== $stored && preg_match( '/\*{4,}/', $stored );
601 697
602 - $__pages = [];
698 + if ( '' !== $incoming && preg_match( '/\*{4,}/', $incoming ) ) {
699 + $settings[ $api_key_field ] = $stored_is_mask ? '' : $stored;
700 + }
701 + }
603 702
604 - if ( ! empty( $_pages ) ) {
605 - $__pages[0] = __( 'Select a Page', 'betterdocs' );
606 - foreach ( $_pages->posts as $page ) {
607 - $__pages[ $page->ID ] = esc_html( $page->post_title );
608 - }
609 - }
703 + // Minimum-token policy: reject saves where a feature's max_token field is below the
704 + // per-model floor defined by AIHelper::get_min_tokens(). The model may be unchanged in
705 + // this submission, so fall back to the stored value when it isn't part of the payload.
706 + // Both token fields live under the AI Content Suite tab, so enforce the floor only when
707 + // that tab is the one being saved — saving any other settings page never trips it (e.g.
708 + // old users whose stored value predates the floor). When the active-tab hint is absent
709 + // (stale cached JS, the quick-setup wizard, or any programmatic caller) the loop is
710 + // skipped and the save is allowed through.
711 + $token_pairs = array(
712 + array(
713 + 'tab' => 'tab-betterdocs-ai',
714 + 'context' => 'write_with_ai',
715 + 'token_key' => 'ai_autowrite_max_token',
716 + 'model_key' => 'ai_model',
717 + 'label' => __( 'Write with AI', 'betterdocs' )
718 + ),
719 + array(
720 + 'tab' => 'tab-betterdocs-ai',
721 + 'context' => 'article_summary',
722 + 'token_key' => 'article_summary_max_token',
723 + 'model_key' => 'ai_model',
724 + 'label' => __( 'AI Doc Summarizer', 'betterdocs' )
725 + )
726 + );
727 + foreach ( $token_pairs as $pair ) {
728 + if ( $active_tab !== $pair[ 'tab' ] ) {
729 + continue;
730 + }
731 + if ( ! array_key_exists( $pair[ 'token_key' ], $settings ) ) {
732 + continue;
733 + }
734 + $incoming_tokens = (int) $settings[ $pair[ 'token_key' ] ];
735 + $incoming_model = isset( $settings[ $pair[ 'model_key' ] ] )
736 + ? $settings[ $pair[ 'model_key' ] ]
737 + : ( isset( $_old_settings[ $pair[ 'model_key' ] ] ) ? $_old_settings[ $pair[ 'model_key' ] ] : '' );
738 + $min = AIHelper::get_min_tokens( $pair[ 'context' ], $incoming_model );
739 + if ( $min > 0 && $incoming_tokens < $min ) {
740 + return new WP_Error(
741 + 'min_tokens_below_threshold',
742 + sprintf(
743 + /* translators: 1: feature label, 2: minimum tokens, 3: model id */
744 + __( '%1$s max tokens must be at least %2$d for %3$s.', 'betterdocs' ),
745 + $pair[ 'label' ],
746 + $min,
747 + $incoming_model
748 + )
749 + );
750 + }
751 + }
610 752
611 - return $__pages;
612 - }
753 + // @todo: sanitize the data before inject in DB.
754 + $_normalized_settings = $this->get_normalized_values( $settings );
755 + if ( $existing_plugins && isset( $_normalized_settings[ 'migration_step' ] ) && true == $_normalized_settings[ 'migration_step' ] ) {
756 + betterdocs()->kbmigration->migrate();
757 + }
758 + $_settings = wp_parse_args( $_normalized_settings, $_old_settings );
613 759
614 - public function settings_args() {
615 - $wp_roles = $this->normalize_options( $this->get_roles() );
760 + // Detect whether this save actually changes the effective settings.
761 + //
762 + // The stored option and the submitted payload are normalized differently:
763 + // an optional field can be ABSENT from storage yet arrive as '' (e.g.
764 + // Feedback URL), and array fields can be stored empty ( [] ) while their
765 + // normalized/default form is non-empty (e.g. Instant Answer's
766 + // display_ia_texonomy defaults to ['all']). Comparing the raw arrays
767 + // ( $_settings != $_old_settings ) therefore reported a phantom change on
768 + // every save, leaving the tab perpetually "dirty" and always toasting
769 + // "Changes Saved Successfully." instead of "There are no changes to be
770 + // saved." — see WPDevelopers/betterdocs-pro#78.
771 + //
772 + // Compare like-for-like instead: fill defaults on both sides and run both
773 + // through the same normalization, so semantically-equal states (absent vs
774 + // '', [] vs ['all'], 'on' vs true) collapse to identical values and only a
775 + // real edit registers. This is also more reliable than update_option()'s
776 + // return, which is false whenever values serialize identically under object
777 + // caching or type coercion even when the user did change something (#49).
778 + $_defaults = array_merge( $this->get_default(), $this->get_pro_defaults() );
779 + $_old_normalized = $this->get_normalized_values( wp_parse_args( $_old_settings, $_defaults ), $_defaults );
780 + $_new_normalized = $this->get_normalized_values( wp_parse_args( $_settings, $_defaults ), $_defaults );
781 + $_has_changes = $_new_normalized != $_old_normalized;
616 782
617 - $roles_for_ikb = $this->normalize_options( array_merge( [ 'all' => __( 'All logged in users', 'betterdocs' ) ], wp_roles()->role_names ) );
783 + $_saved = $this->database->save( $this->base_key, $_settings );
618 784
619 - unset( $roles_for_ikb['administrator'] );
785 + do_action_ref_array( 'betterdocs::settings::saved', array( $_saved, $_settings, $_old_settings, &$this ) );
620 786
621 - $settings = [
622 - 'id' => 'betterdocs_settings_metabox_wrapper',
623 - 'title' => __( 'betterdocs', 'betterdocs' ),
624 - 'object_types' => [ 'betterdocs' ],
625 - 'context' => 'normal',
626 - 'priority' => 'high',
627 - 'show_header' => false,
628 - 'tabnumber' => false,
629 - 'is_pro_active' => betterdocs()->is_pro_active(),
630 - 'logoURL' => betterdocs()->assets->icon( 'betterdocs-icon.svg', true ),
631 - 'layout' => 'vertical',
632 - 'config' => [
633 - 'active' => 'tab-general',
634 - 'sidebar' => true,
635 - 'title' => false
636 - ],
637 - 'submit' => [
638 - 'show' => true,
639 - 'label' => __( 'Save', 'betterdocs' ),
640 - 'loadingLabel' => __( 'Saving...', 'betterdocs' ),
641 - 'class' => 'save-settings',
642 - 'rules' => Rules::logicalRule( [
643 - Rules::is( 'config.active', 'tab-design', true ),
644 - Rules::is( 'config.active', 'tab-shortcodes', true ),
645 - Rules::is( 'config.active', 'tab-instant-answer', true ),
646 - Rules::is( 'config.active', 'tab-import-export', true ),
647 - Rules::is( 'config.active', 'tab-migration', true )
648 - ], 'and' )
649 - ],
650 - 'values' => betterdocs()->is_pro_active() ? $this->get_all() : array_merge( $this->get_all(), $this->pro_settings_default_values() ),
651 - 'tabs' => apply_filters( 'betterdocs_settings_tabs', [
652 - 'tab-general' => apply_filters( 'betterdocs_settings_tab_general', [
653 - 'id' => 'tab-general',
654 - 'label' => __( 'General', 'betterdocs' ),
655 - 'classes' => 'tab-general',
656 - 'priority' => 10,
657 - 'fields' => [
658 - 'title-general' => apply_filters( 'betterdocs_encyclopedia_settings', [
659 - 'name' => 'title-general-tab',
660 - 'type' => 'section',
661 - 'label' => __( 'General Settings', 'betterdocs' ),
662 - 'priority' => 10,
663 - 'fields' => [
664 - 'multiple_kb' => apply_filters( 'betterdocs_multi_kb_settings', [
665 - 'name' => 'multiple_kb',
666 - 'type' => 'toggle',
667 - 'label' => __( 'Multiple Knowledge Base', 'betterdocs' ),
668 - 'enable_disable_text_active' => true,
669 - 'default' => '',
670 - 'priority' => 1,
671 - 'is_pro' => true
672 - ] ),
673 - 'builtin_doc_page' => [
674 - 'name' => 'builtin_doc_page',
675 - 'type' => 'toggle',
676 - 'label' => __( 'Built-in Documentation Page', 'betterdocs' ),
677 - 'enable_disable_text_active' => true,
678 - 'default' => 1,
679 - 'priority' => 2
680 - ],
681 - 'enable_category_hierarchy_slugs' => [
682 - 'name' => 'enable_category_hierarchy_slugs',
683 - 'type' => 'toggle',
684 - 'label' => __( 'Enable Category Hierarchy Slug', 'betterdocs' ),
685 - 'enable_disable_text_active' => true,
686 - 'default' => false,
687 - 'priority' => 3,
688 - 'label_subtitle' => __( "Shows Hierarchy Based Permalink Slugs For Doc Categories & Single Doc Page", 'betterdocs' )
689 - ],
690 - 'breadcrumb_doc_title' => [
691 - 'name' => 'breadcrumb_doc_title',
692 - 'type' => 'text',
693 - 'label' => __( 'Documentation Page Title', 'betterdocs' ),
694 - 'default' => __( 'Docs', 'betterdocs' ),
695 - 'priority' => 4,
696 - 'rules' => Rules::is( 'builtin_doc_page', true )
697 - ],
698 - 'docs_slug' => [
699 - 'name' => 'docs_slug',
700 - 'type' => 'text',
701 - 'label' => __( 'BetterDocs Root Slug', 'betterdocs' ),
702 - 'default' => 'docs',
703 - 'priority' => 5,
704 - 'rules' => Rules::is( 'builtin_doc_page', true )
705 - ],
706 - 'docs_page' => [
707 - 'name' => 'docs_page',
708 - 'label' => __( 'Docs Page', 'betterdocs' ),
709 - 'type' => 'select',
710 - 'default' => 0,
711 - 'priority' => 6,
712 - 'search' => true,
713 - 'options' => $this->normalize_options( $this->get_pages() ),
714 - 'label_subtitle' => __( 'You will need to insert BetterDocs Shortcode inside the page. This page will be used as docs permalink.', 'betterdocs' ),
715 - 'rules' => Rules::is( 'builtin_doc_page', false )
716 - ],
787 + // The success / no-changes toast reflects whether the user made a real
788 + // change, not update_option()'s (unreliable) return value.
789 + return $_has_changes;
790 + }
717 791
718 - 'category_slug' => [
719 - 'name' => 'category_slug',
720 - 'type' => 'text',
721 - 'label' => __( 'Custom Category Slug', 'betterdocs' ),
722 - 'default' => 'docs-category',
723 - 'priority' => 7
724 - ],
725 - 'tag_slug' => [
726 - 'name' => 'tag_slug',
727 - 'type' => 'text',
728 - 'label' => __( 'Custom Tag Slug', 'betterdocs' ),
729 - 'default' => 'docs-tag',
730 - 'priority' => 8
731 - ],
732 - 'permalink_structure' => [
733 - 'name' => 'permalink_structure',
734 - 'type' => 'permalink_structure',
735 - 'label' => __( 'Single Docs Permalink', 'betterdocs' ),
736 - 'default' => PostType::permalink_structure(),
737 - 'priority' => 9,
738 - 'tags' => $this->normalize_options( [
739 - '%doc_category%' => '%doc_category%',
740 - '%knowledge_base%' => '%knowledge_base%'
741 - ] ),
742 - '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' )
743 - ],
744 - 'enable_glossaries' => [
745 - 'name' => 'enable_glossaries',
746 - 'type' => 'toggle',
747 - 'label' => __( 'Show Glossary', 'betterdocs' ),
748 - 'label_subtitle' => __( 'Enable the glossary feature to allow users to look up definitions for terms used within your encyclopedia or glossaries themselves.', 'betterdocs' ),
749 - 'enable_disable_text_active' => true,
750 - 'default' => false,
751 - 'priority' => 10,
752 - 'is_pro' => true
753 - ],
754 - 'enable_encyclopedia' => [
755 - 'name' => 'enable_encyclopedia',
756 - 'type' => 'toggle',
757 - 'label' => __( 'Built-in Encyclopedia Page', 'betterdocs' ),
758 - 'enable_disable_text_active' => true,
759 - 'default' => false,
760 - 'priority' => 11,
761 - 'is_pro' => true
762 - ],
763 - 'enable_faq_schema' => [
764 - 'name' => 'enable_faq_schema',
765 - 'type' => 'toggle',
766 - 'label' => __( 'FAQ Schema', 'betterdocs' ),
767 - 'enable_disable_text_active' => true,
768 - 'default' => '',
769 - 'priority' => 12
770 - ],
771 - 'analytics_from' => [
772 - 'name' => 'analytics_from',
773 - 'type' => 'select',
774 - 'label' => __( 'Analytics From', 'betterdocs' ),
775 - 'options' => $this->normalize_options( [
776 - 'everyone' => __( 'Everyone', 'betterdocs' ),
777 - 'guests' => __( 'Guests Only', 'betterdocs' ),
778 - 'registered_users' => __( 'Registered Users Only', 'betterdocs' )
779 - ] ),
780 - 'default' => 'everyone',
781 - 'priority' => 13,
782 - 'is_pro' => true
783 - ],
784 - 'unique_visitor_count' => [
785 - 'name' => 'unique_visitor_count',
786 - 'type' => 'toggle',
787 - 'label' => __( 'Unique Visitor Count', 'betterdocs' ),
788 - 'enable_disable_text_active' => true,
789 - 'default' => false,
790 - 'priority' => 14,
791 - 'is_pro' => true
792 - ],
793 - 'exclude_bot_analytics' => [
794 - 'name' => 'exclude_bot_analytics',
795 - 'type' => 'toggle',
796 - 'label' => __( 'Exclude Bot Analytics', 'betterdocs' ),
797 - 'enable_disable_text_active' => true,
798 - 'default' => false,
799 - 'priority' => 15,
800 - 'is_pro' => true
801 - ]
792 + public function views( $hook ) {
793 + return betterdocs()->views->get( 'admin/settings' );
794 + }
802 795
803 - ]
804 - ] )
805 - ]
806 - ] ),
807 - 'tab-layout' => apply_filters( 'betterdocs_settings_tab_layout', [
808 - 'id' => 'tab-layout',
809 - 'label' => __( 'Layout', 'betterdocs' ),
810 - 'classes' => 'tab-layout',
811 - 'priority' => 20,
812 - 'fields' => [
813 - 'title-layout' => [
814 - 'name' => 'title-layout-tab',
815 - 'type' => 'section',
816 - 'label' => __( 'Layout Settings', 'betterdocs' ),
817 - 'priority' => 20,
818 - 'fields' => [
819 - 'tab-sidebar-layout' => apply_filters( 'betterdocs_settings_tab_sidebar_layout', [
820 - 'id' => 'tab-sidebar-layout',
821 - 'name' => 'tab_sidebar_layout',
822 - 'label' => __( 'Layout Settings', 'betterdocs' ),
823 - 'classes' => 'tab-layout',
824 - 'type' => 'tab',
825 - 'active' => 'layout_documentation_page',
826 - 'completionTrack' => true,
827 - 'sidebar' => false,
828 - 'save' => false,
829 - 'title' => false,
830 - 'config' => [
831 - 'active' => 'layout_documentation_page',
832 - 'sidebar' => false,
833 - 'title' => false
834 - ],
835 - 'submit' => [
836 - 'show' => false
837 - ],
838 - 'step' => [
839 - 'show' => false
840 - ],
841 - 'priority' => 20,
842 - 'fields' => [
843 - 'layout_documentation_page' => [
844 - 'id' => 'layout_documentation_page',
845 - 'name' => 'layout_documentation_page',
846 - 'type' => 'section',
847 - 'label' => __( 'Documentation Page', 'betterdocs' ),
848 - 'priority' => 1,
849 - 'fields' => [
850 - 'tab-nested-layout-1' => [
851 - 'id' => 'tab-nested-layout-1',
852 - 'name' => 'tab_nested_layout_1',
853 - 'label' => __( 'Documentation Page', 'betterdocs' ),
854 - 'classes' => 'tab-nested-layout',
855 - 'type' => 'tab',
856 - 'active' => 'layout_documentation_page_general',
857 - 'completionTrack' => true,
858 - 'sidebar' => false,
859 - 'save' => false,
860 - 'title' => false,
861 - 'config' => [
862 - 'active' => 'layout_documentation_page_general',
863 - 'sidebar' => false,
864 - 'title' => false
865 - ],
866 - 'submit' => [
867 - 'show' => false
868 - ],
869 - 'step' => [
870 - 'show' => false
871 - ],
872 - 'priority' => 1,
873 - 'fields' => [
874 - 'layout_documentation_page_general' => [
875 - 'id' => 'layout_documentation_page_general',
876 - 'name' => 'layout_documentation_page_general',
877 - 'type' => 'section',
878 - 'label' => __( 'General', 'betterdocs' ),
879 - 'priority' => 1,
880 - 'fields' => [
881 - 'docs_list_icon' => [
882 - 'name' => 'docs_list_icon',
883 - 'type' => 'media',
884 - 'value' => '',
885 - 'label' => __( 'Docs List Icon', 'betterdocs' ),
886 - 'label_subtitle' => __( 'Upload your own preferred document list icon', 'betterdocs' ),
887 - 'priority' => 0
888 - ],
889 - 'category_title_link' => [
890 - 'name' => 'category_title_link',
891 - 'type' => 'toggle',
892 - 'label' => __( 'Category Title Link', 'betterdocs' ),
893 - 'label_subtitle' => __( 'This setting is applicable for category grid layout', 'betterdocs' ),
894 - 'enable_disable_text_active' => true,
895 - 'default' => false,
896 - 'priority' => 0
897 - ],
898 - 'masonry_layout' => [
899 - 'name' => 'masonry_layout',
900 - 'type' => 'toggle',
901 - 'label' => __( 'Masonry', 'betterdocs' ),
902 - 'enable_disable_text_active' => true,
903 - 'default' => 1,
904 - 'priority' => 1
905 - ],
906 - 'nested_subcategory' => [
907 - 'name' => 'nested_subcategory',
908 - 'type' => 'toggle',
909 - 'label' => __( 'Nested Sub Category', 'betterdocs' ),
910 - 'enable_disable_text_active' => true,
911 - 'default' => '',
912 - 'priority' => 2
913 - ],
914 - 'column_number' => [
915 - 'name' => 'column_number',
916 - 'type' => 'number',
917 - 'label' => __( 'Number Of Columns', 'betterdocs' ),
918 - 'label_subtitle' => __( 'This setting is not applicable for sleek layout.', 'betterdocs' ),
919 - 'default' => 3,
920 - 'priority' => 3
921 - ],
922 - 'posts_number' => apply_filters( 'betterdocs_posts_number', [
923 - 'name' => 'posts_number',
924 - 'type' => 'number',
925 - 'label' => __( 'Number Of Docs', 'betterdocs' ),
926 - 'label_subtitle' => __( 'This setting is not applicable for handbook layout.', 'betterdocs' ),
927 - 'default' => 10,
928 - 'priority' => 4
929 - ] ),
930 - 'post_count' => [
931 - 'name' => 'post_count',
932 - 'type' => 'toggle',
933 - 'label' => __( 'Doc Count', 'betterdocs' ),
934 - 'enable_disable_text_active' => true,
935 - 'default' => 1,
936 - 'priority' => 5
937 - ],
938 - 'count_text' => [
939 - 'name' => 'count_text',
940 - 'type' => 'text',
941 - 'label' => __( 'Count Text', 'betterdocs' ),
942 - 'default' => __( 'Docs', 'betterdocs' ),
943 - 'priority' => 6
944 - ],
945 - 'count_text_singular' => [
946 - 'name' => 'count_text_singular',
947 - 'type' => 'text',
948 - 'label' => __( 'Count Text Singular', 'betterdocs' ),
949 - 'default' => __( 'Doc', 'betterdocs' ),
950 - 'priority' => 7
951 - ],
952 - 'exploremore_btn' => [
953 - 'name' => 'exploremore_btn',
954 - 'type' => 'toggle',
955 - 'label' => __( 'Explore More Button', 'betterdocs' ),
956 - 'enable_disable_text_active' => true,
957 - 'default' => true,
958 - 'priority' => 8
959 - ],
960 - 'exploremore_btn_txt' => [
961 - 'name' => 'exploremore_btn_txt',
962 - 'type' => 'text',
963 - 'label' => __( 'Explore More Button Text', 'betterdocs' ),
964 - 'default' => __( 'Explore More', 'betterdocs' ),
965 - 'priority' => 9,
966 - 'rules' => Rules::is( 'exploremore_btn', true )
967 - ],
968 - 'betterdocs_popular_docs_text' => [
969 - 'name' => 'betterdocs_popular_docs_text',
970 - 'type' => 'text',
971 - 'label' => __( 'Popular Docs Text', 'betterdocs' ),
972 - 'default' => __( 'Popular Docs', 'betterdocs' ),
973 - 'priority' => 10,
974 - 'is_pro' => true
975 - ],
976 - 'betterdocs_popular_docs_number' => [
977 - 'name' => 'betterdocs_popular_docs_number',
978 - 'type' => 'number',
979 - 'label' => __( 'Popular Docs Number', 'betterdocs' ),
980 - 'default' => 10,
981 - 'priority' => 11,
982 - 'is_pro' => true
983 - ]
984 - ]
985 - ],
986 - 'layout_documentation_page_search' => [
987 - 'id' => 'layout_documentation_page_search',
988 - 'name' => 'layout_documentation_page_search',
989 - 'type' => 'section',
990 - 'label' => __( 'Search', 'betterdocs' ),
991 - 'priority' => 2,
992 - 'fields' => [
993 - 'live_search' => [
994 - 'name' => 'live_search',
995 - 'type' => 'toggle',
996 - 'label' => __( 'Live Search', 'betterdocs' ),
997 - 'enable_disable_text_active' => true,
998 - 'default' => 1,
999 - 'priority' => 1
1000 - ],
1001 - 'advance_search' => apply_filters( 'betterdocs_advance_search_settings', [
1002 - 'name' => 'advance_search',
1003 - 'type' => 'toggle',
1004 - 'label' => __( 'Advanced Search', 'betterdocs' ),
1005 - 'enable_disable_text_active' => true,
1006 - 'default' => '',
1007 - 'priority' => 2,
1008 - 'is_pro' => true
1009 - ] ),
1010 - 'child_category_exclude' => apply_filters( 'child_category_exclude', [
1011 - 'name' => 'child_category_exclude',
1012 - 'type' => 'toggle',
1013 - 'label' => __( 'Exclude Child Terms In Category Search', 'betterdocs' ),
1014 - 'enable_disable_text_active' => true,
1015 - 'default' => '',
1016 - 'priority' => 3,
1017 - 'is_pro' => true
1018 - ] ),
1019 - 'popular_keyword_limit' => apply_filters( 'betterdocs_popular_keyword_limit_settings', [
1020 - 'name' => 'popular_keyword_limit',
1021 - 'type' => 'number',
1022 - 'label' => __( 'Minimum amount of Keywords Search', 'betterdocs' ),
1023 - 'default' => 5,
1024 - 'priority' => 4,
1025 - 'is_pro' => true
1026 - ] ),
1027 - 'search_letter_limit' => [
1028 - 'name' => 'search_letter_limit',
1029 - 'type' => 'number',
1030 - 'label' => __( 'Minimum Character Limit For Search Result', 'betterdocs' ),
1031 - 'priority' => 5,
1032 - 'default' => 3
1033 - ],
1034 - 'search_placeholder' => [
1035 - 'name' => 'search_placeholder',
1036 - 'type' => 'text',
1037 - 'label' => __( 'Search Placeholder', 'betterdocs' ),
1038 - 'default' => __( 'Search..', 'betterdocs' ),
1039 - 'priority' => 6
1040 - ],
1041 - 'search_button_text' => apply_filters( 'betterdocs_search_button_text', [
1042 - 'name' => 'search_button_text',
1043 - 'type' => 'text',
1044 - 'label' => __( 'Search Button Text', 'betterdocs' ),
1045 - 'priority' => 7,
1046 - 'default' => __( 'Search', 'betterdocs' )
1047 - ] ),
1048 - 'search_not_found_text' => [
1049 - 'name' => 'search_not_found_text',
1050 - 'type' => 'text',
1051 - 'label' => __( 'Search Not Found Text', 'betterdocs' ),
1052 - 'default' => 'Sorry, no docs were found.',
1053 - 'priority' => 8
1054 - ],
1055 - 'search_result_image' => [
1056 - 'name' => 'search_result_image',
1057 - 'type' => 'toggle',
1058 - 'label' => __( 'Search Result Image', 'betterdocs' ),
1059 - 'enable_disable_text_active' => true,
1060 - 'default' => 1,
1061 - 'priority' => 9
1062 - ],
1063 - 'kb_based_search' => apply_filters( 'betterdocs_kb_based_search_settings', [
1064 - 'name' => 'kb_based_search',
1065 - 'type' => 'toggle',
1066 - 'label' => __( 'KB Based Search', 'betterdocs' ),
1067 - 'enable_disable_text_active' => true,
1068 - 'default' => '',
1069 - 'priority' => 10,
1070 - 'is_pro' => true,
1071 - 'rules' => Rules::is( 'multiple_kb', true )
1072 - ] ),
1073 - 'search_modal_search_type' => [
1074 - 'name' => 'search_modal_search_type',
1075 - 'type' => 'select',
1076 - 'label' => __( 'Search Modal Source', 'betterdocs' ),
1077 - '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' ),
1078 - 'default' => 'all',
1079 - 'options' => $this->normalize_options( [
1080 - 'all' => __('Both (Docs + FAQs)', 'betterdocs'),
1081 - 'docs' => __('Docs only', 'betterdocs'),
1082 - 'faq' => __('FAQs only', 'betterdocs')
1083 - ] ),
1084 - 'priority' => 11,
1085 - ]
1086 - ]
1087 - ],
1088 - 'layout_documentation_page_order_by' => [
1089 - 'id' => 'layout_documentation_page_order_by',
1090 - 'name' => 'layout_documentation_page_order_by',
1091 - 'type' => 'section',
1092 - 'label' => __( 'Order By', 'betterdocs' ),
1093 - 'priority' => 3,
1094 - 'fields' => [
1095 - 'terms_orderby' => [
1096 - 'name' => 'terms_orderby',
1097 - 'type' => 'select',
1098 - 'label' => __( 'Terms Order By', 'betterdocs' ),
1099 - 'default' => 'betterdocs_order',
1100 - 'options' => $this->normalize_options( apply_filters( 'betterdocs_terms_orderby_options', [
1101 - 'none' => __( 'No order', 'betterdocs' ),
1102 - 'name' => __( 'Name', 'betterdocs' ),
1103 - 'slug' => __( 'Slug', 'betterdocs' ),
1104 - 'term_group' => __( 'Term Group', 'betterdocs' ),
1105 - 'term_id' => __( 'Term ID', 'betterdocs' ),
1106 - 'id' => __( 'ID', 'betterdocs' ),
1107 - 'description' => __( 'Description', 'betterdocs' ),
1108 - 'parent' => __( 'Parent', 'betterdocs' ),
1109 - 'betterdocs_order' => __( 'BetterDocs Order', 'betterdocs' )
1110 - ] ) ),
1111 - 'priority' => 1
1112 - ],
1113 - 'terms_order' => [
1114 - 'name' => 'terms_order',
1115 - 'type' => 'select',
1116 - 'label' => __( 'Terms Order', 'betterdocs' ),
1117 - 'default' => 'ASC',
1118 - 'options' => $this->normalize_options( [
1119 - 'ASC' => 'Ascending',
1120 - 'DESC' => 'Descending'
1121 - ] ),
1122 - 'priority' => 3,
1123 - 'rules' => Rules::includes( 'terms_orderby', 'betterdocs_order', true )
1124 - ],
1125 - 'alphabetically_order_post' => [
1126 - 'name' => 'alphabetically_order_post',
1127 - 'type' => 'select',
1128 - 'label' => __( 'Docs Order By', 'betterdocs' ),
1129 - 'default' => 'betterdocs_order',
1130 - 'options' => $this->normalize_options( [
1131 - 'none' => __( 'No order', 'betterdocs' ),
1132 - 'ID' => __( 'Docs ID', 'betterdocs' ),
1133 - 'author' => __( 'Docs Author', 'betterdocs' ),
1134 - 'title' => __( 'Title', 'betterdocs' ),
1135 - 'date' => __( 'Date', 'betterdocs' ),
1136 - 'modified' => __( 'Last Modified Date', 'betterdocs' ),
1137 - 'parent' => __( 'Parent Id', 'betterdocs' ),
1138 - 'rand' => __( 'Random', 'betterdocs' ),
1139 - 'comment_count' => __( 'Comment Count', 'betterdocs' ),
1140 - 'menu_order' => __( 'Menu Order', 'betterdocs' ),
1141 - 'betterdocs_order' => __( 'BetterDocs Order', 'betterdocs' )
1142 - ] ),
1143 - 'priority' => 4
1144 - ],
1145 - 'docs_order' => [
1146 - 'name' => 'docs_order',
1147 - 'type' => 'select',
1148 - 'label' => __( 'Docs Order', 'betterdocs' ),
1149 - 'default' => 'ASC',
1150 - 'options' => $this->normalize_options( [
1151 - 'ASC' => 'Ascending',
1152 - 'DESC' => 'Descending'
1153 - ] ),
1154 - 'priority' => 5,
1155 - 'rules' => Rules::includes( 'alphabetically_order_post', 'betterdocs_order', true )
1156 - ]
1157 - ]
1158 - ]
1159 - ]
1160 - ]
1161 - ]
1162 - ],
1163 - 'layout_single_doc' => apply_filters( 'single_doc_setting_section', [
1164 - 'id' => 'layout_single_doc',
1165 - 'name' => 'layout_single_doc',
1166 - 'type' => 'section',
1167 - 'label' => __( 'Single Doc', 'betterdocs' ),
1168 - 'priority' => 2,
1169 - 'fields' => [
1170 - 'tab-nested-layout-2' => [
1171 - 'id' => 'tab-nested-layout-2',
1172 - 'name' => 'tab_nested_layout_2',
1173 - 'label' => __( 'Single Doc', 'betterdocs' ),
1174 - 'classes' => 'tab-nested-layout',
1175 - 'type' => 'tab',
1176 - 'active' => 'layout_single_doc_general',
1177 - 'completionTrack' => true,
1178 - 'sidebar' => false,
1179 - 'save' => false,
1180 - 'title' => false,
1181 - 'config' => [
1182 - 'active' => 'layout_single_doc_general',
1183 - 'sidebar' => false,
1184 - 'title' => false
1185 - ],
1186 - 'submit' => [
1187 - 'show' => false
1188 - ],
1189 - 'step' => [
1190 - 'show' => false
1191 - ],
1192 - 'priority' => 20,
1193 - 'fields' => [
1194 - 'layout_single_doc_general' => [
1195 - 'id' => 'layout_single_doc_general',
1196 - 'name' => 'layout_single_doc_general',
1197 - 'type' => 'section',
1198 - 'label' => __( 'General', 'betterdocs' ),
1199 - 'priority' => 5,
1200 - 'fields' => [
1201 - 'enable_post_title' => [
1202 - 'name' => 'enable_post_title',
1203 - 'type' => 'toggle',
1204 - 'label' => __( 'Doc Title', 'betterdocs' ),
1205 - 'enable_disable_text_active' => true,
1206 - 'default' => 1,
1207 - 'priority' => 1
1208 - ],
1209 - 'enable_sidebar_cat_list' => [
1210 - 'name' => 'enable_sidebar_cat_list',
1211 - 'type' => 'toggle',
1212 - 'label' => __( 'Sidebar Category List', 'betterdocs' ),
1213 - 'enable_disable_text_active' => true,
1214 - 'default' => 1,
1215 - 'priority' => 2
1216 - ],
1217 - 'enable_print_icon' => [
1218 - 'name' => 'enable_print_icon',
1219 - 'type' => 'toggle',
1220 - 'label' => __( 'Print Icon', 'betterdocs' ),
1221 - 'enable_disable_text_active' => true,
1222 - 'default' => 1,
1223 - 'priority' => 3
1224 - ],
1225 - 'enable_tags' => [
1226 - 'name' => 'enable_tags',
1227 - 'type' => 'toggle',
1228 - 'label' => __( 'Tags', 'betterdocs' ),
1229 - 'enable_disable_text_active' => true,
1230 - 'default' => 1,
1231 - 'priority' => 4
1232 - ],
1233 - 'show_last_update_time' => [
1234 - 'name' => 'show_last_update_time',
1235 - 'type' => 'toggle',
1236 - 'label' => __( 'Last Update Time', 'betterdocs' ),
1237 - 'enable_disable_text_active' => true,
1238 - 'default' => 1,
1239 - 'priority' => 5
1240 - ],
1241 - 'enable_navigation' => [
1242 - 'name' => 'enable_navigation',
1243 - 'type' => 'toggle',
1244 - 'label' => __( 'Navigation', 'betterdocs' ),
1245 - 'enable_disable_text_active' => true,
1246 - 'default' => 1,
1247 - 'priority' => 6
1248 - ],
1249 - 'enable_comment' => [
1250 - 'name' => 'enable_comment',
1251 - 'type' => 'toggle',
1252 - 'label' => __( 'Comment', 'betterdocs' ),
1253 - 'enable_disable_text_active' => true,
1254 - 'default' => '',
1255 - 'priority' => 7
1256 - ],
1257 - 'enable_credit' => [
1258 - 'name' => 'enable_credit',
1259 - 'type' => 'toggle',
1260 - 'label' => __( 'Show Powered by BetterDocs', 'betterdocs' ),
1261 - 'enable_disable_text_active' => true,
1262 - 'default' => '',
1263 - 'priority' => 8
1264 - ],
1265 - 'reaction_feedback_text' => [
1266 - 'name' => 'reaction_feedback_text',
1267 - 'type' => 'text',
1268 - 'label' => __( 'Reaction Feedback Text', 'betterdocs' ),
1269 - 'default' => __( 'Thanks for your feedback.', 'betterdocs' ),
1270 - 'priority' => 9
1271 - ],
1272 - 'enable_estimated_reading_time' => [
1273 - 'name' => 'enable_estimated_reading_time',
1274 - 'type' => 'toggle',
1275 - 'label' => __( 'Estimated Reading Time', 'betterdocs' ),
1276 - 'enable_disable_text_active' => true,
1277 - 'default' => 0,
1278 - 'priority' => 10
1279 - ],
1280 - 'estimated_reading_time_title' => [
1281 - 'name' => 'estimated_reading_time_title',
1282 - 'type' => 'text',
1283 - 'label' => __( 'Estimated Reading Time Title', 'betterdocs' ),
1284 - 'default' => '',
1285 - 'priority' => 11,
1286 - 'rules' => Rules::is( 'enable_estimated_reading_time', true )
1287 - ],
1288 - 'estimated_reading_time_text' => [
1289 - 'name' => 'estimated_reading_time_text',
1290 - 'type' => 'text',
1291 - 'label' => __( 'Estimated Reading Time Text', 'betterdocs' ),
1292 - 'default' => __( 'min read', 'betterdocs' ),
1293 - 'priority' => 12,
1294 - 'rules' => Rules::is( 'enable_estimated_reading_time', true )
1295 - ],
1296 - 'singular_estimated_reading_time_text' => [
1297 - 'name' => 'singular_estimated_reading_time_text',
1298 - 'type' => 'text',
1299 - 'label' => __( 'Estimated Reading Time Text Singular', 'betterdocs' ),
1300 - 'default' => __( 'min read', 'betterdocs' ),
1301 - 'priority' => 13,
1302 - 'rules' => Rules::is( 'enable_estimated_reading_time', true )
1303 - ]
1304 - ]
1305 - ],
1306 - 'layout_single_doc_TOC' => [
1307 - 'id' => 'layout_single_doc_TOC',
1308 - 'name' => 'layout_single_doc_TOC',
1309 - 'type' => 'section',
1310 - 'label' => __( 'TOC', 'betterdocs' ),
1311 - 'priority' => 5,
1312 - 'fields' => [
1313 - 'enable_toc' => [
1314 - 'name' => 'enable_toc',
1315 - 'type' => 'toggle',
1316 - 'label' => __( 'Table of Contents', 'betterdocs' ),
1317 - 'enable_disable_text_active' => true,
1318 - 'default' => 1,
1319 - 'priority' => 1
1320 - ],
1321 - 'toc_title' => [
1322 - 'name' => 'toc_title',
1323 - 'type' => 'text',
1324 - 'label' => __( 'TOC Title', 'betterdocs' ),
1325 - 'default' => __( 'Table of Contents', 'betterdocs' ),
1326 - 'priority' => 2,
1327 - 'rules' => Rules::is( 'enable_toc', true )
796 + public function save_default_settings() {
797 + $_settings = $this->get_all();
1328 798
1329 - ],
1330 - 'toc_hierarchy' => [
1331 - 'name' => 'toc_hierarchy',
1332 - 'type' => 'toggle',
1333 - 'label' => __( 'TOC Hierarchy', 'betterdocs' ),
1334 - 'enable_disable_text_active' => true,
1335 - 'default' => 1,
1336 - 'priority' => 3,
1337 - 'rules' => Rules::is( 'enable_toc', true )
1338 - ],
1339 - 'toc_list_number' => [
1340 - 'name' => 'toc_list_number',
1341 - 'type' => 'toggle',
1342 - 'label' => __( 'TOC List Number', 'betterdocs' ),
1343 - 'enable_disable_text_active' => true,
1344 - 'default' => 1,
1345 - 'priority' => 4,
1346 - 'rules' => Rules::is( 'enable_toc', true )
1347 - ],
1348 - 'toc_dynamic_title' => [
1349 - 'name' => 'toc_dynamic_title',
1350 - 'type' => 'toggle',
1351 - 'label' => __( 'Show TOC Title in Anchor Links', 'betterdocs' ),
1352 - 'enable_disable_text_active' => true,
1353 - 'default' => 0,
1354 - 'priority' => 5,
1355 - 'rules' => Rules::is( 'enable_toc', true )
1356 - ],
1357 - 'enable_sticky_toc' => [
1358 - 'name' => 'enable_sticky_toc',
1359 - 'type' => 'toggle',
1360 - 'label' => __( 'Sticky TOC', 'betterdocs' ),
1361 - 'enable_disable_text_active' => true,
1362 - 'default' => 1,
1363 - 'priority' => 6,
1364 - 'rules' => Rules::is( 'enable_toc', true )
1365 - ],
1366 - 'collapsible_toc_mobile' => [
1367 - 'name' => 'collapsible_toc_mobile',
1368 - 'type' => 'toggle',
1369 - 'label' => __( 'Collapsible TOC on small devices', 'betterdocs' ),
1370 - 'enable_disable_text_active' => true,
1371 - 'default' => '',
1372 - 'priority' => 7,
1373 - 'rules' => Rules::is( 'enable_toc', true )
1374 - ],
1375 - 'title_link_ctc' => [
1376 - 'name' => 'title_link_ctc',
1377 - 'type' => 'toggle',
1378 - 'label' => __( 'Title Link Copy To Clipboard', 'betterdocs' ),
1379 - 'enable_disable_text_active' => true,
1380 - 'default' => 1,
1381 - 'priority' => 8
1382 - ],
1383 - 'supported_heading_tag' => [
1384 - 'name' => 'supported_heading_tag',
1385 - 'label' => __( 'TOC Supported Heading Tag', 'betterdocs' ),
1386 - 'type' => 'checkbox-select',
1387 - 'multiple' => true,
1388 - 'priority' => 10,
1389 - 'default' => [
1390 - '1',
1391 - '2',
1392 - '3',
1393 - '4',
1394 - '5',
1395 - '6'
1396 - ],
1397 - 'options' => $this->normalize_options( [
1398 - '1' => 'H1',
1399 - '2' => 'H2',
1400 - '3' => 'H3',
1401 - '4' => 'H4',
1402 - '5' => 'H5',
1403 - '6' => 'H6'
1404 - ] ),
1405 - 'priority' => 9,
1406 - 'rules' => Rules::is( 'enable_toc', true )
1407 - ],
1408 - 'sticky_toc_offset' => [
1409 - 'name' => 'sticky_toc_offset',
1410 - 'type' => 'number',
1411 - 'label' => __( 'Content Offset', 'betterdocs' ),
1412 - 'default' => 100,
1413 - 'priority' => 10,
1414 - 'label_subtitle' => __( 'content offset from top on scroll.', 'betterdocs' ),
1415 - 'rules' => Rules::is( 'enable_toc', true )
1416 - ]
1417 - ]
1418 - ],
1419 - 'layout_single_doc_breadcrumb' => [
1420 - 'id' => 'layout_single_doc_breadcrumb',
1421 - 'name' => 'layout_single_doc_breadcrumb',
1422 - 'type' => 'section',
1423 - 'label' => __( 'Breadcrumb', 'betterdocs' ),
1424 - 'priority' => 5,
1425 - 'fields' => [
1426 - 'enable_breadcrumb' => [
1427 - 'name' => 'enable_breadcrumb',
1428 - 'type' => 'toggle',
1429 - 'label' => __( 'Breadcrumb', 'betterdocs' ),
1430 - 'enable_disable_text_active' => true,
1431 - 'default' => 1,
1432 - 'priority' => 1
1433 - ],
1434 - 'enable_breadcrumb_home_text' => [
1435 - 'name' => 'enable_breadcrumb_home_text',
1436 - 'type' => 'toggle',
1437 - 'label' => __( 'Enable Breadcrumb Home Text', 'betterdocs' ),
1438 - 'enable_disable_text_active' => true,
1439 - 'default' => true,
1440 - 'priority' => 2,
1441 - 'rules' => Rules::is( 'enable_breadcrumb', true )
1442 - ],
1443 - 'breadcrumb_home_text' => [
1444 - 'name' => 'breadcrumb_home_text',
1445 - 'type' => 'text',
1446 - 'label' => __( 'Breadcrumb Home Text', 'betterdocs' ),
1447 - 'default' => __( 'Home', 'betterdocs' ),
1448 - 'priority' => 3,
1449 - 'rules' => Rules::logicalRule(
1450 - [
1451 - Rules::is( 'enable_breadcrumb', true ),
1452 - Rules::is( 'enable_breadcrumb_home_text', true )
1453 - ],
1454 - 'and'
1455 - )
1456 - ],
1457 - 'breadcrumb_home_url' => [
1458 - 'name' => 'breadcrumb_home_url',
1459 - 'type' => 'text',
1460 - 'label' => __( 'Breadcrumb Home URL', 'betterdocs' ),
1461 - 'priority' => 4,
1462 - 'default' => get_home_url(),
1463 - 'rules' => Rules::is( 'enable_breadcrumb', true )
1464 - ],
1465 - 'enable_breadcrumb_category' => [
1466 - 'name' => 'enable_breadcrumb_category',
1467 - 'type' => 'toggle',
1468 - 'label' => __( 'Category on Breadcrumb', 'betterdocs' ),
1469 - 'enable_disable_text_active' => true,
1470 - 'default' => 1,
1471 - 'priority' => 5,
1472 - 'rules' => Rules::is( 'enable_breadcrumb', true )
1473 - ],
1474 - 'enable_breadcrumb_title' => [
1475 - 'name' => 'enable_breadcrumb_title',
1476 - 'type' => 'toggle',
1477 - 'label' => __( 'Title on Breadcrumb', 'betterdocs' ),
1478 - 'enable_disable_text_active' => true,
1479 - 'default' => 1,
1480 - 'priority' => 6,
1481 - 'rules' => Rules::is( 'enable_breadcrumb', true )
1482 - ]
1483 - ]
1484 - ],
1485 - 'layout_single_doc_email_feedback' => [
1486 - 'id' => 'layout_single_doc_email_feedback',
1487 - 'name' => 'layout_single_doc_email_feedback',
1488 - 'type' => 'section',
1489 - 'label' => __( 'Email Feedback', 'betterdocs' ),
1490 - 'priority' => 5,
1491 - 'fields' => [
1492 - 'email_feedback' => [
1493 - 'name' => 'email_feedback',
1494 - 'type' => 'toggle',
1495 - 'label' => __( 'Email Feedback', 'betterdocs' ),
1496 - 'enable_disable_text_active' => true,
1497 - 'default' => 1,
1498 - 'priority' => 1
1499 - ],
1500 - 'feedback_link_text' => [
1501 - 'name' => 'feedback_link_text',
1502 - 'type' => 'text',
1503 - 'label' => __( 'Feedback Link Text', 'betterdocs' ),
1504 - 'default' => __( 'Still stuck? How can we help?', 'betterdocs' ),
1505 - 'priority' => 2,
1506 - 'rules' => Rules::is( 'email_feedback', true )
1507 - ],
1508 - 'feedback_form_title' => [
1509 - 'name' => 'feedback_form_title',
1510 - 'type' => 'text',
1511 - 'label' => __( 'Feedback Form Title', 'betterdocs' ),
1512 - 'default' => __( 'Still stuck? How can we help?', 'betterdocs' ),
1513 - 'priority' => 3,
1514 - 'rules' => Rules::is( 'email_feedback', true )
1515 - ],
1516 - 'email_address' => [
1517 - 'name' => 'email_address',
1518 - 'type' => 'text',
1519 - 'label' => __( 'Email Address', 'betterdocs' ),
1520 - 'default' => get_option( 'admin_email' ),
1521 - 'priority' => 4,
1522 - 'label_subtitle' => __( 'The email address where the Feedback form will be sent', 'betterdocs' ),
1523 - 'rules' => Rules::is( 'email_feedback', true )
1524 - ],
1525 - 'feedback_url' => [
1526 - 'name' => 'feedback_url',
1527 - 'type' => 'text',
1528 - 'label' => __( 'Feedback URL', 'betterdocs' ),
1529 - 'default' => '',
1530 - 'priority' => 5,
1531 - 'rules' => Rules::is( 'email_feedback', true )
1532 - ]
1533 - ]
1534 - ],
1535 - [
1536 - 'id' => 'layout_single_doc_attachments',
1537 - 'name' => 'layout_single_doc_attachments',
1538 - 'type' => 'section',
1539 - 'label' => __( 'Attachments', 'betterdocs' ),
1540 - 'priority' => 6,
1541 - 'fields' => apply_filters( 'betterdocs_single_doc_attachments', [
1542 - 'show_attachment' => [
1543 - 'name' => 'show_attachment',
1544 - 'type' => 'toggle',
1545 - 'is_pro' => true,
1546 - 'priority' => 1,
1547 - 'label' => __( 'Show Attachment', 'betterdocs' ),
1548 - 'enable_disable_text_active' => true,
1549 - 'default' => false
1550 - ]
1551 - ] )
1552 - ],
1553 - [
1554 - 'id' => 'layout_single_doc_related_docs',
1555 - 'name' => 'layout_single_doc_related_docs',
1556 - 'type' => 'section',
1557 - 'label' => __( 'Related Docs', 'betterdocs' ),
1558 - 'priority' => 7,
1559 - 'fields' => apply_filters( 'betterdocs_single_doc_related_docs', [
1560 - 'show_related_docs' => [
1561 - 'name' => 'show_related_docs',
1562 - 'type' => 'toggle',
1563 - 'is_pro' => true,
1564 - 'priority' => 1,
1565 - 'label' => __( 'Show Related Docs', 'betterdocs' ),
1566 - 'enable_disable_text_active' => true,
1567 - 'default' => false
1568 - ]
1569 - ] )
1570 - ]
1571 - ]
1572 - ]
1573 - ]
1574 - ] ),
1575 - 'layout_archive_page' => [
1576 - 'id' => 'layout_archive_page',
1577 - 'name' => 'layout_archive_page',
1578 - 'type' => 'section',
1579 - 'label' => __( 'Archive Page', 'betterdocs' ),
1580 - 'priority' => 3,
1581 - 'fields' => [
1582 - 'enable_archive_sidebar' => [
1583 - 'name' => 'enable_archive_sidebar',
1584 - 'type' => 'toggle',
1585 - 'label' => __( 'Sidebar Category List', 'betterdocs' ),
1586 - 'enable_disable_text_active' => true,
1587 - 'default' => 1,
1588 - 'priority' => 31
1589 - ],
1590 - 'archive_nested_subcategory' => [
1591 - 'name' => 'archive_nested_subcategory',
1592 - 'type' => 'toggle',
1593 - 'label' => __( 'Nested Subcategory', 'betterdocs' ),
1594 - 'enable_disable_text_active' => true,
1595 - 'default' => 1,
1596 - 'priority' => 32
1597 - ],
1598 - 'archive_enable_pagination' => [
1599 - 'name' => 'archive_enable_pagination',
1600 - 'type' => 'toggle',
1601 - 'label' => __( 'Enable Pagination', 'betterdocs' ),
1602 - 'enable_disable_text_active' => true,
1603 - 'default' => false,
1604 - 'priority' => 33
1605 - ]
1606 - ]
1607 - ]
1608 - ]
1609 - ] )
1610 - ]
1611 - ]
1612 - ]
1613 - ] ),
1614 - 'tab-design' => apply_filters( 'betterdocs_settings_tab_design', [
1615 - 'id' => 'tab-design',
1616 - 'label' => __( 'Design', 'betterdocs' ),
1617 - 'priority' => 30,
1618 - 'fields' => [
1619 - 'title-design' => [
1620 - 'name' => 'title-design-tab',
1621 - 'type' => 'section',
1622 - 'label' => __( 'Design', 'betterdocs' ),
1623 - 'priority' => 30,
1624 - 'fields' => $this->design_tab()
1625 - ]
1626 - ]
1627 - ] ),
1628 - 'tab-shortcodes' => apply_filters( 'betterdocs_settings_tab_shortcodes', [
1629 - 'label' => __( 'Shortcodes', 'betterdocs' ),
1630 - 'id' => 'tab-shortcodes',
1631 - 'classes' => 'tab-shortcodes',
1632 - 'priority' => 40,
1633 - 'fields' => [
1634 - 'title-shortcodes' => [
1635 - 'name' => 'title-shortcodes-tab',
1636 - 'type' => 'section',
1637 - 'label' => __( 'Shortcodes', 'betterdocs' ),
1638 - 'priority' => 40,
1639 - 'searchable' => true,
1640 - 'searchPlaceholder' => __( 'Search for shortcode', 'betterdocs' ),
1641 - 'searchNotFoundMessage' => '<img src="' . betterdocs()->assets->icon( 'not-found.svg', true ) . '"/><p>' . __( 'No Shortcodes Found with these keywords', 'betterdocs' ) . '</p>',
1642 - 'fields' => apply_filters( 'betterdocs_shortcode_fields', [
1643 - 'search_form' => [
1644 - 'name' => 'search_form',
1645 - 'type' => 'copy-to-clipboard',
1646 - 'label' => __( 'Search Form', 'betterdocs' ),
1647 - 'default' => '[betterdocs_search_form]',
1648 - 'readOnly' => true,
1649 - 'priority' => 1,
1650 - 'description' => __( '[betterdocs_search_form placeholder="Search..." heading="Heading" subheading="Subheading" category_search="true" search_button="true" popular_search="true"]', 'betterdocs' ),
1651 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1652 - 'descriptionCopyable' => true
1653 - ],
1654 - 'feedback_form' => [
1655 - 'name' => 'feedback_form',
1656 - 'type' => 'copy-to-clipboard',
1657 - 'label' => __( 'Feedback Form', 'betterdocs' ),
1658 - 'default' => '[betterdocs_feedback_form]',
1659 - 'readOnly' => true,
1660 - 'priority' => 2,
1661 - 'description' => __( '[betterdocs_feedback_form button_text="Send"]', 'betterdocs' ),
1662 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1663 - 'descriptionCopyable' => true
1664 - ],
1665 - 'category_grid' => [
1666 - 'name' => 'category_grid',
1667 - 'type' => 'copy-to-clipboard',
1668 - 'label' => __( 'Category Grid- Layout 1', 'betterdocs' ),
1669 - 'default' => '[betterdocs_category_grid]',
1670 - 'readOnly' => true,
1671 - 'priority' => 3,
1672 - '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' ),
1673 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1674 - 'descriptionCopyable' => true
1675 - ],
1676 - 'category_box' => [
1677 - 'name' => 'category_box',
1678 - 'type' => 'copy-to-clipboard',
1679 - 'label' => __( 'Category Box- Layout 2', 'betterdocs' ),
1680 - 'default' => '[betterdocs_category_box]',
1681 - 'readOnly' => true,
1682 - 'priority' => 4,
1683 - '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' ),
1684 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1685 - 'descriptionCopyable' => true
1686 - ],
1687 - 'category_list' => [
1688 - 'name' => 'category_list',
1689 - 'type' => 'copy-to-clipboard',
1690 - 'label' => __( 'Category List', 'betterdocs' ),
1691 - 'default' => '[betterdocs_category_list]',
1692 - 'readOnly' => true,
1693 - 'priority' => 5,
1694 - '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' ),
1695 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1696 - 'descriptionCopyable' => true
1697 - ],
1698 - 'faq_modern_layout' => [
1699 - 'name' => 'faq_modern_layout',
1700 - 'type' => 'copy-to-clipboard',
1701 - 'label' => __( 'FAQ Layout - 1', 'betterdocs' ),
1702 - 'default' => '[betterdocs_faq_list_modern]',
1703 - 'readOnly' => true,
1704 - 'priority' => 13,
1705 - 'description' => __( '[betterdocs_faq_list_modern groups="group_id" class="" group_exclude="group_id" faq_heading="Frequently Asked Questions"]', 'betterdocs' ),
1706 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1707 - 'descriptionCopyable' => true
1708 - ],
1709 - 'faq_classic_layout' => [
1710 - 'name' => 'faq_classic_layout',
1711 - 'type' => 'copy-to-clipboard',
1712 - 'label' => __( 'FAQ Layout - 2', 'betterdocs' ),
1713 - 'default' => '[betterdocs_faq_list_classic]',
1714 - 'readOnly' => true,
1715 - 'priority' => 14,
1716 - 'description' => __( '[betterdocs_faq_list_classic groups="group_id" class="" group_exclude="group_id" faq_heading="Frequently Asked Questions"]', 'betterdocs' ),
1717 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1718 - 'descriptionCopyable' => true
1719 - ],
1720 - 'betterdocs_faq_list_layout_3' => [
1721 - 'name' => 'betterdocs_faq_list_layout_3',
1722 - 'type' => 'copy-to-clipboard',
1723 - 'label' => __( 'FAQ Layout - 3', 'betterdocs' ),
1724 - 'default' => '[betterdocs_faq_list_layout_3 class="faq-doc betterdocs-faq-layout-3"]',
1725 - 'readOnly' => true,
1726 - 'priority' => 15,
1727 - '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' ),
1728 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1729 - 'descriptionCopyable' => true
1730 - ],
1731 - 'betterdocs_faq_tab' => [
1732 - 'name' => 'betterdocs_faq_tab',
1733 - 'type' => 'copy-to-clipboard',
1734 - 'label' => __( 'FAQ Layout - 4', 'betterdocs' ),
1735 - 'default' => '[betterdocs_faq_tab class="faq-doc betterdocs-faq-layout-4"]',
1736 - 'readOnly' => true,
1737 - 'priority' => 16,
1738 - 'description' => __( '[betterdocs_faq_tab class="faq-doc betterdocs-faq-layout-4" groups="group_id" group_exclude="group_id" faq_heading="Frequently Asked Questions"]', 'betterdocs' ),
1739 - 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
1740 - 'descriptionCopyable' => true
1741 - ]
1742 - ] )
1743 - ]
1744 - ]
1745 - ] ),
1746 - 'tab-advance-settings' => apply_filters( 'betterdocs_settings_tab_advance', [
1747 - 'id' => 'tab-advance-settings',
1748 - 'label' => __( 'Access & Restrictions', 'betterdocs' ),
1749 - 'classes' => 'tab-layout',
1750 - 'priority' => 50,
1751 - 'fields' => [
1752 - 'title_advance_settings' => [
1753 - 'name' => 'title-advance-settings-tab',
1754 - 'type' => 'section',
1755 - 'label' => __( 'Access & Restrictions', 'betterdocs' ),
1756 - 'priority' => 50,
1757 - 'fields' => [
1758 - 'tab-advanced-settings' => [
1759 - 'id' => 'tab-advanced-settings',
1760 - 'name' => 'tab-advanced-settings',
1761 - 'label' => __( 'Access & Restrictions', 'betterdocs' ),
1762 - 'classes' => 'tab-layout',
1763 - 'type' => 'tab',
1764 - 'active' => 'global_role_management',
1765 - 'completionTrack' => true,
1766 - 'sidebar' => false,
1767 - 'save' => false,
1768 - 'title' => false,
1769 - 'config' => [
1770 - 'active' => '',
1771 - 'sidebar' => false,
1772 - 'title' => false
1773 - ],
1774 - 'submit' => [
1775 - 'show' => false
1776 - ],
1777 - 'step' => [
1778 - 'show' => false
1779 - ],
1780 - 'priority' => 50,
1781 - 'fields' => [
1782 - 'global_role_management' => [
1783 - 'id' => 'global_role_management',
1784 - 'name' => 'global_role_management',
1785 - 'type' => 'section',
1786 - 'label' => __( 'Global Role Management', 'betterdocs' ),
1787 - 'priority' => 1,
1788 - 'fields' => [
1789 - 'article_roles' => [
1790 - 'name' => 'article_roles',
1791 - 'type' => 'checkbox-select',
1792 - 'label' => __( 'Who Can Write Docs?', 'betterdocs' ),
1793 - 'priority' => 1,
1794 - 'multiple' => true,
1795 - 'search' => true,
1796 - 'is_pro' => true,
1797 - 'default' => [ 'administrator' ],
1798 - 'options' => $wp_roles
1799 - ],
1800 - 'settings_roles' => [
1801 - 'name' => 'settings_roles',
1802 - 'type' => 'checkbox-select',
1803 - 'label' => __( 'Who Can Edit Settings?', 'betterdocs' ),
1804 - 'priority' => 2,
1805 - 'multiple' => true,
1806 - 'is_pro' => true,
1807 - 'search' => true,
1808 - 'default' => [ 'administrator' ],
1809 - 'options' => $wp_roles
1810 - ],
1811 - 'analytics_roles' => [
1812 - 'name' => 'analytics_roles',
1813 - 'type' => 'checkbox-select',
1814 - 'label' => __( 'Who Can Check Analytics?', 'betterdocs' ),
1815 - 'priority' => 3,
1816 - 'multiple' => true,
1817 - 'is_pro' => true,
1818 - 'search' => true,
1819 - 'default' => [ 'administrator' ],
1820 - 'options' => $wp_roles
1821 - ],
1822 - 'faq_roles' => [
1823 - 'name' => 'faq_roles',
1824 - 'type' => 'checkbox-select',
1825 - 'label' => __( 'Who Can Check FAQ Builder?', 'betterdocs' ),
1826 - 'priority' => 4,
1827 - 'multiple' => true,
1828 - 'is_pro' => true,
1829 - 'search' => true,
1830 - 'default' => [ 'administrator' ],
1831 - 'options' => $wp_roles
1832 - ],
799 + return $this->database->save( $this->base_key, $_settings );
800 + }
1833 801
1834 - ]
1835 - ],
1836 - 'internal_knowledge_base' => [
1837 - 'id' => 'internal_knowledge_base',
1838 - 'name' => 'internal_knowledge_base',
1839 - 'type' => 'section',
1840 - 'label' => __('Internal Knowledge Base', 'betterdocs'),
1841 - 'priority' => 1,
1842 - 'fields' => apply_filters('betterdocs_settings_content_restriction_fields', [
1843 - 'enable_content_restriction' => [
1844 - 'name' => 'enable_content_restriction',
1845 - 'type' => 'toggle',
1846 - 'is_pro' => true,
1847 - 'priority' => 5,
1848 - 'label' => __( 'Internal Knowledge Base', 'betterdocs' ),
1849 - 'enable_disable_text_active' => true,
1850 - 'default' => [ 'all' ]
1851 - ],
1852 - 'internal_knowledge_base_type' => [
1853 - 'name' => 'internal_knowledge_base_type',
1854 - 'type' => 'radio-card',
1855 - 'label' => __( 'Choose a Rule Type', 'betterdocs' ),
1856 - 'label_subtitle' => __( 'Choose a rule type: apply access globally (Basic), or configure detailed restrictions (Advanced) for docs, categories, and KBs.', 'betterdocs' ),
1857 - 'priority' => 6,
1858 - 'multiple' => true,
1859 - 'search' => true,
1860 - 'default' => [ 'all' ],
1861 - 'placeholder' => __( 'Select any', 'betterdocs' ),
1862 - 'options' => [
1863 - [
1864 - 'label' => 'Basic',
1865 - 'value' => 'basic'
1866 - ],
1867 - [
1868 - 'label' => 'Advanced',
1869 - 'value' => 'advanced'
1870 - ]
1871 - ],
1872 - 'filterValue' => 'all',
1873 - 'rules' => Rules::is( 'enable_content_restriction', true )
1874 - ],
1875 - 'content_visibility' => [
1876 - 'name' => 'content_visibility',
1877 - 'type' => 'checkbox-select',
1878 - 'label' => __( 'Restrict Access to', 'betterdocs' ),
1879 - 'label_subtitle' => __( 'Only selected User Roles will be able to view your Knowledge Base', 'betterdocs' ),
1880 - 'is_pro' => true,
1881 - 'priority' => 7,
1882 - 'multiple' => true,
1883 - 'search' => true,
1884 - 'default' => [ 'all' ],
1885 - 'placeholder' => __( 'Select any', 'betterdocs' ),
1886 - 'options' => $roles_for_ikb,
1887 - 'rules' => Rules::logicalRule(
1888 - [
1889 - Rules::is( 'enable_content_restriction', true ),
1890 - Rules::is( 'internal_knowledge_base_type', 'basic' )
1891 - ],
1892 - 'and'
1893 - ),
1894 - 'filterValue' => 'all'
1895 - ],
1896 - 'restrict_template' => [
1897 - 'name' => 'restrict_template',
1898 - 'type' => 'checkbox-select',
1899 - 'label' => __( 'Restriction on Docs', 'betterdocs' ),
1900 - 'label_subtitle' => __( 'Selected Docs pages will be restricted', 'betterdocs' ),
1901 - 'is_pro' => true,
1902 - 'priority' => 8,
1903 - 'multiple' => true,
1904 - 'search' => true,
1905 - 'default' => [ 'all' ],
1906 - 'placeholder' => __( 'Select any', 'betterdocs' ),
1907 - 'options' => $this->get_texanomy(),
1908 - 'rules' => Rules::logicalRule(
1909 - [
1910 - Rules::is( 'enable_content_restriction', true ),
1911 - Rules::is( 'internal_knowledge_base_type', 'basic' )
1912 - ],
1913 - 'and'
1914 - ),
1915 - 'filterValue' => 'all'
1916 - ],
1917 - 'restrict_category' => [
1918 - 'name' => 'restrict_category',
1919 - 'type' => 'checkbox-select',
1920 - 'label' => __( 'Restriction on Docs Categories', 'betterdocs' ),
1921 - 'label_subtitle' => __( 'Selected Docs categories will be restricted', 'betterdocs' ),
1922 - 'is_pro' => true,
1923 - 'priority' => 9,
1924 - 'multiple' => true,
1925 - 'search' => true,
1926 - 'default' => [ 'all' ],
1927 - 'placeholder' => __( 'Select any', 'betterdocs' ),
1928 - 'options' => $this->get_terms( 'doc_category' ),
1929 - 'rules' => Rules::logicalRule(
1930 - [
1931 - Rules::is( 'enable_content_restriction', true ),
1932 - Rules::is( 'internal_knowledge_base_type', 'basic' )
1933 - ],
1934 - 'and'
1935 - ),
1936 - 'filterValue' => 'all'
1937 - ],
1938 - 'restricted_redirect_url' => [
1939 - 'name' => 'restricted_redirect_url',
1940 - 'type' => 'text',
1941 - 'label' => __( 'Redirect URL', 'betterdocs' ),
1942 - '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' ),
1943 - 'default' => '',
1944 - 'placeholder' => 'https://',
1945 - 'is_pro' => true,
1946 - 'priority' => 20,
1947 - 'rules' => Rules::logicalRule(
1948 - [
1949 - Rules::is( 'enable_content_restriction', true ),
1950 - ],
1951 - 'and'
1952 - )
1953 - ]
1954 - ] )
1955 - ]
1956 - ]
1957 - ]
1958 - ]
1959 - ]
1960 - ]
1961 - ] ),
1962 - 'tab-email-reporting' => apply_filters( 'betterdocs_settings_tab_email_reporting', [
1963 - 'id' => 'tab-email-reporting',
1964 - 'label' => __( 'Email Reporting', 'betterdocs' ),
1965 - 'priority' => 60,
1966 - 'fields' => [
1967 - 'title-email-reporting' => [
1968 - 'name' => 'title-email-reporting-tab',
1969 - 'type' => 'section',
1970 - 'label' => __( 'Email Reporting', 'betterdocs' ),
1971 - 'priority' => 60,
1972 - 'fields' => [
1973 - 'enable_reporting' => [
1974 - 'name' => 'enable_reporting',
1975 - 'label' => __( 'Email Reporting', 'betterdocs' ),
1976 - 'enable_disable_text_active' => true,
1977 - 'type' => 'toggle',
1978 - 'priority' => 1,
1979 - 'default' => 0
1980 - ],
1981 - 'reporting_frequency' => apply_filters( 'betterdocs_reporting_frequency_settings', [
1982 - 'name' => 'reporting_frequency',
1983 - 'type' => 'select',
1984 - 'label' => __( 'Reporting Frequency', 'betterdocs' ),
1985 - 'default' => 'betterdocs_weekly',
1986 - 'priority' => 2,
1987 - 'is_pro' => true,
1988 - 'options' => $this->normalize_options( [
1989 - 'betterdocs_daily' => __( 'Once Daily', 'betterdocs' ),
1990 - 'betterdocs_weekly' => __( 'Once Weekly', 'betterdocs' ),
1991 - 'betterdocs_monthly' => __( 'Once Monthly', 'betterdocs' )
1992 - ] ),
1993 - 'rules' => Rules::is( 'enable_reporting', true )
1994 - ] ),
1995 - 'reporting_day' => [
1996 - 'name' => 'reporting_day',
1997 - 'type' => 'select',
1998 - 'label' => __( 'Reporting Day', 'betterdocs' ),
1999 - 'default' => 'monday',
2000 - 'rules' => Rules::logicalRule( [
2001 - Rules::is( 'enable_reporting', true ),
2002 - Rules::is( 'reporting_frequency', 'betterdocs_weekly' )
2003 - ], 'and' ),
2004 - 'priority' => 3,
2005 - 'options' => $this->normalize_options( [
2006 - 'sunday' => __( 'Sunday', 'betterdocs' ),
2007 - 'monday' => __( 'Monday', 'betterdocs' ),
2008 - 'tuesday' => __( 'Tuesday', 'betterdocs' ),
2009 - 'wednesday' => __( 'Wednesday', 'betterdocs' ),
2010 - 'thursday' => __( 'Thursday', 'betterdocs' ),
2011 - 'friday' => __( 'Friday', 'betterdocs' ),
2012 - 'saturday' => __( 'Saturday', 'betterdocs' )
2013 - ] ),
2014 - 'label_subtitle' => __( 'This is only applicable for the “Weekly” report', 'betterdocs' )
2015 - ],
2016 - 'select_reporting_data' => apply_filters( 'betterdocs_select_reporting_data_settings', [
2017 - 'name' => 'select_reporting_data',
2018 - 'type' => 'checkbox-select',
2019 - 'label' => __( 'Select Reporting Data', 'betterdocs' ),
2020 - 'priority' => 4,
2021 - 'multiple' => true,
2022 - 'options' => $this->normalize_options( [
2023 - 'overview' => 'Overview',
2024 - 'top-docs' => 'Top Docs',
2025 - 'most-search' => 'Most Searched Keywords'
2026 - ] ),
2027 - 'default' => [ 'overview', 'top-docs', 'most-search' ],
2028 - 'is_pro' => true,
2029 - 'rules' => Rules::is( 'enable_reporting', true )
2030 - ] ),
2031 - 'reporting_email' => [
2032 - 'name' => 'reporting_email',
2033 - 'type' => 'text',
2034 - 'label' => __( 'Reporting Email', 'betterdocs' ),
2035 - 'default' => get_option( 'admin_email' ),
2036 - 'priority' => 5,
2037 - 'rules' => Rules::is( 'enable_reporting', true )
2038 - ],
2039 - 'reporting_subject' => apply_filters( 'betterdocs_reporting_subject_settings', [
2040 - 'name' => 'reporting_subject',
2041 - 'type' => 'textarea',
2042 - 'label' => __( 'Reporting Email Subject', 'betterdocs' ),
2043 - 'default' => wp_sprintf( // Translators: %s is replaced with the website name.
2044 - __( 'Your Documentation Performance of %s Website', 'betterdocs' ), get_bloginfo( 'name' ) ),
2045 - 'priority' => 6,
2046 - 'is_pro' => true,
2047 - 'rules' => Rules::is( 'enable_reporting', true )
2048 - ] ),
2049 - 'test_report' => [
2050 - 'name' => 'test_report',
2051 - 'label' => __( 'Reporting Test', 'betterdocs' ),
2052 - 'text' => __( 'Test Report', 'betterdocs' ),
2053 - 'type' => 'button',
2054 - 'priority' => 7,
2055 - 'rules' => Rules::is( 'enable_reporting', true ),
2056 - 'ajax' => [
2057 - 'on' => 'click',
2058 - 'api' => '/betterdocs/v1/reporting-test',
2059 - 'data' => [
2060 - 'enable_reporting' => '@enable_reporting',
2061 - 'select_reporting_data' => '@select_reporting_data',
2062 - 'reporting_subject' => '@reporting_subject',
2063 - 'reporting_email' => '@reporting_email',
2064 - 'reporting_day' => '@reporting_day',
2065 - 'reporting_frequency' => '@reporting_frequency'
2066 - ],
2067 - 'swal' => [
2068 - 'text' => __( 'Successfully Sent a Test Report in Your Email.', 'betterdocs' ),
2069 - 'icon' => 'success',
2070 - 'autoClose' => 2000
2071 - ]
2072 - ]
2073 - ]
2074 - ]
2075 - ]
2076 - ]
2077 - ] ),
2078 - 'tab-github-integration' => apply_filters( 'betterdocs_settings_tab_github_integration', [
2079 - 'id' => 'tab-github-integration',
2080 - 'label' => __( 'Git Sync', 'betterdocs' ),
2081 - 'priority' => 60,
2082 - 'fields' => [
2083 - 'title-git-integration' => [
2084 - 'name' => 'title-git-integration-tab',
2085 - 'type' => 'section',
2086 - 'label' => __( 'Git Sync Settings', 'betterdocs' ),
2087 - 'priority' => 60,
2088 - 'fields' => [
2089 - 'enable_git_integration' => [
2090 - 'name' => 'enable_git_integration',
2091 - 'type' => 'toggle',
2092 - 'label' => __( 'Enable Git Sync', 'betterdocs' ),
2093 - 'enable_disable_text_active' => true,
2094 - 'default' => false,
2095 - 'priority' => 1,
2096 - 'is_pro' => true,
2097 - 'label_subtitle' => __( 'Enable bidirectional synchronization between BetterDocs and Git repositories', 'betterdocs' )
2098 - ]
2099 - ]
2100 - ]
2101 - ]
2102 - ] ),
2103 - 'tab-instant-answer' => apply_filters( 'betterdocs_settings_tab_instant_answer', [
2104 - 'id' => 'tab-instant-answer',
2105 - 'name' => 'tab-instant-answer',
2106 - 'type' => 'section',
2107 - 'label' => __( 'Instant Answer', 'betterdocs' ),
2108 - 'save' => false,
2109 - 'priority' => 70,
2110 - 'fields' => [
2111 - 'title-instant-answer' => [
2112 - 'name' => 'title-instant-answer-tab',
2113 - 'type' => 'section',
2114 - 'label' => __( 'Instant Answer', 'betterdocs' ),
2115 - 'priority' => 80,
2116 - 'save' => false,
2117 - 'showSubmit' => false,
2118 - 'fields' => apply_filters( 'betterdocs_instant_answer_fields', [
2119 - 'enable_disable_wrapper' => [
2120 - 'name' => 'enable_disable_wrapper',
2121 - 'type' => 'section',
2122 - 'priority' => 0,
2123 - 'save' => false,
2124 - 'fields' => [
2125 - 'enable_disable' => [
2126 - 'name' => 'enable_disable',
2127 - 'type' => 'toggle',
2128 - 'priority' => 100,
2129 - 'description' => __( 'Enable Instant Answer', 'betterdocs' ),
2130 - 'enable_disable_text_active' => false,
2131 - 'default' => false,
2132 - 'is_pro' => true
2133 - ]
2134 - ]
2135 - ]
2136 - ] )
2137 - ]
2138 - ]
2139 - ] ),
2140 - 'tab-betterdocs-ai' => [
2141 - 'id' => 'tab-betterdocs-ai',
2142 - 'name' => 'tab-betterdocs-ai',
2143 - 'type' => 'section',
2144 - 'label' => __( 'AI Content Suite', 'betterdocs' ),
2145 - 'priority' => 74,
2146 - 'fields' => [
2147 - 'sections-betterdocs-ai' => [
2148 - 'name' => 'sections-betterdocs-ai',
2149 - 'type' => 'section',
2150 - 'label' => __( 'AI Content Suite', 'betterdocs' ),
2151 - 'priority' => 10,
2152 - 'fields' => [
2153 - 'all-betterdocs-ai' => [
2154 - 'id' => 'all-tab-betterdocs-ai',
2155 - 'name' => 'all-tab-betterdocs-ai',
2156 - 'label' => __( 'AI Content Suite Settings', 'betterdocs' ),
2157 - 'classes' => 'tab-layout',
2158 - 'type' => 'tab',
2159 - 'active' => 'open-ai-settings',
2160 - 'completionTrack' => true,
2161 - 'sidebar' => false,
2162 - 'save' => false,
2163 - 'title' => false,
2164 - 'config' => [
2165 - 'active' => 'open-ai-settings',
2166 - 'sidebar' => false,
2167 - 'title' => false
2168 - ],
2169 - 'submit' => [
2170 - 'show' => false
2171 - ],
2172 - 'step' => [
2173 - 'show' => false
2174 - ],
2175 - 'priority' => 20,
2176 - 'fields' => apply_filters(
2177 - 'betterdocs_migration_tab_sections',
2178 - [
2179 - 'open-ai-settings' => [
2180 - 'id' => 'open-ai-settings',
2181 - 'name' => 'open-ai-settings',
2182 - 'type' => 'section',
2183 - 'label' => __( 'API Settings', 'betterdocs' ),
2184 - 'priority' => 1,
2185 - 'fields' => [
2186 - 'ai_autowrite_api_key' => [
2187 - 'name' => 'ai_autowrite_api_key',
2188 - 'type' => 'text',
2189 - 'label' => __( 'API Key', 'betterdocs' ),
2190 - '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/' ) ),
2191 - 'default' => '',
2192 - 'priority' => 1
2193 - ],
2194 - ]
2195 - ],
2196 - 'write-with-ai' => [
2197 - 'id' => 'write-with-ai',
2198 - 'name' => 'write-with-ai',
2199 - 'type' => 'section',
2200 - 'label' => __( 'Write with AI', 'betterdocs' ),
2201 - 'priority' => 5,
2202 - 'fields' => [
2203 - 'enable_write_with_ai' => [
2204 - 'name' => 'enable_write_with_ai',
2205 - 'type' => 'toggle',
2206 - 'priority' => 0,
2207 - 'label' => __( 'Write Docs with AI', 'betterdocs' ),
2208 - 'label_subtitle' => __( 'Generate AI based Documentation in your Gutenberg Editor', 'betterdocs' ),
2209 - 'enable_disable_text_active' => true,
2210 - 'default' => true
2211 - ],
2212 - 'enable_faq_write_with_ai' => [
2213 - 'name' => 'enable_faq_write_with_ai',
2214 - 'type' => 'toggle',
2215 - 'priority' => 5,
2216 - 'label' => __( 'Write FAQ with AI', 'betterdocs' ),
2217 - 'label_subtitle' => __( 'Generate AI based FAQ in your Editor', 'betterdocs' ),
2218 - 'enable_disable_text_active' => true,
2219 - 'default' => true
2220 - ],
2221 - 'write_with_ai_model' => [
2222 - 'name' => 'write_with_ai_model',
2223 - 'type' => 'select',
2224 - 'label' => __( 'OpenAI Model*', 'betterdocs' ),
2225 - 'priority' => 20,
2226 - 'multiple' => false,
2227 - 'default' => 'gpt-4o-mini',
2228 - 'options' => GlobalFields::normalize_fields( [
2229 - 'gpt-4o-mini' => 'GPT-4o Mini',
2230 - 'gpt-4o' => 'GPT-4o',
2231 - ] ),
2232 - ],
2233 - 'ai_autowrite_max_token' => [
2234 - 'name' => 'ai_autowrite_max_token',
2235 - 'type' => 'number',
2236 - 'label' => __( 'Set Max Tokens', 'betterdocs' ),
2237 - 'label_subtitle' => sprintf( // translators: %s is a link to more information about token limits.
2238 - __( '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' ) ),
2239 - 'default' => 1500,
2240 - 'priority' => 10
2241 - ],
2242 - ]
2243 - ],
2244 - 'article-summary' => [
2245 - 'id' => 'article-summary',
2246 - 'name' => 'article-summary',
2247 - 'type' => 'section',
2248 - 'label' => __( 'AI Doc Summarizer', 'betterdocs' ),
2249 - 'priority' => 10,
2250 - 'fields' => [
2251 - 'enable_article_summary' => [
2252 - 'name' => 'enable_article_summary',
2253 - 'type' => 'toggle',
2254 - 'priority' => 1,
2255 - 'label' => __( 'AI Powered Doc Summarizer', 'betterdocs' ),
2256 - 'label_subtitle' => __( 'Enable AI-powered article summaries on single doc pages. Requires OpenAI API key.', 'betterdocs' ),
2257 - 'enable_disable_text_active' => true,
2258 - 'default' => false
2259 - ],
2260 - 'article_summary_max_token' => [
2261 - 'name' => 'article_summary_max_token',
2262 - 'type' => 'number',
2263 - 'label' => __( 'Set Max Tokens', 'betterdocs' ),
2264 - 'label_subtitle' => sprintf( // translators: %s is a link to more information about token limits.
2265 - __( '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' ) ),
2266 - 'default' => 1500,
2267 - 'priority' => 5
2268 - ],
2269 - 'article_summary_model' => [
2270 - 'name' => 'article_summary_model',
2271 - 'type' => 'select',
2272 - 'label' => __( 'OpenAI Model*', 'betterdocs' ),
2273 - 'priority' => 10,
2274 - 'multiple' => false,
2275 - 'default' => 'gpt-4o-mini',
2276 - 'options' => GlobalFields::normalize_fields( [
2277 - 'gpt-4o-mini' => 'GPT-4o Mini',
2278 - 'gpt-4o' => 'GPT-4o',
2279 - ] ),
2280 - ],
2281 - ]
2282 - ],
2283 - ]
2284 - )
2285 - ]
2286 - ]
2287 - ]
2288 - ],
2289 - ],
2290 - 'tab-ai-chatbot' => apply_filters( 'betterdocs_settings_tab_ai_chatbot', [
2291 - 'id' => 'tab-ai-chatbot',
2292 - 'name' => 'tab-ai-chatbot',
2293 - 'type' => 'section',
2294 - 'label' => __( 'AI Chatbot', 'betterdocs' ),
2295 - 'submit' => [
2296 - 'show' => false
2297 - ],
2298 - 'save' => false,
2299 - 'priority' => 75,
2300 - 'fields' => [
2301 - 'title-ai-chatbot-tab' => [
2302 - 'name' => 'title-ai-chatbot-tab',
2303 - 'type' => 'section',
2304 - 'label' => __( 'AI Chatbot', 'betterdocs' ),
2305 - 'priority' => 80,
2306 - 'submit' => [
2307 - 'show' => false
2308 - ],
2309 - 'save' => false,
2310 - 'fields' => apply_filters( 'betterdocs_ai_chatbot_fields', [
2311 - 'ai_chatbot_fields' => [
2312 - 'name' => 'ai_chatbot_fields',
2313 - 'type' => 'section',
2314 - 'priority' => 0,
2315 - 'fields' => [
2316 - 'enable_ai_chatbot' => [
2317 - 'name' => 'enable_ai_chatbot',
2318 - 'label' => __( 'AI Chatbot', 'betterdocs' ),
2319 - 'description' => __( 'Enable AI Chatbot', 'betterdocs' ),
2320 - 'type' => 'toggle',
2321 - 'priority' => 5,
2322 - 'default' => 0,
2323 - 'is_pro' => true,
2324 - 'is_license_active' => false,
2325 - 'disabled' => ! betterdocs()->is_pro_active() || ! defined( 'BETTERDOCS_CHATBOT_FILE' )
2326 - ],
2327 - ]
2328 - ]
2329 - ] )
2330 - ]
2331 - ]
2332 - ] ),
2333 - ] ),
2334 - 'TAB_AI_CHATBOT' => get_option( 'enable_ai_chatbot' ),
2335 - 'CHATBOT_LICENSE' => get_option( 'betterdocs_chatbot_software__license_status' ),
2336 - 'PRO_ACTIVE' => is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' ),
2337 - 'PRO_LICENSE' => get_option( 'betterdocs_pro_software__license_status' ),
2338 - ];
802 + public function get_pages() {
803 + $_pages = betterdocs()->query->get_posts( array(
804 + 'post_type' => 'page',
805 + 'numberposts' => -1,
806 + 'post_status' => 'publish',
807 + 'posts_per_page' => -1
808 + ) );
2339 809
2340 - $settings = array_merge( $settings, $this->chatbot_active_localize() );
810 + $__pages = array();
2341 811
2342 - return apply_filters( 'betterdocs_settings_args', $settings );
2343 - }
812 + if ( ! empty( $_pages ) ) {
813 + $__pages[ 0 ] = __( 'Select a Page', 'betterdocs' );
814 + foreach ( $_pages->posts as $page ) {
815 + $__pages[ $page->ID ] = esc_html( $page->post_title );
816 + }
817 + }
2344 818
2345 - /**
2346 - * @return array
2347 - */
2348 - public function chatbot_active_localize() {
2349 - $chatbot_active = is_plugin_active( 'betterdocs-ai-chatbot/betterdocs-ai-chatbot.php' );
2350 - $chatbot_license_valid = get_option( 'betterdocs_chatbot_software__license_status' ) === 'valid';
2351 - $chatbot_enabled = $this->get( 'enable_ai_chatbot', false );
819 + return $__pages;
820 + }
2352 821
2353 - // AI Search Suggestions are enabled if all conditions are met
2354 - $ai_search_suggestions_enabled = betterdocs()->helper->is_ai_chatbot_enabled();
822 + public function settings_args() {
823 + $wp_roles = $this->normalize_options( $this->get_roles() );
2355 824
2356 - return [
2357 - 'CHATBOT_ACTIVE' => $chatbot_active,
2358 - 'CHATBOT_LICENSE_VALID' => $chatbot_license_valid,
2359 - 'CHATBOT_ENABLED' => $chatbot_enabled,
2360 - 'AI_SEARCH_SUGGESTIONS_ENABLED' => $ai_search_suggestions_enabled
2361 - ];
2362 - }
825 + $roles_for_ikb = $this->normalize_options( array_merge( array( 'all' => __( 'All logged in users', 'betterdocs' ) ), wp_roles()->role_names ) );
2363 826
2364 - /**
2365 - * Call This Function As Helper, When Pro Is Deactivated, To Be Used As Settings Default Values, When Betterdocs Pro Is Deactivated
2366 - *
2367 - * @return array
2368 - */
2369 - public function pro_settings_default_values() {
2370 - return [
2371 - 'multiple_kb' => false,
2372 - 'enable_glossaries' => false,
2373 - 'enable_encyclopedia' => false,
2374 - 'analytics_from' => false,
2375 - 'unique_visitor_count' => false,
2376 - 'exclude_bot_analytics' => false,
2377 - 'show_attachment' => false,
2378 - 'show_related_docs' => false,
2379 - 'advance_search' => false,
2380 - 'child_category_exclude' => false,
2381 - 'kb_based_search' => false,
2382 - 'enable_disable' => false,
2383 - 'enable_content_restriction' => false
2384 - ];
2385 - }
827 + unset( $roles_for_ikb[ 'administrator' ] );
2386 828
2387 - public function import_export_settings( $settings ) {
2388 - if ( ! current_user_can( 'import' ) ) {
2389 - return $settings;
2390 - }
829 + $settings = array(
830 + 'id' => 'betterdocs_settings_metabox_wrapper',
831 + 'title' => __( 'betterdocs', 'betterdocs' ),
832 + 'object_types' => array( 'betterdocs' ),
833 + 'context' => 'normal',
834 + 'priority' => 'high',
835 + 'show_header' => false,
836 + 'tabnumber' => false,
837 + 'is_pro_active' => betterdocs()->is_pro_active(),
838 + 'logoURL' => betterdocs()->assets->icon( 'betterdocs-icon.svg', true ),
839 + 'layout' => 'vertical',
840 + 'config' => array(
841 + 'active' => 'tab-general',
842 + 'sidebar' => true,
843 + 'title' => false
844 + ),
845 + 'submit' => array(
846 + 'show' => true,
847 + 'label' => __( 'Save', 'betterdocs' ),
848 + 'loadingLabel' => __( 'Saving...', 'betterdocs' ),
849 + 'class' => 'save-settings',
850 + 'rules' => Rules::logicalRule( array(
851 + Rules::is( 'config.active', 'tab-design', true ),
852 + Rules::is( 'config.active', 'tab-shortcodes', true ),
853 + Rules::is( 'config.active', 'tab-instant-answer', true ),
854 + Rules::is( 'config.active', 'tab-import-export', true ),
855 + Rules::is( 'config.active', 'tab-migration', true )
856 + ), 'and' )
857 + ),
858 + 'values' => betterdocs()->is_pro_active() ? $this->get_all() : array_merge( $this->get_all(), $this->pro_settings_default_values() ),
859 + 'tabs' => apply_filters( 'betterdocs_settings_tabs', array(
860 + 'tab-general' => apply_filters( 'betterdocs_settings_tab_general', array(
861 + 'id' => 'tab-general',
862 + 'label' => __( 'General', 'betterdocs' ),
863 + 'classes' => 'tab-general',
864 + 'priority' => 10,
865 + 'fields' => array(
866 + 'title-general' => apply_filters( 'betterdocs_encyclopedia_settings', array(
867 + 'name' => 'title-general-tab',
868 + 'type' => 'section',
869 + 'label' => __( 'General Settings', 'betterdocs' ),
870 + 'priority' => 10,
871 + 'fields' => array(
872 + 'multiple_kb' => apply_filters( 'betterdocs_multi_kb_settings', array(
873 + 'name' => 'multiple_kb',
874 + 'type' => 'toggle',
875 + 'label' => __( 'Multiple Knowledge Base', 'betterdocs' ),
876 + 'enable_disable_text_active' => true,
877 + 'default' => '',
878 + 'priority' => 1,
879 + 'is_pro' => true
880 + ) ),
881 + 'builtin_doc_page' => array(
882 + 'name' => 'builtin_doc_page',
883 + 'type' => 'toggle',
884 + 'label' => __( 'Built-in Documentation Page', 'betterdocs' ),
885 + 'enable_disable_text_active' => true,
886 + 'default' => 1,
887 + 'priority' => 2
888 + ),
889 + 'enable_category_hierarchy_slugs' => array(
890 + 'name' => 'enable_category_hierarchy_slugs',
891 + 'type' => 'toggle',
892 + 'label' => __( 'Enable Category Hierarchy Slug', 'betterdocs' ),
893 + 'enable_disable_text_active' => true,
894 + 'default' => false,
895 + 'priority' => 3,
896 + 'label_subtitle' => __( "Shows Hierarchy Based Permalink Slugs For Doc Categories & Single Doc Page", 'betterdocs' )
897 + ),
898 + 'breadcrumb_doc_title' => array(
899 + 'name' => 'breadcrumb_doc_title',
900 + 'type' => 'text',
901 + 'label' => __( 'Documentation Page Title', 'betterdocs' ),
902 + 'default' => __( 'Docs', 'betterdocs' ),
903 + 'priority' => 4,
904 + 'rules' => Rules::is( 'builtin_doc_page', true )
905 + ),
906 + 'docs_slug' => array(
907 + 'name' => 'docs_slug',
908 + 'type' => 'text',
909 + 'label' => __( 'BetterDocs Root Slug', 'betterdocs' ),
910 + 'default' => 'docs',
911 + 'priority' => 5,
912 + 'rules' => Rules::is( 'builtin_doc_page', true )
913 + ),
914 + 'docs_page' => array(
915 + 'name' => 'docs_page',
916 + 'label' => __( 'Docs Page', 'betterdocs' ),
917 + 'type' => 'select',
918 + 'default' => 0,
919 + 'priority' => 6,
920 + 'search' => true,
921 + 'options' => $this->normalize_options( $this->get_pages() ),
922 + 'label_subtitle' => __( 'You will need to insert BetterDocs Shortcode inside the page. This page will be used as docs permalink.', 'betterdocs' ),
923 + 'rules' => Rules::is( 'builtin_doc_page', false )
924 + ),
2391 925
2392 - $settings['tab-import-export'] = apply_filters( 'betterdocs_settings_tab_import_export', [
2393 - 'id' => 'tab-import-export',
2394 - 'name' => 'tab-import-export',
2395 - 'classes' => 'tab-import-export',
2396 - 'label' => __( 'Import / Export', 'betterdocs' ),
2397 - 'priority' => 80,
2398 - 'fields' => [
2399 - 'sections-import-export' => [
2400 - 'name' => 'sections-import-export',
2401 - 'type' => 'section',
2402 - 'label' => __( 'Import / Export', 'betterdocs' ),
2403 - 'priority' => 30,
2404 - 'fields' => [
2405 - 'all-tab-import-export' => [
2406 - 'id' => 'all-tab-import-export',
2407 - 'name' => 'all-tab-import-export',
2408 - 'label' => __( 'Import Export Settings', 'betterdocs' ),
2409 - 'classes' => 'tab-layout',
2410 - 'type' => 'tab',
2411 - 'active' => 'import',
2412 - 'completionTrack' => true,
2413 - 'sidebar' => false,
2414 - 'save' => false,
2415 - 'title' => false,
2416 - 'config' => [
2417 - 'active' => 'import',
2418 - 'sidebar' => false,
2419 - 'title' => false
2420 - ],
2421 - 'submit' => [
2422 - 'show' => false
2423 - ],
2424 - 'step' => [
2425 - 'show' => false
2426 - ],
2427 - 'priority' => 20,
2428 - 'fields' => [
2429 - 'import' => [
2430 - 'id' => 'import',
2431 - 'name' => 'import',
2432 - 'type' => 'section',
2433 - 'label' => __( 'Import', 'betterdocs' ),
2434 - 'priority' => 1,
2435 - 'fields' => [
2436 - 'import_tab_nested' => [
2437 - 'id' => 'import_tab_nested',
2438 - 'name' => 'import_tab_nested',
2439 - 'label' => __( 'Import', 'betterdocs' ),
2440 - 'classes' => 'tab-nested-layout',
2441 - 'type' => 'tab',
2442 - 'active' => 'import_docs_nested',
2443 - 'completionTrack' => true,
2444 - 'sidebar' => false,
2445 - 'save' => false,
2446 - 'title' => false,
2447 - 'config' => [
2448 - 'active' => 'import_docs_nested',
2449 - 'sidebar' => false,
2450 - 'title' => false
2451 - ],
2452 - 'submit' => [
2453 - 'show' => false
2454 - ],
2455 - 'step' => [
2456 - 'show' => false
2457 - ],
2458 - 'priority' => 1,
2459 - 'fields' => [
2460 - 'import_docs_nested' => [
2461 - 'id' => 'import_docs_nested',
2462 - 'name' => 'import_docs_nested',
2463 - 'type' => 'section',
2464 - 'label' => __( 'Import Docs', 'betterdocs' ),
2465 - 'priority' => 1,
2466 - 'fields' => [
2467 - 'import_docs' => [
2468 - 'name' => 'import_docs',
2469 - 'type' => 'importerupload',
2470 - 'label' => __( 'Import Docs', 'betterdocs' ),
2471 - 'label_subtitle' => wp_sprintf( // Translators: %1$s is a link to download a sample CSV file.
2472 - __( '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 ) ),
2473 - 'text' => [
2474 - 'normal' => __( 'Proceed', 'betterdocs' ),
2475 - 'saved' => __( 'Proceed', 'betterdocs' ),
2476 - 'loading' => __( 'Importing...', 'betterdocs' ),
2477 - 'exists_notice' => __( 'It seems like documentations with same slugs already exist on your website. What would you like to do?', 'betterdocs' )
2478 - ],
2479 - 'ajax' => [
2480 - 'on' => 'click',
2481 - 'api' => '/betterdocs/v1/import-docs',
2482 - 'swal' => [
2483 - 'text' => __( 'Import completed successfully.', 'betterdocs' ),
2484 - 'icon' => 'success',
2485 - 'autoClose' => 2000
2486 - ]
2487 - ],
2488 - 'file_type' => '.xml, .csv',
2489 - 'priority' => 1
2490 - ]
2491 - ]
2492 - ],
926 + 'category_slug' => array(
927 + 'name' => 'category_slug',
928 + 'type' => 'text',
929 + 'label' => __( 'Custom Category Slug', 'betterdocs' ),
930 + 'default' => 'docs-category',
931 + 'priority' => 7
932 + ),
933 + 'tag_slug' => array(
934 + 'name' => 'tag_slug',
935 + 'type' => 'text',
936 + 'label' => __( 'Custom Tag Slug', 'betterdocs' ),
937 + 'default' => 'docs-tag',
938 + 'priority' => 8
939 + ),
940 + 'permalink_structure' => array(
941 + 'name' => 'permalink_structure',
942 + 'type' => 'permalink_structure',
943 + 'label' => __( 'Single Docs Permalink', 'betterdocs' ),
944 + 'default' => PostType::permalink_structure(),
945 + 'priority' => 9,
946 + 'tags' => $this->normalize_options( array(
947 + '%doc_category%' => '%doc_category%',
948 + '%knowledge_base%' => '%knowledge_base%'
949 + ) ),
950 + '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' )
951 + ),
952 + 'enable_glossaries' => array(
953 + 'name' => 'enable_glossaries',
954 + 'type' => 'toggle',
955 + 'label' => __( 'Show Glossary', 'betterdocs' ),
956 + 'label_subtitle' => __( 'Enable the glossary feature to allow users to look up definitions for terms used within your encyclopedia or glossaries themselves.', 'betterdocs' ),
957 + 'enable_disable_text_active' => true,
958 + 'default' => false,
959 + 'priority' => 10,
960 + 'is_pro' => true
961 + ),
962 + 'enable_encyclopedia' => array(
963 + 'name' => 'enable_encyclopedia',
964 + 'type' => 'toggle',
965 + 'label' => __( 'Built-in Encyclopedia Page', 'betterdocs' ),
966 + 'enable_disable_text_active' => true,
967 + 'default' => false,
968 + 'priority' => 11,
969 + 'is_pro' => true
970 + ),
971 + 'enable_faq_schema' => array(
972 + 'name' => 'enable_faq_schema',
973 + 'type' => 'toggle',
974 + 'label' => __( 'FAQ Schema', 'betterdocs' ),
975 + 'enable_disable_text_active' => true,
976 + 'default' => '',
977 + 'priority' => 12
978 + ),
979 + 'analytics_from' => array(
980 + 'name' => 'analytics_from',
981 + 'type' => 'select',
982 + 'label' => __( 'Analytics From', 'betterdocs' ),
983 + 'options' => $this->normalize_options( array(
984 + 'everyone' => __( 'Everyone', 'betterdocs' ),
985 + 'guests' => __( 'Guests Only', 'betterdocs' ),
986 + 'registered_users' => __( 'Registered Users Only', 'betterdocs' )
987 + ) ),
988 + 'default' => 'everyone',
989 + 'priority' => 13
990 + ),
991 + 'unique_visitor_count' => array(
992 + 'name' => 'unique_visitor_count',
993 + 'type' => 'toggle',
994 + 'label' => __( 'Unique Visitor Count', 'betterdocs' ),
995 + 'enable_disable_text_active' => true,
996 + 'default' => true,
997 + 'priority' => 14
998 + ),
999 + 'exclude_bot_analytics' => array(
1000 + 'name' => 'exclude_bot_analytics',
1001 + 'type' => 'toggle',
1002 + 'label' => __( 'Exclude Bot Analytics', 'betterdocs' ),
1003 + 'enable_disable_text_active' => true,
1004 + 'default' => true,
1005 + 'priority' => 15
1006 + )
2493 1007
2494 - 'import_settings_nested' => [
2495 - 'id' => 'import_settings_nested',
2496 - 'name' => 'import_settings_nested',
2497 - 'type' => 'section',
2498 - 'label' => __( 'Import Settings', 'betterdocs' ),
2499 - 'priority' => 1,
2500 - 'fields' => [
2501 - 'settings_importer' => [
2502 - 'name' => 'settings_importer',
2503 - 'type' => 'settingsuploader',
2504 - 'label' => __( 'Import Settings', 'betterdocs' ),
2505 - 'label_subtitle' => __( 'To import BetterDocs Settings, please upload BetterDocs settings you have exported from another website in .json format', 'betterdocs' ),
2506 - 'reset' => __( 'Change', 'betterdocs' ),
2507 - 'priority' => 1
2508 - ],
2509 - 'import_settings' => [
2510 - 'name' => 'import_settings',
2511 - 'type' => 'button',
2512 - 'rules' => Rules::is( 'settings_importer', null, true ),
2513 - 'text' => [
2514 - 'normal' => __( 'Proceed', 'betterdocs' ),
2515 - 'saved' => __( 'Proceed', 'betterdocs' ),
2516 - 'loading' => __( 'Importing...', 'betterdocs' )
2517 - ],
2518 - 'ajax' => [
2519 - 'on' => 'click',
2520 - 'api' => '/betterdocs/v1/import-settings',
2521 - 'data' => [
2522 - 'settings' => '@settings_importer'
2523 - ],
2524 - 'swal' => [
2525 - 'text' => __( 'Import completed successfully.', 'betterdocs' ),
2526 - 'icon' => 'success',
2527 - 'autoClose' => 1000
2528 - ],
2529 - 'reload' => true
2530 - ],
2531 - 'priority' => 2
2532 - ]
2533 - ]
2534 - ]
2535 - ]
2536 - ]
2537 - ]
2538 - ],
2539 - 'export' => [
2540 - 'id' => 'export',
2541 - 'name' => 'export',
2542 - 'type' => 'section',
2543 - 'label' => __( 'Export', 'betterdocs' ),
2544 - 'priority' => 1,
2545 - 'fields' => [
2546 - 'export_tab_nested' => [
2547 - 'id' => 'export_tab_nested',
2548 - 'name' => 'export_tab_nested',
2549 - 'label' => __( 'Export', 'betterdocs' ),
2550 - 'classes' => 'tab-nested-layout',
2551 - 'type' => 'tab',
2552 - 'active' => 'export_docs_nested',
2553 - 'completionTrack' => true,
2554 - 'sidebar' => false,
2555 - 'save' => false,
2556 - 'title' => false,
2557 - 'config' => [
2558 - 'active' => 'export_docs_nested',
2559 - 'sidebar' => false,
2560 - 'title' => false
2561 - ],
2562 - 'submit' => [
2563 - 'show' => false
2564 - ],
2565 - 'step' => [
2566 - 'show' => false
2567 - ],
2568 - 'priority' => 1,
2569 - 'fields' => [
2570 - 'export_docs_nested' => [
2571 - 'id' => 'export_docs_nested',
2572 - 'name' => 'export_docs_nested',
2573 - 'type' => 'section',
2574 - 'label' => __( 'Export Docs', 'betterdocs' ),
2575 - 'priority' => 1,
2576 - 'fields' => apply_filters( 'betterdocs_export_fields', [
2577 - 'export_type' => [
2578 - 'name' => 'export_type',
2579 - 'label' => __( 'Select Docs Type', 'betterdocs' ),
2580 - 'label_subtitle' => __( 'Choose an export type: All Docs, a specific Knowledge Base, or a Doc Category', 'betterdocs' ),
2581 - 'type' => 'select',
2582 - 'default' => 'docs',
2583 - 'priority' => 3,
2584 - 'search' => true,
2585 - 'options' => $this->normalize_options( apply_filters( 'betterdocs_export_type_options', [
2586 - 'docs' => __( 'Docs', 'betterdocs' ),
2587 - 'doc_category' => __( 'Docs Category', 'betterdocs' ),
2588 - 'glossaries' => __( 'Glossaries', 'betterdocs' )
2589 - ] ) )
2590 - ],
2591 - 'export_docs' => [
2592 - 'name' => 'export_docs',
2593 - 'type' => 'checkbox-select',
2594 - 'label' => __( 'Select Docs', 'betterdocs' ),
2595 - 'label_subtitle' => __( 'Selected docs will be included in the export.', 'betterdocs' ),
2596 - 'priority' => 4,
2597 - 'multiple' => true,
2598 - 'search' => true,
2599 - 'default' => [ 'all' ],
2600 - 'placeholder' => __( 'Select any', 'betterdocs' ),
2601 - 'options' => array_merge( [
2602 - [
2603 - 'value' => 'all',
2604 - 'label' => 'All'
2605 - ]
2606 - ], $this->docs() ),
2607 - 'filterValue' => 'all',
2608 - 'rules' => Rules::is( 'export_type', 'docs' )
2609 - ],
2610 - 'export_categories' => [
2611 - 'name' => 'export_categories',
2612 - 'type' => 'checkbox-select',
2613 - 'label' => __( 'Select Categories', 'betterdocs' ),
2614 - 'label_subtitle' => __( 'Selected categories and its docs will be included in the export.', 'betterdocs' ),
2615 - 'priority' => 6,
2616 - 'multiple' => true,
2617 - 'search' => true,
2618 - 'default' => [ 'all' ],
2619 - 'placeholder' => __( 'Select any', 'betterdocs' ),
2620 - 'options' => $this->get_terms( 'doc_category', false ),
2621 - 'filterValue' => 'all',
2622 - 'rules' => Rules::is( 'export_type', 'doc_category' )
2623 - ],
2624 - 'export_glossaries' => [
2625 - 'name' => 'export_glossaries',
2626 - 'type' => 'checkbox-select',
2627 - 'label' => __( 'Select Glossaries', 'betterdocs' ),
2628 - 'label_subtitle' => __( 'Selected glossary terms will be exported.', 'betterdocs' ),
2629 - 'priority' => 7,
2630 - 'multiple' => true,
2631 - 'search' => true,
2632 - 'default' => [ 'all' ],
2633 - 'placeholder' => __( 'Select any', 'betterdocs' ),
2634 - 'options' => $this->get_terms( 'glossaries' ),
2635 - 'filterValue' => 'all',
2636 - 'rules' => Rules::is( 'export_type', 'glossaries' )
2637 - ],
2638 - 'file_type' => [
2639 - 'name' => 'file_type',
2640 - 'label' => __( 'Select File Type', 'betterdocs' ),
2641 - 'label_subtitle' => __( 'Choose a file type', 'betterdocs' ),
2642 - 'type' => 'select',
2643 - 'default' => 'xml',
2644 - 'priority' => 8,
2645 - 'search' => true,
2646 - 'options' => $this->normalize_options( apply_filters( 'betterdocs_export_file_type_options', [
2647 - 'xml' => __( '.xml', 'betterdocs' ),
2648 - 'csv' => __( '.csv', 'betterdocs' )
2649 - ] ) )
2650 - ],
2651 - 'enable_export_faq' => [
2652 - 'name' => 'enable_export_faq',
2653 - 'type' => 'toggle',
2654 - 'priority' => 9,
2655 - 'label' => __( 'Export FAQ', 'betterdocs' ),
2656 - 'label_subtitle' => __( 'Export FAQ Related Terms & Posts', 'betterdocs' ),
2657 - 'enable_disable_text_active' => true,
2658 - 'default' => true,
2659 - 'rules' => Rules::is( 'export_type', 'glossaries', true )
2660 - ],
2661 - 'export_docs_btn' => [
2662 - 'name' => 'export_docs_btn',
2663 - 'text' => [
2664 - 'normal' => __( 'Proceed', 'betterdocs' ),
2665 - 'saved' => __( 'Proceed', 'betterdocs' ),
2666 - 'loading' => __( 'Exporting...', 'betterdocs' )
2667 - ],
2668 - 'type' => 'button',
2669 - 'priority' => 10,
2670 - 'ajax' => [
2671 - 'on' => 'click',
2672 - 'api' => '/betterdocs/v1/export-docs',
2673 - 'data' => [
2674 - 'export_type' => '@export_type',
2675 - 'export_docs' => '@export_docs',
2676 - 'export_kbs' => '@export_kbs',
2677 - 'export_categories' => '@export_categories',
2678 - 'export_glossaries' => '@export_glossaries',
2679 - 'file_type' => '@file_type',
2680 - 'enable_export_faq' => '@enable_export_faq'
2681 - ],
2682 - 'swal' => [
2683 - 'text' => __( 'Exported Successfully.', 'betterdocs' ),
2684 - 'icon' => 'success',
2685 - 'autoClose' => 2000
2686 - ]
2687 - ]
2688 - ]
2689 - ] )
2690 - ],
1008 + )
1009 + ) )
1010 + )
1011 + ) ),
1012 + 'tab-layout' => apply_filters( 'betterdocs_settings_tab_layout', array(
1013 + 'id' => 'tab-layout',
1014 + 'label' => __( 'Layout', 'betterdocs' ),
1015 + 'classes' => 'tab-layout',
1016 + 'priority' => 20,
1017 + 'fields' => array(
1018 + 'title-layout' => array(
1019 + 'name' => 'title-layout-tab',
1020 + 'type' => 'section',
1021 + 'label' => __( 'Layout Settings', 'betterdocs' ),
1022 + 'priority' => 20,
1023 + 'fields' => array(
1024 + 'tab-sidebar-layout' => apply_filters( 'betterdocs_settings_tab_sidebar_layout', array(
1025 + 'id' => 'tab-sidebar-layout',
1026 + 'name' => 'tab_sidebar_layout',
1027 + 'label' => __( 'Layout Settings', 'betterdocs' ),
1028 + 'classes' => 'tab-layout',
1029 + 'type' => 'tab',
1030 + 'active' => 'layout_documentation_page',
1031 + 'completionTrack' => true,
1032 + 'sidebar' => false,
1033 + 'save' => false,
1034 + 'title' => false,
1035 + 'config' => array(
1036 + 'active' => 'layout_documentation_page',
1037 + 'sidebar' => false,
1038 + 'title' => false
1039 + ),
1040 + 'submit' => array(
1041 + 'show' => false
1042 + ),
1043 + 'step' => array(
1044 + 'show' => false
1045 + ),
1046 + 'priority' => 20,
1047 + 'fields' => array(
1048 + 'layout_documentation_page' => array(
1049 + 'id' => 'layout_documentation_page',
1050 + 'name' => 'layout_documentation_page',
1051 + 'type' => 'section',
1052 + 'label' => __( 'Documentation Page', 'betterdocs' ),
1053 + 'priority' => 1,
1054 + 'fields' => array(
1055 + 'tab-nested-layout-1' => array(
1056 + 'id' => 'tab-nested-layout-1',
1057 + 'name' => 'tab_nested_layout_1',
1058 + 'label' => __( 'Documentation Page', 'betterdocs' ),
1059 + 'classes' => 'tab-nested-layout',
1060 + 'type' => 'tab',
1061 + 'active' => 'layout_documentation_page_general',
1062 + 'completionTrack' => true,
1063 + 'sidebar' => false,
1064 + 'save' => false,
1065 + 'title' => false,
1066 + 'config' => array(
1067 + 'active' => 'layout_documentation_page_general',
1068 + 'sidebar' => false,
1069 + 'title' => false
1070 + ),
1071 + 'submit' => array(
1072 + 'show' => false
1073 + ),
1074 + 'step' => array(
1075 + 'show' => false
1076 + ),
1077 + 'priority' => 1,
1078 + 'fields' => array(
1079 + 'layout_documentation_page_general' => array(
1080 + 'id' => 'layout_documentation_page_general',
1081 + 'name' => 'layout_documentation_page_general',
1082 + 'type' => 'section',
1083 + 'label' => __( 'General', 'betterdocs' ),
1084 + 'priority' => 1,
1085 + 'fields' => array(
1086 + 'docs_list_icon' => array(
1087 + 'name' => 'docs_list_icon',
1088 + 'type' => 'media',
1089 + 'value' => '',
1090 + 'label' => __( 'Docs List Icon', 'betterdocs' ),
1091 + 'label_subtitle' => __( 'Upload your own preferred document list icon', 'betterdocs' ),
1092 + 'priority' => 0
1093 + ),
1094 + 'category_title_link' => array(
1095 + 'name' => 'category_title_link',
1096 + 'type' => 'toggle',
1097 + 'label' => __( 'Category Title Link', 'betterdocs' ),
1098 + 'label_subtitle' => __( 'This setting is applicable for category grid layout', 'betterdocs' ),
1099 + 'enable_disable_text_active' => true,
1100 + 'default' => false,
1101 + 'priority' => 0
1102 + ),
1103 + 'masonry_layout' => array(
1104 + 'name' => 'masonry_layout',
1105 + 'type' => 'toggle',
1106 + 'label' => __( 'Masonry', 'betterdocs' ),
1107 + 'enable_disable_text_active' => true,
1108 + 'default' => 1,
1109 + 'priority' => 1
1110 + ),
1111 + 'archive_lazy_load_descendants' => array(
1112 + 'name' => 'archive_lazy_load_descendants',
1113 + 'type' => 'toggle',
1114 + 'label' => __( 'Lazy Load Sidebar Docs & Subcategories', 'betterdocs' ),
1115 + 'label_subtitle' => __( 'Applies to the Sidebar layout wherever it appears — single docs, category archives, and the Sidebar widget/block. Off by default: enable to render only the active category upfront and fetch the rest on click (or on scroll for the Memphis layout), cutting initial HTML size on large knowledge bases.', 'betterdocs' ),
1116 + 'enable_disable_text_active' => true,
1117 + 'default' => false,
1118 + 'priority' => 2
1119 + ),
1120 + 'nested_subcategory' => array(
1121 + 'name' => 'nested_subcategory',
1122 + 'type' => 'toggle',
1123 + 'label' => __( 'Nested Sub Category', 'betterdocs' ),
1124 + 'enable_disable_text_active' => true,
1125 + 'default' => '',
1126 + 'priority' => 3
1127 + ),
1128 + 'column_number' => array(
1129 + 'name' => 'column_number',
1130 + 'type' => 'number',
1131 + 'label' => __( 'Number Of Columns', 'betterdocs' ),
1132 + 'label_subtitle' => __( 'This setting is not applicable for sleek layout.', 'betterdocs' ),
1133 + 'default' => 3,
1134 + 'priority' => 4
1135 + ),
1136 + 'posts_number' => apply_filters( 'betterdocs_posts_number', array(
1137 + 'name' => 'posts_number',
1138 + 'type' => 'number',
1139 + 'label' => __( 'Number Of Docs', 'betterdocs' ),
1140 + 'label_subtitle' => __( 'This setting is not applicable for handbook layout.', 'betterdocs' ),
1141 + 'default' => 10,
1142 + 'priority' => 5
1143 + ) ),
1144 + 'post_count' => array(
1145 + 'name' => 'post_count',
1146 + 'type' => 'toggle',
1147 + 'label' => __( 'Doc Count', 'betterdocs' ),
1148 + 'enable_disable_text_active' => true,
1149 + 'default' => 1,
1150 + 'priority' => 6
1151 + ),
1152 + 'count_text' => array(
1153 + 'name' => 'count_text',
1154 + 'type' => 'text',
1155 + 'label' => __( 'Count Text', 'betterdocs' ),
1156 + 'default' => __( 'Docs', 'betterdocs' ),
1157 + 'priority' => 7
1158 + ),
1159 + 'count_text_singular' => array(
1160 + 'name' => 'count_text_singular',
1161 + 'type' => 'text',
1162 + 'label' => __( 'Count Text Singular', 'betterdocs' ),
1163 + 'default' => __( 'Doc', 'betterdocs' ),
1164 + 'priority' => 8
1165 + ),
1166 + 'exploremore_btn' => array(
1167 + 'name' => 'exploremore_btn',
1168 + 'type' => 'toggle',
1169 + 'label' => __( 'Explore More Button', 'betterdocs' ),
1170 + 'enable_disable_text_active' => true,
1171 + 'default' => true,
1172 + 'priority' => 9
1173 + ),
1174 + 'exploremore_btn_txt' => array(
1175 + 'name' => 'exploremore_btn_txt',
1176 + 'type' => 'text',
1177 + 'label' => __( 'Explore More Button Text', 'betterdocs' ),
1178 + 'default' => __( 'Explore More', 'betterdocs' ),
1179 + 'priority' => 10,
1180 + 'rules' => Rules::is( 'exploremore_btn', true )
1181 + ),
1182 + 'betterdocs_popular_docs_text' => array(
1183 + 'name' => 'betterdocs_popular_docs_text',
1184 + 'type' => 'text',
1185 + 'label' => __( 'Popular Docs Text', 'betterdocs' ),
1186 + 'default' => __( 'Popular Docs', 'betterdocs' ),
1187 + 'priority' => 11,
1188 + 'is_pro' => true
1189 + ),
1190 + 'betterdocs_popular_docs_number' => array(
1191 + 'name' => 'betterdocs_popular_docs_number',
1192 + 'type' => 'number',
1193 + 'label' => __( 'Popular Docs Number', 'betterdocs' ),
1194 + 'default' => 10,
1195 + 'priority' => 12,
1196 + 'is_pro' => true
1197 + )
1198 + )
1199 + ),
1200 + 'layout_documentation_page_search' => array(
1201 + 'id' => 'layout_documentation_page_search',
1202 + 'name' => 'layout_documentation_page_search',
1203 + 'type' => 'section',
1204 + 'label' => __( 'Search', 'betterdocs' ),
1205 + 'priority' => 2,
1206 + 'fields' => array(
1207 + 'live_search' => array(
1208 + 'name' => 'live_search',
1209 + 'type' => 'toggle',
1210 + 'label' => __( 'Live Search', 'betterdocs' ),
1211 + 'enable_disable_text_active' => true,
1212 + 'default' => 1,
1213 + 'priority' => 1
1214 + ),
1215 + 'advance_search' => apply_filters( 'betterdocs_advance_search_settings', array(
1216 + 'name' => 'advance_search',
1217 + 'type' => 'toggle',
1218 + 'label' => __( 'Advanced Search', 'betterdocs' ),
1219 + 'enable_disable_text_active' => true,
1220 + 'default' => '',
1221 + 'priority' => 2,
1222 + 'is_pro' => true
1223 + ) ),
1224 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- legacy public filter name for category-exclude settings field, retained for back-compat.
1225 + 'child_category_exclude' => apply_filters( 'child_category_exclude', array(
1226 + 'name' => 'child_category_exclude',
1227 + 'type' => 'toggle',
1228 + 'label' => __( 'Exclude Child Terms In Category Search', 'betterdocs' ),
1229 + 'enable_disable_text_active' => true,
1230 + 'default' => false,
1231 + 'priority' => 3
1232 + ) ),
1233 + 'popular_keyword_limit' => apply_filters( 'betterdocs_popular_keyword_limit_settings', array(
1234 + 'name' => 'popular_keyword_limit',
1235 + 'type' => 'number',
1236 + 'label' => __( 'Minimum amount of Keywords Search', 'betterdocs' ),
1237 + 'default' => 5,
1238 + 'priority' => 4,
1239 + 'is_pro' => true
1240 + ) ),
1241 + 'search_letter_limit' => array(
1242 + 'name' => 'search_letter_limit',
1243 + 'type' => 'number',
1244 + 'label' => __( 'Minimum Character Limit For Search Result', 'betterdocs' ),
1245 + 'priority' => 5,
1246 + 'default' => 3
1247 + ),
1248 + 'search_placeholder' => array(
1249 + 'name' => 'search_placeholder',
1250 + 'type' => 'text',
1251 + 'label' => __( 'Search Placeholder', 'betterdocs' ),
1252 + 'default' => __( 'Search..', 'betterdocs' ),
1253 + 'priority' => 6
1254 + ),
1255 + 'search_button_text' => apply_filters( 'betterdocs_search_button_text', array(
1256 + 'name' => 'search_button_text',
1257 + 'type' => 'text',
1258 + 'label' => __( 'Search Button Text', 'betterdocs' ),
1259 + 'priority' => 7,
1260 + 'default' => __( 'Search', 'betterdocs' )
1261 + ) ),
1262 + 'search_not_found_text' => array(
1263 + 'name' => 'search_not_found_text',
1264 + 'type' => 'text',
1265 + 'label' => __( 'Search Not Found Text', 'betterdocs' ),
1266 + 'default' => 'Sorry, no docs were found.',
1267 + 'priority' => 8
1268 + ),
1269 + 'search_result_image' => array(
1270 + 'name' => 'search_result_image',
1271 + 'type' => 'toggle',
1272 + 'label' => __( 'Search Result Image', 'betterdocs' ),
1273 + 'enable_disable_text_active' => true,
1274 + 'default' => 1,
1275 + 'priority' => 9
1276 + ),
1277 + 'kb_based_search' => apply_filters( 'betterdocs_kb_based_search_settings', array(
1278 + 'name' => 'kb_based_search',
1279 + 'type' => 'toggle',
1280 + 'label' => __( 'KB Based Search', 'betterdocs' ),
1281 + 'enable_disable_text_active' => true,
1282 + 'default' => '',
1283 + 'priority' => 10,
1284 + 'is_pro' => true,
1285 + 'rules' => Rules::is( 'multiple_kb', true )
1286 + ) ),
1287 + 'search_modal_search_type' => array(
1288 + 'name' => 'search_modal_search_type',
1289 + 'type' => 'select',
1290 + 'label' => __( 'Search Modal Source', 'betterdocs' ),
1291 + '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' ),
1292 + 'default' => 'all',
1293 + 'options' => $this->normalize_options( array(
1294 + 'all' => __( 'Both (Docs + FAQs)', 'betterdocs' ),
1295 + 'docs' => __( 'Docs only', 'betterdocs' ),
1296 + 'faq' => __( 'FAQs only', 'betterdocs' )
1297 + ) ),
1298 + 'priority' => 11
1299 + )
1300 + )
1301 + ),
1302 + 'layout_documentation_page_order_by' => array(
1303 + 'id' => 'layout_documentation_page_order_by',
1304 + 'name' => 'layout_documentation_page_order_by',
1305 + 'type' => 'section',
1306 + 'label' => __( 'Order By', 'betterdocs' ),
1307 + 'priority' => 3,
1308 + 'fields' => array(
1309 + 'terms_orderby' => array(
1310 + 'name' => 'terms_orderby',
1311 + 'type' => 'select',
1312 + 'label' => __( 'Terms Order By', 'betterdocs' ),
1313 + 'default' => 'betterdocs_order',
1314 + 'options' => $this->normalize_options( apply_filters( 'betterdocs_terms_orderby_options', array(
1315 + 'none' => __( 'No order', 'betterdocs' ),
1316 + 'name' => __( 'Name', 'betterdocs' ),
1317 + 'slug' => __( 'Slug', 'betterdocs' ),
1318 + 'term_group' => __( 'Term Group', 'betterdocs' ),
1319 + 'term_id' => __( 'Term ID', 'betterdocs' ),
1320 + 'id' => __( 'ID', 'betterdocs' ),
1321 + 'description' => __( 'Description', 'betterdocs' ),
1322 + 'parent' => __( 'Parent', 'betterdocs' ),
1323 + 'betterdocs_order' => __( 'BetterDocs Order', 'betterdocs' )
1324 + ) ) ),
1325 + 'priority' => 1
1326 + ),
1327 + 'terms_order' => array(
1328 + 'name' => 'terms_order',
1329 + 'type' => 'select',
1330 + 'label' => __( 'Terms Order', 'betterdocs' ),
1331 + 'default' => 'ASC',
1332 + 'options' => $this->normalize_options( array(
1333 + 'ASC' => 'Ascending',
1334 + 'DESC' => 'Descending'
1335 + ) ),
1336 + 'priority' => 3,
1337 + 'rules' => Rules::includes( 'terms_orderby', 'betterdocs_order', true )
1338 + ),
1339 + 'alphabetically_order_post' => array(
1340 + 'name' => 'alphabetically_order_post',
1341 + 'type' => 'select',
1342 + 'label' => __( 'Docs Order By', 'betterdocs' ),
1343 + 'default' => 'betterdocs_order',
1344 + 'options' => $this->normalize_options( array(
1345 + 'none' => __( 'No order', 'betterdocs' ),
1346 + 'ID' => __( 'Docs ID', 'betterdocs' ),
1347 + 'author' => __( 'Docs Author', 'betterdocs' ),
1348 + 'title' => __( 'Title', 'betterdocs' ),
1349 + 'date' => __( 'Date', 'betterdocs' ),
1350 + 'modified' => __( 'Last Modified Date', 'betterdocs' ),
1351 + 'parent' => __( 'Parent Id', 'betterdocs' ),
1352 + 'rand' => __( 'Random', 'betterdocs' ),
1353 + 'comment_count' => __( 'Comment Count', 'betterdocs' ),
1354 + 'menu_order' => __( 'Menu Order', 'betterdocs' ),
1355 + 'betterdocs_order' => __( 'BetterDocs Order', 'betterdocs' )
1356 + ) ),
1357 + 'priority' => 4
1358 + ),
1359 + 'docs_order' => array(
1360 + 'name' => 'docs_order',
1361 + 'type' => 'select',
1362 + 'label' => __( 'Docs Order', 'betterdocs' ),
1363 + 'default' => 'ASC',
1364 + 'options' => $this->normalize_options( array(
1365 + 'ASC' => 'Ascending',
1366 + 'DESC' => 'Descending'
1367 + ) ),
1368 + 'priority' => 5,
1369 + 'rules' => Rules::includes( 'alphabetically_order_post', 'betterdocs_order', true )
1370 + )
1371 + )
1372 + )
1373 + )
1374 + )
1375 + )
1376 + ),
1377 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- legacy public filter name for single-doc setting section, retained for back-compat.
1378 + 'layout_single_doc' => apply_filters( 'single_doc_setting_section', array(
1379 + 'id' => 'layout_single_doc',
1380 + 'name' => 'layout_single_doc',
1381 + 'type' => 'section',
1382 + 'label' => __( 'Single Doc', 'betterdocs' ),
1383 + 'priority' => 2,
1384 + 'fields' => array(
1385 + 'tab-nested-layout-2' => array(
1386 + 'id' => 'tab-nested-layout-2',
1387 + 'name' => 'tab_nested_layout_2',
1388 + 'label' => __( 'Single Doc', 'betterdocs' ),
1389 + 'classes' => 'tab-nested-layout',
1390 + 'type' => 'tab',
1391 + 'active' => 'layout_single_doc_general',
1392 + 'completionTrack' => true,
1393 + 'sidebar' => false,
1394 + 'save' => false,
1395 + 'title' => false,
1396 + 'config' => array(
1397 + 'active' => 'layout_single_doc_general',
1398 + 'sidebar' => false,
1399 + 'title' => false
1400 + ),
1401 + 'submit' => array(
1402 + 'show' => false
1403 + ),
1404 + 'step' => array(
1405 + 'show' => false
1406 + ),
1407 + 'priority' => 20,
1408 + 'fields' => array(
1409 + 'layout_single_doc_general' => array(
1410 + 'id' => 'layout_single_doc_general',
1411 + 'name' => 'layout_single_doc_general',
1412 + 'type' => 'section',
1413 + 'label' => __( 'General', 'betterdocs' ),
1414 + 'priority' => 5,
1415 + 'fields' => array(
1416 + 'enable_post_title' => array(
1417 + 'name' => 'enable_post_title',
1418 + 'type' => 'toggle',
1419 + 'label' => __( 'Doc Title', 'betterdocs' ),
1420 + 'enable_disable_text_active' => true,
1421 + 'default' => 1,
1422 + 'priority' => 1
1423 + ),
1424 + 'enable_sidebar_cat_list' => array(
1425 + 'name' => 'enable_sidebar_cat_list',
1426 + 'type' => 'toggle',
1427 + 'label' => __( 'Sidebar Category List', 'betterdocs' ),
1428 + 'enable_disable_text_active' => true,
1429 + 'default' => 1,
1430 + 'priority' => 2
1431 + ),
1432 + 'enable_print_icon' => array(
1433 + 'name' => 'enable_print_icon',
1434 + 'type' => 'toggle',
1435 + 'label' => __( 'Print Icon', 'betterdocs' ),
1436 + 'enable_disable_text_active' => true,
1437 + 'default' => 1,
1438 + 'priority' => 3
1439 + ),
1440 + 'print_enable_logo' => array(
1441 + 'name' => 'print_enable_logo',
1442 + 'type' => 'toggle',
1443 + 'label' => __( 'Logo on Printed Doc', 'betterdocs' ),
1444 + 'label_subtitle' => __( 'Show a logo at the top of the printed / PDF page', 'betterdocs' ),
1445 + 'enable_disable_text_active' => true,
1446 + 'default' => 0,
1447 + 'priority' => 4
1448 + ),
1449 + 'print_logo' => array(
1450 + 'name' => 'print_logo',
1451 + 'type' => 'media',
1452 + 'value' => '',
1453 + 'label' => __( 'Print Logo', 'betterdocs' ),
1454 + 'label_subtitle' => __( 'Leave empty to use your site logo, or the site icon when no site logo is set', 'betterdocs' ),
1455 + 'priority' => 5,
1456 + 'rules' => Rules::is( 'print_enable_logo', true )
1457 + ),
1458 + 'print_enable_footer' => array(
1459 + 'name' => 'print_enable_footer',
1460 + 'type' => 'toggle',
1461 + 'label' => __( 'Footer on Printed Doc', 'betterdocs' ),
1462 + 'label_subtitle' => __( 'Show a footer on every page of the printed / PDF document', 'betterdocs' ),
1463 + 'enable_disable_text_active' => true,
1464 + 'default' => 0,
1465 + 'priority' => 6
1466 + ),
1467 + 'print_footer_text' => array(
1468 + 'name' => 'print_footer_text',
1469 + 'type' => 'textarea',
1470 + 'label' => __( 'Print Footer Text', 'betterdocs' ),
1471 + 'label_subtitle' => __( 'Leave empty to use the site name and current year', 'betterdocs' ),
1472 + 'default' => '',
1473 + 'priority' => 7,
1474 + 'rules' => Rules::is( 'print_enable_footer', true )
1475 + ),
1476 + 'enable_tags' => array(
1477 + 'name' => 'enable_tags',
1478 + 'type' => 'toggle',
1479 + 'label' => __( 'Tags', 'betterdocs' ),
1480 + 'enable_disable_text_active' => true,
1481 + 'default' => 1,
1482 + 'priority' => 8
1483 + ),
1484 + 'show_last_update_time' => array(
1485 + 'name' => 'show_last_update_time',
1486 + 'type' => 'toggle',
1487 + 'label' => __( 'Last Update Time', 'betterdocs' ),
1488 + 'enable_disable_text_active' => true,
1489 + 'default' => 1,
1490 + 'priority' => 9
1491 + ),
1492 + 'enable_navigation' => array(
1493 + 'name' => 'enable_navigation',
1494 + 'type' => 'toggle',
1495 + 'label' => __( 'Navigation', 'betterdocs' ),
1496 + 'enable_disable_text_active' => true,
1497 + 'default' => 1,
1498 + 'priority' => 10
1499 + ),
1500 + 'enable_comment' => array(
1501 + 'name' => 'enable_comment',
1502 + 'type' => 'toggle',
1503 + 'label' => __( 'Comment', 'betterdocs' ),
1504 + 'enable_disable_text_active' => true,
1505 + 'default' => '',
1506 + 'priority' => 11
1507 + ),
1508 + 'enable_credit' => array(
1509 + 'name' => 'enable_credit',
1510 + 'type' => 'toggle',
1511 + 'label' => __( 'Show Powered by BetterDocs', 'betterdocs' ),
1512 + 'enable_disable_text_active' => true,
1513 + 'default' => '',
1514 + 'priority' => 12
1515 + ),
1516 + 'reaction_feedback_text' => array(
1517 + 'name' => 'reaction_feedback_text',
1518 + 'type' => 'text',
1519 + 'label' => __( 'Reaction Feedback Text', 'betterdocs' ),
1520 + 'default' => __( 'Thanks for your feedback.', 'betterdocs' ),
1521 + 'priority' => 13
1522 + ),
1523 + 'enable_estimated_reading_time' => array(
1524 + 'name' => 'enable_estimated_reading_time',
1525 + 'type' => 'toggle',
1526 + 'label' => __( 'Estimated Reading Time', 'betterdocs' ),
1527 + 'enable_disable_text_active' => true,
1528 + 'default' => 0,
1529 + 'priority' => 14
1530 + ),
1531 + 'estimated_reading_time_title' => array(
1532 + 'name' => 'estimated_reading_time_title',
1533 + 'type' => 'text',
1534 + 'label' => __( 'Estimated Reading Time Title', 'betterdocs' ),
1535 + 'default' => '',
1536 + 'priority' => 15,
1537 + 'rules' => Rules::is( 'enable_estimated_reading_time', true )
1538 + ),
1539 + 'estimated_reading_time_text' => array(
1540 + 'name' => 'estimated_reading_time_text',
1541 + 'type' => 'text',
1542 + 'label' => __( 'Estimated Reading Time Text', 'betterdocs' ),
1543 + 'default' => __( 'min read', 'betterdocs' ),
1544 + 'priority' => 16,
1545 + 'rules' => Rules::is( 'enable_estimated_reading_time', true )
1546 + ),
1547 + 'singular_estimated_reading_time_text' => array(
1548 + 'name' => 'singular_estimated_reading_time_text',
1549 + 'type' => 'text',
1550 + 'label' => __( 'Estimated Reading Time Text Singular', 'betterdocs' ),
1551 + 'default' => __( 'min read', 'betterdocs' ),
1552 + 'priority' => 17,
1553 + 'rules' => Rules::is( 'enable_estimated_reading_time', true )
1554 + )
1555 + )
1556 + ),
1557 + 'layout_single_doc_TOC' => array(
1558 + 'id' => 'layout_single_doc_TOC',
1559 + 'name' => 'layout_single_doc_TOC',
1560 + 'type' => 'section',
1561 + 'label' => __( 'TOC', 'betterdocs' ),
1562 + 'priority' => 5,
1563 + 'fields' => array(
1564 + 'enable_toc' => array(
1565 + 'name' => 'enable_toc',
1566 + 'type' => 'toggle',
1567 + 'label' => __( 'Table of Contents', 'betterdocs' ),
1568 + 'enable_disable_text_active' => true,
1569 + 'default' => 1,
1570 + 'priority' => 1
1571 + ),
1572 + 'toc_title' => array(
1573 + 'name' => 'toc_title',
1574 + 'type' => 'text',
1575 + 'label' => __( 'TOC Title', 'betterdocs' ),
1576 + 'default' => __( 'Table of Contents', 'betterdocs' ),
1577 + 'priority' => 2,
1578 + 'rules' => Rules::is( 'enable_toc', true )
2691 1579
2692 - 'export_settings_nested' => [
2693 - 'id' => 'export_settings_nested',
2694 - 'name' => 'export_settings_nested',
2695 - 'type' => 'section',
2696 - 'label' => __( 'Export Settings', 'betterdocs' ),
2697 - 'priority' => 1,
2698 - 'fields' => [
2699 - 'export_settings' => [
2700 - 'name' => 'export_settings',
2701 - 'label' => __( 'Export Settings', 'betterdocs' ),
2702 - 'label_subtitle' => __( 'Simply click on “Export Settings” button to download your BetterDocs settings in .json format', 'betterdocs' ),
2703 - 'text' => [
2704 - 'normal' => __( 'Export Settings', 'betterdocs' ),
2705 - 'saved' => __( 'Export Settings', 'betterdocs' ),
2706 - 'loading' => __( 'Exporting...', 'betterdocs' )
2707 - ],
2708 - 'type' => 'button',
2709 - 'priority' => 8,
2710 - 'ajax' => [
2711 - 'on' => 'click',
2712 - 'api' => '/betterdocs/v1/export-settings',
2713 - 'data' => [
2714 - 'betterdocs_settings' => get_option( 'betterdocs_settings' )
2715 - ],
2716 - 'swal' => [
2717 - 'text' => __( 'File downloaded successfully.', 'betterdocs' ),
2718 - 'icon' => 'success',
2719 - 'autoClose' => 2000
2720 - ]
2721 - ]
2722 - ]
2723 - ]
2724 - ]
2725 - ]
2726 - ]
2727 - ]
2728 - ]
2729 - ]
2730 - ]
2731 - ]
2732 - ]
2733 - ]
2734 - ] );
1580 + ),
1581 + 'toc_hierarchy' => array(
1582 + 'name' => 'toc_hierarchy',
1583 + 'type' => 'toggle',
1584 + 'label' => __( 'TOC Hierarchy', 'betterdocs' ),
1585 + 'enable_disable_text_active' => true,
1586 + 'default' => 1,
1587 + 'priority' => 3,
1588 + 'rules' => Rules::is( 'enable_toc', true )
1589 + ),
1590 + 'toc_list_number' => array(
1591 + 'name' => 'toc_list_number',
1592 + 'type' => 'toggle',
1593 + 'label' => __( 'TOC List Number', 'betterdocs' ),
1594 + 'enable_disable_text_active' => true,
1595 + 'default' => 1,
1596 + 'priority' => 4,
1597 + 'rules' => Rules::is( 'enable_toc', true )
1598 + ),
1599 + 'toc_dynamic_title' => array(
1600 + 'name' => 'toc_dynamic_title',
1601 + 'type' => 'toggle',
1602 + 'label' => __( 'Show TOC Title in Anchor Links', 'betterdocs' ),
1603 + 'enable_disable_text_active' => true,
1604 + 'default' => 0,
1605 + 'priority' => 5,
1606 + 'rules' => Rules::is( 'enable_toc', true )
1607 + ),
1608 + 'enable_sticky_toc' => array(
1609 + 'name' => 'enable_sticky_toc',
1610 + 'type' => 'toggle',
1611 + 'label' => __( 'Sticky TOC', 'betterdocs' ),
1612 + 'enable_disable_text_active' => true,
1613 + 'default' => 1,
1614 + 'priority' => 6,
1615 + 'rules' => Rules::is( 'enable_toc', true )
1616 + ),
1617 + 'collapsible_toc_mobile' => array(
1618 + 'name' => 'collapsible_toc_mobile',
1619 + 'type' => 'toggle',
1620 + 'label' => __( 'Collapsible TOC on small devices', 'betterdocs' ),
1621 + 'enable_disable_text_active' => true,
1622 + 'default' => '',
1623 + 'priority' => 7,
1624 + 'rules' => Rules::is( 'enable_toc', true )
1625 + ),
1626 + 'title_link_ctc' => array(
1627 + 'name' => 'title_link_ctc',
1628 + 'type' => 'toggle',
1629 + 'label' => __( 'Title Link Copy To Clipboard', 'betterdocs' ),
1630 + 'enable_disable_text_active' => true,
1631 + 'default' => 1,
1632 + 'priority' => 8
1633 + ),
1634 + 'supported_heading_tag' => array(
1635 + 'name' => 'supported_heading_tag',
1636 + 'label' => __( 'TOC Supported Heading Tag', 'betterdocs' ),
1637 + 'type' => 'checkbox-select',
1638 + 'multiple' => true,
1639 + 'priority' => 10,
1640 + 'default' => array(
1641 + '1',
1642 + '2',
1643 + '3',
1644 + '4',
1645 + '5',
1646 + '6'
1647 + ),
1648 + 'options' => $this->normalize_options( array(
1649 + '1' => 'H1',
1650 + '2' => 'H2',
1651 + '3' => 'H3',
1652 + '4' => 'H4',
1653 + '5' => 'H5',
1654 + '6' => 'H6'
1655 + ) ),
1656 + 'priority' => 9,
1657 + 'rules' => Rules::is( 'enable_toc', true )
1658 + ),
1659 + 'sticky_toc_offset' => array(
1660 + 'name' => 'sticky_toc_offset',
1661 + 'type' => 'number',
1662 + 'label' => __( 'Content Offset', 'betterdocs' ),
1663 + 'default' => 100,
1664 + 'priority' => 10,
1665 + 'label_subtitle' => __( 'content offset from top on scroll.', 'betterdocs' ),
1666 + 'rules' => Rules::is( 'enable_toc', true )
1667 + )
1668 + )
1669 + ),
1670 + 'layout_single_doc_breadcrumb' => array(
1671 + 'id' => 'layout_single_doc_breadcrumb',
1672 + 'name' => 'layout_single_doc_breadcrumb',
1673 + 'type' => 'section',
1674 + 'label' => __( 'Breadcrumb', 'betterdocs' ),
1675 + 'priority' => 5,
1676 + 'fields' => array(
1677 + 'enable_breadcrumb' => array(
1678 + 'name' => 'enable_breadcrumb',
1679 + 'type' => 'toggle',
1680 + 'label' => __( 'Breadcrumb', 'betterdocs' ),
1681 + 'enable_disable_text_active' => true,
1682 + 'default' => 1,
1683 + 'priority' => 1
1684 + ),
1685 + 'enable_breadcrumb_home_text' => array(
1686 + 'name' => 'enable_breadcrumb_home_text',
1687 + 'type' => 'toggle',
1688 + 'label' => __( 'Enable Breadcrumb Home Text', 'betterdocs' ),
1689 + 'enable_disable_text_active' => true,
1690 + 'default' => true,
1691 + 'priority' => 2,
1692 + 'rules' => Rules::is( 'enable_breadcrumb', true )
1693 + ),
1694 + 'breadcrumb_home_text' => array(
1695 + 'name' => 'breadcrumb_home_text',
1696 + 'type' => 'text',
1697 + 'label' => __( 'Breadcrumb Home Text', 'betterdocs' ),
1698 + 'default' => __( 'Home', 'betterdocs' ),
1699 + 'priority' => 3,
1700 + 'rules' => Rules::logicalRule(
1701 + array(
1702 + Rules::is( 'enable_breadcrumb', true ),
1703 + Rules::is( 'enable_breadcrumb_home_text', true )
1704 + ),
1705 + 'and'
1706 + )
1707 + ),
1708 + 'breadcrumb_home_url' => array(
1709 + 'name' => 'breadcrumb_home_url',
1710 + 'type' => 'text',
1711 + 'label' => __( 'Breadcrumb Home URL', 'betterdocs' ),
1712 + 'priority' => 4,
1713 + 'default' => get_home_url(),
1714 + 'rules' => Rules::is( 'enable_breadcrumb', true )
1715 + ),
1716 + 'enable_breadcrumb_category' => array(
1717 + 'name' => 'enable_breadcrumb_category',
1718 + 'type' => 'toggle',
1719 + 'label' => __( 'Category on Breadcrumb', 'betterdocs' ),
1720 + 'enable_disable_text_active' => true,
1721 + 'default' => 1,
1722 + 'priority' => 5,
1723 + 'rules' => Rules::is( 'enable_breadcrumb', true )
1724 + ),
1725 + 'enable_breadcrumb_title' => array(
1726 + 'name' => 'enable_breadcrumb_title',
1727 + 'type' => 'toggle',
1728 + 'label' => __( 'Title on Breadcrumb', 'betterdocs' ),
1729 + 'enable_disable_text_active' => true,
1730 + 'default' => 1,
1731 + 'priority' => 6,
1732 + 'rules' => Rules::is( 'enable_breadcrumb', true )
1733 + )
1734 + )
1735 + ),
1736 + 'layout_single_doc_email_feedback' => array(
1737 + 'id' => 'layout_single_doc_email_feedback',
1738 + 'name' => 'layout_single_doc_email_feedback',
1739 + 'type' => 'section',
1740 + 'label' => __( 'Email Feedback', 'betterdocs' ),
1741 + 'priority' => 5,
1742 + 'fields' => array(
1743 + 'email_feedback' => array(
1744 + 'name' => 'email_feedback',
1745 + 'type' => 'toggle',
1746 + 'label' => __( 'Email Feedback', 'betterdocs' ),
1747 + 'enable_disable_text_active' => true,
1748 + 'default' => 1,
1749 + 'priority' => 1
1750 + ),
1751 + 'feedback_link_text' => array(
1752 + 'name' => 'feedback_link_text',
1753 + 'type' => 'text',
1754 + 'label' => __( 'Feedback Link Text', 'betterdocs' ),
1755 + 'default' => __( 'Still stuck? How can we help?', 'betterdocs' ),
1756 + 'priority' => 2,
1757 + 'rules' => Rules::is( 'email_feedback', true )
1758 + ),
1759 + 'feedback_form_title' => array(
1760 + 'name' => 'feedback_form_title',
1761 + 'type' => 'text',
1762 + 'label' => __( 'Feedback Form Title', 'betterdocs' ),
1763 + 'default' => __( 'Still stuck? How can we help?', 'betterdocs' ),
1764 + 'priority' => 3,
1765 + 'rules' => Rules::is( 'email_feedback', true )
1766 + ),
1767 + 'email_address' => array(
1768 + 'name' => 'email_address',
1769 + 'type' => 'text',
1770 + 'label' => __( 'Email Address', 'betterdocs' ),
1771 + 'default' => get_option( 'admin_email' ),
1772 + 'priority' => 4,
1773 + 'label_subtitle' => __( 'The email address where the Feedback form will be sent', 'betterdocs' ),
1774 + 'rules' => Rules::is( 'email_feedback', true )
1775 + ),
1776 + 'feedback_url' => array(
1777 + 'name' => 'feedback_url',
1778 + 'type' => 'text',
1779 + 'label' => __( 'Feedback URL', 'betterdocs' ),
1780 + 'default' => '',
1781 + 'priority' => 5,
1782 + 'rules' => Rules::is( 'email_feedback', true )
1783 + )
1784 + )
1785 + ),
1786 + array(
1787 + 'id' => 'layout_single_doc_attachments',
1788 + 'name' => 'layout_single_doc_attachments',
1789 + 'type' => 'section',
1790 + 'label' => __( 'Attachments', 'betterdocs' ),
1791 + 'priority' => 6,
1792 + 'fields' => apply_filters( 'betterdocs_single_doc_attachments', array(
1793 + 'show_attachment' => array(
1794 + 'name' => 'show_attachment',
1795 + 'type' => 'toggle',
1796 + 'is_pro' => true,
1797 + 'priority' => 1,
1798 + 'label' => __( 'Show Attachment', 'betterdocs' ),
1799 + 'enable_disable_text_active' => true,
1800 + 'default' => false
1801 + )
1802 + ) )
1803 + ),
1804 + array(
1805 + 'id' => 'layout_single_doc_related_docs',
1806 + 'name' => 'layout_single_doc_related_docs',
1807 + 'type' => 'section',
1808 + 'label' => __( 'Related Docs', 'betterdocs' ),
1809 + 'priority' => 7,
1810 + 'fields' => apply_filters( 'betterdocs_single_doc_related_docs', array(
1811 + 'show_related_docs' => array(
1812 + 'name' => 'show_related_docs',
1813 + 'type' => 'toggle',
1814 + 'is_pro' => true,
1815 + 'priority' => 1,
1816 + 'label' => __( 'Show Related Docs', 'betterdocs' ),
1817 + 'enable_disable_text_active' => true,
1818 + 'default' => false
1819 + )
1820 + ) )
1821 + ),
1822 + 'layout_single_doc_ai_actions' => array(
1823 + 'id' => 'layout_single_doc_ai_actions',
1824 + 'name' => 'layout_single_doc_ai_actions',
1825 + 'type' => 'section',
1826 + 'label' => __( 'AI Actions', 'betterdocs' ),
1827 + 'priority' => 8,
1828 + 'fields' => apply_filters( 'betterdocs_single_doc_ai_actions', array(
1829 + 'enable_ai_actions' => array(
1830 + 'name' => 'enable_ai_actions',
1831 + 'type' => 'toggle',
1832 + 'priority' => 1,
1833 + 'label' => __( 'Enable AI Actions', 'betterdocs' ),
1834 + 'label_subtitle' => __( 'Show a "Copy page" button beside the doc title so readers can copy the page as Markdown or open it in an AI assistant.', 'betterdocs' ),
1835 + 'enable_disable_text_active' => true,
1836 + 'default' => true
1837 + ),
1838 + 'enable_markdown_endpoint' => array(
1839 + 'name' => 'enable_markdown_endpoint',
1840 + 'type' => 'toggle',
1841 + 'priority' => 2,
1842 + 'label' => __( 'Serve Docs as Markdown', 'betterdocs' ),
1843 + // Plain text, not `<doc-url>.md`: the subtitle is rendered as HTML, so an
1844 + // angle-bracketed placeholder is swallowed as an unknown tag and the
1845 + // sentence read "Publish every doc at .md".
1846 + 'label_subtitle' => __( 'Publish every doc as Markdown at its address plus .md (for example /docs/getting-started.md), so AI assistants can read a clean copy. The Listen player uses it too. Required by "Copy page", "View as Markdown", and the Claude and Google AI Studio actions.', 'betterdocs' ),
1847 + 'enable_disable_text_active' => true,
1848 + 'default' => true
1849 + ),
1850 + // AI Actions and the Markdown endpoint are deliberately independent: the
1851 + // `.md` copies also serve AI assistants directly and the Listen player.
1852 + // So switching AI Actions off leaves Markdown on — say so where the
1853 + // admin is looking, rather than leaving a lone "Enabled" toggle under a
1854 + // feature that reads as switched off.
1855 + 'ai_actions_markdown_notice' => array(
1856 + 'name' => 'ai_actions_markdown_notice',
1857 + 'type' => 'html',
1858 + 'priority' => 3,
1859 + 'html' => sprintf(
1860 + '<div class="betterdocs-ai-actions-markdown-notice" style="margin:8px 0 0;padding:12px 16px;background:#f0f6ff;border-left:4px solid #5a6bff;border-radius:4px;font-size:13px;color:#202223;line-height:1.5;">%s</div>',
1861 + esc_html__( 'AI Actions is off, but your docs are still published as Markdown (.md) for AI assistants and the Listen player. Turn off "Serve Docs as Markdown" above if you don\'t want that.', 'betterdocs' )
1862 + ),
1863 + 'rules' => Rules::logicalRule( array(
1864 + Rules::is( 'enable_ai_actions', false ),
1865 + Rules::is( 'enable_markdown_endpoint', true )
1866 + ), 'and' )
1867 + ),
1868 + 'ai_actions_button_label' => array(
1869 + 'name' => 'ai_actions_button_label',
1870 + 'type' => 'text',
1871 + 'priority' => 4,
1872 + 'label' => __( 'Button Label', 'betterdocs' ),
1873 + 'default' => __( 'Copy page', 'betterdocs' ),
1874 + 'rules' => Rules::is( 'enable_ai_actions', true )
1875 + ),
1876 + 'ai_actions_prompt_template' => array(
1877 + 'name' => 'ai_actions_prompt_template',
1878 + 'type' => 'text',
1879 + 'priority' => 5,
1880 + 'label' => __( 'AI Prompt Template', 'betterdocs' ),
1881 + 'label_subtitle' => __( 'Sent to the AI assistant when a reader opens this doc there. Use {URL} for the doc address.', 'betterdocs' ),
1882 + 'default' => __( 'Read from {URL} so I can ask questions about it.', 'betterdocs' ),
1883 + 'rules' => Rules::is( 'enable_ai_actions', true )
1884 + ),
1885 + 'ai_actions_copy_page' => array(
1886 + 'name' => 'ai_actions_copy_page',
1887 + 'type' => 'toggle',
1888 + 'priority' => 6,
1889 + 'label' => __( 'Copy Page', 'betterdocs' ),
1890 + 'enable_disable_text_active' => true,
1891 + 'default' => true,
1892 + 'rules' => Rules::logicalRule( array(
1893 + Rules::is( 'enable_ai_actions', true ),
1894 + Rules::is( 'enable_markdown_endpoint', true )
1895 + ), 'and' )
1896 + ),
1897 + 'ai_actions_view_markdown' => array(
1898 + 'name' => 'ai_actions_view_markdown',
1899 + 'type' => 'toggle',
1900 + 'priority' => 7,
1901 + 'label' => __( 'View as Markdown', 'betterdocs' ),
1902 + 'enable_disable_text_active' => true,
1903 + 'default' => true,
1904 + 'rules' => Rules::logicalRule( array(
1905 + Rules::is( 'enable_ai_actions', true ),
1906 + Rules::is( 'enable_markdown_endpoint', true )
1907 + ), 'and' )
1908 + ),
1909 + 'ai_actions_chatgpt' => array(
1910 + 'name' => 'ai_actions_chatgpt',
1911 + 'type' => 'toggle',
1912 + 'priority' => 8,
1913 + 'label' => __( 'Open in ChatGPT', 'betterdocs' ),
1914 + 'enable_disable_text_active' => true,
1915 + 'default' => true,
1916 + 'rules' => Rules::is( 'enable_ai_actions', true )
1917 + ),
1918 + 'ai_actions_claude' => array(
1919 + 'name' => 'ai_actions_claude',
1920 + 'type' => 'toggle',
1921 + 'priority' => 9,
1922 + 'label' => __( 'Open in Claude', 'betterdocs' ),
1923 + 'enable_disable_text_active' => true,
1924 + 'default' => true,
1925 + 'rules' => Rules::logicalRule( array(
1926 + Rules::is( 'enable_ai_actions', true ),
1927 + Rules::is( 'enable_markdown_endpoint', true )
1928 + ), 'and' )
1929 + ),
1930 + 'ai_actions_gemini' => array(
1931 + 'name' => 'ai_actions_gemini',
1932 + 'type' => 'toggle',
1933 + 'priority' => 10,
1934 + 'label' => __( 'Open in Google AI Studio', 'betterdocs' ),
1935 + 'label_subtitle' => __( 'Gemini has no way to receive a prompt from a link, so this opens Google AI Studio instead. A Google account is required.', 'betterdocs' ),
1936 + 'enable_disable_text_active' => true,
1937 + 'default' => true,
1938 + 'rules' => Rules::logicalRule( array(
1939 + Rules::is( 'enable_ai_actions', true ),
1940 + Rules::is( 'enable_markdown_endpoint', true )
1941 + ), 'and' )
1942 + ),
1943 + 'ai_actions_perplexity' => array(
1944 + 'name' => 'ai_actions_perplexity',
1945 + 'type' => 'toggle',
1946 + 'priority' => 11,
1947 + 'label' => __( 'Open in Perplexity', 'betterdocs' ),
1948 + 'enable_disable_text_active' => true,
1949 + 'default' => false,
1950 + 'rules' => Rules::logicalRule( array(
1951 + Rules::is( 'enable_ai_actions', true ),
1952 + Rules::is( 'enable_markdown_endpoint', true )
1953 + ), 'and' )
1954 + ),
1955 + 'ai_actions_grok' => array(
1956 + 'name' => 'ai_actions_grok',
1957 + 'type' => 'toggle',
1958 + 'priority' => 12,
1959 + 'label' => __( 'Open in Grok', 'betterdocs' ),
1960 + 'enable_disable_text_active' => true,
1961 + 'default' => false,
1962 + 'rules' => Rules::logicalRule( array(
1963 + Rules::is( 'enable_ai_actions', true ),
1964 + Rules::is( 'enable_markdown_endpoint', true )
1965 + ), 'and' )
1966 + )
1967 + ) )
1968 + ),
1969 + 'layout_single_doc_listen' => array(
1970 + 'id' => 'layout_single_doc_listen',
1971 + 'name' => 'layout_single_doc_listen',
1972 + 'type' => 'section',
1973 + 'label' => __( 'Listen', 'betterdocs' ),
1974 + 'priority' => 9,
1975 + 'fields' => apply_filters( 'betterdocs_single_doc_listen', array(
1976 + 'enable_listen' => array(
1977 + 'name' => 'enable_listen',
1978 + 'type' => 'toggle',
1979 + 'priority' => 1,
1980 + 'label' => __( 'Enable Listen', 'betterdocs' ),
1981 + 'label_subtitle' => __( 'Show a "Listen" button beside the reading time. Pressed, it turns into a small audio player that reads the doc aloud using the visitor\'s browser — no audio files and no third-party service.', 'betterdocs' ),
1982 + 'enable_disable_text_active' => true,
1983 + 'default' => true
1984 + ),
1985 + 'listen_button_label' => array(
1986 + 'name' => 'listen_button_label',
1987 + 'type' => 'text',
1988 + 'priority' => 2,
1989 + 'label' => __( 'Button Label', 'betterdocs' ),
1990 + 'default' => __( 'Listen', 'betterdocs' ),
1991 + 'rules' => Rules::is( 'enable_listen', true )
1992 + ),
1993 + 'listen_show_speed' => array(
1994 + 'name' => 'listen_show_speed',
1995 + 'type' => 'toggle',
1996 + 'priority' => 3,
1997 + 'label' => __( 'Speed Control', 'betterdocs' ),
1998 + 'label_subtitle' => __( 'Let readers cycle the playback speed between 0.75× and 2×.', 'betterdocs' ),
1999 + 'enable_disable_text_active' => true,
2000 + 'default' => true,
2001 + 'rules' => Rules::is( 'enable_listen', true )
2002 + ),
2003 + 'listen_words_per_minute' => array(
2004 + 'name' => 'listen_words_per_minute',
2005 + 'type' => 'number',
2006 + 'priority' => 4,
2007 + 'label' => __( 'Words Per Minute', 'betterdocs' ),
2008 + 'label_subtitle' => __( 'Used to estimate the total playing time the player shows. Browser voices read at roughly 180 words a minute at normal speed; raise this if the countdown finishes early.', 'betterdocs' ),
2009 + 'default' => 180,
2010 + 'min' => 60,
2011 + 'max' => 400,
2012 + 'rules' => Rules::is( 'enable_listen', true )
2013 + )
2014 + ) )
2015 + )
2016 + )
2017 + )
2018 + )
2019 + ) ),
2020 + 'layout_archive_page' => array(
2021 + 'id' => 'layout_archive_page',
2022 + 'name' => 'layout_archive_page',
2023 + 'type' => 'section',
2024 + 'label' => __( 'Archive Page', 'betterdocs' ),
2025 + 'priority' => 3,
2026 + 'fields' => array(
2027 + 'enable_archive_sidebar' => array(
2028 + 'name' => 'enable_archive_sidebar',
2029 + 'type' => 'toggle',
2030 + 'label' => __( 'Sidebar Category List', 'betterdocs' ),
2031 + 'enable_disable_text_active' => true,
2032 + 'default' => 1,
2033 + 'priority' => 31
2034 + ),
2035 + 'archive_nested_subcategory' => array(
2036 + 'name' => 'archive_nested_subcategory',
2037 + 'type' => 'toggle',
2038 + 'label' => __( 'Nested Subcategory', 'betterdocs' ),
2039 + 'enable_disable_text_active' => true,
2040 + 'default' => 1,
2041 + 'priority' => 32
2042 + ),
2043 + 'archive_enable_pagination' => array(
2044 + 'name' => 'archive_enable_pagination',
2045 + 'type' => 'toggle',
2046 + 'label' => __( 'Enable Pagination', 'betterdocs' ),
2047 + 'enable_disable_text_active' => true,
2048 + 'default' => false,
2049 + 'priority' => 33
2050 + )
2051 + )
2052 + )
2053 + )
2054 + ) )
2055 + )
2056 + )
2057 + )
2058 + ) ),
2059 + 'tab-design' => apply_filters( 'betterdocs_settings_tab_design', array(
2060 + 'id' => 'tab-design',
2061 + 'label' => __( 'Design', 'betterdocs' ),
2062 + 'priority' => 30,
2063 + 'fields' => array(
2064 + 'title-design' => array(
2065 + 'name' => 'title-design-tab',
2066 + 'type' => 'section',
2067 + 'label' => __( 'Design', 'betterdocs' ),
2068 + 'priority' => 30,
2069 + 'fields' => $this->design_tab()
2070 + )
2071 + )
2072 + ) ),
2073 + 'tab-shortcodes' => apply_filters( 'betterdocs_settings_tab_shortcodes', array(
2074 + 'label' => __( 'Shortcodes', 'betterdocs' ),
2075 + 'id' => 'tab-shortcodes',
2076 + 'classes' => 'tab-shortcodes',
2077 + 'priority' => 40,
2078 + 'fields' => array(
2079 + 'title-shortcodes' => array(
2080 + 'name' => 'title-shortcodes-tab',
2081 + 'type' => 'section',
2082 + 'label' => __( 'Shortcodes', 'betterdocs' ),
2083 + 'priority' => 40,
2084 + 'searchable' => true,
2085 + 'searchPlaceholder' => __( 'Search for shortcode', 'betterdocs' ),
2086 + 'searchNotFoundMessage' => '<img src="' . betterdocs()->assets->icon( 'not-found.svg', true ) . '"/><p>' . __( 'No Shortcodes Found with these keywords', 'betterdocs' ) . '</p>',
2087 + 'fields' => apply_filters( 'betterdocs_shortcode_fields', array(
2088 + 'search_form' => array(
2089 + 'name' => 'search_form',
2090 + 'type' => 'copy-to-clipboard',
2091 + 'label' => __( 'Search Form', 'betterdocs' ),
2092 + 'default' => '[betterdocs_search_form]',
2093 + 'readOnly' => true,
2094 + 'priority' => 1,
2095 + 'description' => __( '[betterdocs_search_form placeholder="Search..." heading="Heading" subheading="Subheading" category_search="true" search_button="true" popular_search="true"]', 'betterdocs' ),
2096 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
2097 + 'descriptionCopyable' => true
2098 + ),
2099 + 'feedback_form' => array(
2100 + 'name' => 'feedback_form',
2101 + 'type' => 'copy-to-clipboard',
2102 + 'label' => __( 'Feedback Form', 'betterdocs' ),
2103 + 'default' => '[betterdocs_feedback_form]',
2104 + 'readOnly' => true,
2105 + 'priority' => 2,
2106 + 'description' => __( '[betterdocs_feedback_form button_text="Send"]', 'betterdocs' ),
2107 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
2108 + 'descriptionCopyable' => true
2109 + ),
2110 + 'category_grid' => array(
2111 + 'name' => 'category_grid',
2112 + 'type' => 'copy-to-clipboard',
2113 + 'label' => __( 'Category Grid- Layout 1', 'betterdocs' ),
2114 + 'default' => '[betterdocs_category_grid]',
2115 + 'readOnly' => true,
2116 + 'priority' => 3,
2117 + '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' ),
2118 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
2119 + 'descriptionCopyable' => true
2120 + ),
2121 + 'category_box' => array(
2122 + 'name' => 'category_box',
2123 + 'type' => 'copy-to-clipboard',
2124 + 'label' => __( 'Category Box- Layout 2', 'betterdocs' ),
2125 + 'default' => '[betterdocs_category_box]',
2126 + 'readOnly' => true,
2127 + 'priority' => 4,
2128 + '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' ),
2129 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
2130 + 'descriptionCopyable' => true
2131 + ),
2132 + 'category_list' => array(
2133 + 'name' => 'category_list',
2134 + 'type' => 'copy-to-clipboard',
2135 + 'label' => __( 'Category List', 'betterdocs' ),
2136 + 'default' => '[betterdocs_category_list]',
2137 + 'readOnly' => true,
2138 + 'priority' => 5,
2139 + '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' ),
2140 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
2141 + 'descriptionCopyable' => true
2142 + ),
2143 + 'faq_modern_layout' => array(
2144 + 'name' => 'faq_modern_layout',
2145 + 'type' => 'copy-to-clipboard',
2146 + 'label' => __( 'FAQ Layout - 1', 'betterdocs' ),
2147 + 'default' => '[betterdocs_faq_list_modern]',
2148 + 'readOnly' => true,
2149 + 'priority' => 13,
2150 + 'description' => __( '[betterdocs_faq_list_modern groups="group_id" class="" group_exclude="group_id" faq_heading="Frequently Asked Questions"]', 'betterdocs' ),
2151 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
2152 + 'descriptionCopyable' => true
2153 + ),
2154 + 'faq_classic_layout' => array(
2155 + 'name' => 'faq_classic_layout',
2156 + 'type' => 'copy-to-clipboard',
2157 + 'label' => __( 'FAQ Layout - 2', 'betterdocs' ),
2158 + 'default' => '[betterdocs_faq_list_classic]',
2159 + 'readOnly' => true,
2160 + 'priority' => 14,
2161 + 'description' => __( '[betterdocs_faq_list_classic groups="group_id" class="" group_exclude="group_id" faq_heading="Frequently Asked Questions"]', 'betterdocs' ),
2162 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
2163 + 'descriptionCopyable' => true
2164 + ),
2165 + 'betterdocs_faq_list_layout_3' => array(
2166 + 'name' => 'betterdocs_faq_list_layout_3',
2167 + 'type' => 'copy-to-clipboard',
2168 + 'label' => __( 'FAQ Layout - 3', 'betterdocs' ),
2169 + 'default' => '[betterdocs_faq_list_layout_3 class="faq-doc betterdocs-faq-layout-3"]',
2170 + 'readOnly' => true,
2171 + 'priority' => 15,
2172 + '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' ),
2173 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
2174 + 'descriptionCopyable' => true
2175 + ),
2176 + 'betterdocs_faq_tab' => array(
2177 + 'name' => 'betterdocs_faq_tab',
2178 + 'type' => 'copy-to-clipboard',
2179 + 'label' => __( 'FAQ Layout - 4', 'betterdocs' ),
2180 + 'default' => '[betterdocs_faq_tab class="faq-doc betterdocs-faq-layout-4"]',
2181 + 'readOnly' => true,
2182 + 'priority' => 16,
2183 + 'description' => __( '[betterdocs_faq_tab class="faq-doc betterdocs-faq-layout-4" groups="group_id" group_exclude="group_id" faq_heading="Frequently Asked Questions"]', 'betterdocs' ),
2184 + 'descriptionLabel' => __( 'Example with parameters:', 'betterdocs' ),
2185 + 'descriptionCopyable' => true
2186 + )
2187 + ) )
2188 + )
2189 + )
2190 + ) ),
2191 + 'tab-advance-settings' => apply_filters( 'betterdocs_settings_tab_advance', array(
2192 + 'id' => 'tab-advance-settings',
2193 + 'label' => __( 'Access & Restrictions', 'betterdocs' ),
2194 + 'classes' => 'tab-layout',
2195 + 'priority' => 50,
2196 + 'fields' => array(
2197 + 'title_advance_settings' => array(
2198 + 'name' => 'title-advance-settings-tab',
2199 + 'type' => 'section',
2200 + 'label' => __( 'Access & Restrictions', 'betterdocs' ),
2201 + 'priority' => 50,
2202 + 'fields' => array(
2203 + 'tab-advanced-settings' => array(
2204 + 'id' => 'tab-advanced-settings',
2205 + 'name' => 'tab-advanced-settings',
2206 + 'label' => __( 'Access & Restrictions', 'betterdocs' ),
2207 + 'classes' => 'tab-layout',
2208 + 'type' => 'tab',
2209 + 'active' => 'global_role_management',
2210 + 'completionTrack' => true,
2211 + 'sidebar' => false,
2212 + 'save' => false,
2213 + 'title' => false,
2214 + 'config' => array(
2215 + 'active' => '',
2216 + 'sidebar' => false,
2217 + 'title' => false
2218 + ),
2219 + 'submit' => array(
2220 + 'show' => false
2221 + ),
2222 + 'step' => array(
2223 + 'show' => false
2224 + ),
2225 + 'priority' => 50,
2226 + 'fields' => array(
2227 + 'global_role_management' => array(
2228 + 'id' => 'global_role_management',
2229 + 'name' => 'global_role_management',
2230 + 'type' => 'section',
2231 + 'label' => __( 'Global Role Management', 'betterdocs' ),
2232 + 'priority' => 1,
2233 + 'fields' => array(
2234 + 'article_roles' => array(
2235 + 'name' => 'article_roles',
2236 + 'type' => 'checkbox-select',
2237 + 'label' => __( 'Who Can Write Docs?', 'betterdocs' ),
2238 + 'priority' => 1,
2239 + 'multiple' => true,
2240 + 'search' => true,
2241 + 'is_pro' => true,
2242 + 'default' => array( 'administrator' ),
2243 + 'options' => $wp_roles
2244 + ),
2245 + 'settings_roles' => array(
2246 + 'name' => 'settings_roles',
2247 + 'type' => 'checkbox-select',
2248 + 'label' => __( 'Who Can Edit Settings?', 'betterdocs' ),
2249 + 'priority' => 2,
2250 + 'multiple' => true,
2251 + 'is_pro' => true,
2252 + 'search' => true,
2253 + 'default' => array( 'administrator' ),
2254 + 'options' => $wp_roles
2255 + ),
2256 + 'analytics_roles' => array(
2257 + 'name' => 'analytics_roles',
2258 + 'type' => 'checkbox-select',
2259 + 'label' => __( 'Who Can Check Analytics?', 'betterdocs' ),
2260 + 'priority' => 3,
2261 + 'multiple' => true,
2262 + 'is_pro' => true,
2263 + 'search' => true,
2264 + 'default' => array( 'administrator' ),
2265 + 'options' => $wp_roles
2266 + ),
2267 + 'faq_roles' => array(
2268 + 'name' => 'faq_roles',
2269 + 'type' => 'checkbox-select',
2270 + 'label' => __( 'Who Can Check FAQ Builder?', 'betterdocs' ),
2271 + 'priority' => 4,
2272 + 'multiple' => true,
2273 + 'is_pro' => true,
2274 + 'search' => true,
2275 + 'default' => array( 'administrator' ),
2276 + 'options' => $wp_roles
2277 + )
2735 2278
2736 - return $settings;
2737 - }
2279 + )
2280 + ),
2281 + 'internal_knowledge_base' => array(
2282 + 'id' => 'internal_knowledge_base',
2283 + 'name' => 'internal_knowledge_base',
2284 + 'type' => 'section',
2285 + 'label' => __( 'Internal Knowledge Base', 'betterdocs' ),
2286 + 'priority' => 1,
2287 + 'fields' => apply_filters( 'betterdocs_settings_content_restriction_fields', array(
2288 + 'enable_content_restriction' => array(
2289 + 'name' => 'enable_content_restriction',
2290 + 'type' => 'toggle',
2291 + 'is_pro' => true,
2292 + 'priority' => 5,
2293 + 'label' => __( 'Internal Knowledge Base', 'betterdocs' ),
2294 + 'enable_disable_text_active' => true,
2295 + 'default' => array( 'all' )
2296 + ),
2297 + 'internal_knowledge_base_type' => array(
2298 + 'name' => 'internal_knowledge_base_type',
2299 + 'type' => 'radio-card',
2300 + 'label' => __( 'Choose a Rule Type', 'betterdocs' ),
2301 + 'label_subtitle' => __( 'Choose a rule type: apply access globally (Basic), or configure detailed restrictions (Advanced) for docs, categories, and KBs.', 'betterdocs' ),
2302 + 'priority' => 6,
2303 + 'multiple' => true,
2304 + 'search' => true,
2305 + 'default' => array( 'all' ),
2306 + 'placeholder' => __( 'Select any', 'betterdocs' ),
2307 + 'options' => array(
2308 + array(
2309 + 'label' => 'Basic',
2310 + 'value' => 'basic'
2311 + ),
2312 + array(
2313 + 'label' => 'Advanced',
2314 + 'value' => 'advanced'
2315 + )
2316 + ),
2317 + 'filterValue' => 'all',
2318 + 'rules' => Rules::is( 'enable_content_restriction', true )
2319 + ),
2320 + 'content_visibility' => array(
2321 + 'name' => 'content_visibility',
2322 + 'type' => 'checkbox-select',
2323 + 'label' => __( 'Restrict Access to', 'betterdocs' ),
2324 + 'label_subtitle' => __( 'Only selected User Roles will be able to view your Knowledge Base', 'betterdocs' ),
2325 + 'is_pro' => true,
2326 + 'priority' => 7,
2327 + 'multiple' => true,
2328 + 'search' => true,
2329 + 'default' => array( 'all' ),
2330 + 'placeholder' => __( 'Select any', 'betterdocs' ),
2331 + 'options' => $roles_for_ikb,
2332 + 'rules' => Rules::logicalRule(
2333 + array(
2334 + Rules::is( 'enable_content_restriction', true ),
2335 + Rules::is( 'internal_knowledge_base_type', 'basic' )
2336 + ),
2337 + 'and'
2338 + ),
2339 + 'filterValue' => 'all'
2340 + ),
2341 + 'restrict_template' => array(
2342 + 'name' => 'restrict_template',
2343 + 'type' => 'checkbox-select',
2344 + 'label' => __( 'Restriction on Docs', 'betterdocs' ),
2345 + 'label_subtitle' => __( 'Selected Docs pages will be restricted', 'betterdocs' ),
2346 + 'is_pro' => true,
2347 + 'priority' => 8,
2348 + 'multiple' => true,
2349 + 'search' => true,
2350 + 'default' => array( 'all' ),
2351 + 'placeholder' => __( 'Select any', 'betterdocs' ),
2352 + 'options' => $this->get_texanomy(),
2353 + 'rules' => Rules::logicalRule(
2354 + array(
2355 + Rules::is( 'enable_content_restriction', true ),
2356 + Rules::is( 'internal_knowledge_base_type', 'basic' )
2357 + ),
2358 + 'and'
2359 + ),
2360 + 'filterValue' => 'all'
2361 + ),
2362 + 'restrict_category' => array(
2363 + 'name' => 'restrict_category',
2364 + 'type' => 'checkbox-select',
2365 + 'label' => __( 'Restriction on Docs Categories', 'betterdocs' ),
2366 + 'label_subtitle' => __( 'Selected Docs categories will be restricted', 'betterdocs' ),
2367 + 'is_pro' => true,
2368 + 'priority' => 9,
2369 + 'multiple' => true,
2370 + 'search' => true,
2371 + 'default' => array( 'all' ),
2372 + 'placeholder' => __( 'Select any', 'betterdocs' ),
2373 + 'options' => $this->get_terms( 'doc_category' ),
2374 + 'rules' => Rules::logicalRule(
2375 + array(
2376 + Rules::is( 'enable_content_restriction', true ),
2377 + Rules::is( 'internal_knowledge_base_type', 'basic' )
2378 + ),
2379 + 'and'
2380 + ),
2381 + 'filterValue' => 'all'
2382 + ),
2383 + 'restricted_redirect_url' => array(
2384 + 'name' => 'restricted_redirect_url',
2385 + 'type' => 'text',
2386 + 'label' => __( 'Redirect URL', 'betterdocs' ),
2387 + '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' ),
2388 + 'default' => '',
2389 + 'placeholder' => 'https://',
2390 + 'is_pro' => true,
2391 + 'priority' => 20,
2392 + 'rules' => Rules::logicalRule(
2393 + array(
2394 + Rules::is( 'enable_content_restriction', true )
2395 + ),
2396 + 'and'
2397 + )
2398 + )
2399 + ) )
2400 + )
2401 + )
2402 + )
2403 + )
2404 + )
2405 + )
2406 + ) ),
2407 + 'tab-email-reporting' => apply_filters( 'betterdocs_settings_tab_email_reporting', array(
2408 + 'id' => 'tab-email-reporting',
2409 + 'label' => __( 'Email Reporting', 'betterdocs' ),
2410 + 'priority' => 60,
2411 + 'fields' => array(
2412 + 'title-email-reporting' => array(
2413 + 'name' => 'title-email-reporting-tab',
2414 + 'type' => 'section',
2415 + 'label' => __( 'Email Reporting', 'betterdocs' ),
2416 + 'priority' => 60,
2417 + 'fields' => array(
2418 + 'enable_reporting' => array(
2419 + 'name' => 'enable_reporting',
2420 + 'label' => __( 'Email Reporting', 'betterdocs' ),
2421 + 'enable_disable_text_active' => true,
2422 + 'type' => 'toggle',
2423 + 'priority' => 1,
2424 + 'default' => 0
2425 + ),
2426 + 'reporting_frequency' => apply_filters( 'betterdocs_reporting_frequency_settings', array(
2427 + 'name' => 'reporting_frequency',
2428 + 'type' => 'select',
2429 + 'label' => __( 'Reporting Frequency', 'betterdocs' ),
2430 + 'default' => 'betterdocs_weekly',
2431 + 'priority' => 2,
2432 + 'is_pro' => true,
2433 + 'options' => $this->normalize_options( array(
2434 + 'betterdocs_daily' => __( 'Once Daily', 'betterdocs' ),
2435 + 'betterdocs_weekly' => __( 'Once Weekly', 'betterdocs' ),
2436 + 'betterdocs_monthly' => __( 'Once Monthly', 'betterdocs' )
2437 + ) ),
2438 + 'rules' => Rules::is( 'enable_reporting', true )
2439 + ) ),
2440 + 'reporting_day' => array(
2441 + 'name' => 'reporting_day',
2442 + 'type' => 'select',
2443 + 'label' => __( 'Reporting Day', 'betterdocs' ),
2444 + 'default' => 'monday',
2445 + 'rules' => Rules::logicalRule( array(
2446 + Rules::is( 'enable_reporting', true ),
2447 + Rules::is( 'reporting_frequency', 'betterdocs_weekly' )
2448 + ), 'and' ),
2449 + 'priority' => 3,
2450 + 'options' => $this->normalize_options( array(
2451 + 'sunday' => __( 'Sunday', 'betterdocs' ),
2452 + 'monday' => __( 'Monday', 'betterdocs' ),
2453 + 'tuesday' => __( 'Tuesday', 'betterdocs' ),
2454 + 'wednesday' => __( 'Wednesday', 'betterdocs' ),
2455 + 'thursday' => __( 'Thursday', 'betterdocs' ),
2456 + 'friday' => __( 'Friday', 'betterdocs' ),
2457 + 'saturday' => __( 'Saturday', 'betterdocs' )
2458 + ) ),
2459 + 'label_subtitle' => __( 'This is only applicable for the “Weekly” report', 'betterdocs' )
2460 + ),
2461 + 'select_reporting_data' => apply_filters( 'betterdocs_select_reporting_data_settings', array(
2462 + 'name' => 'select_reporting_data',
2463 + 'type' => 'checkbox-select',
2464 + 'label' => __( 'Select Reporting Data', 'betterdocs' ),
2465 + 'priority' => 4,
2466 + 'multiple' => true,
2467 + 'options' => $this->normalize_options( array(
2468 + 'overview' => 'Overview',
2469 + 'top-docs' => 'Top Docs',
2470 + 'most-search' => 'Most Searched Keywords'
2471 + ) ),
2472 + 'default' => array( 'overview', 'top-docs', 'most-search' ),
2473 + 'is_pro' => true,
2474 + 'rules' => Rules::is( 'enable_reporting', true )
2475 + ) ),
2476 + 'reporting_email' => array(
2477 + 'name' => 'reporting_email',
2478 + 'type' => 'text',
2479 + 'label' => __( 'Reporting Email', 'betterdocs' ),
2480 + 'default' => get_option( 'admin_email' ),
2481 + 'priority' => 5,
2482 + 'rules' => Rules::is( 'enable_reporting', true )
2483 + ),
2484 + 'reporting_subject' => apply_filters( 'betterdocs_reporting_subject_settings', array(
2485 + 'name' => 'reporting_subject',
2486 + 'type' => 'textarea',
2487 + 'label' => __( 'Reporting Email Subject', 'betterdocs' ),
2488 + 'default' => wp_sprintf( // Translators: %s is replaced with the website name.
2489 + __( 'Your Documentation Performance of %s Website', 'betterdocs' ), get_bloginfo( 'name' ) ),
2490 + 'priority' => 6,
2491 + 'is_pro' => true,
2492 + 'rules' => Rules::is( 'enable_reporting', true )
2493 + ) ),
2494 + 'test_report' => array(
2495 + 'name' => 'test_report',
2496 + 'label' => __( 'Reporting Test', 'betterdocs' ),
2497 + 'text' => __( 'Test Report', 'betterdocs' ),
2498 + 'type' => 'button',
2499 + 'priority' => 7,
2500 + 'rules' => Rules::is( 'enable_reporting', true ),
2501 + 'ajax' => array(
2502 + 'on' => 'click',
2503 + 'api' => '/betterdocs/v1/reporting-test',
2504 + 'data' => array(
2505 + 'enable_reporting' => '@enable_reporting',
2506 + 'select_reporting_data' => '@select_reporting_data',
2507 + 'reporting_subject' => '@reporting_subject',
2508 + 'reporting_email' => '@reporting_email',
2509 + 'reporting_day' => '@reporting_day',
2510 + 'reporting_frequency' => '@reporting_frequency'
2511 + ),
2512 + 'swal' => array(
2513 + 'text' => __( 'Successfully Sent a Test Report in Your Email.', 'betterdocs' ),
2514 + 'icon' => 'success',
2515 + 'autoClose' => 2000
2516 + )
2517 + )
2518 + )
2519 + )
2520 + )
2521 + )
2522 + ) ),
2523 + 'tab-git-sync' => apply_filters( 'betterdocs_settings_tab_github_integration', array(
2524 + 'id' => 'tab-git-sync',
2525 + 'label' => __( 'Git Sync', 'betterdocs' ),
2526 + 'priority' => 60,
2527 + 'fields' => array(
2528 + 'title-git-sync' => array(
2529 + 'name' => 'title-git-sync-tab',
2530 + 'type' => 'section',
2531 + 'label' => __( 'Git Sync Settings', 'betterdocs' ),
2532 + 'priority' => 60,
2533 + 'fields' => array(
2534 + 'enable_git_integration' => array(
2535 + 'name' => 'enable_git_integration',
2536 + 'type' => 'toggle',
2537 + 'label' => __( 'Enable Git Sync', 'betterdocs' ),
2538 + 'enable_disable_text_active' => true,
2539 + 'default' => false,
2540 + 'priority' => 1,
2541 + 'is_pro' => true,
2542 + 'label_subtitle' => __( 'Enable bidirectional synchronization between BetterDocs and Git repositories', 'betterdocs' )
2543 + )
2544 + )
2545 + )
2546 + )
2547 + ) ),
2548 + 'tab-instant-answer' => apply_filters( 'betterdocs_settings_tab_instant_answer', array(
2549 + 'id' => 'tab-instant-answer',
2550 + 'name' => 'tab-instant-answer',
2551 + 'type' => 'section',
2552 + 'label' => __( 'Instant Answer', 'betterdocs' ),
2553 + 'save' => false,
2554 + 'priority' => 70,
2555 + 'fields' => array(
2556 + 'title-instant-answer' => array(
2557 + 'name' => 'title-instant-answer-tab',
2558 + 'type' => 'section',
2559 + 'label' => __( 'Instant Answer', 'betterdocs' ),
2560 + 'priority' => 80,
2561 + 'save' => false,
2562 + 'showSubmit' => false,
2563 + 'fields' => apply_filters( 'betterdocs_instant_answer_fields', array(
2564 + 'enable_disable_wrapper' => array(
2565 + 'name' => 'enable_disable_wrapper',
2566 + 'type' => 'section',
2567 + 'priority' => 0,
2568 + 'save' => false,
2569 + 'fields' => array(
2570 + 'enable_disable' => array(
2571 + 'name' => 'enable_disable',
2572 + 'type' => 'toggle',
2573 + 'priority' => 100,
2574 + 'description' => __( 'Enable Instant Answer', 'betterdocs' ),
2575 + 'enable_disable_text_active' => false,
2576 + 'default' => false,
2577 + 'is_pro' => true
2578 + )
2579 + )
2580 + )
2581 + ) )
2582 + )
2583 + )
2584 + ) ),
2585 + 'tab-betterdocs-ai' => array(
2586 + 'id' => 'tab-betterdocs-ai',
2587 + 'name' => 'tab-betterdocs-ai',
2588 + 'type' => 'section',
2589 + 'label' => __( 'AI Content Suite', 'betterdocs' ),
2590 + 'priority' => 74,
2591 + 'fields' => array(
2592 + 'sections-betterdocs-ai' => array(
2593 + 'name' => 'sections-betterdocs-ai',
2594 + 'type' => 'section',
2595 + 'label' => __( 'AI Content Suite', 'betterdocs' ),
2596 + 'priority' => 10,
2597 + 'fields' => array(
2598 + 'all-betterdocs-ai' => array(
2599 + 'id' => 'all-tab-betterdocs-ai',
2600 + 'name' => 'all-tab-betterdocs-ai',
2601 + 'label' => __( 'AI Content Suite Settings', 'betterdocs' ),
2602 + 'classes' => 'tab-layout',
2603 + 'type' => 'tab',
2604 + 'active' => 'open-ai-settings',
2605 + 'completionTrack' => true,
2606 + 'sidebar' => false,
2607 + 'save' => false,
2608 + 'title' => false,
2609 + 'config' => array(
2610 + 'active' => 'open-ai-settings',
2611 + 'sidebar' => false,
2612 + 'title' => false
2613 + ),
2614 + 'submit' => array(
2615 + 'show' => false
2616 + ),
2617 + 'step' => array(
2618 + 'show' => false
2619 + ),
2620 + 'priority' => 20,
2621 + 'fields' => apply_filters(
2622 + 'betterdocs_migration_tab_sections',
2623 + array(
2624 + 'open-ai-settings' => array(
2625 + 'id' => 'open-ai-settings',
2626 + 'name' => 'open-ai-settings',
2627 + 'type' => 'section',
2628 + 'label' => __( 'AI Platform & API', 'betterdocs' ),
2629 + 'priority' => 1,
2630 + 'fields' => array(
2631 + 'ai_platform' => array(
2632 + 'name' => 'ai_platform',
2633 + 'type' => 'select',
2634 + 'label' => __( 'AI Platform', 'betterdocs' ),
2635 + 'label_subtitle' => __( 'Choose which AI platform powers Write with AI, AI Edit, the Doc Summarizer and Quality Score. The model list and API key field below adapt to your choice.', 'betterdocs' ),
2636 + 'priority' => 1,
2637 + 'multiple' => false,
2638 + 'default' => 'openai',
2639 + // DeepSeek and OpenRouter are temporarily hidden from the
2640 + // dropdown. Filter the options here, NOT ModelRegistry::platforms() —
2641 + // sensitive_api_key_fields() loops the registry to mask each
2642 + // platform's key field, so trimming the registry would silently
2643 + // un-mask those keys. Re-enable later by dropping the array_diff_key.
2644 + 'options' => GlobalFields::normalize_fields(
2645 + array_diff_key( ModelRegistry::platforms(), array_flip( array( 'deepseek', 'openrouter' ) ) )
2646 + )
2647 + ),
2648 + // OpenAI's key field keeps its original name so installs
2649 + // that already saved a Write with AI key keep it.
2650 + 'ai_autowrite_api_key' => array(
2651 + 'name' => 'ai_autowrite_api_key',
2652 + 'type' => 'text',
2653 + 'label' => __( 'OpenAI API Key', 'betterdocs' ),
2654 + 'label_subtitle' => sprintf( /* translators: %s: documentation URL */ __( 'Check out this <a target="_blank" href="%s">documentation</a> to generate your OpenAI API key.', 'betterdocs' ), esc_url( 'https://betterdocs.co/docs/write-with-ai/' ) ),
2655 + 'default' => '',
2656 + 'priority' => 2,
2657 + 'rules' => Rules::is( 'ai_platform', 'openai' )
2658 + ),
2659 + 'ai_api_key_gemini' => array(
2660 + 'name' => 'ai_api_key_gemini',
2661 + 'type' => 'text',
2662 + 'label' => __( 'Google Gemini API Key', 'betterdocs' ),
2663 + 'label_subtitle' => sprintf( /* translators: %s: Google AI Studio URL */ __( 'Generate a key from <a target="_blank" href="%s">Google AI Studio</a>.', 'betterdocs' ), esc_url( 'https://aistudio.google.com/app/apikey' ) ),
2664 + 'default' => '',
2665 + 'priority' => 2,
2666 + 'rules' => Rules::is( 'ai_platform', 'gemini' )
2667 + ),
2668 + 'ai_api_key_claude' => array(
2669 + 'name' => 'ai_api_key_claude',
2670 + 'type' => 'text',
2671 + 'label' => __( 'Anthropic Claude API Key', 'betterdocs' ),
2672 + 'label_subtitle' => sprintf( /* translators: %s: Anthropic Console URL */ __( 'Generate a key from the <a target="_blank" href="%s">Anthropic Console</a>.', 'betterdocs' ), esc_url( 'https://console.anthropic.com/settings/keys' ) ),
2673 + 'default' => '',
2674 + 'priority' => 2,
2675 + 'rules' => Rules::is( 'ai_platform', 'claude' )
2676 + ),
2677 + 'ai_api_key_deepseek' => array(
2678 + 'name' => 'ai_api_key_deepseek',
2679 + 'type' => 'text',
2680 + 'label' => __( 'DeepSeek API Key', 'betterdocs' ),
2681 + 'label_subtitle' => sprintf( /* translators: %s: DeepSeek platform URL */ __( 'Generate a key from the <a target="_blank" href="%s">DeepSeek platform</a>.', 'betterdocs' ), esc_url( 'https://platform.deepseek.com/api_keys' ) ),
2682 + 'default' => '',
2683 + 'priority' => 2,
2684 + 'rules' => Rules::is( 'ai_platform', 'deepseek' )
2685 + ),
2686 + 'ai_api_key_openrouter' => array(
2687 + 'name' => 'ai_api_key_openrouter',
2688 + 'type' => 'text',
2689 + 'label' => __( 'OpenRouter API Key', 'betterdocs' ),
2690 + 'label_subtitle' => sprintf( /* translators: %s: OpenRouter keys URL */ __( 'Generate a key from <a target="_blank" href="%s">OpenRouter</a>.', 'betterdocs' ), esc_url( 'https://openrouter.ai/keys' ) ),
2691 + 'default' => '',
2692 + 'priority' => 2,
2693 + 'rules' => Rules::is( 'ai_platform', 'openrouter' )
2694 + ),
2695 + 'ai_model' => array(
2696 + 'name' => 'ai_model',
2697 + 'type' => 'platform_model_select',
2698 + 'label' => __( 'Model', 'betterdocs' ),
2699 + 'label_subtitle' => __( 'Available models depend on the selected platform.', 'betterdocs' ),
2700 + 'priority' => 10,
2701 + 'default' => 'gpt-4o-mini',
2702 + 'catalogue' => ModelRegistry::catalogue(),
2703 + 'defaults' => ModelRegistry::defaults()
2704 + )
2705 + )
2706 + ),
2707 + 'write-with-ai' => array(
2708 + 'id' => 'write-with-ai',
2709 + 'name' => 'write-with-ai',
2710 + 'type' => 'section',
2711 + 'label' => __( 'Write with AI', 'betterdocs' ),
2712 + 'priority' => 5,
2713 + 'fields' => array(
2714 + 'write-with-ai-subtabs' => array(
2715 + 'id' => 'write-with-ai-subtabs',
2716 + 'name' => 'write_with_ai_subtabs',
2717 + 'label' => __( 'Write with AI', 'betterdocs' ),
2718 + 'classes' => 'tab-nested-layout',
2719 + 'type' => 'tab',
2720 + 'active' => 'wwa-configuration',
2721 + 'completionTrack' => true,
2722 + 'sidebar' => false,
2723 + 'save' => false,
2724 + 'title' => false,
2725 + 'config' => array(
2726 + 'active' => 'wwa-configuration',
2727 + 'sidebar' => false,
2728 + 'title' => false
2729 + ),
2730 + 'submit' => array(
2731 + 'show' => false
2732 + ),
2733 + 'step' => array(
2734 + 'show' => false
2735 + ),
2736 + 'priority' => 5,
2737 + 'fields' => array(
2738 + 'wwa-configuration' => array(
2739 + 'id' => 'wwa-configuration',
2740 + 'name' => 'wwa-configuration',
2741 + 'type' => 'section',
2742 + 'label' => __( 'Configuration', 'betterdocs' ),
2743 + 'priority' => 1,
2744 + 'fields' => array(
2745 + 'enable_write_with_ai' => array(
2746 + 'name' => 'enable_write_with_ai',
2747 + 'type' => 'toggle',
2748 + 'priority' => 0,
2749 + 'label' => __( 'Write Docs with AI', 'betterdocs' ),
2750 + 'label_subtitle' => __( 'Generate AI based Documentation in your Gutenberg Editor', 'betterdocs' ),
2751 + 'enable_disable_text_active' => true,
2752 + 'default' => true
2753 + ),
2754 + 'enable_faq_write_with_ai' => array(
2755 + 'name' => 'enable_faq_write_with_ai',
2756 + 'type' => 'toggle',
2757 + 'priority' => 5,
2758 + 'label' => __( 'Write FAQ with AI', 'betterdocs' ),
2759 + 'label_subtitle' => __( 'Generate AI based FAQ in your Editor', 'betterdocs' ),
2760 + 'enable_disable_text_active' => true,
2761 + 'default' => true
2762 + ),
2763 + 'enable_glossaries_write_with_ai' => array(
2764 + 'name' => 'enable_glossaries_write_with_ai',
2765 + 'type' => 'toggle',
2766 + 'priority' => 6,
2767 + 'label' => __( 'Write Glossaries with AI', 'betterdocs' ),
2768 + 'label_subtitle' => __( 'Generate AI based Glossary definitions from the Glossaries admin page', 'betterdocs' ),
2769 + 'enable_disable_text_active' => true,
2770 + 'default' => true,
2771 + 'is_pro' => true
2772 + ),
2773 + 'enable_docs_ai_suite' => array(
2774 + 'name' => 'enable_docs_ai_suite',
2775 + 'type' => 'toggle',
2776 + 'priority' => 7,
2777 + 'label' => __( 'Enhance Docs with AI', 'betterdocs' ),
2778 + 'label_subtitle' => __( 'Add BetterDocs AI actions for suggesting categories, tags and excerpts inside the native Docs editor panels.', 'betterdocs' ),
2779 + 'enable_disable_text_active' => true,
2780 + 'default' => true
2781 + ),
2782 + 'ai_autowrite_max_token' => array(
2783 + 'name' => 'ai_autowrite_max_token',
2784 + 'type' => 'min_token_number',
2785 + 'label' => __( 'Set Max Tokens', 'betterdocs' ),
2786 + 'label_subtitle' => sprintf( // translators: %s is a link to more information about token limits.
2787 + __( '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' ) ),
2788 + 'default' => 2500,
2789 + 'priority' => 10,
2790 + 'model_field' => 'ai_model',
2791 + 'context' => 'write_with_ai',
2792 + 'min_token_map' => AIHelper::get_min_tokens_map( 'write_with_ai' ),
2793 + 'classes' => 'wprf-type-text'
2794 + )
2795 + )
2796 + ),
2797 + 'wwa-personalize' => array(
2798 + 'id' => 'wwa-personalize',
2799 + 'name' => 'wwa-personalize',
2800 + 'type' => 'section',
2801 + 'label' => __( 'Write AI Personalize', 'betterdocs' ),
2802 + 'priority' => 5,
2803 + 'fields' => array(
2804 + 'write_with_ai_instructions' => array(
2805 + 'name' => 'write_with_ai_instructions',
2806 + 'type' => 'wwa_instructions',
2807 + 'label' => __( 'Instructions', 'betterdocs' ),
2808 + 'label_subtitle' => __( 'Add reusable instruction sets to steer how BetterDocs AI writes. The "Default/Core" set is always applied; extra sets can be picked in the Write with AI popup.', 'betterdocs' ),
2809 + 'priority' => 1,
2810 + 'default' => array(
2811 + array(
2812 + 'id' => 'default',
2813 + 'title' => __( 'Default/Core', 'betterdocs' ),
2814 + 'content' => WriteWithAI::default_instruction_content()
2815 + )
2816 + )
2817 + )
2818 + )
2819 + ),
2820 + 'edit-ai-personalize' => array(
2821 + 'id' => 'edit-ai-personalize',
2822 + 'name' => 'edit-ai-personalize',
2823 + 'type' => 'section',
2824 + 'label' => __( 'Edit AI Personalize', 'betterdocs' ),
2825 + 'priority' => 7,
2826 + 'fields' => array(
2827 + 'ai_edit_actions' => array(
2828 + 'name' => 'ai_edit_actions',
2829 + 'type' => 'ai_edit_actions',
2830 + 'label' => __( 'Actions', 'betterdocs' ),
2831 + 'label_subtitle' => __( 'Choose which Edit with AI actions appear in the editor. Toggle actions on or off, edit each action\'s instruction, or add your own custom actions. All predefined actions are enabled by default.', 'betterdocs' ),
2832 + 'priority' => 1,
2833 + 'default' => AIEdit::default_actions()
2834 + )
2835 + )
2836 + )
2837 + )
2838 + )
2839 + )
2840 + ),
2841 + 'article-summary' => array(
2842 + 'id' => 'article-summary',
2843 + 'name' => 'article-summary',
2844 + 'type' => 'section',
2845 + 'label' => __( 'AI Doc Summarizer', 'betterdocs' ),
2846 + 'priority' => 10,
2847 + 'fields' => array(
2848 + 'enable_article_summary' => array(
2849 + 'name' => 'enable_article_summary',
2850 + 'type' => 'toggle',
2851 + 'priority' => 1,
2852 + 'label' => __( 'AI Powered Doc Summarizer', 'betterdocs' ),
2853 + 'label_subtitle' => __( 'Enable AI-powered article summaries on single doc pages. Requires OpenAI API key.', 'betterdocs' ),
2854 + 'enable_disable_text_active' => true,
2855 + 'default' => false
2856 + ),
2857 + 'article_summary_max_token' => array(
2858 + 'name' => 'article_summary_max_token',
2859 + 'type' => 'min_token_number',
2860 + 'label' => __( 'Set Max Tokens', 'betterdocs' ),
2861 + 'label_subtitle' => sprintf( // translators: %s is a link to more information about token limits.
2862 + __( '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' ) ),
2863 + 'default' => 1500,
2864 + 'priority' => 5,
2865 + 'model_field' => 'ai_model',
2866 + 'context' => 'article_summary',
2867 + 'min_token_map' => AIHelper::get_min_tokens_map( 'article_summary' ),
2868 + 'classes' => 'wprf-type-text'
2869 + )
2870 + )
2871 + )
2872 + )
2873 + )
2874 + )
2875 + )
2876 + )
2877 + )
2878 + ),
2879 + 'tab-ai-chatbot' => apply_filters( 'betterdocs_settings_tab_ai_chatbot', array(
2880 + 'id' => 'tab-ai-chatbot',
2881 + 'name' => 'tab-ai-chatbot',
2882 + 'type' => 'section',
2883 + 'label' => __( 'AI Chatbot', 'betterdocs' ),
2884 + 'submit' => array(
2885 + 'show' => false
2886 + ),
2887 + 'save' => false,
2888 + 'priority' => 75,
2889 + 'fields' => array(
2890 + 'title-ai-chatbot-tab' => array(
2891 + 'name' => 'title-ai-chatbot-tab',
2892 + 'type' => 'section',
2893 + 'label' => __( 'AI Chatbot', 'betterdocs' ),
2894 + 'priority' => 80,
2895 + 'submit' => array(
2896 + 'show' => false
2897 + ),
2898 + 'save' => false,
2899 + 'fields' => apply_filters( 'betterdocs_ai_chatbot_fields', array(
2900 + 'ai_chatbot_fields' => array(
2901 + 'name' => 'ai_chatbot_fields',
2902 + 'type' => 'section',
2903 + 'priority' => 0,
2904 + 'fields' => array(
2905 + 'enable_ai_chatbot' => array(
2906 + 'name' => 'enable_ai_chatbot',
2907 + 'label' => __( 'AI Chatbot', 'betterdocs' ),
2908 + 'description' => __( 'Enable AI Chatbot', 'betterdocs' ),
2909 + 'type' => 'toggle',
2910 + 'priority' => 5,
2911 + 'default' => 0,
2912 + 'is_pro' => true,
2913 + 'is_license_active' => false,
2914 + 'disabled' => ! betterdocs()->is_pro_active() || ! defined( 'BETTERDOCS_CHATBOT_FILE' )
2915 + ),
2916 + 'instant_answer_warning' => array(
2917 + 'name' => 'instant_answer_warning',
2918 + 'type' => 'html',
2919 + 'priority' => 6,
2920 + 'html' => sprintf(
2921 + '<div class="betterdocs-ia-warning" style="margin:8px 0 0;padding:12px 16px;background:#fffaeb;border-left:4px solid #fdb022;border-radius:4px;display:flex;align-items:flex-start;gap:10px;"><span style="font-size:18px;line-height:1;flex-shrink:0;color:#b54708;">&#9888;</span><div style="font-size:13px;color:#202223;line-height:1.5;">%1$s<br><a href="?page=betterdocs-settings&amp;tab=tab-instant-answer" style="display:inline-block;margin-top:6px;color:#5a6bff;text-decoration:none;font-weight:500;">%2$s &rarr;</a></div></div>',
2922 + esc_html__( 'Instant Answer is currently disabled. The AI Chatbot won\'t appear on your site until Instant Answer is enabled.', 'betterdocs' ),
2923 + esc_html__( 'Enable Instant Answer', 'betterdocs' )
2924 + ),
2925 + 'rules' => Rules::logicalRule( array(
2926 + Rules::is( 'enable_ai_chatbot', true ),
2927 + Rules::is( 'enable_disable', false ),
2928 + ), 'and' ),
2929 + )
2930 + )
2931 + )
2932 + ) )
2933 + )
2934 + )
2935 + ) )
2936 + ) ),
2937 + 'TAB_AI_CHATBOT' => get_option( 'enable_ai_chatbot' ),
2938 + 'CHATBOT_LICENSE' => get_option( 'betterdocs_chatbot_software__license_status' ),
2939 + 'PRO_ACTIVE' => is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' ),
2940 + 'PRO_LICENSE' => get_option( 'betterdocs_pro_software__license_status' )
2941 + );
2738 2942
2739 - public function maybe_remove_git_tab( $tabs ) {
2740 - $pro_active = is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' );
2741 - $pro_has_git = apply_filters( 'betterdocs_pro_has_git_integration', false );
2943 + $settings = array_merge( $settings, $this->chatbot_active_localize() );
2742 2944
2743 - if ( $pro_active && ! $pro_has_git ) {
2744 - unset( $tabs['tab-github-integration'] );
2745 - }
2945 + return apply_filters( 'betterdocs_settings_args', $settings );
2946 + }
2746 2947
2747 - return $tabs;
2748 - }
2948 + /**
2949 + * @return array
2950 + */
2951 + public function chatbot_active_localize() {
2952 + $chatbot_active = is_plugin_active( 'betterdocs-ai-chatbot/betterdocs-ai-chatbot.php' );
2953 + $chatbot_license_valid = get_option( 'betterdocs_chatbot_software__license_status' ) === 'valid';
2954 + $chatbot_enabled = $this->get( 'enable_ai_chatbot', false );
2749 2955
2750 - public function normalize_options( $options ) {
2751 - return GlobalFields::normalize_fields( $options );
2752 - }
2956 + // AI Search Suggestions are enabled if all conditions are met
2957 + $ai_search_suggestions_enabled = betterdocs()->helper->is_ai_chatbot_enabled();
2753 2958
2754 - public function get_texanomy() {
2755 - $docs_tax = $this->database->get_cache( 'betterdocs::settings::taxonomies' );
2959 + return array(
2960 + 'CHATBOT_ACTIVE' => $chatbot_active,
2961 + 'CHATBOT_LICENSE_VALID' => $chatbot_license_valid,
2962 + 'CHATBOT_ENABLED' => $chatbot_enabled,
2963 + 'AI_SEARCH_SUGGESTIONS_ENABLED' => $ai_search_suggestions_enabled
2964 + );
2965 + }
2756 2966
2757 - if ( $docs_tax ) {
2758 - return $docs_tax;
2759 - }
2967 + /**
2968 + * Call This Function As Helper, When Pro Is Deactivated, To Be Used As Settings Default Values, When Betterdocs Pro Is Deactivated
2969 + *
2970 + * @return array
2971 + */
2972 + public function pro_settings_default_values() {
2973 + return array(
2974 + 'multiple_kb' => false,
2975 + 'enable_glossaries' => false,
2976 + 'enable_encyclopedia' => false,
2977 + 'show_attachment' => false,
2978 + 'show_related_docs' => false,
2979 + 'advance_search' => false,
2980 + 'kb_based_search' => false,
2981 + 'enable_disable' => false,
2982 + 'enable_content_restriction' => false
2983 + );
2984 + }
2760 2985
2761 - $taxonomies = get_taxonomies( [
2762 - 'object_type' => [ 'docs' ]
2763 - ], 'objects' );
2986 + public function import_export_settings( $settings ) {
2987 + if ( ! current_user_can( 'import' ) ) {
2988 + return $settings;
2989 + }
2764 2990
2765 - $docs_tax = [
2766 - 'all' => 'All Docs Archive',
2767 - 'docs' => 'Docs Page'
2768 - ];
2769 - foreach ( $taxonomies as $key => $value ) {
2770 - $docs_tax[ $key ] = $value->label;
2771 - }
2772 - unset( $docs_tax['doc_tag'] );
2991 + $settings[ 'tab-import-export' ] = apply_filters( 'betterdocs_settings_tab_import_export', array(
2992 + 'id' => 'tab-import-export',
2993 + 'name' => 'tab-import-export',
2994 + 'classes' => 'tab-import-export',
2995 + 'label' => __( 'Import / Export', 'betterdocs' ),
2996 + 'priority' => 80,
2997 + 'fields' => array(
2998 + 'sections-import-export' => array(
2999 + 'name' => 'sections-import-export',
3000 + 'type' => 'section',
3001 + 'label' => __( 'Import / Export', 'betterdocs' ),
3002 + 'priority' => 30,
3003 + 'fields' => array(
3004 + 'all-tab-import-export' => array(
3005 + 'id' => 'all-tab-import-export',
3006 + 'name' => 'all-tab-import-export',
3007 + 'label' => __( 'Import Export Settings', 'betterdocs' ),
3008 + 'classes' => 'tab-layout',
3009 + 'type' => 'tab',
3010 + 'active' => 'import',
3011 + 'completionTrack' => true,
3012 + 'sidebar' => false,
3013 + 'save' => false,
3014 + 'title' => false,
3015 + 'config' => array(
3016 + 'active' => 'import',
3017 + 'sidebar' => false,
3018 + 'title' => false
3019 + ),
3020 + 'submit' => array(
3021 + 'show' => false
3022 + ),
3023 + 'step' => array(
3024 + 'show' => false
3025 + ),
3026 + 'priority' => 20,
3027 + 'fields' => array(
3028 + 'import' => array(
3029 + 'id' => 'import',
3030 + 'name' => 'import',
3031 + 'type' => 'section',
3032 + 'label' => __( 'Import', 'betterdocs' ),
3033 + 'priority' => 1,
3034 + 'fields' => array(
3035 + 'import_tab_nested' => array(
3036 + 'id' => 'import_tab_nested',
3037 + 'name' => 'import_tab_nested',
3038 + 'label' => __( 'Import', 'betterdocs' ),
3039 + 'classes' => 'tab-nested-layout',
3040 + 'type' => 'tab',
3041 + 'active' => 'import_docs_nested',
3042 + 'completionTrack' => true,
3043 + 'sidebar' => false,
3044 + 'save' => false,
3045 + 'title' => false,
3046 + 'config' => array(
3047 + 'active' => 'import_docs_nested',
3048 + 'sidebar' => false,
3049 + 'title' => false
3050 + ),
3051 + 'submit' => array(
3052 + 'show' => false
3053 + ),
3054 + 'step' => array(
3055 + 'show' => false
3056 + ),
3057 + 'priority' => 1,
3058 + 'fields' => array(
3059 + 'import_docs_nested' => array(
3060 + 'id' => 'import_docs_nested',
3061 + 'name' => 'import_docs_nested',
3062 + 'type' => 'section',
3063 + 'label' => __( 'Import Docs', 'betterdocs' ),
3064 + 'priority' => 1,
3065 + 'fields' => array(
3066 + 'import_docs' => array(
3067 + 'name' => 'import_docs',
3068 + 'type' => 'importerupload',
3069 + 'label' => __( 'Import Docs', 'betterdocs' ),
3070 + 'label_subtitle' => wp_sprintf( // Translators: %1$s is a link to download a sample CSV file.
3071 + __( '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 ) ),
3072 + 'text' => array(
3073 + 'normal' => __( 'Proceed', 'betterdocs' ),
3074 + 'saved' => __( 'Proceed', 'betterdocs' ),
3075 + 'loading' => __( 'Importing...', 'betterdocs' ),
3076 + 'exists_notice' => __( 'It seems like documentations with same slugs already exist on your website. What would you like to do?', 'betterdocs' )
3077 + ),
3078 + 'ajax' => array(
3079 + 'on' => 'click',
3080 + 'api' => '/betterdocs/v1/import-docs',
3081 + 'swal' => array(
3082 + 'text' => __( 'Import completed successfully.', 'betterdocs' ),
3083 + 'icon' => 'success',
3084 + 'autoClose' => 2000
3085 + )
3086 + ),
3087 + 'file_type' => '.xml, .csv',
3088 + 'priority' => 1
3089 + )
3090 + )
3091 + ),
2773 3092
2774 - $docs_tax = $this->normalize_options( $docs_tax );
2775 - if ( count( $docs_tax ) > 2 ) {
2776 - $this->database->set_cache( 'betterdocs::settings::taxonomies', $docs_tax );
2777 - }
3093 + 'import_settings_nested' => array(
3094 + 'id' => 'import_settings_nested',
3095 + 'name' => 'import_settings_nested',
3096 + 'type' => 'section',
3097 + 'label' => __( 'Import Settings', 'betterdocs' ),
3098 + 'priority' => 1,
3099 + 'fields' => array(
3100 + 'settings_importer' => array(
3101 + 'name' => 'settings_importer',
3102 + 'type' => 'settingsuploader',
3103 + 'label' => __( 'Import Settings', 'betterdocs' ),
3104 + 'label_subtitle' => __( 'To import BetterDocs Settings, please upload BetterDocs settings you have exported from another website in .json format', 'betterdocs' ),
3105 + 'reset' => __( 'Change', 'betterdocs' ),
3106 + 'priority' => 1
3107 + ),
3108 + 'import_settings' => array(
3109 + 'name' => 'import_settings',
3110 + 'type' => 'button',
3111 + 'rules' => Rules::is( 'settings_importer', null, true ),
3112 + 'text' => array(
3113 + 'normal' => __( 'Proceed', 'betterdocs' ),
3114 + 'saved' => __( 'Proceed', 'betterdocs' ),
3115 + 'loading' => __( 'Importing...', 'betterdocs' )
3116 + ),
3117 + 'ajax' => array(
3118 + 'on' => 'click',
3119 + 'api' => '/betterdocs/v1/import-settings',
3120 + 'data' => array(
3121 + 'settings' => '@settings_importer'
3122 + ),
3123 + 'swal' => array(
3124 + 'text' => __( 'Import completed successfully.', 'betterdocs' ),
3125 + 'icon' => 'success',
3126 + 'autoClose' => 1000
3127 + ),
3128 + 'reload' => true
3129 + ),
3130 + 'priority' => 2
3131 + )
3132 + )
3133 + )
3134 + )
3135 + )
3136 + )
3137 + ),
3138 + 'export' => array(
3139 + 'id' => 'export',
3140 + 'name' => 'export',
3141 + 'type' => 'section',
3142 + 'label' => __( 'Export', 'betterdocs' ),
3143 + 'priority' => 1,
3144 + 'fields' => array(
3145 + 'export_tab_nested' => array(
3146 + 'id' => 'export_tab_nested',
3147 + 'name' => 'export_tab_nested',
3148 + 'label' => __( 'Export', 'betterdocs' ),
3149 + 'classes' => 'tab-nested-layout',
3150 + 'type' => 'tab',
3151 + 'active' => 'export_docs_nested',
3152 + 'completionTrack' => true,
3153 + 'sidebar' => false,
3154 + 'save' => false,
3155 + 'title' => false,
3156 + 'config' => array(
3157 + 'active' => 'export_docs_nested',
3158 + 'sidebar' => false,
3159 + 'title' => false
3160 + ),
3161 + 'submit' => array(
3162 + 'show' => false
3163 + ),
3164 + 'step' => array(
3165 + 'show' => false
3166 + ),
3167 + 'priority' => 1,
3168 + 'fields' => array(
3169 + 'export_docs_nested' => array(
3170 + 'id' => 'export_docs_nested',
3171 + 'name' => 'export_docs_nested',
3172 + 'type' => 'section',
3173 + 'label' => __( 'Export Docs', 'betterdocs' ),
3174 + 'priority' => 1,
3175 + 'fields' => apply_filters( 'betterdocs_export_fields', array(
3176 + 'export_type' => array(
3177 + 'name' => 'export_type',
3178 + 'label' => __( 'Select Docs Type', 'betterdocs' ),
3179 + 'label_subtitle' => __( 'Choose an export type: All Docs, a specific Knowledge Base, or a Doc Category', 'betterdocs' ),
3180 + 'type' => 'select',
3181 + 'default' => 'docs',
3182 + 'priority' => 3,
3183 + 'search' => true,
3184 + 'options' => $this->normalize_options( apply_filters( 'betterdocs_export_type_options', array(
3185 + 'docs' => __( 'Docs', 'betterdocs' ),
3186 + 'doc_category' => __( 'Docs Category', 'betterdocs' ),
3187 + 'glossaries' => __( 'Glossaries', 'betterdocs' )
3188 + ) ) )
3189 + ),
3190 + 'export_docs' => array(
3191 + 'name' => 'export_docs',
3192 + 'type' => 'checkbox-select',
3193 + 'label' => __( 'Select Docs', 'betterdocs' ),
3194 + 'label_subtitle' => __( 'Selected docs will be included in the export.', 'betterdocs' ),
3195 + 'priority' => 4,
3196 + 'multiple' => true,
3197 + 'search' => true,
3198 + 'default' => array( 'all' ),
3199 + 'placeholder' => __( 'Select any', 'betterdocs' ),
3200 + 'options' => array_merge( array(
3201 + array(
3202 + 'value' => 'all',
3203 + 'label' => 'All'
3204 + )
3205 + ), $this->docs() ),
3206 + 'filterValue' => 'all',
3207 + 'rules' => Rules::is( 'export_type', 'docs' )
3208 + ),
3209 + 'export_categories' => array(
3210 + 'name' => 'export_categories',
3211 + 'type' => 'checkbox-select',
3212 + 'label' => __( 'Select Categories', 'betterdocs' ),
3213 + 'label_subtitle' => __( 'Selected categories and its docs will be included in the export.', 'betterdocs' ),
3214 + 'priority' => 6,
3215 + 'multiple' => true,
3216 + 'search' => true,
3217 + 'default' => array( 'all' ),
3218 + 'placeholder' => __( 'Select any', 'betterdocs' ),
3219 + 'options' => $this->get_terms( 'doc_category', false ),
3220 + 'filterValue' => 'all',
3221 + 'rules' => Rules::is( 'export_type', 'doc_category' )
3222 + ),
3223 + 'export_glossaries' => array(
3224 + 'name' => 'export_glossaries',
3225 + 'type' => 'checkbox-select',
3226 + 'label' => __( 'Select Glossaries', 'betterdocs' ),
3227 + 'label_subtitle' => __( 'Selected glossary terms will be exported.', 'betterdocs' ),
3228 + 'priority' => 7,
3229 + 'multiple' => true,
3230 + 'search' => true,
3231 + 'default' => array( 'all' ),
3232 + 'placeholder' => __( 'Select any', 'betterdocs' ),
3233 + 'options' => $this->get_terms( 'glossaries' ),
3234 + 'filterValue' => 'all',
3235 + 'rules' => Rules::is( 'export_type', 'glossaries' )
3236 + ),
3237 + 'file_type' => array(
3238 + 'name' => 'file_type',
3239 + 'label' => __( 'Select File Type', 'betterdocs' ),
3240 + 'label_subtitle' => __( 'Choose a file type', 'betterdocs' ),
3241 + 'type' => 'select',
3242 + 'default' => 'xml',
3243 + 'priority' => 8,
3244 + 'search' => true,
3245 + 'options' => $this->normalize_options( apply_filters( 'betterdocs_export_file_type_options', array(
3246 + 'xml' => __( '.xml', 'betterdocs' ),
3247 + 'csv' => __( '.csv', 'betterdocs' )
3248 + ) ) )
3249 + ),
3250 + 'enable_export_faq' => array(
3251 + 'name' => 'enable_export_faq',
3252 + 'type' => 'toggle',
3253 + 'priority' => 9,
3254 + 'label' => __( 'Export FAQ', 'betterdocs' ),
3255 + 'label_subtitle' => __( 'Export FAQ Related Terms & Posts', 'betterdocs' ),
3256 + 'enable_disable_text_active' => true,
3257 + 'default' => true,
3258 + 'rules' => Rules::is( 'export_type', 'glossaries', true )
3259 + ),
3260 + 'export_docs_btn' => array(
3261 + 'name' => 'export_docs_btn',
3262 + 'text' => array(
3263 + 'normal' => __( 'Proceed', 'betterdocs' ),
3264 + 'saved' => __( 'Proceed', 'betterdocs' ),
3265 + 'loading' => __( 'Exporting...', 'betterdocs' )
3266 + ),
3267 + 'type' => 'button',
3268 + 'priority' => 10,
3269 + 'ajax' => array(
3270 + 'on' => 'click',
3271 + 'api' => '/betterdocs/v1/export-docs',
3272 + 'data' => array(
3273 + 'export_type' => '@export_type',
3274 + 'export_docs' => '@export_docs',
3275 + 'export_kbs' => '@export_kbs',
3276 + 'export_categories' => '@export_categories',
3277 + 'export_glossaries' => '@export_glossaries',
3278 + 'file_type' => '@file_type',
3279 + 'enable_export_faq' => '@enable_export_faq'
3280 + ),
3281 + 'swal' => array(
3282 + 'text' => __( 'Exported Successfully.', 'betterdocs' ),
3283 + 'icon' => 'success',
3284 + 'autoClose' => 2000
3285 + )
3286 + )
3287 + )
3288 + ) )
3289 + ),
2778 3290
2779 - return $docs_tax;
2780 - }
3291 + 'export_settings_nested' => array(
3292 + 'id' => 'export_settings_nested',
3293 + 'name' => 'export_settings_nested',
3294 + 'type' => 'section',
3295 + 'label' => __( 'Export Settings', 'betterdocs' ),
3296 + 'priority' => 1,
3297 + 'fields' => array(
3298 + 'export_settings' => array(
3299 + 'name' => 'export_settings',
3300 + 'label' => __( 'Export Settings', 'betterdocs' ),
3301 + 'label_subtitle' => __( 'Simply click on “Export Settings” button to download your BetterDocs settings in .json format', 'betterdocs' ),
3302 + 'text' => array(
3303 + 'normal' => __( 'Export Settings', 'betterdocs' ),
3304 + 'saved' => __( 'Export Settings', 'betterdocs' ),
3305 + 'loading' => __( 'Exporting...', 'betterdocs' )
3306 + ),
3307 + 'type' => 'button',
3308 + 'priority' => 8,
3309 + 'ajax' => array(
3310 + 'on' => 'click',
3311 + 'api' => '/betterdocs/v1/export-settings',
3312 + 'data' => array(
3313 + 'betterdocs_settings' => get_option( 'betterdocs_settings' )
3314 + ),
3315 + 'swal' => array(
3316 + 'text' => __( 'File downloaded successfully.', 'betterdocs' ),
3317 + 'icon' => 'success',
3318 + 'autoClose' => 2000
3319 + )
3320 + )
3321 + )
3322 + )
3323 + )
3324 + )
3325 + )
3326 + )
3327 + )
3328 + )
3329 + )
3330 + )
3331 + )
3332 + )
3333 + ) );
2781 3334
2782 - public function get_terms( $taxonomy, $hide_empty = true ) {
2783 - $_cache_key = 'betterdocs::settings::terms::' . trim( $taxonomy );
2784 - $docs_tax = $this->database->get_cache( $_cache_key );
3335 + return $settings;
3336 + }
2785 3337
2786 - if ( $docs_tax ) {
2787 - return $docs_tax;
2788 - }
3338 + public function maybe_remove_git_tab( $tabs ) {
3339 + $pro_active = is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' );
3340 + $pro_has_git = apply_filters( 'betterdocs_pro_has_git_integration', false );
2789 3341
2790 - $get_terms = get_terms( [
2791 - 'taxonomy' => $taxonomy,
2792 - 'hide_empty' => $hide_empty
2793 - ] );
3342 + if ( $pro_active && ! $pro_has_git ) {
3343 + unset( $tabs[ 'tab-git-sync' ] );
3344 + }
2794 3345
2795 - $terms = [
2796 - 'all' => 'All'
2797 - ];
3346 + return $tabs;
3347 + }
2798 3348
2799 - if ( ! empty( $get_terms ) && ! is_wp_error( $get_terms ) ) {
2800 - foreach ( $get_terms as $value ) {
2801 - if ( isset( $value->slug ) && isset( $value->name ) ) {
2802 - $terms[ $value->slug ] = $value->name;
2803 - }
2804 - }
2805 - }
3349 + public function normalize_options( $options ) {
3350 + return GlobalFields::normalize_fields( $options );
3351 + }
2806 3352
2807 - $terms = $this->normalize_options( $terms );
2808 - if ( count( $terms ) > 1 ) {
2809 - $this->database->set_cache( $_cache_key, $terms );
2810 - }
3353 + public function get_texanomy() {
3354 + $docs_tax = $this->database->get_cache( 'betterdocs::settings::taxonomies' );
2811 3355
2812 - return $terms;
2813 - }
3356 + if ( $docs_tax ) {
3357 + return $docs_tax;
3358 + }
2814 3359
2815 - public function get_terms_with_ids( $taxonomy ) {
2816 - $_cache_key = 'betterdocs::settings::terms::ids' . trim( $taxonomy );
2817 - $docs_tax = $this->database->get_cache( $_cache_key );
3360 + $taxonomies = get_taxonomies( array(
3361 + 'object_type' => array( 'docs' )
3362 + ), 'objects' );
2818 3363
2819 - if ( $docs_tax ) {
2820 - return $docs_tax;
2821 - }
3364 + $docs_tax = array(
3365 + 'all' => 'All Docs Archive',
3366 + 'docs' => 'Docs Page'
3367 + );
3368 + foreach ( $taxonomies as $key => $value ) {
3369 + $docs_tax[ $key ] = $value->label;
3370 + }
3371 + unset( $docs_tax[ 'doc_tag' ] );
2822 3372
2823 - $get_terms = get_terms( [
2824 - 'taxonomy' => $taxonomy,
2825 - 'hide_empty' => false,
2826 - 'suppress_filter' => true,
2827 - ] );
3373 + $docs_tax = $this->normalize_options( $docs_tax );
3374 + if ( count( $docs_tax ) > 2 ) {
3375 + $this->database->set_cache( 'betterdocs::settings::taxonomies', $docs_tax );
3376 + }
2828 3377
2829 - $terms = [];
3378 + return $docs_tax;
3379 + }
2830 3380
2831 - if ( ! empty( $get_terms ) && ! is_wp_error( $get_terms ) ) {
2832 - foreach ( $get_terms as $value ) {
2833 - if ( isset( $value->term_id ) && isset( $value->name ) ) {
2834 - $terms[ $value->term_id ] = $value->name;
2835 - }
2836 - }
2837 - }
3381 + public function get_terms( $taxonomy, $hide_empty = true ) {
3382 + $_cache_key = 'betterdocs::settings::terms::' . trim( $taxonomy );
3383 + $docs_tax = $this->database->get_cache( $_cache_key );
2838 3384
2839 - $terms = $this->normalize_options( $terms );
2840 - if ( count( $terms ) > 1 ) {
2841 - $this->database->set_cache( $_cache_key, $terms );
2842 - }
3385 + if ( $docs_tax ) {
3386 + return $docs_tax;
3387 + }
2843 3388
2844 - return $terms;
2845 - }
3389 + $get_terms = get_terms( array(
3390 + 'taxonomy' => $taxonomy,
3391 + 'hide_empty' => $hide_empty
3392 + ) );
2846 3393
2847 - /**
2848 - * Get all docs
2849 - */
2850 - public function docs() {
2851 - $docs = $this->database->get_cache( 'betterdocs::settings::all_docs' );
3394 + $terms = array(
3395 + 'all' => 'All'
3396 + );
2852 3397
2853 - if ( $docs ) {
2854 - return $docs;
2855 - }
3398 + if ( ! empty( $get_terms ) && ! is_wp_error( $get_terms ) ) {
3399 + foreach ( $get_terms as $value ) {
3400 + if ( isset( $value->slug ) && isset( $value->name ) ) {
3401 + $terms[ $value->slug ] = $value->name;
3402 + }
3403 + }
3404 + }
2856 3405
2857 - $docs = [];
3406 + $terms = $this->normalize_options( $terms );
3407 + if ( count( $terms ) > 1 ) {
3408 + $this->database->set_cache( $_cache_key, $terms );
3409 + }
2858 3410
2859 - $_docs = get_posts( [
2860 - 'post_type' => 'docs',
2861 - 'numberposts' => - 1,
2862 - 'posts_per_page' => - 1
2863 - ] );
3411 + return $terms;
3412 + }
2864 3413
2865 - if ( ! empty( $_docs ) ) {
2866 - foreach ( $_docs as $doc ) {
2867 - $docs[ $doc->ID ] = betterdocs()->template_helper->kses( $doc->post_title );
2868 - }
2869 - $docs = GlobalFields::normalize_fields( $docs );
2870 - $this->database->set_cache( 'betterdocs::settings::all_docs', $docs );
2871 - }
3414 + public function get_terms_with_ids( $taxonomy ) {
3415 + $_cache_key = 'betterdocs::settings::terms::ids' . trim( $taxonomy );
3416 + $docs_tax = $this->database->get_cache( $_cache_key );
2872 3417
2873 - return $docs;
2874 - }
3418 + if ( $docs_tax ) {
3419 + return $docs_tax;
3420 + }
2875 3421
2876 - public function hide_roles_management( $tabData = [] ) {
2877 - global $current_user;
3422 + $get_terms = get_terms( array(
3423 + 'taxonomy' => $taxonomy,
3424 + 'hide_empty' => false,
3425 + 'suppress_filter' => true
3426 + ) );
2878 3427
2879 - if ( $current_user instanceof WP_User && ! in_array( 'administrator', $current_user->roles ) ) {
2880 - unset( $tabData['fields']['title-advance-settings']['fields']['article_roles'] );
2881 - unset( $tabData['fields']['title-advance-settings']['fields']['settings_roles'] );
2882 - unset( $tabData['fields']['title-advance-settings']['fields']['analytics_roles'] );
2883 - unset( $tabData['fields']['title-advance-settings']['fields']['faq_roles'] );
2884 - }
3428 + $terms = array();
2885 3429
2886 - return $tabData;
2887 - }
3430 + if ( ! empty( $get_terms ) && ! is_wp_error( $get_terms ) ) {
3431 + foreach ( $get_terms as $value ) {
3432 + if ( isset( $value->term_id ) && isset( $value->name ) ) {
3433 + $terms[ $value->term_id ] = $value->name;
3434 + }
3435 + }
3436 + }
3437 +
3438 + $terms = $this->normalize_options( $terms );
3439 + if ( count( $terms ) > 1 ) {
3440 + $this->database->set_cache( $_cache_key, $terms );
3441 + }
3442 +
3443 + return $terms;
3444 + }
3445 +
3446 + /**
3447 + * Get all docs
3448 + */
3449 + public function docs() {
3450 + $docs = $this->database->get_cache( 'betterdocs::settings::all_docs' );
3451 +
3452 + if ( $docs ) {
3453 + return $docs;
3454 + }
3455 +
3456 + $docs = array();
3457 +
3458 + $_docs = get_posts( array(
3459 + 'post_type' => 'docs',
3460 + 'numberposts' => -1,
3461 + 'posts_per_page' => -1
3462 + ) );
3463 +
3464 + if ( ! empty( $_docs ) ) {
3465 + foreach ( $_docs as $doc ) {
3466 + $docs[ $doc->ID ] = betterdocs()->template_helper->kses( $doc->post_title );
3467 + }
3468 + $docs = GlobalFields::normalize_fields( $docs );
3469 + $this->database->set_cache( 'betterdocs::settings::all_docs', $docs );
3470 + }
3471 +
3472 + return $docs;
3473 + }
3474 +
3475 + public function hide_roles_management( $tabData = array() ) {
3476 + global $current_user;
3477 +
3478 + if ( $current_user instanceof WP_User && ! in_array( 'administrator', $current_user->roles ) ) {
3479 + unset( $tabData[ 'fields' ][ 'title-advance-settings' ][ 'fields' ][ 'article_roles' ] );
3480 + unset( $tabData[ 'fields' ][ 'title-advance-settings' ][ 'fields' ][ 'settings_roles' ] );
3481 + unset( $tabData[ 'fields' ][ 'title-advance-settings' ][ 'fields' ][ 'analytics_roles' ] );
3482 + unset( $tabData[ 'fields' ][ 'title-advance-settings' ][ 'fields' ][ 'faq_roles' ] );
3483 + }
3484 +
3485 + return $tabData;
3486 + }
2888 3487 }