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