[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> class-wp-theme-json-resolver.php (summary)

WP_Theme_JSON_Resolver class

File Size: 236 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_Theme_JSON_Resolver:: (9 methods):
  read_json_file()
  get_fields_to_translate()
  translate()
  get_core_data()
  get_theme_data()
  get_merged_data()
  theme_has_support()
  get_file_path_from_theme()
  clean_cached_data()


Class: WP_Theme_JSON_Resolver  - X-Ref

Class that abstracts the processing of the different data sources
for site-level config and offers an API to work with them.

read_json_file( $file_path )   X-Ref
Processes a file that adheres to the theme.json schema
and returns an array with its contents, or a void array if none found.

param: string $file_path Path to file. Empty if no file.
return: array Contents that adhere to the theme.json schema.
since: 5.8.0

get_fields_to_translate()   X-Ref
Returns a data structure used in theme.json translation.

return: array An array of theme.json fields that are translatable and the keys that are translatable.
since: 5.8.0

translate( $theme_json, $domain = 'default' )   X-Ref
Given a theme.json structure modifies it in place to update certain values
by its translated strings according to the language set by the user.

param: array  $theme_json The theme.json to translate.
param: string $domain     Optional. Text domain. Unique identifier for retrieving translated strings.
return: array Returns the modified $theme_json_structure.
since: 5.8.0

get_core_data()   X-Ref
Return core's origin config.

return: WP_Theme_JSON Entity that holds core data.
since: 5.8.0

get_theme_data( $theme_support_data = array()   X-Ref
Returns the theme's data.

Data from theme.json can be augmented via the $theme_support_data variable.
This is useful, for example, to backfill the gaps in theme.json that a theme
has declared via add_theme_supports.

Note that if the same data is present in theme.json and in $theme_support_data,
the theme.json's is not overwritten.

param: array $theme_support_data Optional. Theme support data in theme.json format.
return: WP_Theme_JSON Entity that holds theme data.
since: 5.8.0

get_merged_data( $settings = array()   X-Ref
There are different sources of data for a site: core and theme.

While the getters {@link get_core_data}, {@link get_theme_data} return the raw data
from the respective origins, this method merges them all together.

If the same piece of data is declared in different origins (core and theme),
the last origin overrides the previous. For example, if core disables custom colors
but a theme enables them, the theme config wins.

param: array $settings Optional. Existing block editor settings. Default empty array.
return: WP_Theme_JSON
since: 5.8.0

theme_has_support()   X-Ref
Whether the current theme has a theme.json file.

return: bool
since: 5.8.0

get_file_path_from_theme( $file_name )   X-Ref
Builds the path to the given file and checks that it is readable.

If it isn't, returns an empty string, otherwise returns the whole file path.

param: string $file_name Name of the file.
return: string The whole file path or empty if the file doesn't exist.
since: 5.8.0

clean_cached_data()   X-Ref
Cleans the cached data so it can be recalculated.

since: 5.8.0



Generated: Sat Oct 16 01:00:03 2021 Cross-referenced by PHPXref 0.7.1