PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16
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/controllers/FrmOnboardingWizardController.php +104 -68 6.286.16 View file →
@@ -119,17 +119,15 @@
119 119 /**
120 120 * Initialize hooks for template page only.
121 121 *
122 122 * @since 6.9
123 - *
124 - * @return void
125 123 */
126 124 public static function load_admin_hooks() {
127 125 self::set_page_url();
128 - add_action( 'admin_init', self::class . '::do_admin_redirects' );
126 + add_action( 'admin_init', __CLASS__ . '::do_admin_redirects' );
129 127
130 128 if ( self::has_onboarding_been_skipped() ) {
131 - add_filter( 'option_frm_inbox', self::class . '::add_wizard_to_floating_links' );
129 + add_filter( 'option_frm_inbox', __CLASS__ . '::add_wizard_to_floating_links' );
132 130 }
133 131
134 132 // Load page if admin page is Onboarding Wizard.
135 133 self::maybe_load_page();
@@ -160,9 +158,8 @@
160 158 return;
161 159 }
162 160
163 161 $transient_value = get_transient( self::TRANSIENT_NAME );
164 -
165 162 if ( ! in_array( $transient_value, array( self::TRANSIENT_VALUE, self::TRANSIENT_MULTI_VALUE ), true ) ) {
166 163 return;
167 164 }
168 165
@@ -188,9 +185,8 @@
188 185 }
189 186
190 187 // Redirect to the onboarding wizard's initial step.
191 188 $page_url = add_query_arg( 'step', self::INITIAL_STEP, self::$page_url );
192 -
193 189 if ( wp_safe_redirect( esc_url_raw( $page_url ) ) ) {
194 190 exit;
195 191 }
196 192 }
@@ -202,23 +198,17 @@
202 198 *
203 199 * @return void
204 200 */
205 201 public static function maybe_load_page() {
206 - if ( ! self::is_onboarding_wizard_page() ) {
207 - return;
202 + if ( self::is_onboarding_wizard_page() ) {
203 + add_action( 'admin_menu', __CLASS__ . '::menu', 99 );
204 + add_action( 'admin_init', __CLASS__ . '::assign_properties' );
205 + add_action( 'admin_enqueue_scripts', __CLASS__ . '::enqueue_assets', 15 );
206 + add_action( 'admin_head', __CLASS__ . '::remove_menu' );
207 +
208 + add_filter( 'admin_body_class', __CLASS__ . '::add_admin_body_classes', 999 );
209 + add_filter( 'frm_show_footer_links', '__return_false' );
208 210 }
209 -
210 - // Dismiss the onboarding wizard message so it stops appearing after it is clicked.
211 - $message = new FrmInbox();
212 - $message->dismiss( 'onboarding_wizard' );
213 -
214 - add_action( 'admin_menu', self::class . '::menu', 99 );
215 - add_action( 'admin_init', self::class . '::assign_properties' );
216 - add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 );
217 - add_action( 'admin_head', self::class . '::remove_menu' );
218 -
219 - add_filter( 'admin_body_class', self::class . '::add_admin_body_classes', 999 );
220 - add_filter( 'frm_show_footer_links', '__return_false' );
221 211 }
222 212
223 213 /**
224 214 * Initializes class properties with essential values for operation.
@@ -259,9 +249,9 @@
259 249 'Formidable | ' . $label,
260 250 $label,
261 251 self::REQUIRED_CAPABILITY,
262 252 self::PAGE_SLUG,
263 - array( self::class, 'render' )
253 + array( __CLASS__, 'render' )
264 254 );
265 255 }
266 256
267 257 /**
@@ -317,9 +307,9 @@
317 307 // Remove the 'FrmProSettingsController::store' action to avoid PHP errors during AJAX call.
318 308 remove_action( 'frm_store_settings', 'FrmProSettingsController::store' );
319 309 $frm_settings->store();
320 310
321 - FrmEmailCollectionHelper::subscribe_to_active_campaign();
311 + self::subscribe_to_active_campaign();
322 312
323 313 // Send response.
324 314 wp_send_json_success();
325 315 }
@@ -324,8 +314,67 @@
324 314 wp_send_json_success();
325 315 }
326 316
327 317 /**
318 + * When the user consents to receiving news of updates, subscribe their email to ActiveCampaign.
319 + *
320 + * @since 6.16
321 + *
322 + * @return void
323 + */
324 + private static function subscribe_to_active_campaign() {
325 + $user = wp_get_current_user();
326 + if ( empty( $user->user_email ) ) {
327 + return;
328 + }
329 +
330 + if ( ! self::should_send_email_to_active_campaign( $user->user_email ) ) {
331 + return;
332 + }
333 +
334 + wp_remote_post(
335 + 'https://sandbox.formidableforms.com/api/wp-admin/admin-ajax.php?action=frm_forms_preview&form=subscribe-onboarding',
336 + array(
337 + 'body' => http_build_query(
338 + array(
339 + 'form_key' => 'subscribe-onboarding',
340 + 'frm_action' => 'create',
341 + 'form_id' => 5,
342 + 'item_key' => '',
343 + 'item_meta[0]' => '',
344 + 'item_meta[15]' => $user->user_email,
345 + 'item_meta[17]' => 'Source - FF Lite Plugin Onboarding',
346 + )
347 + ),
348 + )
349 + );
350 + }
351 +
352 + /**
353 + * Try to skip any fake emails.
354 + *
355 + * @since 6.16
356 + *
357 + * @param string $email
358 + * @return bool
359 + */
360 + private static function should_send_email_to_active_campaign( $email ) {
361 + $substrings = array(
362 + '@wpengine.local',
363 + '@example.com',
364 + '@localhost',
365 + '@local.dev',
366 + '@local.test',
367 + );
368 + foreach ( $substrings as $substring ) {
369 + if ( false !== strpos( $email, $substring ) ) {
370 + return false;
371 + }
372 + }
373 + return true;
374 + }
375 +
376 + /**
328 377 * Handle AJAX request to set up usage data for the Onboarding Wizard.
329 378 *
330 379 * @since 6.9
331 380 *
@@ -428,9 +477,8 @@
428 477 *
429 478 * @since 6.9
430 479 *
431 480 * @param string $classes Existing body classes.
432 - *
433 481 * @return string Updated list of body classes, including the newly added classes.
434 482 */
435 483 public static function add_admin_body_classes( $classes ) {
436 484 return $classes . ' frm-admin-full-screen';
@@ -439,9 +487,8 @@
439 487 /**
440 488 * Checks if the Onboarding Wizard was skipped during the plugin's installation.
441 489 *
442 490 * @since 6.9
443 - *
444 491 * @return bool True if the Onboarding Wizard was skipped, false otherwise.
445 492 */
446 493 public static function has_onboarding_been_skipped() {
447 494 return get_option( self::ONBOARDING_SKIPPED_OPTION, false );
@@ -450,13 +497,12 @@
450 497 /**
451 498 * Marks the Onboarding Wizard as skipped to prevent automatic redirects to the wizard.
452 499 *
453 500 * @since 6.9
454 - *
455 501 * @return void
456 502 */
457 503 public static function mark_onboarding_as_skipped() {
458 - update_option( self::ONBOARDING_SKIPPED_OPTION, true, false );
504 + update_option( self::ONBOARDING_SKIPPED_OPTION, true, 'no' );
459 505 }
460 506
461 507 /**
462 508 * Adds an Onboarding Wizard welcome message to the floating notifications.
@@ -462,29 +508,24 @@
462 508 * Adds an Onboarding Wizard welcome message to the floating notifications.
463 509 *
464 510 * @since 6.9
465 511 *
466 - * @param mixed $inbox_messages The inbox option data. An array of existing inbox messages if there is valid data set in the option.
467 - *
512 + * @param array $inbox_messages The array of existing inbox messages.
468 513 * @return array Configuration for the onboarding wizard slide-in notification.
469 514 */
470 515 public static function add_wizard_to_floating_links( $inbox_messages ) {
471 - $message = __( 'Welcome to Formidable Forms! Click here to run the Onboarding Wizard and it will guide you through the basic settings and get you started in 2 minutes.', 'formidable' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
516 + $message = __( 'Welcome to Formidable Forms! Click here to run the Onboarding Wizard and it will guide you through the basic settings and get you started in 2 minutes.', 'formidable' );
472 517
473 - if ( ! is_array( $inbox_messages ) ) {
474 - $inbox_messages = array();
475 - }
476 -
477 - $inbox_messages['onboarding_wizard'] = array(
478 - 'subject' => esc_html__( 'Begin With Ease!', 'formidable' ),
479 - 'message' => esc_html( $message ),
480 - 'slidein' => esc_html( $message ),
481 - 'cta' => '<a href="' . esc_url( self::$page_url ) . '" class="button-primary frm-button-primary" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Begin Setup', 'formidable' ) . '</a>', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
482 - 'created' => time(),
483 - 'key' => 'onboarding_wizard',
518 + return array(
519 + 'onboarding_wizard' => array(
520 + 'subject' => esc_html__( 'Begin With Ease!', 'formidable' ),
521 + 'message' => esc_html( $message ),
522 + 'slidein' => esc_html( $message ),
523 + 'cta' => '<a href="' . esc_url( self::$page_url ) . '" class="button-primary frm-button-primary" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Begin Setup', 'formidable' ) . '</a>',
524 + 'created' => time(),
525 + 'key' => 'onboarding_wizard',
526 + ),
484 527 );
485 -
486 - return $inbox_messages;
487 528 }
488 529
489 530 /**
490 531 * Check if the current page is the Onboarding Wizard page.
@@ -506,9 +547,9 @@
506 547 if ( get_option( self::REDIRECT_STATUS_OPTION ) ) {
507 548 return true;
508 549 }
509 550
510 - update_option( self::REDIRECT_STATUS_OPTION, FrmAppHelper::plugin_version(), false );
551 + update_option( self::REDIRECT_STATUS_OPTION, FrmAppHelper::plugin_version(), 'no' );
511 552 return false;
512 553 }
513 554
514 555 /**
@@ -640,41 +681,36 @@
640 681 foreach ( $available_pro_addons as $key => $data ) {
641 682 $addon = FrmAddonsController::get_addon( $data['addon_key'] );
642 683 $plugin_file = $data['plugin_file'];
643 684
644 - if ( is_plugin_active( $plugin_file ) || ! isset( $addon['url'] ) ) {
645 - continue;
685 + if ( ! is_plugin_active( $plugin_file ) && isset( $addon['url'] ) ) {
686 + $is_installed = array_key_exists( $plugin_file, $plugins );
687 +
688 + self::$available_addons[ $key ] = array(
689 + 'title' => $data['title'],
690 + 'rel' => $is_installed ? $plugin_file : $addon['url'],
691 + 'is-checked' => false,
692 + 'is-installed' => $is_installed,
693 + 'help-text' => $addon['excerpt'],
694 + );
646 695 }
647 -
648 - $is_installed = array_key_exists( $plugin_file, $plugins );
649 -
650 - self::$available_addons[ $key ] = array(
651 - 'title' => $data['title'],
652 - 'rel' => $is_installed ? $plugin_file : $addon['url'],
653 - 'is-checked' => false,
654 - 'is-installed' => $is_installed,
655 - 'help-text' => $addon['excerpt'],
656 - );
657 696 }
658 697 }//end if
659 698
660 699 // Gravity Forms Migrator add-on.
661 700 $gravity_forms_plugin = 'formidable-gravity-forms-importer/formidable-gravity-forms-importer.php';
701 + if ( class_exists( 'GFForms' ) && ! is_plugin_active( $gravity_forms_plugin ) ) {
702 + $is_installed_gravity_forms = array_key_exists( $gravity_forms_plugin, $plugins );
662 703
663 - if ( ! class_exists( 'GFForms' ) || is_plugin_active( $gravity_forms_plugin ) ) {
664 - return;
704 + self::$available_addons['formidable-gravity-forms-importer'] = array(
705 + 'title' => esc_html__( 'Gravity Forms Migrator', 'formidable' ),
706 + 'rel' => $is_installed_gravity_forms ? $gravity_forms_plugin : 'formidable-gravity-forms-importer',
707 + 'is-checked' => false,
708 + 'is-vendor' => true,
709 + 'is-installed' => $is_installed_gravity_forms,
710 + 'help-text' => esc_html__( 'Easily migrate your forms from Gravity Forms to Formidable.', 'formidable' ),
711 + );
665 712 }
666 -
667 - $is_installed_gravity_forms = array_key_exists( $gravity_forms_plugin, $plugins );
668 -
669 - self::$available_addons['formidable-gravity-forms-importer'] = array(
670 - 'title' => esc_html__( 'Gravity Forms Migrator', 'formidable' ),
671 - 'rel' => $is_installed_gravity_forms ? $gravity_forms_plugin : 'formidable-gravity-forms-importer',
672 - 'is-checked' => false,
673 - 'is-vendor' => true,
674 - 'is-installed' => $is_installed_gravity_forms,
675 - 'help-text' => esc_html__( 'Easily migrate your forms from Gravity Forms to Formidable.', 'formidable' ),
676 - );
677 713 }
678 714
679 715 /**
680 716 * Get the path to the Onboarding Wizard views.