WP_Style_Engine_CSS_Declarations::add_declaration()publicWP 6.1.0

Adds a single declaration.

Method of the class: WP_Style_Engine_CSS_Declarations{}

No Hooks.

Return

WP_Style_Engine_CSS_Declarations. Returns the object to allow chaining methods.

Usage

$WP_Style_Engine_CSS_Declarations = new WP_Style_Engine_CSS_Declarations();
$WP_Style_Engine_CSS_Declarations->add_declaration( $property, $value );
$property(string) (required)
The CSS property.
$value(string) (required)
The CSS value.

Changelog

Since 6.1.0 Introduced.

WP_Style_Engine_CSS_Declarations::add_declaration() code WP 6.4.3

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