Make the option 'woocommerce_tracker_ua' load on demand. (#33274)

This commit is contained in:
Adp5067 2022-06-10 02:55:10 -04:00 committed by GitHub
parent 16a478eeb2
commit 4c164c3247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: tweak
Make the option 'woocommerce_tracker_ua' load on demand.

View File

@ -862,7 +862,7 @@ function wc_maybe_store_user_agent( $user_login, $user ) {
if ( 'yes' === get_option( 'woocommerce_allow_tracking', 'no' ) && user_can( $user, 'manage_woocommerce' ) ) { if ( 'yes' === get_option( 'woocommerce_allow_tracking', 'no' ) && user_can( $user, 'manage_woocommerce' ) ) {
$admin_user_agents = array_filter( (array) get_option( 'woocommerce_tracker_ua', array() ) ); $admin_user_agents = array_filter( (array) get_option( 'woocommerce_tracker_ua', array() ) );
$admin_user_agents[] = wc_get_user_agent(); $admin_user_agents[] = wc_get_user_agent();
update_option( 'woocommerce_tracker_ua', array_unique( $admin_user_agents ) ); update_option( 'woocommerce_tracker_ua', array_unique( $admin_user_agents ), false );
} }
} }
add_action( 'wp_login', 'wc_maybe_store_user_agent', 10, 2 ); add_action( 'wp_login', 'wc_maybe_store_user_agent', 10, 2 );