| @@ -93,8 +93,9 @@ | ||
| 93 | 93 | return false; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | self::$checklist = self::get_checklist(); |
| 97 | + | |
| 97 | 98 | if ( |
| 98 | 99 | self::is_tour_completed() && ( ! empty( self::$checklist['completed_seen'] ) || ! self::get_current_form_id() ) |
| 99 | 100 | || ! empty( self::$checklist['dismissed'] ) |
| 100 | 101 | ) { |
| @@ -101,8 +102,9 @@ | ||
| 101 | 102 | return false; |
| 102 | 103 | } |
| 103 | 104 | |
| 104 | 105 | self::$is_dashboard_page = FrmDashboardController::is_dashboard_page(); |
| 106 | + | |
| 105 | 107 | if ( self::$is_dashboard_page ) { |
| 106 | 108 | return empty( self::$checklist['seen'] ); |
| 107 | 109 | } |
| 108 | 110 | |
| @@ -197,8 +199,9 @@ | ||
| 197 | 199 | * Fills the steps with the completed data. |
| 198 | 200 | * |
| 199 | 201 | * @param array $steps The steps to fill. |
| 200 | 202 | * @param array $steps_keys The steps keys. |
| 203 | + * | |
| 201 | 204 | * @return array The steps with the completed data. |
| 202 | 205 | */ |
| 203 | 206 | private static function fill_step_completed_data( $steps, $steps_keys ) { |
| 204 | 207 | return array_map( |
| @@ -299,8 +302,10 @@ | ||
| 299 | 302 | /** |
| 300 | 303 | * Shows links after completing the Welcome tour. |
| 301 | 304 | * |
| 302 | 305 | * @param int $current_form_id Current form ID. |
| 306 | + * | |
| 307 | + * @return void | |
| 303 | 308 | */ |
| 304 | 309 | public static function show_completed_links( $current_form_id ) { |
| 305 | 310 | $links = array( |
| 306 | 311 | 'setup-email-notification' => array( |
| @@ -329,13 +334,15 @@ | ||
| 329 | 334 | ); |
| 330 | 335 | |
| 331 | 336 | foreach ( $links as $key => $link ) { |
| 332 | 337 | $attrs = $button_attrs + array( 'data-tracking-value' => $key ); |
| 338 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 333 | 339 | ?> |
| 334 | 340 | <a href="<?php echo esc_url( $link['url'] ); ?>" <?php FrmAppHelper::array_to_html_params( $attrs, true ); ?>> |
| 335 | 341 | <?php echo esc_html( $link['text'] ); ?> |
| 336 | 342 | </a> |
| 337 | 343 | <?php |
| 344 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 338 | 345 | } |
| 339 | 346 | } |
| 340 | 347 | |
| 341 | 348 | /** |
| @@ -352,9 +359,8 @@ | ||
| 352 | 359 | $active_step = self::$checklist['active_step_key']; |
| 353 | 360 | $page = FrmAppHelper::simple_get( 'page' ); |
| 354 | 361 | $is_form_templates_page = FrmFormTemplatesController::PAGE_SLUG === $page; |
| 355 | 362 | $is_form_builder_page = FrmAppHelper::is_form_builder_page(); |
| 356 | - $is_style_editor_page = FrmAppHelper::is_style_editor_page(); | |
| 357 | 363 | |
| 358 | 364 | switch ( $active_step ) { |
| 359 | 365 | case 'create-form': |
| 360 | 366 | return $is_form_templates_page; |
| @@ -362,9 +368,9 @@ | ||
| 362 | 368 | return $is_form_builder_page; |
| 363 | 369 | case 'style-form': |
| 364 | 370 | case 'embed-form': |
| 365 | 371 | case 'completed': |
| 366 | - return $is_form_builder_page || $is_style_editor_page; | |
| 372 | + return $is_form_builder_page || FrmAppHelper::is_style_editor_page(); | |
| 367 | 373 | default: |
| 368 | 374 | return false; |
| 369 | 375 | } |
| 370 | 376 | } |
| @@ -378,8 +384,9 @@ | ||
| 378 | 384 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 379 | 385 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 380 | 386 | |
| 381 | 387 | $step_key = FrmAppHelper::get_post_param( 'step_key' ); |
| 388 | + | |
| 382 | 389 | if ( ! $step_key ) { |
| 383 | 390 | wp_send_json_error( __( 'Invalid step', 'formidable' ) ); |
| 384 | 391 | } |
| 385 | 392 | |
| @@ -412,8 +419,9 @@ | ||
| 412 | 419 | * @return bool True if more than the default form exists, false otherwise. |
| 413 | 420 | */ |
| 414 | 421 | private static function more_than_the_default_form_exists() { |
| 415 | 422 | $form_keys = FrmDb::get_col( 'frm_forms', array(), 'form_key' ); |
| 423 | + | |
| 416 | 424 | if ( count( $form_keys ) > 1 ) { |
| 417 | 425 | return true; |
| 418 | 426 | } |
| 419 | 427 | |
| @@ -457,8 +465,9 @@ | ||
| 457 | 465 | /** |
| 458 | 466 | * Adds custom classes to the existing string of admin body classes. |
| 459 | 467 | * |
| 460 | 468 | * @param string $classes Existing body classes. |
| 469 | + * | |
| 461 | 470 | * @return string Updated list of body classes, including the newly added classes. |
| 462 | 471 | */ |
| 463 | 472 | public static function add_admin_body_classes( $classes ) { |
| 464 | 473 | return $classes . ' frm-admin-welcome-tour'; |
| @@ -515,8 +524,10 @@ | ||
| 515 | 524 | /** |
| 516 | 525 | * Saves the checklist data. |
| 517 | 526 | * |
| 518 | 527 | * @param array|null $checklist The checklist data to set. |
| 528 | + * | |
| 529 | + * @return void | |
| 519 | 530 | */ |
| 520 | 531 | public static function save_checklist( $checklist = null ) { |
| 521 | 532 | update_option( self::CHECKLIST_OPTION, $checklist ?? self::$checklist, false ); |
| 522 | 533 | } |
| @@ -539,18 +550,19 @@ | ||
| 539 | 550 | /** |
| 540 | 551 | * Build a tracked URL with UTM parameters and affiliate tracking. |
| 541 | 552 | * |
| 542 | 553 | * @param string $url The base URL to process. |
| 554 | + * | |
| 543 | 555 | * @return string The processed URL with UTM parameters and affiliate tracking. |
| 544 | 556 | */ |
| 545 | 557 | public static function make_tracked_url( $url ) { |
| 546 | - $utm_params = array( | |
| 547 | - 'utm_source' => 'WordPress', | |
| 548 | - 'utm_medium' => 'welcome-tour', | |
| 549 | - 'utm_campaign' => 'liteplugin', | |
| 558 | + $url = FrmAppHelper::maybe_add_missing_utm( | |
| 559 | + $url, | |
| 560 | + array( | |
| 561 | + 'campaign' => 'welcome-tour', | |
| 562 | + ) | |
| 550 | 563 | ); |
| 551 | - | |
| 552 | - return FrmAppHelper::make_affiliate_url( add_query_arg( $utm_params, $url ) ); | |
| 564 | + return FrmAppHelper::make_affiliate_url( $url ); | |
| 553 | 565 | } |
| 554 | 566 | |
| 555 | 567 | /** |
| 556 | 568 | * Get the current form ID. |
| @@ -562,8 +574,9 @@ | ||
| 562 | 574 | return self::$current_form_id; |
| 563 | 575 | } |
| 564 | 576 | |
| 565 | 577 | self::$current_form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 ); |
| 578 | + | |
| 566 | 579 | if ( ! self::$current_form_id ) { |
| 567 | 580 | self::$current_form_id = FrmAppHelper::simple_get( 'id', 'absint', 0 ); |
| 568 | 581 | } |
| 569 | 582 | |
| @@ -600,8 +613,9 @@ | ||
| 600 | 613 | */ |
| 601 | 614 | public static function get_usage_data() { |
| 602 | 615 | // Do not use the get_checklist() method to prevent adding default value. |
| 603 | 616 | $option = get_option( self::CHECKLIST_OPTION ); |
| 617 | + | |
| 604 | 618 | if ( ! $option ) { |
| 605 | 619 | // Welcome tour doesn't show on this site. |
| 606 | 620 | return array(); |
| 607 | 621 | } |
| @@ -606,11 +620,10 @@ | ||
| 606 | 620 | return array(); |
| 607 | 621 | } |
| 608 | 622 | |
| 609 | 623 | $usage_data = array(); |
| 610 | - $steps = self::get_steps(); | |
| 611 | 624 | |
| 612 | - foreach ( $steps as $key => $step ) { | |
| 625 | + foreach ( self::get_steps() as $key => $step ) { | |
| 613 | 626 | $usage_data[ 'completed_step_' . $key ] = empty( $option['completed_steps'][ $key ] ) ? 0 : 1; |
| 614 | 627 | } |
| 615 | 628 | |
| 616 | 629 | $usage_data['done'] = empty( $option['done'] ) ? 0 : 1; |