PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.2.3
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.2.3
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 +64 -119 6.276.2.3 View file →
@@ -3,10 +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 - * @package Formidable
9 7 */
10 8
11 9 if ( ! defined( 'ABSPATH' ) ) {
12 10 die( 'You are not allowed to call this page directly.' );
@@ -13,16 +11,10 @@
13 11 }
14 12
15 13 class FrmSolution {
16 14
17 - /**
18 - * @var string
19 - */
20 15 protected $plugin_slug = '';
21 16
22 - /**
23 - * @var string
24 - */
25 17 protected $plugin_file = '';
26 18
27 19 /**
28 20 * Hidden welcome page slug.
@@ -27,21 +19,13 @@
27 19 /**
28 20 * Hidden welcome page slug.
29 21 *
30 22 * @since 4.06.02
31 - *
32 - * @var string
33 23 */
34 24 protected $page = '';
35 25
36 - /**
37 - * @var string
38 - */
39 - protected $icon = 'frmfont frm_settings_icon';
26 + protected $icon = 'frm_icon_font frm_settings_icon';
40 27
41 - /**
42 - * @param array $atts
43 - */
44 28 public function __construct( $atts = array() ) {
45 29 if ( empty( $this->plugin_slug ) ) {
46 30 return;
47 31 }
@@ -82,13 +66,8 @@
82 66 add_action( 'admin_menu', array( $this, 'register' ) );
83 67 add_action( 'admin_head', array( $this, 'hide_menu' ) );
84 68 }
85 69
86 - /**
87 - * @param array $links
88 - *
89 - * @return array
90 - */
91 70 public function plugin_links( $links ) {
92 71 if ( ! $this->is_complete() ) {
93 72 $settings = '<a href="' . esc_url( $this->settings_link() ) . '">' . __( 'Setup', 'formidable' ) . '</a>';
94 73 array_unshift( $links, $settings );
@@ -107,8 +86,9 @@
107 86 *
108 87 * @return void
109 88 */
110 89 public function register() {
90 +
111 91 // Getting started - shows after installation.
112 92 add_dashboard_page(
113 93 esc_html( $this->page_title() ),
114 94 esc_html( $this->page_title() ),
@@ -164,10 +144,10 @@
164 144 *
165 145 * @return void
166 146 */
167 147 public function redirect() {
148 +
168 149 $current_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
169 -
170 150 if ( $current_page === $this->page ) {
171 151 // Prevent endless loop.
172 152 return;
173 153 }
@@ -181,9 +161,9 @@
181 161 if ( ! $this->is_current_plugin() ) {
182 162 return;
183 163 }
184 164
185 - delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
165 + delete_transient( 'frm_activation_redirect' );
186 166
187 167 // Initial install.
188 168 wp_safe_redirect( $this->settings_link() );
189 169 exit;
@@ -195,14 +175,10 @@
195 175 protected function settings_link() {
196 176 return admin_url( 'index.php?page=' . $this->page );
197 177 }
198 178
199 - /**
179 + /*
200 180 * Add page to global settings.
201 - *
202 - * @param array $sections Sections.
203 - *
204 - * @return array
205 181 */
206 182 public function add_settings( $sections ) {
207 183 wp_enqueue_style( 'formidable-pro-fields' );
208 184 $sections[ $this->plugin_slug ] = array(
@@ -222,9 +198,8 @@
222 198 * @return void
223 199 */
224 200 public function settings_page() {
225 201 $steps = $this->get_steps_data();
226 -
227 202 if ( ! $steps['license']['complete'] || ( isset( $steps['plugin'] ) && ! $steps['plugin']['complete'] ) ) {
228 203 // Redirect to the welcome page if install hasn't been done.
229 204 $url = $this->settings_link();
230 205 echo '<script>window.location.replace("' . esc_url_raw( $url ) . '");</script>';
@@ -230,9 +205,10 @@
230 205 echo '<script>window.location.replace("' . esc_url_raw( $url ) . '");</script>';
231 206 return;
232 207 }
233 208
234 - $all_imported = $this->is_complete( 'all' );
209 + $all_imported = $this->is_complete( 'all' );
210 +
235 211 $step = $steps['import'];
236 212 $step['label'] = '';
237 213 $step['nested'] = true;
238 214
@@ -239,12 +215,11 @@
239 215 if ( $steps['complete']['current'] ) {
240 216 // Always show this step in settings.
241 217 $step['current'] = true;
242 218
243 - $new_class = $all_imported ? ' button frm_hidden' : '';
219 + $new_class = $all_imported ? ' button frm_hidden' : '';
244 220 $step['button_class'] = str_replace( 'frm_grey disabled', $new_class, $step['button_class'] );
245 221 }
246 -
247 222 if ( $all_imported ) {
248 223 $step['description'] = __( 'The following form(s) have been created.', 'formidable' );
249 224 }
250 225 $this->show_app_install( $step );
@@ -249,10 +224,10 @@
249 224 }
250 225 $this->show_app_install( $step );
251 226
252 227 if ( ! $all_imported ) {
253 - $step = $steps['complete'];
254 - $step['current'] = false;
228 + $step = $steps['complete'];
229 + $step['current'] = false;
255 230 $step['button_class'] .= ' frm_grey disabled';
256 231 $this->show_page_links( $step );
257 232 }
258 233 }
@@ -321,9 +296,8 @@
321 296 */
322 297 protected function main_content() {
323 298 $steps = $this->get_steps_data();
324 299 $this->license_box( $steps['license'] );
325 -
326 300 if ( isset( $steps['plugin'] ) ) {
327 301 $this->show_plugin_install( $steps['plugin'] );
328 302 }
329 303 $this->show_app_install( $steps['import'] );
@@ -329,44 +303,41 @@
329 303 $this->show_app_install( $steps['import'] );
330 304 $this->show_page_links( $steps['complete'] );
331 305 }
332 306
333 - /**
334 - * @return array
335 - */
336 307 protected function get_steps_data() {
337 308 $pro_installed = FrmAppHelper::pro_is_connected();
338 309
339 310 $steps = array(
340 - 'license' => array(
341 - 'label' => __( 'Connect to FormidableForms.com', 'formidable' ),
342 - 'description' => __( 'Create a connection to get plugin downloads.', 'formidable' ),
343 - 'button_label' => __( 'Connect an Account', 'formidable' ),
344 - 'current' => empty( $pro_installed ),
345 - 'complete' => $pro_installed,
346 - 'num' => 1,
311 + 'license' => array(
312 + 'label' => __( 'Connect to FormidableForms.com', 'formidable' ),
313 + 'description' => __( 'Create a connection to get plugin downloads.', 'formidable' ),
314 + 'button_label' => __( 'Connect an Account', 'formidable' ),
315 + 'current' => empty( $pro_installed ),
316 + 'complete' => $pro_installed,
317 + 'num' => 1,
347 318 ),
348 - 'plugin' => array(
349 - 'label' => __( 'Install and Activate Add-Ons', 'formidable' ),
350 - 'description' => __( 'Install any required add-ons from FormidableForms.com.', 'formidable' ),
351 - 'button_label' => __( 'Install & Activate', 'formidable' ),
352 - 'current' => false,
353 - 'complete' => false,
354 - 'num' => 2,
319 + 'plugin' => array(
320 + 'label' => __( 'Install and Activate Add-Ons', 'formidable' ),
321 + 'description' => __( 'Install any required add-ons from FormidableForms.com.', 'formidable' ),
322 + 'button_label' => __( 'Install & Activate', 'formidable' ),
323 + 'current' => false,
324 + 'complete' => false,
325 + 'num' => 2,
355 326 ),
356 - 'import' => array(
357 - 'label' => __( 'Setup Forms, Views, and Pages', 'formidable' ),
358 - 'description' => __( 'Build the forms, views, and pages automatically.', 'formidable' ),
359 - 'button_label' => __( 'Create Now', 'formidable' ),
360 - 'complete' => $this->is_complete(),
361 - 'num' => 3,
327 + 'import' => array(
328 + 'label' => __( 'Setup Forms, Views, and Pages', 'formidable' ),
329 + 'description' => __( 'Build the forms, views, and pages automatically.', 'formidable' ),
330 + 'button_label' => __( 'Create Now', 'formidable' ),
331 + 'complete' => $this->is_complete(),
332 + 'num' => 3,
362 333 ),
363 334 'complete' => array(
364 - 'label' => __( 'Customize Your New Pages', 'formidable' ),
365 - 'description' => __( 'Make any required changes and publish the page.', 'formidable' ),
366 - 'button_label' => __( 'View Page', 'formidable' ),
367 - 'complete' => false,
368 - 'num' => 4,
335 + 'label' => __( 'Customize Your New Pages', 'formidable' ),
336 + 'description' => __( 'Make any required changes and publish the page.', 'formidable' ),
337 + 'button_label' => __( 'View Page', 'formidable' ),
338 + 'complete' => false,
339 + 'num' => 4,
369 340 ),
370 341 );
371 342
372 343 $this->adjust_plugin_install_step( $steps );
@@ -371,9 +342,8 @@
371 342
372 343 $this->adjust_plugin_install_step( $steps );
373 344
374 345 $has_current = false;
375 -
376 346 foreach ( $steps as $k => $step ) {
377 347 // Set the current step.
378 348 if ( ! isset( $step['current'] ) ) {
379 349 if ( $step['complete'] ) {
@@ -379,9 +349,9 @@
379 349 if ( $step['complete'] ) {
380 350 $steps[ $k ]['current'] = false;
381 351 } else {
382 352 $steps[ $k ]['current'] = ! $has_current;
383 - $has_current = true;
353 + $has_current = true;
384 354 }
385 355 } elseif ( $step['current'] ) {
386 356 $has_current = true;
387 357 }
@@ -386,16 +356,15 @@
386 356 $has_current = true;
387 357 }
388 358
389 359 // Set disabled buttons.
390 - $class = $step['button_class'] ?? '';
360 + $class = isset( $step['button_class'] ) ? $step['button_class'] : '';
391 361 $class .= ' button-primary frm-button-primary';
392 -
393 362 if ( ! $steps[ $k ]['current'] ) {
394 363 $class .= ' frm_grey disabled';
395 364 }
396 365 $steps[ $k ]['button_class'] = $class;
397 - }//end foreach
366 + }
398 367
399 368 return $steps;
400 369 }
401 370
@@ -405,10 +374,9 @@
405 374 * @return void
406 375 */
407 376 protected function adjust_plugin_install_step( &$steps ) {
408 377 $plugins = $this->required_plugins();
409 -
410 - if ( ! $plugins ) {
378 + if ( empty( $plugins ) ) {
411 379 unset( $steps['plugin'] );
412 380 $steps['import']['num'] = 2;
413 381 $steps['complete']['num'] = 3;
414 382 return;
@@ -415,16 +383,14 @@
415 383 }
416 384
417 385 $missing = array();
418 386 $rel = array();
419 -
420 387 foreach ( $plugins as $plugin_key ) {
421 388 $plugin = FrmAddonsController::install_link( $plugin_key );
422 -
423 389 if ( $plugin['status'] === 'active' ) {
424 390 continue;
425 391 }
426 -
392 + $links[ $plugin_key ] = $plugin;
427 393 if ( isset( $plugin['url'] ) ) {
428 394 $rel[] = $plugin['url'];
429 395 } else {
430 396 // Add-on is required but not allowed.
@@ -430,12 +396,11 @@
430 396 // Add-on is required but not allowed.
431 397 $missing[] = $plugin_key;
432 398 }
433 399 }
434 -
435 - if ( ! $rel && ! $missing ) {
400 + if ( empty( $rel ) && empty( $missing ) ) {
436 401 $steps['plugin']['complete'] = true;
437 - } elseif ( $missing ) {
402 + } elseif ( ! empty( $missing ) ) {
438 403 $steps['plugin']['error'] = sprintf(
439 404 /* translators: %1$s: Plugin name */
440 405 esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ),
441 406 implode( ', ', $missing )
@@ -440,9 +405,9 @@
440 405 esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ),
441 406 implode( ', ', $missing )
442 407 );
443 408 } else {
444 - $steps['plugin']['links'] = $rel;
409 + $steps['plugin']['links'] = $rel;
445 410 $steps['plugin']['button_class'] = 'frm-solution-multiple ';
446 411 }
447 412
448 413 if ( $steps['license']['complete'] && ! $steps['plugin']['complete'] ) {
@@ -450,20 +415,18 @@
450 415 }
451 416 }
452 417
453 418 /**
454 - * @param array $step Step.
455 - *
456 419 * @return void
457 420 */
458 421 protected function step_top( $step ) {
459 - $section_class = empty( $step['current'] ) ? 'frm_grey' : '';
422 + $section_class = ( ! isset( $step['current'] ) || ! $step['current'] ) ? 'frm_grey' : '';
460 423
461 424 ?>
462 425 <section class="step step-install <?php echo esc_attr( $section_class ); ?>">
463 426 <aside class="num">
464 427 <?php
465 - if ( ! empty( $step['complete'] ) ) {
428 + if ( isset( $step['complete'] ) && $step['complete'] ) {
466 429 FrmAppHelper::icon_by_class(
467 430 'frmfont frm_step_complete_icon',
468 431 array(
469 432 /* translators: %1$s: Step number */
@@ -472,9 +435,9 @@
472 435 )
473 436 );
474 437 } else {
475 438 ?>
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 ?>
439 + <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 440 <?php
478 441 }
479 442 ?>
480 443 <i class="loader hidden"></i>
@@ -490,10 +453,8 @@
490 453 <?php
491 454 }
492 455
493 456 /**
494 - * @param array $step Step.
495 - *
496 457 * @return void
497 458 */
498 459 protected function step_bottom( $step ) {
499 460 ?>
@@ -504,10 +465,8 @@
504 465
505 466 /**
506 467 * Generate and output Connect step section HTML.
507 468 *
508 - * @param array $step Step.
509 - *
510 469 * @return void
511 470 */
512 471 protected function license_box( $step ) {
513 472 $this->step_top( $step );
@@ -525,10 +484,8 @@
525 484 $this->step_bottom( $step );
526 485 }
527 486
528 487 /**
529 - * @param array $step Step.
530 - *
531 488 * @return void
532 489 */
533 490 protected function show_plugin_install( $step ) {
534 491 $this->step_top( $step );
@@ -533,9 +490,9 @@
533 490 protected function show_plugin_install( $step ) {
534 491 $this->step_top( $step );
535 492
536 493 if ( ! isset( $step['error'] ) ) {
537 - $rel = $step['links'] ?? array();
494 + $rel = isset( $step['links'] ) ? $step['links'] : array();
538 495
539 496 ?>
540 497 <a rel="<?php echo esc_attr( implode( ',', $rel ) ); ?>" class="<?php echo esc_attr( $step['button_class'] ); ?>">
541 498 <?php echo esc_html( $step['button_label'] ); ?>
@@ -546,15 +503,12 @@
546 503 $this->step_bottom( $step );
547 504 }
548 505
549 506 /**
550 - * @param array $step Step.
551 - *
552 507 * @return void
553 508 */
554 509 protected function show_app_install( $step ) {
555 510 $is_complete = $step['complete'];
556 -
557 511 if ( ! empty( $this->form_options() ) && ! $is_complete ) {
558 512 $step['description'] = __( 'Select the form or view you would like to create.', 'formidable' );
559 513 }
560 514
@@ -559,11 +513,12 @@
559 513 }
560 514
561 515 $this->step_top( $step );
562 516
563 - $api = new FrmFormApi();
564 - $addons = $api->get_api_info();
565 - $id = $this->download_id();
517 + $api = new FrmFormApi();
518 + $addons = $api->get_api_info();
519 +
520 + $id = $this->download_id();
566 521 $has_file = isset( $addons[ $id ] ) && isset( $addons[ $id ]['beta'] );
567 522
568 523 if ( ! $step['current'] ) {
569 524 ?>
@@ -578,12 +533,11 @@
578 533
579 534 if ( ! $has_file ) {
580 535 echo '<p class="frm_error_style">' . esc_html__( 'We didn\'t find anything to import. Please contact our team.', 'formidable' ) . '</p>';
581 536 } 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
537 + 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 538 } else {
584 539 $xml = $addons[ $id ]['beta']['package'];
585 -
586 540 if ( is_array( $xml ) ) {
587 541 $xml = reset( $xml );
588 542 }
589 543
@@ -620,16 +574,14 @@
620 574 echo '</fieldset>';
621 575 } else {
622 576 echo '</form>';
623 577 }
624 - }//end if
578 + }
625 579
626 580 $this->step_bottom( $step );
627 581 }
628 582
629 583 /**
630 - * @param string $xml
631 - *
632 584 * @return void
633 585 */
634 586 protected function show_form_options( $xml ) {
635 587 $this->show_import_options( $this->form_options(), 'form', $xml );
@@ -642,11 +594,9 @@
642 594 $this->show_import_options( $this->view_options(), 'view' );
643 595 }
644 596
645 597 /**
646 - * @param array $options
647 598 * @param string $importing
648 - * @param string $xml
649 599 *
650 600 * @psalm-param 'form'|'view' $importing
651 601 *
652 602 * @return void
@@ -651,28 +601,26 @@
651 601 *
652 602 * @return void
653 603 */
654 604 protected function show_import_options( $options, $importing, $xml = '' ) {
655 - if ( ! $options ) {
605 + if ( empty( $options ) ) {
656 606 return;
657 607 }
658 608
659 609 $imported = $this->previously_imported_forms();
660 610 $count = count( $options );
661 -
662 611 foreach ( $options as $info ) {
663 612 // Count the number of options displayed for css.
664 613 if ( $count > 1 && ! isset( $info['img'] ) ) {
665 - --$count;
614 + $count --;
666 615 }
667 616 }
668 -
669 617 $width = floor( ( 533 - ( ( $count - 1 ) * 20 ) ) / $count );
670 618 unset( $count );
671 619
672 620 $selected = false;
673 621
674 - include FrmAppHelper::plugin_path() . '/classes/views/solutions/_import.php';
622 + include( FrmAppHelper::plugin_path() . '/classes/views/solutions/_import.php' );
675 623 }
676 624
677 625 /**
678 626 * @return void
@@ -678,15 +626,13 @@
678 626 * @return void
679 627 */
680 628 protected function show_page_options() {
681 629 $pages = $this->needed_pages();
682 -
683 - if ( ! $pages ) {
630 + if ( empty( $pages ) ) {
684 631 return;
685 632 }
686 633
687 634 echo '<h3>Choose New Page Title</h3>';
688 -
689 635 foreach ( $pages as $page ) {
690 636 ?>
691 637 <p>
692 638 <label for="pages_<?php echo esc_html( $page['type'] ); ?>">
@@ -691,9 +637,9 @@
691 637 <p>
692 638 <label for="pages_<?php echo esc_html( $page['type'] ); ?>">
693 639 <?php echo esc_html( $page['label'] ); ?>
694 640 </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 ?>
641 + <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 642 </p>
697 643 <?php
698 644 }
699 645 }
@@ -698,10 +644,8 @@
698 644 }
699 645 }
700 646
701 647 /**
702 - * @param array $step
703 - *
704 648 * @return void
705 649 */
706 650 protected function show_page_links( $step ) {
707 651 if ( $step['current'] ) {
@@ -724,9 +668,9 @@
724 668 *
725 669 * @return bool
726 670 */
727 671 protected function is_current_plugin() {
728 - $to_redirect = get_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
672 + $to_redirect = get_transient( 'frm_activation_redirect' );
729 673 return $to_redirect === $this->plugin_slug && empty( $this->is_complete() );
730 674 }
731 675
732 676 /**
@@ -739,13 +683,11 @@
739 683 * @return bool
740 684 */
741 685 protected function is_complete( $count = 1 ) {
742 686 $imported = $this->previously_imported_forms();
743 -
744 687 if ( $count === 'all' ) {
745 688 return count( $imported ) >= count( $this->form_options() );
746 689 }
747 -
748 690 return ! empty( $imported );
749 691 }
750 692
751 693 /**
@@ -755,12 +697,10 @@
755 697 */
756 698 protected function previously_imported_forms() {
757 699 $imported = array();
758 700 $forms = $this->form_options();
759 -
760 701 foreach ( $forms as $form ) {
761 702 $was_imported = isset( $form['form'] ) ? FrmForm::get_id_by_key( $form['form'] ) : false;
762 -
763 703 if ( $was_imported ) {
764 704 $imported[ $form['form'] ] = $was_imported;
765 705 }
766 706 }
@@ -841,8 +781,10 @@
841 781 wp_enqueue_style( 'formidable-pro-fields' );
842 782 ?>
843 783 <style>
844 784 #frm-welcome *, #frm-welcome *::before, #frm-welcome *::after {
785 + -webkit-box-sizing: border-box;
786 + -moz-box-sizing: border-box;
845 787 box-sizing: border-box;
846 788 }
847 789 #frm-welcome{
848 790 width: 700px;
@@ -901,8 +843,10 @@
901 843 border-radius: 3px;
902 844 }
903 845 #frm-welcome .step,
904 846 #frm-welcome .screenshot .cont {
847 + -webkit-box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
848 + -moz-box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
905 849 box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
906 850 }
907 851 #frm-welcome .step {
908 852 background-color: #F9F9F9;
@@ -945,5 +889,6 @@
945 889 }
946 890 </style>
947 891 <?php
948 892 }
893 +
949 894 }