WP_oEmbed::sanitize_provider
Sanitizes and normalizes a single oEmbed provider entry.
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.
Method of the class: WP_oEmbed{}
No Hooks.
Returns
array{ match_mask: non-empty-string, endpoint: non-empty-string, is_regex: bool }|null. Normalized provider array, or null if malformed.
Usage
// private - for code of main (parent) class only $result = $this->sanitize_provider( $match_mask, $data ): ?array;
- $match_mask(array-key) (required)
- The URL pattern used to match against URLs.
- $data(mixed) (required)
- The raw provider data to sanitize.
Changelog
| Since 7.1.0 | Introduced. |
WP_oEmbed::sanitize_provider() WP oEmbed::sanitize provider code WP 7.1
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;
}