Automattic\WooCommerce\EmailEditor\Integrations\Utils

Table_Wrapper_Helper::render_table_wrapperpublic staticWC 1.0

Render a table wrapper for email blocks.

Method of the class: Table_Wrapper_Helper{}

No Hooks.

Returns

String. The generated table wrapper HTML.

Usage

$result = Table_Wrapper_Helper::render_table_wrapper( $content, $table_attrs, $cell_attrs, $row_attrs, $render_cell ): string;
$content(string) (required)
The content to wrap (e.g., '{block_content}').
$table_attrs(array)
Table attributes to merge with defaults.
Default: array()
$cell_attrs(array)
Cell attributes.
Default: array()
$row_attrs(array)
Row attributes.
Default: array()
$render_cell(true|false)
Whether to render the td wrapper (default true).
Default: true

Table_Wrapper_Helper::render_table_wrapper() code WC 10.4.3

public static function render_table_wrapper(
	string $content,
	array $table_attrs = array(),
	array $cell_attrs = array(),
	array $row_attrs = array(),
	bool $render_cell = true
): string {
	$merged_table_attrs = array_merge( self::DEFAULT_TABLE_ATTRS, $table_attrs );
	$table_attr_string  = self::build_attributes_string( $merged_table_attrs );
	$row_attr_string    = self::build_attributes_string( $row_attrs );

	if ( $render_cell ) {
		$content = self::render_table_cell( $content, $cell_attrs );
	}

	return sprintf(
		'<table%2$s>
	<tbody>
		<tr%3$s>
			%1$s
		</tr>
	</tbody>
</table>',
		$content,
		$table_attr_string ? ' ' . $table_attr_string : '',
		$row_attr_string ? ' ' . $row_attr_string : ''
	);
}