| 1 |
<?php |
| 2 |
namespace WPDeveloper\BetterDocs\Core; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
|
| 9 |
use WPDeveloper\BetterDocs\Utils\Base; |
| 10 |
use WPDeveloper\BetterDocs\Admin\Builder\Rules; |
| 11 |
use WPDeveloper\BetterDocs\Admin\Builder\GlobalFields; |
| 12 |
|
| 13 |
class SetupWizard extends Base { |
| 14 |
private $settings; |
| 15 |
public function __construct( Settings $settings ) { |
| 16 |
$this->settings = $settings; |
| 17 |
|
| 18 |
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); |
| 19 |
} |
| 20 |
|
| 21 |
public function enqueue( $hook ) { |
| 22 |
if ( $hook !== 'betterdocs_page_betterdocs-setup' ) { |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 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(); |
| 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 |
); |
| 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' ] ); |
| 78 |
|
| 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 |
} |
| 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 |
|
| 178 |
public function normalize_options( $options ) { |
| 179 |
return GlobalFields::normalize_fields( $options ); |
| 180 |
} |
| 181 |
|
| 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 |
); |
| 191 |
|
| 192 |
$__pages = []; |
| 193 |
|
| 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 |
} |
| 200 |
|
| 201 |
return $__pages; |
| 202 |
} |
| 203 |
|
| 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 |
), |
| 314 |
|
| 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 |
], |
| 391 |
|
| 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 |
]; |
| 546 |
|
| 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 |
} |
| 587 |
|
| 588 |
return $quick_setup; |
| 589 |
} |
| 590 |
|
| 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 |
} |
| 636 |
} |
| 637 |
|