Add return filter to current_theme_supports()
|Reported by:||DJPaul||Owned by:|
current_theme_supports() makes it hard for plugins to affect whether a theme supports a certain feature.
The use case I have is that I am building a plugin that utilises bbPress (and soon, BuddyPress)-style template compatibility parts. In those template parts, I display something very, very similar to a post thumbnail or custom header. I want to use the "Featured Image" metabox on the Post screen to set that image.
If I use the plugin on a theme that doesn't support post thumbnails, the metabox correctly doesn't appear, and so users have no way of choosing a featured image. While there are ways around this -- manual conditional registering of the Featured Image metabox, creating my own metabox, or calling add_theme_support/remove_theme_support like a toggle -- none of them are particularly elegant.
While current_theme_supports has a return filter, it's not reached by all code execution paths. The attached patch reworks the function so that the return value is always passed through the filter.