Skip to content

Commit

Permalink
Adds cleanup steps when uninstalling the plugin
Browse files Browse the repository at this point in the history
When uninstalling from the dashboard the plugin will now remove the
symlinks created as well as the options from the database.

fixes: wpugph#33
  • Loading branch information
jocastaneda committed Sep 26, 2020
1 parent 538b96a commit 05ef9ff
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,22 @@
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}

// loading up to get the home path
require_once ABSPATH . 'wp-admin/includes/file.php';
// load the easy-symlinks file so we can later get token and version
include_once 'easy-symlinks.php';

// unlink paths
$links = maybe_unserialize( get_option( 'caes_symlink_list' ) );
foreach ($links as $key => $value) {
$link = strstr( $value, ' ->', true );
unlink( get_home_path() . $link );
}

// remove options
delete_option( easy_symlinks()->token . 'version', easy_symlinks()->version );
delete_option( 'caes_symlink_list' );
delete_option( 'caes_symlink_list_lastdelete' );
delete_option( 'caes_target' );
delete_option( 'caes_link' );

0 comments on commit 05ef9ff

Please sign in to comment.