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'; $default_classnames = array( 'kirki-background' => 'Kirki_Output_Field_Background', 'kirki-dimensions' => 'Kirki_Output_Field_Dimensions', 'kirki-image' => 'Kirki_Output_Field_Image', 'kirki-typography' => 'Kirki_Output_Field_Typography', 'kirki-multicolor' => 'Kirki_Output_Field_Multicolor', ); $field_output_classes = apply_filters( 'kirki_output_control_classnames', $default_classnames ); $field_output_classes = apply_filters( "kirki_{$field['kirki_config']}_output_control_classnames", $field_output_classes ); 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, $field ); return $obj->get_styles(); } /** * Gets the array of generated styles and creates the minimized, inline CSS. * * @static * @access public * @param array $css 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 ) { $css_for_style = ''; foreach ( $style_array as $property => $value ) { if ( is_string( $value ) && '' !== $value ) { $css_for_style .= $property . ':' . $value . ';'; } elseif ( is_array( $value ) ) { foreach ( $value as $subvalue ) { if ( is_string( $subvalue ) && '' !== $subvalue ) { $css_for_style .= $property . ':' . $subvalue . ';'; } } } $value = ( is_string( $value ) ) ? $value : ''; } if ( '' !== $css_for_style ) { $final_css .= $style . '{' . $css_for_style . '}'; } } $final_css .= ( 'global' !== $media_query ) ? '}' : ''; } return $final_css; } /** * Add prefixes if necessary. * * @param array $css 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', ), true ) ) { 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', ), true ) ) { 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; } }