[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/block-supports/ -> custom-css.php (summary)

Custom CSS block support.

File Size: 541 lines (16 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 14 functions

  wp_custom_css_has_value()
  wp_get_custom_css_state_entries()
  wp_process_custom_css_state_entries()
  wp_generate_custom_css_class_name()
  wp_render_custom_css_support_styles()
  wp_enqueue_block_custom_css()
  wp_render_custom_css_class_name()
  wp_register_custom_css_support()
  wp_strip_custom_css_from_style_array()
  wp_strip_custom_css_from_blocks()
  wp_custom_css_kses_init_filters()
  wp_custom_css_remove_filters()
  wp_custom_css_kses_init()
  wp_custom_css_force_filtered_html_on_import_filter()

Functions
Functions that are not part of a class:

wp_custom_css_has_value( $style_node )   X-Ref
Checks whether a style node has a non-empty custom CSS string.

return: bool Whether the node has a non-empty custom CSS string.
param: mixed $style_node A style node, possibly containing a `css` key.

wp_get_custom_css_state_entries( $style, $block_name, $responsive_media_queries )   X-Ref
Collects custom CSS defined for a block instance across its default,
pseudo-selector, and viewport states.

return: array[] Custom CSS entries with `css`, `pseudo`, and `media_query` keys.
param: array  $style                    The block's `style` attribute.
param: string $block_name               Block name.
param: array  $responsive_media_queries Media queries keyed by viewport state name.

wp_process_custom_css_state_entries( $state_entries, $selector )   X-Ref
Validates and processes custom CSS for each block style state.

return: string Processed CSS.
param: array[] $state_entries Custom CSS entries.
param: string  $selector      Selector scoping the block instance.

wp_generate_custom_css_class_name( $parsed_block )   X-Ref
Generates the custom CSS class name for a block and registers its stylesheet.

return: string|null The generated class name, or null if the block has no custom CSS to render.
param: array $parsed_block The parsed block.

wp_render_custom_css_support_styles( $parsed_block )   X-Ref
Render the custom CSS stylesheet and add class name to block as required.

return: array The same parsed block with custom CSS class name added if appropriate.
param: array $parsed_block The parsed block.

wp_enqueue_block_custom_css()   X-Ref
Enqueues the block custom CSS styles.


wp_render_custom_css_class_name( $block_content, $block )   X-Ref
Applies the custom CSS class name to the block's rendered HTML.

Uses the class name that {@see wp_render_custom_css_support_styles()}
stored in the block attributes. Blocks that a parent parsed and rendered
itself never reach that filter, so the class name is generated here instead
via {@see wp_generate_custom_css_class_name()}.

return: string Filtered block content.
param: string $block_content Rendered block content.
param: array  $block         Block object.

wp_register_custom_css_support( $block_type )   X-Ref
Registers the style block attribute for block types that support it.

param: WP_Block_Type $block_type Block Type.

wp_strip_custom_css_from_style_array( $style )   X-Ref
Removes custom CSS from a style attribute and any nested style states.

return: array The style attribute with all `css` keys removed.
param: array $style The block's `style` attribute.

wp_strip_custom_css_from_blocks( $content )   X-Ref
Strips custom CSS (`style.css` in attributes) from all blocks in post content.

Uses {@see WP_Block_Parser::next_token()} to scan block tokens and surgically
replace only the attribute JSON that changed — no parse_blocks() +
serialize_blocks() round-trip needed.

return: string Filtered post content with block custom CSS removed.
param: string $content Post content to filter, expected to be escaped with slashes.

wp_custom_css_kses_init_filters()   X-Ref
Adds the filters to strip custom CSS from block content on save.
Priority of 8 to run before wp_filter_global_styles_post (priority 9) and wp_filter_post_kses (priority 10).


wp_custom_css_remove_filters()   X-Ref
Removes the filters that strip custom CSS from block content on save.
Priority of 8 to run before wp_filter_global_styles_post (priority 9) and wp_filter_post_kses (priority 10).


wp_custom_css_kses_init()   X-Ref
Registers the custom CSS content filters if the user does not have the edit_css capability.


wp_custom_css_force_filtered_html_on_import_filter( $arg )   X-Ref
Initializes custom CSS content filters when imported data should be filtered.

Runs at priority 999 on {@see 'force_filtered_html_on_import'} to ensure it
fires after general KSES initialization, independently of user capabilities.
If the input of the filter is true it means we are in an import situation and should
enable the custom CSS filters, independently of the user capabilities.

return: mixed Input argument of the filter.
param: mixed $arg Input argument of the filter.



Generated : Mon Nov 2 08:20:36 2026 Cross-referenced by PHPXref