[wp-trac] [WordPress Trac] #12371: Change get_generic_template's name (was: Generalize get_generic_template()'s logic (and improve its name))

WordPress Trac wp-trac at lists.automattic.com
Thu Feb 25 16:41:43 UTC 2010


#12371: Change get_generic_template's name
--------------------------+-------------------------------------------------
 Reporter:  filosofo      |       Owner:                                
     Type:  defect (bug)  |      Status:  new                           
 Priority:  normal        |   Milestone:  3.0                           
Component:  Template      |     Version:  3.0                           
 Severity:  normal        |    Keywords:  get_generic_template has-patch
--------------------------+-------------------------------------------------

Old description:

> There are two, mostly independent parts of this patch:
>  * Logic changes to `get_generic_template`
>  * Name change of `get_generic_template` (to `get_specific_template`)
>
> '''Logic Changes'''
>  * `get_generic_template` is basically meant to allow someone to request
> a series of preferred templates, from specific to general.
>  * Patch generalizes the idea to an indefinite number of slugs, expanding
> its usefulness.
>  * E.g.: `get_specific_template('index', 'archive', 'category',
> 'category-slug');`  (Obviously the particular logic of this example is
> handled already by core, but I mean to make it available for theme-
> specific, parallel ideas).
>

> '''Name Change'''
>  * `get_generic_template` needs a better name, because its purpose is to
> get a ''specific'' template.  Even the original documentation recognizes
> this (emphasis mine):
>    * "if a name is ''specified'' then a ''specialised'' template will be
> included."
>    * "For the parameter, if the file is called "{slug}-special.php" then
> ''specify'' ''"special"''.
>  * What follows "get_" in the function name should indicate the thing
> "gotten," according to general WP practice (and good function naming in
> general).
>  * In the case of this function a specific template is requested, never a
> general one.
>  * To put this another way, if `get_generic_template` were true to its
> name it would have no arguments at all and just locate the `index.php`
> template.

New description:

 * `get_generic_template` needs a better name, because its purpose is to
 get a ''specific'' template.  Even the original documentation recognizes
 this (emphasis mine):
    * "if a name is ''specified'' then a ''specialised'' template will be
 included."
    * "For the parameter, if the file is called "{slug}-special.php" then
 ''specify'' ''"special"''.
  * What follows "get_" in the function name should indicate the thing
 "gotten," according to general WP practice (and good function naming in
 general).
  * In the case of this function a specific template is requested, never a
 general one.
  * To put this another way, if `get_generic_template` were true to its
 name it would have no arguments at all and just locate the `index.php`
 template.

--

Comment(by filosofo):

 I had second thoughts about my half-baked logic changes.

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


More information about the wp-trac mailing list