+ $files_to_delete = $theme_info = array();
+ $theme_translations = wp_get_installed_translations( 'themes' );
+ foreach ( $themes as $key => $theme ) {
+ $theme_info[ $theme ] = wp_get_theme( $theme );
+
+ // Locate all the files in that folder.
+ $files = list_files( $theme_info[ $theme ]->get_stylesheet_directory() );
+ if ( $files ) {
+ $files_to_delete = array_merge( $files_to_delete, $files );
+ }
+
+ // Add translation files.
+ $theme_slug = $theme_info[ $theme ]->get_stylesheet();
+ if ( ! empty( $theme_translations[ $theme_slug ] ) ) {
+ $translations = $theme_translations[ $theme_slug ];
+
+ foreach ( $translations as $translation => $data ) {
+ $files_to_delete[] = $theme_slug . '-' . $translation . '.po';
+ $files_to_delete[] = $theme_slug . '-' . $translation . '.mo';
+ }
+ }
+ }
+