This repository has been archived by the owner on Apr 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
uninstall.php
58 lines (51 loc) · 1.47 KB
/
uninstall.php
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
<?php
/**
* Posts in Sidebar Uninstall
*
* This file contains the uninstall function of the plugin.
*
* @package PostsInSidebar
* @since 1.0
*/
// Check for the 'WP_UNINSTALL_PLUGIN' constant, before executing.
if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit( 'No script kiddies please!' );
}
/**
* Delete transients and options from the database.
*
* Transient created by this plugin have always this string:
* `pis_transients_`.
*
* @since 1.16
* @since 4.10.3 Modified according to new transients management.
*/
function pis_garbage_collection() {
// Delete plugin's transients from the database.
global $wpdb;
$results = $wpdb->get_results(
$wpdb->prepare(
"SELECT option_name FROM $wpdb->options WHERE option_name LIKE %s",
'%pis_transients_%'
)
);
if ( $results ) {
foreach ( $results as $key => $transients ) {
// Ignore transients with `timeout` in the name, since WordPress will delete them by itself.
if ( false === strpos( $transients->option_name, '_transient_timeout_' ) ) {
// Remove `_transient_` from name, otherwise WordPress will not find them.
$transient = str_replace( '_transient_', '', $transients->option_name );
if ( get_transient( $transient ) ) {
delete_transient( $transient );
}
}
}
}
// Delete plugin's options from the database.
delete_option( 'widget_pis_posts_in_sidebar' );
}
pis_garbage_collection();
/*
* "So long, and thanks for all the fish."
* (Douglas Adams)
*/