2013-03-05 07:24:35 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Fired when the plugin is uninstalled.
|
2013-05-10 05:20:26 +03:00
|
|
|
*
|
2013-07-07 21:03:25 +03:00
|
|
|
* @package Plugin_Name
|
2013-05-16 16:41:58 +03:00
|
|
|
* @author Your Name <email@example.com>
|
|
|
|
* @license GPL-2.0+
|
|
|
|
* @link http://example.com
|
2014-01-02 23:44:06 +02:00
|
|
|
* @copyright 2014 Your Name or Company Name
|
2013-03-05 07:24:35 +02:00
|
|
|
*/
|
|
|
|
|
2013-10-30 22:50:42 +02:00
|
|
|
// If uninstall not called from WordPress, then exit
|
2013-05-10 14:33:53 +03:00
|
|
|
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
2013-05-12 17:12:50 +03:00
|
|
|
exit;
|
2013-05-10 14:33:53 +03:00
|
|
|
}
|
2014-05-09 16:35:11 +03:00
|
|
|
|
|
|
|
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
|
2014-03-25 14:25:08 +02:00
|
|
|
delete_transient( 'TRANSIENT_NAME' );
|
|
|
|
delete_option('OPTION_NAME');
|
2014-05-09 16:35:11 +03:00
|
|
|
//info: remove custom file directory for main site
|
2014-03-25 14:25:08 +02:00
|
|
|
$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);
|
|
|
|
}
|
|
|
|
*/
|
2014-05-09 16:35:11 +03:00
|
|
|
if ( $blogs ) {
|
|
|
|
|
|
|
|
foreach ( $blogs as $blog ) {
|
|
|
|
switch_to_blog( $blog['blog_id'] );
|
|
|
|
/* @TODO: delete all transient, options and files you may have added
|
2014-03-25 14:25:08 +02:00
|
|
|
delete_transient( 'TRANSIENT_NAME' );
|
|
|
|
delete_option('OPTION_NAME');
|
2014-05-09 16:35:11 +03:00
|
|
|
//info: remove custom file directory for main site
|
2014-03-25 14:25:08 +02:00
|
|
|
$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();
|
|
|
|
}
|
|
|
|
}
|
2014-05-09 16:35:11 +03:00
|
|
|
|
|
|
|
} else {
|
|
|
|
/* @TODO: delete all transient, options and files you may have added
|
2014-03-25 14:25:08 +02:00
|
|
|
delete_transient( 'TRANSIENT_NAME' );
|
|
|
|
delete_option('OPTION_NAME');
|
2014-05-09 16:35:11 +03:00
|
|
|
//info: remove custom file directory for main site
|
2014-03-25 14:25:08 +02:00
|
|
|
$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`");
|
|
|
|
*/
|
|
|
|
}
|