The following filter works in Multisite in the following screens:
/wp-admin/network/themes.php
/wp-admin/network/site-themes.php?id=1
(individual sites allowed themes)
add_filter( 'all_themes', 'wpse_55081_remove_themes_ms' );
function wpse_55081_remove_themes_ms($themes)
{
unset($themes['Twenty Ten'], $themes['Twenty Eleven']);
return $themes;
}
For the regular theme selector in a single site or sub-site of a network /wp-admin/themes.php
(Appearance -> Themes), looks like there's no hook...
I found that $wp_themes
global var holds the array with all themes, but couldn't manage to unset items in it...
The old jQuery trickery does the job, but pagination may become funny...
add_action( 'admin_head-themes.php', 'wpse_55081_remove_themes' );
function wpse_55081_remove_themes()
{
?>
<script type="text/javascript">
jQuery(document).ready( function($) {
$('div.available-theme:contains("comicpress")').remove();
$('div.available-theme:contains("twentyten")').remove();
$('div.available-theme:contains("starkers")').remove();
});
</script>
<?php
}
Update
Looks like there's a new hook on the block: extra_theme_headers
.
But there's something weird:
- it is documented as a new filter in WP 3.4
- but it appears in
wp-includes/deprecated.php
(?!)
/*
* The returning $arr is always empty, but we are able to unset items in the global $wp_themes
* Works in all theme screens, Multisite or Single Site (and doesn't bugs pagination)
*
* It is defined this way: apply_filters( 'extra_theme_headers', array() )
* The array value is always empty but, if we return it, the filter doesn't works..
*
*/
add_filter( 'extra_theme_headers', 'wpse_55081_remove_themes_everywhere', 10, 1 );
function wpse_55081_remove_themes_everywhere($arr)
{
global $wp_themes;
unset($wp_themes['Convertible/Convertible'], $wp_themes['grido-child'], $wp_themes['ilost'], $wp_themes['parallels'], $wp_themes['twentyeleven']);
// return $arr;
}