From fbd0b570fc4ce86406f8f16a09aefa5e6504d456 Mon Sep 17 00:00:00 2001
From: Sergey Biryukov
Date: Sat, 31 Oct 2015 15:50:23 +0000
Subject: [PATCH] Embeds: In `get_post_embed_html()`, move the optional `$post`
argument after the required `$width` and `$height`.
Props swissspidy.
Fixes #34523.
git-svn-id: https://develop.svn.wordpress.org/trunk@35472 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/embed-functions.php | 6 +++---
src/wp-includes/embed-template.php | 2 +-
tests/phpunit/tests/oembed/getResponseData.php | 4 ++--
tests/phpunit/tests/oembed/template.php | 6 +++---
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/wp-includes/embed-functions.php b/src/wp-includes/embed-functions.php
index b3eb6528f2..ba8b08df57 100644
--- a/src/wp-includes/embed-functions.php
+++ b/src/wp-includes/embed-functions.php
@@ -446,12 +446,12 @@ function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) {
*
* @since 4.4.0
*
- * @param int|WP_Post $post Optional. Post ID or object. Default is global `$post`.
* @param int $width The width for the response.
* @param int $height The height for the response.
+ * @param int|WP_Post $post Optional. Post ID or object. Default is global `$post`.
* @return string|false Embed code on success, false if post doesn't exist.
*/
-function get_post_embed_html( $post = null, $width, $height ) {
+function get_post_embed_html( $width, $height, $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
@@ -590,7 +590,7 @@ function get_oembed_response_data_rich( $data, $post, $width, $height ) {
$data['width'] = absint( $width );
$data['height'] = absint( $height );
$data['type'] = 'rich';
- $data['html'] = get_post_embed_html( $post, $width, $height );
+ $data['html'] = get_post_embed_html( $width, $height, $post );
// Add post thumbnail to response if available.
$thumbnail_id = false;
diff --git a/src/wp-includes/embed-template.php b/src/wp-includes/embed-template.php
index 120ae3b37e..5af9cb6e30 100644
--- a/src/wp-includes/embed-template.php
+++ b/src/wp-includes/embed-template.php
@@ -184,7 +184,7 @@ if ( have_posts() ) :
-
+
diff --git a/tests/phpunit/tests/oembed/getResponseData.php b/tests/phpunit/tests/oembed/getResponseData.php
index 6dcdcbd1bf..4a5c4f7d8e 100644
--- a/tests/phpunit/tests/oembed/getResponseData.php
+++ b/tests/phpunit/tests/oembed/getResponseData.php
@@ -25,7 +25,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
'type' => 'rich',
'width' => 400,
'height' => 225,
- 'html' => get_post_embed_html( $post, 400, 225 ),
+ 'html' => get_post_embed_html( 400, 225, $post ),
), $data );
}
@@ -54,7 +54,7 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
'type' => 'rich',
'width' => 400,
'height' => 225,
- 'html' => get_post_embed_html( $post, 400, 225 ),
+ 'html' => get_post_embed_html( 400, 225, $post ),
), $data );
}
diff --git a/tests/phpunit/tests/oembed/template.php b/tests/phpunit/tests/oembed/template.php
index 644a6d52b6..ca07035b23 100644
--- a/tests/phpunit/tests/oembed/template.php
+++ b/tests/phpunit/tests/oembed/template.php
@@ -236,8 +236,8 @@ class Tests_Embed_Template extends WP_UnitTestCase {
}
function test_get_post_embed_html_non_existent_post() {
- $this->assertFalse( get_post_embed_html( 0, 200, 200 ) );
- $this->assertFalse( get_post_embed_html( null, 200, 200 ) );
+ $this->assertFalse( get_post_embed_html( 200, 200, 0 ) );
+ $this->assertFalse( get_post_embed_html( 200, 200 ) );
}
function test_get_post_embed_html() {
@@ -245,7 +245,7 @@ class Tests_Embed_Template extends WP_UnitTestCase {
$expected = '';
- $this->assertStringEndsWith( $expected, get_post_embed_html( $post_id, 200, 200 ) );
+ $this->assertStringEndsWith( $expected, get_post_embed_html( 200, 200, $post_id ) );
}
function test_add_host_js() {