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

Built from https://develop.svn.wordpress.org/trunk@53560


git-svn-id: http://core.svn.wordpress.org/trunk@53149 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2022-06-23 18:59:09 +00:00
parent a457e3498e
commit 5dd1936fdb
2 changed files with 25 additions and 1 deletions

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;

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-53559';
$wp_version = '6.1-alpha-53560';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.