Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Table::get_default_border_widths
Get default border widths for table element when individual border colors are present.
Method of the class: Table{}
No Hooks.
Returns
String. CSS border width styles or empty string if not needed.
Usage
// private - for code of main (parent) class only $result = $this->get_default_border_widths( $existing_style ): string;
- $existing_style(string) (required)
- Existing style attribute of the table element.
Table::get_default_border_widths() Table::get default border widths code WC 10.5.0
private function get_default_border_widths( string $existing_style ): string {
// Check if individual border colors are present but no corresponding widths.
$sides = array( 'top', 'right', 'bottom', 'left' );
$border_width_styles = array();
foreach ( $sides as $side ) {
$has_color = strpos( $existing_style, "border-{$side}-color:" ) !== false;
$has_width = strpos( $existing_style, "border-{$side}-width:" ) !== false;
// If border color is present but no width, add default width.
if ( $has_color && ! $has_width ) {
$border_width_styles[] = "border-{$side}-width: 1.5px";
}
}
return implode( '; ', $border_width_styles );
}