Skip to main content
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
Source Link

You'd have to make you site categories slug match your theme categoriestheme categories folder names.

Here's how to filter themes: Hide a theme on list of themes in wp-admin without editing core filesHide a theme on list of themes in wp-admin without editing core files

And then, supposing a site has the category a-p and the themes are stored in themes/a-p/, this will filter them out:

add_filter( 'all_themes', 'remove_themes_ms_wpse_117537' );

function remove_themes_ms_wpse_117537( $themes )
{
    if( 'site-themes-network' != get_current_screen()->id )
        return $themes;
        
    $site_cat = get_blog_option( absint( $_GET['id'] ), 'site_category' );
    if( $site_cat )
    {
        # Unset themes not in the folder /themes/$site_cat/
        foreach( $themes as $key => $theme )
        {
            if( strpos( $key, "$site_cat/" ) === false )
                unset($themes[$key]);
        }
    }
    return $themes;
}

You'd have to make you site categories slug match your theme categories folder names.

Here's how to filter themes: Hide a theme on list of themes in wp-admin without editing core files

And then, supposing a site has the category a-p and the themes are stored in themes/a-p/, this will filter them out:

add_filter( 'all_themes', 'remove_themes_ms_wpse_117537' );

function remove_themes_ms_wpse_117537( $themes )
{
    if( 'site-themes-network' != get_current_screen()->id )
        return $themes;
        
    $site_cat = get_blog_option( absint( $_GET['id'] ), 'site_category' );
    if( $site_cat )
    {
        # Unset themes not in the folder /themes/$site_cat/
        foreach( $themes as $key => $theme )
        {
            if( strpos( $key, "$site_cat/" ) === false )
                unset($themes[$key]);
        }
    }
    return $themes;
}

You'd have to make you site categories slug match your theme categories folder names.

Here's how to filter themes: Hide a theme on list of themes in wp-admin without editing core files

And then, supposing a site has the category a-p and the themes are stored in themes/a-p/, this will filter them out:

add_filter( 'all_themes', 'remove_themes_ms_wpse_117537' );

function remove_themes_ms_wpse_117537( $themes )
{
    if( 'site-themes-network' != get_current_screen()->id )
        return $themes;
        
    $site_cat = get_blog_option( absint( $_GET['id'] ), 'site_category' );
    if( $site_cat )
    {
        # Unset themes not in the folder /themes/$site_cat/
        foreach( $themes as $key => $theme )
        {
            if( strpos( $key, "$site_cat/" ) === false )
                unset($themes[$key]);
        }
    }
    return $themes;
}
Source Link
brasofilo
  • 22.1k
  • 8
  • 69
  • 264

You'd have to make you site categories slug match your theme categories folder names.

Here's how to filter themes: Hide a theme on list of themes in wp-admin without editing core files

And then, supposing a site has the category a-p and the themes are stored in themes/a-p/, this will filter them out:

add_filter( 'all_themes', 'remove_themes_ms_wpse_117537' );

function remove_themes_ms_wpse_117537( $themes )
{
    if( 'site-themes-network' != get_current_screen()->id )
        return $themes;
        
    $site_cat = get_blog_option( absint( $_GET['id'] ), 'site_category' );
    if( $site_cat )
    {
        # Unset themes not in the folder /themes/$site_cat/
        foreach( $themes as $key => $theme )
        {
            if( strpos( $key, "$site_cat/" ) === false )
                unset($themes[$key]);
        }
    }
    return $themes;
}