[wp-trac] [WordPress Trac] #27278: More sanity for add_theme_support( 'html5' )
WordPress Trac
noreply at wordpress.org
Wed Mar 5 13:52:12 UTC 2014
#27278: More sanity for add_theme_support( 'html5' )
-------------------------+-----------------------------
Reporter: jond3r | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version: trunk
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
In #26697 was introduced support for HTML5 markup in image galleries. To
enable this you would have to write:
{{{ add_theme_support( 'html5', array( 'gallery' ) ); }}}
Previously there were just three so-called 'types' of HTML5 support in
core: 'comment-list', 'comment-form', 'search-form'.
So now there is one more: 'gallery'!
This has pinpointed a weakness (or asymmetry if you like) in the current
API for theme support. Though discouraged (ticket:26697#comment:12), it is
currently possible and legitimate to use:
{{{ add_theme_support( 'html5' ); }}}
which adds support for the three types 'comment-list', 'comment-form' and
'search-form', but not the new type 'gallery'!
Thus, as the code stands today 'gallery' is treated as a second-class
citizen, which it does not deserve!
Another manifestation of the current asymmetry of the API is that
{{{remove_theme_support( 'html5' )}}} removes all previously added types,
but {{{add_theme_support( 'html5' )}}} only adds back three of them.
To add some sanity back to the theme support API, three possible roads are
outlined:
1. Keep the current code as is, for preserved backwards compatibility, but
add some comment to the code and an additional assertion for clarity to
the theme-support test. This is provided in the attached patch no. 1.
2. Add 'gallery' to the default list of types for preserved symmetry but
broken back-compat, with some additional test assertion. This is patch no.
2.
3. Remove the possibility to use {{{add_theme_support( 'html5' )}}}
altogether, which breaks back-compat this time, but is future proof as
other types are added. It also restores symmetry of the API, albeit in
another form. Adjust the unit tests accordingly. This is patch no. 3.
I do not have very strong feelings about which road is better. No. 1 is
safest, but does not provide much improvement. Patch no. 2 was rejected in
ticket:26697#comment:12, and will realistically not be accepted as it is
not future proof and breaks back-compat in a silent way: gallery styling
might stop working for themes or plugins using {{{add_theme_support(
'html5' )}}}. Patch no. 3 is 100% future-proof, but usage of
{{{add_theme_support( 'html5' )}}} will trigger a doing-it-wrong error. It
is somewhat 'boring' though, as something is taken away, and a longer api-
call must be made to achieve the same thing as before.
Much of the current behavior was added in #24932.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27278>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list