WP_Style_Engine_CSS_Declarations::add_declaration( string $property, string $value ): WP_Style_Engine_CSS_Declarations

In this article

Adds a single declaration.

Parameters

$propertystringrequired
The CSS property.
$valuestringrequired
The CSS value.

Return

WP_Style_Engine_CSS_Declarations Returns the object to allow chaining methods.

Source

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;
}

Changelog

VersionDescription
6.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.