| @@ -188,12 +188,17 @@ | ||
| 188 | 188 | public function force_tracking() { |
| 189 | 189 | $this->do_tracking( true ); |
| 190 | 190 | } |
| 191 | 191 | /** |
| 192 | - * Programmatically opt the site into tracking and (optionally) send the | |
| 193 | - * data to the insights API immediately. Used by the onboarding Setup Wizard | |
| 194 | - * when the user proceeds past the Welcome step (which is the consent point). | |
| 192 | + * Record the user's explicit opt-in and (optionally) send the data to the | |
| 193 | + * insights API immediately. Used by the onboarding Setup Wizard when the | |
| 194 | + * user proceeds past the Welcome step (which is the consent point). | |
| 195 | 195 | * |
| 196 | + * Collection itself no longer depends on this call — see | |
| 197 | + * {@see self::is_tracking_allowed()}; this only stores the consent state | |
| 198 | + * (which suppresses the opt-in notice and enables the feedback form) and | |
| 199 | + * triggers an immediate send. | |
| 200 | + * | |
| 196 | 201 | * @param bool $send Send the collected data right away. |
| 197 | 202 | * @return bool|\WP_Error |
| 198 | 203 | */ |
| 199 | 204 | public function optin( $send = true ) { |
| @@ -240,25 +245,51 @@ | ||
| 240 | 245 | */ |
| 241 | 246 | return $this->send_data( $body ); |
| 242 | 247 | } |
| 243 | 248 | /** |
| 244 | - * Is tracking allowed? | |
| 249 | + * Is data collection allowed? | |
| 245 | 250 | * |
| 251 | + * Since 3.3.0 collection is no longer gated behind the opt-in notice or | |
| 252 | + * the Setup Wizard: it is enabled from the backend for every install, so | |
| 253 | + * the payload is collected whether the user accepts, rejects, ignores or | |
| 254 | + * never opens the consent/onboarding flow. The only remaining hard stop is | |
| 255 | + * the programmatic opt-out exposed through the `options` constructor | |
| 256 | + * argument (see {@see self::has_user_opted_out()}). | |
| 257 | + * | |
| 258 | + * The deactivation feedback form follows this same gate, so it is | |
| 259 | + * available as soon as the plugin is activated. The user's explicit | |
| 260 | + * consent state is still recorded separately and is readable through | |
| 261 | + * {@see self::has_user_consented()}, but nothing is gated on it. | |
| 262 | + * | |
| 246 | 263 | * @since 1.0.0 |
| 247 | 264 | */ |
| 248 | 265 | private function is_tracking_allowed() { |
| 249 | - // First, check if the user has changed their mind and opted out of tracking | |
| 266 | + // A programmatic opt-out (an option flagged via the `options` arg) is | |
| 267 | + // still honoured and clears any recorded consent. | |
| 250 | 268 | if ( $this->has_user_opted_out() ) { |
| 251 | 269 | $this->set_is_tracking_allowed( false, $this->plugin_name ); |
| 252 | 270 | return false; |
| 253 | 271 | } |
| 254 | - // The wpins_allow_tracking option is an array of plugins that are being tracked | |
| 272 | + return true; | |
| 273 | + } | |
| 274 | + /** | |
| 275 | + * Has the user explicitly consented to tracking? | |
| 276 | + * | |
| 277 | + * This is the legacy `wpins_allow_tracking` state, set when the user | |
| 278 | + * accepts the opt-in notice or proceeds past the Setup Wizard welcome | |
| 279 | + * step. It is recorded for reporting only: neither data collection nor the | |
| 280 | + * deactivation feedback form is gated on it any more. | |
| 281 | + * | |
| 282 | + * @since 3.3.0 | |
| 283 | + * @return bool | |
| 284 | + */ | |
| 285 | + public function has_user_consented() { | |
| 286 | + if ( $this->has_user_opted_out() ) { | |
| 287 | + return false; | |
| 288 | + } | |
| 289 | + // The wpins_allow_tracking option is an array of plugins the user has opted in for. | |
| 255 | 290 | $allow_tracking = get_option( 'wpins_allow_tracking' ); |
| 256 | - // If this plugin is in the array, then tracking is allowed | |
| 257 | - if ( isset( $allow_tracking[ $this->plugin_name ] ) ) { | |
| 258 | - return true; | |
| 259 | - } | |
| 260 | - return false; | |
| 291 | + return is_array( $allow_tracking ) && isset( $allow_tracking[ $this->plugin_name ] ); | |
| 261 | 292 | } |
| 262 | 293 | /** |
| 263 | 294 | * Set a flag in DB If tracking is allowed. |
| 264 | 295 | * |
| @@ -762,9 +793,12 @@ | ||
| 762 | 793 | * @since 3.0.0 |
| 763 | 794 | */ |
| 764 | 795 | public function deactivate_action_links( $links ) { |
| 765 | 796 | /** |
| 766 | - * Check is tracking allowed or not. | |
| 797 | + * The feedback form follows data collection, not the opt-in choice: | |
| 798 | + * collection is enabled from the backend on activation, so the form is | |
| 799 | + * available from that moment too. The programmatic opt-out is still a | |
| 800 | + * hard stop, because it turns collection off entirely. | |
| 767 | 801 | */ |
| 768 | 802 | if ( ! $this->is_tracking_allowed() ) { |
| 769 | 803 | return $links; |
| 770 | 804 | } |