Opened 15 months ago
Closed 13 months ago
#20138 closed defect (bug) (fixed)
What happens to get_current_theme()?
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.4 |
| Component: | Themes | Version: | |
| Severity: | normal | Keywords: | |
| Cc: |
Description (last modified by nacin)
After #20103, get_current_theme() is only useful for returning the theme name untranslated. It no longer serves as a key anywhere (like for get_themes()), and we previously phased it out in the theme mod functions.
The question is, what to do with it?
No theme in http://wpcom-themes.svn.automattic.com uses get_current_theme() in the footer (only on theme options pages), but that doesn't mean some other theme isn't doing exactly that. On one hand, if we eliminate the current_theme option, get_current_theme() will force style.css to be read, which normally does not happen on the frontend. But, if we keep the current_theme option, the name will not be translated.
My current thought is this:
- Deprecate get_current_theme(). Have it call wp_get_theme()->get('Name'), as it does now, but remove the current_theme option all together. No more caching the style.css read.
- Introduce a new way to get a theme name.
Point 2 is interesting. I think it could be solved with a fancy __toString() method on WP_Theme, which means that echo wp_get_theme() could actually echo wp_get_theme()->display('Name'). Or, another function.
Both points leave a conundrum, though — whether style.css reads (a single style.css read, not every theme) are not the end of the world on the frontend.
I had a cursory thought about forcing WP_Theme, wp_get_themes(), and wp_get_theme() to only be used in the admin, and force the includes/admin.php bootstrap to load for the very few situations where we'll need it (update checks, switch_theme(), the new customizer, and deprecated compat).
I am going to do some profiling to see how bad the fread is. We already do plenty of file_exists checks as part of the template loader, so one or two more of those are not the end of the world.
Change History (8)
get_current_theme() still seems to be used in a few places in Core.
wp_get_theme() is mighty fast. Took 0.20% of processing time after adding it to the footer of Twenty Eleven as a test. get_current_theme() hitting get_option('current_theme') was five times faster, but this is a very safe trade-off for everything else we're getting in return.

In [20033]: