packages/kirki-framework/field-typography/src/Field/Typography.php
public static function sanitize( $value ) {
		if ( ! is_array( $value ) ) {
			return [];
		}

		foreach ( $value as $key => $val ) {
			switch ( $key ) {
				case 'font-family':
					$value['font-family'] = sanitize_text_field( $val );
					break;
				case 'font-weight':
					if ( isset( $value['variant'] ) ) {
						break;
					}
					$value['variant'] = $val;
					if ( isset( $value['font-style'] ) && 'italic' === $value['font-style'] ) {
						$value['variant'] = ( '400' !== $val || 400 !== $val ) ? $value['variant'] . 'italic' : 'italic';
					}
					break;
				case 'variant':
					// Use 'regular' instead of 400 for font-variant.
					$value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val;

					// Get font-weight from variant.
					$value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
					$value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? 400 : (string) absint( $value['font-weight'] );

					// Get font-style from variant.
					if ( ! isset( $value['font-style'] ) ) {
						$value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic';
					}
					break;
				case 'font-size':
				case 'letter-spacing':
				case 'word-spacing':
				case 'line-height':
					$value[ $key ] = '' === trim( $value[ $key ] ) ? '' : sanitize_text_field( $val );
					break;
				case 'text-align':
					if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) {
						$value['text-align'] = '';
					}
					break;
				case 'text-transform':
					if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) {
						$value['text-transform'] = '';
					}
					break;
				case 'text-decoration':
					if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'initial', 'inherit' ], true ) ) {
						$value['text-transform'] = '';
					}
					break;
				case 'color':
					$value['color'] = '' === $value['color'] ? '' : \ariColor::newColor( $val )->toCSS( 'hex' );
					break;
			}
		}

		return $value;
	}
public static function sanitize( $value ) {
		if ( ! is_array( $value ) ) {
			return [];
		}

		foreach ( $value as $key => $val ) {
			switch ( $key ) {
				case 'font-family':
					$value['font-family'] = sanitize_text_field( $val );
					break;
				case 'font-weight':
					if ( isset( $value['variant'] ) ) {
						break;
					}
					$value['variant'] = $val;
					if ( isset( $value['font-style'] ) && 'italic' === $value['font-style'] ) {
						$value['variant'] = ( '400' !== $val || 400 !== $val ) ? $value['variant'] . 'italic' : 'italic';
					}
					break;
				case 'variant':
					// Use 'regular' instead of 400 for font-variant.
					$value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val;

					// Get font-weight from variant.
					$value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
					$value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? 400 : (string) absint( $value['font-weight'] );

					// Get font-style from variant.
					if ( ! isset( $value['font-style'] ) ) {
						$value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic';
					}
					break;
				case 'font-size':
				case 'letter-spacing':
				case 'word-spacing':
				case 'line-height':
					$value[ $key ] = '' === trim( $value[ $key ] ) ? '' : sanitize_text_field( $val );
					break;
				case 'text-align':
					if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) {
						$value['text-align'] = '';
					}
					break;
				case 'text-transform':
					if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) {
						$value['text-transform'] = '';
					}
					break;
				case 'text-decoration':
					if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'initial', 'inherit' ], true ) ) {
						$value['text-transform'] = '';
					}
					break;
				case 'color':
					$value['color'] = '' === $value['color'] ? '' : \ariColor::newColor( $val )->toCSS( 'hex' );
					break;
			}
		}

		return $value;
	}
public static function sanitize ( $ value ) { if ( ! is_array ( $ value ) ) { return [ ] ; } foreach ( $ value as $ key => $ val ) { switch ( $ key ) { case 'font-family' : $ value [ 'font-family' ] = sanitize_text_field ( $ val ) ; break ; case 'font-weight' : if ( isset ( $ value [ 'variant' ] ) ) { break ; } $ value [ 'variant' ] = $ val ; if ( isset ( $ value [ 'font-style' ] ) && 'italic' === $ value [ 'font-style' ] ) { $ value [ 'variant' ] = ( '400' !== $ val || 400 !== $ val ) ? $ value [ 'variant' ] . 'italic' : 'italic' ; } break ; case 'variant' : // Use 'regular' instead of 400 for font-variant. $ value [ 'variant' ] = ( 400 === $ val || '400' === $ val ) ? 'regular' : $ val ; // Get font-weight from variant. $ value [ 'font-weight' ] = filter_var ( $ value [ 'variant' ] , FILTER_SANITIZE_NUMBER_FLOAT , FILTER_FLAG_ALLOW_FRACTION ) ; $ value [ 'font-weight' ] = ( 'regular' === $ value [ 'variant' ] || 'italic' === $ value [ 'variant' ] ) ? 400 : ( string ) absint ( $ value [ 'font-weight' ] ) ; // Get font-style from variant. if ( ! isset ( $ value [ 'font-style' ] ) ) { $ value [ 'font-style' ] = ( false === strpos ( $ value [ 'variant' ] , 'italic' ) ) ? 'normal' : 'italic' ; } break ; case 'font-size' : case 'letter-spacing' : case 'word-spacing' : case 'line-height' : $ value [ $ key ] = '' === trim ( $ value [ $ key ] ) ? '' : sanitize_text_field ( $ val ) ; break ; case 'text-align' : if ( ! in_array ( $ val , [ '' , 'inherit' , 'left' , 'center' , 'right' , 'justify' ] , true ) ) { $ value [ 'text-align' ] = '' ; } break ; case 'text-transform' : if ( ! in_array ( $ val , [ '' , 'none' , 'capitalize' , 'uppercase' , 'lowercase' , 'initial' , 'inherit' ] , true ) ) { $ value [ 'text-transform' ] = '' ; } break ; case 'text-decoration' : if ( ! in_array ( $ val , [ '' , 'none' , 'underline' , 'overline' , 'line-through' , 'initial' , 'inherit' ] , true ) ) { $ value [ 'text-transform' ] = '' ; } break ; case 'color' : $ value [ 'color' ] = '' === $ value [ 'color' ] ? '' : \ ariColor :: newColor ( $ val ) -> toCSS ( 'hex' ) ; break ; } } return $ value ; }
Sanitizes typography controls

@static
@since 1.0
@param array $value The value.
@return array
Sanitizes typography controls