Skip to content

Instantly share code, notes, and snippets.

@denisstoyanov
Created October 23, 2015 18:42
Show Gist options
  • Save denisstoyanov/9cb9c60af1ba204e2208 to your computer and use it in GitHub Desktop.
Save denisstoyanov/9cb9c60af1ba204e2208 to your computer and use it in GitHub Desktop.
// Deletes all themes except the active one
function delete_not_active_themes() {
if (!function_exists('delete_theme')) {
require_once(ABSPATH . WPINC . '/pluggable.php');
require_once(ABSPATH . 'wp-admin/includes/file.php');
require_once(ABSPATH . 'wp-admin/includes/theme.php');
}
$themes = wp_get_themes();
$current_theme = wp_get_theme();
foreach ($themes as $theme) {
if ($current_theme->get_stylesheet() !== $theme->get_stylesheet()) {
delete_theme($theme->get_stylesheet());
}
}
}
delete_not_active_themes();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment