[wp-trac] [WordPress Trac] #21676: Pass a variable to get_template_part()
WordPress Trac
noreply at wordpress.org
Wed Jul 1 15:44:50 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 SergeyBiryukov):
I think I'd like to use just `$args` as the parameter name, for
consistency with `get_search_form()`.
Since this is new functionality, I don't expect that to cause any back
compat issues. The initial value would be an empty array, but if someone
already uses the variable locally, it should continue working as it did
before.
If we do want to be specific, I'd suggest `$template_args`, but I think
`$args` might just work. Thoughts?
On the other hand, `$template_args` might be a bit more future-proof if
these functions ever get an `$args` parameter that should *not* be passed
to the template, but that seems unlikely.
Still thinking about the naming, but this appears to be in good shape and
I think can be tried for beta.
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
[https://make.wordpress.org/core/handbook/best-practices/coding-
standards/php/#dont-extract discouraged per the coding standards].
I would also like to further explore the idea of `get_template_var()` from
comment:66. Something like `(get|set)_template_var()` that would work
pretty much like `(get|set)_query_var()`, but without polluting the main
query object. Any thoughts on that?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/21676#comment:88>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list