| | 1357 | * Audio embed handler callback. |
| | 1358 | * |
| | 1359 | * @since 3.6.0 |
| | 1360 | * |
| | 1361 | * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}. |
| | 1362 | * @param array $attr Embed attributes. |
| | 1363 | * @param string $url The original URL that was matched by the regex. |
| | 1364 | * @param array $rawattr The original unmodified attributes. |
| | 1365 | * @return string The embed HTML. |
| | 1366 | */ |
| | 1367 | function wp_embed_handler_audio( $matches, $attr, $url, $rawattr ) { |
| | 1368 | $audio = $url; |
| | 1369 | if ( shortcode_exists( 'audio' ) ) |
| | 1370 | $audio = do_shortcode( '[audio src="' . $url . '" /]' ); |
| | 1371 | return apply_filters( 'wp_embed_handler_audio', $audio, $attr, $url, $rawattr ); |
| | 1372 | } |
| | 1373 | |
| | 1374 | /** |
| | 1375 | * Video embed handler callback. |
| | 1376 | * |
| | 1377 | * @since 3.6.0 |
| | 1378 | * |
| | 1379 | * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}. |
| | 1380 | * @param array $attr Embed attributes. |
| | 1381 | * @param string $url The original URL that was matched by the regex. |
| | 1382 | * @param array $rawattr The original unmodified attributes. |
| | 1383 | * @return string The embed HTML. |
| | 1384 | */ |
| | 1385 | function wp_embed_handler_video( $matches, $attr, $url, $rawattr ) { |
| | 1386 | $dimensions = ''; |
| | 1387 | $video = $url; |
| | 1388 | if ( shortcode_exists( 'video' ) ) { |
| | 1389 | if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) { |
| | 1390 | $dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] ); |
| | 1391 | $dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] ); |
| | 1392 | } elseif ( strstr( $url, home_url() ) ) { |
| | 1393 | $id = attachment_url_to_postid( $url ); |
| | 1394 | if ( ! empty( $id ) ) { |
| | 1395 | $meta = wp_get_attachment_metadata( $id ); |
| | 1396 | if ( ! empty( $meta['width'] ) ) |
| | 1397 | $dimensions .= sprintf( 'width="%d" ', (int) $meta['width'] ); |
| | 1398 | if ( ! empty( $meta['height'] ) ) |
| | 1399 | $dimensions .= sprintf( 'height="%d" ', (int) $meta['height'] ); |
| | 1400 | } |
| | 1401 | } |
| | 1402 | $video = do_shortcode( '[video ' . $dimensions . 'src="' . $url . '" /]' ); |
| | 1403 | } |
| | 1404 | return apply_filters( 'wp_embed_handler_video', $video, $attr, $url, $rawattr ); |
| | 1405 | } |
| | 1406 | |
| | 1407 | /** |
| 1998 | | * Audio embed handler callback. |
| 1999 | | * |
| 2000 | | * @since 3.6.0 |
| 2001 | | * |
| 2002 | | * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}. |
| 2003 | | * @param array $attr Embed attributes. |
| 2004 | | * @param string $url The original URL that was matched by the regex. |
| 2005 | | * @param array $rawattr The original unmodified attributes. |
| 2006 | | * @return string The embed HTML. |
| 2007 | | */ |
| 2008 | | function wp_audio_embed( $matches, $attr, $url, $rawattr ) { |
| 2009 | | $audio = $url; |
| 2010 | | if ( shortcode_exists( 'audio' ) ) |
| 2011 | | $audio = do_shortcode( '[audio src="' . $url . '" /]' ); |
| 2012 | | return apply_filters( 'wp_audio_embed', $audio, $attr, $url, $rawattr ); |
| 2013 | | } |
| 2014 | | wp_embed_register_handler( 'wp_audio_embed', '#https?://.+?\.(' . join( '|', wp_get_audio_extensions() ) . ')#i', apply_filters( 'wp_audio_embed_handler', 'wp_audio_embed' ), 9999 ); |
| 2015 | | |
| 2016 | | /** |
| 2017 | | * Video embed handler callback. |
| 2018 | | * |
| 2019 | | * @since 3.6.0 |
| 2020 | | * |
| 2021 | | * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}. |
| 2022 | | * @param array $attr Embed attributes. |
| 2023 | | * @param string $url The original URL that was matched by the regex. |
| 2024 | | * @param array $rawattr The original unmodified attributes. |
| 2025 | | * @return string The embed HTML. |
| 2026 | | */ |
| 2027 | | function wp_video_embed( $matches, $attr, $url, $rawattr ) { |
| 2028 | | $dimensions = ''; |
| 2029 | | $video = $url; |
| 2030 | | if ( shortcode_exists( 'video' ) ) { |
| 2031 | | if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) { |
| 2032 | | $dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] ); |
| 2033 | | $dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] ); |
| 2034 | | } elseif ( strstr( $url, home_url() ) ) { |
| 2035 | | $id = attachment_url_to_postid( $url ); |
| 2036 | | if ( ! empty( $id ) ) { |
| 2037 | | $meta = wp_get_attachment_metadata( $id ); |
| 2038 | | if ( ! empty( $meta['width'] ) ) |
| 2039 | | $dimensions .= sprintf( 'width="%d" ', (int) $meta['width'] ); |
| 2040 | | if ( ! empty( $meta['height'] ) ) |
| 2041 | | $dimensions .= sprintf( 'height="%d" ', (int) $meta['height'] ); |
| 2042 | | } |
| 2043 | | } |
| 2044 | | $video = do_shortcode( '[video ' . $dimensions . 'src="' . $url . '" /]' ); |
| 2045 | | } |
| 2046 | | return apply_filters( 'wp_video_embed', $video, $attr, $url, $rawattr ); |
| 2047 | | } |
| 2048 | | wp_embed_register_handler( 'wp_video_embed', '#https?://.+?\.(' . join( '|', wp_get_video_extensions() ) . ')#i', apply_filters( 'wp_video_embed_handler', 'wp_video_embed' ), 9999 ); |
| 2049 | | |
| 2050 | | /** |