[wp-trac] [WordPress Trac] #59847: Since WordPress 6.4, the functions.php of a theme moved to a different location using register_theme_directory is no longer called

WordPress Trac noreply at wordpress.org
Wed Nov 8 22:29:32 UTC 2023


#59847: Since WordPress 6.4, the functions.php of a theme moved to a different
location using register_theme_directory is no longer called
-----------------------------+------------------------------------
 Reporter:  partyfrikadelle  |       Owner:  joemcgill
     Type:  defect (bug)     |      Status:  reviewing
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Bootstrap/Load   |     Version:  6.4
 Severity:  critical         |  Resolution:
 Keywords:                   |     Focuses:  template, performance
-----------------------------+------------------------------------

Comment (by coreyw):

 @joemcgill It doesn't appear that resetting the globals would help. It
 seems that calls to `get_stylesheet_directory()` return an invalid path if
 called before a certain point (when the theme is setup perhaps).

 So, when ACF calls it during it's setup (`plugins_loaded` or similar),
 `get_stylesheet_directory()` returns the default theme path (`wp-
 content/themes/whatever`), but any call to that function during
 `after_setup_theme` returns the correct path (`custom-
 directory/whatever`).

 So this could be the fault of ACF calling the function too early (I've
 opened a ticket with them to investigate), but there is no mention of this
 being an issue on the
 [https://developer.wordpress.org/reference/functions/get_stylesheet_directory/
 docs page]. Or, WordPress should be handling this better and not returning
 an invalid path.

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


More information about the wp-trac mailing list