Cover
extends Abstract_Block_Renderer
in package
Cover block renderer.
This renderer handles core/cover blocks with proper email-friendly HTML layout.
Table of Contents
- render() : string
- Render the block.
- add_spacer() : string
- Add a spacer around the block.
- compile_css() : string
- Compile objects containing CSS properties to a string.
- get_styles_from_block() : array<string|int, mixed>
- Wrapper for wp_style_engine_get_styles which ensures all values are returned.
- render_content() : string
- Renders the cover block content using a table-based layout for email compatibility.
- build_cover_content() : string
- Build the cover content with background image or color.
- build_email_layout() : string
- Build the email-friendly layout for cover blocks.
- extract_background_image() : string
- Extract background image from block attributes or HTML content.
- get_background_color() : string
- Get background color from block attributes.
- get_minimum_height() : string
- Get minimum height from block attributes.
- validate_and_sanitize_color() : string
- Validate and sanitize a color value, returning empty string for invalid colors.
Methods
render()
Render the block.
public
render(string $block_content, array<string|int, mixed> $parsed_block, Rendering_Context $rendering_context) : string
Parameters
- $block_content : string
-
The block content.
- $parsed_block : array<string|int, mixed>
-
The parsed block.
- $rendering_context : Rendering_Context
-
The rendering context.
Return values
string —add_spacer()
Add a spacer around the block.
protected
add_spacer(string $content, array<string|int, mixed> $email_attrs) : string
Parameters
- $content : string
-
The block content.
- $email_attrs : array<string|int, mixed>
-
The email attributes.
Return values
string —compile_css()
Compile objects containing CSS properties to a string.
protected
compile_css(array<string|int, mixed> ...$styles) : string
Parameters
- $styles : array<string|int, mixed>
-
Style arrays to compile.
Return values
string —get_styles_from_block()
Wrapper for wp_style_engine_get_styles which ensures all values are returned.
protected
get_styles_from_block(array<string|int, mixed> $block_styles[, bool $skip_convert_vars = false ]) : array<string|int, mixed>
Parameters
- $block_styles : array<string|int, mixed>
-
Array of block styles.
- $skip_convert_vars : bool = false
-
If true, --wp_preset--spacing--x type values will be left in the original var:preset:spacing:x format.
Return values
array<string|int, mixed> —render_content()
Renders the cover block content using a table-based layout for email compatibility.
protected
render_content(string $block_content, array<string|int, mixed> $parsed_block, Rendering_Context $rendering_context) : string
Parameters
- $block_content : string
-
Block content.
- $parsed_block : array<string|int, mixed>
-
Parsed block.
- $rendering_context : Rendering_Context
-
Rendering context.
Return values
string —build_cover_content()
Build the cover content with background image or color.
private
build_cover_content(string $inner_content) : string
Parameters
- $inner_content : string
-
Inner content.
Return values
string — Cover content HTML.build_email_layout()
Build the email-friendly layout for cover blocks.
private
build_email_layout(string $inner_content, array<string|int, mixed> $block_attrs, string $block_content, string $background_image, Rendering_Context $rendering_context) : string
Parameters
- $inner_content : string
-
Inner content.
- $block_attrs : array<string|int, mixed>
-
Block attributes.
- $block_content : string
-
Original block content.
- $background_image : string
-
Background image URL.
- $rendering_context : Rendering_Context
-
Rendering context.
Return values
string — Rendered HTML.extract_background_image()
Extract background image from block attributes or HTML content.
private
extract_background_image(array<string|int, mixed> $block_attrs, string $block_content) : string
Parameters
- $block_attrs : array<string|int, mixed>
-
Block attributes.
- $block_content : string
-
Original block content.
Return values
string — Background image URL or empty string.get_background_color()
Get background color from block attributes.
private
get_background_color(array<string|int, mixed> $block_attrs, Rendering_Context $rendering_context) : string
Parameters
- $block_attrs : array<string|int, mixed>
-
Block attributes.
- $rendering_context : Rendering_Context
-
Rendering context.
Return values
string — Background color or empty string.get_minimum_height()
Get minimum height from block attributes.
private
get_minimum_height(array<string|int, mixed> $block_attrs) : string
Parameters
- $block_attrs : array<string|int, mixed>
-
Block attributes.
Return values
string — Minimum height value or empty string.validate_and_sanitize_color()
Validate and sanitize a color value, returning empty string for invalid colors.
private
validate_and_sanitize_color(string $color) : string
Parameters
- $color : string
-
The color value to validate and sanitize.
