Make WordPress Core

Opened 2 years ago

Last modified 2 months ago

#26516 assigned enhancement

Make it easier to check theme support

Reported by: obenland Owned by: obenland
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:

$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 2 years ago.
26516.2.diff (7.1 KB) - added by obenland 2 years ago.
Adds some documentation and makes sure current_theme_supports() always returns a boolean.
26516.3.diff (7.4 KB) - added by DH-Shredder 22 months ago.

Download all attachments as: .zip

Change History (8)

2 years ago

#1 @obenland
2 years ago

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)
Last edited 2 years ago by obenland (previous) (diff)

2 years ago

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

#2 @obenland
2 years ago

  • Description modified (diff)

22 months ago


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

22 months ago

#4 @DH-Shredder
22 months 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.

#5 @wonderboymusic
2 months ago

  • Owner set to obenland
  • Status changed from new to assigned
Note: See TracTickets for help on using tickets.