WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Theme_JSON_Resolver::extract_paths_to_translate() private WP 5.8.0

Converts a tree as in i18n-theme.json into a linear array containing metadata to translate a theme.json file.

Ищем WP-разработчика! Фулл-тайм, удаленка, хорошая зарплата, соц. пакет. Подробности.
Компания Boosta.

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'
  ]
]

{} Это метод класса: WP_Theme_JSON_Resolver{}

Хуков нет.

Возвращает

Массив. A linear array containing the paths to translate.

Использование

$result = WP_Theme_JSON_Resolver::extract_paths_to_translate( $i18n_partial, $current_path );
$i18n_partial(массив) (обязательный)
A tree that follows the format of i18n-theme.json.
$current_path(массив)
Keeps track of the path as we walk down the given tree.
По умолчанию: empty array

Список изменений

С версии 5.8.0 Введена.

Код WP_Theme_JSON_Resolver::extract_paths_to_translate() WP 5.8.2

private static function extract_paths_to_translate( $i18n_partial, $current_path = array() ) {
	$result = array();
	foreach ( $i18n_partial as $property => $partial_child ) {
		if ( is_numeric( $property ) ) {
			foreach ( $partial_child as $key => $context ) {
				$result[] = array(
					'path'    => $current_path,
					'key'     => $key,
					'context' => $context,
				);
			}
			return $result;
		}
		$result = array_merge(
			$result,
			self::extract_paths_to_translate( $partial_child, array_merge( $current_path, array( $property ) ) )
		);
	}
	return $result;
}