From 4176aa347e8c062c8dea72bcf60426edd3e94617 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 30 Jun 2014 11:15:33 +0000 Subject: [PATCH] Pass $url parameter to wp_embed_defaults() and 'embed_defaults' filter. props wpsmith, sabreuse, jacobdubail. fixes #20151. git-svn-id: https://develop.svn.wordpress.org/trunk@28923 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-oembed.php | 2 +- src/wp-includes/class-wp-embed.php | 2 +- src/wp-includes/media.php | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/class-oembed.php b/src/wp-includes/class-oembed.php index 363b7c9933..381d3d0d8f 100644 --- a/src/wp-includes/class-oembed.php +++ b/src/wp-includes/class-oembed.php @@ -277,7 +277,7 @@ class WP_oEmbed { * @return bool|object False on failure, otherwise the result in the form of an object. */ public function fetch( $provider, $url, $args = '' ) { - $args = wp_parse_args( $args, wp_embed_defaults() ); + $args = wp_parse_args( $args, wp_embed_defaults( $url ) ); $provider = add_query_arg( 'maxwidth', (int) $args['width'], $provider ); $provider = add_query_arg( 'maxheight', (int) $args['height'], $provider ); diff --git a/src/wp-includes/class-wp-embed.php b/src/wp-includes/class-wp-embed.php index e959d93590..1b849f6f28 100644 --- a/src/wp-includes/class-wp-embed.php +++ b/src/wp-includes/class-wp-embed.php @@ -156,7 +156,7 @@ class WP_Embed { return ''; $rawattr = $attr; - $attr = wp_parse_args( $attr, wp_embed_defaults() ); + $attr = wp_parse_args( $attr, wp_embed_defaults( $url ) ); // kses converts & into & and we need to undo this // See http://core.trac.wordpress.org/ticket/11311 diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index f0e77724ed..e208c52ee3 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -2082,9 +2082,11 @@ function wp_embed_unregister_handler( $id, $priority = 10 ) { * * @since 2.9.0 * + * @param string $url Optional. The URL that should be embedded. Default empty. + * * @return array Default embed parameters. */ -function wp_embed_defaults() { +function wp_embed_defaults( $url = '' ) { if ( ! empty( $GLOBALS['content_width'] ) ) $width = (int) $GLOBALS['content_width']; @@ -2098,10 +2100,11 @@ function wp_embed_defaults() { * * @since 2.9.0 * - * @param int $width Width of the embed in pixels. - * @param int $height Height of the embed in pixels. + * @param int $width Width of the embed in pixels. + * @param int $height Height of the embed in pixels. + * @param string $url The URL that should be embedded. */ - return apply_filters( 'embed_defaults', compact( 'width', 'height' ) ); + return apply_filters( 'embed_defaults', compact( 'width', 'height' ), $url ); } /**