Skip to content

Commit 1038745

Browse files
committed
Customize: Introduce a fix for themes that pass a stringable object through the template_include filter despite it being documented as only accepting a string.
This has historically worked until [61892] increased the strictness of the template file validation which dismissed any value of a type other than a string, which a stringable object is not. Merges r61913 to the 6.4 branch. Props dmsnell, westonruter. git-svn-id: https://develop.svn.wordpress.org/branches/6.4@61926 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 662aabe commit 1038745

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/wp-includes/template-loader.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@
101101
*
102102
* @param string $template The path of the template to include.
103103
*/
104-
$template = apply_filters( 'template_include', $template );
105-
$template = is_string( $template ) ? realpath( $template ) : null;
104+
$template = apply_filters( 'template_include', $template );
105+
$is_stringy = is_string( $template ) || ( is_object( $template ) && method_exists( $template, '__toString' ) );
106+
$template = $is_stringy ? realpath( (string) $template ) : null;
106107
if (
107108
is_string( $template ) &&
108109
( str_ends_with( $template, '.php' ) || str_ends_with( $template, '.html' ) ) &&

0 commit comments

Comments
 (0)