youtube_link

Replaces plain-text links to YouTube videos with YouTube embeds.

Description

(string) youtube_link( (string) $content ); 

Returns (string)

The content with embeds instead of URLs

Parameters (1)

0. $content (string)
The content.

Usage

  1. if ( !function_exists( 'youtube_link' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/shortcodes/youtube.php'; 
  3.  
  4. // The content. 
  5. $content = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = youtube_link($content); 
  9.  

Defined (1)

The function is defined in the following location(s).

/modules/shortcodes/youtube.php  
  1. function youtube_link( $content ) { 
  2. return preg_replace_callback( '!(?:\n|\A)https?://(?:www\.)?(?:youtube.com/(?:v/|playlist|watch[/\#?])|youtu\.be/)[^\s]+?(?:\n|\Z)!i', 'youtube_link_callback', $content );