wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
wp_get_state_declarations_with_background_resets › WordPress Function
Seit7.1.0
Veraltetn/v
› wp_get_state_declarations_with_background_resets ( $declarations )
| Parameter: |
|
| Gibt zurück: |
|
| Definiert in: |
|
| Codex: |
Adds background reset declarations to prevent gradient/solid color conflicts.
When a state sets a solid background-color, any gradient applied to the default state (viabackground shorthand or background-image) must be
explicitly cleared. Without this, the gradient image layer remains visible
on top of the solid hover color even when !important is used, because
background-color and background-image are separate CSS properties.Quellcode
function wp_get_state_declarations_with_background_resets( $declarations ) {
if ( ! is_array( $declarations ) ) {
return $declarations;
}
$has_background_color = isset( $declarations['background-color'] ) && '' !== $declarations['background-color'];
$has_background = isset( $declarations['background'] ) && '' !== $declarations['background'];
$has_background_image = isset( $declarations['background-image'] ) && '' !== $declarations['background-image'];
/*
* When the state sets a solid background-color but no gradient of its own,
* emit `background-image: unset` to clear any gradient (whether stored as
* the `background` shorthand or as `background-image`) that was applied to
* the default / normal state via an inline style attribute. The declaration
* is marked important when the state rule is registered with the style engine.
*/
if ( $has_background_color && ! $has_background && ! $has_background_image ) {
$declarations['background-image'] = 'unset';
}
return $declarations;
}