LLMS_Theme_Support::get_css( string[] $selectors, string[] $rules, string $selector_prefix = '' )
Retrieve formatted inline CSS for a given list of selectors and rules
Parameters Parameters
- $selectors
-
(string[]) (Required) Array of CSS selectors.
- $rules
-
(string[]) (Required) Associative array of CSS rules and properties. For example:
array( 'color' => '#fff' )
. - $selector_prefix
-
(string) (Optional) A CSS selector to prefix each item in $selectors with.
Default value: ''
Return Return
(string)
Source Source
File: includes/theme-support/class-llms-theme-support.php
public static function get_css( $selectors, $rules, $selector_prefix = '' ) { // Convert the $rules array to a list of CSS strings. $rules_list = array(); foreach ( $rules as $prop => $val ) { $val = is_array( $val ) ? $val : array( $val ); foreach ( $val as $value ) { $rules_list[] = sprintf( '%1$s: %2$s;', $prop, $value ); } } // When supplied, prefix each selector. if ( $selector_prefix ) { foreach ( $selectors as &$selector ) { $selector = $selector_prefix . ' ' . $selector; } } // Return the formatted CSS. return implode( ', ', $selectors ) . ' { ' . implode( ' ', $rules_list ) . ' }'; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
4.10.0 | Introduced. |