Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

WP_Theme_JSON_Resolver::translate_theme_json_chunk() WordPress Method

The WP_Theme_JSON_Resolver::translate_theme_json_chunk() method is used to translate a theme JSON string into a WordPress theme. The method accepts two arguments: the JSON string to be translated and the theme slug. The JSON string is first decoded and then passed through the WordPress translation functions. The translated string is then returned.

WP_Theme_JSON_Resolver::translate_theme_json_chunk( array $array_to_translate, string $key, string $context, string $domain ) #

Translates a chunk of the loaded theme.json structure.


Parameters

$array_to_translate

(array)(Required)The chunk of theme.json to translate.

$key

(string)(Required)The key of the field that contains the string to translate.

$context

(string)(Required)The context to apply in the translation call.

$domain

(string)(Required)Text domain. Unique identifier for retrieving translated strings.


Top ↑

Return

(array) Returns the modified $theme_json chunk.


Top ↑

Source

File: wp-includes/class-wp-theme-json-resolver.php

			_deprecated_argument( __METHOD__, '5.9.0' );
		}

		$options = wp_parse_args( $options, array( 'with_supports' => true ) );

		if ( null === static::$theme ) {
			$theme_json_data = static::read_json_file( static::get_file_path_from_theme( 'theme.json' ) );
			$theme_json_data = static::translate( $theme_json_data, wp_get_theme()->get( 'TextDomain' ) );
			static::$theme   = new WP_Theme_JSON( $theme_json_data );

			if ( wp_get_theme()->parent() ) {
				// Get parent theme.json.

Top ↑

Changelog

Changelog
VersionDescription
5.8.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.