On this page
WP_Style_Engine_CSS_Declarations::add_declaration( string $property, string $value ): WP_Style_Engine_CSS_Declarations
Adds a single declaration.
Parameters
$propertystring Required-
The CSS property.
$valuestring Required-
The CSS value.
Return
WP_Style_Engine_CSS_Declarations Returns the object to allow chaining methods.
Source
File: wp-includes/style-engine/class-wp-style-engine-css-declarations.php. View all references
public function add_declaration( $property, $value ) {
// Sanitizes the property.
$property = $this->sanitize_property( $property );
// Bails early if the property is empty.
if ( empty( $property ) ) {
return $this;
}
// Trims the value. If empty, bail early.
$value = trim( $value );
if ( '' === $value ) {
return $this;
}
// Adds the declaration property/value pair.
$this->declarations[ $property ] = $value;
return $this;
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Style_Engine_CSS_Declarations::sanitize_property() wp-includes/style-engine/class-wp-style-engine-css-declarations.php | Sanitizes property names. |
Used By
| Used By | Description |
|---|---|
| WP_Style_Engine_CSS_Declarations::add_declarations() wp-includes/style-engine/class-wp-style-engine-css-declarations.php | Adds multiple declarations. |
Changelog
| Version | Description |
|---|---|
| 6.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_style_engine_css_declarations/add_declaration