WooCommerce Code Reference

Media_Text extends Abstract_Block_Renderer
in package

Media-text block renderer.

This renderer handles core/media-text 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 media-text block content using a direct table-based layout.
build_email_layout()  : string
Build the email-friendly layout for media-text blocks.
extract_media_from_html()  : string
Extract media content from the HTML block content.
get_media_width_from_attributes()  : int
Get the media width value from block attributes.
get_vertical_alignment_from_attributes()  : string
Get the vertical alignment value from block attributes.
wrap_media_with_link()  : string
Wrap media content with a link if it's not already wrapped.

Methods

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 media-text block content using a direct table-based layout.

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_email_layout()

Build the email-friendly layout for media-text blocks.

private build_email_layout(string $media_content, string $text_content, array<string|int, mixed> $block_attrs, string $block_content, Rendering_Context $rendering_context) : string
Parameters
$media_content : string

Media HTML content.

$text_content : string

Text content.

$block_attrs : array<string|int, mixed>

Block attributes.

$block_content : string

Original block content.

$rendering_context : Rendering_Context

Rendering context.

Return values
stringRendered HTML.

get_vertical_alignment_from_attributes()

Get the vertical alignment value from block attributes.

private get_vertical_alignment_from_attributes(array<string|int, mixed> $block_attrs) : string
Parameters
$block_attrs : array<string|int, mixed>

Block attributes.

Return values
stringCSS vertical-align value.

Wrap media content with a link if it's not already wrapped.

private wrap_media_with_link(string $media_content, string $href) : string
Parameters
$media_content : string

The media content (inner content from figure element).

$href : string

The URL to link to.

Return values
stringMedia content wrapped with link.