Make WordPress Core

Opened 11 years ago

Last modified 5 years ago

#26516 assigned enhancement

Make it easier to check theme support

Reported by: obenland's profile obenland Owned by: obenland's profile obenland
Milestone: 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 11 years ago.
26516.2.diff (7.1 KB) - added by obenland 11 years ago.
Adds some documentation and makes sure current_theme_supports() always returns a boolean.
26516.3.diff (7.4 KB) - added by kirasong 11 years ago.
Refreshed.

Download all attachments as: .zip

Change History (8)

@obenland
11 years ago

#1 @obenland
11 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)
Version 0, edited 11 years ago by obenland (next)

@obenland
11 years ago

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

#2 @obenland
11 years ago

  • Description modified (diff)

@kirasong
11 years ago

Refreshed.

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


11 years ago

#4 @kirasong
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.

#5 @wonderboymusic
9 years ago

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