From 8abd17acf2e152e1f96ee7dc0d8633e37e3820bd Mon Sep 17 00:00:00 2001 From: ashubawork Date: Thu, 21 Sep 2023 13:56:11 +0300 Subject: [PATCH] - add the ability to add youtube shorts --- includes/um-short-functions.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index 139fd66e..cebfc9e0 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -1915,6 +1915,9 @@ function um_profile( $key ) { * @return bool */ function um_youtube_id_from_url( $url ) { + $url = preg_replace( '/&ab_channel=.*/', '', $url ); + $url = preg_replace( '/\?si=.*/', '', $url ); + $pattern = '%^# Match any youtube URL (?:https?://)? # Optional scheme. Either http or https @@ -1926,10 +1929,12 @@ function um_youtube_id_from_url( $url ) { /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. $%x'; + $result = preg_match( $pattern, $url, $matches ); if ( false !== $result && isset( $matches[1] ) ) { return $matches[1];