[wp-trac] [WordPress Trac] #12195: add filter for get_themes function

WordPress Trac wp-trac at lists.automattic.com
Thu Feb 11 19:34:04 UTC 2010


#12195: add filter for get_themes function
-------------------------+--------------------------------------------------
 Reporter:  maxaud       |        Owner:          
     Type:  enhancement  |       Status:  reopened
 Priority:  normal       |    Milestone:  3.0     
Component:  Themes       |      Version:          
 Severity:  normal       |   Resolution:          
 Keywords:  has-patch    |  
-------------------------+--------------------------------------------------
Changes (by maxaud):

  * status:  closed => reopened
  * resolution:  duplicate =>


Comment:

 I don't believe this is possible on a per '''site''' basis though.
 When I say site, I don't mean blog.

 Example:
 ms-themes.php shows the themes available to that '''site'''.
 What if I only want certain themes available/visible to certain
 '''sites''' (even to site admins)?

 My reasoning:
 My Multisite setup has restricted 'Site Admins' so they cannot go beyond
 the bounds of their 'Site'. If a user's main blog belongs on a different
 'Site' they cannot edit all their details or delete them. They also cannot
 edit blogs that don't reside on their site. I then made it so 'Site
 Admins' of site_id=1 have full control over everything (how it's currently
 set up).

 What if I want to upload a custom theme on site #1 and I don't even want
 site #2 to know that it's an option?

 I believe this cannot be done without making a filter on the get_themes
 function.

 example code for making a theme available to only one site:
 (uses scribu's add_filter patch)

 {{{
 function remove_themes($wp_themes) {

         // get current site
         global $current_site;

         // set themes that are site specific by unsetting them on all
 other sites
         if($current_site->id != 1) {

                 // unset theme from array
                 unset($wp_themes['Theme Name']);
         }

         // return theme
         return $wp_themes;
 }
 add_filter("get_themes", "remove_themes");
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12195#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list