web/wp-includes/default-embeds.php
author ymh
Fri, 12 Mar 2010 13:29:04 +0000
changeset 1 0d28b7c10758
permissions -rw-r--r--
First commit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
0d28b7c10758 First commit
ymh
parents:
diff changeset
     1
<?php
0d28b7c10758 First commit
ymh
parents:
diff changeset
     2
0d28b7c10758 First commit
ymh
parents:
diff changeset
     3
/**
0d28b7c10758 First commit
ymh
parents:
diff changeset
     4
 * Default Embed Handlers
0d28b7c10758 First commit
ymh
parents:
diff changeset
     5
 *
0d28b7c10758 First commit
ymh
parents:
diff changeset
     6
 * @package WordPress
0d28b7c10758 First commit
ymh
parents:
diff changeset
     7
 * @subpackage Embeds
0d28b7c10758 First commit
ymh
parents:
diff changeset
     8
 */
0d28b7c10758 First commit
ymh
parents:
diff changeset
     9
0d28b7c10758 First commit
ymh
parents:
diff changeset
    10
/**
0d28b7c10758 First commit
ymh
parents:
diff changeset
    11
 * The Google Video embed handler callback. Google Video does not support oEmbed.
0d28b7c10758 First commit
ymh
parents:
diff changeset
    12
 *
0d28b7c10758 First commit
ymh
parents:
diff changeset
    13
 * @see WP_Embed::register_handler()
0d28b7c10758 First commit
ymh
parents:
diff changeset
    14
 * @see WP_Embed::shortcode()
0d28b7c10758 First commit
ymh
parents:
diff changeset
    15
 *
0d28b7c10758 First commit
ymh
parents:
diff changeset
    16
 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
0d28b7c10758 First commit
ymh
parents:
diff changeset
    17
 * @param array $attr Embed attributes.
0d28b7c10758 First commit
ymh
parents:
diff changeset
    18
 * @param string $url The original URL that was matched by the regex.
0d28b7c10758 First commit
ymh
parents:
diff changeset
    19
 * @param array $rawattr The original unmodified attributes.
0d28b7c10758 First commit
ymh
parents:
diff changeset
    20
 * @return string The embed HTML.
0d28b7c10758 First commit
ymh
parents:
diff changeset
    21
 */
0d28b7c10758 First commit
ymh
parents:
diff changeset
    22
function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    23
	// If the user supplied a fixed width AND height, use it
0d28b7c10758 First commit
ymh
parents:
diff changeset
    24
	if ( !empty($rawattr['width']) && !empty($rawattr['height']) ) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    25
		$width  = (int) $rawattr['width'];
0d28b7c10758 First commit
ymh
parents:
diff changeset
    26
		$height = (int) $rawattr['height'];
0d28b7c10758 First commit
ymh
parents:
diff changeset
    27
	} else {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    28
		list( $width, $height ) = wp_expand_dimensions( 425, 344, $attr['width'], $attr['height'] );
0d28b7c10758 First commit
ymh
parents:
diff changeset
    29
	}
0d28b7c10758 First commit
ymh
parents:
diff changeset
    30
0d28b7c10758 First commit
ymh
parents:
diff changeset
    31
	return apply_filters( 'embed_googlevideo', '<embed type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docid=' . esc_attr($matches[2]) . '&amp;hl=en&amp;fs=true" style="width:' . esc_attr($width) . 'px;height:' . esc_attr($height) . 'px" allowFullScreen="true" allowScriptAccess="always"></embed>', $matches, $attr, $url, $rawattr );
0d28b7c10758 First commit
ymh
parents:
diff changeset
    32
}
0d28b7c10758 First commit
ymh
parents:
diff changeset
    33
wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' );
0d28b7c10758 First commit
ymh
parents:
diff changeset
    34
0d28b7c10758 First commit
ymh
parents:
diff changeset
    35
/**
0d28b7c10758 First commit
ymh
parents:
diff changeset
    36
 * The PollDaddy.com embed handler callback. PollDaddy does not support oEmbed, at least not yet.
0d28b7c10758 First commit
ymh
parents:
diff changeset
    37
 *
0d28b7c10758 First commit
ymh
parents:
diff changeset
    38
 * @see WP_Embed::register_handler()
0d28b7c10758 First commit
ymh
parents:
diff changeset
    39
 * @see WP_Embed::shortcode()
0d28b7c10758 First commit
ymh
parents:
diff changeset
    40
 *
0d28b7c10758 First commit
ymh
parents:
diff changeset
    41
 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
0d28b7c10758 First commit
ymh
parents:
diff changeset
    42
 * @param array $attr Embed attributes.
0d28b7c10758 First commit
ymh
parents:
diff changeset
    43
 * @param string $url The original URL that was matched by the regex.
0d28b7c10758 First commit
ymh
parents:
diff changeset
    44
 * @param array $rawattr The original unmodified attributes.
0d28b7c10758 First commit
ymh
parents:
diff changeset
    45
 * @return string The embed HTML.
0d28b7c10758 First commit
ymh
parents:
diff changeset
    46
 */
0d28b7c10758 First commit
ymh
parents:
diff changeset
    47
function wp_embed_handler_polldaddy( $matches, $attr, $url, $rawattr ) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    48
	return apply_filters( 'embed_polldaddy', '<script type="text/javascript" charset="utf8" src="http://s3.polldaddy.com/p/' . esc_attr($matches[1]) . '"></script>', $matches, $attr, $url, $rawattr );
0d28b7c10758 First commit
ymh
parents:
diff changeset
    49
}
0d28b7c10758 First commit
ymh
parents:
diff changeset
    50
wp_embed_register_handler( 'polldaddy', '#http://answers.polldaddy.com/poll/(\d+)(.*?)#i', 'wp_embed_handler_polldaddy' );
0d28b7c10758 First commit
ymh
parents:
diff changeset
    51
0d28b7c10758 First commit
ymh
parents:
diff changeset
    52
?>