5

Assume we have a multisite network. All sites in the network are separated into groups by some option value. What I want to do is to separate network available themes to be available to specific groups.

For instance, I have A-Z themes installed. I want to activate A-K themes to group 1, L-O themes to group 2 and P-Z themes to group 3.

Is there an easy way to do it?

6
  • possible duplicate of Categorising themes by folders in backend
    – brasofilo
    Commented Oct 11, 2013 at 14:38
  • @brasofilo I don't see an answer on my question in your link... I don't need to add custom column to themes list or theme actions, i need to find a way how to show different themes to different site owners... Or i missed something? Commented Oct 11, 2013 at 14:47
  • 1
    Oh, sorry, misread that. Retracting close vote.
    – brasofilo
    Commented Oct 11, 2013 at 14:59
  • 1
    Don't think somebody did ever build a plugin for that. Atleast it seems like it's possible to hide a theme from the list wordpress.stackexchange.com/questions/55081/…. So you can build this yourself.
    – s1lv3r
    Commented Oct 11, 2013 at 15:18
  • Eugene, no follow up here? Or did you find another solution?
    – brasofilo
    Commented Oct 15, 2013 at 16:39

1 Answer 1

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.