forked from WebberZone/contextual-related-posts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.php
67 lines (49 loc) · 1.59 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
60
61
62
63
64
65
66
67
<?php
/**
* Fired when the plugin is uninstalled
*
* @package Contextual_Related_Posts
*/
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit();
}
global $wpdb;
$option_name = 'ald_crp_settings';
if ( !is_multisite() ) {
$wpdb->query( "ALTER TABLE " . $wpdb->posts . " DROP INDEX crp_related" );
$wpdb->query( "ALTER TABLE " . $wpdb->posts . " DROP INDEX crp_related_title" );
$wpdb->query( "ALTER TABLE " . $wpdb->posts . " DROP INDEX crp_related_content" );
$wpdb->query("
DELETE FROM " . $wpdb->postmeta . "
WHERE meta_key='crp_related_posts'
");
$wpdb->query("
DELETE FROM " . $wpdb->postmeta . "
WHERE meta_key='crp_related_posts_widget'
");
delete_option( $option_name );
} else {
// Get all blogs in the network and activate plugin on each one
$blog_ids = $wpdb->get_col( "
SELECT blog_id FROM $wpdb->blogs
WHERE archived = '0' AND spam = '0' AND deleted = '0'
" );
foreach ( $blog_ids as $blog_id ) {
switch_to_blog( $blog_id );
$wpdb->query( "ALTER TABLE " . $wpdb->posts . " DROP INDEX crp_related" );
$wpdb->query( "ALTER TABLE " . $wpdb->posts . " DROP INDEX crp_related_title" );
$wpdb->query( "ALTER TABLE " . $wpdb->posts . " DROP INDEX crp_related_content" );
$wpdb->query("
DELETE FROM " . $wpdb->postmeta . "
WHERE meta_key='crp_related_posts'
");
$wpdb->query("
DELETE FROM " . $wpdb->postmeta . "
WHERE meta_key='crp_related_posts_widget'
");
delete_option( $option_name );
}
// Switch back to the current blog
restore_current_blog();
}
?>