PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.2
4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 All 200 releases
← All changes | includes/Core/SetupWizard.php +187 -43 4.4.14.9.2 View file →
@@ -1,8 +1,12 @@
1 1 <?php
2 +namespace WPDeveloper\BetterDocs\Core;
2 3
3 -namespace WPDeveloper\BetterDocs\Core;
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
4 7
8 +
5 9 use WPDeveloper\BetterDocs\Utils\Base;
6 10 use WPDeveloper\BetterDocs\Admin\Builder\Rules;
7 11 use WPDeveloper\BetterDocs\Admin\Builder\GlobalFields;
8 12
@@ -20,13 +24,57 @@
20 24 }
21 25
22 26 betterdocs()->assets->enqueue( 'betterdocs-quick-setup', 'admin/js/quick-setup.js' );
23 27 betterdocs()->assets->localize( 'betterdocs-quick-setup', 'betterdocsQuickSetup', GlobalFields::normalize( $this->quickbuilder_setup() ) );
28 + betterdocs()->assets->localize(
29 + 'betterdocs-quick-setup',
30 + 'betterdocsSampleDocs',
31 + [
32 + 'enabled' => (bool) $this->settings->get( 'enable_ai_sample_docs', true ),
33 + 'rest_url' => esc_url_raw( rest_url() ),
34 + 'rest_base' => esc_url_raw( get_rest_url( null, '/betterdocs/v1/sample-docs' ) ),
35 + 'nonce' => wp_create_nonce( 'wp_rest' ),
36 + ]
37 + );
38 + // The layout picker writes Customizer theme_mods, which a block (FSE) theme never
39 + // reads — so on FSE we don't offer the picker at all (and don't spend the work
40 + // building its groups). The Customize step shows the same "design it in the Site
41 + // Editor" card the Settings > Design tab already shows there instead.
42 + $is_fse = (bool) betterdocs()->helper->current_theme_is_fse_theme();
43 +
44 + betterdocs()->assets->localize(
45 + 'betterdocs-quick-setup',
46 + 'betterdocsCustomizeLayouts',
47 + [
48 + 'rest_url' => esc_url_raw( rest_url() ),
49 + 'rest_base' => esc_url_raw( get_rest_url( null, '/betterdocs/v1/customize' ) ),
50 + 'nonce' => wp_create_nonce( 'wp_rest' ),
51 + 'is_fse' => $is_fse,
52 + 'groups' => $is_fse ? [] : $this->customize_layout_groups(),
53 + 'fse' => [
54 + 'eyebrow' => __( 'Full Site Editing', 'betterdocs' ),
55 + 'title' => __( 'Design with the Gutenberg Site Editor', 'betterdocs' ),
56 + 'description' => __( 'BetterDocs ships editable templates and ready-made patterns for your documentation. Open the Site Editor to design them block by block — colors, typography and layout included.', 'betterdocs' ),
57 + 'features' => [
58 + __( 'Docs archive & category templates', 'betterdocs' ),
59 + __( 'Single doc layout', 'betterdocs' ),
60 + __( 'Ready-made BetterDocs patterns', 'betterdocs' ),
61 + ],
62 + 'button' => __( 'Design with Gutenberg', 'betterdocs' ),
63 + 'note' => __( 'Opens in a new tab, so you can finish setup here.', 'betterdocs' ),
64 + // Opens the Site Editor's template list filtered to BetterDocs, rather than
65 + // dropping the user straight into one template (what Settings::gutenberg_link()
66 + // does) — from the wizard they've not chosen a template to edit yet.
67 + // Built by concatenation on purpose: add_query_arg() would re-encode the %2F.
68 + 'url' => admin_url( 'site-editor.php?p=%2Ftemplate&activeView=BetterDocs' ),
69 + 'image' => betterdocs()->assets->icon( 'customizer/gutenberg-preview.png', true ),
70 + ],
71 + ]
72 + );
24 73 betterdocs()->assets->enqueue( 'betterdocs-sweetalert', 'vendor/js/sweetalert.min.js', [] );
25 74 betterdocs()->assets->enqueue( 'betterdocs-icons', 'admin/btd-icon/style.css' );
26 75 betterdocs()->assets->enqueue( 'betterdocs-setup-wizard-qb-css', 'admin/css/quick-setup.css' );
27 76 betterdocs()->assets->enqueue( 'betterdocs-setup-wizard-new-css', 'admin/css/setup-wizard.css' );
28 - betterdocs()->assets->enqueue( 'betterdocs-icons', 'admin//style.css' );
29 77 betterdocs()->assets->enqueue( 'betterdocs-setup-wizard-default-js', 'admin/js/setup-wizard.js', [ 'jquery', 'betterdocs-sweetalert' ] );
30 78
31 79 // Localize the script with new data
32 80 betterdocs()->assets->localize(
@@ -42,8 +90,92 @@
42 90 ]
43 91 );
44 92 }
45 93
94 + /**
95 + * Layout-picker groups for the interactive "Customize" step. Each group's
96 + * `current` reflects the saved theme_mod; only the free layouts are offered.
97 + *
98 + * @return array
99 + */
100 + private function customize_layout_groups() {
101 + $build = function ( $key, $default, $dir, $title, $hint, $cols, array $options ) {
102 + $out = [];
103 + foreach ( $options as $value => $label ) {
104 + $out[] = [
105 + 'value' => $value,
106 + 'label' => $label,
107 + 'image' => betterdocs()->assets->icon( "customizer/{$dir}/{$value}.png", true ),
108 + ];
109 + }
110 + return [
111 + 'title' => $title,
112 + 'hint' => $hint,
113 + 'cols' => $cols,
114 + 'key' => $key,
115 + 'current' => get_theme_mod( $key, $default ),
116 + 'options' => $out,
117 + ];
118 + };
119 +
120 + return [
121 + 'docs' => $build(
122 + 'betterdocs_docs_layout_select',
123 + 'layout-7',
124 + 'docs-page',
125 + __( 'Docs Page', 'betterdocs' ),
126 + __( 'The main knowledge-base landing page.', 'betterdocs' ),
127 + 4,
128 + [
129 + 'layout-7' => __( 'Sleek', 'betterdocs' ),
130 + 'layout-1' => __( 'Grid', 'betterdocs' ),
131 + 'layout-8' => __( 'Slate', 'betterdocs' ),
132 + 'layout-5' => __( 'Classic', 'betterdocs' ),
133 + ]
134 + ),
135 + 'category' => $build(
136 + 'betterdocs_archive_layout_select',
137 + 'layout-7',
138 + 'archive',
139 + __( 'Category Page', 'betterdocs' ),
140 + __( "Where a single category's articles live.", 'betterdocs' ),
141 + 4,
142 + [
143 + 'layout-7' => __( 'Sleek', 'betterdocs' ),
144 + 'layout-1' => __( 'Classic', 'betterdocs' ),
145 + 'layout-8' => __( 'Slate', 'betterdocs' ),
146 + 'layout-4' => __( 'Abstract', 'betterdocs' ),
147 + ]
148 + ),
149 + 'single' => $build(
150 + 'betterdocs_single_layout_select',
151 + 'layout-8',
152 + 'single',
153 + __( 'Single Doc', 'betterdocs' ),
154 + __( 'An individual article layout.', 'betterdocs' ),
155 + 4,
156 + [
157 + 'layout-8' => __( 'Essence', 'betterdocs' ),
158 + 'layout-9' => __( 'Rustic', 'betterdocs' ),
159 + 'layout-10' => __( 'Slate', 'betterdocs' ),
160 + 'layout-1' => __( 'Classic', 'betterdocs' ),
161 + ]
162 + ),
163 + 'search' => $build(
164 + 'betterdocs_search_layout_select',
165 + 'layout-2',
166 + 'search',
167 + __( 'Search', 'betterdocs' ),
168 + __( 'How visitors search your docs.', 'betterdocs' ),
169 + 4,
170 + [
171 + 'layout-2' => __( 'Modal', 'betterdocs' ),
172 + 'layout-1' => __( 'Classic', 'betterdocs' ),
173 + ]
174 + ),
175 + ];
176 + }
177 +
46 178 public function normalize_options( $options ) {
47 179 return GlobalFields::normalize_fields( $options );
48 180 }
49 181
@@ -89,19 +221,19 @@
89 221 'active' => 'getting-started',
90 222 'sidebar' => false,
91 223 'title' => false,
92 224 'tab_number' => true,
93 - 'clickable' => false,
225 + 'clickable' => true,
94 226 'completionTrack' => true,
95 227 'content_heading' => [],
96 228 'step' => [
97 229 'show' => true,
98 230 'buttons' => [
99 - 'skip' => __( 'Skip This Step', 'betterdocs' ),
231 + 'skip' => __( 'Skip for now', 'betterdocs' ),
100 232 'prev' => [
101 - 'name' => __( 'Previous', 'betterdocs' ),
233 + 'name' => __( 'Back', 'betterdocs' ),
102 234 'type' => 'customize',
103 - 'customName' => __( 'Previous', 'betterdocs' ),
235 + 'customName' => __( 'Back', 'betterdocs' ),
104 236 'condition' => 'getting-started',
105 237 ],
106 238 'start' => [
107 239 'name' => 'Start',
@@ -119,18 +251,23 @@
119 251 ],
120 252 'next' => [
121 253 'name' => 'Next',
122 254 'type' => 'customize',
123 - 'customName' => __( 'Next', 'betterdocs' ),
255 + 'customName' => __( 'Save & Continue', 'betterdocs' ),
124 256 'condition' => 'getting-started',
125 - ],
126 - 'quick-builder-publish' => [
127 - 'name' => 'quick-builder-publish',
128 - 'type' => 'action',
129 - 'action' => 'btd_quick_build_launch'
130 257 ]
131 258 ],
132 - 'rules' => Rules::is( 'config.active', 'getting-started', true )
259 + // Hide the footer step bar on the first step (its CTA is in
260 + // content via showSteps) and on the last step (Finalize's
261 + // Finish CTA is in content too, so a lone Back button looked
262 + // off). Back-navigation there is still available via the tabs.
263 + 'rules' => Rules::logicalRule(
264 + [
265 + Rules::is( 'config.active', 'getting-started', true ),
266 + Rules::is( 'config.active', 'finalize', true ),
267 + ],
268 + 'and'
269 + )
133 270 ]
134 271 ],
135 272 'submit' => [
136 273 'show' => false
@@ -151,9 +288,9 @@
151 288 'type' => 'header',
152 289 'title' => __( 'Quick Launch', 'betterdocs' ),
153 290 'direction' => 'column',
154 291 'description' => __( 'Start your Knowledge Base configuration process with an easy-to-follow setup wizard.', 'betterdocs' ),
155 - 'icon' => '<img src="' . betterdocs()->assets->icon( 'icons/rocket.svg', true ) . '"/>',
292 + 'icon' => '<svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"></path><path d="M12 15l-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"></path><path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"></path><path d="M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"></path></svg>',
156 293 'priority' => 1
157 294 ],
158 295 'betterdocs-quick-setup-start' => [
159 296 'name' => 'betterdocs-quick-setup-start',
@@ -165,9 +302,9 @@
165 302 'name' => 'betterdocs-quick-setup-start-collapse',
166 303 'type' => 'collapse',
167 304 'priority' => 2,
168 305 'label' => __( 'By clicking this button, you are allowing this app to collect your information.', 'betterdocs' ),
169 - 'collapse_title' => __( 'What We Collect?', 'betterdocs' ),
306 + 'collapse_title' => __( 'What do we collect?', 'betterdocs' ),
170 307 'collapse_message' => __( 'We collect non-sensitive diagnostic data and plugin usage information. Your site URL, WordPress & PHP version, plugins & themes and email address to send you the discount coupon. This data lets us make sure this plugin always stays compatible with the most popular plugins and themes. No spam, we promise.', 'betterdocs' )
171 308 ]
172 309 ]
173 310 ]
@@ -188,9 +325,9 @@
188 325 'type' => 'header',
189 326 'title' => __( 'Page Setup Magic', 'betterdocs' ),
190 327 'direction' => 'row',
191 328 'description' => __( 'Configure the structure and layout of your documentation pages to match your preferences for an organized Knowledge Base.', 'betterdocs' ),
192 - 'icon' => '<img src="' . betterdocs()->assets->icon( 'icons/content-setting.svg', true ) . '"/>',
329 + 'icon' => '<svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M15 8a1 1 0 0 1-1-1V2a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8z"></path><path d="M20 8v12a2 2 0 0 1-2 2h-4.182"></path><path d="m3.305 19.53.923-.382"></path><path d="M4 10.592V4a2 2 0 0 1 2-2h8"></path><path d="m4.228 16.852-.924-.383"></path><path d="m5.852 15.228-.383-.923"></path><path d="m5.852 20.772-.383.924"></path><path d="m8.148 15.228.383-.923"></path><path d="m8.53 21.696-.382-.924"></path><path d="m9.773 16.852.922-.383"></path><path d="m9.773 19.148.922.383"></path><circle cx="7" cy="18" r="3"></circle></svg>',
193 330 'priority' => 1
194 331 ],
195 332 'betterdocs-quick-setup-fields' => [
196 333 'name' => 'betterdocs-quick-setup-fields',
@@ -203,9 +340,13 @@
203 340 'label' => __( 'Built-in Documentation Page', 'betterdocs' ),
204 341 'enable_disable_text_active' => true,
205 342 'default' => 1,
206 343 'priority' => 1,
207 - 'label_subtitle' => __( 'If you disable root slug for KB Archives, your individual knowledge base URL will be like this: https://example.com/knowledgebase-1', 'betterdocs' )
344 + 'label_subtitle' => sprintf(
345 + /* translators: %s: example knowledge base URL */
346 + __( 'If you disable root slug for KB Archives, your individual knowledge base URL will be like this: %s', 'betterdocs' ),
347 + 'https://example.com/knowledgebase-1'
348 + )
208 349 ],
209 350 'docs_page' => [
210 351 'name' => 'docs_page',
211 352 'label' => __( 'Docs Page', 'betterdocs' ),
@@ -325,17 +466,14 @@
325 466 'type' => 'header',
326 467 'title' => __( 'Content Crafting', 'betterdocs' ),
327 468 'direction' => 'row',
328 469 'description' => __( 'Craft categories & articles for your Knowledge Base to efficiently organize and manage your repository with respective categories.', 'betterdocs' ),
329 - 'icon' => '<img src="' . betterdocs()->assets->icon( 'icons/create-content.svg', true ) . '"/>',
470 + 'icon' => '<svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4a1 1 0 0 1 1-1h9l5 5v3"></path><path d="M4 4v15a1 1 0 0 0 1 1h6"></path><path d="M14 3v5h5"></path><path d="M18.5 13.5a2.1 2.1 0 0 1 3 3L16 22l-4 1 1-4z"></path></svg>',
330 471 'priority' => 1
331 472 ],
332 - 'create_content_video' => [
333 - 'name' => 'create_content_video',
334 - 'type' => 'image',
335 - 'media' => [
336 - 'url' => betterdocs()->assets->icon( 'setup-wizard/DocCreate.gif', true )
337 - ],
473 + 'create_content_generator' => [
474 + 'name' => 'create_content_generator',
475 + 'type' => 'sample_docs_generator',
338 476 'priority' => 2
339 477 ]
340 478 ]
341 479 ]
@@ -343,9 +481,14 @@
343 481 'customize' => apply_filters(
344 482 'betterdocs_quick_setup_tab_customize',
345 483 [
346 484 'id' => 'customize',
347 - 'label' => __( 'Customize', 'betterdocs' ),
485 + // A block theme has no Customizer layouts to pick, so the step isn't
486 + // "Customize" there — it hands off to the Site Editor. (The tab id stays
487 + // `customize`: it keys the step's navigation and styling.)
488 + 'label' => betterdocs()->helper->current_theme_is_fse_theme()
489 + ? __( 'Design', 'betterdocs' )
490 + : __( 'Customize', 'betterdocs' ),
348 491 'classes' => 'customize',
349 492 'priority' => 50,
350 493 'fields' => [
351 494 'customize_header' => [
@@ -350,20 +493,24 @@
350 493 'fields' => [
351 494 'customize_header' => [
352 495 'name' => 'customize_header',
353 496 'type' => 'header',
354 - 'title' => __( 'Style Your Documentation', 'betterdocs' ),
497 + 'title' => betterdocs()->helper->current_theme_is_fse_theme()
498 + ? __( 'Design Your Documentation', 'betterdocs' )
499 + : __( 'Style Your Documentation', 'betterdocs' ),
355 500 'direction' => 'row',
356 - 'description' => __( 'Personalize the appearance of your documentation page, articles, and archive pages using the power of this Customizer.', 'betterdocs' ),
357 - 'icon' => '<img src="' . betterdocs()->assets->icon( 'icons/customize.svg', true ) . '"/>',
501 + // On a block theme the layout picker is replaced by the Site Editor
502 + // hand-off, so the copy leads with what the user CAN do rather than
503 + // naming a Customizer they will never open.
504 + 'description' => betterdocs()->helper->current_theme_is_fse_theme()
505 + ? __( 'Your theme supports Full Site Editing. Design your docs archive, single doc pages and patterns right in the Gutenberg Site Editor.', 'betterdocs' )
506 + : __( 'Pick a layout for your docs page, categories, single articles, and search — applied when you finish setup. Fine-tune the details anytime in the Customizer.', 'betterdocs' ),
507 + 'icon' => '<svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2.5"></rect><path d="M3 9h18M9 9v11"></path></svg>',
358 508 'priority' => 1
359 509 ],
360 - 'customize_video' => [
361 - 'name' => 'customize_video',
362 - 'type' => 'image',
363 - 'media' => [
364 - 'url' => betterdocs()->assets->icon( 'setup-wizard/Customizer.gif', true )
365 - ],
510 + 'customize_layouts' => [
511 + 'name' => 'customize_layouts',
512 + 'type' => 'layout_customizer',
366 513 'priority' => 2
367 514 ]
368 515 ]
369 516 ]
@@ -378,20 +525,17 @@
378 525 'fields' => [
379 526 'finalize_header' => [
380 527 'name' => 'finalize_header',
381 528 'type' => 'header',
382 - 'title' => __( 'Congratulations!', 'betterdocs' ),
529 + 'title' => __( 'One last step', 'betterdocs' ),
383 530 'direction' => 'row',
384 - 'description' => __( 'Your documentation page is now ready for use. Enrich it with more articles to ensure proper categorization and valuable resources.', 'betterdocs' ),
385 - 'icon' => '<img src="' . betterdocs()->assets->icon( 'icons/thumbs-up.svg', true ) . '"/>',
531 + 'description' => __( 'Review your setup below. When you\'re ready, finish to save your settings and apply BetterDocs across your site — you can change anything later in Settings.', 'betterdocs' ),
532 + 'icon' => '<svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="m3 17 2 2 4-4"></path><path d="m3 7 2 2 4-4"></path><path d="M13 6h8"></path><path d="M13 12h8"></path><path d="M13 18h8"></path></svg>',
386 533 'priority' => 1
387 534 ],
388 - 'finalize_video' => [
389 - 'name' => 'finalize_video',
390 - 'type' => 'image',
391 - 'media' => [
392 - 'url' => betterdocs()->assets->icon( 'setup-wizard/ThankYou.gif', true )
393 - ],
535 + 'finalize_finish' => [
536 + 'name' => 'finalize_finish',
537 + 'type' => 'finish_panel',
394 538 'priority' => 2
395 539 ]
396 540 ]
397 541 ]