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 +609 -345 3.3.44.9.2 View file →
@@ -1,372 +1,636 @@
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
9 13 class SetupWizard extends Base {
10 - private $settings;
11 - public function __construct( Settings $settings ) {
12 - $this->settings = $settings;
14 + private $settings;
15 + public function __construct( Settings $settings ) {
16 + $this->settings = $settings;
13 17
14 - add_action( 'admin_enqueue_scripts', [$this, 'enqueue'] );
15 - }
18 + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
19 + }
16 20
17 - public function enqueue( $hook ) {
18 - if ( $hook !== 'betterdocs_page_betterdocs-setup' ) {
19 - return;
20 - }
21 + public function enqueue( $hook ) {
22 + if ( $hook !== 'betterdocs_page_betterdocs-setup' ) {
23 + return;
24 + }
21 25
22 - betterdocs()->assets->enqueue( 'betterdocs-quick-setup', 'admin/js/quick-setup.js' );
23 - betterdocs()->assets->localize( 'betterdocs-quick-setup', 'betterdocsQuickSetup', GlobalFields::normalize( $this->quickbuilder_setup() ) );
24 - betterdocs()->assets->enqueue( 'betterdocs-sweetalert', 'vendor/js/sweetalert.min.js', [] );
25 - betterdocs()->assets->enqueue( 'betterdocs-setup-wizard-qb-css', 'admin/css/quick-setup.css' );
26 - betterdocs()->assets->enqueue( 'betterdocs-setup-wizard-new-css', 'admin/css/setup-wizard.css' );
27 - betterdocs()->assets->enqueue( 'betterdocs-icons', 'admin/btd-icon/style.css' );
28 - betterdocs()->assets->enqueue( 'betterdocs-setup-wizard-default-js', 'admin/js/setup-wizard.js', ['jquery', 'betterdocs-sweetalert'] );
26 + betterdocs()->assets->enqueue( 'betterdocs-quick-setup', 'admin/js/quick-setup.js' );
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();
29 43
30 - // Localize the script with new data
31 - betterdocs()->assets->localize( 'betterdocs-setup-wizard', 'bdquicksetup', [
32 - 'finish_txt' => __( 'Finish', 'betterdocs' ),
33 - 'next_txt' => __( 'Next', 'betterdocs' ),
34 - 'customizerurl' => $this->customizer_settings_url(),
35 - 'docspageurl' => $this->docs_page_url(),
36 - 'currentslug' => $this->settings->get( 'docs_slug' ),
37 - 'redirecturl' => admin_url( '/admin.php?page=betterdocs-settings' )
38 - ] );
39 - }
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 + );
73 + betterdocs()->assets->enqueue( 'betterdocs-sweetalert', 'vendor/js/sweetalert.min.js', [] );
74 + betterdocs()->assets->enqueue( 'betterdocs-icons', 'admin/btd-icon/style.css' );
75 + betterdocs()->assets->enqueue( 'betterdocs-setup-wizard-qb-css', 'admin/css/quick-setup.css' );
76 + betterdocs()->assets->enqueue( 'betterdocs-setup-wizard-new-css', 'admin/css/setup-wizard.css' );
77 + betterdocs()->assets->enqueue( 'betterdocs-setup-wizard-default-js', 'admin/js/setup-wizard.js', [ 'jquery', 'betterdocs-sweetalert' ] );
40 78
41 - public function normalize_options( $options ) {
42 - return GlobalFields::normalize_fields( $options );
43 - }
79 + // Localize the script with new data
80 + betterdocs()->assets->localize(
81 + 'betterdocs-setup-wizard',
82 + 'bdquicksetup',
83 + [
84 + 'finish_txt' => __( 'Finish', 'betterdocs' ),
85 + 'next_txt' => __( 'Next', 'betterdocs' ),
86 + 'customizerurl' => $this->customizer_settings_url(),
87 + 'docspageurl' => $this->docs_page_url(),
88 + 'currentslug' => $this->settings->get( 'docs_slug' ),
89 + 'redirecturl' => admin_url( '/admin.php?page=betterdocs-settings' )
90 + ]
91 + );
92 + }
44 93
45 - public function get_pages() {
46 - $_pages = betterdocs()->query->get_posts( [
47 - 'post_type' => 'page',
48 - 'numberposts' => -1,
49 - 'post_status' => 'publish',
50 - 'posts_per_page' => -1
51 - ] );
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 + };
52 119
53 - $__pages = [];
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 + }
54 177
55 - if ( ! empty( $_pages ) ) {
56 - $__pages[0] = __( 'Select a Page', 'betterdocs' );
57 - foreach ( $_pages->posts as $page ) {
58 - $__pages[$page->ID] = esc_html( $page->post_title );
59 - }
60 - }
178 + public function normalize_options( $options ) {
179 + return GlobalFields::normalize_fields( $options );
180 + }
61 181
62 - return $__pages;
63 - }
182 + public function get_pages() {
183 + $_pages = betterdocs()->query->get_posts(
184 + [
185 + 'post_type' => 'page',
186 + 'numberposts' => -1,
187 + 'post_status' => 'publish',
188 + 'posts_per_page' => -1
189 + ]
190 + );
64 191
65 - public function quickbuilder_setup() {
66 - $existing_plugins = betterdocs()->kbmigration->knowledge_base_plugins();
67 - $quick_setup = [
68 - 'id' => 'betterdocs_quick_setup_metabox_wrapper',
69 - 'title' => __( 'Betterdocs Quick Setup', 'betterdocs' ),
70 - 'object_types' => ['betterdocs'],
71 - 'context' => 'normal',
72 - 'priority' => 'high',
73 - 'show_header' => false,
74 - 'tab_number' => true,
75 - 'is_pro_active' => betterdocs()->is_pro_active(),
76 - 'logoURL' => betterdocs()->assets->icon( 'betterdocs-icon.svg', true ),
77 - 'layout' => 'vertical',
78 - 'values' => betterdocs()->settings->get_all(),
79 - 'config' => [
80 - 'save_locally' => true,
81 - 'save' => true,
82 - 'active' => 'getting-started',
83 - 'sidebar' => false,
84 - 'title' => false,
85 - 'tab_number' => true,
86 - 'clickable' => false,
87 - 'completionTrack' => true,
88 - 'content_heading' => [],
89 - 'step' => [
90 - 'show' => true,
91 - 'buttons' => [
92 - 'skip' => __( 'Skip This Step', 'betterdocs' ),
93 - 'prev' => __( 'Previous', 'betterdocs' ),
94 - 'next' => [
95 - 'name' => 'Next',
96 - 'type' => 'customize',
97 - 'customName' => 'Proceed to Next Step',
98 - 'condition' => 'getting-started',
99 - 'ajax' => [
100 - 'api' => "/betterdocs/v1/plugin_insights",
101 - 'data' => [
102 - 'type' => "@type",
103 - 'source' => "@source",
104 - 'field' => "product_list"
105 - ],
106 - 'rules' => Rules::is( 'active_tab', 'getting-started', false ),
107 - 'hideSwal' => true
108 - ]
109 - ],
110 - 'quick-builder-publish' => [
111 - 'name' => 'quick-builder-publish',
112 - 'type' => 'action',
113 - 'action' => 'btd_quick_build_launch'
114 - ]
115 - ],
116 - 'rules' => Rules::is( 'config.active', 'getting-started', true )
117 - ]
118 - ],
119 - 'submit' => [
120 - 'show' => false
121 - ],
122 - 'tabs' => apply_filters( 'betterdocs_quick_setup_tabs', [
123 - 'getting-started' => apply_filters( 'betterdocs_quick_setup_tab_getting_started', [
124 - 'id' => 'getting-started',
125 - 'label' => __( 'Getting Started', 'betterdocs' ),
126 - 'classes' => 'getting-started',
127 - 'priority' => 10,
128 - 'fields' => [
129 - 'getting_started_header' => [
130 - 'name' => 'getting_started_header',
131 - 'type' => 'header',
132 - 'title' => __( 'Quick Launch', 'betterdocs' ),
133 - 'direction' => 'column',
134 - 'description' => __( 'Start your Knowledge Base configuration process with an easy-to-follow setup wizard.', 'betterdocs' ),
135 - 'icon' => '<img src="' . betterdocs()->assets->icon( 'icons/rocket.svg', true ) . '"/>',
136 - 'priority' => 1
137 - ],
138 - 'betterdocs-quick-setup-start' => [
139 - 'name' => 'betterdocs-quick-setup-start',
140 - 'type' => 'section',
141 - 'priority' => 2,
142 - 'showSteps' => true,
143 - 'fields' => [
144 - 'betterdocs-quick-setup-start-collapse' => [
145 - 'name' => 'betterdocs-quick-setup-start-collapse',
146 - 'type' => 'collapse',
147 - 'priority' => 2,
148 - 'label' => __( 'By clicking this button, you are allowing this app to collect your information.', 'betterdocs' ),
149 - 'collapse_title' => __( 'What We Collect?', 'betterdocs' ),
150 - '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' )
151 - ]
152 - ]
153 - ]
154 - ]
155 - ] ),
192 + $__pages = [];
156 193
157 - 'setup-page' => apply_filters( 'betterdocs_quick_setup_tab_setup_page', [
158 - 'id' => 'setup-page',
159 - 'label' => __( 'Setup Page', 'betterdocs' ),
160 - 'classes' => 'setup-page',
161 - 'priority' => 30,
162 - 'fields' => [
163 - 'setup_page_header' => [
164 - 'name' => 'setup_page_header',
165 - 'type' => 'header',
166 - 'title' => __( 'Page Setup Magic', 'betterdocs' ),
167 - 'direction' => 'row',
168 - 'description' => __( 'Configure the structure and layout of your documentation pages to match your preferences for an organized Knowledge Base.', 'betterdocs' ),
169 - 'icon' => '<img src="' . betterdocs()->assets->icon( 'icons/content-setting.svg', true ) . '"/>',
170 - 'priority' => 1
171 - ],
172 - 'betterdocs-quick-setup-fields' => [
173 - 'name' => 'betterdocs-quick-setup-fields',
174 - 'type' => 'section',
175 - 'priority' => 2,
176 - 'fields' => [
177 - 'builtin_doc_page' => [
178 - 'name' => 'builtin_doc_page',
179 - 'type' => 'toggle',
180 - 'label' => __( 'Built-in Documentation Page', 'betterdocs' ),
181 - 'enable_disable_text_active' => true,
182 - 'default' => 1,
183 - 'priority' => 1,
184 - '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' )
185 - ],
186 - 'breadcrumb_doc_title' => [
187 - 'name' => 'breadcrumb_doc_title',
188 - 'type' => 'text',
189 - 'label' => __( 'Documentation Page Title', 'betterdocs' ),
190 - 'default' => 'Docs',
191 - 'priority' => 2
192 - ],
193 - 'permalink_structure' => [
194 - 'name' => 'permalink_structure',
195 - 'type' => 'permalink_structure',
196 - 'label' => __( 'Single Docs Permalink', 'betterdocs' ),
197 - 'default' => PostType::permalink_structure(),
198 - 'priority' => 3,
199 - 'tags' => $this->normalize_options( [
200 - '%doc_category%' => '%doc_category%',
201 - '%knowledge_base%' => '%knowledge_base%'
202 - ] ),
203 - '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' )
204 - ],
205 - 'enable_faq_schema' => [
206 - 'name' => 'enable_faq_schema',
207 - 'type' => 'toggle',
208 - 'label' => __( 'FAQ Schema', 'betterdocs' ),
209 - 'enable_disable_text_active' => true,
210 - 'default' => '',
211 - 'priority' => 4
212 - ],
213 - 'advance_search' => apply_filters( 'betterdocs_advance_search_settings', [
214 - 'name' => 'advance_search',
215 - 'type' => 'toggle',
216 - 'label' => __( 'Advanced Search', 'betterdocs' ),
217 - 'enable_disable_text_active' => true,
218 - 'default' => true,
219 - 'priority' => 5,
220 - 'is_pro' => true
221 - ] ),
222 - 'enable_disable' => [
223 - 'name' => 'enable_disable',
224 - 'type' => 'toggle',
225 - 'priority' => 6,
226 - 'label' => __( 'Instant Answer', 'betterdocs' ),
227 - 'enable_disable_text_active' => true,
228 - 'default' => true,
229 - 'is_pro' => true
230 - ]
231 - ]
232 - ]
233 - ]
234 - ] ),
235 - 'create-content' => apply_filters( 'betterdocs_quick_setup_tab_create-content', [
236 - 'id' => 'create-content',
237 - 'label' => __( 'Create Content', 'betterdocs' ),
238 - 'classes' => 'create-content',
239 - 'priority' => 40,
240 - 'fields' => [
241 - 'create_content_header' => [
242 - 'name' => 'create_content_header',
243 - 'type' => 'header',
244 - 'title' => __( 'Content Crafting', 'betterdocs' ),
245 - 'direction' => 'row',
246 - 'description' => __( 'Craft categories & articles for your Knowledge Base to efficiently organize and manage your repository with respective categories.', 'betterdocs' ),
247 - 'icon' => '<img src="' . betterdocs()->assets->icon( 'icons/create-content.svg', true ) . '"/>',
248 - 'priority' => 1
249 - ],
250 - 'create_content_video' => [
251 - 'name' => 'create_content_video',
252 - 'type' => 'image',
253 - 'media' => [
254 - 'url' => betterdocs()->assets->icon( 'setup-wizard/DocCreate.gif', true )
255 - ],
256 - 'priority' => 2
257 - ]
258 - ]
259 - ] ),
260 - 'customize' => apply_filters( 'betterdocs_quick_setup_tab_customize', [
261 - 'id' => 'customize',
262 - 'label' => __( 'Customize', 'betterdocs' ),
263 - 'classes' => 'customize',
264 - 'priority' => 50,
265 - 'fields' => [
266 - 'customize_header' => [
267 - 'name' => 'customize_header',
268 - 'type' => 'header',
269 - 'title' => __( 'Style Your Documentation', 'betterdocs' ),
270 - 'direction' => 'row',
271 - 'description' => __( 'Personalize the appearance of your documentation page, articles, and archive pages using the power of this Customizer.', 'betterdocs' ),
272 - 'icon' => '<img src="' . betterdocs()->assets->icon( 'icons/customize.svg', true ) . '"/>',
273 - 'priority' => 1
274 - ],
275 - 'customize_video' => [
276 - 'name' => 'customize_video',
277 - 'type' => 'image',
278 - 'media' => [
279 - 'url' => betterdocs()->assets->icon( 'setup-wizard/Customizer.gif', true )
280 - ],
281 - 'priority' => 2
282 - ]
283 - ]
284 - ] ),
285 - 'finalize' => apply_filters( 'betterdocs_quick_setup_tab_finalize', [
286 - 'id' => 'finalize',
287 - 'label' => __( 'Finalize', 'betterdocs' ),
288 - 'classes' => 'finalize',
289 - 'priority' => 60,
290 - 'fields' => [
291 - 'finalize_header' => [
292 - 'name' => 'finalize_header',
293 - 'type' => 'header',
294 - 'title' => __( 'Congratulations!', 'betterdocs' ),
295 - 'direction' => 'row',
296 - 'description' => __( 'Your documentation page is now ready for use. Enrich it with more articles to ensure proper categorization and valuable resources.', 'betterdocs' ),
297 - 'icon' => '<img src="' . betterdocs()->assets->icon( 'icons/thumbs-up.svg', true ) . '"/>',
298 - 'priority' => 1
299 - ],
300 - 'finalize_video' => [
301 - 'name' => 'finalize_video',
302 - 'type' => 'image',
303 - 'media' => [
304 - 'url' => betterdocs()->assets->icon( 'setup-wizard/ThankYou.gif', true )
305 - ],
306 - 'priority' => 2
307 - ]
308 - ]
309 - ] )
310 - ] )
311 - ];
194 + if ( ! empty( $_pages ) ) {
195 + $__pages[0] = __( 'Select a Page', 'betterdocs' );
196 + foreach ( $_pages->posts as $page ) {
197 + $__pages[ $page->ID ] = esc_html( $page->post_title );
198 + }
199 + }
312 200
313 - if ( $existing_plugins ) {
314 - $quick_setup['tabs']['migration'] = apply_filters( 'betterdocs_quick_setup_tab_migration', [
315 - 'id' => 'migration',
316 - 'label' => __( 'Migration', 'betterdocs' ),
317 - 'classes' => 'migration',
318 - 'priority' => 20,
319 - 'fields' => [
320 - 'migration_header' => [
321 - 'name' => 'migration_header',
322 - 'type' => 'header',
323 - 'title' => __( 'Migration', 'betterdocs' ),
324 - 'direction' => 'column',
325 - 'description' => __( 'We detected another Knoledge Base Plugin installed in this site. For BetterDocs to work efficiently, we will migrate the data from the plugin listed below, and deactivate the plugins, to avoid conflict.', 'betterdocs' ),
326 - 'icon' => '<img src="' . betterdocs()->assets->icon( 'icons/migration.svg', true ) . '"/>',
327 - 'priority' => 1,
328 - ],
329 - 'betterdocs-quick-setup-migrate' => [
330 - 'name' => 'betterdocs-quick-setup-migrate',
331 - 'type' => 'section',
332 - 'priority' => 2,
333 - 'fields' => [
334 - 'migration_step' => [
335 - 'name' => "migration_step",
336 - 'type' => 'migration',
337 - 'kb' => $existing_plugins[0][0],
338 - 'label' => __( 'Migrate ' . $existing_plugins[0][1], 'betterdocs' ),
339 - 'priority' => 10
340 - ]
341 - ]
342 - ]
343 - ]
344 - ] );
345 - }
201 + return $__pages;
202 + }
346 203
347 - return $quick_setup;
348 - }
204 + public function quickbuilder_setup() {
205 + $existing_plugins = betterdocs()->kbmigration->knowledge_base_plugins();
206 + $quick_setup = [
207 + 'id' => 'betterdocs_quick_setup_metabox_wrapper',
208 + 'title' => __( 'Betterdocs Quick Setup', 'betterdocs' ),
209 + 'object_types' => [ 'betterdocs' ],
210 + 'context' => 'normal',
211 + 'priority' => 'high',
212 + 'show_header' => false,
213 + 'tab_number' => true,
214 + 'is_pro_active' => betterdocs()->is_pro_active(),
215 + 'logoURL' => betterdocs()->assets->icon( 'betterdocs-icon.svg', true ),
216 + 'layout' => 'vertical',
217 + 'values' => betterdocs()->is_pro_active() ? array_merge( betterdocs()->settings->get_all(), [ 'enable_credit' => true ] ) : array_merge( betterdocs()->settings->get_all(), [ 'enable_credit' => true ], $this->pro_settings_default_values() ),
218 + 'config' => [
219 + 'save_locally' => true,
220 + 'save' => true,
221 + 'active' => 'getting-started',
222 + 'sidebar' => false,
223 + 'title' => false,
224 + 'tab_number' => true,
225 + 'clickable' => true,
226 + 'completionTrack' => true,
227 + 'content_heading' => [],
228 + 'step' => [
229 + 'show' => true,
230 + 'buttons' => [
231 + 'skip' => __( 'Skip for now', 'betterdocs' ),
232 + 'prev' => [
233 + 'name' => __( 'Back', 'betterdocs' ),
234 + 'type' => 'customize',
235 + 'customName' => __( 'Back', 'betterdocs' ),
236 + 'condition' => 'getting-started',
237 + ],
238 + 'start' => [
239 + 'name' => 'Start',
240 + 'type' => 'customize',
241 + 'customName' => __( 'Proceed to Next Step', 'betterdocs' ),
242 + 'condition' => 'getting-started',
243 + 'ajax' => [
244 + 'on' => 'click',
245 + 'api' => '/betterdocs/v1/plugin_insights',
246 + 'data' => [
247 + 'product_list' => 'betterdocs'
248 + ],
249 + 'hideSwal' => true
250 + ]
251 + ],
252 + 'next' => [
253 + 'name' => 'Next',
254 + 'type' => 'customize',
255 + 'customName' => __( 'Save & Continue', 'betterdocs' ),
256 + 'condition' => 'getting-started',
257 + ]
258 + ],
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 + )
270 + ]
271 + ],
272 + 'submit' => [
273 + 'show' => false
274 + ],
275 + 'tabs' => apply_filters(
276 + 'betterdocs_quick_setup_tabs',
277 + [
278 + 'getting-started' => apply_filters(
279 + 'betterdocs_quick_setup_tab_getting_started',
280 + [
281 + 'id' => 'getting-started',
282 + 'label' => __( 'Getting Started', 'betterdocs' ),
283 + 'classes' => 'getting-started',
284 + 'priority' => 10,
285 + 'fields' => [
286 + 'getting_started_header' => [
287 + 'name' => 'getting_started_header',
288 + 'type' => 'header',
289 + 'title' => __( 'Quick Launch', 'betterdocs' ),
290 + 'direction' => 'column',
291 + 'description' => __( 'Start your Knowledge Base configuration process with an easy-to-follow setup wizard.', 'betterdocs' ),
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>',
293 + 'priority' => 1
294 + ],
295 + 'betterdocs-quick-setup-start' => [
296 + 'name' => 'betterdocs-quick-setup-start',
297 + 'type' => 'section',
298 + 'priority' => 2,
299 + 'showSteps' => true,
300 + 'fields' => [
301 + 'betterdocs-quick-setup-start-collapse' => [
302 + 'name' => 'betterdocs-quick-setup-start-collapse',
303 + 'type' => 'collapse',
304 + 'priority' => 2,
305 + 'label' => __( 'By clicking this button, you are allowing this app to collect your information.', 'betterdocs' ),
306 + 'collapse_title' => __( 'What do we collect?', 'betterdocs' ),
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' )
308 + ]
309 + ]
310 + ]
311 + ]
312 + ]
313 + ),
349 314
350 - public function views() {
351 - betterdocs()->views->get( 'admin/setup-wizard' );
352 - }
315 + 'setup-page' => apply_filters(
316 + 'betterdocs_quick_setup_tab_setup_page',
317 + [
318 + 'id' => 'setup-page',
319 + 'label' => __( 'Setup Page', 'betterdocs' ),
320 + 'classes' => 'setup-page',
321 + 'priority' => 30,
322 + 'fields' => [
323 + 'setup_page_header' => [
324 + 'name' => 'setup_page_header',
325 + 'type' => 'header',
326 + 'title' => __( 'Page Setup Magic', 'betterdocs' ),
327 + 'direction' => 'row',
328 + 'description' => __( 'Configure the structure and layout of your documentation pages to match your preferences for an organized Knowledge Base.', 'betterdocs' ),
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>',
330 + 'priority' => 1
331 + ],
332 + 'betterdocs-quick-setup-fields' => [
333 + 'name' => 'betterdocs-quick-setup-fields',
334 + 'type' => 'section',
335 + 'priority' => 2,
336 + 'fields' => [
337 + 'builtin_doc_page' => [
338 + 'name' => 'builtin_doc_page',
339 + 'type' => 'toggle',
340 + 'label' => __( 'Built-in Documentation Page', 'betterdocs' ),
341 + 'enable_disable_text_active' => true,
342 + 'default' => 1,
343 + 'priority' => 1,
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 + )
349 + ],
350 + 'docs_page' => [
351 + 'name' => 'docs_page',
352 + 'label' => __( 'Docs Page', 'betterdocs' ),
353 + 'type' => 'select',
354 + 'default' => 0,
355 + 'priority' => 2,
356 + 'search' => true,
357 + 'options' => $this->normalize_options( $this->get_pages() ),
358 + 'label_subtitle' => __( 'You will need to insert BetterDocs Shortcode inside the page. This page will be used as docs permalink.', 'betterdocs' ),
359 + 'rules' => Rules::is( 'builtin_doc_page', false )
360 + ],
361 + 'breadcrumb_doc_title' => [
362 + 'name' => 'breadcrumb_doc_title',
363 + 'type' => 'text',
364 + 'label' => __( 'Documentation Page Title', 'betterdocs' ),
365 + 'default' => __( 'Docs', 'betterdocs' ),
366 + 'priority' => 3,
367 + 'rules' => Rules::is( 'builtin_doc_page', true )
368 + ],
369 + 'docs_slug' => [
370 + 'name' => 'docs_slug',
371 + 'type' => 'text',
372 + 'label' => __( 'BetterDocs Root Slug', 'betterdocs' ),
373 + 'default' => 'docs',
374 + 'priority' => 4,
375 + 'rules' => Rules::is( 'builtin_doc_page', true )
376 + ],
377 + 'permalink_structure' => [
378 + 'name' => 'permalink_structure',
379 + 'type' => 'permalink_structure',
380 + 'label' => __( 'Single Docs Permalink', 'betterdocs' ),
381 + 'default' => PostType::permalink_structure(),
382 + 'priority' => 4,
383 + 'tags' => $this->normalize_options(
384 + [
385 + '%doc_category%' => '%doc_category%',
386 + '%knowledge_base%' => '%knowledge_base%'
387 + ]
388 + ),
389 + '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' )
390 + ],
353 391
354 - public function customizer_settings_url() {
355 - $query = [
356 - 'autofocus[panel]' => 'betterdocs_customize_options',
357 - 'return' => admin_url( 'edit.php?post_type=docs' )
358 - ];
392 + 'enable_glossaries' => [
393 + 'name' => 'enable_glossaries',
394 + 'type' => 'toggle',
395 + 'label' => __( 'Show Glossary', 'betterdocs' ),
396 + 'label_subtitle' => __( 'Enable the glossary feature to allow users to look up definitions for terms used within your encyclopedia or glossaries themselves.', 'betterdocs' ),
397 + 'enable_disable_text_active' => true,
398 + 'default' => false,
399 + 'priority' => 5,
400 + 'is_pro' => true
401 + ],
402 + 'enable_encyclopedia' => [
403 + 'name' => 'enable_encyclopedia',
404 + 'type' => 'toggle',
405 + 'label' => __( 'Built-in Encyclopedia Page', 'betterdocs' ),
406 + 'enable_disable_text_active' => true,
407 + 'default' => false,
408 + 'priority' => 6,
409 + 'is_pro' => true
410 + ],
411 + 'enable_credit' => [
412 + 'name' => 'enable_credit',
413 + 'type' => 'toggle',
414 + 'label' => __( 'Show Powered by BetterDocs', 'betterdocs' ),
415 + 'enable_disable_text_active' => true,
416 + 'default' => true,
417 + 'priority' => 7
418 + ],
419 + 'enable_faq_schema' => [
420 + 'name' => 'enable_faq_schema',
421 + 'type' => 'toggle',
422 + 'label' => __( 'FAQ Schema', 'betterdocs' ),
423 + 'enable_disable_text_active' => true,
424 + 'default' => '',
425 + 'priority' => 8
426 + ],
427 + 'advance_search' => apply_filters(
428 + 'betterdocs_advance_search_settings',
429 + [
430 + 'name' => 'advance_search',
431 + 'type' => 'toggle',
432 + 'label' => __( 'Advanced Search', 'betterdocs' ),
433 + 'enable_disable_text_active' => true,
434 + 'default' => true,
435 + 'priority' => 9,
436 + 'is_pro' => true
437 + ]
438 + ),
439 + 'enable_disable' => apply_filters(
440 + 'betterdocs_setup_wizard_instant_answer',
441 + [
442 + 'name' => 'enable_disable',
443 + 'type' => 'toggle',
444 + 'priority' => 10,
445 + 'label' => __( 'Instant Answer', 'betterdocs' ),
446 + 'enable_disable_text_active' => true,
447 + 'default' => false,
448 + 'is_pro' => true
449 + ]
450 + ),
451 + ]
452 + ]
453 + ]
454 + ]
455 + ),
456 + 'create-content' => apply_filters(
457 + 'betterdocs_quick_setup_tab_create-content',
458 + [
459 + 'id' => 'create-content',
460 + 'label' => __( 'Create Content', 'betterdocs' ),
461 + 'classes' => 'create-content',
462 + 'priority' => 40,
463 + 'fields' => [
464 + 'create_content_header' => [
465 + 'name' => 'create_content_header',
466 + 'type' => 'header',
467 + 'title' => __( 'Content Crafting', 'betterdocs' ),
468 + 'direction' => 'row',
469 + 'description' => __( 'Craft categories & articles for your Knowledge Base to efficiently organize and manage your repository with respective categories.', 'betterdocs' ),
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>',
471 + 'priority' => 1
472 + ],
473 + 'create_content_generator' => [
474 + 'name' => 'create_content_generator',
475 + 'type' => 'sample_docs_generator',
476 + 'priority' => 2
477 + ]
478 + ]
479 + ]
480 + ),
481 + 'customize' => apply_filters(
482 + 'betterdocs_quick_setup_tab_customize',
483 + [
484 + 'id' => 'customize',
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' ),
491 + 'classes' => 'customize',
492 + 'priority' => 50,
493 + 'fields' => [
494 + 'customize_header' => [
495 + 'name' => 'customize_header',
496 + 'type' => 'header',
497 + 'title' => betterdocs()->helper->current_theme_is_fse_theme()
498 + ? __( 'Design Your Documentation', 'betterdocs' )
499 + : __( 'Style Your Documentation', 'betterdocs' ),
500 + 'direction' => 'row',
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>',
508 + 'priority' => 1
509 + ],
510 + 'customize_layouts' => [
511 + 'name' => 'customize_layouts',
512 + 'type' => 'layout_customizer',
513 + 'priority' => 2
514 + ]
515 + ]
516 + ]
517 + ),
518 + 'finalize' => apply_filters(
519 + 'betterdocs_quick_setup_tab_finalize',
520 + [
521 + 'id' => 'finalize',
522 + 'label' => __( 'Finalize', 'betterdocs' ),
523 + 'classes' => 'finalize',
524 + 'priority' => 60,
525 + 'fields' => [
526 + 'finalize_header' => [
527 + 'name' => 'finalize_header',
528 + 'type' => 'header',
529 + 'title' => __( 'One last step', 'betterdocs' ),
530 + 'direction' => 'row',
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>',
533 + 'priority' => 1
534 + ],
535 + 'finalize_finish' => [
536 + 'name' => 'finalize_finish',
537 + 'type' => 'finish_panel',
538 + 'priority' => 2
539 + ]
540 + ]
541 + ]
542 + )
543 + ]
544 + )
545 + ];
359 546
360 - $docs_slug = $this->settings->get( 'docs_slug', 'docs' );
361 - if ( $docs_slug ) {
362 - $query['url'] = site_url( '/' . $docs_slug );
363 - }
364 - $customizer_link = add_query_arg( $query, admin_url( 'customize.php' ) );
547 + if ( $existing_plugins ) {
548 + $quick_setup['tabs']['migration'] = apply_filters(
549 + 'betterdocs_quick_setup_tab_migration',
550 + [
551 + 'id' => 'migration',
552 + 'label' => __( 'Migration', 'betterdocs' ),
553 + 'classes' => 'migration',
554 + 'priority' => 20,
555 + 'fields' => [
556 + 'migration_header' => [
557 + 'name' => 'migration_header',
558 + 'type' => 'header',
559 + 'title' => __( 'Migration', 'betterdocs' ),
560 + 'direction' => 'column',
561 + 'description' => __( 'We detected another Knoledge Base Plugin installed in this site. For BetterDocs to work efficiently, we will migrate the data from the plugin listed below, and deactivate the plugins, to avoid conflict.', 'betterdocs' ),
562 + 'icon' => '<img src="' . betterdocs()->assets->icon( 'icons/migration.svg', true ) . '"/>',
563 + 'priority' => 1,
564 + ],
565 + 'betterdocs-quick-setup-migrate' => [
566 + 'name' => 'betterdocs-quick-setup-migrate',
567 + 'type' => 'section',
568 + 'priority' => 2,
569 + 'fields' => [
570 + 'migration_step' => [
571 + 'name' => 'migration_step',
572 + 'type' => 'migration',
573 + 'kb' => $existing_plugins[0][0],
574 + 'label' => sprintf(
575 + /* translators: %s is the name of the plugin being migrated. */
576 + __( 'Migrate %s', 'betterdocs' ),
577 + $existing_plugins[0][1]
578 + ),
579 + 'priority' => 10
580 + ]
581 + ]
582 + ]
583 + ]
584 + ]
585 + );
586 + }
365 587
366 - return esc_url( $customizer_link );
367 - }
588 + return $quick_setup;
589 + }
368 590
369 - public function docs_page_url() {
370 - return esc_url( site_url( '/' . $this->settings->get( 'docs_slug', 'docs' ) ) );
371 - }
591 + public function views() {
592 + betterdocs()->views->get( 'admin/setup-wizard' );
593 + }
594 +
595 + public function customizer_settings_url() {
596 + $query = [
597 + 'autofocus[panel]' => 'betterdocs_customize_options',
598 + 'return' => admin_url( 'edit.php?post_type=docs' )
599 + ];
600 +
601 + $docs_slug = $this->settings->get( 'docs_slug', 'docs' );
602 + if ( $docs_slug ) {
603 + $query['url'] = site_url( '/' . $docs_slug );
604 + }
605 + $customizer_link = add_query_arg( $query, admin_url( 'customize.php' ) );
606 +
607 + return esc_url( $customizer_link );
608 + }
609 +
610 + public function docs_page_url() {
611 + return esc_url( site_url( '/' . $this->settings->get( 'docs_slug', 'docs' ) ) );
612 + }
613 +
614 + /**
615 + * Call This Function As Helper, When Pro Is Deactivated, To Be Used As Settings Default Values, When Betterdocs Pro Is Deactivated
616 + *
617 + * @return array
618 + */
619 + public function pro_settings_default_values() {
620 + return [
621 + 'multiple_kb' => false,
622 + 'enable_glossaries' => false,
623 + 'enable_encyclopedia' => false,
624 + 'analytics_from' => false,
625 + 'unique_visitor_count' => false,
626 + 'exclude_bot_analytics' => false,
627 + 'show_attachment' => false,
628 + 'show_related_docs' => false,
629 + 'advance_search' => false,
630 + 'child_category_exclude' => false,
631 + 'kb_based_search' => false,
632 + 'enable_disable' => false,
633 + 'enable_content_restriction' => false
634 + ];
635 + }
372 636 }