PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.19
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.19
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 +118 -74 6.356.19 View file →
@@ -119,26 +119,19 @@
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 - /**
135 - * Load page if admin page is Onboarding Wizard.
136 - * This waits for init because it reads the inbox option, and the filter above translates
137 - * when it does. Translating before the text domain is loaded triggers a
138 - * _load_textdomain_just_in_time notice in WordPress 6.7+.
139 - */
140 - add_action( 'init', self::class . '::maybe_load_page' );
132 + // Load page if admin page is Onboarding Wizard.
133 + self::maybe_load_page();
141 134 }
142 135
143 136 /**
144 137 * Performs a safe redirect to the welcome screen when the plugin is activated.
@@ -165,9 +158,8 @@
165 158 return;
166 159 }
167 160
168 161 $transient_value = get_transient( self::TRANSIENT_NAME );
169 -
170 162 if ( ! in_array( $transient_value, array( self::TRANSIENT_VALUE, self::TRANSIENT_MULTI_VALUE ), true ) ) {
171 163 return;
172 164 }
173 165
@@ -193,9 +185,8 @@
193 185 }
194 186
195 187 // Redirect to the onboarding wizard's initial step.
196 188 $page_url = add_query_arg( 'step', self::INITIAL_STEP, self::$page_url );
197 -
198 189 if ( wp_safe_redirect( esc_url_raw( $page_url ) ) ) {
199 190 exit;
200 191 }
201 192 }
@@ -207,23 +198,21 @@
207 198 *
208 199 * @return void
209 200 */
210 201 public static function maybe_load_page() {
211 - if ( ! self::is_onboarding_wizard_page() ) {
212 - return;
213 - }
202 + if ( self::is_onboarding_wizard_page() ) {
203 + // Dismiss the onboarding wizard message so it stops appearing after it is clicked.
204 + $message = new FrmInbox();
205 + $message->dismiss( 'onboarding_wizard' );
214 206
215 - // Dismiss the onboarding wizard message so it stops appearing after it is clicked.
216 - $message = new FrmInbox();
217 - $message->dismiss( 'onboarding_wizard' );
207 + add_action( 'admin_menu', __CLASS__ . '::menu', 99 );
208 + add_action( 'admin_init', __CLASS__ . '::assign_properties' );
209 + add_action( 'admin_enqueue_scripts', __CLASS__ . '::enqueue_assets', 15 );
210 + add_action( 'admin_head', __CLASS__ . '::remove_menu' );
218 211
219 - add_action( 'admin_menu', self::class . '::menu', 99 );
220 - add_action( 'admin_init', self::class . '::assign_properties' );
221 - add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 );
222 - add_action( 'admin_head', self::class . '::remove_menu' );
223 -
224 - add_filter( 'admin_body_class', self::class . '::add_admin_body_classes', 999 );
225 - add_filter( 'frm_show_footer_links', '__return_false' );
212 + add_filter( 'admin_body_class', __CLASS__ . '::add_admin_body_classes', 999 );
213 + add_filter( 'frm_show_footer_links', '__return_false' );
214 + }
226 215 }
227 216
228 217 /**
229 218 * Initializes class properties with essential values for operation.
@@ -264,9 +253,9 @@
264 253 'Formidable | ' . $label,
265 254 $label,
266 255 self::REQUIRED_CAPABILITY,
267 256 self::PAGE_SLUG,
268 - array( self::class, 'render' )
257 + array( __CLASS__, 'render' )
269 258 );
270 259 }
271 260
272 261 /**
@@ -322,9 +311,9 @@
322 311 // Remove the 'FrmProSettingsController::store' action to avoid PHP errors during AJAX call.
323 312 remove_action( 'frm_store_settings', 'FrmProSettingsController::store' );
324 313 $frm_settings->store();
325 314
326 - FrmEmailCollectionHelper::subscribe_to_active_campaign();
315 + self::subscribe_to_active_campaign();
327 316
328 317 // Send response.
329 318 wp_send_json_success();
330 319 }
@@ -329,8 +318,76 @@
329 318 wp_send_json_success();
330 319 }
331 320
332 321 /**
322 + * When the user consents to receiving news of updates, subscribe their email to ActiveCampaign.
323 + *
324 + * @since 6.16
325 + *
326 + * @return void
327 + */
328 + private static function subscribe_to_active_campaign() {
329 + $user = wp_get_current_user();
330 + if ( empty( $user->user_email ) ) {
331 + return;
332 + }
333 +
334 + if ( ! self::should_send_email_to_active_campaign( $user->user_email ) ) {
335 + return;
336 + }
337 +
338 + $user_id = $user->ID;
339 + $first_name = get_user_meta( $user_id, 'first_name', true );
340 + $last_name = get_user_meta( $user_id, 'last_name', true );
341 +
342 + wp_remote_post(
343 + 'https://sandbox.formidableforms.com/api/wp-admin/admin-ajax.php?action=frm_forms_preview&form=subscribe-onboarding',
344 + array(
345 + 'body' => http_build_query(
346 + array(
347 + 'form_key' => 'subscribe-onboarding',
348 + 'frm_action' => 'create',
349 + 'form_id' => 5,
350 + 'item_key' => '',
351 + 'item_meta[0]' => '',
352 + 'item_meta[15]' => $user->user_email,
353 + 'item_meta[17]' => 'Source - FF Lite Plugin Onboarding',
354 + 'item_meta[18]' => is_string( $first_name ) ? $first_name : '',
355 + 'item_meta[19]' => is_string( $last_name ) ? $last_name : '',
356 + )
357 + ),
358 + )
359 + );
360 + }
361 +
362 + /**
363 + * Try to skip any fake emails.
364 + *
365 + * @since 6.16
366 + *
367 + * @param string $email
368 + * @return bool
369 + */
370 + private static function should_send_email_to_active_campaign( $email ) {
371 + $substrings = array(
372 + '@wpengine.local',
373 + '@example.com',
374 + '@localhost',
375 + '@local.dev',
376 + '@local.test',
377 + 'test@gmail.com',
378 + 'admin@gmail.com',
379 +
380 + );
381 + foreach ( $substrings as $substring ) {
382 + if ( false !== strpos( $email, $substring ) ) {
383 + return false;
384 + }
385 + }
386 + return true;
387 + }
388 +
389 + /**
333 390 * Handle AJAX request to set up usage data for the Onboarding Wizard.
334 391 *
335 392 * @since 6.9
336 393 *
@@ -433,9 +490,8 @@
433 490 *
434 491 * @since 6.9
435 492 *
436 493 * @param string $classes Existing body classes.
437 - *
438 494 * @return string Updated list of body classes, including the newly added classes.
439 495 */
440 496 public static function add_admin_body_classes( $classes ) {
441 497 return $classes . ' frm-admin-full-screen';
@@ -444,9 +500,8 @@
444 500 /**
445 501 * Checks if the Onboarding Wizard was skipped during the plugin's installation.
446 502 *
447 503 * @since 6.9
448 - *
449 504 * @return bool True if the Onboarding Wizard was skipped, false otherwise.
450 505 */
451 506 public static function has_onboarding_been_skipped() {
452 507 return get_option( self::ONBOARDING_SKIPPED_OPTION, false );
@@ -455,13 +510,12 @@
455 510 /**
456 511 * Marks the Onboarding Wizard as skipped to prevent automatic redirects to the wizard.
457 512 *
458 513 * @since 6.9
459 - *
460 514 * @return void
461 515 */
462 516 public static function mark_onboarding_as_skipped() {
463 - update_option( self::ONBOARDING_SKIPPED_OPTION, true, false );
517 + update_option( self::ONBOARDING_SKIPPED_OPTION, true, 'no' );
464 518 }
465 519
466 520 /**
467 521 * Adds an Onboarding Wizard welcome message to the floating notifications.
@@ -467,29 +521,24 @@
467 521 * Adds an Onboarding Wizard welcome message to the floating notifications.
468 522 *
469 523 * @since 6.9
470 524 *
471 - * @param mixed $inbox_messages The inbox option data. An array of existing inbox messages if there is valid data set in the option.
472 - *
525 + * @param array $inbox_messages The array of existing inbox messages.
473 526 * @return array Configuration for the onboarding wizard slide-in notification.
474 527 */
475 528 public static function add_wizard_to_floating_links( $inbox_messages ) {
476 - $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
529 + $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' );
477 530
478 - if ( ! is_array( $inbox_messages ) ) {
479 - $inbox_messages = array();
480 - }
481 -
482 - $inbox_messages['onboarding_wizard'] = array(
483 - 'subject' => esc_html__( 'Begin With Ease!', 'formidable' ),
484 - 'message' => esc_html( $message ),
485 - 'slidein' => esc_html( $message ),
486 - '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
487 - 'created' => time(),
488 - 'key' => 'onboarding_wizard',
531 + return array(
532 + 'onboarding_wizard' => array(
533 + 'subject' => esc_html__( 'Begin With Ease!', 'formidable' ),
534 + 'message' => esc_html( $message ),
535 + 'slidein' => esc_html( $message ),
536 + '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>',
537 + 'created' => time(),
538 + 'key' => 'onboarding_wizard',
539 + ),
489 540 );
490 -
491 - return $inbox_messages;
492 541 }
493 542
494 543 /**
495 544 * Check if the current page is the Onboarding Wizard page.
@@ -511,9 +560,9 @@
511 560 if ( get_option( self::REDIRECT_STATUS_OPTION ) ) {
512 561 return true;
513 562 }
514 563
515 - update_option( self::REDIRECT_STATUS_OPTION, FrmAppHelper::plugin_version(), false );
564 + update_option( self::REDIRECT_STATUS_OPTION, FrmAppHelper::plugin_version(), 'no' );
516 565 return false;
517 566 }
518 567
519 568 /**
@@ -645,41 +694,36 @@
645 694 foreach ( $available_pro_addons as $key => $data ) {
646 695 $addon = FrmAddonsController::get_addon( $data['addon_key'] );
647 696 $plugin_file = $data['plugin_file'];
648 697
649 - if ( is_plugin_active( $plugin_file ) || ! isset( $addon['url'] ) ) {
650 - continue;
698 + if ( ! is_plugin_active( $plugin_file ) && isset( $addon['url'] ) ) {
699 + $is_installed = array_key_exists( $plugin_file, $plugins );
700 +
701 + self::$available_addons[ $key ] = array(
702 + 'title' => $data['title'],
703 + 'rel' => $is_installed ? $plugin_file : $addon['url'],
704 + 'is-checked' => false,
705 + 'is-installed' => $is_installed,
706 + 'help-text' => $addon['excerpt'],
707 + );
651 708 }
652 -
653 - $is_installed = array_key_exists( $plugin_file, $plugins );
654 -
655 - self::$available_addons[ $key ] = array(
656 - 'title' => $data['title'],
657 - 'rel' => $is_installed ? $plugin_file : $addon['url'],
658 - 'is-checked' => false,
659 - 'is-installed' => $is_installed,
660 - 'help-text' => $addon['excerpt'],
661 - );
662 709 }
663 710 }//end if
664 711
665 712 // Gravity Forms Migrator add-on.
666 713 $gravity_forms_plugin = 'formidable-gravity-forms-importer/formidable-gravity-forms-importer.php';
714 + if ( class_exists( 'GFForms' ) && ! is_plugin_active( $gravity_forms_plugin ) ) {
715 + $is_installed_gravity_forms = array_key_exists( $gravity_forms_plugin, $plugins );
667 716
668 - if ( ! class_exists( 'GFForms' ) || is_plugin_active( $gravity_forms_plugin ) ) {
669 - return;
717 + self::$available_addons['formidable-gravity-forms-importer'] = array(
718 + 'title' => esc_html__( 'Gravity Forms Migrator', 'formidable' ),
719 + 'rel' => $is_installed_gravity_forms ? $gravity_forms_plugin : 'formidable-gravity-forms-importer',
720 + 'is-checked' => false,
721 + 'is-vendor' => true,
722 + 'is-installed' => $is_installed_gravity_forms,
723 + 'help-text' => esc_html__( 'Easily migrate your forms from Gravity Forms to Formidable.', 'formidable' ),
724 + );
670 725 }
671 -
672 - $is_installed_gravity_forms = array_key_exists( $gravity_forms_plugin, $plugins );
673 -
674 - self::$available_addons['formidable-gravity-forms-importer'] = array(
675 - 'title' => esc_html__( 'Gravity Forms Migrator', 'formidable' ),
676 - 'rel' => $is_installed_gravity_forms ? $gravity_forms_plugin : 'formidable-gravity-forms-importer',
677 - 'is-checked' => false,
678 - 'is-vendor' => true,
679 - 'is-installed' => $is_installed_gravity_forms,
680 - 'help-text' => esc_html__( 'Easily migrate your forms from Gravity Forms to Formidable.', 'formidable' ),
681 - );
682 726 }
683 727
684 728 /**
685 729 * Get the path to the Onboarding Wizard views.