WP_Theme_JSON::update_separator_declarations()
Returns a filtered declarations array if there is a separator block with only a background style defined in theme.json by adding a color attribute to reflect the changes in the front.
Method of the class: WP_Theme_JSON{}
No Hooks.
Return
Array
. $declarations List of declarations filtered.
Usage
$result = WP_Theme_JSON::update_separator_declarations( $declarations );
- $declarations(array) (required)
- List of declarations.
Changelog
Since 6.1.1 | Introduced. |
WP_Theme_JSON::update_separator_declarations() WP Theme JSON::update separator declarations code WP 6.7.1
private static function update_separator_declarations( $declarations ) { $background_color = ''; $border_color_matches = false; $text_color_matches = false; foreach ( $declarations as $declaration ) { if ( 'background-color' === $declaration['name'] && ! $background_color && isset( $declaration['value'] ) ) { $background_color = $declaration['value']; } elseif ( 'border-color' === $declaration['name'] ) { $border_color_matches = true; } elseif ( 'color' === $declaration['name'] ) { $text_color_matches = true; } if ( $background_color && $border_color_matches && $text_color_matches ) { break; } } if ( $background_color && ! $border_color_matches && ! $text_color_matches ) { $declarations[] = array( 'name' => 'color', 'value' => $background_color, ); } return $declarations; }