[wp-trac] [WordPress Trac] #18390: apply_filters for a theme's functions.php

WordPress Trac wp-trac at lists.automattic.com
Sat Aug 13 01:00:54 UTC 2011


#18390: apply_filters for a theme's functions.php
-------------------------+-----------------------------
 Reporter:  ofshard      |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Themes       |    Version:  3.2.1
 Severity:  normal       |   Keywords:
-------------------------+-----------------------------
 My primary intention with this suggestion is for switching a page's theme
 on the fly. Currently the only method I know of for this is to change the
 active theme before functions.php is included and then switching back
 sometime after, which I don't find very thread safe.

 Anyway, I suggest that lines 278-283 in wp-settings.php which currently
 read:

 {{{
 if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) {
         if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(
 STYLESHEETPATH . '/functions.php' ) )
                 include( STYLESHEETPATH . '/functions.php' );
         if ( file_exists( TEMPLATEPATH . '/functions.php' ) )
                 include( TEMPLATEPATH . '/functions.php' );
 }
 }}}

 be altered to implement the 'theme_functions' and 'theme_parent_functions'
 filters as below:


 {{{
 if ( !defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ){
         $path = (file_exists(STYLESHEETPATH . '/functions.php')) ?
 STYLESHEETPATH . '/functions.php' : '';
         $functions = apply_filters('theme_functions', $path);
         if( $functions != '' )
                 include($functions);

         $path = (TEMPLATEPATH !== STYLESHEETPATH &&
 file_exists(TEMPLATEPATH . '/functions.php')) ? TEMPLATEPATH .
 '/functions.php' : '';
         $functions = apply_filters('theme_parent_functions', $path);
         if( $functions != '' )
                 include($functions);
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18390>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list