initial commit
This commit is contained in:
parent
e468202f95
commit
423b9a25fb
24 changed files with 6670 additions and 0 deletions
62
native/wordpress/maple-icons-wp/uninstall.php
Normal file
62
native/wordpress/maple-icons-wp/uninstall.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* Maple Icons Uninstall
|
||||
*
|
||||
* Runs when the plugin is uninstalled (deleted).
|
||||
* Cleans up all plugin data including downloaded icons and settings.
|
||||
*
|
||||
* @package MapleIcons
|
||||
*/
|
||||
|
||||
// Exit if not called by WordPress.
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove plugin options.
|
||||
*/
|
||||
delete_option( 'maple_icons_settings' );
|
||||
|
||||
/**
|
||||
* Remove transients.
|
||||
*/
|
||||
global $wpdb;
|
||||
$wpdb->query(
|
||||
"DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_mi_%' OR option_name LIKE '_transient_timeout_mi_%'"
|
||||
);
|
||||
|
||||
/**
|
||||
* Remove downloaded icons directory.
|
||||
*/
|
||||
$icons_dir = WP_CONTENT_DIR . '/maple-icons/';
|
||||
|
||||
if ( is_dir( $icons_dir ) ) {
|
||||
/**
|
||||
* Recursively delete a directory and its contents.
|
||||
*
|
||||
* @param string $dir Directory path.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
function mi_delete_directory( $dir ) {
|
||||
if ( ! is_dir( $dir ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$files = array_diff( scandir( $dir ), array( '.', '..' ) );
|
||||
|
||||
foreach ( $files as $file ) {
|
||||
$path = $dir . '/' . $file;
|
||||
|
||||
if ( is_dir( $path ) ) {
|
||||
mi_delete_directory( $path );
|
||||
} else {
|
||||
unlink( $path );
|
||||
}
|
||||
}
|
||||
|
||||
return rmdir( $dir );
|
||||
}
|
||||
|
||||
mi_delete_directory( $icons_dir );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue