Skip to content

Commit

Permalink
Themes: Relocate actions firing prior to and after template loading.
Browse files Browse the repository at this point in the history
This relocates the actions `wp_before_load_template` and `wp_after_load_template` to fire within the `load_template()` function.

Prior to this change the actions fired in the `locate_template()` function.

Follow up to [53560].

Props johnjamesjacoby, johnbillion.
Fixes #54541.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53829 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
peterwilsoncc committed Sep 21, 2022
1 parent 3b68d37 commit a0cefe8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
46 changes: 22 additions & 24 deletions wp-includes/template.php
Expand Up @@ -715,31 +715,7 @@ 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;
Expand Down Expand Up @@ -792,9 +768,31 @@ function load_template( $_template_file, $require_once = true, $args = array() )
$s = esc_attr( $s );
}

/**
* Fires before a template file is loaded.
*
* @since 6.1.0
*
* @param string $_template_file The full path to the template file.
* @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', $_template_file, $require_once, $args );

if ( $require_once ) {
require_once $_template_file;
} else {
require $_template_file;
}

/**
* Fires after a template file is loaded.
*
* @since 6.1.0
*
* @param string $_template_file The full path to the template file.
* @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', $_template_file, $require_once, $args );
}
2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-54269';
$wp_version = '6.1-alpha-54270';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit a0cefe8

Please sign in to comment.