以下过滤器适用于Multisite 在以下屏幕中:
/wp-admin/network/themes.php
/wp-admin/network/site-themes.php?id=1
(个别网站允许主题)
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;
}
中的常规主题选择器
single site 或
sub-site of a network /wp-admin/themes.php
(外观->;主题),看起来没有挂钩。。。
- Manipulate list of themes in wp-admin
- Reordering themes in admin panel我发现
$wp_themes
全局变量保存包含所有主题的数组,但无法取消设置其中的项。。。jQuery的老把戏可以做到这一点,但分页可能会变得很有趣。。。
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
}
更新看起来有了一个新的钩子:extra_theme_headers
.
但有件奇怪的事:是的documented 作为WP 3.4中的新过滤器,但它出现在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;
}