wp_style_add_data() WordPress Function

The wp_style_add_data() function allows you to add data to a CSS file. You can use this function to add information such as the author's name, version number, and copyright information.

wp_style_add_data( string $handle, string $key, mixed $value ) #

Add metadata to a CSS stylesheet.


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.

Top ↑

See also


Top ↑

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.


Top ↑

Return

(bool) True on success, false on failure.


Top ↑

Source

File: wp-includes/functions.wp-styles.php

function wp_style_add_data( $handle, $key, $value ) {
	return wp_styles()->add_data( $handle, $key, $value );
}


Top ↑

Changelog

Changelog
VersionDescription
5.8.0Added 'path' as an official value for $key. See wp_maybe_inline_styles().
3.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.