PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.18
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.18
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 +77 -18 6.266.18 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 }
@@ -207,14 +203,14 @@
207 203 // Dismiss the onboarding wizard message so it stops appearing after it is clicked.
208 204 $message = new FrmInbox();
209 205 $message->dismiss( 'onboarding_wizard' );
210 206
211 - add_action( 'admin_menu', self::class . '::menu', 99 );
212 - add_action( 'admin_init', self::class . '::assign_properties' );
213 - add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 );
214 - add_action( 'admin_head', self::class . '::remove_menu' );
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' );
215 211
216 - add_filter( 'admin_body_class', self::class . '::add_admin_body_classes', 999 );
212 + add_filter( 'admin_body_class', __CLASS__ . '::add_admin_body_classes', 999 );
217 213 add_filter( 'frm_show_footer_links', '__return_false' );
218 214 }
219 215 }
220 216
@@ -257,9 +253,9 @@
257 253 'Formidable | ' . $label,
258 254 $label,
259 255 self::REQUIRED_CAPABILITY,
260 256 self::PAGE_SLUG,
261 - array( self::class, 'render' )
257 + array( __CLASS__, 'render' )
262 258 );
263 259 }
264 260
265 261 /**
@@ -315,9 +311,9 @@
315 311 // Remove the 'FrmProSettingsController::store' action to avoid PHP errors during AJAX call.
316 312 remove_action( 'frm_store_settings', 'FrmProSettingsController::store' );
317 313 $frm_settings->store();
318 314
319 - FrmEmailCollectionHelper::subscribe_to_active_campaign();
315 + self::subscribe_to_active_campaign();
320 316
321 317 // Send response.
322 318 wp_send_json_success();
323 319 }
@@ -322,8 +318,76 @@
322 318 wp_send_json_success();
323 319 }
324 320
325 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 + /**
326 390 * Handle AJAX request to set up usage data for the Onboarding Wizard.
327 391 *
328 392 * @since 6.9
329 393 *
@@ -426,9 +490,8 @@
426 490 *
427 491 * @since 6.9
428 492 *
429 493 * @param string $classes Existing body classes.
430 - *
431 494 * @return string Updated list of body classes, including the newly added classes.
432 495 */
433 496 public static function add_admin_body_classes( $classes ) {
434 497 return $classes . ' frm-admin-full-screen';
@@ -437,9 +500,8 @@
437 500 /**
438 501 * Checks if the Onboarding Wizard was skipped during the plugin's installation.
439 502 *
440 503 * @since 6.9
441 - *
442 504 * @return bool True if the Onboarding Wizard was skipped, false otherwise.
443 505 */
444 506 public static function has_onboarding_been_skipped() {
445 507 return get_option( self::ONBOARDING_SKIPPED_OPTION, false );
@@ -448,9 +510,8 @@
448 510 /**
449 511 * Marks the Onboarding Wizard as skipped to prevent automatic redirects to the wizard.
450 512 *
451 513 * @since 6.9
452 - *
453 514 * @return void
454 515 */
455 516 public static function mark_onboarding_as_skipped() {
456 517 update_option( self::ONBOARDING_SKIPPED_OPTION, true, 'no' );
@@ -461,9 +522,8 @@
461 522 *
462 523 * @since 6.9
463 524 *
464 525 * @param array $inbox_messages The array of existing inbox messages.
465 - *
466 526 * @return array Configuration for the onboarding wizard slide-in notification.
467 527 */
468 528 public static function add_wizard_to_floating_links( $inbox_messages ) {
469 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' );
@@ -650,9 +710,8 @@
650 710 }//end if
651 711
652 712 // Gravity Forms Migrator add-on.
653 713 $gravity_forms_plugin = 'formidable-gravity-forms-importer/formidable-gravity-forms-importer.php';
654 -
655 714 if ( class_exists( 'GFForms' ) && ! is_plugin_active( $gravity_forms_plugin ) ) {
656 715 $is_installed_gravity_forms = array_key_exists( $gravity_forms_plugin, $plugins );
657 716
658 717 self::$available_addons['formidable-gravity-forms-importer'] = array(