WP_REST_Themes_Controller::prepare_theme_support( mixed $support, array $args, string $feature, WP_REST_Request $request ): mixed

In this article

Prepares the theme support value for inclusion in the REST API response.

Parameters

$supportmixedrequired
The raw value from get_theme_support() .
More Arguments from get_theme_support( … $args )Optional extra arguments to be checked against certain features.
$argsarrayrequired
The feature’s registration args.
$featurestringrequired
The feature name.
$requestWP_REST_Requestrequired
The request object.

Return

mixed The prepared support value.

Source

protected function prepare_theme_support( $support, $args, $feature, $request ) {
	$schema = $args['show_in_rest']['schema'];

	if ( 'boolean' === $schema['type'] ) {
		return true;
	}

	if ( is_array( $support ) && ! $args['variadic'] ) {
		$support = $support[0];
	}

	return rest_sanitize_value_from_schema( $support, $schema );
}

Changelog

VersionDescription
5.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.