PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.5.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.5.0
5.6.0 5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.51 3.0.60 3.0.61 3.0.62 3.0.70 3.0.71 3.0.72 All 35 releases
← All changes | uninstall.php +101 -30 3.0.35.5.0 View file →
@@ -1,30 +1,101 @@
1 -<?php
2 -
3 -namespace forge12\contactform7\CF7DoubleOptIn;
4 -
5 -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
6 - die;
7 -}
8 -
9 -function drop_table_optin() {
10 - global $wpdb;
11 -
12 - // Backup Table
13 - $tableName = 'f12_cf7_doubleoptin';
14 - $wpTableName = $wpdb->prefix . $tableName;
15 -
16 - $wpdb->query( "DROP TABLE IF EXISTS " . $wpTableName );
17 -}
18 -
19 -function drop_table_categories() {
20 - global $wpdb;
21 -
22 - // Backup Table
23 - $tableName = 'f12_cf7_doubleoptin_categories';
24 - $wpTableName = $wpdb->prefix . $tableName;
25 -
26 - $wpdb->query( "DROP TABLE IF EXISTS " . $wpTableName );
27 -}
28 -
29 -drop_table_categories();
30 -drop_table_optin();
1 +<?php
2 +
3 +namespace forge12\contactform7\CF7DoubleOptIn;
4 +
5 +use Forge12\Shared\Logger;
6 +
7 +if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
8 + die;
9 +}
10 +
11 +require_once plugin_dir_path( __FILE__ ) . 'logger/logger.php';
12 +
13 +/**
14 + * Whether the admin asked to KEEP opt-in data when deleting the plugin.
15 + *
16 + * Defaults to KEEP: data is dropped ONLY when the
17 + * `keep_data_on_uninstall` setting is explicitly 0. A site that never
18 + * touched the setting (key absent) keeps its data — deleting the plugin
19 + * must never silently destroy GDPR consent records.
20 + *
21 + * @return bool True if the opt-in tables should be preserved.
22 + */
23 +function should_keep_data_on_uninstall(): bool {
24 + $settings = get_option( 'f12-doi-settings', array() );
25 +
26 + if ( ! is_array( $settings ) || ! array_key_exists( 'keep_data_on_uninstall', $settings ) ) {
27 + return true; // key absent → safe default: keep.
28 + }
29 +
30 + return (int) $settings['keep_data_on_uninstall'] !== 0;
31 +}
32 +
33 +function drop_table_optin() {
34 + global $wpdb;
35 +
36 + $logger = Logger::getInstance();
37 +
38 + $tableName = 'f12_cf7_doubleoptin';
39 + $wpTableName = $wpdb->prefix . $tableName;
40 +
41 + $logger->info( 'Dropping table if exists', [
42 + 'plugin' => 'double-opt-in',
43 + 'table_name' => $wpTableName,
44 + 'class' => __CLASS__ ?? null,
45 + 'method' => __FUNCTION__,
46 + ] );
47 +
48 + $wpdb->query( "DROP TABLE IF EXISTS " . esc_sql( $wpTableName ) );
49 +
50 + $logger->info( 'Table dropped', [
51 + 'plugin' => 'double-opt-in',
52 + 'table_name' => $wpTableName,
53 + ] );
54 +}
55 +
56 +function drop_table_categories() {
57 + global $wpdb;
58 +
59 + $logger = Logger::getInstance();
60 +
61 + $tableName = 'f12_cf7_doubleoptin_categories';
62 + $wpTableName = $wpdb->prefix . $tableName;
63 +
64 + $logger->info( 'Dropping table if exists', [
65 + 'plugin' => 'double-opt-in',
66 + 'table_name' => $wpTableName,
67 + 'class' => __CLASS__ ?? null,
68 + 'method' => __FUNCTION__,
69 + ] );
70 +
71 + $wpdb->query( "DROP TABLE IF EXISTS " . esc_sql( $wpTableName ) );
72 +
73 + $logger->info( 'Table dropped', [
74 + 'plugin' => 'double-opt-in',
75 + 'table_name' => $wpTableName,
76 + ] );
77 +}
78 +
79 +if ( should_keep_data_on_uninstall() ) {
80 + Logger::getInstance()->info( 'Uninstall: keeping opt-in data (keep_data_on_uninstall enabled).', [
81 + 'plugin' => 'double-opt-in',
82 + ] );
83 +} else {
84 + Logger::getInstance()->info( 'Uninstall: deleting opt-in data (keep_data_on_uninstall disabled by admin).', [
85 + 'plugin' => 'double-opt-in',
86 + ] );
87 + drop_table_categories();
88 + drop_table_optin();
89 +}
90 +
91 +// Purely operational options with no value after removal. Admin-set config
92 +// (f12-doi-settings) is intentionally left in place, and cross-package options
93 +// (bundle-pro licence, addon settings) are owned by their own uninstallers.
94 +delete_option( 'f12_cf7_doubleoptin_installed_at' );
95 +delete_option( 'f12_cf7_doubleoptin_installation_uuid' );
96 +delete_option( 'f12_cf7_doubleoptin_telemetry_counters' );
97 +
98 +// The daily telemetry job is no longer scheduled, but an installation that ran
99 +// an older version still carries the event. Uninstalling has to take it with
100 +// it, otherwise the entry outlives the plugin in the WP-Cron table.
101 +wp_clear_scheduled_hook( 'f12_cf7_doubleoptin_daily_telemetry' );