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
This commit is contained in:
John Blackbourn 2022-06-23 18:57:24 +00:00
parent 828d518988
commit 32ee6cb39e

View File

@ -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;