| @@ -3,8 +3,9 @@ | ||
| 3 | 3 | * Handles the installation of a solution and any dependencies. |
| 4 | 4 | * This page is shown when a Formidable plugin is activated. |
| 5 | 5 | * |
| 6 | 6 | * @since 4.06.02 |
| 7 | + * | |
| 7 | 8 | * @package Formidable |
| 8 | 9 | */ |
| 9 | 10 | |
| 10 | 11 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -12,10 +13,16 @@ | ||
| 12 | 13 | } |
| 13 | 14 | |
| 14 | 15 | class FrmSolution { |
| 15 | 16 | |
| 17 | + /** | |
| 18 | + * @var string | |
| 19 | + */ | |
| 16 | 20 | protected $plugin_slug = ''; |
| 17 | 21 | |
| 22 | + /** | |
| 23 | + * @var string | |
| 24 | + */ | |
| 18 | 25 | protected $plugin_file = ''; |
| 19 | 26 | |
| 20 | 27 | /** |
| 21 | 28 | * Hidden welcome page slug. |
| @@ -20,16 +27,23 @@ | ||
| 20 | 27 | /** |
| 21 | 28 | * Hidden welcome page slug. |
| 22 | 29 | * |
| 23 | 30 | * @since 4.06.02 |
| 31 | + * | |
| 24 | 32 | * @var string |
| 25 | 33 | */ |
| 26 | 34 | protected $page = ''; |
| 27 | 35 | |
| 28 | - protected $icon = 'frm_icon_font frm_settings_icon'; | |
| 36 | + /** | |
| 37 | + * @var string | |
| 38 | + */ | |
| 39 | + protected $icon = 'frmfont frm_settings_icon'; | |
| 29 | 40 | |
| 41 | + /** | |
| 42 | + * @param array $atts | |
| 43 | + */ | |
| 30 | 44 | public function __construct( $atts = array() ) { |
| 31 | - if ( empty( $this->plugin_slug ) ) { | |
| 45 | + if ( ! $this->plugin_slug ) { | |
| 32 | 46 | return; |
| 33 | 47 | } |
| 34 | 48 | |
| 35 | 49 | add_action( 'plugins_loaded', array( $this, 'load_hooks' ), 50 ); |
| @@ -34,9 +48,9 @@ | ||
| 34 | 48 | |
| 35 | 49 | add_action( 'plugins_loaded', array( $this, 'load_hooks' ), 50 ); |
| 36 | 50 | add_action( 'admin_init', array( $this, 'redirect' ), 9999 ); |
| 37 | 51 | |
| 38 | - if ( empty( $this->plugin_file ) ) { | |
| 52 | + if ( ! $this->plugin_file ) { | |
| 39 | 53 | $this->plugin_file = $this->plugin_slug . '.php'; |
| 40 | 54 | } |
| 41 | 55 | } |
| 42 | 56 | |
| @@ -68,11 +82,16 @@ | ||
| 68 | 82 | add_action( 'admin_menu', array( $this, 'register' ) ); |
| 69 | 83 | add_action( 'admin_head', array( $this, 'hide_menu' ) ); |
| 70 | 84 | } |
| 71 | 85 | |
| 86 | + /** | |
| 87 | + * @param array $links | |
| 88 | + * | |
| 89 | + * @return array | |
| 90 | + */ | |
| 72 | 91 | public function plugin_links( $links ) { |
| 73 | 92 | if ( ! $this->is_complete() ) { |
| 74 | - $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>'; | |
| 75 | 94 | array_unshift( $links, $settings ); |
| 76 | 95 | } |
| 77 | 96 | |
| 78 | 97 | return $links; |
| @@ -88,9 +107,8 @@ | ||
| 88 | 107 | * |
| 89 | 108 | * @return void |
| 90 | 109 | */ |
| 91 | 110 | public function register() { |
| 92 | - | |
| 93 | 111 | // Getting started - shows after installation. |
| 94 | 112 | add_dashboard_page( |
| 95 | 113 | esc_html( $this->page_title() ), |
| 96 | 114 | esc_html( $this->page_title() ), |
| @@ -146,10 +164,10 @@ | ||
| 146 | 164 | * |
| 147 | 165 | * @return void |
| 148 | 166 | */ |
| 149 | 167 | public function redirect() { |
| 168 | + $current_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); | |
| 150 | 169 | |
| 151 | - $current_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); | |
| 152 | 170 | if ( $current_page === $this->page ) { |
| 153 | 171 | // Prevent endless loop. |
| 154 | 172 | return; |
| 155 | 173 | } |
| @@ -179,8 +197,12 @@ | ||
| 179 | 197 | } |
| 180 | 198 | |
| 181 | 199 | /** |
| 182 | 200 | * Add page to global settings. |
| 201 | + * | |
| 202 | + * @param array $sections Sections. | |
| 203 | + * | |
| 204 | + * @return array | |
| 183 | 205 | */ |
| 184 | 206 | public function add_settings( $sections ) { |
| 185 | 207 | wp_enqueue_style( 'formidable-pro-fields' ); |
| 186 | 208 | $sections[ $this->plugin_slug ] = array( |
| @@ -200,8 +222,9 @@ | ||
| 200 | 222 | * @return void |
| 201 | 223 | */ |
| 202 | 224 | public function settings_page() { |
| 203 | 225 | $steps = $this->get_steps_data(); |
| 226 | + | |
| 204 | 227 | if ( ! $steps['license']['complete'] || ( isset( $steps['plugin'] ) && ! $steps['plugin']['complete'] ) ) { |
| 205 | 228 | // Redirect to the welcome page if install hasn't been done. |
| 206 | 229 | $url = $this->settings_link(); |
| 207 | 230 | echo '<script>window.location.replace("' . esc_url_raw( $url ) . '");</script>'; |
| @@ -207,10 +230,9 @@ | ||
| 207 | 230 | echo '<script>window.location.replace("' . esc_url_raw( $url ) . '");</script>'; |
| 208 | 231 | return; |
| 209 | 232 | } |
| 210 | 233 | |
| 211 | - $all_imported = $this->is_complete( 'all' ); | |
| 212 | - | |
| 234 | + $all_imported = $this->is_complete( 'all' ); | |
| 213 | 235 | $step = $steps['import']; |
| 214 | 236 | $step['label'] = ''; |
| 215 | 237 | $step['nested'] = true; |
| 216 | 238 | |
| @@ -220,19 +242,24 @@ | ||
| 220 | 242 | |
| 221 | 243 | $new_class = $all_imported ? ' button frm_hidden' : ''; |
| 222 | 244 | $step['button_class'] = str_replace( 'frm_grey disabled', $new_class, $step['button_class'] ); |
| 223 | 245 | } |
| 246 | + | |
| 224 | 247 | if ( $all_imported ) { |
| 225 | 248 | $step['description'] = __( 'The following form(s) have been created.', 'formidable' ); |
| 226 | 249 | } |
| 250 | + | |
| 227 | 251 | $this->show_app_install( $step ); |
| 228 | 252 | |
| 229 | - if ( ! $all_imported ) { | |
| 230 | - $step = $steps['complete']; | |
| 231 | - $step['current'] = false; | |
| 232 | - $step['button_class'] .= ' frm_grey disabled'; | |
| 233 | - $this->show_page_links( $step ); | |
| 253 | + if ( $all_imported ) { | |
| 254 | + return; | |
| 234 | 255 | } |
| 256 | + | |
| 257 | + $step = $steps['complete']; | |
| 258 | + $step['current'] = false; | |
| 259 | + $step['button_class'] .= ' frm_grey disabled'; | |
| 260 | + | |
| 261 | + $this->show_page_links( $step ); | |
| 235 | 262 | } |
| 236 | 263 | |
| 237 | 264 | /** |
| 238 | 265 | * Getting Started screen. Shows after first install. |
| @@ -262,8 +289,9 @@ | ||
| 262 | 289 | 'height' => 90, |
| 263 | 290 | 'width' => 90, |
| 264 | 291 | ); |
| 265 | 292 | |
| 293 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 266 | 294 | ?> |
| 267 | 295 | <section class="top"> |
| 268 | 296 | <div class="frm-smtp-logos"> |
| 269 | 297 | <?php FrmAppHelper::show_logo( $size ); ?> |
| @@ -287,8 +315,9 @@ | ||
| 287 | 315 | <h1><?php echo esc_html( $this->page_title() ); ?></h1> |
| 288 | 316 | <p><?php echo esc_html( $this->page_description() ); ?></p> |
| 289 | 317 | </section> |
| 290 | 318 | <?php |
| 319 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 291 | 320 | } |
| 292 | 321 | |
| 293 | 322 | /** |
| 294 | 323 | * This is the welcome page content. |
| @@ -298,8 +327,9 @@ | ||
| 298 | 327 | */ |
| 299 | 328 | protected function main_content() { |
| 300 | 329 | $steps = $this->get_steps_data(); |
| 301 | 330 | $this->license_box( $steps['license'] ); |
| 331 | + | |
| 302 | 332 | if ( isset( $steps['plugin'] ) ) { |
| 303 | 333 | $this->show_plugin_install( $steps['plugin'] ); |
| 304 | 334 | } |
| 305 | 335 | $this->show_app_install( $steps['import'] ); |
| @@ -305,8 +335,11 @@ | ||
| 305 | 335 | $this->show_app_install( $steps['import'] ); |
| 306 | 336 | $this->show_page_links( $steps['complete'] ); |
| 307 | 337 | } |
| 308 | 338 | |
| 339 | + /** | |
| 340 | + * @return array | |
| 341 | + */ | |
| 309 | 342 | protected function get_steps_data() { |
| 310 | 343 | $pro_installed = FrmAppHelper::pro_is_connected(); |
| 311 | 344 | |
| 312 | 345 | $steps = array( |
| @@ -313,9 +346,9 @@ | ||
| 313 | 346 | 'license' => array( |
| 314 | 347 | 'label' => __( 'Connect to FormidableForms.com', 'formidable' ), |
| 315 | 348 | 'description' => __( 'Create a connection to get plugin downloads.', 'formidable' ), |
| 316 | 349 | 'button_label' => __( 'Connect an Account', 'formidable' ), |
| 317 | - 'current' => empty( $pro_installed ), | |
| 350 | + 'current' => ! $pro_installed, | |
| 318 | 351 | 'complete' => $pro_installed, |
| 319 | 352 | 'num' => 1, |
| 320 | 353 | ), |
| 321 | 354 | 'plugin' => array( |
| @@ -344,8 +377,9 @@ | ||
| 344 | 377 | |
| 345 | 378 | $this->adjust_plugin_install_step( $steps ); |
| 346 | 379 | |
| 347 | 380 | $has_current = false; |
| 381 | + | |
| 348 | 382 | foreach ( $steps as $k => $step ) { |
| 349 | 383 | // Set the current step. |
| 350 | 384 | if ( ! isset( $step['current'] ) ) { |
| 351 | 385 | if ( $step['complete'] ) { |
| @@ -360,8 +394,9 @@ | ||
| 360 | 394 | |
| 361 | 395 | // Set disabled buttons. |
| 362 | 396 | $class = $step['button_class'] ?? ''; |
| 363 | 397 | $class .= ' button-primary frm-button-primary'; |
| 398 | + | |
| 364 | 399 | if ( ! $steps[ $k ]['current'] ) { |
| 365 | 400 | $class .= ' frm_grey disabled'; |
| 366 | 401 | } |
| 367 | 402 | $steps[ $k ]['button_class'] = $class; |
| @@ -376,9 +411,10 @@ | ||
| 376 | 411 | * @return void |
| 377 | 412 | */ |
| 378 | 413 | protected function adjust_plugin_install_step( &$steps ) { |
| 379 | 414 | $plugins = $this->required_plugins(); |
| 380 | - if ( empty( $plugins ) ) { | |
| 415 | + | |
| 416 | + if ( ! $plugins ) { | |
| 381 | 417 | unset( $steps['plugin'] ); |
| 382 | 418 | $steps['import']['num'] = 2; |
| 383 | 419 | $steps['complete']['num'] = 3; |
| 384 | 420 | return; |
| @@ -385,13 +421,16 @@ | ||
| 385 | 421 | } |
| 386 | 422 | |
| 387 | 423 | $missing = array(); |
| 388 | 424 | $rel = array(); |
| 425 | + | |
| 389 | 426 | foreach ( $plugins as $plugin_key ) { |
| 390 | 427 | $plugin = FrmAddonsController::install_link( $plugin_key ); |
| 428 | + | |
| 391 | 429 | if ( $plugin['status'] === 'active' ) { |
| 392 | 430 | continue; |
| 393 | 431 | } |
| 432 | + | |
| 394 | 433 | if ( isset( $plugin['url'] ) ) { |
| 395 | 434 | $rel[] = $plugin['url']; |
| 396 | 435 | } else { |
| 397 | 436 | // Add-on is required but not allowed. |
| @@ -397,11 +436,12 @@ | ||
| 397 | 436 | // Add-on is required but not allowed. |
| 398 | 437 | $missing[] = $plugin_key; |
| 399 | 438 | } |
| 400 | 439 | } |
| 401 | - if ( empty( $rel ) && empty( $missing ) ) { | |
| 440 | + | |
| 441 | + if ( ! $rel && ! $missing ) { | |
| 402 | 442 | $steps['plugin']['complete'] = true; |
| 403 | - } elseif ( ! empty( $missing ) ) { | |
| 443 | + } elseif ( $missing ) { | |
| 404 | 444 | $steps['plugin']['error'] = sprintf( |
| 405 | 445 | /* translators: %1$s: Plugin name */ |
| 406 | 446 | esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ), |
| 407 | 447 | implode( ', ', $missing ) |
| @@ -416,18 +456,21 @@ | ||
| 416 | 456 | } |
| 417 | 457 | } |
| 418 | 458 | |
| 419 | 459 | /** |
| 460 | + * @param array $step Step. | |
| 461 | + * | |
| 420 | 462 | * @return void |
| 421 | 463 | */ |
| 422 | 464 | protected function step_top( $step ) { |
| 423 | - $section_class = empty( $step['current'] ) ? 'frm_grey' : ''; | |
| 465 | + $section_class = ! empty( $step['current'] ) ? '' : 'frm_grey'; | |
| 424 | 466 | |
| 467 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 425 | 468 | ?> |
| 426 | 469 | <section class="step step-install <?php echo esc_attr( $section_class ); ?>"> |
| 427 | 470 | <aside class="num"> |
| 428 | 471 | <?php |
| 429 | - if ( isset( $step['complete'] ) && $step['complete'] ) { | |
| 472 | + if ( ! empty( $step['complete'] ) ) { | |
| 430 | 473 | FrmAppHelper::icon_by_class( |
| 431 | 474 | 'frmfont frm_step_complete_icon', |
| 432 | 475 | array( |
| 433 | 476 | /* translators: %1$s: Step number */ |
| @@ -436,9 +479,9 @@ | ||
| 436 | 479 | ) |
| 437 | 480 | ); |
| 438 | 481 | } else { |
| 439 | 482 | ?> |
| 440 | - <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 ?> | |
| 441 | 484 | <?php |
| 442 | 485 | } |
| 443 | 486 | ?> |
| 444 | 487 | <i class="loader hidden"></i> |
| @@ -451,23 +494,30 @@ | ||
| 451 | 494 | <?php if ( isset( $step['error'] ) ) { ?> |
| 452 | 495 | <p class="frm_error"><?php echo esc_html( $step['error'] ); ?></p> |
| 453 | 496 | <?php } ?> |
| 454 | 497 | <?php |
| 498 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 455 | 499 | } |
| 456 | 500 | |
| 457 | 501 | /** |
| 502 | + * @param array $step Step. | |
| 503 | + * | |
| 458 | 504 | * @return void |
| 459 | 505 | */ |
| 460 | 506 | protected function step_bottom( $step ) { |
| 507 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 461 | 508 | ?> |
| 462 | 509 | </div> |
| 463 | 510 | </section> |
| 464 | 511 | <?php |
| 512 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 465 | 513 | } |
| 466 | 514 | |
| 467 | 515 | /** |
| 468 | 516 | * Generate and output Connect step section HTML. |
| 469 | 517 | * |
| 518 | + * @param array $step Step. | |
| 519 | + * | |
| 470 | 520 | * @return void |
| 471 | 521 | */ |
| 472 | 522 | protected function license_box( $step ) { |
| 473 | 523 | $this->step_top( $step ); |
| @@ -472,13 +522,15 @@ | ||
| 472 | 522 | protected function license_box( $step ) { |
| 473 | 523 | $this->step_top( $step ); |
| 474 | 524 | |
| 475 | 525 | if ( $step['complete'] ) { |
| 526 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 476 | 527 | ?> |
| 477 | 528 | <a href="#" class="<?php echo esc_attr( $step['button_class'] ); ?>"> |
| 478 | 529 | <?php echo esc_html( $step['button_label'] ); ?> |
| 479 | 530 | </a> |
| 480 | 531 | <?php |
| 532 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 481 | 533 | } else { |
| 482 | 534 | FrmSettingsController::license_box(); |
| 483 | 535 | } |
| 484 | 536 | |
| @@ -485,8 +537,10 @@ | ||
| 485 | 537 | $this->step_bottom( $step ); |
| 486 | 538 | } |
| 487 | 539 | |
| 488 | 540 | /** |
| 541 | + * @param array $step Step. | |
| 542 | + * | |
| 489 | 543 | * @return void |
| 490 | 544 | */ |
| 491 | 545 | protected function show_plugin_install( $step ) { |
| 492 | 546 | $this->step_top( $step ); |
| @@ -493,13 +547,15 @@ | ||
| 493 | 547 | |
| 494 | 548 | if ( ! isset( $step['error'] ) ) { |
| 495 | 549 | $rel = $step['links'] ?? array(); |
| 496 | 550 | |
| 551 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 497 | 552 | ?> |
| 498 | 553 | <a rel="<?php echo esc_attr( implode( ',', $rel ) ); ?>" class="<?php echo esc_attr( $step['button_class'] ); ?>"> |
| 499 | 554 | <?php echo esc_html( $step['button_label'] ); ?> |
| 500 | 555 | </a> |
| 501 | 556 | <?php |
| 557 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 502 | 558 | } |
| 503 | 559 | |
| 504 | 560 | $this->step_bottom( $step ); |
| 505 | 561 | } |
| @@ -504,24 +560,27 @@ | ||
| 504 | 560 | $this->step_bottom( $step ); |
| 505 | 561 | } |
| 506 | 562 | |
| 507 | 563 | /** |
| 564 | + * @param array $step Step. | |
| 565 | + * | |
| 508 | 566 | * @return void |
| 509 | 567 | */ |
| 510 | 568 | protected function show_app_install( $step ) { |
| 511 | 569 | $is_complete = $step['complete']; |
| 512 | - if ( ! empty( $this->form_options() ) && ! $is_complete ) { | |
| 570 | + | |
| 571 | + if ( $this->form_options() && ! $is_complete ) { | |
| 513 | 572 | $step['description'] = __( 'Select the form or view you would like to create.', 'formidable' ); |
| 514 | 573 | } |
| 515 | 574 | |
| 516 | 575 | $this->step_top( $step ); |
| 517 | 576 | |
| 518 | - $api = new FrmFormApi(); | |
| 519 | - $addons = $api->get_api_info(); | |
| 520 | - | |
| 577 | + $api = new FrmFormApi(); | |
| 578 | + $addons = $api->get_api_info(); | |
| 521 | 579 | $id = $this->download_id(); |
| 522 | 580 | $has_file = isset( $addons[ $id ] ) && isset( $addons[ $id ]['beta'] ); |
| 523 | 581 | |
| 582 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 524 | 583 | if ( ! $step['current'] ) { |
| 525 | 584 | ?> |
| 526 | 585 | <a href="#" class="<?php echo esc_attr( $step['button_class'] ); ?>"> |
| 527 | 586 | <?php echo esc_html( $step['button_label'] ); ?> |
| @@ -534,11 +593,12 @@ | ||
| 534 | 593 | |
| 535 | 594 | if ( ! $has_file ) { |
| 536 | 595 | echo '<p class="frm_error_style">' . esc_html__( 'We didn\'t find anything to import. Please contact our team.', 'formidable' ) . '</p>'; |
| 537 | 596 | } elseif ( ! isset( $addons[ $id ]['beta']['package'] ) ) { |
| 538 | - 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 | |
| 539 | 598 | } else { |
| 540 | 599 | $xml = $addons[ $id ]['beta']['package']; |
| 600 | + | |
| 541 | 601 | if ( is_array( $xml ) ) { |
| 542 | 602 | $xml = reset( $xml ); |
| 543 | 603 | } |
| 544 | 604 | |
| @@ -576,13 +636,16 @@ | ||
| 576 | 636 | } else { |
| 577 | 637 | echo '</form>'; |
| 578 | 638 | } |
| 579 | 639 | }//end if |
| 640 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 580 | 641 | |
| 581 | 642 | $this->step_bottom( $step ); |
| 582 | 643 | } |
| 583 | 644 | |
| 584 | 645 | /** |
| 646 | + * @param string $xml | |
| 647 | + * | |
| 585 | 648 | * @return void |
| 586 | 649 | */ |
| 587 | 650 | protected function show_form_options( $xml ) { |
| 588 | 651 | $this->show_import_options( $this->form_options(), 'form', $xml ); |
| @@ -604,14 +667,15 @@ | ||
| 604 | 667 | * |
| 605 | 668 | * @return void |
| 606 | 669 | */ |
| 607 | 670 | protected function show_import_options( $options, $importing, $xml = '' ) { |
| 608 | - if ( empty( $options ) ) { | |
| 671 | + if ( ! $options ) { | |
| 609 | 672 | return; |
| 610 | 673 | } |
| 611 | 674 | |
| 612 | 675 | $imported = $this->previously_imported_forms(); |
| 613 | 676 | $count = count( $options ); |
| 677 | + | |
| 614 | 678 | foreach ( $options as $info ) { |
| 615 | 679 | // Count the number of options displayed for css. |
| 616 | 680 | if ( $count > 1 && ! isset( $info['img'] ) ) { |
| 617 | 681 | --$count; |
| @@ -616,8 +680,9 @@ | ||
| 616 | 680 | if ( $count > 1 && ! isset( $info['img'] ) ) { |
| 617 | 681 | --$count; |
| 618 | 682 | } |
| 619 | 683 | } |
| 684 | + | |
| 620 | 685 | $width = floor( ( 533 - ( ( $count - 1 ) * 20 ) ) / $count ); |
| 621 | 686 | unset( $count ); |
| 622 | 687 | |
| 623 | 688 | $selected = false; |
| @@ -629,26 +694,32 @@ | ||
| 629 | 694 | * @return void |
| 630 | 695 | */ |
| 631 | 696 | protected function show_page_options() { |
| 632 | 697 | $pages = $this->needed_pages(); |
| 633 | - if ( empty( $pages ) ) { | |
| 698 | + | |
| 699 | + if ( ! $pages ) { | |
| 634 | 700 | return; |
| 635 | 701 | } |
| 636 | 702 | |
| 637 | 703 | echo '<h3>Choose New Page Title</h3>'; |
| 704 | + | |
| 638 | 705 | foreach ( $pages as $page ) { |
| 706 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 639 | 707 | ?> |
| 640 | 708 | <p> |
| 641 | 709 | <label for="pages_<?php echo esc_html( $page['type'] ); ?>"> |
| 642 | 710 | <?php echo esc_html( $page['label'] ); ?> |
| 643 | 711 | </label> |
| 644 | - <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 ?> | |
| 645 | 713 | </p> |
| 646 | 714 | <?php |
| 715 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 647 | 716 | } |
| 648 | 717 | } |
| 649 | 718 | |
| 650 | 719 | /** |
| 720 | + * @param array $step | |
| 721 | + * | |
| 651 | 722 | * @return void |
| 652 | 723 | */ |
| 653 | 724 | protected function show_page_links( $step ) { |
| 654 | 725 | if ( $step['current'] ) { |
| @@ -656,13 +727,15 @@ | ||
| 656 | 727 | } |
| 657 | 728 | |
| 658 | 729 | $this->step_top( $step ); |
| 659 | 730 | |
| 731 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 660 | 732 | ?> |
| 661 | 733 | <a href="#" target="_blank" rel="noopener" id="frm-redirect-link" class="<?php echo esc_attr( $step['button_class'] ); ?>"> |
| 662 | 734 | <?php echo esc_html( $step['button_label'] ); ?> |
| 663 | 735 | </a> |
| 664 | 736 | <?php |
| 737 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 665 | 738 | |
| 666 | 739 | $this->step_bottom( $step ); |
| 667 | 740 | } |
| 668 | 741 | |
| @@ -672,9 +745,9 @@ | ||
| 672 | 745 | * @return bool |
| 673 | 746 | */ |
| 674 | 747 | protected function is_current_plugin() { |
| 675 | 748 | $to_redirect = get_transient( FrmOnboardingWizardController::TRANSIENT_NAME ); |
| 676 | - return $to_redirect === $this->plugin_slug && empty( $this->is_complete() ); | |
| 749 | + return $to_redirect === $this->plugin_slug && ! $this->is_complete(); | |
| 677 | 750 | } |
| 678 | 751 | |
| 679 | 752 | /** |
| 680 | 753 | * Override this function to indicate when install is complete. |
| @@ -686,11 +759,13 @@ | ||
| 686 | 759 | * @return bool |
| 687 | 760 | */ |
| 688 | 761 | protected function is_complete( $count = 1 ) { |
| 689 | 762 | $imported = $this->previously_imported_forms(); |
| 763 | + | |
| 690 | 764 | if ( $count === 'all' ) { |
| 691 | 765 | return count( $imported ) >= count( $this->form_options() ); |
| 692 | 766 | } |
| 767 | + | |
| 693 | 768 | return ! empty( $imported ); |
| 694 | 769 | } |
| 695 | 770 | |
| 696 | 771 | /** |
| @@ -699,11 +774,12 @@ | ||
| 699 | 774 | * @return array |
| 700 | 775 | */ |
| 701 | 776 | protected function previously_imported_forms() { |
| 702 | 777 | $imported = array(); |
| 703 | - $forms = $this->form_options(); | |
| 704 | - foreach ( $forms as $form ) { | |
| 778 | + | |
| 779 | + foreach ( $this->form_options() as $form ) { | |
| 705 | 780 | $was_imported = isset( $form['form'] ) ? FrmForm::get_id_by_key( $form['form'] ) : false; |
| 781 | + | |
| 706 | 782 | if ( $was_imported ) { |
| 707 | 783 | $imported[ $form['form'] ] = $was_imported; |
| 708 | 784 | } |
| 709 | 785 | } |