Ticket #15086: 15086.001.diff
| File 15086.001.diff, 1.4 KB (added by aaroncampbell, 3 years ago) |
|---|
-
wp-includes/general-template.php
116 116 * @param string $slug The slug name for the generic template. 117 117 * @param string $name The name of the specialised template. 118 118 */ 119 function get_template_part( $slug, $name = null ) { 120 do_action( "get_template_part_{$slug}", $slug, $name ); 119 function get_template_part( $slug, $name = null, $directory = null ) { 120 if ( false !== strpos( $slug, DIRECTORY_SEPARATOR ) ) { 121 $original_slug = $slug; 122 $slug = substr( strrchr( $slug, DIRECTORY_SEPARATOR ), 1 ); 123 if ( empty( $directory ) ) { 124 $directory = substr( $original_slug, 0, strrpos( $original_slug, DIRECTORY_SEPARATOR ) ); 125 } 126 } 127 $slug = sanitize_file_name( $slug ); 121 128 129 // @todo sanitize here 130 $directory = rtrim( $directory, DIRECTORY_SEPARATOR ); 131 132 do_action( "get_template_part_{$slug}", $slug, $name, $directory ); 133 122 134 $templates = array(); 135 if ( ! empty( $directory ) ) { 136 if ( isset($name) ) 137 $templates[] = $directory . DIRECTORY_SEPARATOR . "{$slug}-{$name}.php"; 138 139 $templates[] = $directory . DIRECTORY_SEPARATOR . "{$slug}.php"; 140 } 141 123 142 if ( isset($name) ) 124 143 $templates[] = "{$slug}-{$name}.php"; 125 144 126 145 $templates[] = "{$slug}.php"; 127 146 128 locate_template( $templates, true, false);147 locate_template( $templates, true, false ); 129 148 } 130 149 131 150 /**
