Opened 11 years ago
Closed 11 years ago
#24932 closed defect (bug) (fixed)
HTML5 support for specific features doesn't work.
Reported by: | nathanrice | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.6.1 | Priority: | normal |
Severity: | normal | Version: | 3.6 |
Component: | Themes | Keywords: | has-patch commit fixed-major needs-codex |
Focuses: | Cc: |
Description (last modified by )
The check for the second parameter in current_theme_supports()
in [24417] is irrelevant.
Unit test here:
https://gist.github.com/nathanrice/6143003
There is no exception in the switch statement for html5 support, so the function just returns true (early) if html5
is supported at all. The second parameter is essentially ignored.
So, if you intend to turn on html5 output for just 1 of the 3 options, it doesn't matter. All 3 will output in html5.
Which is, perhaps, intentional. I'm really not sure.
If not, I'm prepping a patch to correct it.
Attachments (4)
Change History (22)
#4
@
11 years ago
24932.diff makes two functionality changes:
- Calling
add_theme_support( 'html5', array( 'comments-list' ) ); add_theme_support( 'html5', array( 'comment-form' ) );
should merge. If a theme wants to replace, they need to do aremove_theme_support( 'html5' )
first. This is a change in behavior that we can really only get away with now, in 3.6.1. Reasoning is the mess that is #22080.
add_theme_support( 'html5' )
(no arguments) no longer works. This was never supposed to work, as it would prevent us from adding future types in the future.current_theme_supports( 'html5' )
, however, does continue to work, and will returntrue
if *any* feature is supported. This might help a plugin author decide what markup to serve, but core should never check for this.
In both cases, this is how the functionality was designed. It just wasn't implemented correctly.
Also adds some unit tests.
#7
@
11 years ago
- Enables the existing three types if no second argument was passed (per the IRC discussion).
- Adds a
_doing_it_wrong()
notice for an empty or non-array argument. - Updates the tests and fixes a few typos in [25193].
#8
@
11 years ago
Alas, I'm fine with 24932.2.diff. I've updated it with more tests, see 24932.3.diff. It now tests that A) a non-array is invalid, and B) passing nothing gives you all three existing types and nothing wrong.
Also updated the _doing_it_wrong()
to reflect 3.6.1 and added some context for the first parameter there. Agree with not translating the string for 3.6.x.
#9
follow-up:
↓ 11
@
11 years ago
If I could, I'd like to formally request that this NOT return false if no array of types gets passed.
Short story, this will break Genesis child themes, which we can't push updates to address.
In Genesis, we only define HTML5 as being on or off. We have no need to specify types, since if html5 theme support is added, we don't want anything outputting in any other format except for html5.
I understand the "intended" behavior from the core perspective, but it's silly to assume that the following would somehow return false.
add_theme_support( 'html5' ); return current_theme_supports( 'html5' ); // false?
I'm not trying to pull special privilege here or anything ... but I can't stress enough how a 3.6.1 update that includes this short circuit will immediately and catastrophically damage the look of sites running Genesis 2.0 and a child theme that supports HTML5.
#10
@
11 years ago
Good grief, nevermind. I see in 24932.3.diff that you haven't let it return false if no types array is passed. My mistake.
Obviously, we'll still get a warning, and we'll have to deal with that at some point, but at least it's not going to bork a site.
Might I still recommend that JUST enabling theme support for html5 with no types array isn't necessarily doing it wrong? It's more like a universal "html5 everything" directive.
#11
in reply to:
↑ 9
@
11 years ago
Replying to nathanrice:
Might I still recommend that JUST enabling theme support for html5 with no types array isn't necessarily doing it wrong? It's more like a universal "html5 everything" directive.
So, this is to prepare you for the fact that if/when we add additional values (there are more template tags that could probably get this treatment?), you won't actually opt-in by specifying only html5
. The problem here is if we add a future type, we might completely break a site and/or its CSS by pulling the rug out. That's why it was meant to be explicit. I don't want to hamstring us from future changes. As you said, overhauling markup suddenly could "catastrophically damage the look of sites".
#12
follow-up:
↓ 14
@
11 years ago
We also possibly don't need to add the _doing_it_wrong() until we actually add new markup somewhere, or at least confirm there is new markup to be added somewhere, but we have a lot of template tags and I'm sure there will be something.
Quick search finds some could-use-some-modernization markup in wp_login_form() (and eventually, #17948), maybe get_calendar(), some page menu / page links / nav menus stuff (and other walkers), term/cat/tag lists and such, using dropdowns as jump fields in widgets, maybe some other default widgets. The point is, let's make sure themes are explicit now, for forwards compatibility purposes.
#14
in reply to:
↑ 12
@
11 years ago
Replying to nacin:
We also possibly don't need to add the _doing_it_wrong() until we actually add new markup somewhere
I tend to agree.
#15
@
11 years ago
- Keywords needs-codex added
We should update Codex to clarify that passing an array of types is recommended.
The list of pages where add_theme_support( 'html5' )
is mentioned:
Going to remove the whitespace changes from a commit to 3.6.1. Looks good, thanks.