wppaste
WordPress

WP_Style_Engine

Since
6.1.0, 6.3.0, 6.4.0, 6.5.0, 6.7.0, 7.0.0
Source
wp-includes/style-engine/class-wp-style-engine.php:31
The main class integrating all other WP_Style_Engine_* classes.

Description

The Style Engine aims to provide a consistent API for rendering styling for blocks across both client-side and server-side applications.

This class is final and should not be extended.

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 wp_style_engine_get_styles() instead.

Compatibility

WordPress
since 7.0.0
  • 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).

Methods · 12

Source code

#[AllowDynamicProperties]final class WP_Style_Engine {	/**	 * Style definitions that contain the instructions to parse/output valid Gutenberg styles from a block's attributes.	 *	 * For every style definition, the following properties are valid:	 *	 *  - classnames    => (array) an array of classnames to be returned for block styles. The key is a classname or pattern.	 *                    A value of `true` means the classname should be applied always. Otherwise, a valid CSS property (string)	 *                    to match the incoming value, e.g., "color" to match var:preset|color|somePresetSlug.	 *  - css_vars      => (array) an array of key value pairs used to generate CSS var values.	 *                     The key should be the CSS property name that matches the second element of the preset string value,	 *                     i.e., "color" in var:preset|color|somePresetSlug. The value is a CSS var pattern (e.g. `--wp--preset--color--$slug`),	 *                     whose `$slug` fragment will be replaced with the preset slug, which is the third element of the preset string value,	 *                     i.e., `somePresetSlug` in var:preset|color|somePresetSlug.	 *  - property_keys => (array) array of keys whose values represent a valid CSS property, e.g., "margin" or "border".	 *  - path          => (array) a path that accesses the corresponding style value in the block style object.	 *  - value_func    => (string) the name of a function to generate a CSS definition array for a particular style object. The output of this function should be `array( "$property" => "$value", ... )`.	 *	 * @since 6.1.0	 * @since 7.1.0 Added `background.gradient` property.	 * @var array	 */	const BLOCK_STYLE_DEFINITIONS_METADATA = array(		'background' => array(			'backgroundImage'      => array(				'property_keys' => array(					'default' => 'background-image',				),				'value_func'    => array( self::class, 'get_url_or_value_css_declaration' ),				'path'          => array( 'background', 'backgroundImage' ),			),			'backgroundPosition'   => array(				'property_keys' => array(					'default' => 'background-position',				),				'path'          => array( 'background', 'backgroundPosition' ),			),			'backgroundRepeat'     => array(				'property_keys' => array(					'default' => 'background-repeat',				),				'path'          => array( 'background', 'backgroundRepeat' ),			),			'backgroundSize'       => array(				'property_keys' => array(					'default' => 'background-size',				),				'path'          => array( 'background', 'backgroundSize' ),			),			'backgroundAttachment' => array(				'property_keys' => array(					'default' => 'background-attachment',				),				'path'          => array( 'background', 'backgroundAttachment' ),			),			'gradient'             => array(				'property_keys' => array(					'default' => 'background-image',				),				'css_vars'      => array(					'gradient' => '--wp--preset--gradient--$slug',				),				'path'          => array( 'background', 'gradient' ),				'classnames'    => array(					'has-background' => true,				),			),		),		'color'      => array(			'text'       => array(				'property_keys' => array(					'default' => 'color',				),				'path'          => array( 'color', 'text' ),				'css_vars'      => array(					'color' => '--wp--preset--color--$slug',				),				'classnames'    => array(					'has-text-color'  => true,

Changelog

Introduced in 6.1.0. Unchanged from 6.7.7 through 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.0.0
Added support for typography.textIndent.from the docblock
6.7.0
Added support for typography.writingMode.from the docblock
6.5.0
Added support for background.backgroundPosition, background.backgroundRepeat and dimensions.aspectRatio.from the docblock
6.4.0
Added support for background.backgroundImage.from the docblock
6.3.0
Added support for text-columns.from the docblock
6.1.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/style-engine/class-wp-style-engine.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.