Make WordPress Core

Ticket #13691: get_template_part.2.diff

File get_template_part.2.diff, 1.1 KB (added by wjm, 15 years ago)

Simplified version

  • general-template.php

     
    111111 *
    112112 * @uses locate_template()
    113113 * @since 3.0.0
    114  * @uses do_action() Calls 'get_template_part{$slug}' action.
     114 * @uses do_action() Calls 'get_template_part_{$slug}' action.
    115115 *
    116116 * @param string $slug The slug name for the generic template.
    117  * @param string $name The name of the specialised template.
     117 * @param mixed $names The names of the specialised templates (it can be a string, or an array of names to search for in priority order.).
    118118 */
    119 function get_template_part( $slug, $name = null ) {
    120         do_action( "get_template_part_{$slug}", $slug, $name );
    121 
     119function get_template_part( $slug, $names = array() ) {
     120        do_action( "get_template_part_{$slug}", $slug, $names );
     121       
    122122        $templates = array();
    123         if ( isset($name) )
     123        foreach ( (array)$names as $name ) {
    124124                $templates[] = "{$slug}-{$name}.php";
    125 
     125        }
    126126        $templates[] = "{$slug}.php";
    127127
    128128        locate_template($templates, true, false);