From 60a92eb070ad62daeb566c03b0006bb7753bf6c3 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 28 Mar 2019 21:12:20 +0000 Subject: [PATCH] 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 --- src/wp-includes/general-template.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index 1923c79b48..b225665a3e 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -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 ); }