| @@ -35,15 +35,15 @@ | ||
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @var string |
| 38 | 38 | */ |
| 39 | - protected $icon = 'frm_icon_font frm_settings_icon'; | |
| 39 | + protected $icon = 'frmfont frm_settings_icon'; | |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @param array $atts |
| 43 | 43 | */ |
| 44 | 44 | public function __construct( $atts = array() ) { |
| 45 | - if ( empty( $this->plugin_slug ) ) { | |
| 45 | + if ( ! $this->plugin_slug ) { | |
| 46 | 46 | return; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | add_action( 'plugins_loaded', array( $this, 'load_hooks' ), 50 ); |
| @@ -48,9 +48,9 @@ | ||
| 48 | 48 | |
| 49 | 49 | add_action( 'plugins_loaded', array( $this, 'load_hooks' ), 50 ); |
| 50 | 50 | add_action( 'admin_init', array( $this, 'redirect' ), 9999 ); |
| 51 | 51 | |
| 52 | - if ( empty( $this->plugin_file ) ) { | |
| 52 | + if ( ! $this->plugin_file ) { | |
| 53 | 53 | $this->plugin_file = $this->plugin_slug . '.php'; |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| @@ -89,9 +89,9 @@ | ||
| 89 | 89 | * @return array |
| 90 | 90 | */ |
| 91 | 91 | public function plugin_links( $links ) { |
| 92 | 92 | if ( ! $this->is_complete() ) { |
| 93 | - $settings = '<a href="' . esc_url( $this->settings_link() ) . '">' . __( 'Setup', 'formidable' ) . '</a>'; | |
| 93 | + $settings = '<a href="' . esc_url( $this->settings_link() ) . '">' . esc_html__( 'Setup', 'formidable' ) . '</a>'; | |
| 94 | 94 | array_unshift( $links, $settings ); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | return $links; |
| @@ -107,9 +107,8 @@ | ||
| 107 | 107 | * |
| 108 | 108 | * @return void |
| 109 | 109 | */ |
| 110 | 110 | public function register() { |
| 111 | - | |
| 112 | 111 | // Getting started - shows after installation. |
| 113 | 112 | add_dashboard_page( |
| 114 | 113 | esc_html( $this->page_title() ), |
| 115 | 114 | esc_html( $this->page_title() ), |
| @@ -165,9 +164,8 @@ | ||
| 165 | 164 | * |
| 166 | 165 | * @return void |
| 167 | 166 | */ |
| 168 | 167 | public function redirect() { |
| 169 | - | |
| 170 | 168 | $current_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 171 | 169 | |
| 172 | 170 | if ( $current_page === $this->page ) { |
| 173 | 171 | // Prevent endless loop. |
| @@ -232,10 +230,9 @@ | ||
| 232 | 230 | echo '<script>window.location.replace("' . esc_url_raw( $url ) . '");</script>'; |
| 233 | 231 | return; |
| 234 | 232 | } |
| 235 | 233 | |
| 236 | - $all_imported = $this->is_complete( 'all' ); | |
| 237 | - | |
| 234 | + $all_imported = $this->is_complete( 'all' ); | |
| 238 | 235 | $step = $steps['import']; |
| 239 | 236 | $step['label'] = ''; |
| 240 | 237 | $step['nested'] = true; |
| 241 | 238 | |
| @@ -249,16 +246,20 @@ | ||
| 249 | 246 | |
| 250 | 247 | if ( $all_imported ) { |
| 251 | 248 | $step['description'] = __( 'The following form(s) have been created.', 'formidable' ); |
| 252 | 249 | } |
| 250 | + | |
| 253 | 251 | $this->show_app_install( $step ); |
| 254 | 252 | |
| 255 | - if ( ! $all_imported ) { | |
| 256 | - $step = $steps['complete']; | |
| 257 | - $step['current'] = false; | |
| 258 | - $step['button_class'] .= ' frm_grey disabled'; | |
| 259 | - $this->show_page_links( $step ); | |
| 253 | + if ( $all_imported ) { | |
| 254 | + return; | |
| 260 | 255 | } |
| 256 | + | |
| 257 | + $step = $steps['complete']; | |
| 258 | + $step['current'] = false; | |
| 259 | + $step['button_class'] .= ' frm_grey disabled'; | |
| 260 | + | |
| 261 | + $this->show_page_links( $step ); | |
| 261 | 262 | } |
| 262 | 263 | |
| 263 | 264 | /** |
| 264 | 265 | * Getting Started screen. Shows after first install. |
| @@ -288,8 +289,9 @@ | ||
| 288 | 289 | 'height' => 90, |
| 289 | 290 | 'width' => 90, |
| 290 | 291 | ); |
| 291 | 292 | |
| 293 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 292 | 294 | ?> |
| 293 | 295 | <section class="top"> |
| 294 | 296 | <div class="frm-smtp-logos"> |
| 295 | 297 | <?php FrmAppHelper::show_logo( $size ); ?> |
| @@ -313,8 +315,9 @@ | ||
| 313 | 315 | <h1><?php echo esc_html( $this->page_title() ); ?></h1> |
| 314 | 316 | <p><?php echo esc_html( $this->page_description() ); ?></p> |
| 315 | 317 | </section> |
| 316 | 318 | <?php |
| 319 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 317 | 320 | } |
| 318 | 321 | |
| 319 | 322 | /** |
| 320 | 323 | * This is the welcome page content. |
| @@ -343,9 +346,9 @@ | ||
| 343 | 346 | 'license' => array( |
| 344 | 347 | 'label' => __( 'Connect to FormidableForms.com', 'formidable' ), |
| 345 | 348 | 'description' => __( 'Create a connection to get plugin downloads.', 'formidable' ), |
| 346 | 349 | 'button_label' => __( 'Connect an Account', 'formidable' ), |
| 347 | - 'current' => empty( $pro_installed ), | |
| 350 | + 'current' => ! $pro_installed, | |
| 348 | 351 | 'complete' => $pro_installed, |
| 349 | 352 | 'num' => 1, |
| 350 | 353 | ), |
| 351 | 354 | 'plugin' => array( |
| @@ -409,9 +412,9 @@ | ||
| 409 | 412 | */ |
| 410 | 413 | protected function adjust_plugin_install_step( &$steps ) { |
| 411 | 414 | $plugins = $this->required_plugins(); |
| 412 | 415 | |
| 413 | - if ( empty( $plugins ) ) { | |
| 416 | + if ( ! $plugins ) { | |
| 414 | 417 | unset( $steps['plugin'] ); |
| 415 | 418 | $steps['import']['num'] = 2; |
| 416 | 419 | $steps['complete']['num'] = 3; |
| 417 | 420 | return; |
| @@ -434,11 +437,11 @@ | ||
| 434 | 437 | $missing[] = $plugin_key; |
| 435 | 438 | } |
| 436 | 439 | } |
| 437 | 440 | |
| 438 | - if ( empty( $rel ) && empty( $missing ) ) { | |
| 441 | + if ( ! $rel && ! $missing ) { | |
| 439 | 442 | $steps['plugin']['complete'] = true; |
| 440 | - } elseif ( ! empty( $missing ) ) { | |
| 443 | + } elseif ( $missing ) { | |
| 441 | 444 | $steps['plugin']['error'] = sprintf( |
| 442 | 445 | /* translators: %1$s: Plugin name */ |
| 443 | 446 | esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ), |
| 444 | 447 | implode( ', ', $missing ) |
| @@ -458,15 +461,16 @@ | ||
| 458 | 461 | * |
| 459 | 462 | * @return void |
| 460 | 463 | */ |
| 461 | 464 | protected function step_top( $step ) { |
| 462 | - $section_class = empty( $step['current'] ) ? 'frm_grey' : ''; | |
| 465 | + $section_class = ! empty( $step['current'] ) ? '' : 'frm_grey'; | |
| 463 | 466 | |
| 467 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 464 | 468 | ?> |
| 465 | 469 | <section class="step step-install <?php echo esc_attr( $section_class ); ?>"> |
| 466 | 470 | <aside class="num"> |
| 467 | 471 | <?php |
| 468 | - if ( isset( $step['complete'] ) && $step['complete'] ) { | |
| 472 | + if ( ! empty( $step['complete'] ) ) { | |
| 469 | 473 | FrmAppHelper::icon_by_class( |
| 470 | 474 | 'frmfont frm_step_complete_icon', |
| 471 | 475 | array( |
| 472 | 476 | /* translators: %1$s: Step number */ |
| @@ -475,9 +479,9 @@ | ||
| 475 | 479 | ) |
| 476 | 480 | ); |
| 477 | 481 | } else { |
| 478 | 482 | ?> |
| 479 | - <svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 100 100"><circle cx="50" cy="50" r="50" fill="#ccc"/><text x="50%" y="50%" text-anchor="middle" fill="#fff" stroke="#fff" stroke-width="2px" dy=".3em" font-size="3.7em"><?php echo esc_html( $step['num'] ); ?></text></svg> | |
| 483 | + <svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 100 100"><circle cx="50" cy="50" r="50" fill="#ccc"/><text x="50%" y="50%" text-anchor="middle" fill="#fff" stroke="#fff" stroke-width="2px" dy=".3em" font-size="3.7em"><?php echo esc_html( $step['num'] ); ?></text></svg><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?> | |
| 480 | 484 | <?php |
| 481 | 485 | } |
| 482 | 486 | ?> |
| 483 | 487 | <i class="loader hidden"></i> |
| @@ -490,8 +494,9 @@ | ||
| 490 | 494 | <?php if ( isset( $step['error'] ) ) { ?> |
| 491 | 495 | <p class="frm_error"><?php echo esc_html( $step['error'] ); ?></p> |
| 492 | 496 | <?php } ?> |
| 493 | 497 | <?php |
| 498 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 494 | 499 | } |
| 495 | 500 | |
| 496 | 501 | /** |
| 497 | 502 | * @param array $step Step. |
| @@ -498,12 +503,14 @@ | ||
| 498 | 503 | * |
| 499 | 504 | * @return void |
| 500 | 505 | */ |
| 501 | 506 | protected function step_bottom( $step ) { |
| 507 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 502 | 508 | ?> |
| 503 | 509 | </div> |
| 504 | 510 | </section> |
| 505 | 511 | <?php |
| 512 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 506 | 513 | } |
| 507 | 514 | |
| 508 | 515 | /** |
| 509 | 516 | * Generate and output Connect step section HTML. |
| @@ -515,13 +522,15 @@ | ||
| 515 | 522 | protected function license_box( $step ) { |
| 516 | 523 | $this->step_top( $step ); |
| 517 | 524 | |
| 518 | 525 | if ( $step['complete'] ) { |
| 526 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 519 | 527 | ?> |
| 520 | 528 | <a href="#" class="<?php echo esc_attr( $step['button_class'] ); ?>"> |
| 521 | 529 | <?php echo esc_html( $step['button_label'] ); ?> |
| 522 | 530 | </a> |
| 523 | 531 | <?php |
| 532 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 524 | 533 | } else { |
| 525 | 534 | FrmSettingsController::license_box(); |
| 526 | 535 | } |
| 527 | 536 | |
| @@ -538,13 +547,15 @@ | ||
| 538 | 547 | |
| 539 | 548 | if ( ! isset( $step['error'] ) ) { |
| 540 | 549 | $rel = $step['links'] ?? array(); |
| 541 | 550 | |
| 551 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 542 | 552 | ?> |
| 543 | 553 | <a rel="<?php echo esc_attr( implode( ',', $rel ) ); ?>" class="<?php echo esc_attr( $step['button_class'] ); ?>"> |
| 544 | 554 | <?php echo esc_html( $step['button_label'] ); ?> |
| 545 | 555 | </a> |
| 546 | 556 | <?php |
| 557 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 547 | 558 | } |
| 548 | 559 | |
| 549 | 560 | $this->step_bottom( $step ); |
| 550 | 561 | } |
| @@ -556,20 +567,20 @@ | ||
| 556 | 567 | */ |
| 557 | 568 | protected function show_app_install( $step ) { |
| 558 | 569 | $is_complete = $step['complete']; |
| 559 | 570 | |
| 560 | - if ( ! empty( $this->form_options() ) && ! $is_complete ) { | |
| 571 | + if ( $this->form_options() && ! $is_complete ) { | |
| 561 | 572 | $step['description'] = __( 'Select the form or view you would like to create.', 'formidable' ); |
| 562 | 573 | } |
| 563 | 574 | |
| 564 | 575 | $this->step_top( $step ); |
| 565 | 576 | |
| 566 | - $api = new FrmFormApi(); | |
| 567 | - $addons = $api->get_api_info(); | |
| 568 | - | |
| 577 | + $api = new FrmFormApi(); | |
| 578 | + $addons = $api->get_api_info(); | |
| 569 | 579 | $id = $this->download_id(); |
| 570 | 580 | $has_file = isset( $addons[ $id ] ) && isset( $addons[ $id ]['beta'] ); |
| 571 | 581 | |
| 582 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 572 | 583 | if ( ! $step['current'] ) { |
| 573 | 584 | ?> |
| 574 | 585 | <a href="#" class="<?php echo esc_attr( $step['button_class'] ); ?>"> |
| 575 | 586 | <?php echo esc_html( $step['button_label'] ); ?> |
| @@ -582,9 +593,9 @@ | ||
| 582 | 593 | |
| 583 | 594 | if ( ! $has_file ) { |
| 584 | 595 | echo '<p class="frm_error_style">' . esc_html__( 'We didn\'t find anything to import. Please contact our team.', 'formidable' ) . '</p>'; |
| 585 | 596 | } elseif ( ! isset( $addons[ $id ]['beta']['package'] ) ) { |
| 586 | - echo '<p class="frm_error_style">' . esc_html__( 'Looks like you may not have a current subscription for this solution. Please check your account.', 'formidable' ) . '</p>'; | |
| 597 | + echo '<p class="frm_error_style">' . esc_html__( 'Looks like you may not have a current subscription for this solution. Please check your account.', 'formidable' ) . '</p>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 587 | 598 | } else { |
| 588 | 599 | $xml = $addons[ $id ]['beta']['package']; |
| 589 | 600 | |
| 590 | 601 | if ( is_array( $xml ) ) { |
| @@ -625,8 +636,9 @@ | ||
| 625 | 636 | } else { |
| 626 | 637 | echo '</form>'; |
| 627 | 638 | } |
| 628 | 639 | }//end if |
| 640 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 629 | 641 | |
| 630 | 642 | $this->step_bottom( $step ); |
| 631 | 643 | } |
| 632 | 644 | |
| @@ -655,9 +667,9 @@ | ||
| 655 | 667 | * |
| 656 | 668 | * @return void |
| 657 | 669 | */ |
| 658 | 670 | protected function show_import_options( $options, $importing, $xml = '' ) { |
| 659 | - if ( empty( $options ) ) { | |
| 671 | + if ( ! $options ) { | |
| 660 | 672 | return; |
| 661 | 673 | } |
| 662 | 674 | |
| 663 | 675 | $imported = $this->previously_imported_forms(); |
| @@ -683,9 +695,9 @@ | ||
| 683 | 695 | */ |
| 684 | 696 | protected function show_page_options() { |
| 685 | 697 | $pages = $this->needed_pages(); |
| 686 | 698 | |
| 687 | - if ( empty( $pages ) ) { | |
| 699 | + if ( ! $pages ) { | |
| 688 | 700 | return; |
| 689 | 701 | } |
| 690 | 702 | |
| 691 | 703 | echo '<h3>Choose New Page Title</h3>'; |
| @@ -690,16 +702,18 @@ | ||
| 690 | 702 | |
| 691 | 703 | echo '<h3>Choose New Page Title</h3>'; |
| 692 | 704 | |
| 693 | 705 | foreach ( $pages as $page ) { |
| 706 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 694 | 707 | ?> |
| 695 | 708 | <p> |
| 696 | 709 | <label for="pages_<?php echo esc_html( $page['type'] ); ?>"> |
| 697 | 710 | <?php echo esc_html( $page['label'] ); ?> |
| 698 | 711 | </label> |
| 699 | - <input type="text" name="pages[<?php echo esc_html( $page['type'] ); ?>]" value="<?php echo esc_attr( $page['name'] ); ?>" id="pages_<?php echo esc_html( $page['type'] ); ?>" required /> | |
| 712 | + <input type="text" name="pages[<?php echo esc_html( $page['type'] ); ?>]" value="<?php echo esc_attr( $page['name'] ); ?>" id="pages_<?php echo esc_html( $page['type'] ); ?>" required /><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?> | |
| 700 | 713 | </p> |
| 701 | 714 | <?php |
| 715 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 702 | 716 | } |
| 703 | 717 | } |
| 704 | 718 | |
| 705 | 719 | /** |
| @@ -713,13 +727,15 @@ | ||
| 713 | 727 | } |
| 714 | 728 | |
| 715 | 729 | $this->step_top( $step ); |
| 716 | 730 | |
| 731 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 717 | 732 | ?> |
| 718 | 733 | <a href="#" target="_blank" rel="noopener" id="frm-redirect-link" class="<?php echo esc_attr( $step['button_class'] ); ?>"> |
| 719 | 734 | <?php echo esc_html( $step['button_label'] ); ?> |
| 720 | 735 | </a> |
| 721 | 736 | <?php |
| 737 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 722 | 738 | |
| 723 | 739 | $this->step_bottom( $step ); |
| 724 | 740 | } |
| 725 | 741 | |
| @@ -729,9 +745,9 @@ | ||
| 729 | 745 | * @return bool |
| 730 | 746 | */ |
| 731 | 747 | protected function is_current_plugin() { |
| 732 | 748 | $to_redirect = get_transient( FrmOnboardingWizardController::TRANSIENT_NAME ); |
| 733 | - return $to_redirect === $this->plugin_slug && empty( $this->is_complete() ); | |
| 749 | + return $to_redirect === $this->plugin_slug && ! $this->is_complete(); | |
| 734 | 750 | } |
| 735 | 751 | |
| 736 | 752 | /** |
| 737 | 753 | * Override this function to indicate when install is complete. |
| @@ -747,8 +763,9 @@ | ||
| 747 | 763 | |
| 748 | 764 | if ( $count === 'all' ) { |
| 749 | 765 | return count( $imported ) >= count( $this->form_options() ); |
| 750 | 766 | } |
| 767 | + | |
| 751 | 768 | return ! empty( $imported ); |
| 752 | 769 | } |
| 753 | 770 | |
| 754 | 771 | /** |
| @@ -757,11 +774,10 @@ | ||
| 757 | 774 | * @return array |
| 758 | 775 | */ |
| 759 | 776 | protected function previously_imported_forms() { |
| 760 | 777 | $imported = array(); |
| 761 | - $forms = $this->form_options(); | |
| 762 | 778 | |
| 763 | - foreach ( $forms as $form ) { | |
| 779 | + foreach ( $this->form_options() as $form ) { | |
| 764 | 780 | $was_imported = isset( $form['form'] ) ? FrmForm::get_id_by_key( $form['form'] ) : false; |
| 765 | 781 | |
| 766 | 782 | if ( $was_imported ) { |
| 767 | 783 | $imported[ $form['form'] ] = $was_imported; |