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 +73 -238 6.295.0 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,23 +19,15 @@
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 - if ( ! $this->plugin_slug ) {
29 + if ( empty( $this->plugin_slug ) ) {
46 30 return;
47 31 }
48 32
49 33 add_action( 'plugins_loaded', array( $this, 'load_hooks' ), 50 );
@@ -48,9 +32,9 @@
48 32
49 33 add_action( 'plugins_loaded', array( $this, 'load_hooks' ), 50 );
50 34 add_action( 'admin_init', array( $this, 'redirect' ), 9999 );
51 35
52 - if ( ! $this->plugin_file ) {
36 + if ( empty( $this->plugin_file ) ) {
53 37 $this->plugin_file = $this->plugin_slug . '.php';
54 38 }
55 39 }
56 40
@@ -57,10 +41,8 @@
57 41 /**
58 42 * Register all WP hooks.
59 43 *
60 44 * @since 4.06.02
61 - *
62 - * @return void
63 45 */
64 46 public function load_hooks() {
65 47 // If user is in admin ajax or doing cron, return.
66 48 if ( wp_doing_cron() ) {
@@ -82,16 +64,11 @@
82 64 add_action( 'admin_menu', array( $this, 'register' ) );
83 65 add_action( 'admin_head', array( $this, 'hide_menu' ) );
84 66 }
85 67
86 - /**
87 - * @param array $links
88 - *
89 - * @return array
90 - */
91 68 public function plugin_links( $links ) {
92 69 if ( ! $this->is_complete() ) {
93 - $settings = '<a href="' . esc_url( $this->settings_link() ) . '">' . esc_html__( 'Setup', 'formidable' ) . '</a>';
70 + $settings = '<a href="' . esc_url( $this->settings_link() ) . '">' . __( 'Setup', 'formidable' ) . '</a>';
94 71 array_unshift( $links, $settings );
95 72 }
96 73
97 74 return $links;
@@ -103,12 +80,11 @@
103 80 * These pages will be removed from the Dashboard menu, so they will
104 81 * not actually show. Sneaky, sneaky.
105 82 *
106 83 * @since 4.06.02
107 - *
108 - * @return void
109 84 */
110 85 public function register() {
86 +
111 87 // Getting started - shows after installation.
112 88 add_dashboard_page(
113 89 esc_html( $this->page_title() ),
114 90 esc_html( $this->page_title() ),
@@ -123,34 +99,21 @@
123 99 *
124 100 * This means the pages are still available to us, but hidden.
125 101 *
126 102 * @since 4.06.02
127 - *
128 - * @return void
129 103 */
130 104 public function hide_menu() {
131 105 remove_submenu_page( 'index.php', $this->page );
132 106 }
133 107
134 - /**
135 - * @return string
136 - *
137 - * @psalm-return ''
138 - */
139 108 protected function plugin_name() {
140 109 return '';
141 110 }
142 111
143 - /**
144 - * @return string
145 - */
146 112 protected function page_title() {
147 113 return __( 'Welcome to Formidable Forms', 'formidable' );
148 114 }
149 115
150 - /**
151 - * @return string
152 - */
153 116 protected function page_description() {
154 117 return __( 'Follow the steps below to get started.', 'formidable' );
155 118 }
156 119
@@ -160,14 +123,12 @@
160 123 * This function checks if a new install or update has just occurred. If so,
161 124 * then we redirect the user to the appropriate page.
162 125 *
163 126 * @since 4.06.02
164 - *
165 - * @return void
166 127 */
167 128 public function redirect() {
129 +
168 130 $current_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
169 -
170 131 if ( $current_page === $this->page ) {
171 132 // Prevent endless loop.
172 133 return;
173 134 }
@@ -172,9 +133,9 @@
172 133 return;
173 134 }
174 135
175 136 // Only do this for single site installs.
176 - 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.
177 138 return;
178 139 }
179 140
180 141 // Check if we should consider redirection.
@@ -181,9 +142,9 @@
181 142 if ( ! $this->is_current_plugin() ) {
182 143 return;
183 144 }
184 145
185 - delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
146 + delete_transient( 'frm_activation_redirect' );
186 147
187 148 // Initial install.
188 149 wp_safe_redirect( $this->settings_link() );
189 150 exit;
@@ -188,21 +149,14 @@
188 149 wp_safe_redirect( $this->settings_link() );
189 150 exit;
190 151 }
191 152
192 - /**
193 - * @return string
194 - */
195 153 protected function settings_link() {
196 154 return admin_url( 'index.php?page=' . $this->page );
197 155 }
198 156
199 - /**
157 + /*
200 158 * Add page to global settings.
201 - *
202 - * @param array $sections Sections.
203 - *
204 - * @return array
205 159 */
206 160 public function add_settings( $sections ) {
207 161 wp_enqueue_style( 'formidable-pro-fields' );
208 162 $sections[ $this->plugin_slug ] = array(
@@ -217,14 +171,10 @@
217 171
218 172 /*
219 173 * Output for global settings.
220 174 */
221 - /**
222 - * @return void
223 - */
224 175 public function settings_page() {
225 176 $steps = $this->get_steps_data();
226 -
227 177 if ( ! $steps['license']['complete'] || ( isset( $steps['plugin'] ) && ! $steps['plugin']['complete'] ) ) {
228 178 // Redirect to the welcome page if install hasn't been done.
229 179 $url = $this->settings_link();
230 180 echo '<script>window.location.replace("' . esc_url_raw( $url ) . '");</script>';
@@ -230,9 +180,10 @@
230 180 echo '<script>window.location.replace("' . esc_url_raw( $url ) . '");</script>';
231 181 return;
232 182 }
233 183
234 - $all_imported = $this->is_complete( 'all' );
184 + $all_imported = $this->is_complete( 'all' );
185 +
235 186 $step = $steps['import'];
236 187 $step['label'] = '';
237 188 $step['nested'] = true;
238 189
@@ -239,33 +190,26 @@
239 190 if ( $steps['complete']['current'] ) {
240 191 // Always show this step in settings.
241 192 $step['current'] = true;
242 193
243 - $new_class = $all_imported ? ' button frm_hidden' : '';
194 + $new_class = $all_imported ? ' button frm_hidden' : '';
244 195 $step['button_class'] = str_replace( 'frm_grey disabled', $new_class, $step['button_class'] );
245 196 }
246 -
247 197 if ( $all_imported ) {
248 198 $step['description'] = __( 'The following form(s) have been created.', 'formidable' );
249 199 }
250 -
251 200 $this->show_app_install( $step );
252 201
253 - if ( $all_imported ) {
254 - return;
202 + if ( ! $all_imported ) {
203 + $step = $steps['complete'];
204 + $step['current'] = false;
205 + $step['button_class'] .= ' frm_grey disabled';
206 + $this->show_page_links( $step );
255 207 }
256 -
257 - $step = $steps['complete'];
258 - $step['current'] = false;
259 - $step['button_class'] .= ' frm_grey disabled';
260 -
261 - $this->show_page_links( $step );
262 208 }
263 209
264 210 /**
265 211 * Getting Started screen. Shows after first install.
266 - *
267 - * @return void
268 212 */
269 213 public function output() {
270 214 FrmAppHelper::include_svg();
271 215 $this->css();
@@ -280,10 +224,8 @@
280 224 }
281 225
282 226 /**
283 227 * Heading section.
284 - *
285 - * @return void
286 228 */
287 229 protected function header() {
288 230 $size = array(
289 231 'height' => 90,
@@ -289,9 +231,8 @@
289 231 'height' => 90,
290 232 'width' => 90,
291 233 );
292 234
293 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
294 235 ?>
295 236 <section class="top">
296 237 <div class="frm-smtp-logos">
297 238 <?php FrmAppHelper::show_logo( $size ); ?>
@@ -315,21 +256,17 @@
315 256 <h1><?php echo esc_html( $this->page_title() ); ?></h1>
316 257 <p><?php echo esc_html( $this->page_description() ); ?></p>
317 258 </section>
318 259 <?php
319 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
320 260 }
321 261
322 262 /**
323 263 * This is the welcome page content.
324 264 * Override me to insert different content.
325 - *
326 - * @return void
327 265 */
328 266 protected function main_content() {
329 267 $steps = $this->get_steps_data();
330 268 $this->license_box( $steps['license'] );
331 -
332 269 if ( isset( $steps['plugin'] ) ) {
333 270 $this->show_plugin_install( $steps['plugin'] );
334 271 }
335 272 $this->show_app_install( $steps['import'] );
@@ -335,44 +272,41 @@
335 272 $this->show_app_install( $steps['import'] );
336 273 $this->show_page_links( $steps['complete'] );
337 274 }
338 275
339 - /**
340 - * @return array
341 - */
342 276 protected function get_steps_data() {
343 277 $pro_installed = FrmAppHelper::pro_is_connected();
344 278
345 279 $steps = array(
346 - 'license' => array(
347 - 'label' => __( 'Connect to FormidableForms.com', 'formidable' ),
348 - 'description' => __( 'Create a connection to get plugin downloads.', 'formidable' ),
349 - 'button_label' => __( 'Connect an Account', 'formidable' ),
350 - 'current' => ! $pro_installed,
351 - 'complete' => $pro_installed,
352 - '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,
353 287 ),
354 - 'plugin' => array(
355 - 'label' => __( 'Install and Activate Add-Ons', 'formidable' ),
356 - 'description' => __( 'Install any required add-ons from FormidableForms.com.', 'formidable' ),
357 - 'button_label' => __( 'Install & Activate', 'formidable' ),
358 - 'current' => false,
359 - 'complete' => false,
360 - '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,
361 295 ),
362 - 'import' => array(
363 - 'label' => __( 'Setup Forms, Views, and Pages', 'formidable' ),
364 - 'description' => __( 'Build the forms, views, and pages automatically.', 'formidable' ),
365 - 'button_label' => __( 'Create Now', 'formidable' ),
366 - 'complete' => $this->is_complete(),
367 - '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,
368 302 ),
369 303 'complete' => array(
370 - 'label' => __( 'Customize Your New Pages', 'formidable' ),
371 - 'description' => __( 'Make any required changes and publish the page.', 'formidable' ),
372 - 'button_label' => __( 'View Page', 'formidable' ),
373 - 'complete' => false,
374 - '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,
375 309 ),
376 310 );
377 311
378 312 $this->adjust_plugin_install_step( $steps );
@@ -377,9 +311,8 @@
377 311
378 312 $this->adjust_plugin_install_step( $steps );
379 313
380 314 $has_current = false;
381 -
382 315 foreach ( $steps as $k => $step ) {
383 316 // Set the current step.
384 317 if ( ! isset( $step['current'] ) ) {
385 318 if ( $step['complete'] ) {
@@ -385,9 +318,9 @@
385 318 if ( $step['complete'] ) {
386 319 $steps[ $k ]['current'] = false;
387 320 } else {
388 321 $steps[ $k ]['current'] = ! $has_current;
389 - $has_current = true;
322 + $has_current = true;
390 323 }
391 324 } elseif ( $step['current'] ) {
392 325 $has_current = true;
393 326 }
@@ -392,29 +325,22 @@
392 325 $has_current = true;
393 326 }
394 327
395 328 // Set disabled buttons.
396 - $class = $step['button_class'] ?? '';
329 + $class = isset( $step['button_class'] ) ? $step['button_class'] : '';
397 330 $class .= ' button-primary frm-button-primary';
398 -
399 331 if ( ! $steps[ $k ]['current'] ) {
400 332 $class .= ' frm_grey disabled';
401 333 }
402 334 $steps[ $k ]['button_class'] = $class;
403 - }//end foreach
335 + }
404 336
405 337 return $steps;
406 338 }
407 339
408 - /**
409 - * @param array $steps
410 - *
411 - * @return void
412 - */
413 340 protected function adjust_plugin_install_step( &$steps ) {
414 341 $plugins = $this->required_plugins();
415 -
416 - if ( ! $plugins ) {
342 + if ( empty( $plugins ) ) {
417 343 unset( $steps['plugin'] );
418 344 $steps['import']['num'] = 2;
419 345 $steps['complete']['num'] = 3;
420 346 return;
@@ -421,16 +347,14 @@
421 347 }
422 348
423 349 $missing = array();
424 350 $rel = array();
425 -
426 351 foreach ( $plugins as $plugin_key ) {
427 352 $plugin = FrmAddonsController::install_link( $plugin_key );
428 -
429 353 if ( $plugin['status'] === 'active' ) {
430 354 continue;
431 355 }
432 -
356 + $links[ $plugin_key ] = $plugin;
433 357 if ( isset( $plugin['url'] ) ) {
434 358 $rel[] = $plugin['url'];
435 359 } else {
436 360 // Add-on is required but not allowed.
@@ -436,12 +360,11 @@
436 360 // Add-on is required but not allowed.
437 361 $missing[] = $plugin_key;
438 362 }
439 363 }
440 -
441 - if ( ! $rel && ! $missing ) {
364 + if ( empty( $rel ) && empty( $missing ) ) {
442 365 $steps['plugin']['complete'] = true;
443 - } elseif ( $missing ) {
366 + } elseif ( ! empty( $missing ) ) {
444 367 $steps['plugin']['error'] = sprintf(
445 368 /* translators: %1$s: Plugin name */
446 369 esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ),
447 370 implode( ', ', $missing )
@@ -446,9 +369,9 @@
446 369 esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ),
447 370 implode( ', ', $missing )
448 371 );
449 372 } else {
450 - $steps['plugin']['links'] = $rel;
373 + $steps['plugin']['links'] = $rel;
451 374 $steps['plugin']['button_class'] = 'frm-solution-multiple ';
452 375 }
453 376
454 377 if ( $steps['license']['complete'] && ! $steps['plugin']['complete'] ) {
@@ -455,22 +378,16 @@
455 378 $steps['plugin']['current'] = true;
456 379 }
457 380 }
458 381
459 - /**
460 - * @param array $step Step.
461 - *
462 - * @return void
463 - */
464 382 protected function step_top( $step ) {
465 - $section_class = ! empty( $step['current'] ) ? '' : 'frm_grey';
383 + $section_class = ( ! isset( $step['current'] ) || ! $step['current'] ) ? 'frm_grey' : '';
466 384
467 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
468 385 ?>
469 386 <section class="step step-install <?php echo esc_attr( $section_class ); ?>">
470 387 <aside class="num">
471 388 <?php
472 - if ( ! empty( $step['complete'] ) ) {
389 + if ( isset( $step['complete'] ) && $step['complete'] ) {
473 390 FrmAppHelper::icon_by_class(
474 391 'frmfont frm_step_complete_icon',
475 392 array(
476 393 /* translators: %1$s: Step number */
@@ -479,9 +396,9 @@
479 396 )
480 397 );
481 398 } else {
482 399 ?>
483 - <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 ?>
400 + <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>
484 401 <?php
485 402 }
486 403 ?>
487 404 <i class="loader hidden"></i>
@@ -494,43 +411,29 @@
494 411 <?php if ( isset( $step['error'] ) ) { ?>
495 412 <p class="frm_error"><?php echo esc_html( $step['error'] ); ?></p>
496 413 <?php } ?>
497 414 <?php
498 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
499 415 }
500 416
501 - /**
502 - * @param array $step Step.
503 - *
504 - * @return void
505 - */
506 417 protected function step_bottom( $step ) {
507 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
508 418 ?>
509 419 </div>
510 420 </section>
511 421 <?php
512 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
513 422 }
514 423
515 424 /**
516 425 * Generate and output Connect step section HTML.
517 - *
518 - * @param array $step Step.
519 - *
520 - * @return void
521 426 */
522 427 protected function license_box( $step ) {
523 428 $this->step_top( $step );
524 429
525 430 if ( $step['complete'] ) {
526 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
527 431 ?>
528 432 <a href="#" class="<?php echo esc_attr( $step['button_class'] ); ?>">
529 433 <?php echo esc_html( $step['button_label'] ); ?>
530 434 </a>
531 435 <?php
532 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
533 436 } else {
534 437 FrmSettingsController::license_box();
535 438 }
536 439
@@ -536,51 +439,38 @@
536 439
537 440 $this->step_bottom( $step );
538 441 }
539 442
540 - /**
541 - * @param array $step Step.
542 - *
543 - * @return void
544 - */
545 443 protected function show_plugin_install( $step ) {
546 444 $this->step_top( $step );
547 445
548 446 if ( ! isset( $step['error'] ) ) {
549 - $rel = $step['links'] ?? array();
447 + $rel = isset( $step['links'] ) ? $step['links'] : array();
550 448
551 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
552 449 ?>
553 450 <a rel="<?php echo esc_attr( implode( ',', $rel ) ); ?>" class="<?php echo esc_attr( $step['button_class'] ); ?>">
554 451 <?php echo esc_html( $step['button_label'] ); ?>
555 452 </a>
556 453 <?php
557 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
558 454 }
559 455
560 456 $this->step_bottom( $step );
561 457 }
562 458
563 - /**
564 - * @param array $step Step.
565 - *
566 - * @return void
567 - */
568 459 protected function show_app_install( $step ) {
569 460 $is_complete = $step['complete'];
570 -
571 - if ( $this->form_options() && ! $is_complete ) {
461 + if ( ! empty( $this->form_options() ) && ! $is_complete ) {
572 462 $step['description'] = __( 'Select the form or view you would like to create.', 'formidable' );
573 463 }
574 464
575 465 $this->step_top( $step );
576 466
577 - $api = new FrmFormApi();
578 - $addons = $api->get_api_info();
579 - $id = $this->download_id();
467 + $api = new FrmFormApi();
468 + $addons = $api->get_api_info();
469 +
470 + $id = $this->download_id();
580 471 $has_file = isset( $addons[ $id ] ) && isset( $addons[ $id ]['beta'] );
581 472
582 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
583 473 if ( ! $step['current'] ) {
584 474 ?>
585 475 <a href="#" class="<?php echo esc_attr( $step['button_class'] ); ?>">
586 476 <?php echo esc_html( $step['button_label'] ); ?>
@@ -593,12 +483,11 @@
593 483
594 484 if ( ! $has_file ) {
595 485 echo '<p class="frm_error_style">' . esc_html__( 'We didn\'t find anything to import. Please contact our team.', 'formidable' ) . '</p>';
596 486 } elseif ( ! isset( $addons[ $id ]['beta']['package'] ) ) {
597 - 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
487 + 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>';
598 488 } else {
599 489 $xml = $addons[ $id ]['beta']['package'];
600 -
601 490 if ( is_array( $xml ) ) {
602 491 $xml = reset( $xml );
603 492 }
604 493
@@ -635,93 +524,61 @@
635 524 echo '</fieldset>';
636 525 } else {
637 526 echo '</form>';
638 527 }
639 - }//end if
640 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
528 + }
641 529
642 530 $this->step_bottom( $step );
643 531 }
644 532
645 - /**
646 - * @param string $xml
647 - *
648 - * @return void
649 - */
650 533 protected function show_form_options( $xml ) {
651 534 $this->show_import_options( $this->form_options(), 'form', $xml );
652 535 }
653 536
654 - /**
655 - * @return void
656 - */
657 537 protected function show_view_options() {
658 538 $this->show_import_options( $this->view_options(), 'view' );
659 539 }
660 540
661 - /**
662 - * @param array $options
663 - * @param string $importing
664 - * @param string $xml
665 - *
666 - * @psalm-param 'form'|'view' $importing
667 - *
668 - * @return void
669 - */
670 541 protected function show_import_options( $options, $importing, $xml = '' ) {
671 - if ( ! $options ) {
542 + if ( empty( $options ) ) {
672 543 return;
673 544 }
674 545
675 546 $imported = $this->previously_imported_forms();
676 547 $count = count( $options );
677 -
678 548 foreach ( $options as $info ) {
679 549 // Count the number of options displayed for css.
680 550 if ( $count > 1 && ! isset( $info['img'] ) ) {
681 - --$count;
551 + $count --;
682 552 }
683 553 }
684 -
685 554 $width = floor( ( 533 - ( ( $count - 1 ) * 20 ) ) / $count );
686 555 unset( $count );
687 556
688 557 $selected = false;
689 558
690 - include FrmAppHelper::plugin_path() . '/classes/views/solutions/_import.php';
559 + include( FrmAppHelper::plugin_path() . '/classes/views/solutions/_import.php' );
691 560 }
692 561
693 - /**
694 - * @return void
695 - */
696 562 protected function show_page_options() {
697 563 $pages = $this->needed_pages();
698 -
699 - if ( ! $pages ) {
564 + if ( empty( $pages ) ) {
700 565 return;
701 566 }
702 567
703 568 echo '<h3>Choose New Page Title</h3>';
704 -
705 569 foreach ( $pages as $page ) {
706 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
707 570 ?>
708 571 <p>
709 572 <label for="pages_<?php echo esc_html( $page['type'] ); ?>">
710 573 <?php echo esc_html( $page['label'] ); ?>
711 574 </label>
712 - <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 ?>
575 + <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 />
713 576 </p>
714 577 <?php
715 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
716 578 }
717 579 }
718 580
719 - /**
720 - * @param array $step
721 - *
722 - * @return void
723 - */
724 581 protected function show_page_links( $step ) {
725 582 if ( $step['current'] ) {
726 583 return;
727 584 }
@@ -727,15 +584,13 @@
727 584 }
728 585
729 586 $this->step_top( $step );
730 587
731 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
732 588 ?>
733 589 <a href="#" target="_blank" rel="noopener" id="frm-redirect-link" class="<?php echo esc_attr( $step['button_class'] ); ?>">
734 590 <?php echo esc_html( $step['button_label'] ); ?>
735 591 </a>
736 592 <?php
737 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
738 593
739 594 $this->step_bottom( $step );
740 595 }
741 596
@@ -740,32 +595,22 @@
740 595 }
741 596
742 597 /**
743 598 * Only show the content for the correct plugin.
744 - *
745 - * @return bool
746 599 */
747 600 protected function is_current_plugin() {
748 - $to_redirect = get_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
749 - return $to_redirect === $this->plugin_slug && ! $this->is_complete();
601 + $to_redirect = get_transient( 'frm_activation_redirect' );
602 + return $to_redirect === $this->plugin_slug && empty( $this->is_complete() );
750 603 }
751 604
752 605 /**
753 606 * Override this function to indicate when install is complete.
754 - *
755 - * @param int|string $count
756 - *
757 - * @psalm-param 'all'|1 $count
758 - *
759 - * @return bool
760 607 */
761 608 protected function is_complete( $count = 1 ) {
762 609 $imported = $this->previously_imported_forms();
763 -
764 610 if ( $count === 'all' ) {
765 611 return count( $imported ) >= count( $this->form_options() );
766 612 }
767 -
768 613 return ! empty( $imported );
769 614 }
770 615
771 616 /**
@@ -775,12 +620,10 @@
775 620 */
776 621 protected function previously_imported_forms() {
777 622 $imported = array();
778 623 $forms = $this->form_options();
779 -
780 624 foreach ( $forms as $form ) {
781 625 $was_imported = isset( $form['form'] ) ? FrmForm::get_id_by_key( $form['form'] ) : false;
782 -
783 626 if ( $was_imported ) {
784 627 $imported[ $form['form'] ] = $was_imported;
785 628 }
786 629 }
@@ -789,10 +632,8 @@
789 632 }
790 633
791 634 /**
792 635 * In the new plugin has any dependencies, include them here.
793 - *
794 - * @return array
795 636 */
796 637 protected function required_plugins() {
797 638 return array();
798 639 }
@@ -798,10 +639,8 @@
798 639 }
799 640
800 641 /**
801 642 * This needs to be overridden.
802 - *
803 - * @return int
804 643 */
805 644 protected function download_id() {
806 645 return 0;
807 646 }
@@ -807,10 +646,8 @@
807 646 }
808 647
809 648 /**
810 649 * Give options for which forms to import.
811 - *
812 - * @return array
813 650 */
814 651 protected function form_options() {
815 652 /**
816 653 * Example:
@@ -826,10 +663,8 @@
826 663 }
827 664
828 665 /**
829 666 * Give options for which view to use.
830 - *
831 - * @return array
832 667 */
833 668 protected function view_options() {
834 669 return array();
835 670 }
@@ -835,10 +670,8 @@
835 670 }
836 671
837 672 /**
838 673 * If the pages aren't imported automatically, set the page names.
839 - *
840 - * @return array
841 674 */
842 675 protected function needed_pages() {
843 676 /**
844 677 * Example:
@@ -853,16 +686,15 @@
853 686
854 687 return array();
855 688 }
856 689
857 - /**
858 - * @return void
859 - */
860 690 private function css() {
861 691 wp_enqueue_style( 'formidable-pro-fields' );
862 692 ?>
863 693 <style>
864 694 #frm-welcome *, #frm-welcome *::before, #frm-welcome *::after {
695 + -webkit-box-sizing: border-box;
696 + -moz-box-sizing: border-box;
865 697 box-sizing: border-box;
866 698 }
867 699 #frm-welcome{
868 700 width: 700px;
@@ -921,8 +753,10 @@
921 753 border-radius: 3px;
922 754 }
923 755 #frm-welcome .step,
924 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);
925 759 box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
926 760 }
927 761 #frm-welcome .step {
928 762 background-color: #F9F9F9;
@@ -965,5 +799,6 @@
965 799 }
966 800 </style>
967 801 <?php
968 802 }
803 +
969 804 }