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 +61 -112 6.276.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 - 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 }
@@ -181,9 +163,9 @@
181 163 if ( ! $this->is_current_plugin() ) {
182 164 return;
183 165 }
184 166
185 - delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
167 + delete_transient( 'frm_activation_redirect' );
186 168
187 169 // Initial install.
188 170 wp_safe_redirect( $this->settings_link() );
189 171 exit;
@@ -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
@@ -239,12 +217,11 @@
239 217 if ( $steps['complete']['current'] ) {
240 218 // Always show this step in settings.
241 219 $step['current'] = true;
242 220
243 - $new_class = $all_imported ? ' button frm_hidden' : '';
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 );
@@ -249,10 +226,10 @@
249 226 }
250 227 $this->show_app_install( $step );
251 228
252 229 if ( ! $all_imported ) {
253 - $step = $steps['complete'];
254 - $step['current'] = false;
230 + $step = $steps['complete'];
231 + $step['current'] = false;
255 232 $step['button_class'] .= ' frm_grey disabled';
256 233 $this->show_page_links( $step );
257 234 }
258 235 }
@@ -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,44 +305,41 @@
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(
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,
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,
347 320 ),
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,
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,
355 328 ),
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,
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,
362 335 ),
363 336 '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,
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,
369 342 ),
370 343 );
371 344
372 345 $this->adjust_plugin_install_step( $steps );
@@ -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'] ) {
@@ -379,9 +351,9 @@
379 351 if ( $step['complete'] ) {
380 352 $steps[ $k ]['current'] = false;
381 353 } else {
382 354 $steps[ $k ]['current'] = ! $has_current;
383 - $has_current = true;
355 + $has_current = true;
384 356 }
385 357 } elseif ( $step['current'] ) {
386 358 $has_current = true;
387 359 }
@@ -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,14 @@
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 -
394 + $links[ $plugin_key ] = $plugin;
427 395 if ( isset( $plugin['url'] ) ) {
428 396 $rel[] = $plugin['url'];
429 397 } else {
430 398 // Add-on is required but not allowed.
@@ -430,12 +398,11 @@
430 398 // Add-on is required but not allowed.
431 399 $missing[] = $plugin_key;
432 400 }
433 401 }
434 -
435 - if ( ! $rel && ! $missing ) {
402 + if ( empty( $rel ) && empty( $missing ) ) {
436 403 $steps['plugin']['complete'] = true;
437 - } elseif ( $missing ) {
404 + } elseif ( ! empty( $missing ) ) {
438 405 $steps['plugin']['error'] = sprintf(
439 406 /* translators: %1$s: Plugin name */
440 407 esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ),
441 408 implode( ', ', $missing )
@@ -440,9 +407,9 @@
440 407 esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ),
441 408 implode( ', ', $missing )
442 409 );
443 410 } else {
444 - $steps['plugin']['links'] = $rel;
411 + $steps['plugin']['links'] = $rel;
445 412 $steps['plugin']['button_class'] = 'frm-solution-multiple ';
446 413 }
447 414
448 415 if ( $steps['license']['complete'] && ! $steps['plugin']['complete'] ) {
@@ -450,20 +417,18 @@
450 417 }
451 418 }
452 419
453 420 /**
454 - * @param array $step Step.
455 - *
456 421 * @return void
457 422 */
458 423 protected function step_top( $step ) {
459 - $section_class = empty( $step['current'] ) ? 'frm_grey' : '';
424 + $section_class = ( ! isset( $step['current'] ) || ! $step['current'] ) ? 'frm_grey' : '';
460 425
461 426 ?>
462 427 <section class="step step-install <?php echo esc_attr( $section_class ); ?>">
463 428 <aside class="num">
464 429 <?php
465 - if ( ! empty( $step['complete'] ) ) {
430 + if ( isset( $step['complete'] ) && $step['complete'] ) {
466 431 FrmAppHelper::icon_by_class(
467 432 'frmfont frm_step_complete_icon',
468 433 array(
469 434 /* translators: %1$s: Step number */
@@ -472,9 +437,9 @@
472 437 )
473 438 );
474 439 } else {
475 440 ?>
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 ?>
441 + <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 442 <?php
478 443 }
479 444 ?>
480 445 <i class="loader hidden"></i>
@@ -490,10 +455,8 @@
490 455 <?php
491 456 }
492 457
493 458 /**
494 - * @param array $step Step.
495 - *
496 459 * @return void
497 460 */
498 461 protected function step_bottom( $step ) {
499 462 ?>
@@ -504,10 +467,8 @@
504 467
505 468 /**
506 469 * Generate and output Connect step section HTML.
507 470 *
508 - * @param array $step Step.
509 - *
510 471 * @return void
511 472 */
512 473 protected function license_box( $step ) {
513 474 $this->step_top( $step );
@@ -525,10 +486,8 @@
525 486 $this->step_bottom( $step );
526 487 }
527 488
528 489 /**
529 - * @param array $step Step.
530 - *
531 490 * @return void
532 491 */
533 492 protected function show_plugin_install( $step ) {
534 493 $this->step_top( $step );
@@ -533,9 +492,9 @@
533 492 protected function show_plugin_install( $step ) {
534 493 $this->step_top( $step );
535 494
536 495 if ( ! isset( $step['error'] ) ) {
537 - $rel = $step['links'] ?? array();
496 + $rel = isset( $step['links'] ) ? $step['links'] : array();
538 497
539 498 ?>
540 499 <a rel="<?php echo esc_attr( implode( ',', $rel ) ); ?>" class="<?php echo esc_attr( $step['button_class'] ); ?>">
541 500 <?php echo esc_html( $step['button_label'] ); ?>
@@ -546,15 +505,12 @@
546 505 $this->step_bottom( $step );
547 506 }
548 507
549 508 /**
550 - * @param array $step Step.
551 - *
552 509 * @return void
553 510 */
554 511 protected function show_app_install( $step ) {
555 512 $is_complete = $step['complete'];
556 -
557 513 if ( ! empty( $this->form_options() ) && ! $is_complete ) {
558 514 $step['description'] = __( 'Select the form or view you would like to create.', 'formidable' );
559 515 }
560 516
@@ -559,11 +515,12 @@
559 515 }
560 516
561 517 $this->step_top( $step );
562 518
563 - $api = new FrmFormApi();
564 - $addons = $api->get_api_info();
565 - $id = $this->download_id();
519 + $api = new FrmFormApi();
520 + $addons = $api->get_api_info();
521 +
522 + $id = $this->download_id();
566 523 $has_file = isset( $addons[ $id ] ) && isset( $addons[ $id ]['beta'] );
567 524
568 525 if ( ! $step['current'] ) {
569 526 ?>
@@ -578,12 +535,11 @@
578 535
579 536 if ( ! $has_file ) {
580 537 echo '<p class="frm_error_style">' . esc_html__( 'We didn\'t find anything to import. Please contact our team.', 'formidable' ) . '</p>';
581 538 } 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
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>';
583 540 } else {
584 541 $xml = $addons[ $id ]['beta']['package'];
585 -
586 542 if ( is_array( $xml ) ) {
587 543 $xml = reset( $xml );
588 544 }
589 545
@@ -626,10 +582,8 @@
626 582 $this->step_bottom( $step );
627 583 }
628 584
629 585 /**
630 - * @param string $xml
631 - *
632 586 * @return void
633 587 */
634 588 protected function show_form_options( $xml ) {
635 589 $this->show_import_options( $this->form_options(), 'form', $xml );
@@ -651,28 +605,26 @@
651 605 *
652 606 * @return void
653 607 */
654 608 protected function show_import_options( $options, $importing, $xml = '' ) {
655 - if ( ! $options ) {
609 + if ( empty( $options ) ) {
656 610 return;
657 611 }
658 612
659 613 $imported = $this->previously_imported_forms();
660 614 $count = count( $options );
661 -
662 615 foreach ( $options as $info ) {
663 616 // Count the number of options displayed for css.
664 617 if ( $count > 1 && ! isset( $info['img'] ) ) {
665 - --$count;
618 + $count --;
666 619 }
667 620 }
668 -
669 621 $width = floor( ( 533 - ( ( $count - 1 ) * 20 ) ) / $count );
670 622 unset( $count );
671 623
672 624 $selected = false;
673 625
674 - include FrmAppHelper::plugin_path() . '/classes/views/solutions/_import.php';
626 + include( FrmAppHelper::plugin_path() . '/classes/views/solutions/_import.php' );
675 627 }
676 628
677 629 /**
678 630 * @return void
@@ -678,15 +630,13 @@
678 630 * @return void
679 631 */
680 632 protected function show_page_options() {
681 633 $pages = $this->needed_pages();
682 -
683 - if ( ! $pages ) {
634 + if ( empty( $pages ) ) {
684 635 return;
685 636 }
686 637
687 638 echo '<h3>Choose New Page Title</h3>';
688 -
689 639 foreach ( $pages as $page ) {
690 640 ?>
691 641 <p>
692 642 <label for="pages_<?php echo esc_html( $page['type'] ); ?>">
@@ -691,9 +641,9 @@
691 641 <p>
692 642 <label for="pages_<?php echo esc_html( $page['type'] ); ?>">
693 643 <?php echo esc_html( $page['label'] ); ?>
694 644 </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 ?>
645 + <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 646 </p>
697 647 <?php
698 648 }
699 649 }
@@ -698,10 +648,8 @@
698 648 }
699 649 }
700 650
701 651 /**
702 - * @param array $step
703 - *
704 652 * @return void
705 653 */
706 654 protected function show_page_links( $step ) {
707 655 if ( $step['current'] ) {
@@ -724,9 +672,9 @@
724 672 *
725 673 * @return bool
726 674 */
727 675 protected function is_current_plugin() {
728 - $to_redirect = get_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
676 + $to_redirect = get_transient( 'frm_activation_redirect' );
729 677 return $to_redirect === $this->plugin_slug && empty( $this->is_complete() );
730 678 }
731 679
732 680 /**
@@ -739,13 +687,11 @@
739 687 * @return bool
740 688 */
741 689 protected function is_complete( $count = 1 ) {
742 690 $imported = $this->previously_imported_forms();
743 -
744 691 if ( $count === 'all' ) {
745 692 return count( $imported ) >= count( $this->form_options() );
746 693 }
747 -
748 694 return ! empty( $imported );
749 695 }
750 696
751 697 /**
@@ -755,12 +701,10 @@
755 701 */
756 702 protected function previously_imported_forms() {
757 703 $imported = array();
758 704 $forms = $this->form_options();
759 -
760 705 foreach ( $forms as $form ) {
761 706 $was_imported = isset( $form['form'] ) ? FrmForm::get_id_by_key( $form['form'] ) : false;
762 -
763 707 if ( $was_imported ) {
764 708 $imported[ $form['form'] ] = $was_imported;
765 709 }
766 710 }
@@ -841,8 +785,10 @@
841 785 wp_enqueue_style( 'formidable-pro-fields' );
842 786 ?>
843 787 <style>
844 788 #frm-welcome *, #frm-welcome *::before, #frm-welcome *::after {
789 + -webkit-box-sizing: border-box;
790 + -moz-box-sizing: border-box;
845 791 box-sizing: border-box;
846 792 }
847 793 #frm-welcome{
848 794 width: 700px;
@@ -901,8 +847,10 @@
901 847 border-radius: 3px;
902 848 }
903 849 #frm-welcome .step,
904 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);
905 853 box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
906 854 }
907 855 #frm-welcome .step {
908 856 background-color: #F9F9F9;
@@ -945,5 +893,6 @@
945 893 }
946 894 </style>
947 895 <?php
948 896 }
897 +
949 898 }