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.
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
| Version | Description |
|---|---|
| 7.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.