[wp-trac] [WordPress Trac] #20509: Theme idea - generic.php

WordPress Trac wp-trac at lists.automattic.com
Mon Apr 23 05:19:46 UTC 2012


#20509: Theme idea - generic.php
-----------------------------+------------------------------
 Reporter:  johnjamesjacoby  |       Owner:
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Themes           |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  dev-feedback     |
-----------------------------+------------------------------

Comment (by johnbillion):

 I like this idea.

 I wonder what would be the best way to implement it. It might be nice if
 plugins could register the path to their bundled generic.php as a fallback
 file, that way they won't need to mess around with hooking into
 `template_include` and checking for the existance of generic.php in the
 theme.

 Example plugin code:

 {{{
 if ( get_query_var( 'my_plugin_query_var' ) )
         register_generic_plugin_file( plugin_dir_path( __FILE__ ) .
 '/generic.php' );
 }}}

 Then we'd have a function similar to all the other `get_*_template()`
 functions used by the template loader which loads the generic template
 when [comment:4 is_generic_request()] is true:

 {{{
 function get_generic_template() {

         $templates = array();

         $templates[] = 'generic.php';

         if ( $fallback = get_generic_plugin_file() )
                 $templates[] = $fallback;

         return get_query_template( 'generic', $templates );
 }
 }}}

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


More information about the wp-trac mailing list