diff --git a/src/wp-includes/class-wp-oembed-controller.php b/src/wp-includes/class-wp-oembed-controller.php index 22c062be9f..a613d0616d 100644 --- a/src/wp-includes/class-wp-oembed-controller.php +++ b/src/wp-includes/class-wp-oembed-controller.php @@ -32,7 +32,7 @@ final class WP_oEmbed_Controller { if ( false === $wp_query->get( 'url', false ) ) { status_header( 400 ); - echo 'URL parameter missing'; + return get_status_header_desc( 400 ); exit; } @@ -88,7 +88,7 @@ final class WP_oEmbed_Controller { if ( false === $data ) { status_header( 404 ); - return __( 'Invalid URL.' ); + return get_status_header_desc( 404 ); } if ( 'json' === $request['format'] ) { @@ -117,7 +117,7 @@ final class WP_oEmbed_Controller { // Bail if the result couldn't be JSON encoded. if ( ! $result || ! is_array( $data ) || empty( $data ) ) { status_header( 501 ); - return 'Not implemented'; + return get_status_header_desc( 501 ); } if ( ! headers_sent() ) { diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php index 34ce7dd4ee..51c6302c32 100644 --- a/tests/phpunit/tests/oembed/controller.php +++ b/tests/phpunit/tests/oembed/controller.php @@ -13,7 +13,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $legacy_controller = new WP_oEmbed_Controller(); - $this->assertEquals( 'Invalid URL.', $legacy_controller->dispatch( $request ) ); + $this->assertEquals( get_status_header_desc( 404 ), $legacy_controller->dispatch( $request ) ); } function test_request_json() { @@ -27,7 +27,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { // WP_Query arguments. $request = array( - 'url' => get_permalink( $post->ID ), + 'url' => get_permalink( $post->ID ), 'format' => 'json', 'maxwidth' => 400, 'callback' => '', @@ -69,7 +69,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { ) ); $request = array( - 'url' => get_permalink( $post->ID ), + 'url' => get_permalink( $post->ID ), 'format' => 'json', 'maxwidth' => 600, 'callback' => 'mycallback', @@ -92,7 +92,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { ) ); $request = array( - 'url' => get_permalink( $post->ID ), + 'url' => get_permalink( $post->ID ), 'format' => 'json', 'maxwidth' => 600, 'callback' => array( 'foo', 'bar' ), @@ -112,9 +112,9 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $legacy_controller = new WP_oEmbed_Controller(); - $this->assertEquals( 'Not implemented', $legacy_controller->json_response( null, $request ) ); - $this->assertEquals( 'Not implemented', $legacy_controller->json_response( 123, $request ) ); - $this->assertEquals( 'Not implemented', $legacy_controller->json_response( array(), $request ) ); + $this->assertEquals( get_status_header_desc( 501 ), $legacy_controller->json_response( null, $request ) ); + $this->assertEquals( get_status_header_desc( 501 ), $legacy_controller->json_response( 123, $request ) ); + $this->assertEquals( get_status_header_desc( 501 ), $legacy_controller->json_response( array(), $request ) ); } function test_request_xml() {