wp-includes/style-engine/class-wp-style-engine-css-declarations.php:17Core class used for style engine CSS declarations.
$declarationsstring[]protected#[AllowDynamicProperties]class WP_Style_Engine_CSS_Declarations { /** * An array of CSS declarations (property => value pairs). * * @since 6.1.0 * * @var string[] */ protected $declarations = array(); /** * Constructor for this object. * * If a `$declarations` array is passed, it will be used to populate * the initial `$declarations` prop of the object by calling add_declarations(). * * @since 6.1.0 * * @param string[] $declarations Optional. An associative array of CSS definitions, * e.g. `array( "$property" => "$value", "$property" => "$value" )`. * Default empty array. */ public function __construct( $declarations = array() ) { $this->add_declarations( $declarations ); } /** * Adds a single declaration. * * @since 6.1.0 * * @param string $property The CSS property. * @param string $value The CSS value. * @return WP_Style_Engine_CSS_Declarations Returns the object to allow chaining methods. */ 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; } // Bail early if value is not a string. Prevents fatal errors from malformed block markup. if ( ! is_string( $value ) ) { 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; } /** * Removes a single declaration. * * @since 6.1.0 * * @param string $property The CSS property. * @return WP_Style_Engine_CSS_Declarations Returns the object to allow chaining methods. */ public function remove_declaration( $property ) { unset( $this->declarations[ $property ] ); return $this; } /** * Adds multiple declarations. * * @since 6.1.0 *Introduced in 6.1.0. One change between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
get_declaration_options() added.verified against sourcesrc/wp-includes/style-engine/class-wp-style-engine-css-declarations.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.