[wp-trac] [WordPress Trac] #21676: Pass a variable to get_template_part()
WordPress Trac
noreply at wordpress.org
Wed Jul 1 16:19:30 UTC 2020
#21676: Pass a variable to get_template_part()
-------------------------------------+------------------------------
Reporter: sc0ttkclark | Owner: SergeyBiryukov
Type: enhancement | Status: reviewing
Priority: normal | Milestone: Awaiting Review
Component: Template | Version: 3.4.1
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses:
-------------------------------------+------------------------------
Comment (by apedog):
>As already noted above, I believe we'd want to avoid the extract() usage,
as most instances were eliminated from core in #22400, except for one
instance in load_template() that was left for backward compatibility. The
extract() usage is also discouraged per the coding standards.
As we are still within the specific context of load_template, where
extract() is still allowed, I think this can still be allowed without
regarding this as a ''new'' exception to the coding standards.
I find that usage of {{{<img src="<?php echo $img ?>" />}}} (which can
currently be achieved using {{{set_query_var('img')}}}) should also be
available to variables added through the new $args.
Adding this feature but handicapping its like so: {{{<img src="<?php echo
$args['img'] ?>" />}}} makes this feel like a half-measure and not a
robust/smooth addition to WP templating system.
I think the extra work that would be required to protect global variables
is certainly worth it.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/21676#comment:90>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list