You appear to be a bot. Output may be restricted
Description
Improves YouTube URL
Notes: If the URL is like one of these below http://youtu.be/VIDEO_ID http://www.youtube.com/v/VIDEO_ID http://www.youtube.com/watch?v=HBVPKRW7QBU We replace it with the embed method http://www.youtube.com/embed/VIDEO_ID AND we also Enable privacy-enhanced mode using www.youtube-nocookie.com Unfortunately this method doesn't like &rel=0 when it becomes the first parameter so we need to convert the first & to a ? We also have to convert '&'s back to simple ampersands. Finally, we set the protocol depending on is_ssl() using set_url_scheme();
Usage
$string = _bw_improve_url( $url );
Parameters
- $url
- ( string ) required – the requested URL
Returns
string the improved URL
Source
File name: oik-video/oik-video.inc
Lines:
function _bw_improve_url( $url ) { $url = str_replace( "youtu.be", "www.youtube-nocookie.com/embed/", $url ); $url = str_replace( "watch?v=", "embed/" , $url ); $url = str_replace( "/v/", "/embed/", $url ); $url = str_replace( "youtube.", "youtube-nocookie.", $url ); $url = str_replace( "&", "&", $url ); if ( false === strpos( $url, "?" ) ) { $posamp = strpos( $url, "&" ); if ( $posamp !== false ) { $url[$posamp] = "?"; } } $url = set_url_scheme( $url ); bw_trace2( $url, "url", true, BW_TRACE_VERBOSE ); return( $url ); }