diff --git a/includes/admin/class-wc-admin-setup-wizard.php b/includes/admin/class-wc-admin-setup-wizard.php index 15b95e79602..18912286352 100644 --- a/includes/admin/class-wc-admin-setup-wizard.php +++ b/includes/admin/class-wc-admin-setup-wizard.php @@ -331,6 +331,7 @@ class WC_Admin_Setup_Wizard { step || 'activate' === $this->step ) : ?> + + + + + + queue as $script ) { + if ( in_array( $script, $whitelist, true ) ) { + continue; + } + wp_dequeue_script( $script ); + } + } + /** * Track when tracking is opted into and OBW has started. * @@ -65,6 +101,24 @@ class WC_Admin_Setup_Wizard_Tracking { WC_Tracks::record_event( 'obw_start' ); } + /** + * Track the marketing form on submit. + */ + public static function track_marketing_signup() { + if ( 'next_steps' !== self::get_current_step() ) { + return; + } + + wc_enqueue_js( + " + var form = $( '.newsletter-form-email' ).closest( 'form' ); + $( document ).on( 'submit', form, function() { + window.wcTracks.recordEvent( 'obw_marketing_signup' ); + } ); + " + ); + } + /** * Track various events when a step is saved. */ @@ -73,10 +127,9 @@ class WC_Admin_Setup_Wizard_Tracking { return; } - $current_step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification - update_option( 'woocommerce_obw_last_completed_step', $current_step ); + update_option( 'woocommerce_obw_last_completed_step', self::get_current_step() ); - switch ( $current_step ) { + switch ( self::get_current_step() ) { case '': case 'store_setup': add_action( 'admin_init', array( __CLASS__, 'track_store_setup' ), 1 ); @@ -207,7 +260,7 @@ class WC_Admin_Setup_Wizard_Tracking { */ public static function track_skip_step() { $previous_step = get_option( 'woocommerce_obw_last_completed_step' ); - $current_step = isset( $_GET['step'] ) ? sanitize_text_field( $_GET['step'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification, WordPress.Security.ValidatedSanitizedInput + $current_step = self::get_current_step(); if ( ! $previous_step || ! $current_step ) { return; }