Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
WP_Theme_JSON::get_merged_preset_by_slug() WordPress Method
The WP_Theme_JSON::get_merged_preset_by_slug() method allows you to retrieve a preset object by its slug. The slug is used to identify the preset within the database. This method is useful for getting a specific preset object when you know the slug. For example, if you want to get the preset with the slug "my-preset", you would use this method like so: $preset = WP_Theme_JSON::get_merged_preset_by_slug( 'my-preset' ); This would return the preset object for "my-preset".
WP_Theme_JSON::get_merged_preset_by_slug( array $preset_per_origin, string $value_key ) #
Given an array of presets keyed by origin and the value key of the preset, it returns an array where each key is the preset slug and each value the preset value.
Contents
Parameters
- $preset_per_origin
(array)(Required)Array of presets keyed by origin.
- $value_key
(string)(Required)The property of the preset that contains its value.
Return
(array) Array of presets where each key is a slug and each value is the preset value.
Source
File: wp-includes/class-wp-theme-json.php
/** * Returns the stylesheet that results of processing * the theme.json structure this object represents. * * @since 5.8.0 * @since 5.9.0 Removed the `$type` parameter`, added the `$types` and `$origins` parameters. * * @param array $types Types of styles to load. Will load all by default. It accepts: * - `variables`: only the CSS Custom Properties for presets & custom ones. * - `styles`: only the styles section in theme.json. * - `presets`: only the classes for the presets. * @param array $origins A list of origins to include. By default it includes VALID_ORIGINS. * @return string Stylesheet. */ public function get_stylesheet( $types = array( 'variables', 'styles', 'presets' ), $origins = null ) { if ( null === $origins ) { $origins = static::VALID_ORIGINS; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |