public static function css($field)
{
// Set class vars.
self::$settings = $field['settings'];
self::$callback = $field['sanitize_callback'];
self::$field_type = $field['type'];
self::$output = $field['output'];
if (!is_array(self::$output)) {
self::$output = array(array('element' => self::$output, 'sanitize_callback' => null));
}
// Get the value of this field.
self::$value = Kirki_Values::get_sanitized_field_value($field);
// Find the class that will handle the outpout for this field.
$classname = 'Kirki_Output';
$field_output_classes = apply_filters('kirki/' . $field['kirki_config'] . '/output/control-classnames', array('kirki-spacing' => 'Kirki_Output_Field_Spacing', 'kirki-typography' => 'Kirki_Output_Field_Typography', 'kirki-multicolor' => 'Kirki_Output_Field_Multicolor'));
if (array_key_exists(self::$field_type, $field_output_classes)) {
$classname = $field_output_classes[self::$field_type];
}
$obj = new $classname($field['kirki_config'], self::$output, self::$value);
return $obj->get_styles();
}
/** * 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; }