[wp-trac] [WordPress Trac] #21676: Pass a variable to get_template_part()

WordPress Trac noreply at wordpress.org
Wed Jul 1 21:12:05 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 afercia):

 Replying to [comment:94 apedog]:
 > The second is the coding standards issue of using PHP's {{{extract()}}}
 which is discouraged outside of {{{load_template()}}}. As this feature IS
 implemented in {{{load_template()}}} and IS attempting to offer the same
 option as {{{set_query_var()}}} currently allows - direct access to
 variables - it is my opinion that {{{extract()}}} can be justified here as
 well.

 To my understanding, this is not entirely correct. Usage of `extract()` is
 discouraged without exceptions. I'm not sure it's stated anywhere that it
 is discouraged only "outside `load_template()`".

 Quoting:
 > most instances were eliminated from core in #22400, except for one
 instance in load_template() that was left for backward compatibility.

 I trust and support @SergeyBiryukov's judgment here:
 > this appears to be in good shape and I think can be tried for beta.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/21676#comment:96>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list