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

WordPress Trac noreply at wordpress.org
Mon May 1 21:37:50 UTC 2023


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

 * owner:  (none) => danielbachhuber
 * status:  new => assigned
 * milestone:  Awaiting Review => Future Release


Comment:

 @SergeyBiryukov @hellofromTonya @flixos90 @spacedmonkey I put together a
 few options to consider:

 1. [https://github.com/WordPress/wordpress-develop/pull/4409 Return an
 empty array from wp_get_active_and_valid_themes() when !
 wp_using_themes()].\\\\This feels like the most correct approach to me.
 However, it would be a backwards compat break for any site with
 `add_filter( 'wp_using_themes', '__return_false' );` and a valid
 `template` value, because the theme's `functions.php` would no longer be
 loaded.\\\\
 2. [https://github.com/WordPress/wordpress-develop/pull/4408 Return an
 empty array from wp_get_active_and_valid_themes() when get_template() and
 get_stylesheet() are falsy].\\\\This is more of a WP-CLI-specific fix and
 has less surface area. However, it would be a backwards compat break for
 any site that has `template` set to `''` but is still filtering
 `template_directory` (unlikely).\\\\
 3. [https://github.com/WordPress/wordpress-develop/pull/4410 Add a filter
 to wp_get_active_and_valid_themes()].\\\\Maybe the least risky change or
 maybe the most risky change. I'm not sure we actually want to introduce a
 filter here, but we do have filters for other parts of `wp-
 includes/load.php`.

 Thoughts?

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


More information about the wp-trac mailing list