-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.php
More file actions
60 lines (50 loc) · 1.65 KB
/
Copy pathuninstall.php
File metadata and controls
60 lines (50 loc) · 1.65 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* Fired when the plugin is uninstalled.
*
* @package 100Prints
*/
// If uninstall not called from WordPress, exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
global $wpdb;
// Drop generation history table.
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}100p_generation_history" );
// Drop legacy generation log table.
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}100p_generation_log" );
// Drop legacy forms/submissions tables (if they exist from older versions).
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}100p_submission_values" );
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}100p_submissions" );
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}100p_form_fields" );
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}100p_forms" );
// Delete plugin options.
delete_option( '100p_settings' );
delete_option( '100prints_api_key' );
delete_option( '100p_template_index' );
delete_option( '100p_last_sync_error' );
// Delete template caches from options.
$options_to_delete = $wpdb->get_col(
$wpdb->prepare(
"SELECT option_name FROM $wpdb->options WHERE option_name LIKE %s",
'100p_template_cache_%'
)
);
if ( ! empty( $options_to_delete ) ) {
foreach ( $options_to_delete as $option ) {
delete_option( $option );
}
}
// Clear transients.
$transients_to_delete = $wpdb->get_col(
$wpdb->prepare(
"SELECT option_name FROM $wpdb->options WHERE option_name LIKE %s",
'_transient_100p_template_%'
)
);
if ( ! empty( $transients_to_delete ) ) {
foreach ( $transients_to_delete as $transient_option ) {
$transient_name = str_replace( '_transient_', '', $transient_option );
delete_transient( $transient_name );
}
}