wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_get_state_declarations_with_fallback_border_styles › WordPress Function
Since7.1.0
Deprecatedn/a
› wp_get_state_declarations_with_fallback_border_styles ( $declarations )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
| Codex: |
Adds fallback border-style declarations for visible border declarations.
CSS does not render border color or width unless a border style is also set. State styles are emitted as stylesheet rules rather than inline styles, so they cannot rely on the block-library inline-style attribute fallback rules.Source
function wp_get_state_declarations_with_fallback_border_styles( $declarations ) {
if ( ! is_array( $declarations ) ) {
return $declarations;
}
$has_border_style = isset( $declarations['border-style'] ) && '' !== $declarations['border-style'];
$has_border_color = isset( $declarations['border-color'] ) && '' !== $declarations['border-color'];
$has_border_width = isset( $declarations['border-width'] ) && '' !== $declarations['border-width'];
if ( ! $has_border_style && ( $has_border_color || $has_border_width ) ) {
$declarations['border-style'] = 'solid';
}
$sides = array( 'top', 'right', 'bottom', 'left' );
foreach ( $sides as $side ) {
$side_style_property = "border-$side-style";
$side_color_property = "border-$side-color";
$side_width_property = "border-$side-width";
$has_side_style = isset( $declarations[ $side_style_property ] ) && '' !== $declarations[ $side_style_property ];
$has_side_color = isset( $declarations[ $side_color_property ] ) && '' !== $declarations[ $side_color_property ];
$has_side_width = isset( $declarations[ $side_width_property ] ) && '' !== $declarations[ $side_width_property ];
if ( ! $has_border_style && ! $has_side_style && ( $has_side_color || $has_side_width ) ) {
$declarations[ $side_style_property ] = 'solid';
}
}
return $declarations;
}