Make core in charge of front end output

Context

I’ve seen this a lot, but most recently in the TinyMCE code, where the theme is in charge of outputting whatever the end user sees. Switching themes can be painful because some themes add functionality or styling that ties the content to it.
There are conventions that the theme "must call wp_head() and wp_footer()" or some things won’t work.
I think the theme should be more limited.

Possible implementation

There could be a filter for the type of output, that defaults to HTML. The core code would have the skeleton to output, filtering the attributes of <html> and <body>, and firing actions for each section like we already have for wp_head and wp_footer, but add wp_body_open where the template loader would be. That means template files would not include anything but body content. The filter for the attributes would be a core function to be used for all major content areas, or have a core function that the theme calls to get output filtered. (needs design)

Will you be able to help with the implementation?

Yes, I have already written a way this could work, and use the attribute filter function in my theme (which has been working for 3 years).

Could this be done as a new add_theme_support flag that themes opt in to? That would eliminate the need to ship this in a new major version since it would be a new optional feature as opposed to a change in the default behavior.

Yes, I think so. I was thinking that yesterday actually.

2 Likes

Title changed from “V2 or v3… make core in charge of front end output” to “Make core in charge of front end output” according to petition title guidelines.