From 32ee6cb39ed6fbd88d30fb98f5efaee70c348f32 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 23 Jun 2022 18:57:24 +0000 Subject: [PATCH] Themes: Add actions to template loading to assist with collecting debug info. This introduces the following new actions which wrap the process of loading a template file: * `wp_before_load_template` * `wp_after_load_template` Props rmccue, tabrisrp, peterwilsoncc Fixes #54541 git-svn-id: https://develop.svn.wordpress.org/trunk@53560 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/template.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/wp-includes/template.php b/src/wp-includes/template.php index 891e77748d..60752349c0 100644 --- a/src/wp-includes/template.php +++ b/src/wp-includes/template.php @@ -713,7 +713,31 @@ function locate_template( $template_names, $load = false, $require_once = true, } if ( $load && '' !== $located ) { + /** + * Fires before a located template is loaded. + * + * @since 6.1.0 + * + * @param string $located The template filename. + * @param string|array $template_names Template file(s) to search for, in order. + * @param bool $require_once Whether to require_once or require. + * @param array $args Additional arguments passed to the template. + */ + do_action( 'wp_before_load_template', $located, $template_names, $require_once, $args ); + load_template( $located, $require_once, $args ); + + /** + * Fires after a located template is loaded. + * + * @since 6.1.0 + * + * @param string $located The template filename. + * @param string|array $template_names Template file(s) to search for, in order. + * @param bool $require_once Whether to require_once or require. + * @param array $args Additional arguments passed to the template. + */ + do_action( 'wp_after_load_template', $located, $template_names, $require_once, $args ); } return $located;