[wp-trac] [WordPress Trac] #58866: Avoid consts inside `locate_template` as it gives incorrect template path after switch_theme

WordPress Trac noreply at wordpress.org
Wed Jul 26 04:58:34 UTC 2023


#58866: Avoid consts inside `locate_template` as it gives incorrect template path
after switch_theme
-------------------------------------------------+-------------------------
 Reporter:  thekt12                              |       Owner:  thekt12
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  normal                               |   Milestone:  6.4
Component:  Themes                               |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  good-first-bug has-patch reporter-   |     Focuses:  template
  feedback                                       |
-------------------------------------------------+-------------------------

Comment (by mukesh27):

 @joemcgill Yesterday, I came across ticket #18298, where I collected the
 data that I intended to share here. However, you posted it before I could.
 Thank you for sharing it.

 This ticket addresses the deprecation of TEMPLATEPATH and STYLESHEETPATH
 constants in WordPress and proposes using the respective functions
 instead.

 As mentioned in https://core.trac.wordpress.org/ticket/18298#comment:31,
 if we switch to using functions instead of constants, we may experience
 performance regression.


  Eliminating TEMPLATEPATH and STYLESHEETPATH was designed to make things
 more testable, I get that. But that doesn't apply to wp-settings.php, for
 example. This also exposes the ability to tinker with locate_template() by
 filtering the theme directory itself, which seems pretty scary. And, the
 changes in locate_template() mean these functions are called in a loop,
 rather than outside of it, especially problematic because it could be
 called up to four times per iteration even though the values might be the
 same (in the case of no child theme).

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


More information about the wp-trac mailing list