[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 13:22:59 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           |   Keywords:  dev-feedback
  Focuses:                   |
-----------------------------+-----------------------------
 `--skip-themes` is a WP-CLI feature to disable loading of a given theme or
 all themes.

 It works by returning an empty string for 'template' and 'stylesheet':

 https://github.com/wp-cli/wp-
 cli/blob/a71167e1030462275a48c419854261efceba11e3/php/WP_CLI/Runner.php#L1751-L1755

 This hack has worked pretty reliably for a long time. However, there's a
 specific edge case we discovered: `--skip-themes` will load `wp-
 content/themes/functions.php` if it exists.

 See https://github.com/wp-cli/wp-cli/issues/5240 for some additional
 context.

 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?

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


More information about the wp-trac mailing list