PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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 +48 -136 6.255.0 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 - * @package Formidable
8 7 */
9 8
10 9 if ( ! defined( 'ABSPATH' ) ) {
11 10 die( 'You are not allowed to call this page directly.' );
@@ -20,9 +19,8 @@
20 19 /**
21 20 * Hidden welcome page slug.
22 21 *
23 22 * @since 4.06.02
24 - * @var string
25 23 */
26 24 protected $page = '';
27 25
28 26 protected $icon = 'frm_icon_font frm_settings_icon';
@@ -43,10 +41,8 @@
43 41 /**
44 42 * Register all WP hooks.
45 43 *
46 44 * @since 4.06.02
47 - *
48 - * @return void
49 45 */
50 46 public function load_hooks() {
51 47 // If user is in admin ajax or doing cron, return.
52 48 if ( wp_doing_cron() ) {
@@ -84,10 +80,8 @@
84 80 * These pages will be removed from the Dashboard menu, so they will
85 81 * not actually show. Sneaky, sneaky.
86 82 *
87 83 * @since 4.06.02
88 - *
89 - * @return void
90 84 */
91 85 public function register() {
92 86
93 87 // Getting started - shows after installation.
@@ -105,34 +99,21 @@
105 99 *
106 100 * This means the pages are still available to us, but hidden.
107 101 *
108 102 * @since 4.06.02
109 - *
110 - * @return void
111 103 */
112 104 public function hide_menu() {
113 105 remove_submenu_page( 'index.php', $this->page );
114 106 }
115 107
116 - /**
117 - * @return string
118 - *
119 - * @psalm-return ''
120 - */
121 108 protected function plugin_name() {
122 109 return '';
123 110 }
124 111
125 - /**
126 - * @return string
127 - */
128 112 protected function page_title() {
129 113 return __( 'Welcome to Formidable Forms', 'formidable' );
130 114 }
131 115
132 - /**
133 - * @return string
134 - */
135 116 protected function page_description() {
136 117 return __( 'Follow the steps below to get started.', 'formidable' );
137 118 }
138 119
@@ -142,10 +123,8 @@
142 123 * This function checks if a new install or update has just occurred. If so,
143 124 * then we redirect the user to the appropriate page.
144 125 *
145 126 * @since 4.06.02
146 - *
147 - * @return void
148 127 */
149 128 public function redirect() {
150 129
151 130 $current_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
@@ -154,9 +133,9 @@
154 133 return;
155 134 }
156 135
157 136 // Only do this for single site installs.
158 - if ( isset( $_GET['activate-multi'] ) || is_network_admin() ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
137 + if ( isset( $_GET['activate-multi'] ) || is_network_admin() ) { // WPCS: CSRF ok.
159 138 return;
160 139 }
161 140
162 141 // Check if we should consider redirection.
@@ -163,9 +142,9 @@
163 142 if ( ! $this->is_current_plugin() ) {
164 143 return;
165 144 }
166 145
167 - delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
146 + delete_transient( 'frm_activation_redirect' );
168 147
169 148 // Initial install.
170 149 wp_safe_redirect( $this->settings_link() );
171 150 exit;
@@ -170,16 +149,13 @@
170 149 wp_safe_redirect( $this->settings_link() );
171 150 exit;
172 151 }
173 152
174 - /**
175 - * @return string
176 - */
177 153 protected function settings_link() {
178 154 return admin_url( 'index.php?page=' . $this->page );
179 155 }
180 156
181 - /**
157 + /*
182 158 * Add page to global settings.
183 159 */
184 160 public function add_settings( $sections ) {
185 161 wp_enqueue_style( 'formidable-pro-fields' );
@@ -195,11 +171,8 @@
195 171
196 172 /*
197 173 * Output for global settings.
198 174 */
199 - /**
200 - * @return void
201 - */
202 175 public function settings_page() {
203 176 $steps = $this->get_steps_data();
204 177 if ( ! $steps['license']['complete'] || ( isset( $steps['plugin'] ) && ! $steps['plugin']['complete'] ) ) {
205 178 // Redirect to the welcome page if install hasn't been done.
@@ -217,9 +190,9 @@
217 190 if ( $steps['complete']['current'] ) {
218 191 // Always show this step in settings.
219 192 $step['current'] = true;
220 193
221 - $new_class = $all_imported ? ' button frm_hidden' : '';
194 + $new_class = $all_imported ? ' button frm_hidden' : '';
222 195 $step['button_class'] = str_replace( 'frm_grey disabled', $new_class, $step['button_class'] );
223 196 }
224 197 if ( $all_imported ) {
225 198 $step['description'] = __( 'The following form(s) have been created.', 'formidable' );
@@ -226,10 +199,10 @@
226 199 }
227 200 $this->show_app_install( $step );
228 201
229 202 if ( ! $all_imported ) {
230 - $step = $steps['complete'];
231 - $step['current'] = false;
203 + $step = $steps['complete'];
204 + $step['current'] = false;
232 205 $step['button_class'] .= ' frm_grey disabled';
233 206 $this->show_page_links( $step );
234 207 }
235 208 }
@@ -235,10 +208,8 @@
235 208 }
236 209
237 210 /**
238 211 * Getting Started screen. Shows after first install.
239 - *
240 - * @return void
241 212 */
242 213 public function output() {
243 214 FrmAppHelper::include_svg();
244 215 $this->css();
@@ -253,10 +224,8 @@
253 224 }
254 225
255 226 /**
256 227 * Heading section.
257 - *
258 - * @return void
259 228 */
260 229 protected function header() {
261 230 $size = array(
262 231 'height' => 90,
@@ -292,10 +261,8 @@
292 261
293 262 /**
294 263 * This is the welcome page content.
295 264 * Override me to insert different content.
296 - *
297 - * @return void
298 265 */
299 266 protected function main_content() {
300 267 $steps = $this->get_steps_data();
301 268 $this->license_box( $steps['license'] );
@@ -309,37 +276,37 @@
309 276 protected function get_steps_data() {
310 277 $pro_installed = FrmAppHelper::pro_is_connected();
311 278
312 279 $steps = array(
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,
280 + 'license' => array(
281 + 'label' => __( 'Connect to FormidableForms.com', 'formidable' ),
282 + 'description' => __( 'Create a connection to get plugin downloads.', 'formidable' ),
283 + 'button_label' => __( 'Connect an Account', 'formidable' ),
284 + 'current' => empty( $pro_installed ),
285 + 'complete' => $pro_installed,
286 + 'num' => 1,
320 287 ),
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,
288 + 'plugin' => array(
289 + 'label' => __( 'Install and Activate Add-Ons', 'formidable' ),
290 + 'description' => __( 'Install any required add-ons from FormidableForms.com.', 'formidable' ),
291 + 'button_label' => __( 'Install & Activate', 'formidable' ),
292 + 'current' => false,
293 + 'complete' => false,
294 + 'num' => 2,
328 295 ),
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,
296 + 'import' => array(
297 + 'label' => __( 'Setup Forms, Views, and Pages', 'formidable' ),
298 + 'description' => __( 'Build the forms, views, and pages automatically.', 'formidable' ),
299 + 'button_label' => __( 'Create Now', 'formidable' ),
300 + 'complete' => $this->is_complete(),
301 + 'num' => 3,
335 302 ),
336 303 'complete' => array(
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,
304 + 'label' => __( 'Customize Your New Pages', 'formidable' ),
305 + 'description' => __( 'Make any required changes and publish the page.', 'formidable' ),
306 + 'button_label' => __( 'View Page', 'formidable' ),
307 + 'complete' => false,
308 + 'num' => 4,
342 309 ),
343 310 );
344 311
345 312 $this->adjust_plugin_install_step( $steps );
@@ -351,9 +318,9 @@
351 318 if ( $step['complete'] ) {
352 319 $steps[ $k ]['current'] = false;
353 320 } else {
354 321 $steps[ $k ]['current'] = ! $has_current;
355 - $has_current = true;
322 + $has_current = true;
356 323 }
357 324 } elseif ( $step['current'] ) {
358 325 $has_current = true;
359 326 }
@@ -358,24 +325,19 @@
358 325 $has_current = true;
359 326 }
360 327
361 328 // Set disabled buttons.
362 - $class = $step['button_class'] ?? '';
329 + $class = isset( $step['button_class'] ) ? $step['button_class'] : '';
363 330 $class .= ' button-primary frm-button-primary';
364 331 if ( ! $steps[ $k ]['current'] ) {
365 332 $class .= ' frm_grey disabled';
366 333 }
367 334 $steps[ $k ]['button_class'] = $class;
368 - }//end foreach
335 + }
369 336
370 337 return $steps;
371 338 }
372 339
373 - /**
374 - * @param array $steps
375 - *
376 - * @return void
377 - */
378 340 protected function adjust_plugin_install_step( &$steps ) {
379 341 $plugins = $this->required_plugins();
380 342 if ( empty( $plugins ) ) {
381 343 unset( $steps['plugin'] );
@@ -390,8 +352,9 @@
390 352 $plugin = FrmAddonsController::install_link( $plugin_key );
391 353 if ( $plugin['status'] === 'active' ) {
392 354 continue;
393 355 }
356 + $links[ $plugin_key ] = $plugin;
394 357 if ( isset( $plugin['url'] ) ) {
395 358 $rel[] = $plugin['url'];
396 359 } else {
397 360 // Add-on is required but not allowed.
@@ -406,9 +369,9 @@
406 369 esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ),
407 370 implode( ', ', $missing )
408 371 );
409 372 } else {
410 - $steps['plugin']['links'] = $rel;
373 + $steps['plugin']['links'] = $rel;
411 374 $steps['plugin']['button_class'] = 'frm-solution-multiple ';
412 375 }
413 376
414 377 if ( $steps['license']['complete'] && ! $steps['plugin']['complete'] ) {
@@ -415,13 +378,10 @@
415 378 $steps['plugin']['current'] = true;
416 379 }
417 380 }
418 381
419 - /**
420 - * @return void
421 - */
422 382 protected function step_top( $step ) {
423 - $section_class = empty( $step['current'] ) ? 'frm_grey' : '';
383 + $section_class = ( ! isset( $step['current'] ) || ! $step['current'] ) ? 'frm_grey' : '';
424 384
425 385 ?>
426 386 <section class="step step-install <?php echo esc_attr( $section_class ); ?>">
427 387 <aside class="num">
@@ -453,11 +413,8 @@
453 413 <?php } ?>
454 414 <?php
455 415 }
456 416
457 - /**
458 - * @return void
459 - */
460 417 protected function step_bottom( $step ) {
461 418 ?>
462 419 </div>
463 420 </section>
@@ -465,10 +422,8 @@
465 422 }
466 423
467 424 /**
468 425 * Generate and output Connect step section HTML.
469 - *
470 - * @return void
471 426 */
472 427 protected function license_box( $step ) {
473 428 $this->step_top( $step );
474 429
@@ -484,16 +439,13 @@
484 439
485 440 $this->step_bottom( $step );
486 441 }
487 442
488 - /**
489 - * @return void
490 - */
491 443 protected function show_plugin_install( $step ) {
492 444 $this->step_top( $step );
493 445
494 446 if ( ! isset( $step['error'] ) ) {
495 - $rel = $step['links'] ?? array();
447 + $rel = isset( $step['links'] ) ? $step['links'] : array();
496 448
497 449 ?>
498 450 <a rel="<?php echo esc_attr( implode( ',', $rel ) ); ?>" class="<?php echo esc_attr( $step['button_class'] ); ?>">
499 451 <?php echo esc_html( $step['button_label'] ); ?>
@@ -503,11 +455,8 @@
503 455
504 456 $this->step_bottom( $step );
505 457 }
506 458
507 - /**
508 - * @return void
509 - */
510 459 protected function show_app_install( $step ) {
511 460 $is_complete = $step['complete'];
512 461 if ( ! empty( $this->form_options() ) && ! $is_complete ) {
513 462 $step['description'] = __( 'Select the form or view you would like to create.', 'formidable' );
@@ -517,9 +466,9 @@
517 466
518 467 $api = new FrmFormApi();
519 468 $addons = $api->get_api_info();
520 469
521 - $id = $this->download_id();
470 + $id = $this->download_id();
522 471 $has_file = isset( $addons[ $id ] ) && isset( $addons[ $id ]['beta'] );
523 472
524 473 if ( ! $step['current'] ) {
525 474 ?>
@@ -575,36 +524,21 @@
575 524 echo '</fieldset>';
576 525 } else {
577 526 echo '</form>';
578 527 }
579 - }//end if
528 + }
580 529
581 530 $this->step_bottom( $step );
582 531 }
583 532
584 - /**
585 - * @return void
586 - */
587 533 protected function show_form_options( $xml ) {
588 534 $this->show_import_options( $this->form_options(), 'form', $xml );
589 535 }
590 536
591 - /**
592 - * @return void
593 - */
594 537 protected function show_view_options() {
595 538 $this->show_import_options( $this->view_options(), 'view' );
596 539 }
597 540
598 - /**
599 - * @param array $options
600 - * @param string $importing
601 - * @param string $xml
602 - *
603 - * @psalm-param 'form'|'view' $importing
604 - *
605 - * @return void
606 - */
607 541 protected function show_import_options( $options, $importing, $xml = '' ) {
608 542 if ( empty( $options ) ) {
609 543 return;
610 544 }
@@ -613,9 +547,9 @@
613 547 $count = count( $options );
614 548 foreach ( $options as $info ) {
615 549 // Count the number of options displayed for css.
616 550 if ( $count > 1 && ! isset( $info['img'] ) ) {
617 - --$count;
551 + $count --;
618 552 }
619 553 }
620 554 $width = floor( ( 533 - ( ( $count - 1 ) * 20 ) ) / $count );
621 555 unset( $count );
@@ -621,14 +555,11 @@
621 555 unset( $count );
622 556
623 557 $selected = false;
624 558
625 - include FrmAppHelper::plugin_path() . '/classes/views/solutions/_import.php';
559 + include( FrmAppHelper::plugin_path() . '/classes/views/solutions/_import.php' );
626 560 }
627 561
628 - /**
629 - * @return void
630 - */
631 562 protected function show_page_options() {
632 563 $pages = $this->needed_pages();
633 564 if ( empty( $pages ) ) {
634 565 return;
@@ -646,11 +577,8 @@
646 577 <?php
647 578 }
648 579 }
649 580
650 - /**
651 - * @return void
652 - */
653 581 protected function show_page_links( $step ) {
654 582 if ( $step['current'] ) {
655 583 return;
656 584 }
@@ -667,24 +595,16 @@
667 595 }
668 596
669 597 /**
670 598 * Only show the content for the correct plugin.
671 - *
672 - * @return bool
673 599 */
674 600 protected function is_current_plugin() {
675 - $to_redirect = get_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
601 + $to_redirect = get_transient( 'frm_activation_redirect' );
676 602 return $to_redirect === $this->plugin_slug && empty( $this->is_complete() );
677 603 }
678 604
679 605 /**
680 606 * Override this function to indicate when install is complete.
681 - *
682 - * @param int|string $count
683 - *
684 - * @psalm-param 'all'|1 $count
685 - *
686 - * @return bool
687 607 */
688 608 protected function is_complete( $count = 1 ) {
689 609 $imported = $this->previously_imported_forms();
690 610 if ( $count === 'all' ) {
@@ -712,10 +632,8 @@
712 632 }
713 633
714 634 /**
715 635 * In the new plugin has any dependencies, include them here.
716 - *
717 - * @return array
718 636 */
719 637 protected function required_plugins() {
720 638 return array();
721 639 }
@@ -721,10 +639,8 @@
721 639 }
722 640
723 641 /**
724 642 * This needs to be overridden.
725 - *
726 - * @return int
727 643 */
728 644 protected function download_id() {
729 645 return 0;
730 646 }
@@ -730,10 +646,8 @@
730 646 }
731 647
732 648 /**
733 649 * Give options for which forms to import.
734 - *
735 - * @return array
736 650 */
737 651 protected function form_options() {
738 652 /**
739 653 * Example:
@@ -749,10 +663,8 @@
749 663 }
750 664
751 665 /**
752 666 * Give options for which view to use.
753 - *
754 - * @return array
755 667 */
756 668 protected function view_options() {
757 669 return array();
758 670 }
@@ -758,10 +670,8 @@
758 670 }
759 671
760 672 /**
761 673 * If the pages aren't imported automatically, set the page names.
762 - *
763 - * @return array
764 674 */
765 675 protected function needed_pages() {
766 676 /**
767 677 * Example:
@@ -776,16 +686,15 @@
776 686
777 687 return array();
778 688 }
779 689
780 - /**
781 - * @return void
782 - */
783 690 private function css() {
784 691 wp_enqueue_style( 'formidable-pro-fields' );
785 692 ?>
786 693 <style>
787 694 #frm-welcome *, #frm-welcome *::before, #frm-welcome *::after {
695 + -webkit-box-sizing: border-box;
696 + -moz-box-sizing: border-box;
788 697 box-sizing: border-box;
789 698 }
790 699 #frm-welcome{
791 700 width: 700px;
@@ -844,8 +753,10 @@
844 753 border-radius: 3px;
845 754 }
846 755 #frm-welcome .step,
847 756 #frm-welcome .screenshot .cont {
757 + -webkit-box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
758 + -moz-box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
848 759 box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
849 760 }
850 761 #frm-welcome .step {
851 762 background-color: #F9F9F9;
@@ -888,5 +799,6 @@
888 799 }
889 800 </style>
890 801 <?php
891 802 }
803 +
892 804 }