WP_oEmbed::sanitize_provider( array-key $match_mask, mixed $data ): array{

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

Sanitizes and normalizes a single oEmbed provider entry.

Description

Validates that the match mask is a non-empty string and that the provider data is an array with a non-empty string endpoint URL at index 0. Normalizes the optional regex flag at index 1 to a boolean.

Parameters

$match_maskarray-keyrequired
The URL pattern used to match against URLs.
$datamixedrequired
The raw provider data to sanitize.

Return

array{ match_mask: non-empty-string, endpoint: non-empty-string, is_regex: bool }|null Normalized provider array, or null if malformed.

Source

private function sanitize_provider( $match_mask, $data ): ?array {
	if (
		is_string( $match_mask ) &&
		'' !== $match_mask &&
		is_array( $data ) &&
		isset( $data[0] ) &&
		is_string( $data[0] ) &&
		'' !== $data[0]
	) {
		return array(
			'match_mask' => $match_mask,
			'endpoint'   => $data[0],
			'is_regex'   => (bool) ( $data[1] ?? false ),
		);
	}
	return null;
}

Changelog

VersionDescription
7.1.0Introduced.

User Contributed Notes

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