Ticket #15141: get_templates_filter.patch
| File get_templates_filter.patch, 2.6 KB (added by , 16 years ago) |
|---|
-
wp-includes/general-template.php
1 1 <?php 2 2 /** 3 * Stub function allowing filters on get_(header|footer|sidebar|template_part) functions. 4 * Plugins can take over template elements giving a lot more versatility to template designers. 5 * 6 * @author 5ubliminal 7 * @internal 8 * @param string $template 9 * @param array $templates 10 * @return array 11 */ 12 function apply_templates_filter($template, $templates){ 13 // If plugins don't return a valid array just return the defaults 14 if(!is_array($tpls = apply_filters("{$template}_templates", $templates)) || empty($tpls)) return $templates; 15 // Try and validate existance of a file in new template array... if not found fade back to defaults 16 if((!$tpl = locate_template($tpls)) || empty($tpl)) return $templates; 17 // Return the new array here (previous line can be skipped but better safe than sorry) 18 return $tpls; 19 } 20 21 /** 3 22 * General template tags that can go anywhere in a template. 4 23 * 5 24 * @package WordPress … … 29 48 $templates[] = "header-{$name}.php"; 30 49 31 50 $templates[] = "header.php"; 51 52 /** 53 * Allow plugins to hook in here and add / remove templates. 54 * @see apply_templates_filter() 55 */ 56 $templates = apply_templates_filter('header', $templates); 32 57 33 58 // Backward compat code will be removed in a future release 34 59 if ('' == locate_template($templates, true)) … … 59 84 60 85 $templates[] = "footer.php"; 61 86 87 /** 88 * Allow plugins to hook in here and add / remove templates. 89 * @see apply_templates_filter() 90 */ 91 $templates = apply_templates_filter('footer', $templates); 92 62 93 // Backward compat code will be removed in a future release 63 94 if ('' == locate_template($templates, true)) 64 95 load_template( ABSPATH . WPINC . '/theme-compat/footer.php'); … … 88 119 89 120 $templates[] = "sidebar.php"; 90 121 122 /** 123 * Allow plugins to hook in here and add / remove templates. 124 * @see apply_templates_filter() 125 */ 126 $templates = apply_templates_filter('sidebar', $templates); 127 91 128 // Backward compat code will be removed in a future release 92 129 if ('' == locate_template($templates, true)) 93 130 load_template( ABSPATH . WPINC . '/theme-compat/sidebar.php'); … … 125 162 126 163 $templates[] = "{$slug}.php"; 127 164 165 /** 166 * Allow plugins to hook in here and add / remove templates. 167 * @see apply_templates_filter() 168 */ 169 $templates = apply_templates_filter("part-{$slug}", $templates); 170 128 171 locate_template($templates, true, false); 129 172 } 130 173
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)