Skip to content

Commit 77e65ea

Browse files
committed
Themes: Relocate actions firing prior to and after template loading.
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. git-svn-id: https://develop.svn.wordpress.org/trunk@54270 602fd350-edb4-49c9-b593-d223f7449a82
1 parent b343603 commit 77e65ea

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

src/wp-includes/template.php

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -715,31 +715,7 @@ function locate_template( $template_names, $load = false, $require_once = true,
715715
}
716716

717717
if ( $load && '' !== $located ) {
718-
/**
719-
* Fires before a located template is loaded.
720-
*
721-
* @since 6.1.0
722-
*
723-
* @param string $located The template filename.
724-
* @param string|array $template_names Template file(s) to search for, in order.
725-
* @param bool $require_once Whether to require_once or require.
726-
* @param array $args Additional arguments passed to the template.
727-
*/
728-
do_action( 'wp_before_load_template', $located, $template_names, $require_once, $args );
729-
730718
load_template( $located, $require_once, $args );
731-
732-
/**
733-
* Fires after a located template is loaded.
734-
*
735-
* @since 6.1.0
736-
*
737-
* @param string $located The template filename.
738-
* @param string|array $template_names Template file(s) to search for, in order.
739-
* @param bool $require_once Whether to require_once or require.
740-
* @param array $args Additional arguments passed to the template.
741-
*/
742-
do_action( 'wp_after_load_template', $located, $template_names, $require_once, $args );
743719
}
744720

745721
return $located;
@@ -792,9 +768,31 @@ function load_template( $_template_file, $require_once = true, $args = array() )
792768
$s = esc_attr( $s );
793769
}
794770

771+
/**
772+
* Fires before a template file is loaded.
773+
*
774+
* @since 6.1.0
775+
*
776+
* @param string $_template_file The full path to the template file.
777+
* @param bool $require_once Whether to require_once or require.
778+
* @param array $args Additional arguments passed to the template.
779+
*/
780+
do_action( 'wp_before_load_template', $_template_file, $require_once, $args );
781+
795782
if ( $require_once ) {
796783
require_once $_template_file;
797784
} else {
798785
require $_template_file;
799786
}
787+
788+
/**
789+
* Fires after a template file is loaded.
790+
*
791+
* @since 6.1.0
792+
*
793+
* @param string $_template_file The full path to the template file.
794+
* @param bool $require_once Whether to require_once or require.
795+
* @param array $args Additional arguments passed to the template.
796+
*/
797+
do_action( 'wp_after_load_template', $_template_file, $require_once, $args );
800798
}

0 commit comments

Comments
 (0)