packages/kirki-framework/control-background/src/Field/Background.php
public static function sanitize( $value ) {
		if ( ! is_array( $value ) ) {
			return [];
		}
		$sanitized_value = [
			'background-color'      => '',
			'background-image'      => '',
			'background-repeat'     => '',
			'background-position'   => '',
			'background-size'       => '',
			'background-attachment' => '',
		];
		if ( isset( $value['background-color'] ) ) {
			$sanitized_value['background-color'] = \Kirki\Field\Color::sanitize( $value['background-color'] );
		}
		if ( isset( $value['background-image'] ) ) {
			$sanitized_value['background-image'] = esc_url_raw( $value['background-image'] );
		}
		if ( isset( $value['background-repeat'] ) ) {
			$sanitized_value['background-repeat'] = in_array(
				$value['background-repeat'],
				[
					'no-repeat',
					'repeat',
					'repeat-x',
					'repeat-y',
				],
				true
			) ? $value['background-repeat'] : '';
		}
		if ( isset( $value['background-position'] ) ) {
			$sanitized_value['background-position'] = in_array(
				$value['background-position'],
				[
					'left top',
					'left center',
					'left bottom',
					'center top',
					'center center',
					'center bottom',
					'right top',
					'right center',
					'right bottom',
				],
				true
			) ? $value['background-position'] : '';
		}
		if ( isset( $value['background-size'] ) ) {
			$sanitized_value['background-size'] = in_array(
				$value['background-size'],
				[
					'cover',
					'contain',
					'auto',
				],
				true
			) ? $value['background-size'] : '';
		}
		if ( isset( $value['background-attachment'] ) ) {
			$sanitized_value['background-attachment'] = in_array(
				$value['background-attachment'],
				[
					'scroll',
					'fixed',
				],
				true
			) ? $value['background-attachment'] : '';
		}
		return $sanitized_value;
	}
public static function sanitize( $value ) {
		if ( ! is_array( $value ) ) {
			return [];
		}
		$sanitized_value = [
			'background-color'      => '',
			'background-image'      => '',
			'background-repeat'     => '',
			'background-position'   => '',
			'background-size'       => '',
			'background-attachment' => '',
		];
		if ( isset( $value['background-color'] ) ) {
			$sanitized_value['background-color'] = \Kirki\Field\Color::sanitize( $value['background-color'] );
		}
		if ( isset( $value['background-image'] ) ) {
			$sanitized_value['background-image'] = esc_url_raw( $value['background-image'] );
		}
		if ( isset( $value['background-repeat'] ) ) {
			$sanitized_value['background-repeat'] = in_array(
				$value['background-repeat'],
				[
					'no-repeat',
					'repeat',
					'repeat-x',
					'repeat-y',
				],
				true
			) ? $value['background-repeat'] : '';
		}
		if ( isset( $value['background-position'] ) ) {
			$sanitized_value['background-position'] = in_array(
				$value['background-position'],
				[
					'left top',
					'left center',
					'left bottom',
					'center top',
					'center center',
					'center bottom',
					'right top',
					'right center',
					'right bottom',
				],
				true
			) ? $value['background-position'] : '';
		}
		if ( isset( $value['background-size'] ) ) {
			$sanitized_value['background-size'] = in_array(
				$value['background-size'],
				[
					'cover',
					'contain',
					'auto',
				],
				true
			) ? $value['background-size'] : '';
		}
		if ( isset( $value['background-attachment'] ) ) {
			$sanitized_value['background-attachment'] = in_array(
				$value['background-attachment'],
				[
					'scroll',
					'fixed',
				],
				true
			) ? $value['background-attachment'] : '';
		}
		return $sanitized_value;
	}
public static function sanitize ( $ value ) { if ( ! is_array ( $ value ) ) { return [ ] ; } $ sanitized_value = [ 'background-color' => '' , 'background-image' => '' , 'background-repeat' => '' , 'background-position' => '' , 'background-size' => '' , 'background-attachment' => '' , ] ; if ( isset ( $ value [ 'background-color' ] ) ) { $ sanitized_value [ 'background-color' ] = \ Kirki \ Field \ Color :: sanitize ( $ value [ 'background-color' ] ) ; } if ( isset ( $ value [ 'background-image' ] ) ) { $ sanitized_value [ 'background-image' ] = esc_url_raw ( $ value [ 'background-image' ] ) ; } if ( isset ( $ value [ 'background-repeat' ] ) ) { $ sanitized_value [ 'background-repeat' ] = in_array ( $ value [ 'background-repeat' ] , [ 'no-repeat' , 'repeat' , 'repeat-x' , 'repeat-y' , ] , true ) ? $ value [ 'background-repeat' ] : '' ; } if ( isset ( $ value [ 'background-position' ] ) ) { $ sanitized_value [ 'background-position' ] = in_array ( $ value [ 'background-position' ] , [ 'left top' , 'left center' , 'left bottom' , 'center top' , 'center center' , 'center bottom' , 'right top' , 'right center' , 'right bottom' , ] , true ) ? $ value [ 'background-position' ] : '' ; } if ( isset ( $ value [ 'background-size' ] ) ) { $ sanitized_value [ 'background-size' ] = in_array ( $ value [ 'background-size' ] , [ 'cover' , 'contain' , 'auto' , ] , true ) ? $ value [ 'background-size' ] : '' ; } if ( isset ( $ value [ 'background-attachment' ] ) ) { $ sanitized_value [ 'background-attachment' ] = in_array ( $ value [ 'background-attachment' ] , [ 'scroll' , 'fixed' , ] , true ) ? $ value [ 'background-attachment' ] : '' ; } return $ sanitized_value ; }
Sanitizes background controls

@static
@access public
@since 1.0
@param array $value The value.
@return array
Sanitizes background controls