From ca451ee1a960ebce2814d2b9114bf6931417e994 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 28 Apr 2011 17:03:23 +0000 Subject: [PATCH] Remove default-embeds.php. fixes #17112. git-svn-id: https://develop.svn.wordpress.org/trunk@17751 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/default-embeds.php | 35 ---------------------------- wp-includes/functions.php | 14 ------------ wp-includes/media.php | 42 +++++++++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 50 deletions(-) delete mode 100644 wp-includes/default-embeds.php diff --git a/wp-includes/default-embeds.php b/wp-includes/default-embeds.php deleted file mode 100644 index ca599445a5..0000000000 --- a/wp-includes/default-embeds.php +++ /dev/null @@ -1,35 +0,0 @@ -', $matches, $attr, $url, $rawattr ); -} -wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' ); - -?> \ No newline at end of file diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 8d0426a60d..5dc9c12759 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3196,20 +3196,6 @@ function wp_list_pluck( $list, $field ) { return $list; } -/** - * Determines if default embed handlers should be loaded. - * - * Checks to make sure that the embeds library hasn't already been loaded. If - * it hasn't, then it will load the embeds library. - * - * @since 2.9.0 - */ -function wp_maybe_load_embeds() { - if ( ! apply_filters('load_default_embeds', true) ) - return; - require_once( ABSPATH . WPINC . '/default-embeds.php' ); -} - /** * Determines if Widgets library should be loaded. * diff --git a/wp-includes/media.php b/wp-includes/media.php index 9418a50c4a..f4e60d00d8 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1398,4 +1398,44 @@ function wp_oembed_add_provider( $format, $provider, $regex = false ) { require_once( ABSPATH . WPINC . '/class-oembed.php' ); $oembed = _wp_oembed_get_object(); $oembed->providers[$format] = array( $provider, $regex ); -} \ No newline at end of file +} + +/** + * Determines if default embed handlers should be loaded. + * + * Checks to make sure that the embeds library hasn't already been loaded. If + * it hasn't, then it will load the embeds library. + * + * @since 2.9.0 + */ +function wp_maybe_load_embeds() { + if ( ! apply_filters( 'load_default_embeds', true ) ) + return; + wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' ); +} + +/** + * The Google Video embed handler callback. Google Video does not support oEmbed. + * + * @see WP_Embed::register_handler() + * @see WP_Embed::shortcode() + * + * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}. + * @param array $attr Embed attributes. + * @param string $url The original URL that was matched by the regex. + * @param array $rawattr The original unmodified attributes. + * @return string The embed HTML. + */ +function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) { + // If the user supplied a fixed width AND height, use it + if ( !empty($rawattr['width']) && !empty($rawattr['height']) ) { + $width = (int) $rawattr['width']; + $height = (int) $rawattr['height']; + } else { + list( $width, $height ) = wp_expand_dimensions( 425, 344, $attr['width'], $attr['height'] ); + } + + return apply_filters( 'embed_googlevideo', '', $matches, $attr, $url, $rawattr ); +} + +?> \ No newline at end of file