API / Minn\Runtime / ThemeSupports

ThemeSupports final class

Minn\Runtime\ThemeSupports · public/minn/src/Minn/Runtime/ThemeSupports.php · 183 lines

What a theme supports, as add_theme_support keeps it (probe rest-themes): a bare feature is true, anything else its arguments. html5 lists add up (repeats and all), post thumbnails stay on for every type once on, post formats keep only real formats, the custom logo fills in its defaults at once (flexible both ways when asked for bare), and the custom header and background get theirs as WordPress finishes loading, a header with no width or height made flexible that way. title-tag declared after loading is refused. A block theme supports thumbnails, responsive embeds, editor styles, HTML5 markup and feed links before its own setup runs.

The features themselves (data/theme-features.json, and any a theme registers) say how each is shown in REST: its schema, or the default when the theme does not support it.

Constants and properties

privateKEY = 'theme_supports'
privateFEATURES = 'theme_features'
privateLOGO = array ( 'width' => NULL, 'height' => NULL, 'flex-width' => false, 'flex-height' => false, 'header-text' => '', 'unlink-homepage-logo' => false, )
privateHEADER = array ( 'default-image' => '', 'random-default' => false, 'width' => 0, 'height' => 0, 'flex-height' => false, 'flex-width' => false, 'default-text-color' => '', 'header-text' => true, 'uploads' => true, 'wp-head-callback' => '', 'admin-head-callback' => '', 'admin-preview-callback' => '', 'video' => false, 'video-active-callback' => 'is_front_page', )
privateBACKGROUND = array ( 'default-image' => '', 'default-preset' => 'default', 'default-position-x' => 'left', 'default-position-y' => 'top', 'default-size' => 'auto', 'default-repeat' => 'repeat', 'default-attachment' => 'scroll', 'default-color' => '', 'wp-head-callback' => '_custom_background_cb', 'admin-head-callback' => '', 'admin-preview-callback' => '', )
privateFORMATS = array ( 0 => 'aside', 1 => 'chat', 2 => 'gallery', 3 => 'link', 4 => 'image', 5 => 'quote', 6 => 'status', 7 => 'video', 8 => 'audio', )
privateTYPES = array ( 0 => 'boolean', 1 => 'integer', 2 => 'number', 3 => 'string', 4 => 'array', 5 => 'object', )

Public

staticall(): array#

Every feature the theme has declared, as stored. @return array<string, mixed>

@return array<string, mixed>
staticadd(string $feature, array $args): bool#

add_theme_support: false when refused. @param list<mixed> $args

$argslist<mixed>
staticremove(string $feature): bool#

remove_theme_support: false when the theme did not support it.

staticblockThemeDefaults(): void#

_add_default_theme_supports: what every block theme supports before its own setup.

staticeditorDefaults(string $which): void#

wp_enable_block_templates and wp_setup_widgets_block_editor: a block theme's templates, and the block widget editor for any theme.

staticjustInTime(): void#

_custom_header_background_just_in_time: the header's and background's defaults filled in once loaded.

staticregister(string $feature, array $args): WP_Error|true#

register_theme_feature: true, or why the feature cannot be registered.

staticfeatures(): array#

Core's features, then those registered since. @return array<string, array<string, mixed>>

@return array<string, array<string, mixed>>
staticforRest(WP_REST_Request $request): array#

The active theme's supports as wp/v2/themes shows them: each feature shown in REST, shaped by its schema. @return array<string, mixed>

@return array<string, mixed>
staticprepared(mixed $support, array $config, string $feature, WP_REST_Request $request): mixed#

One feature's support as the REST API shows it (the runtime's WP_REST_Themes_Controller::prepare_theme_support): a feature that is not variadic shown by its first value, through its prepare_callback or else cut to its schema.

$configarray<string, mixed>the feature as it was registered

Internals 1

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privateunwrapped(mixed $support, array $config): mixed#
$configarray<string, mixed>