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::extract_paths_to_translate() WordPress Method
The WP_Theme_JSON_Resolver::extract_paths_to_translate() method is used to retrieve an array of all paths that need to be translated for a given theme. The paths are returned as an associative array, with the keys being the path names and the values being the translation strings.
WP_Theme_JSON_Resolver::extract_paths_to_translate( array $i18n_partial, array $current_path = array() ) #
Converts a tree as in i18n-theme.json into a linear array containing metadata to translate a theme.json file.
Description
For example, given this input:
{
"settings": {
"*": {
"typography": {
"fontSizes": [ { "name": "Font size name" } ],
"fontStyles": [ { "name": "Font size name" } ]
}
}
}
}
will return this output:
[
0 => [
'path' => [ 'settings', '*', 'typography', 'fontSizes' ],
'key' => 'name',
'context' => 'Font size name'
],
1 => [
'path' => [ 'settings', '*', 'typography', 'fontStyles' ],
'key' => 'name',
'context' => 'Font style name'
]
]
Parameters
- $i18n_partial
(array)(Required)A tree that follows the format of i18n-theme.json.
- $current_path
(array)(Optional) Keeps track of the path as we walk down the given tree.
Default value: array()
Return
(array) A linear array containing the paths to translate.
Source
File: wp-includes/class-wp-theme-json-resolver.php
static::$i18n_schema = null === $i18n_schema ? array() : $i18n_schema; } return translate_settings_using_i18n_schema( static::$i18n_schema, $theme_json, $domain ); } /** * Returns core's origin config. * * @since 5.8.0 * * @return WP_Theme_JSON Entity that holds core data. */ public static function get_core_data() { if ( null !== static::$core ) { return static::$core; } $config = static::read_json_file( __DIR__ . '/theme.json' ); $config = static::translate( $config );
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |