| 2246 | * The YouTube embed handler callback. Catches URLs that can be parsed but aren't supported by oEmbed. |
| 2247 | * |
| 2248 | * @since 4.0.0 |
| 2249 | * |
| 2250 | * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}. |
| 2251 | * @param array $attr Embed attributes. |
| 2252 | * @param string $url The original URL that was matched by the regex. |
| 2253 | * @param array $rawattr The original unmodified attributes. |
| 2254 | * @return string The embed HTML. |
| 2255 | */ |
| 2256 | function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) { |
| 2257 | global $wp_embed; |
| 2258 | $embed = $wp_embed->autoembed( "https://youtube.com/watch?v={$matches[2]}" ); |
| 2259 | /** |
| 2260 | * Filter the YoutTube embed output. |
| 2261 | * |
| 2262 | * @since 4.0.0 |
| 2263 | * |
| 2264 | * @param string $embed YouTube embed output. |
| 2265 | * @param array $attr An array of embed attributes. |
| 2266 | * @param string $url The original URL that was matched by the regex. |
| 2267 | * @param array $rawattr The original unmodified attributes. |
| 2268 | */ |
| 2269 | return apply_filters( 'wp_embed_handler_youtube', $embed, $attr, $url, $rawattr ); |
| 2270 | } |
| 2271 | |
| 2272 | /** |