[wp-trac] [WordPress Trac] #10467: Add a filter for changing where parent templates are located

WordPress Trac wp-trac at lists.automattic.com
Fri Oct 9 21:51:05 UTC 2009


#10467: Add a filter for changing where parent templates are located
-------------------------+--------------------------------------------------
 Reporter:  apeatling    |       Owner:                                              
     Type:  enhancement  |      Status:  new                                         
 Priority:  normal       |   Milestone:  2.9                                         
Component:  Themes       |     Version:  2.8                                         
 Severity:  normal       |    Keywords:  has-patch, themes, parent themes, buddypress
-------------------------+--------------------------------------------------

Comment(by apeatling):

 I've attached a new patch that allows registration of a new a theme
 directory. WordPress will then consider this as an additional place to
 look for themes.

 {{{
 register_theme_directory( 'plugins/my-plugin/bundled-themes' );
 }}}

 All directories must be relative to the content directory.

 This was considerably more in-depth than I expected. The hardest part was
 getting the get_template_directory[_uri]() and
 get_stylesheet_directory[_uri]() functions to look in varying theme roots
 depending on the theme in use. Currently get_theme_root() simply returns a
 filterable "wp-content/themes" value with no theme parameters to allow us
 to determine where to look.

 The solution was to make sure that the $wp_themes global was available and
 loop through that matching the template or stylesheet name, then use the
 new theme root/theme root uri value. I'm not completely happy with this
 method though, it seems quite inefficient. I'm sure there is a better way,
 but it's a start.

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


More information about the wp-trac mailing list