| @@ -1,10 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Usage_Tracker — anonymous, opt-in plugin usage analytics. | |
| 3 | + * Usage_Tracker — opt-in plugin usage analytics. | |
| 4 | 4 | * |
| 5 | 5 | * Ported from the WP Insights SDK (the same engine WPDeveloper plugins such as |
| 6 | - * EmbedPress ship). Trimmed for xSpeed: no email marketing capture by default. | |
| 6 | + * EmbedPress ship). With email_marketing enabled (Plugin passes it), the | |
| 7 | + * opted-in admin's email + display name are included and disclosed in the | |
| 8 | + * consent copy. | |
| 7 | 9 | * The deactivation "goodbye" survey UI lives in Deactivation_Feedback (shown to |
| 8 | 10 | * every admin); it stores the reason in the canonical WPInsight options and |
| 9 | 11 | * deactivate_this_plugin() transmits it — see that method. |
| 10 | 12 | * |
| @@ -69,11 +71,12 @@ | ||
| 69 | 71 | |
| 70 | 72 | // require_optin is intentionally forced true — never honor a caller |
| 71 | 73 | // that tries to disable consent gating. |
| 72 | 74 | $this->require_optin = true; |
| 73 | - // Email marketing capture is OFF by default in xSpeed (EmbedPress | |
| 74 | - // defaults it on to send a discount coupon; we collect no email | |
| 75 | - // unless a caller explicitly turns it on). | |
| 75 | + // Email/name capture ships OFF here and is enabled by the caller | |
| 76 | + // (Plugin::start_plugin_tracking() passes email_marketing => true). | |
| 77 | + // When on, the opted-in admin's email + display name ride along — | |
| 78 | + // disclosed in the consent copy and readme.txt "External services". | |
| 76 | 79 | $this->marketing = isset( $args['email_marketing'] ) ? (bool) $args['email_marketing'] : false; |
| 77 | 80 | $this->item_id = ! empty( $args['item_id'] ) ? $args['item_id'] : false; |
| 78 | 81 | |
| 79 | 82 | register_deactivation_hook( $this->plugin_file, array( $this, 'deactivate_this_plugin' ) ); |
| @@ -287,11 +290,15 @@ | ||
| 287 | 290 | if ( $this->marketing ) { |
| 288 | 291 | if ( ! function_exists( 'wp_get_current_user' ) ) { |
| 289 | 292 | include ABSPATH . 'wp-includes/pluggable.php'; |
| 290 | 293 | } |
| 291 | - $email = wp_get_current_user()->user_email; | |
| 294 | + $user = wp_get_current_user(); | |
| 295 | + $email = $user->user_email; | |
| 292 | 296 | if ( is_email( $email ) ) { |
| 293 | 297 | $body['email'] = $email; |
| 298 | + } | |
| 299 | + if ( ! empty( $user->display_name ) ) { | |
| 300 | + $body['name'] = sanitize_text_field( $user->display_name ); | |
| 294 | 301 | } |
| 295 | 302 | } |
| 296 | 303 | $body['marketing_method'] = $this->marketing; |
| 297 | 304 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- server software string, reported as-is to insights. |