WP_Font_Collection::sanitize_and_validate_data( array $data, array $required_properties = array() ): array|WP_Error

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Sanitizes and validates the font collection data.

Parameters

$dataarrayrequired
Font collection data to sanitize and validate.
$required_propertiesarrayoptional
Required properties that must exist in the passed data.

Default:array()

Return

array|WP_Error Sanitized data if valid, otherwise a WP_Error instance.

Source

private function sanitize_and_validate_data( $data, $required_properties = array() ) {
	$schema = self::get_sanitization_schema();
	$data   = WP_Font_Utils::sanitize_from_schema( $data, $schema );

	foreach ( $required_properties as $property ) {
		if ( empty( $data[ $property ] ) ) {
			$message = sprintf(
				// translators: 1: Font collection slug, 2: Missing property name, e.g. "font_families".
				__( 'Font collection "%1$s" has missing or empty property: "%2$s".' ),
				$this->slug,
				$property
			);
			_doing_it_wrong( __METHOD__, $message, '6.5.0' );
			return new WP_Error( 'font_collection_missing_property', $message );
		}
	}

	return $data;
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.