| @@ -120,18 +120,8 @@ | ||
| 120 | 120 | */ |
| 121 | 121 | private ?TriggerManager $trigger_manager = null; |
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | - * ReviewPrompt instance. | |
| 125 | - * | |
| 126 | - * Populated when a 'review_prompt' config array is provided, or when | |
| 127 | - * enable_review_prompt() is called after construction. | |
| 128 | - * | |
| 129 | - * @var ReviewPrompt|null | |
| 130 | - */ | |
| 131 | - private ?ReviewPrompt $review_prompt = null; | |
| 132 | - | |
| 133 | - /** | |
| 134 | 124 | * Constructor |
| 135 | 125 | * |
| 136 | 126 | * Accepts either an array configuration or the legacy 4-positional-parameter signature. |
| 137 | 127 | * |
| @@ -396,9 +386,8 @@ | ||
| 396 | 386 | |
| 397 | 387 | $this->handlers['consent']->init(); |
| 398 | 388 | $this->handlers['deactivation']->init(); |
| 399 | 389 | $this->init_triggers(); |
| 400 | - $this->init_review_prompt(); | |
| 401 | 390 | |
| 402 | 391 | // Internally register activation and deactivation hooks |
| 403 | 392 | register_activation_hook( $this->config['pluginFile'], [ $this, 'activate' ] ); |
| 404 | 393 | register_deactivation_hook( $this->config['pluginFile'], [ $this, 'deactivate' ] ); |
| @@ -417,43 +406,8 @@ | ||
| 417 | 406 | } |
| 418 | 407 | } |
| 419 | 408 | |
| 420 | 409 | /** |
| 421 | - * Initialize the review prompt if config was supplied. | |
| 422 | - * | |
| 423 | - * @return void | |
| 424 | - */ | |
| 425 | - private function init_review_prompt(): void { | |
| 426 | - if ( isset( $this->config['review_prompt'] ) && is_array( $this->config['review_prompt'] ) ) { | |
| 427 | - $this->review_prompt = new ReviewPrompt( $this, $this->config['review_prompt'] ); | |
| 428 | - $this->review_prompt->init(); | |
| 429 | - } | |
| 430 | - } | |
| 431 | - | |
| 432 | - /** | |
| 433 | - * Enable (or reconfigure) the review prompt after construction. | |
| 434 | - * | |
| 435 | - * Can be called at any time before admin hooks fire. | |
| 436 | - * | |
| 437 | - * @param array $config ReviewPrompt config array (see ReviewPrompt class docblock). | |
| 438 | - * @return self | |
| 439 | - */ | |
| 440 | - public function enable_review_prompt( array $config = [] ): self { | |
| 441 | - $this->review_prompt = new ReviewPrompt( $this, $config ); | |
| 442 | - $this->review_prompt->init(); | |
| 443 | - return $this; | |
| 444 | - } | |
| 445 | - | |
| 446 | - /** | |
| 447 | - * Get the ReviewPrompt instance, or null if not enabled. | |
| 448 | - * | |
| 449 | - * @return ReviewPrompt|null | |
| 450 | - */ | |
| 451 | - public function get_review_prompt(): ?ReviewPrompt { | |
| 452 | - return $this->review_prompt; | |
| 453 | - } | |
| 454 | - | |
| 455 | - /** | |
| 456 | 410 | * Plugin activation hook. |
| 457 | 411 | * |
| 458 | 412 | * @return void |
| 459 | 413 | */ |
| @@ -611,9 +565,18 @@ | ||
| 611 | 565 | ), |
| 612 | 566 | ); |
| 613 | 567 | |
| 614 | 568 | if ( 'activation/plugin_deactivated' === $event ) { |
| 615 | - $minimal_properties['reason'] = sanitize_text_field( (string) ( $properties['reason'] ?? 'none' ) ); | |
| 569 | + $minimal_properties['reason'] = sanitize_text_field( (string) ( $properties['reason'] ?? 'none' ) ); | |
| 570 | + $minimal_properties['reason_key'] = sanitize_text_field( (string) ( $properties['reason_key'] ?? '' ) ); | |
| 571 | + | |
| 572 | + // Pass through any extra properties added by the plugin via the deactivation_payload filter. | |
| 573 | + $reserved = array( 'site_url', 'unique_id', '__identify', 'reason', 'reason_key' ); | |
| 574 | + foreach ( $properties as $key => $value ) { | |
| 575 | + if ( ! in_array( $key, $reserved, true ) ) { | |
| 576 | + $minimal_properties[ sanitize_key( $key ) ] = is_numeric( $value ) ? $value : sanitize_text_field( (string) $value ); | |
| 577 | + } | |
| 578 | + } | |
| 616 | 579 | } |
| 617 | 580 | |
| 618 | 581 | $result = $this->handlers['dispatcher']->dispatch_minimal( $event, $minimal_properties ); |
| 619 | 582 | |