wppaste
WordPress

WP_Theme_JSON

Source
wp-includes/class-wp-theme-json.php:19
Class that encapsulates the processing of structures that adhere to the theme.json spec.

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 · 1

Every hook that fires from inside WP_Theme_JSON, in the order it appears in the class, grouped by the method that fires it.

Properties · 2

$theme_jsonarrayprotected
Container of data in theme.json format.
$blocks_metadataarrayprotected static
Holds block metadata extracted from block.json to be shared among all instances so we don't process it twice.

Methods · 70

Source code

#[AllowDynamicProperties]class WP_Theme_JSON { 	/**	 * Container of data in theme.json format.	 *	 * @since 5.8.0	 * @var array	 */	protected $theme_json = null; 	/**	 * Holds block metadata extracted from block.json	 * to be shared among all instances so we don't	 * process it twice.	 *	 * @since 5.8.0	 * @since 6.1.0 Initialize as an empty array.	 * @var array	 */	protected static $blocks_metadata = array(); 	/**	 * The CSS selector for the top-level preset settings.	 *	 * @since 6.6.0	 * @var string	 */	const ROOT_CSS_PROPERTIES_SELECTOR = ':root'; 	/**	 * The CSS selector for the top-level styles.	 *	 * @since 5.8.0	 * @var string	 */	const ROOT_BLOCK_SELECTOR = 'body'; 	/**	 * The sources of data this object can represent.	 *	 * @since 5.8.0	 * @since 6.1.0 Added 'blocks'.	 * @var string[]	 */	const VALID_ORIGINS = array(		'default',		'blocks',		'theme',		'custom',	); 	/**	 * Presets are a set of values that serve	 * to bootstrap some styles: colors, font sizes, etc.	 *	 * They are a unkeyed array of values such as:	 *	 *     array(	 *       array(	 *         'slug'      => 'unique-name-within-the-set',	 *         'name'      => 'Name for the UI',	 *         <value_key> => 'value'	 *       ),	 *     )	 *	 * This contains the necessary metadata to process them:	 *	 * - path             => Where to find the preset within the settings section.	 * - prevent_override => Disables override of default presets by theme presets.	 *                       The relationship between whether to override the defaults	 *                       and whether the defaults are enabled is inverse:	 *                         - If defaults are enabled  => theme presets should not be overridden	 *                         - If defaults are disabled => theme presets should be overridden	 *                       For example, a theme sets defaultPalette to false,	 *                       making the default palette hidden from the user.	 *                       In that case, we want all the theme presets to be present,	 *                       so they should override the defaults by setting this false.	 * - use_default_names => whether to use the default names	 * - value_key        => the key that represents the value

Changelog

14 changes between 6.7.7 and 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

7.1.0
Method get_viewport_media_queries() added.verified against source
7.1.0
Method is_valid_viewport_breakpoint_size() added.verified against source
7.1.0
Method get_viewport_breakpoint_value_in_pixels() added.verified against source
7.1.0
Method sanitize_viewport_settings() added.verified against source
7.1.0
Method split_selector_list() added.verified against source
7.1.0
Method get_feature_selector() added.verified against source
7.1.0
Method update_button_width_declarations() added.verified against source
7.1.0
Method get_block_style_variation_feature_selector() added.verified against source
7.1.0
Method get_block_name_from_metadata_path() added.verified against source
7.0.4
Method process_pseudo_selectors() added.verified against source
7.0.4
Method update_paragraph_text_indent_selector() added.verified against source
7.0.4
Method preserve_valid_typed_settings() added.verified against source
6.8.8
Method remove_insecure_element_styles() added.verified against source
6.8.8
Method remove_insecure_inner_block_styles() added.verified against source

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-includes/class-wp-theme-json.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.