Make WordPress Core

Opened 6 years ago

Last modified 6 years ago

#20138 closed defect (bug)

What happens to get_current_theme()? — at Initial Version

Reported by: nacin Owned by:
Milestone: 3.4 Priority: normal
Severity: normal Version:
Component: Themes Keywords:
Focuses: Cc:


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:

  1. 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.
  2. 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 (0)

Note: See TracTickets for help on using tickets.