mirror of
https://github.com/inretio/WordPress-Plugin-Boilerplate
synced 2024-12-22 20:03:53 +02:00
Merge pull request #172 from robertharm/dev
enhance uninstall.php template
This commit is contained in:
commit
4beb185a90
1 changed files with 58 additions and 2 deletions
|
@ -13,5 +13,61 @@
|
||||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
if (is_multisite()) {
|
||||||
// @TODO: Define uninstall functionality here
|
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`");
|
||||||
|
*/
|
||||||
|
}
|
Loading…
Reference in a new issue