Themes: Introduce a generic action that's fired when a template part is loaded.

This action allows debugging mechanisms to perform greater introspection into which template parts are loaded for any given request. It also exposes the array of candidate template part file names for each template part instance.

Props pcfreak30, jdeeburke

Fixes #41575


git-svn-id: https://develop.svn.wordpress.org/trunk@45059 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn 2019-03-28 21:12:20 +00:00
parent a66e27efc4
commit 60a92eb070
1 changed files with 11 additions and 0 deletions

View File

@ -154,6 +154,17 @@ function get_template_part( $slug, $name = null ) {
$templates[] = "{$slug}.php";
/**
* Fires before a template part is loaded.
*
* @since 5.2.0
*
* @param string $slug The slug name for the generic template.
* @param string $name The name of the specialized template.
* @param string[] $templates Array of template files to search for, in order.
*/
do_action( 'get_template_part', $slug, $name, $templates );
locate_template( $templates, true, false );
}