PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.18
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.18
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmSolution.php +19 -76 6.276.18 View file →
@@ -3,9 +3,8 @@
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 - *
8 7 * @package Formidable
9 8 */
10 9
11 10 if ( ! defined( 'ABSPATH' ) ) {
@@ -13,16 +12,10 @@
13 12 }
14 13
15 14 class FrmSolution {
16 15
17 - /**
18 - * @var string
19 - */
20 16 protected $plugin_slug = '';
21 17
22 - /**
23 - * @var string
24 - */
25 18 protected $plugin_file = '';
26 19
27 20 /**
28 21 * Hidden welcome page slug.
@@ -27,21 +20,14 @@
27 20 /**
28 21 * Hidden welcome page slug.
29 22 *
30 23 * @since 4.06.02
31 - *
32 24 * @var string
33 25 */
34 26 protected $page = '';
35 27
36 - /**
37 - * @var string
38 - */
39 - protected $icon = 'frmfont frm_settings_icon';
28 + protected $icon = 'frm_icon_font frm_settings_icon';
40 29
41 - /**
42 - * @param array $atts
43 - */
44 30 public function __construct( $atts = array() ) {
45 31 if ( empty( $this->plugin_slug ) ) {
46 32 return;
47 33 }
@@ -82,13 +68,8 @@
82 68 add_action( 'admin_menu', array( $this, 'register' ) );
83 69 add_action( 'admin_head', array( $this, 'hide_menu' ) );
84 70 }
85 71
86 - /**
87 - * @param array $links
88 - *
89 - * @return array
90 - */
91 72 public function plugin_links( $links ) {
92 73 if ( ! $this->is_complete() ) {
93 74 $settings = '<a href="' . esc_url( $this->settings_link() ) . '">' . __( 'Setup', 'formidable' ) . '</a>';
94 75 array_unshift( $links, $settings );
@@ -107,8 +88,9 @@
107 88 *
108 89 * @return void
109 90 */
110 91 public function register() {
92 +
111 93 // Getting started - shows after installation.
112 94 add_dashboard_page(
113 95 esc_html( $this->page_title() ),
114 96 esc_html( $this->page_title() ),
@@ -164,10 +146,10 @@
164 146 *
165 147 * @return void
166 148 */
167 149 public function redirect() {
150 +
168 151 $current_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
169 -
170 152 if ( $current_page === $this->page ) {
171 153 // Prevent endless loop.
172 154 return;
173 155 }
@@ -197,12 +179,8 @@
197 179 }
198 180
199 181 /**
200 182 * Add page to global settings.
201 - *
202 - * @param array $sections Sections.
203 - *
204 - * @return array
205 183 */
206 184 public function add_settings( $sections ) {
207 185 wp_enqueue_style( 'formidable-pro-fields' );
208 186 $sections[ $this->plugin_slug ] = array(
@@ -222,9 +200,8 @@
222 200 * @return void
223 201 */
224 202 public function settings_page() {
225 203 $steps = $this->get_steps_data();
226 -
227 204 if ( ! $steps['license']['complete'] || ( isset( $steps['plugin'] ) && ! $steps['plugin']['complete'] ) ) {
228 205 // Redirect to the welcome page if install hasn't been done.
229 206 $url = $this->settings_link();
230 207 echo '<script>window.location.replace("' . esc_url_raw( $url ) . '");</script>';
@@ -230,9 +207,10 @@
230 207 echo '<script>window.location.replace("' . esc_url_raw( $url ) . '");</script>';
231 208 return;
232 209 }
233 210
234 - $all_imported = $this->is_complete( 'all' );
211 + $all_imported = $this->is_complete( 'all' );
212 +
235 213 $step = $steps['import'];
236 214 $step['label'] = '';
237 215 $step['nested'] = true;
238 216
@@ -242,9 +220,8 @@
242 220
243 221 $new_class = $all_imported ? ' button frm_hidden' : '';
244 222 $step['button_class'] = str_replace( 'frm_grey disabled', $new_class, $step['button_class'] );
245 223 }
246 -
247 224 if ( $all_imported ) {
248 225 $step['description'] = __( 'The following form(s) have been created.', 'formidable' );
249 226 }
250 227 $this->show_app_install( $step );
@@ -321,9 +298,8 @@
321 298 */
322 299 protected function main_content() {
323 300 $steps = $this->get_steps_data();
324 301 $this->license_box( $steps['license'] );
325 -
326 302 if ( isset( $steps['plugin'] ) ) {
327 303 $this->show_plugin_install( $steps['plugin'] );
328 304 }
329 305 $this->show_app_install( $steps['import'] );
@@ -329,11 +305,8 @@
329 305 $this->show_app_install( $steps['import'] );
330 306 $this->show_page_links( $steps['complete'] );
331 307 }
332 308
333 - /**
334 - * @return array
335 - */
336 309 protected function get_steps_data() {
337 310 $pro_installed = FrmAppHelper::pro_is_connected();
338 311
339 312 $steps = array(
@@ -371,9 +344,8 @@
371 344
372 345 $this->adjust_plugin_install_step( $steps );
373 346
374 347 $has_current = false;
375 -
376 348 foreach ( $steps as $k => $step ) {
377 349 // Set the current step.
378 350 if ( ! isset( $step['current'] ) ) {
379 351 if ( $step['complete'] ) {
@@ -386,11 +358,10 @@
386 358 $has_current = true;
387 359 }
388 360
389 361 // Set disabled buttons.
390 - $class = $step['button_class'] ?? '';
362 + $class = isset( $step['button_class'] ) ? $step['button_class'] : '';
391 363 $class .= ' button-primary frm-button-primary';
392 -
393 364 if ( ! $steps[ $k ]['current'] ) {
394 365 $class .= ' frm_grey disabled';
395 366 }
396 367 $steps[ $k ]['button_class'] = $class;
@@ -405,10 +376,9 @@
405 376 * @return void
406 377 */
407 378 protected function adjust_plugin_install_step( &$steps ) {
408 379 $plugins = $this->required_plugins();
409 -
410 - if ( ! $plugins ) {
380 + if ( empty( $plugins ) ) {
411 381 unset( $steps['plugin'] );
412 382 $steps['import']['num'] = 2;
413 383 $steps['complete']['num'] = 3;
414 384 return;
@@ -415,16 +385,13 @@
415 385 }
416 386
417 387 $missing = array();
418 388 $rel = array();
419 -
420 389 foreach ( $plugins as $plugin_key ) {
421 390 $plugin = FrmAddonsController::install_link( $plugin_key );
422 -
423 391 if ( $plugin['status'] === 'active' ) {
424 392 continue;
425 393 }
426 -
427 394 if ( isset( $plugin['url'] ) ) {
428 395 $rel[] = $plugin['url'];
429 396 } else {
430 397 // Add-on is required but not allowed.
@@ -430,12 +397,11 @@
430 397 // Add-on is required but not allowed.
431 398 $missing[] = $plugin_key;
432 399 }
433 400 }
434 -
435 - if ( ! $rel && ! $missing ) {
401 + if ( empty( $rel ) && empty( $missing ) ) {
436 402 $steps['plugin']['complete'] = true;
437 - } elseif ( $missing ) {
403 + } elseif ( ! empty( $missing ) ) {
438 404 $steps['plugin']['error'] = sprintf(
439 405 /* translators: %1$s: Plugin name */
440 406 esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ),
441 407 implode( ', ', $missing )
@@ -450,10 +416,8 @@
450 416 }
451 417 }
452 418
453 419 /**
454 - * @param array $step Step.
455 - *
456 420 * @return void
457 421 */
458 422 protected function step_top( $step ) {
459 423 $section_class = empty( $step['current'] ) ? 'frm_grey' : '';
@@ -461,9 +425,9 @@
461 425 ?>
462 426 <section class="step step-install <?php echo esc_attr( $section_class ); ?>">
463 427 <aside class="num">
464 428 <?php
465 - if ( ! empty( $step['complete'] ) ) {
429 + if ( isset( $step['complete'] ) && $step['complete'] ) {
466 430 FrmAppHelper::icon_by_class(
467 431 'frmfont frm_step_complete_icon',
468 432 array(
469 433 /* translators: %1$s: Step number */
@@ -472,9 +436,9 @@
472 436 )
473 437 );
474 438 } else {
475 439 ?>
476 - <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 ?>
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>
477 441 <?php
478 442 }
479 443 ?>
480 444 <i class="loader hidden"></i>
@@ -490,10 +454,8 @@
490 454 <?php
491 455 }
492 456
493 457 /**
494 - * @param array $step Step.
495 - *
496 458 * @return void
497 459 */
498 460 protected function step_bottom( $step ) {
499 461 ?>
@@ -504,10 +466,8 @@
504 466
505 467 /**
506 468 * Generate and output Connect step section HTML.
507 469 *
508 - * @param array $step Step.
509 - *
510 470 * @return void
511 471 */
512 472 protected function license_box( $step ) {
513 473 $this->step_top( $step );
@@ -525,10 +485,8 @@
525 485 $this->step_bottom( $step );
526 486 }
527 487
528 488 /**
529 - * @param array $step Step.
530 - *
531 489 * @return void
532 490 */
533 491 protected function show_plugin_install( $step ) {
534 492 $this->step_top( $step );
@@ -533,9 +491,9 @@
533 491 protected function show_plugin_install( $step ) {
534 492 $this->step_top( $step );
535 493
536 494 if ( ! isset( $step['error'] ) ) {
537 - $rel = $step['links'] ?? array();
495 + $rel = isset( $step['links'] ) ? $step['links'] : array();
538 496
539 497 ?>
540 498 <a rel="<?php echo esc_attr( implode( ',', $rel ) ); ?>" class="<?php echo esc_attr( $step['button_class'] ); ?>">
541 499 <?php echo esc_html( $step['button_label'] ); ?>
@@ -546,15 +504,12 @@
546 504 $this->step_bottom( $step );
547 505 }
548 506
549 507 /**
550 - * @param array $step Step.
551 - *
552 508 * @return void
553 509 */
554 510 protected function show_app_install( $step ) {
555 511 $is_complete = $step['complete'];
556 -
557 512 if ( ! empty( $this->form_options() ) && ! $is_complete ) {
558 513 $step['description'] = __( 'Select the form or view you would like to create.', 'formidable' );
559 514 }
560 515
@@ -559,10 +514,11 @@
559 514 }
560 515
561 516 $this->step_top( $step );
562 517
563 - $api = new FrmFormApi();
564 - $addons = $api->get_api_info();
518 + $api = new FrmFormApi();
519 + $addons = $api->get_api_info();
520 +
565 521 $id = $this->download_id();
566 522 $has_file = isset( $addons[ $id ] ) && isset( $addons[ $id ]['beta'] );
567 523
568 524 if ( ! $step['current'] ) {
@@ -578,12 +534,11 @@
578 534
579 535 if ( ! $has_file ) {
580 536 echo '<p class="frm_error_style">' . esc_html__( 'We didn\'t find anything to import. Please contact our team.', 'formidable' ) . '</p>';
581 537 } elseif ( ! isset( $addons[ $id ]['beta']['package'] ) ) {
582 - 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
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>';
583 539 } else {
584 540 $xml = $addons[ $id ]['beta']['package'];
585 -
586 541 if ( is_array( $xml ) ) {
587 542 $xml = reset( $xml );
588 543 }
589 544
@@ -626,10 +581,8 @@
626 581 $this->step_bottom( $step );
627 582 }
628 583
629 584 /**
630 - * @param string $xml
631 - *
632 585 * @return void
633 586 */
634 587 protected function show_form_options( $xml ) {
635 588 $this->show_import_options( $this->form_options(), 'form', $xml );
@@ -651,15 +604,14 @@
651 604 *
652 605 * @return void
653 606 */
654 607 protected function show_import_options( $options, $importing, $xml = '' ) {
655 - if ( ! $options ) {
608 + if ( empty( $options ) ) {
656 609 return;
657 610 }
658 611
659 612 $imported = $this->previously_imported_forms();
660 613 $count = count( $options );
661 -
662 614 foreach ( $options as $info ) {
663 615 // Count the number of options displayed for css.
664 616 if ( $count > 1 && ! isset( $info['img'] ) ) {
665 617 --$count;
@@ -664,9 +616,8 @@
664 616 if ( $count > 1 && ! isset( $info['img'] ) ) {
665 617 --$count;
666 618 }
667 619 }
668 -
669 620 $width = floor( ( 533 - ( ( $count - 1 ) * 20 ) ) / $count );
670 621 unset( $count );
671 622
672 623 $selected = false;
@@ -678,15 +629,13 @@
678 629 * @return void
679 630 */
680 631 protected function show_page_options() {
681 632 $pages = $this->needed_pages();
682 -
683 - if ( ! $pages ) {
633 + if ( empty( $pages ) ) {
684 634 return;
685 635 }
686 636
687 637 echo '<h3>Choose New Page Title</h3>';
688 -
689 638 foreach ( $pages as $page ) {
690 639 ?>
691 640 <p>
692 641 <label for="pages_<?php echo esc_html( $page['type'] ); ?>">
@@ -691,9 +640,9 @@
691 640 <p>
692 641 <label for="pages_<?php echo esc_html( $page['type'] ); ?>">
693 642 <?php echo esc_html( $page['label'] ); ?>
694 643 </label>
695 - <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 ?>
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 />
696 645 </p>
697 646 <?php
698 647 }
699 648 }
@@ -698,10 +647,8 @@
698 647 }
699 648 }
700 649
701 650 /**
702 - * @param array $step
703 - *
704 651 * @return void
705 652 */
706 653 protected function show_page_links( $step ) {
707 654 if ( $step['current'] ) {
@@ -739,13 +686,11 @@
739 686 * @return bool
740 687 */
741 688 protected function is_complete( $count = 1 ) {
742 689 $imported = $this->previously_imported_forms();
743 -
744 690 if ( $count === 'all' ) {
745 691 return count( $imported ) >= count( $this->form_options() );
746 692 }
747 -
748 693 return ! empty( $imported );
749 694 }
750 695
751 696 /**
@@ -755,12 +700,10 @@
755 700 */
756 701 protected function previously_imported_forms() {
757 702 $imported = array();
758 703 $forms = $this->form_options();
759 -
760 704 foreach ( $forms as $form ) {
761 705 $was_imported = isset( $form['form'] ) ? FrmForm::get_id_by_key( $form['form'] ) : false;
762 -
763 706 if ( $was_imported ) {
764 707 $imported[ $form['form'] ] = $was_imported;
765 708 }
766 709 }