summaryrefslogtreecommitdiffstats
path: root/uninstall.php
blob: a3c0333bf67e81195f60ff1f058fe27aea0e005f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
 * Remove every trace of the plugin when it is deleted.
 *
 * Runs on delete, not on deactivate: a store owner switching the plugin off to
 * debug something should not lose their settings.
 *
 * @package CepisWooCommerce
 */

declare(strict_types=1);

defined( 'WP_UNINSTALL_PLUGIN' ) || exit;

$cepis_woo_options = array(
	'cepis_woo_enabled',
	'cepis_woo_mode',
	'cepis_woo_overwrite',
	'cepis_woo_focus_number',
	'cepis_woo_base_url',
);

foreach ( $cepis_woo_options as $cepis_woo_option ) {
	delete_option( $cepis_woo_option );
}

global $wpdb;

$cepis_woo_names = $wpdb->get_col(
	$wpdb->prepare(
		"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s",
		$wpdb->esc_like( '_transient_cepis_woo_' ) . '%',
		$wpdb->esc_like( '_transient_timeout_cepis_woo_' ) . '%'
	)
);

foreach ( (array) $cepis_woo_names as $cepis_woo_name ) {
	delete_option( (string) $cepis_woo_name );
}

wp_cache_flush();