views
1 week ago
Assets.php
1 week ago
OptInOptOut.php
1 week ago
OptInPage.php
1 week ago
OptOut.php
1 week ago
PluginActionLinks.php
1 week ago
Shop.php
1 week ago
Tracker.php
1 week ago
OptOut.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | namespace FSVendor\WPDesk\Tracker; |
| 4 | |
| 5 | use FSVendor\WPDesk\Notice\Notice; |
| 6 | use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable; |
| 7 | class OptOut implements Hookable |
| 8 | { |
| 9 | /** |
| 10 | * @var string |
| 11 | */ |
| 12 | private $plugin_slug; |
| 13 | /** |
| 14 | * @var string |
| 15 | */ |
| 16 | private $plugin_name; |
| 17 | /** |
| 18 | * @param string $plugin_slug |
| 19 | * @param string $plugin_name |
| 20 | */ |
| 21 | public function __construct($plugin_slug, $plugin_name) |
| 22 | { |
| 23 | $this->plugin_slug = $plugin_slug; |
| 24 | $this->plugin_name = $plugin_name; |
| 25 | } |
| 26 | public function hooks() |
| 27 | { |
| 28 | add_action('admin_notices', [$this, 'handle_opt_out']); |
| 29 | } |
| 30 | /** |
| 31 | * @internal |
| 32 | */ |
| 33 | public function handle_opt_out() |
| 34 | { |
| 35 | $screen = get_current_screen(); |
| 36 | if ('plugins' === $screen->id && isset($_GET['wpdesk_tracker_opt_out_' . $this->plugin_slug])) { |
| 37 | $security = sanitize_text_field(wp_unslash($_GET['security'] ?? '')); |
| 38 | if (wp_verify_nonce($security, $this->plugin_slug)) { |
| 39 | $persistence = new \FSVendor\WPDesk_Tracker_Persistence_Consent(); |
| 40 | $persistence->set_active(\false); |
| 41 | delete_option('wpdesk_tracker_notice'); |
| 42 | new Notice(sprintf(esc_html__('You successfully opted out of collecting usage data by %1$s. If you change your mind, you can always opt in later in the plugin\'s quick links.', 'flexible-shipping'), esc_html($this->plugin_name))); |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 |