API / Minn\Runtime / ThemeSupports

ThemeSupports final class

Minn\Runtime\ThemeSupports · public/minn/src/Minn/Runtime/ThemeSupports.php · 263 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

staticget(mixed $feature, mixed ...$args): mixed#

A feature's support (get_theme_support): false when the theme has none; with an argument, that part of it (one of a list, or a key's value).

staticcurrent(mixed $feature, mixed ...$args): mixed#

Whether the theme supports a feature (current_theme_supports): for the features with parts, the part asked; otherwise current_theme_supports-{feature} has the last word.

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.

staticclassicEditorSettings(): array#

get_classic_theme_supports_block_editor_settings: the editor settings a classic theme's supports amount to, the custom-value switches, and its palette, sizes and gradients when it declares them.

@return array<string, mixed>
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): Minn\Objects\Errors|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(Minn\Objects\RestRequest $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, Minn\Objects\RestRequest $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 2

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

privatewithConstants(string $feature, array $args): array#

The custom header's and background's arguments and their old constants, as the reference keeps them in step (themes from before the arguments read the constants, Twenty Eleven's header among them): a constant a theme defined first sets its argument, and an argument the theme passed defines its constant, empty or not (header-text as NO_HEADER_TEXT, turned around).

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