[wp-hackers] Filtering Themes visible for a particular network

Shelby, Harper harper.shelby at parivedasolutions.com
Wed Jul 21 23:28:42 UTC 2010


Andrew,
        Thanks for your help. I've successfully moved the themes into site_id-based folders, and they can all be seen, however this appears to have only fixed that part of the problem. As a network admin (OK, I've only tested this with *the* admin, but I had assumed it would still work in that case), I can see all of the themes no matter which network I'm logged in to, and if I enable them in the Super Admin->Themes menu, then the individual sites can see them even if they're not part of that network. Is there anything I'm missing here - I noticed that register_theme_director() just adds to the global $wp_theme_directories - is that the core of the problem, or is it the use of the original site admin login that could cause this?

Thanks,
Harper

-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Andrew Nacin
Sent: Tuesday, July 20, 2010 5:17 PM
To: wp-hackers at lists.automattic.com
Subject: Re: [wp-hackers] Filtering Themes visible for a particular network

On Tue, Jul 20, 2010 at 6:10 PM, Andrew Nacin <wp at andrewnacin.com> wrote:

> On Tue, Jul 20, 2010 at 5:59 PM, Shelby, Harper <
> harper.shelby at parivedasolutions.com> wrote:
>
>> I've been asked to implement theme filtering for a multi-network
>> installation, so that network admins only see those themes which "belong" to
>> them. In the existing installation (on MU 2.9.2), this was done by altering
>> wpmu-themes to check for a Tags value in the theme's CSS file and filtering
>> based on that. I'm trying to move this implementation into a plugin to
>> reduce changes to the core code. Digging into the code, I don't see any
>> action or filter hooks being called in ms-themes.php, so I suspect my best
>> course of action is to move themes into network-specific subdirectories of
>> wp-content/themes, then alter the include path in an admin_init hook to
>> bring in the proper theme directory. Is there a better way to implement
>> this, or are there any potential risks that I haven't seen in this course of
>> action?
>>
>
> You can indeed register theme directories in a plugin. In fact that seems
> like a very sane way of doing this (as long as you don't expect a theme to
> be used across networks).
>

What I meant was, no need for admin_init modifications or anything of the
sort. Check out register_theme_directory(). So you could simply have a
plugin that calls register_theme_directory( WP_CONTENT_DIR .
'/network-themes/' . $current_site->site_id ); and you'd be good to go.

Also, I'd upgrade to 3.0 when you can (perhaps with 3.0.1), there's a decent
number of MU improvements and bug fixes that went into that release.
_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.


More information about the wp-hackers mailing list