global $wp_filesystem;
if ( is_wp_error( $removed ) ) { return $removed; // Pass errors through.
} $plugin =
isset( $plugin['plugin'
] ) ?
$plugin['plugin'
] : '';
if ( empty( $plugin ) ) { return new WP_Error( 'bad_request',
$this->strings
['bad_request'
] );
} $plugins_dir =
$wp_filesystem->
wp_plugins_dir();
$this_plugin_dir =
trailingslashit( dirname( $plugins_dir .
$plugin ) );
if ( !
$wp_filesystem->
exists( $this_plugin_dir ) ) { // If it's already vanished.
return $removed;
} /*
* If plugin is in its own directory, recursively delete the directory.
* Base check on if plugin includes directory separator AND that it's not the root plugin folder.
*/
if ( strpos( $plugin, '/'
) &&
$this_plugin_dir !==
$plugins_dir ) {