[wp-trac] [WordPress Trac] #18298: deprecate TEMPLATEPATH and STYLESHEETPATH

WordPress Trac noreply at wordpress.org
Wed Sep 20 17:25:41 UTC 2023


#18298: deprecate TEMPLATEPATH and STYLESHEETPATH
-------------------------------------------------+-------------------------
 Reporter:  aaroncampbell                        |       Owner:  flixos90
     Type:  enhancement                          |      Status:  closed
 Priority:  normal                               |   Milestone:  6.4
Component:  Themes                               |     Version:  3.0
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests needs-dev-  |     Focuses:  template,
  note commit                                    |  performance
-------------------------------------------------+-------------------------
Changes (by flixos90):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"56635" 56635]:
 {{{
 #!CommitTicketReference repository="" revision="56635"
 Themes: Deprecate usage of `TEMPLATEPATH` and `STYLESHEETPATH` constants.

 While generally the functions `get_template_directory()` and
 `get_stylesheet_directory()` were long recommended to use to get the
 parent or child theme directory, the `TEMPLATEPATH` and `STYLESHEETPATH`
 constants were still used in a few places in core, most importantly in
 template related logic.

 The remaining usage was problematic as it prevented testability of certain
 key components of WordPress core.

 This changeset replaces all remaining usage with the corresponding
 functions and effectively marks these constants as deprecated. It also
 adds test coverage accordingly and even unlocks some existing, previously
 commented out test coverage to work as expected.

 Performance of the new approach has been benchmarked and shows no notable
 differences. Yet, given that the current theme directories are not
 expected to change within a regular WordPress page load, the
 `get_template_directory()` and `get_stylesheet_directory()` functions were
 amended with in-memory caching of the result, unless one of the defining
 values is being filtered.

 Props thekt12, spacedmonkey, mukesh27, aaroncampbell, scribu, lloydbudd,
 cais, chipbennett, toscho, omarabid, CrazyJaco, DrewAPicture, obenland,
 wonderboymusic, nacin, helen, dd32, chriscct7, SergeyBiryukov, swissspidy,
 joemcgill, flixos90.
 Fixes #18298.
 }}}

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


More information about the wp-trac mailing list