delete-theme

[insert_php]
$get_themes = wp_get_themes();
$get_current_theme = wp_get_theme();

if ($get_current_theme->stylesheet != $get_current_theme->stylesheet) {
$get_current_theme_arr[] = $get_current_theme->template;
}

if ($get_current_theme->stylesheet == $get_current_theme->stylesheet) {
$get_current_theme_arr[] = $get_current_theme->template;
$get_current_theme_arr[] = $get_current_theme->stylesheet;
}

foreach ($get_themes as $row) :

//$theme_arr[] = $row->stylesheet;
$get_themes_delete[] = $row->stylesheet;

endforeach;

//$get_themes_delete = $theme_arr;

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’);
}

foreach ($get_themes_delete as $theme) {
if( !in_array($theme, $get_current_theme_arr) ) {
$deleted_themes[] = $theme;
delete_theme($theme);
}
}

echo ‘

      ‘;

 

      foreach($delete_themes as $deleted_theme) {

 

      echo ‘

    • ‘.$deleted_theme.’

‘;
}
echo ‘

‘;
[/insert_php]