From 666d713c1bace968bc0d8b6a13a0a1e81669ada2 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 6 Feb 2019 18:36:49 +0000 Subject: [PATCH] Themes: Revert returning the value of `locate_template()` in functions that call it. Because the names of the `get_header()`, `get_footer()`, `get_sidebar()`, and `get_template_part()` functions indicate that a value is returned, some plugins and themes already have `echo get_template_part()` in their codebase. Adding a return value to these functions using the approach in [44678] will cause the two unintended side effects of unexpected content being sent to the browser, and accidental path disclosure. Reverts [44678]. Props davidbinda. See #40969. git-svn-id: https://develop.svn.wordpress.org/trunk@44725 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/general-template.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index cd89f4124a..11d4b77ff4 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -16,10 +16,8 @@ * "special". * * @since 1.5.0 - * @since 5.1.0 Added the return value. * * @param string $name The name of the specialised header. - * @return string The template filename if one is located. */ function get_header( $name = null ) { /** @@ -40,7 +38,7 @@ function get_header( $name = null ) { $templates[] = 'header.php'; - return locate_template( $templates, true ); + locate_template( $templates, true ); } /** @@ -53,10 +51,8 @@ function get_header( $name = null ) { * "special". * * @since 1.5.0 - * @since 5.1.0 Added the return value. * * @param string $name The name of the specialised footer. - * @return string The template filename if one is located. */ function get_footer( $name = null ) { /** @@ -77,7 +73,7 @@ function get_footer( $name = null ) { $templates[] = 'footer.php'; - return locate_template( $templates, true ); + locate_template( $templates, true ); } /** @@ -90,10 +86,8 @@ function get_footer( $name = null ) { * "special". * * @since 1.5.0 - * @since 5.1.0 Added the return value. * * @param string $name The name of the specialised sidebar. - * @return string The template filename if one is located. */ function get_sidebar( $name = null ) { /** @@ -114,7 +108,7 @@ function get_sidebar( $name = null ) { $templates[] = 'sidebar.php'; - return locate_template( $templates, true ); + locate_template( $templates, true ); } /** @@ -134,11 +128,9 @@ function get_sidebar( $name = null ) { * "special". * * @since 3.0.0 - * @since 5.1.0 Added the return value. * * @param string $slug The slug name for the generic template. * @param string $name The name of the specialised template. - * @return string The template filename if one is located. */ function get_template_part( $slug, $name = null ) { /** @@ -162,7 +154,7 @@ function get_template_part( $slug, $name = null ) { $templates[] = "{$slug}.php"; - return locate_template( $templates, true, false ); + locate_template( $templates, true, false ); } /**