[ 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: 340 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 9 functions

  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_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_render_custom_css_support_styles( $parsed_block )   X-Ref
Render the custom CSS stylesheet and add class name to block as required.

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

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.

The class name is generated in {@see wp_render_custom_css_support_styles()}
and stored in block attributes. This filter adds it to the actual markup.

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

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_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.

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

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.

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



Generated : Fri Jul 24 08:20:19 2026 Cross-referenced by PHPXref