| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
Block state support for frontend CSS generation. Generates scoped CSS for per-instance state styles declared in block attributes, including pseudo-states (e.g., `style[':hover']`) and responsive states (e.g., `style['@mobile']` and `style['@mobile'][':hover']`).
| File Size: | 947 lines (29 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
| wp_normalize_state_preset_vars( $value ) X-Ref |
| Converts internal preset references to CSS custom property references. State styles are emitted as CSS rules and cannot rely on preset classnames. Converting `var:preset|color|contrast` to `var(--wp--preset--color--contrast)` ensures preset values are emitted as declarations by the style engine. return: mixed Normalized style value. param: mixed $value Style value to normalize. |
| wp_normalize_state_style_for_css_output( $style ) X-Ref |
| Normalizes a state style object before generating CSS declarations. return: array Normalized state style object. param: array $style State style object. |
| wp_get_state_declarations_with_fallback_border_styles( $declarations ) X-Ref |
| Adds fallback border-style declarations for visible border declarations. CSS does not render border color or width unless a border style is also set. State styles are emitted as stylesheet rules rather than inline styles, so they cannot rely on the block-library inline-style attribute fallback rules. return: array CSS declarations with fallback border styles applied where needed. param: array $declarations CSS declarations generated by the style engine. |
| wp_get_state_declarations_with_background_resets( $declarations ) X-Ref |
| Adds background reset declarations to prevent gradient/solid color conflicts. When a state sets a solid background-color, any gradient applied to the default state (via `background` shorthand or `background-image`) must be explicitly cleared. Without this, the gradient image layer remains visible on top of the solid hover color even when `!important` is used, because `background-color` and `background-image` are separate CSS properties. return: array CSS declarations with background resets applied where needed. param: array $declarations CSS declarations generated by the style engine. |
| wp_merge_state_style_objects( $target, $source ) X-Ref |
| Merges one state style object over another. Mirror of `mergeStyleObjects` in packages/block-editor/src/hooks/style.jsx. return: array<string, mixed> Merged style object. param: array<string, mixed> $target Styles underneath. param: array<string, mixed> $source Styles layered over them. |
| wp_state_paints_own_background( array $state_style ) X-Ref |
| Checks whether a state paints its own background. return: bool Whether the state sets a gradient or background image. param: array<string, mixed> $state_style State style object. |
| wp_get_state_text_clip_escape( array $state_style, string $base_clip ) X-Ref |
| Returns the declarations that unclip a text clip when a state sets a different clip. Mirror of `getStateTextClipEscapeCSS` in packages/block-editor/src/hooks/style.jsx. return: array<string, string> CSS declarations, empty when no escape is needed. param: array<string, mixed> $state_style State style object. param: string $base_clip Background clip of the styles the state layers over. |
| wp_get_state_text_fill_reset( array $state_style ) X-Ref |
| Returns the declarations that refill the letters when a state sets a text color but no clip. The fill is added even without a known text clip, since a block instance cannot see a clip set in global styles. It does nothing when no clip applies. Mirror of `getStateTextFillResetCSS` in packages/block-editor/src/hooks/style.jsx. return: array<string, string> CSS declarations, empty when no reset is needed. param: array<string, mixed> $state_style State style object. |
| wp_get_state_style_with_fallback_dimension_styles( $state_style ) X-Ref |
| Adds fallback dimension styles for aspectRatio and height block-support values. return: array State style object with fallback dimension styles applied where needed. param: array $state_style State style object. |
| wp_add_state_style_group( &$groups, $selector, $style ) X-Ref |
| Adds a style fragment to a selector-keyed state style group. param: array $groups Selector-keyed style groups. param: string|null $selector Block or feature selector. param: array $style Style fragment. |
| wp_get_state_style_groups( $state_style, $block_selectors ) X-Ref |
| Splits a state style object into groups based on block feature selectors. return: array[] Selector/style groups. param: array $state_style State style object. param: array $block_selectors Block selectors metadata. |
| wp_get_root_state_style( $state_style, $nested_keys ) X-Ref |
| Returns a style object with nested state keys removed. return: array Root-only style object. param: array $state_style State style object. param: array $nested_keys Keys to remove from the root style object. |
| wp_get_block_state_element_selectors( $root_selector ) X-Ref |
| Generates all element selectors for a block root selector. return: string[] Element selectors keyed by element name. param: string $root_selector The block root CSS selector. |
| wp_add_block_state_style_rule( &$css_rules, $state, $selector, $style, $rules_group = null, $base_style = null ) X-Ref |
| Adds a compiled state style rule to a rule list. param: array[] $css_rules Style rules. param: string $state Pseudo-state selector. param: string|null $selector Block, feature, or element selector. param: array<string, mixed> $style Style object. param: string|null $rules_group Optional CSS grouping rule, e.g. a media query. param: array<string, mixed>|null $base_style Optional styles the state layers over. |
| wp_get_block_state_style_rules( $state_styles, $block_type, $rules_group = null, $base_style = null ) X-Ref |
| Builds compiled state style rules, preserving the selector each rule targets. return: array[] State style rules. param: array<string, mixed> $state_styles Map of state to style array. param: WP_Block_Type $block_type Block type. param: string|null $rules_group Optional CSS grouping rule, e.g. a media query. param: array<string, mixed>|null $base_style Optional styles the state layers over. |
| wp_get_block_state_unique_class( $block_name, $css_rules ) X-Ref |
| Returns a unique class for a set of state style rules. return: string Unique class name. param: string $block_name Block name. param: array $css_rules State style rules. |
| wp_split_selector_list( $selector ) X-Ref |
| Splits a selector list by top-level commas. return: string[] Selectors. param: string $selector CSS selector list. |
| wp_get_state_selector_ancestor( $selector, $block_name ) X-Ref |
| Returns the ancestor part of a block selector whose leading compound names a different block, e.g. `.wp-block-list > ` in List Item's `.wp-block-list > li`. The block-instance class is on the block's own wrapper, so a leading compound naming another block must be kept rather than swapped for that class. When the next compound carries a `wp-block-*` class (`.wp-block-button .wp-block-button__link`), the selector describes a nested element and keeps the leading swap. return: string The leading compound and its combinator, or an empty string. param: string $selector A single block or feature selector. param: string|null $block_name Name of the block being scoped. |
| wp_build_state_selector( $base_selector, $block_selector, $state, $block_name = null ) X-Ref |
| Builds a scoped selector from a block selector and optional pseudo-state. return: string Scoped selector. param: string $base_selector Block-instance scoping selector. param: string|null $block_selector Block or feature selector from metadata. param: string $state Pseudo-state selector. param: string|null $block_name Optional. Name of the block being scoped. |
| wp_render_block_states_support( $block_content, $block ) X-Ref |
| Renders per-instance state styles on the frontend. return: string Modified block content with injected state styles. param: string $block_content The block's rendered HTML. param: array $block The block data including blockName and attrs. |
| Generated : Mon Nov 2 08:20:36 2026 | Cross-referenced by PHPXref |