WordPress.org

Make WordPress Core

Opened 4 months ago

Last modified 8 weeks ago

#26516 new enhancement

Make it easier to check theme support

Reported by: obenland Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 2.9
Component: Themes Keywords: has-patch dev-feedback
Focuses: Cc:

Description (last modified by obenland)

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)

26516.diff (5.3 KB) - added by obenland 4 months ago.
26516.2.diff (7.1 KB) - added by obenland 4 months ago.
Adds some documentation and makes sure current_theme_supports() always returns a boolean.
26516.3.diff (7.4 KB) - added by DH-Shredder 8 weeks ago.
Refreshed.

Download all attachments as: .zip

Change History (7)

obenland4 months ago

comment:1 obenland4 months ago

Attached patch merges the array with the array of information, with the array of information. The result would look like this:

<?php
// 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)
Last edited 4 months ago by obenland (previous) (diff)

obenland4 months ago

Adds some documentation and makes sure current_theme_supports() always returns a boolean.

comment:2 obenland4 months ago

  • Description modified (diff)

DH-Shredder8 weeks ago

Refreshed.

comment:3 ircbot8 weeks ago

This ticket was mentioned in IRC in #wordpress-dev by DH-Shredder. View the logs.

comment:4 DH-Shredder8 weeks 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.

Note: See TracTickets for help on using tickets.