Kirki_Styles_Output_CSS::add_prefixes PHP Method

add_prefixes() public static method

Add prefixes if necessary.
public static add_prefixes ( array $css ) : array
$css array The CSS definitions array.
return array
        public static function add_prefixes($css)
        {
            if (is_array($css)) {
                foreach ($css as $media_query => $elements) {
                    foreach ($elements as $element => $style_array) {
                        foreach ($style_array as $property => $value) {
                            // Add -webkit-* and -moz-*.
                            if (is_string($property) && in_array($property, array('border-radius', 'box-shadow', 'box-sizing', 'text-shadow', 'transform', 'background-size', 'transition', 'transition-property'))) {
                                unset($css[$media_query][$element][$property]);
                                $css[$media_query][$element]['-webkit-' . $property] = $value;
                                $css[$media_query][$element]['-moz-' . $property] = $value;
                                $css[$media_query][$element][$property] = $value;
                            }
                            // Add -ms-* and -o-*.
                            if (is_string($property) && in_array($property, array('transform', 'background-size', 'transition', 'transition-property'))) {
                                unset($css[$media_query][$element][$property]);
                                $css[$media_query][$element]['-ms-' . $property] = $value;
                                $css[$media_query][$element]['-o-' . $property] = $value;
                                $css[$media_query][$element][$property] = $value;
                            }
                        }
                    }
                }
            }
            return $css;
        }

Usage Example

 /**
  * 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;
 }
All Usage Examples Of Kirki_Styles_Output_CSS::add_prefixes