public static styles_parse ( array $css = [] ) : string | ||
$css | array | The CSS definitions array. |
return | string | The generated CSS. |
public static function styles_parse($css = array())
{
// Pass our styles from the kirki/styles_array filter.
$css = apply_filters('kirki/styles_array', $css);
// Process the array of CSS properties and produce the final CSS.
$final_css = '';
if (!is_array($css) || empty($css)) {
return '';
}
foreach ($css as $media_query => $styles) {
$final_css .= 'global' != $media_query ? $media_query . '{' : '';
foreach ($styles as $style => $style_array) {
$final_css .= $style . '{';
foreach ($style_array as $property => $value) {
$value = is_string($value) ? $value : '';
$final_css .= $property . ':' . $value . ';';
}
$final_css .= '}';
}
$final_css .= 'global' != $media_query ? '}' : '';
}
return $final_css;
}
/** * loop through all fields and create an array of style definitions */ public static function loop_controls() { // Get an instance of the Kirki_Styles_Output_CSS class. // This will make sure google fonts and backup fonts are loaded. Kirki_Styles_Output_CSS::get_instance(); $fields = Kirki::$fields; $css = array(); // Early exit if no fields are found. if (empty($fields)) { return; } foreach ($fields as $field) { // Only continue if $field['output'] is set if (isset($field['output']) && !empty($field['output']) && 'background' != $field['type']) { if (function_exists('array_replace_recursive')) { $css = array_replace_recursive($css, Kirki_Styles_Output_CSS::css($field)); } else { $css = Kirki_Helper::array_replace_recursive($css, Kirki_Styles_Output_CSS::css($field)); } } } if (is_array($css)) { return Kirki_Styles_Output_CSS::styles_parse(Kirki_Styles_Output_CSS::add_prefixes($css)); } return; }