WordPress.org

Make WordPress Core

Opened 7 weeks ago

Last modified 4 weeks ago

#49406 new enhancement

Introduce register_theme_support method

Reported by: kadamwhite Owned by:
Milestone: 5.5 Priority: normal
Severity: normal Version: 5.0
Component: Themes Keywords: needs-patch
Focuses: rest-api Cc:

Description (last modified by kadamwhite)

In #49037 support was added to list support for core theme features in the /themes endpoint. This patch was fairly conservative and manually safelisted specific theme supports by manually enumerating their expected schema in the controller.

Custom theme support values introduced by non-core plugins are not yet supported due to the lack of a safe way to validate the shape and content of their associated values. Several major plugins like WooCommerce and jetpack do implement their own theme-support features. While we can theoretically write out the schema for all high-profile plugins manually, this approach is both inequitable (what is "high-profile?") and would be unsustainably difficult to maintain.

The way that we're able to surface metadata to the API is by explicitly registering it using register_post_meta (and related functions). In #49037 therefore, @spacedmonkey proposed introducing a new register_theme_support method which core & third-party themes can use to describe the details of their features. This method could be used by plugins to describe the theme features they introduce, and the values used in that registration could then be used to safely populate theme support details in this endpoint.

Discussed in Slack on 2020-02-11

Change History (4)

#1 @kadamwhite
7 weeks ago

  • Description modified (diff)

#2 @georgestephanis
7 weeks ago

So to confirm on this, functionality would be similar to scripts / styles -- in that just because the theme support is /registered/ it isn't flagged on. Registering is just describing it.

I'd also suggest that we make sure theme support can be added before it's registered -- so that a late register doesn't break legacy declarations of adding it.

#3 @dshanske
7 weeks ago

Suggest, to figure out how to describe custom theme support properties, we ask for someone to provide a list of the custom ones the plugins are using and what they represent.

At the least, Jetpack and Woocommerce as represented in the ticket. Also, what properties do the built in ones have?

#4 @TimothyBlynJacobs
4 weeks ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 5.5
  • Version changed from trunk to 5.0
Note: See TracTickets for help on using tickets.