Opened 11 years ago
Last modified 5 years ago
#26516 assigned enhancement
Make it easier to check theme support
Reported by: | obenland | Owned by: | obenland |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.9 |
Component: | Themes | Keywords: | has-patch dev-feedback |
Focuses: | Cc: |
Description (last modified by )
Currently we don't make it too easy for plugins (and themes I suppose) to get access to the information passed in the second argument to add_theme_support()
.
To get more information about a theme's support for post thumbnails for example, a plugin would have to assign the return value of get_theme_support()
to a variable and then access the value stored in the first key of the returned array:
<?php $support = get_theme_support( 'post-thumbnails' ); $actual_support = $support[0];
While this is not ideal for core features that themes need to register support for, it gets painful quickly when themes and plugins want to deal with information coupled to a custom feature.
Attachments (3)
Change History (8)
#1
@
11 years ago
@
11 years ago
Adds some documentation and makes sure current_theme_supports()
always returns a boolean.
This ticket was mentioned in IRC in #wordpress-dev by DH-Shredder. View the logs.
11 years ago
#4
@
11 years ago
- Milestone changed from Awaiting Review to Future Release
Hi obenland!
I'm sorry it took so long for you to get a reply!
I've refreshed the patch so that it applies cleanly on trunk, and tested it. It appears to work as advertised.
The duplication of returned information seems a little strange, but back-compat often is.
@nacin noted in the chat linked above that a whitelist for support may be appropriate.
Attached patch merges the array with the array of information, with the array of information. The result would look like this:
// get_theme_support('html5'); array (size=4) 0 => array (size=3) 0 => string 'search-form' (length=11) 1 => string 'comment-form' (length=12) 2 => string 'comment-list' (length=12) 1 => string 'search-form' (length=11) 2 => string 'comment-form' (length=12) 3 => string 'comment-list' (length=12)