wp_style_add_data( string $handle, string $key, mixed $value ): bool
Adds metadata to a CSS stylesheet.
Contents
Description
Works only if the stylesheet has already been registered.
Possible values for $key and $value: ‘conditional’ string Comments for IE 6, lte IE 7 etc.
‘rtl’ bool|string To declare an RTL stylesheet.
‘suffix’ string Optional suffix, used in combination with RTL.
‘alt’ bool For rel="alternate stylesheet".
‘title’ string For preferred/alternate stylesheets.
‘path’ string The absolute path to a stylesheet. Stylesheet will load inline when ‘path’ is set.
See also
Parameters
-
$handle
string Required -
Name of the stylesheet.
-
$key
string Required -
Name of data point for which we're storing a value.
Accepts'conditional'
,'rtl'
and'suffix'
,'alt'
,'title'
and'path'
. -
$value
mixed Required -
String containing the CSS data to be added.
Return
bool True on success, false on failure.
Source
File: wp-includes/functions.wp-styles.php
.
View all references
function wp_style_add_data( $handle, $key, $value ) {
return wp_styles()->add_data( $handle, $key, $value );
}
Changelog
Version | Description |
---|---|
5.8.0 | Added 'path' as an official value for $key.See wp_maybe_inline_styles() . |
3.6.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Enqueue IE-specific stylesheets with conditional comments
To add an RTL (right-to-left) version of the style when the site is displayed in an RTL language, you can do this:
But if you want to completely swap out the original style with an RTL one when the site is viewed in an RTL language:
Important notes: