[ Index ] |
PHP Cross Reference of WordPress |
[Source view] [Print] [Project Stats]
WP_Theme_JSON_Resolver class
File Size: | 498 lines (16 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
WP_Theme_JSON_Resolver:: (13 methods):
read_json_file()
get_fields_to_translate()
translate()
get_core_data()
get_theme_data()
get_user_data_from_wp_global_styles()
get_user_data()
get_merged_data()
get_user_global_styles_post_id()
theme_has_support()
get_file_path_from_theme()
clean_cached_data()
get_style_variations()
Class: WP_Theme_JSON_Resolver - X-Ref
Class that abstracts the processing of the different data sourcesread_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. return: array Contents that adhere to the theme.json schema. param: string $file_path Path to file. Empty if no file. 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. return: array Returns the modified $theme_json_structure. param: array $theme_json The theme.json to translate. param: string $domain Optional. Text domain. Unique identifier for retrieving translated strings. since: 5.8.0 |
get_core_data() X-Ref |
Returns core's origin config. return: WP_Theme_JSON Entity that holds core data. since: 5.8.0 |
get_theme_data( $deprecated = array() X-Ref |
Returns the theme's data. Data from theme.json will be backfilled from existing theme supports, if any. Note that if the same data is present in theme.json and in theme supports, the theme.json takes precedence. return: WP_Theme_JSON Entity that holds theme data. param: array $deprecated Deprecated. Not used. param: array $options { since: 5.8.0 since: 5.9.0 Theme supports have been inlined and the `$theme_support_data` argument removed. since: 6.0.0 Added an `$options` parameter to allow the theme data to be returned without theme supports. |
get_user_data_from_wp_global_styles( $theme, $create_post = false, $post_status_filter = array( 'publish' ) X-Ref |
Returns the custom post type that contains the user's origin config for the active theme or a void array if none are found. This can also create and return a new draft custom post type. return: array Custom Post Type for the user's origin config. param: WP_Theme $theme The theme object. If empty, it param: bool $create_post Optional. Whether a new custom post param: array $post_status_filter Optional. Filter custom post type by since: 5.9.0 |
get_user_data() X-Ref |
Returns the user's origin config. return: WP_Theme_JSON Entity that holds styles for user data. since: 5.9.0 |
get_merged_data( $origin = 'custom' ) X-Ref |
Returns the data merged from multiple origins. There are three sources of data (origins) for a site: default, theme, and custom. The custom's has higher priority than the theme's, and the theme's higher than default's. Unlike the getters {@link https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/get_core_data/ get_core_data}, {@link https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/get_theme_data/ get_theme_data}, and {@link https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/get_user_data/ get_user_data}, this method returns data after it has been merged with the previous origins. This means that if the same piece of data is declared in different origins (user, theme, and core), the last origin overrides the previous. For example, if the user has set a background color for the paragraph block, and the theme has done it as well, the user preference wins. return: WP_Theme_JSON param: string $origin Optional. To what level should we merge data. since: 5.8.0 since: 5.9.0 Added user data, removed the `$settings` parameter, |
get_user_global_styles_post_id() X-Ref |
Returns the ID of the custom post type that stores user data. return: integer|null since: 5.9.0 |
theme_has_support() X-Ref |
Determines whether the active theme has a theme.json file. return: bool since: 5.8.0 since: 5.9.0 Added a check in the parent theme. |
get_file_path_from_theme( $file_name, $template = false ) 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. return: string The whole file path or empty if the file doesn't exist. param: string $file_name Name of the file. param: bool $template Optional. Use template theme directory. Default false. since: 5.8.0 since: 5.9.0 Adapted to work with child themes, added the `$template` argument. |
clean_cached_data() X-Ref |
Cleans the cached data so it can be recalculated. since: 5.8.0 since: 5.9.0 Added the `$user`, `$user_custom_post_type_id`, |
get_style_variations() X-Ref |
Returns the style variations defined by the theme. return: array since: 6.0.0 |
Generated: Thu Nov 21 01:00:03 2024 | Cross-referenced by PHPXref 0.7.1 |