WooCommerce Code Reference

Table extends Abstract_Block_Renderer
in package

Renders a table block.

Table of Contents

VALID_TEXT_ALIGNMENTS  = array('left', 'center', 'right')
Valid text alignment values.
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_inner_content()  : string
Extract inner content from a wrapper element.
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 block content.
add_class_to_table_element()  : string
Add a CSS class to the table element.
add_header_footer_borders()  : string
Add thicker borders for table headers and footers when no custom border is set.
apply_styles_to_table_element()  : string
Apply CSS styles directly to the table element.
extract_table_and_caption_from_figure()  : array<string|int, mixed>
Extract table content and caption from figure wrapper if present.
extract_typography_styles_for_caption()  : string
Extract typography styles from CSS string for caption.
get_cell_text_alignment()  : string
Get text alignment for a table cell.
get_custom_border_color()  : string|null
Get custom border color from block attributes.
get_custom_border_style()  : string
Get custom border style from block attributes.
get_custom_border_width()  : string|null
Get custom border width from block attributes.
get_default_border_widths()  : string
Get default border widths for table element when individual border colors are present.
has_fixed_layout()  : bool
Check if table has fixed layout class.
is_striped_table()  : bool
Check if the table has striped styling.
is_valid_table_content()  : bool
Validate if the content is a valid table HTML.
process_table_content()  : string
Process table content to ensure email client compatibility.

Constants

Methods

get_inner_content()

Extract inner content from a wrapper element.

protected get_inner_content(string $block_content[, string $tag_name = 'div' ]) : string

Removes the outer wrapper element (e.g., div) and returns only the inner HTML content. This is useful when you need to strip the wrapper and use only the inner content.

Parameters
$block_content : string

Block content with wrapper element.

$tag_name : string = 'div'

Tag name of the wrapper element (default: 'div').

Return values
stringInner content without the wrapper element, or original content if wrapper not found.

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>

add_class_to_table_element()

Add a CSS class to the table element.

private add_class_to_table_element(string $table_content, string $class_name) : string
Parameters
$table_content : string

Table HTML content.

$class_name : string

CSS class to add.

Return values
stringTable content with class added.

Add thicker borders for table headers and footers when no custom border is set.

private add_header_footer_borders(WP_HTML_Tag_Processor $html, string $base_styles, string $border_color[, string $current_section = '' ][, string|null $custom_border_width = null ]) : string
Parameters
$html : WP_HTML_Tag_Processor

HTML tag processor.

$base_styles : string

Base cell styles.

$border_color : string

Border color.

$current_section : string = ''

Current table section (thead, tbody, tfoot).

$custom_border_width : string|null = null

Custom border width if set.

Return values
stringUpdated cell styles.

apply_styles_to_table_element()

Apply CSS styles directly to the table element.

private apply_styles_to_table_element(string $table_content, string $styles) : string
Parameters
$table_content : string

Table HTML content.

$styles : string

CSS styles to apply.

Return values
stringTable content with styles applied.

extract_table_and_caption_from_figure()

Extract table content and caption from figure wrapper if present.

private extract_table_and_caption_from_figure(string $block_content) : array<string|int, mixed>
Parameters
$block_content : string

Block content.

Return values
array<string|int, mixed>Array with 'table' and 'caption' keys.

get_custom_border_width()

Get custom border width from block attributes.

private get_custom_border_width(array<string|int, mixed> $parsed_block) : string|null
Parameters
$parsed_block : array<string|int, mixed>

Parsed block.

Return values
string|nullCustom border width or null if not set.

get_default_border_widths()

Get default border widths for table element when individual border colors are present.

private get_default_border_widths(string $existing_style) : string
Parameters
$existing_style : string

Existing style attribute of the table element.

Return values
stringCSS border width styles or empty string if not needed.

is_striped_table()

Check if the table has striped styling.

private is_striped_table(string $block_content, array<string|int, mixed> $parsed_block) : bool
Parameters
$block_content : string

Block content.

$parsed_block : array<string|int, mixed>

Parsed block.

Return values
boolTrue if it's a striped table, false otherwise.

process_table_content()

Process table content to ensure email client compatibility.

private process_table_content(string $block_content, array<string|int, mixed> $parsed_block, Rendering_Context $rendering_context[, bool $is_striped_table = false ]) : string
Parameters
$block_content : string

Block content.

$parsed_block : array<string|int, mixed>

Parsed block.

$rendering_context : Rendering_Context

Rendering context.

$is_striped_table : bool = false

Whether this is a striped table.

Return values
string