[wp-trac] [WordPress Trac] #40969: RFE: get_template_part() to return something or warn when nothing found
WordPress Trac
noreply at wordpress.org
Sat May 25 19:01:26 UTC 2019
#40969: RFE: get_template_part() to return something or warn when nothing found
------------------------------------------------+-----------------------
Reporter: sphakka | Owner: pento
Type: enhancement | Status: reopened
Priority: normal | Milestone: 5.3
Component: Themes | Version:
Severity: normal | Resolution:
Keywords: has-patch 2nd-opinion dev-feedback | Focuses: template
------------------------------------------------+-----------------------
Comment (by birgire):
It came to mind to bail early within {{{has_template_part()}}} with:
{{{
if ( ! is_string( $slug ) || '' === $slug ) {
return false;
}
}}}
to avoid {{{'.php'}}} template cases from these examples:
{{{
has_template_part( '' )
has_template_part( false )
has_template_part( null )
}}}
but when testing, it seems {{{'.php'}}} will work just fine as a template
file, corresponding to {{{locate_template( array( '.php' ) )}}} and
{{{get_template_part( '' )}}} :-)
Though I haven't seen {{{'.php'}}} used in the real world as a template
file, I'm inclined to not suggesting bailing early and keep
[attachment:"40969.6.diff"] as is.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40969#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list