| 1 |
<?php |
| 2 |
/** |
| 3 |
* Uninstall script |
| 4 |
* |
| 5 |
* Runs when the plugin is uninstalled |
| 6 |
*/ |
| 7 |
|
| 8 |
// Exit if uninstall not called from WordPress |
| 9 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* Clean up plugin data |
| 15 |
*/ |
| 16 |
function memory_limit_manager_uninstall() { |
| 17 |
// Delete any transients |
| 18 |
delete_transient( 'memory_limit_manager_success' ); |
| 19 |
delete_transient( 'memory_limit_manager_errors' ); |
| 20 |
|
| 21 |
// Note: We intentionally DO NOT remove the memory limit definitions from wp-config.php |
| 22 |
// as these are important settings that should persist even after plugin removal. |
| 23 |
// Users can manually adjust or remove these if needed. |
| 24 |
|
| 25 |
// Optional: Clean up backup files (uncomment if you want to remove backups on uninstall) |
| 26 |
/* |
| 27 |
$config_path = ABSPATH . 'wp-config.php'; |
| 28 |
if ( ! file_exists( $config_path ) ) { |
| 29 |
$config_path = dirname( ABSPATH ) . '/wp-config.php'; |
| 30 |
} |
| 31 |
|
| 32 |
if ( file_exists( $config_path ) ) { |
| 33 |
$dir = dirname( $config_path ); |
| 34 |
$backups = array_merge( |
| 35 |
array( $dir . '/wp-config.mlm-backup.php' ), |
| 36 |
glob( $dir . '/wp-config.mlm-backup-*.php' ) ?: array(), |
| 37 |
glob( $dir . '/' . basename( $config_path ) . '.backup-*' ) ?: array() |
| 38 |
); |
| 39 |
|
| 40 |
if ( $backups ) { |
| 41 |
foreach ( $backups as $backup ) { |
| 42 |
@unlink( $backup ); |
| 43 |
} |
| 44 |
} |
| 45 |
} |
| 46 |
*/ |
| 47 |
} |
| 48 |
|
| 49 |
// Run cleanup |
| 50 |
memory_limit_manager_uninstall(); |
| 51 |
|