PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 1.7.1
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v1.7.1
4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.5.2 All 199 releases
betterdocs / admin / includes / betterdocs-settings-page-helper.php

betterdocs-settings-page-helper.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 1.7.1, at admin/includes/betterdocs-settings-page-helper.php

594 lines 31.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Get all pages
4 */
5 function betterdocs_get_pages() {
6 $pages = [];
7 $_pages = get_posts(array(
8 'post_type' => 'page',
9 'numberposts' => -1,
10 'post_status' => 'publish',
11 'posts_per_page' => -1
12 ));
13
14 if( ! empty( $_pages ) ) {
15 $pages[0] = 'Select a Page';
16 foreach( $_pages as $page ) {
17 $pages[ $page->ID ] = $page->post_title;
18 }
19 }
20
21 return $pages;
22 }
23 function betterdocs_settings_args(){
24 $query['autofocus[panel]'] = 'betterdocs_customize_options';
25 $query['return'] = admin_url( 'edit.php?post_type=docs' );
26 $builtin_doc_page = BetterDocs_DB::get_settings('builtin_doc_page');
27 $docs_slug = BetterDocs_DB::get_settings('docs_slug');
28 $docs_page = BetterDocs_DB::get_settings('docs_page');
29 if ( $builtin_doc_page == 1 && $docs_slug ) {
30 $query['url'] = site_url( '/'.$docs_slug );
31 } elseif ( $builtin_doc_page != 1 && $docs_page ) {
32 $post_info = get_post( $docs_page );
33 $query['url'] = site_url( '/'.$post_info->post_name );
34 }
35 $customizer_link = add_query_arg( $query, admin_url( 'customize.php' ) );
36 return apply_filters('betterdocs_settings_tab', array(
37 'general' => array(
38 'title' => __( 'General', 'betterdocs' ),
39 'priority' => 10,
40 'button_text' => __( 'Save Settings' ),
41 'sections' => apply_filters('betterdocs_general_settings_sections', array(
42 'general_settings' => apply_filters('betterdocs_general_settings', array(
43 'title' => __( 'General Settings', 'betterdocs' ),
44 'priority' => 10,
45 'fields' => array(
46 'multiple_kb' => apply_filters( 'betterdocs_multi_kb_settings', array(
47 'type' => 'checkbox',
48 'label' => __('Enable Multiple Knowledge Base' , 'betterdocs'),
49 'default' => '',
50 'priority' => 10,
51 'disable' => true,
52 )),
53 'builtin_doc_page' => array(
54 'type' => 'checkbox',
55 'label' => __('Enable Built-in Documentation Page' , 'betterdocs'),
56 'default' => 1,
57 'priority' => 10,
58 'help' => __('<strong>Note:</strong> if you disable built-in documentation page, you can use shortcode or page builder widgets to design your documentation page.' , 'betterdocs'),
59 'dependency' => array(
60 1 => array(
61 'fields' => array( 'docs_slug' ),
62 ),
63 0 => array(
64 'fields' => array( 'docs_page' ),
65 ),
66 ),
67 ),
68 'breadcrumb_doc_title' => array(
69 'type' => 'text',
70 'label' => __('Documentation Page Title' , 'betterdocs'),
71 'default' => 'Docs',
72 'priority' => 10,
73 ),
74 'docs_slug' => array(
75 'type' => 'text',
76 'label' => __('BetterDocs Root Slug' , 'betterdocs'),
77 'default' => 'docs',
78 'priority' => 10
79 ),
80 'docs_page' => array(
81 'label' => __( 'Docs Page', 'betterdocs' ),
82 'type' => 'select',
83 'priority' => 10,
84 'options' => betterdocs_get_pages(),
85 'help' => __('Note: You will need to insert BetterDocs Shortcode inside the page. This page will be used as docs permalink.' , 'betterdocs'),
86 ),
87 'category_slug' => array(
88 'type' => 'text',
89 'label' => __('Custom Category Slug' , 'betterdocs'),
90 'default' => 'docs-category',
91 'priority' => 10
92 ),
93 'tag_slug' => array(
94 'type' => 'text',
95 'label' => __('Custom Tag Slug' , 'betterdocs'),
96 'default' => 'docs-tag',
97 'priority' => 10
98 ),
99 'permalink_structure' => array(
100 'type' => 'text',
101 'label' => __( 'Doc Permalink', 'betterdocs' ),
102 'default' => apply_filters("betterdocs_doc_permalink_default", BetterDocs_Docs_Post_Type::$docs_slug),
103 'priority' => 10,
104 'help' => betterdocs_permalink_structure_tags(),
105 ),
106 ),
107 )),
108
109 )),
110 ),
111 'layout' => array(
112 'title' => __( 'Layout', 'betterdocs' ),
113 'priority' => 10,
114 'button_text' => __( 'Save Settings' ),
115 'sections' => apply_filters('betterdocs_layout_settings_sections', array(
116
117 'layout_inner_tab' => array(
118 'title' => __( 'Layout Tab' ),
119 'tabs' => array(
120 'documentation_page' => apply_filters('betterdocs_layout_documentation_page_settings', array(
121 'title' => __( 'Documentation Page', 'betterdocs' ),
122 'priority' => 10,
123 'fields' => array(
124 'doc_page' => array(
125 'type' => 'title',
126 'label' => __('Documentation Page' , 'betterdocs'),
127 'priority' => 10,
128 ),
129 'live_search' => array(
130 'type' => 'checkbox',
131 'label' => __('Enable Live Search' , 'betterdocs'),
132 'default' => 1,
133 'priority' => 10,
134 ),
135 'search_placeholder' => array(
136 'type' => 'text',
137 'label' => __('Search Placeholder' , 'betterdocs'),
138 'default' => 'Search..',
139 'priority' => 10,
140 ),
141 'search_result_image' => array(
142 'type' => 'checkbox',
143 'label' => __('Search Result Image' , 'betterdocs'),
144 'default' => 1,
145 'priority' => 10,
146 ),
147 'masonry_layout' => array(
148 'type' => 'checkbox',
149 'label' => __('Enable Masonry' , 'betterdocs'),
150 'default' => 1,
151 'priority' => 10,
152 ),
153 'alphabetically_order_post' => array(
154 'type' => 'checkbox',
155 'label' => __('Order Docs Post Alphabetically' , 'betterdocs'),
156 'default' => '',
157 'priority' => 10,
158 ),
159 'alphabetically_order_term' => array(
160 'type' => 'checkbox',
161 'label' => __('Order Category Alphabetically' , 'betterdocs'),
162 'default' => '',
163 'priority' => 10,
164 ),
165 'nested_subcategory' => array(
166 'type' => 'checkbox',
167 'label' => __('Nested Subcategory' , 'betterdocs'),
168 'default' => '',
169 'priority' => 10,
170 ),
171 'column_number' => array(
172 'type' => 'number',
173 'label' => __('Number of Columns' , 'betterdocs'),
174 'default' => 3,
175 'priority' => 10
176 ),
177 'posts_number' => array(
178 'type' => 'number',
179 'label' => __('Number of Posts' , 'betterdocs'),
180 'default' => 10,
181 'priority' => 10
182 ),
183 'post_count' => array(
184 'type' => 'checkbox',
185 'label' => __('Enable Post Count' , 'betterdocs'),
186 'default' => 1,
187 'priority' => 10,
188 ),
189 'count_text' => array(
190 'type' => 'text',
191 'label' => __('Count Text' , 'betterdocs'),
192 'default' => __('articles' , 'betterdocs'),
193 'priority' => 10,
194 ),
195 'count_text_singular' => array(
196 'type' => 'text',
197 'label' => __('Count Text Singular' , 'betterdocs'),
198 'default' => __('article' , 'betterdocs'),
199 'priority' => 10,
200 ),
201 'exploremore_btn' => array(
202 'type' => 'checkbox',
203 'label' => __('Enable Explore More Button' , 'betterdocs'),
204 'default' => 1,
205 'priority' => 10,
206 'dependency' => array(
207 1 => array(
208 'fields' => array( 'exploremore_btn_txt' )
209 )
210 ),
211 'hide' => array(
212 0 => array(
213 'fields' => array( 'exploremore_btn_txt' )
214 )
215 )
216 ),
217 'exploremore_btn_txt' => array(
218 'type' => 'text',
219 'label' => __('Button Text' , 'betterdocs'),
220 'default' => __('Explore More' , 'betterdocs'),
221 'priority' => 10
222 ),
223 ),
224 )),
225 'single_doc' => apply_filters('betterdocs_layout_single_doc_settings', array(
226 'title' => __( 'Single Doc', 'betterdocs' ),
227 'priority' => 10,
228 'fields' => array(
229 'doc_single' => array(
230 'type' => 'title',
231 'label' => __('Single Doc' , 'betterdocs'),
232 'priority' => 10,
233 ),
234 'enable_toc' => array(
235 'type' => 'checkbox',
236 'label' => __('Enable Table of Contents (TOC)' , 'betterdocs'),
237 'default' => 1,
238 'priority' => 10,
239 'dependency' => array(
240 1 => array(
241 'fields' => array( 'enable_sticky_toc', 'toc_hierarchy', 'supported_heading_tag' )
242 )
243 ),
244 'hide' => array(
245 0 => array(
246 'fields' => array( 'enable_sticky_toc', 'toc_hierarchy', 'supported_heading_tag' )
247 )
248 )
249 ),
250 'toc_hierarchy' => array(
251 'type' => 'checkbox',
252 'label' => __('TOC Hierarchy' , 'betterdocs'),
253 'default' => 1,
254 'priority' => 10
255 ),
256 'toc_list_number' => array(
257 'type' => 'checkbox',
258 'label' => __('TOC List Number' , 'betterdocs'),
259 'default' => 1,
260 'priority' => 10
261 ),
262 'enable_sticky_toc' => array(
263 'type' => 'checkbox',
264 'label' => __('Enable Sticky TOC' , 'betterdocs'),
265 'default' => 1,
266 'priority' => 10
267 ),
268 'sticky_toc_offset' => array(
269 'type' => 'number',
270 'label' => __('Content Offset' , 'betterdocs'),
271 'default' => 100,
272 'priority' => 10,
273 'description' => __('content offset from top on scroll.' , 'betterdocs'),
274 ),
275 'collapsible_toc_mobile' => array(
276 'type' => 'checkbox',
277 'label' => __('Collapsible TOC on small devices' , 'betterdocs'),
278 'default' => '',
279 'priority' => 10
280 ),
281 'supported_heading_tag' => array(
282 'label' => __( 'TOC Supported Heading Tag', 'betterdocs' ),
283 'type' => 'multi_checkbox',
284 'priority' => 10,
285 'default' => array(1,2,3,4,5,6),
286 'options' => array(
287 '1' => 'h1',
288 '2' => 'h2',
289 '3' => 'h3',
290 '4' => 'h4',
291 '5' => 'h5',
292 '6' => 'h6'
293 ),
294 ),
295 'enable_post_title' => array(
296 'type' => 'checkbox',
297 'label' => __('Enable Post Title' , 'betterdocs'),
298 'default' => 1,
299 'priority' => 10
300 ),
301 'title_link_ctc' => array(
302 'type' => 'checkbox',
303 'label' => __('Title Link Copy To Clipboard' , 'betterdocs'),
304 'default' => 1,
305 'priority' => 10
306 ),
307 'enable_breadcrumb' => array(
308 'type' => 'checkbox',
309 'label' => __('Enable Breadcrumb' , 'betterdocs'),
310 'default' => 1,
311 'priority' => 10,
312 'dependency' => array(
313 1 => array(
314 'fields' => array('breadcrumb_home_text', 'breadcrumb_home_url', 'enable_breadcrumb_category', 'enable_breadcrumb_title')
315 )
316 ),
317 'hide' => array(
318 0 => array(
319 'fields' => array('breadcrumb_home_text', 'breadcrumb_home_url', 'enable_breadcrumb_category', 'enable_breadcrumb_title')
320 )
321 )
322 ),
323 'breadcrumb_home_text' => array(
324 'type' => 'text',
325 'label' => __('Breadcrumb Home Text' , 'betterdocs'),
326 'default' => __('Home' , 'betterdocs'),
327 'priority' => 10,
328
329 ),
330 'breadcrumb_home_url' => array(
331 'type' => 'text',
332 'label' => __('Breadcrumb Home URL' , 'betterdocs'),
333 'priority' => 10,
334 'default' => get_home_url(),
335 ),
336 'enable_breadcrumb_category' => array(
337 'type' => 'checkbox',
338 'label' => __('Enable Category on Breadcrumb' , 'betterdocs'),
339 'default' => 1,
340 'priority' => 10
341 ),
342 'enable_breadcrumb_title' => array(
343 'type' => 'checkbox',
344 'label' => __('Enable Title on Breadcrumb' , 'betterdocs'),
345 'default' => 1,
346 'priority' => 10
347 ),
348 'enable_sidebar_cat_list' => array(
349 'type' => 'checkbox',
350 'label' => __('Enable Sidebar Category List' , 'betterdocs'),
351 'default' => 1,
352 'priority' => 10
353 ),
354 'enable_print_icon' => array(
355 'type' => 'checkbox',
356 'label' => __('Enable Print Icon' , 'betterdocs'),
357 'default' => 1,
358 'priority' => 10
359 ),
360 'enable_tags' => array(
361 'type' => 'checkbox',
362 'label' => __('Enable Tags' , 'betterdocs'),
363 'default' => 1,
364 'priority' => 10
365 ),
366 'email_feedback' => array(
367 'type' => 'checkbox',
368 'label' => __('Enable Email Feedback' , 'betterdocs'),
369 'default' => 1,
370 'priority' => 10,
371 'dependency' => array(
372 1 => array(
373 'fields' => array( 'email_address', 'feedback_link_text', 'feedback_form_title' )
374 )
375 ),
376 'hide' => array(
377 0 => array(
378 'fields' => array( 'email_address', 'feedback_link_text', 'feedback_form_title' )
379 )
380 )
381 ),
382 'feedback_link_text' => array(
383 'type' => 'text',
384 'label' => __('Feedback Link Text' , 'betterdocs'),
385 'default' => esc_html__('Still stuck? How can we help?','betterdocs'),
386 'priority' => 10
387 ),
388 'feedback_form_title' => array(
389 'type' => 'text',
390 'label' => __('Feedback Form Title' , 'betterdocs'),
391 'default' => esc_html__('How can we help?','betterdocs'),
392 'priority' => 10
393 ),
394 'email_address' => array(
395 'type' => 'text',
396 'label' => __('Email Address' , 'betterdocs'),
397 'default' => get_option('admin_email'),
398 'priority' => 10,
399 'description' => __('The email address where the Feedback from will be sent' , 'betterdocs'),
400 ),
401 'show_last_update_time' => array(
402 'type' => 'checkbox',
403 'label' => __('Show Last Update Time' , 'betterdocs'),
404 'default' => 1,
405 'priority' => 10
406 ),
407 'enable_navigation' => array(
408 'type' => 'checkbox',
409 'label' => __('Enable Navigation' , 'betterdocs'),
410 'default' => 1,
411 'priority' => 10
412 ),
413 'enable_comment' => array(
414 'type' => 'checkbox',
415 'label' => __('Enable Comment' , 'betterdocs'),
416 'default' => 1,
417 'priority' => 10
418 ),
419 'enable_credit' => array(
420 'type' => 'checkbox',
421 'label' => __('Enable Credit' , 'betterdocs'),
422 'default' => 1,
423 'priority' => 10
424 ),
425 ),
426 )),
427 'archive_page' => apply_filters('betterdocs_layout_archive_page_settings', array(
428 'title' => __( 'Archive Page', 'betterdocs' ),
429 'priority' => 10,
430 'fields' => array(
431 'archive_page_title' => array(
432 'type' => 'title',
433 'label' => __('Archive Page' , 'betterdocs'),
434 'priority' => 10,
435 ),
436 'enable_archive_sidebar' => array(
437 'type' => 'checkbox',
438 'label' => __('Enable Sidebar Category List' , 'betterdocs'),
439 'default' => 1,
440 'priority' => 10,
441 )
442 ),
443 )),
444 )
445 )
446
447 )),
448 ),
449 'design' => array(
450 'title' => __( 'Design', 'betterdocs' ),
451 'priority' => 10,
452 'sections' => apply_filters('betterdocs_design_settings_sections', array(
453 'design_settings' => apply_filters('betterdocs_design_settings', array(
454 'title' => __( 'Documentation Page', 'betterdocs' ),
455 'priority' => 10,
456 'fields' => array(
457 'customizer_link' => array(
458 'type' => 'card',
459 'label' => __('Customize BetterDocs','betterdocs'),
460 'url' => esc_url($customizer_link),
461 'priority' => 10
462 ),
463 ),
464 )),
465 )),
466 ),
467 'shortcodes' => array(
468 'title' => __( 'Shortcodes', 'betterdocs' ),
469 'priority' => 10,
470 'sections' => apply_filters('betterdocs_shortcodes_settings_sections', array(
471 'shortcodes_settings' => apply_filters('betterdocs_shortcodes_settings', array(
472 'title' => __( 'Shortcodes', 'betterdocs' ),
473 'priority' => 10,
474 'fields' => apply_filters('betterdocs_shortcode_fields', array(
475 'search_form' => array(
476 'type' => 'text',
477 'label' => __('Search Form' , 'betterdocs'),
478 'default' => '[betterdocs_search_form]',
479 'readonly' => true,
480 'priority' => 10
481 ),
482 'feedback_form' => array(
483 'type' => 'text',
484 'label' => __('Feedback Form' , 'betterdocs'),
485 'default' => '[betterdocs_feedback_form]',
486 'readonly' => true,
487 'priority' => 10
488 ),
489 'category_grid' => array(
490 'type' => 'text',
491 'label' => __('Category Grid- Layout 1' , 'betterdocs'),
492 'default' => '[betterdocs_category_grid]',
493 'readonly' => true,
494 'priority' => 10,
495 'help' => __('<strong>You can use:</strong> [betterdocs_category_grid post_counter="true" icon="true" masonry="true" column="3" posts_per_grid="5" nested_subcategory="true" terms="term_ID, term_ID"]' , 'betterdocs'),
496 ),
497 'category_box' => array(
498 'type' => 'text',
499 'label' => __('Category Box- Layout 2' , 'betterdocs'),
500 'default' => '[betterdocs_category_box]',
501 'readonly' => true,
502 'priority' => 10,
503 'help' => __('<strong>You can use:</strong> [betterdocs_category_box column="3" terms="term_ID, term_ID"]' , 'betterdocs'),
504 ),
505 )),
506 )),
507 )),
508 ),
509 'betterdocs_advanced_settings' => array(
510 'title' => __( 'Advanced Settings', 'betterdocs' ),
511 'priority' => 20,
512 'button_text' => __( 'Save Settings' ),
513 'sections' => apply_filters( 'betterdocs_pro_advanced_settings_sections', array(
514 'role_management_section' => array(
515 'title' => __('Role Management', 'betterdocs'),
516 'priority' => 0,
517 'fields' => array(
518 'rms_title' => array(
519 'type' => 'title',
520 'label' => __('Role Management', 'betterdocs'),
521 'priority' => 0,
522 ),
523 'article_roles' => array(
524 'type' => 'select',
525 'label' => __('Who Can Write Docs?', 'betterdocs'),
526 'priority' => 1,
527 'multiple' => true,
528 'disable' => true,
529 'default' => 'administrator',
530 'options' => BetterDocs_Settings::get_roles()
531 ),
532 'settings_roles' => array(
533 'type' => 'select',
534 'label' => __('Who Can Edit Settings?', 'betterdocs'),
535 'priority' => 1,
536 'multiple' => true,
537 'disable' => true,
538 'default' => 'administrator',
539 'options' => BetterDocs_Settings::get_roles()
540 ),
541 'analytics_roles' => array(
542 'type' => 'select',
543 'label' => __('Who Can Check Analytics?', 'betterdocs'),
544 'priority' => 1,
545 'multiple' => true,
546 'disable' => true,
547 'default' => 'administrator',
548 'options' => BetterDocs_Settings::get_roles()
549 ),
550 )
551 )
552 ) )
553 )
554 ));
555 }
556
557 /**
558 * Undocumented function
559 *
560 * @return string
561 */
562 function betterdocs_permalink_structure_tags(){
563 $tags = apply_filters("betterdocs_doc_permalink_tags", [
564 '%doc_category%' => [
565 'class' => '',
566 'aria-label' => __( 'Docs Categories', 'betterdocs' ),
567 'data-added' => __( 'doc_category added to permalink structure', 'betterdocs' ),
568 'data-used' => __( 'doc_category (already used in permalink structure)', 'betterdocs' ),
569 ],
570 ]);
571
572 $return = __( "<b>Available tags:</b>", 'betterdocs' );
573 $return .= "
574 <div class='form-table permalink-structure'>
575 <div class='available-structure-tags hide-if-no-js'>
576 <div id='custom_selection_updated' aria-live='assertive' class='screen-reader-text'></div>
577 <ul role='list'>
578 ";
579
580 foreach($tags as $tag => $args){
581 $return .= "
582 <li class='{$args['class']}'>
583 <button type='button' class='button button-secondary' aria-label='{$args['aria-label']}' data-added='{$args['data-added']}' data-used='{$args['data-used']}'>$tag</button>
584 </li>
585 ";
586 }
587
588 $return .= "
589 </ul>
590 </div>
591 </div>
592 ";
593 return $return;
594 }