Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Postprocessors
Border_Style_Postprocessor::expand_shorthand_value
Expands shorthand border width and style values into individual properties.
Method of the class: Border_Style_Postprocessor{}
No Hooks.
Returns
Array
Usage
// private - for code of main (parent) class only $result = $this->expand_shorthand_value( $value ): array;
- $value(string) (required)
- The shorthand border value.
Border_Style_Postprocessor::expand_shorthand_value() Border Style Postprocessor::expand shorthand value code WC 10.8.1
private function expand_shorthand_value( string $value ): array {
$values = preg_split( '/\s+/', trim( $value ) );
if ( ! is_array( $values ) ) {
return array();
}
$count = count( $values );
if ( 4 === $count ) {
return array(
'top' => $values[0] ?? '',
'right' => $values[1] ?? '',
'bottom' => $values[2] ?? '',
'left' => $values[3] ?? '',
);
}
if ( 3 === $count ) {
return array(
'top' => $values[0] ?? '',
'right' => $values[1] ?? '',
'bottom' => $values[2] ?? '',
'left' => $values[1] ?? '',
);
}
if ( 2 === $count ) {
return array(
'top' => $values[0] ?? '',
'right' => $values[1] ?? '',
'bottom' => $values[0] ?? '',
'left' => $values[1] ?? '',
);
}
if ( 1 === $count ) {
return array(
'top' => $values[0] ?? '',
'right' => $values[0] ?? '',
'bottom' => $values[0] ?? '',
'left' => $values[0] ?? '',
);
}
return array();
}