[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 23:18:19 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:  has-patch        |     Focuses:  template, performance
-----------------------------+------------------------------------

Comment (by coreyw):

 I'm guessing the `return '/themes';` line was there to short-circuit the
 function and avoid the database lookup because it assumes that the default
 theme directory must be the only directory in `$wp_theme_directories`
 array. The "problem" though, is that the default theme directory is not
 registered in `wp-settings.php` until after `muplugins_loaded` has run.

 So if you register a custom directory in a must-use plugin, (and if other
 must-use plugins reference that through use of
 `get_stylesheet_directory()` or similar), then things will be off.

 I feel like a must-use plugin is the most logical place to register a
 custom directory though. One workaround right now is to always register at
 least two custom directories, but that seems a little silly to register a
 dummy directory (plus it has to actually exist).

 I always had registered two custom directories (one for our custom
 directory, and one for the default themes when installing WordPress in a
 subfolder) so I never noticed the issue. But we are no longer registering
 that WordPress `wordpress/wp-content/themes` directory so it is now an
 issue for us.

 This must-use plugin works:
 {{{#!php
 <?php
 register_theme_directory('/custom/path');
 register_theme_directory(ABSPATH.'wp-content/themes');
 }}}

 while this does not:
 {{{#!php
 <?php
 register_theme_directory('/custom/path');
 }}}

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


More information about the wp-trac mailing list