mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
- fixed YouTube link validation
This commit is contained in:
@@ -1918,20 +1918,24 @@ function um_youtube_id_from_url( $url ) {
|
||||
$url = preg_replace( '/\?si=.*/', '', $url ); // referral attribute.
|
||||
|
||||
$pattern =
|
||||
'%^# Match any youtube URL
|
||||
(?:https?://)? # Optional scheme. Either http or https
|
||||
(?:www\.)? # Optional www subdomain
|
||||
(?: # Group host alternatives
|
||||
youtu\.be/ # Either youtu.be,
|
||||
| youtube\.com # or youtube.com
|
||||
(?: # Group path alternatives
|
||||
/embed/ # Either /embed/
|
||||
| /v/ # or /v/
|
||||
| /watch\?v= # or /watch\?v=
|
||||
| /shorts/ # or /shorts/ for short videos
|
||||
) # End path alternatives.
|
||||
) # End host alternatives.
|
||||
([\w-]{10,12}) # Allow 10-12 for 11 char youtube id.
|
||||
'%^ # Match any youtube URL
|
||||
(?:https?://)? # Optional scheme. Either http or https
|
||||
(?:www\.)? # Optional www subdomain
|
||||
(?: # Group host alternatives
|
||||
youtu\.be/ # Either youtu.be,
|
||||
| youtube\.com # or youtube.com
|
||||
(?: # Group path alternatives
|
||||
/embed/ # Either /embed/
|
||||
| /v/ # or /v/
|
||||
| /watch\?v= # or /watch\?v=
|
||||
| /shorts/ # or /shorts/ for short videos
|
||||
) # End path alternatives.
|
||||
) # End host alternatives.
|
||||
([\w-]{10,12}) # Allow 10-12 for 11 char youtube id.
|
||||
(?: # Additional parameters
|
||||
(?:\?|\&)
|
||||
\w+=[^&$]+
|
||||
)*
|
||||
$%x';
|
||||
|
||||
$result = preg_match( $pattern, $url, $matches );
|
||||
|
||||
Reference in New Issue
Block a user