WP_REST_Themes_Controller::prepare_theme_support() WordPress Method

The prepare_theme_support() method is used to add theme support for various features to a child theme. This is done by calling add_theme_support() for each feature. The supported features are 'title-tag', 'custom-logo', 'post-formats', 'html5', and 'starter-content'.

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

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


Parameters

$support

(mixed)(Required)The raw value from get_theme_support().

$args

(array)(Required)The feature's registration args.

$feature

(string)(Required)The feature name.

$request

(WP_REST_Request)(Required)The request object.


Top ↑

Return

(mixed) The prepared support value.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php

	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 );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.