Automattic\WooCommerce\Internal\Font

FontFace::validate_font_face()private staticWC 1.0

Validates a font face.

Method of the class: FontFace{}

No Hooks.

Return

\WP_Error|null. The error if the font family is invalid, null otherwise.

Usage

$result = FontFace::validate_font_face( $font_face );
$font_face(array) (required)
The font face settings.

FontFace::validate_font_face() code WC 9.5.1

private static function validate_font_face( $font_face ) {
	// Validate the font face family name.
	if ( empty( $font_face['fontFamily'] ) ) {
		return new \WP_Error(
			'invalid_font_face_font_family',
			__( 'The font face family name is required.', 'woocommerce' ),
		);
	}

	// Validate the font face font style.
	if ( empty( $font_face['fontStyle'] ) ) {
		return new \WP_Error(
			'invalid_font_face_font_style',
			__( 'The font face font style is required.', 'woocommerce' ),
		);
	}

	// Validate the font face weight.
	if ( empty( $font_face['fontWeight'] ) ) {
		return new \WP_Error(
			'invalid_font_face_font_weight',
			__( 'The font face weight is required.', 'woocommerce' ),
		);
	}

	// Validate the font face src.
	if ( empty( $font_face['src'] ) ) {
		return new \WP_Error(
			'invalid_font_face_src',
			__( 'The font face src is required.', 'woocommerce' ),
		);
	}
}