Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Table::get_custom_border_width
Get custom border width from block attributes.
Method of the class: Table{}
No Hooks.
Returns
String|null. Custom border width or null if not set.
Usage
// private - for code of main (parent) class only $result = $this->get_custom_border_width( $parsed_block ): ?string;
- $parsed_block(array) (required)
- Parsed block.
Table::get_custom_border_width() Table::get custom border width code WC 10.8.1
private function get_custom_border_width( array $parsed_block ): ?string {
$block_attributes = $parsed_block['attrs'] ?? array();
if ( ! empty( $block_attributes['style']['border']['width'] ) ) {
$border_width = $block_attributes['style']['border']['width'];
// Sanitize the border width value.
$border_width = Html_Processing_Helper::sanitize_css_value( $border_width );
if ( empty( $border_width ) ) {
return null;
}
// Ensure the border width has a unit, default to px if not specified.
if ( is_numeric( $border_width ) ) {
return $border_width . 'px';
}
// Validate that the border width contains only valid CSS units and numbers.
if ( preg_match( '/^[0-9]+\.?[0-9]*(px|em|rem|pt|pc|in|cm|mm|ex|ch|vw|vh|vmin|vmax)$/', $border_width ) ) {
return $border_width;
}
// If invalid, return null to use default.
return null;
}
return null;
}