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