2013-03-05 16:24:35 +11:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Fired when the plugin is uninstalled.
|
2013-05-09 22:20:26 -04:00
|
|
|
*
|
2013-07-07 14:03:25 -04:00
|
|
|
* @package Plugin_Name
|
2013-05-16 09:41:58 -04:00
|
|
|
* @author Your Name <email@example.com>
|
|
|
|
* @license GPL-2.0+
|
|
|
|
* @link http://example.com
|
2014-01-02 16:44:06 -05:00
|
|
|
* @copyright 2014 Your Name or Company Name
|
2013-03-05 16:24:35 +11:00
|
|
|
*/
|
|
|
|
|
2013-10-30 16:50:42 -04:00
|
|
|
// If uninstall not called from WordPress, then exit
|
2013-05-10 07:33:53 -04:00
|
|
|
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
2013-05-12 10:12:50 -04:00
|
|
|
exit;
|
2013-05-10 07:33:53 -04:00
|
|
|
}
|
2014-03-25 13:25:08 +01:00
|
|
|
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
|
|
|
|
delete_transient( 'TRANSIENT_NAME' );
|
|
|
|
delete_option('OPTION_NAME');
|
|
|
|
//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)) {
|
|
|
|
foreach(glob($directory.'*.*') as $v){
|
|
|
|
unlink($v);
|
|
|
|
}
|
|
|
|
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
|
|
|
|
delete_transient( 'TRANSIENT_NAME' );
|
|
|
|
delete_option('OPTION_NAME');
|
|
|
|
//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)) {
|
|
|
|
foreach(glob($directory.'*.*') as $v){
|
|
|
|
unlink($v);
|
|
|
|
}
|
|
|
|
rmdir($directory);
|
|
|
|
}
|
|
|
|
//info: remove and optimize tables
|
|
|
|
$GLOBALS['wpdb']->query("DROP TABLE `".$GLOBALS['wpdb']->prefix."TABLE_NAME`");
|
|
|
|
$GLOBALS['wpdb']->query("OPTIMIZE TABLE `" .$GLOBALS['wpdb']->prefix."options`");
|
|
|
|
*/
|
|
|
|
restore_current_blog();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
|
$upload_dir = wp_upload_dir();
|
|
|
|
$directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR;
|
|
|
|
if (is_dir($directory)) {
|
|
|
|
foreach(glob($directory.'*.*') as $v){
|
|
|
|
unlink($v);
|
|
|
|
}
|
|
|
|
rmdir($directory);
|
|
|
|
}
|
|
|
|
//info: remove and optimize tables
|
|
|
|
$GLOBALS['wpdb']->query("DROP TABLE `".$GLOBALS['wpdb']->prefix."TABLE_NAME`");
|
|
|
|
$GLOBALS['wpdb']->query("OPTIMIZE TABLE `" .$GLOBALS['wpdb']->prefix."options`");
|
|
|
|
*/
|
|
|
|
}
|