From 2c29f1ca041520e9ebfbeb36682884f4631c38f3 Mon Sep 17 00:00:00 2001 From: Tom McFarlin Date: Fri, 9 May 2014 09:35:11 -0400 Subject: [PATCH] moving $wpdb outside of the conditional so both cases work Fixes #182 --- plugin-name/uninstall.php | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/plugin-name/uninstall.php b/plugin-name/uninstall.php index 8227ec2..83d7c54 100644 --- a/plugin-name/uninstall.php +++ b/plugin-name/uninstall.php @@ -13,13 +13,16 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { exit; } -if (is_multisite()) { - global $wpdb; - $blogs = $wpdb->get_results("SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A); - /* @TODO: delete all transient, options and files you may have added + +global $wpdb; + +if ( is_multisite() ) { + + $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A ); + /* @TODO: delete all transient, options and files you may have added delete_transient( 'TRANSIENT_NAME' ); delete_option('OPTION_NAME'); - //info: remove custom file directory for main site + //info: remove custom file directory for main site $upload_dir = wp_upload_dir(); $directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR; if (is_dir($directory)) { @@ -29,13 +32,14 @@ if (is_multisite()) { rmdir($directory); } */ - if ($blogs) { - foreach($blogs as $blog) { - switch_to_blog($blog['blog_id']); - /* @TODO: delete all transient, options and files you may have added + if ( $blogs ) { + + foreach ( $blogs as $blog ) { + switch_to_blog( $blog['blog_id'] ); + /* @TODO: delete all transient, options and files you may have added delete_transient( 'TRANSIENT_NAME' ); delete_option('OPTION_NAME'); - //info: remove custom file directory for main site + //info: remove custom file directory for main site $upload_dir = wp_upload_dir(); $directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR; if (is_dir($directory)) { @@ -51,13 +55,12 @@ if (is_multisite()) { restore_current_blog(); } } -} -else -{ - /* @TODO: delete all transient, options and files you may have added + +} else { + /* @TODO: delete all transient, options and files you may have added delete_transient( 'TRANSIENT_NAME' ); delete_option('OPTION_NAME'); - //info: remove custom file directory for main site + //info: remove custom file directory for main site $upload_dir = wp_upload_dir(); $directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR; if (is_dir($directory)) {