WP_Theme_JSON_Resolver
- Source
wp-includes/class-wp-theme-json-resolver.php:20
Class that abstracts the processing of the different data sources for site-level config and offers an API to work with them.
Description
This class is for internal core usage and is not supposed to be used by extenders (plugins and/or themes).
This is a low-level API that may need to do breaking changes. Please, use get_global_settings(), get_global_styles(), and get_global_stylesheet() instead.
Compatibility
- WordPress
- core
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 5
Every hook that fires from inside WP_Theme_JSON_Resolver, in the order it appears in the class, grouped by the method that fires it.
WP_Theme_JSON_Resolver::get_user_data()
- apply_filters( wp_theme_json_data_user )filter line 564
- apply_filters( wp_theme_json_data_user )filter line 593
Properties · 8
$blocks_cachearrayprotected static- Container for keep track of registered blocks.
$coreWP_Theme_JSONprotected static- Container for data coming from core.
$blocksWP_Theme_JSONprotected static- Container for data coming from the blocks.
$themeWP_Theme_JSONprotected static- Container for data coming from the theme.
$userWP_Theme_JSONprotected static- Container for data coming from the user.
$user_custom_post_type_idintprotected static- Stores the ID of the custom post type that holds the user data.
$i18n_schemaarrayprotected static- Container to keep loaded i18n schema for
theme.json. $theme_json_file_cachearrayprotected statictheme.jsonfile cache.
Methods · 22
- read_json_file()Processes a file that adheres to the theme.json schema and returns an array with its contents, or a void array if none found.
- get_fields_to_translate()Returns a data structure used in theme.json translation.
- translate()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.
- get_core_data()Returns core's origin config.
- has_same_registered_blocks()Checks whether the registered blocks were already processed for this origin.
- get_theme_data()Returns the theme's data.
- get_block_data()Gets the styles for blocks from the block.json file.
- remove_json_comments()When given an array, this will remove any keys with the name `//`.
- get_user_data_from_wp_global_styles()Returns the custom post type that contains the user's origin config for the active theme or an empty array if none are found.
- get_user_data()Returns the user's origin config.
- get_merged_data()Returns the data merged from multiple origins.
- get_user_global_styles_post_id()Returns the ID of the custom post type that stores user data.
- theme_has_support()Determines whether the active theme has a theme.json file.
- get_file_path_from_theme()Builds the path to the given file and checks that it is readable.
- clean_cached_data()Cleans the cached data so it can be recalculated.
- recursively_iterate_json()Returns an array of all nested JSON files within a given directory.
- style_variation_has_scope()Determines if a supplied style variation matches the provided scope.
- get_style_variations()Returns the style variations defined by the theme.
- get_resolved_theme_uris()Resolves relative paths in theme.json styles to theme absolute paths and returns them in an array that can be embedded as the value of `_link` object in REST API responses.
- resolve_theme_file_uris()Resolves relative paths in theme.json styles to theme absolute paths and merges them with incoming theme JSON.
- inject_variations_from_block_style_variation_files()Adds variations sourced from block style variations files to the supplied theme.json data.
- inject_variations_from_block_styles_registry()Adds variations sourced from the block styles registry to the supplied theme.json data.
Source code
#[AllowDynamicProperties]class WP_Theme_JSON_Resolver { /** * Container for keep track of registered blocks. * * @since 6.1.0 * @var array */ protected static $blocks_cache = array( 'core' => array(), 'blocks' => array(), 'theme' => array(), 'user' => array(), ); /** * Container for data coming from core. * * @since 5.8.0 * @var WP_Theme_JSON */ protected static $core = null; /** * Container for data coming from the blocks. * * @since 6.1.0 * @var WP_Theme_JSON */ protected static $blocks = null; /** * Container for data coming from the theme. * * @since 5.8.0 * @var WP_Theme_JSON */ protected static $theme = null; /** * Container for data coming from the user. * * @since 5.9.0 * @var WP_Theme_JSON */ protected static $user = null; /** * Stores the ID of the custom post type * that holds the user data. * * @since 5.9.0 * @var int */ protected static $user_custom_post_type_id = null; /** * Container to keep loaded i18n schema for `theme.json`. * * @since 5.8.0 As `$theme_json_i18n`. * @since 5.9.0 Renamed from `$theme_json_i18n` to `$i18n_schema`. * @var array */ protected static $i18n_schema = null; /** * `theme.json` file cache. * * @since 6.1.0 * @var array */ protected static $theme_json_file_cache = array(); /** * Processes a file that adheres to the theme.json schema * and returns an array with its contents, or a void array if none found. * * @since 5.8.0 * @since 6.1.0 Added caching.Changelog
Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/class-wp-theme-json-resolver.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.