-
Notifications
You must be signed in to change notification settings - Fork 2
/
uninstall.php
59 lines (50 loc) · 1.33 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
59
<?php
/**
* Fired when the plugin is uninstalled.
*
* @link https://gp-web.dev/
* @since 1.0.0
*
* @package Simple_Photo_Feed
*/
// If uninstall not called from WordPress, then exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
// If we are on a multisite installation clean up all subsites.
if ( is_multisite() ) {
foreach ( get_sites( array( 'fields' => 'ids' ) ) as $blogid ) {
switch_to_blog( $blogid );
simple_photo_feed_cleanup();
restore_current_blog();
}
} else {
simple_photo_feed_cleanup();
}
/**
* Delete plugin options and any DB tables.
*
* @since 1.0.0
* @return void
*/
function simple_photo_feed_cleanup() {
// Plugin options.
$options = array(
'spf_main_settings',
'spf_version_no',
);
// Loop through each option.
foreach ( $options as $option ) {
delete_option( $option );
}
// Delete our transients.
global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$trans = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM $wpdb->options WHERE option_name LIKE '%spf_get_media_%'" );
foreach ( $trans as $t ) {
delete_transient( $t->name );
}
// Clear our cron jobs.
wp_clear_scheduled_hook( 'simple_photo_update_feed' );
wp_clear_scheduled_hook( 'simple_photo_refresh_token' );
}