[wp-trac] [WordPress Trac] #57928: Prevent loading wp-content/themes/functions.php when 'stylesheet' option is empty

WordPress Trac noreply at wordpress.org
Wed Mar 15 14:00:50 UTC 2023


#57928: Prevent loading wp-content/themes/functions.php when 'stylesheet' option is
empty
--------------------------------------------+------------------------------
 Reporter:  danielbachhuber                 |       Owner:  (none)
     Type:  enhancement                     |      Status:  new
 Priority:  normal                          |   Milestone:  Awaiting Review
Component:  Bootstrap/Load                  |     Version:
 Severity:  normal                          |  Resolution:
 Keywords:  dev-feedback reporter-feedback  |     Focuses:
--------------------------------------------+------------------------------
Changes (by hellofromTonya):

 * keywords:  dev-feedback => dev-feedback reporter-feedback


Comment:

 >What's the best way to prevent loading `wp-content/themes/functions.php`?
 Maybe `wp_get_active_and_valid_themes()` should return an empty array if
 'template' and 'stylesheet' are empty?

 I assume you are referring to when a filter sets `get_template()` and
 `get_stylesheet()` to return an empty string, but the main themes
 directory root (i.e. `WP_CONTENT_DIR . '/themes'`) is defined for the
 constants `TEMPLATEPATH` and `STYLESHEETPATH` (i.e. from
 `get_theme_root()`).

 If yes, then [https://core.trac.wordpress.org/browser/tags/6.1.1/src/wp-
 settings.php?marks=584#L581 the `functions.php` file is loaded if it
 exists in the main themes directory root].

 My question is the same as @SergeyBiryukov's:
 * Why would a `WP_CONTENT_DIR . '/themes/functions.php'` exist?
 * Is this a real-world use case for it to exist?
 * If yes, how prevalent is this real-world use case?

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


More information about the wp-trac mailing list