PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.2
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 +47 -105 6.266.2 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 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 );
@@ -167,9 +146,8 @@
167 146 */
168 147 public function redirect() {
169 148
170 149 $current_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
171 -
172 150 if ( $current_page === $this->page ) {
173 151 // Prevent endless loop.
174 152 return;
175 153 }
@@ -183,9 +161,9 @@
183 161 if ( ! $this->is_current_plugin() ) {
184 162 return;
185 163 }
186 164
187 - delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
165 + delete_transient( 'frm_activation_redirect' );
188 166
189 167 // Initial install.
190 168 wp_safe_redirect( $this->settings_link() );
191 169 exit;
@@ -197,14 +175,10 @@
197 175 protected function settings_link() {
198 176 return admin_url( 'index.php?page=' . $this->page );
199 177 }
200 178
201 - /**
179 + /*
202 180 * Add page to global settings.
203 - *
204 - * @param array $sections Sections.
205 - *
206 - * @return array
207 181 */
208 182 public function add_settings( $sections ) {
209 183 wp_enqueue_style( 'formidable-pro-fields' );
210 184 $sections[ $this->plugin_slug ] = array(
@@ -224,9 +198,8 @@
224 198 * @return void
225 199 */
226 200 public function settings_page() {
227 201 $steps = $this->get_steps_data();
228 -
229 202 if ( ! $steps['license']['complete'] || ( isset( $steps['plugin'] ) && ! $steps['plugin']['complete'] ) ) {
230 203 // Redirect to the welcome page if install hasn't been done.
231 204 $url = $this->settings_link();
232 205 echo '<script>window.location.replace("' . esc_url_raw( $url ) . '");</script>';
@@ -242,12 +215,11 @@
242 215 if ( $steps['complete']['current'] ) {
243 216 // Always show this step in settings.
244 217 $step['current'] = true;
245 218
246 - $new_class = $all_imported ? ' button frm_hidden' : '';
219 + $new_class = $all_imported ? ' button frm_hidden' : '';
247 220 $step['button_class'] = str_replace( 'frm_grey disabled', $new_class, $step['button_class'] );
248 221 }
249 -
250 222 if ( $all_imported ) {
251 223 $step['description'] = __( 'The following form(s) have been created.', 'formidable' );
252 224 }
253 225 $this->show_app_install( $step );
@@ -252,10 +224,10 @@
252 224 }
253 225 $this->show_app_install( $step );
254 226
255 227 if ( ! $all_imported ) {
256 - $step = $steps['complete'];
257 - $step['current'] = false;
228 + $step = $steps['complete'];
229 + $step['current'] = false;
258 230 $step['button_class'] .= ' frm_grey disabled';
259 231 $this->show_page_links( $step );
260 232 }
261 233 }
@@ -324,9 +296,8 @@
324 296 */
325 297 protected function main_content() {
326 298 $steps = $this->get_steps_data();
327 299 $this->license_box( $steps['license'] );
328 -
329 300 if ( isset( $steps['plugin'] ) ) {
330 301 $this->show_plugin_install( $steps['plugin'] );
331 302 }
332 303 $this->show_app_install( $steps['import'] );
@@ -332,44 +303,41 @@
332 303 $this->show_app_install( $steps['import'] );
333 304 $this->show_page_links( $steps['complete'] );
334 305 }
335 306
336 - /**
337 - * @return array
338 - */
339 307 protected function get_steps_data() {
340 308 $pro_installed = FrmAppHelper::pro_is_connected();
341 309
342 310 $steps = array(
343 - 'license' => array(
344 - 'label' => __( 'Connect to FormidableForms.com', 'formidable' ),
345 - 'description' => __( 'Create a connection to get plugin downloads.', 'formidable' ),
346 - 'button_label' => __( 'Connect an Account', 'formidable' ),
347 - 'current' => empty( $pro_installed ),
348 - 'complete' => $pro_installed,
349 - '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,
350 318 ),
351 - 'plugin' => array(
352 - 'label' => __( 'Install and Activate Add-Ons', 'formidable' ),
353 - 'description' => __( 'Install any required add-ons from FormidableForms.com.', 'formidable' ),
354 - 'button_label' => __( 'Install & Activate', 'formidable' ),
355 - 'current' => false,
356 - 'complete' => false,
357 - '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,
358 326 ),
359 - 'import' => array(
360 - 'label' => __( 'Setup Forms, Views, and Pages', 'formidable' ),
361 - 'description' => __( 'Build the forms, views, and pages automatically.', 'formidable' ),
362 - 'button_label' => __( 'Create Now', 'formidable' ),
363 - 'complete' => $this->is_complete(),
364 - '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,
365 333 ),
366 334 'complete' => array(
367 - 'label' => __( 'Customize Your New Pages', 'formidable' ),
368 - 'description' => __( 'Make any required changes and publish the page.', 'formidable' ),
369 - 'button_label' => __( 'View Page', 'formidable' ),
370 - 'complete' => false,
371 - '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,
372 340 ),
373 341 );
374 342
375 343 $this->adjust_plugin_install_step( $steps );
@@ -374,9 +342,8 @@
374 342
375 343 $this->adjust_plugin_install_step( $steps );
376 344
377 345 $has_current = false;
378 -
379 346 foreach ( $steps as $k => $step ) {
380 347 // Set the current step.
381 348 if ( ! isset( $step['current'] ) ) {
382 349 if ( $step['complete'] ) {
@@ -382,9 +349,9 @@
382 349 if ( $step['complete'] ) {
383 350 $steps[ $k ]['current'] = false;
384 351 } else {
385 352 $steps[ $k ]['current'] = ! $has_current;
386 - $has_current = true;
353 + $has_current = true;
387 354 }
388 355 } elseif ( $step['current'] ) {
389 356 $has_current = true;
390 357 }
@@ -389,16 +356,15 @@
389 356 $has_current = true;
390 357 }
391 358
392 359 // Set disabled buttons.
393 - $class = $step['button_class'] ?? '';
360 + $class = isset( $step['button_class'] ) ? $step['button_class'] : '';
394 361 $class .= ' button-primary frm-button-primary';
395 -
396 362 if ( ! $steps[ $k ]['current'] ) {
397 363 $class .= ' frm_grey disabled';
398 364 }
399 365 $steps[ $k ]['button_class'] = $class;
400 - }//end foreach
366 + }
401 367
402 368 return $steps;
403 369 }
404 370
@@ -408,9 +374,8 @@
408 374 * @return void
409 375 */
410 376 protected function adjust_plugin_install_step( &$steps ) {
411 377 $plugins = $this->required_plugins();
412 -
413 378 if ( empty( $plugins ) ) {
414 379 unset( $steps['plugin'] );
415 380 $steps['import']['num'] = 2;
416 381 $steps['complete']['num'] = 3;
@@ -418,16 +383,14 @@
418 383 }
419 384
420 385 $missing = array();
421 386 $rel = array();
422 -
423 387 foreach ( $plugins as $plugin_key ) {
424 388 $plugin = FrmAddonsController::install_link( $plugin_key );
425 -
426 389 if ( $plugin['status'] === 'active' ) {
427 390 continue;
428 391 }
429 -
392 + $links[ $plugin_key ] = $plugin;
430 393 if ( isset( $plugin['url'] ) ) {
431 394 $rel[] = $plugin['url'];
432 395 } else {
433 396 // Add-on is required but not allowed.
@@ -433,9 +396,8 @@
433 396 // Add-on is required but not allowed.
434 397 $missing[] = $plugin_key;
435 398 }
436 399 }
437 -
438 400 if ( empty( $rel ) && empty( $missing ) ) {
439 401 $steps['plugin']['complete'] = true;
440 402 } elseif ( ! empty( $missing ) ) {
441 403 $steps['plugin']['error'] = sprintf(
@@ -443,9 +405,9 @@
443 405 esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ),
444 406 implode( ', ', $missing )
445 407 );
446 408 } else {
447 - $steps['plugin']['links'] = $rel;
409 + $steps['plugin']['links'] = $rel;
448 410 $steps['plugin']['button_class'] = 'frm-solution-multiple ';
449 411 }
450 412
451 413 if ( $steps['license']['complete'] && ! $steps['plugin']['complete'] ) {
@@ -453,14 +415,12 @@
453 415 }
454 416 }
455 417
456 418 /**
457 - * @param array $step Step.
458 - *
459 419 * @return void
460 420 */
461 421 protected function step_top( $step ) {
462 - $section_class = empty( $step['current'] ) ? 'frm_grey' : '';
422 + $section_class = ( ! isset( $step['current'] ) || ! $step['current'] ) ? 'frm_grey' : '';
463 423
464 424 ?>
465 425 <section class="step step-install <?php echo esc_attr( $section_class ); ?>">
466 426 <aside class="num">
@@ -493,10 +453,8 @@
493 453 <?php
494 454 }
495 455
496 456 /**
497 - * @param array $step Step.
498 - *
499 457 * @return void
500 458 */
501 459 protected function step_bottom( $step ) {
502 460 ?>
@@ -507,10 +465,8 @@
507 465
508 466 /**
509 467 * Generate and output Connect step section HTML.
510 468 *
511 - * @param array $step Step.
512 - *
513 469 * @return void
514 470 */
515 471 protected function license_box( $step ) {
516 472 $this->step_top( $step );
@@ -528,10 +484,8 @@
528 484 $this->step_bottom( $step );
529 485 }
530 486
531 487 /**
532 - * @param array $step Step.
533 - *
534 488 * @return void
535 489 */
536 490 protected function show_plugin_install( $step ) {
537 491 $this->step_top( $step );
@@ -536,9 +490,9 @@
536 490 protected function show_plugin_install( $step ) {
537 491 $this->step_top( $step );
538 492
539 493 if ( ! isset( $step['error'] ) ) {
540 - $rel = $step['links'] ?? array();
494 + $rel = isset( $step['links'] ) ? $step['links'] : array();
541 495
542 496 ?>
543 497 <a rel="<?php echo esc_attr( implode( ',', $rel ) ); ?>" class="<?php echo esc_attr( $step['button_class'] ); ?>">
544 498 <?php echo esc_html( $step['button_label'] ); ?>
@@ -549,15 +503,12 @@
549 503 $this->step_bottom( $step );
550 504 }
551 505
552 506 /**
553 - * @param array $step Step.
554 - *
555 507 * @return void
556 508 */
557 509 protected function show_app_install( $step ) {
558 510 $is_complete = $step['complete'];
559 -
560 511 if ( ! empty( $this->form_options() ) && ! $is_complete ) {
561 512 $step['description'] = __( 'Select the form or view you would like to create.', 'formidable' );
562 513 }
563 514
@@ -565,9 +516,9 @@
565 516
566 517 $api = new FrmFormApi();
567 518 $addons = $api->get_api_info();
568 519
569 - $id = $this->download_id();
520 + $id = $this->download_id();
570 521 $has_file = isset( $addons[ $id ] ) && isset( $addons[ $id ]['beta'] );
571 522
572 523 if ( ! $step['current'] ) {
573 524 ?>
@@ -585,9 +536,8 @@
585 536 } elseif ( ! isset( $addons[ $id ]['beta']['package'] ) ) {
586 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>';
587 538 } else {
588 539 $xml = $addons[ $id ]['beta']['package'];
589 -
590 540 if ( is_array( $xml ) ) {
591 541 $xml = reset( $xml );
592 542 }
593 543
@@ -624,16 +574,14 @@
624 574 echo '</fieldset>';
625 575 } else {
626 576 echo '</form>';
627 577 }
628 - }//end if
578 + }
629 579
630 580 $this->step_bottom( $step );
631 581 }
632 582
633 583 /**
634 - * @param string $xml
635 - *
636 584 * @return void
637 585 */
638 586 protected function show_form_options( $xml ) {
639 587 $this->show_import_options( $this->form_options(), 'form', $xml );
@@ -646,11 +594,9 @@
646 594 $this->show_import_options( $this->view_options(), 'view' );
647 595 }
648 596
649 597 /**
650 - * @param array $options
651 598 * @param string $importing
652 - * @param string $xml
653 599 *
654 600 * @psalm-param 'form'|'view' $importing
655 601 *
656 602 * @return void
@@ -661,22 +607,20 @@
661 607 }
662 608
663 609 $imported = $this->previously_imported_forms();
664 610 $count = count( $options );
665 -
666 611 foreach ( $options as $info ) {
667 612 // Count the number of options displayed for css.
668 613 if ( $count > 1 && ! isset( $info['img'] ) ) {
669 - --$count;
614 + $count --;
670 615 }
671 616 }
672 -
673 617 $width = floor( ( 533 - ( ( $count - 1 ) * 20 ) ) / $count );
674 618 unset( $count );
675 619
676 620 $selected = false;
677 621
678 - include FrmAppHelper::plugin_path() . '/classes/views/solutions/_import.php';
622 + include( FrmAppHelper::plugin_path() . '/classes/views/solutions/_import.php' );
679 623 }
680 624
681 625 /**
682 626 * @return void
@@ -682,15 +626,13 @@
682 626 * @return void
683 627 */
684 628 protected function show_page_options() {
685 629 $pages = $this->needed_pages();
686 -
687 630 if ( empty( $pages ) ) {
688 631 return;
689 632 }
690 633
691 634 echo '<h3>Choose New Page Title</h3>';
692 -
693 635 foreach ( $pages as $page ) {
694 636 ?>
695 637 <p>
696 638 <label for="pages_<?php echo esc_html( $page['type'] ); ?>">
@@ -702,10 +644,8 @@
702 644 }
703 645 }
704 646
705 647 /**
706 - * @param array $step
707 - *
708 648 * @return void
709 649 */
710 650 protected function show_page_links( $step ) {
711 651 if ( $step['current'] ) {
@@ -728,9 +668,9 @@
728 668 *
729 669 * @return bool
730 670 */
731 671 protected function is_current_plugin() {
732 - $to_redirect = get_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
672 + $to_redirect = get_transient( 'frm_activation_redirect' );
733 673 return $to_redirect === $this->plugin_slug && empty( $this->is_complete() );
734 674 }
735 675
736 676 /**
@@ -743,9 +683,8 @@
743 683 * @return bool
744 684 */
745 685 protected function is_complete( $count = 1 ) {
746 686 $imported = $this->previously_imported_forms();
747 -
748 687 if ( $count === 'all' ) {
749 688 return count( $imported ) >= count( $this->form_options() );
750 689 }
751 690 return ! empty( $imported );
@@ -758,12 +697,10 @@
758 697 */
759 698 protected function previously_imported_forms() {
760 699 $imported = array();
761 700 $forms = $this->form_options();
762 -
763 701 foreach ( $forms as $form ) {
764 702 $was_imported = isset( $form['form'] ) ? FrmForm::get_id_by_key( $form['form'] ) : false;
765 -
766 703 if ( $was_imported ) {
767 704 $imported[ $form['form'] ] = $was_imported;
768 705 }
769 706 }
@@ -844,8 +781,10 @@
844 781 wp_enqueue_style( 'formidable-pro-fields' );
845 782 ?>
846 783 <style>
847 784 #frm-welcome *, #frm-welcome *::before, #frm-welcome *::after {
785 + -webkit-box-sizing: border-box;
786 + -moz-box-sizing: border-box;
848 787 box-sizing: border-box;
849 788 }
850 789 #frm-welcome{
851 790 width: 700px;
@@ -904,8 +843,10 @@
904 843 border-radius: 3px;
905 844 }
906 845 #frm-welcome .step,
907 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);
908 849 box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
909 850 }
910 851 #frm-welcome .step {
911 852 background-color: #F9F9F9;
@@ -948,5 +889,6 @@
948 889 }
949 890 </style>
950 891 <?php
951 892 }
893 +
952 894 }