1 | <?php |
2 | |
3 | /** |
4 | * Default Embed Handlers |
5 | * |
6 | * @package WordPress |
7 | * @subpackage Embeds |
8 | */ |
9 | |
10 | /** |
11 | * The Google Video embed handler callback. Google Video does not support oEmbed. |
12 | * |
13 | * @see WP_Embed::register_handler() |
14 | * @see WP_Embed::shortcode() |
15 | * |
16 | * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}. |
17 | * @param array $attr Embed attributes. |
18 | * @param string $url The original URL that was matched by the regex. |
19 | * @param array $rawattr The original unmodified attributes. |
20 | * @return string The embed HTML. |
21 | */ |
22 | function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) { |
23 | // If the user supplied a fixed width AND height, use it |
24 | if ( !empty($rawattr['width']) && !empty($rawattr['height']) ) { |
25 | $width = (int) $rawattr['width']; |
26 | $height = (int) $rawattr['height']; |
27 | } else { |
28 | list( $width, $height ) = wp_expand_dimensions( 425, 344, $attr['width'], $attr['height'] ); |
29 | } |
30 | |
31 | return apply_filters( 'embed_googlevideo', '<embed type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docid=' . esc_attr($matches[2]) . '&hl=en&fs=true" style="width:' . esc_attr($width) . 'px;height:' . esc_attr($height) . 'px" allowFullScreen="true" allowScriptAccess="always"></embed>', $matches, $attr, $url, $rawattr ); |
32 | } |
33 | wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' ); |
34 | |
35 | ?> |