[wp-trac] [WordPress Trac] #42855: Add ability to filter header, sidebar, searchform, footer and template_part file paths

WordPress Trac noreply at wordpress.org
Sat Dec 9 21:47:05 UTC 2017


#42855: Add ability to filter header, sidebar, searchform, footer and template_part
file paths
------------------------------+-----------------------------
 Reporter:  atanasangelovdev  |      Owner:
     Type:  enhancement       |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Themes            |    Version:
 Severity:  normal            |   Keywords:
  Focuses:  template          |
------------------------------+-----------------------------
 I've seen several tickets that appear related but are either dead or
 include bigger changes compared to what I'm proposing (the most relevant
 being #21062).

 My proposal (including patch):
 1. Introduce `get_template_part_hierarchy( $slug, $name = null );`.
 1. Update `get_header()`, `get_sidebar()`, `get_search_form()`,
 `get_footer()` and `get_template_part()` to use the new function.
 1. Add a `template_part_{$slug}_template_hierarchy` filter to the new
 function so all 5 general template functions' results are filterable.

 What these changes achieve:
 1. Provide a way to filter the location of header.php, sidebar.php,
 searchform.php, footer.php and any file loaded by `get_template_part()`
 1. Reduce code duplication (all metioned functions had the same $slug +
 $name logic to create a $templates array)

 Also, @MikeSchinkel has mentioned a few benefits and arguments for why
 such a filter is beneficial:
 https://core.trac.wordpress.org/ticket/21062#comment:19

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42855>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list