Make WordPress Core

Changeset 35408


Ignore:
Timestamp:
10/27/2015 08:43:00 PM (9 years ago)
Author:
ocean90
Message:

Embeds: Replace hardcoded error messages with get_status_header_desc( $http_code ).

Fixes #34275.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-oembed-controller.php

    r35354 r35408  
    3333        if ( false === $wp_query->get( 'url', false ) ) {
    3434            status_header( 400 );
    35             echo 'URL parameter missing';
     35            return get_status_header_desc( 400 );
    3636            exit;
    3737        }
     
    8989        if ( false === $data ) {
    9090            status_header( 404 );
    91             return __( 'Invalid URL.' );
     91            return get_status_header_desc( 404 );
    9292        }
    9393
     
    118118        if ( ! $result || ! is_array( $data ) || empty( $data ) ) {
    119119            status_header( 501 );
    120             return 'Not implemented';
     120            return get_status_header_desc( 501 );
    121121        }
    122122
  • trunk/tests/phpunit/tests/oembed/controller.php

    r35354 r35408  
    1414        $legacy_controller = new WP_oEmbed_Controller();
    1515
    16         $this->assertEquals( 'Invalid URL.', $legacy_controller->dispatch( $request ) );
     16        $this->assertEquals( get_status_header_desc( 404 ), $legacy_controller->dispatch( $request ) );
    1717    }
    1818
     
    2828        // WP_Query arguments.
    2929        $request = array(
    30             'url'     => get_permalink( $post->ID ),
     30            'url'      => get_permalink( $post->ID ),
    3131            'format'   => 'json',
    3232            'maxwidth' => 400,
     
    7070
    7171        $request = array(
    72             'url'     => get_permalink( $post->ID ),
     72            'url'      => get_permalink( $post->ID ),
    7373            'format'   => 'json',
    7474            'maxwidth' => 600,
     
    9393
    9494        $request = array(
    95             'url'     => get_permalink( $post->ID ),
     95            'url'      => get_permalink( $post->ID ),
    9696            'format'   => 'json',
    9797            'maxwidth' => 600,
     
    113113        $legacy_controller = new WP_oEmbed_Controller();
    114114
    115         $this->assertEquals( 'Not implemented', $legacy_controller->json_response( null, $request ) );
    116         $this->assertEquals( 'Not implemented', $legacy_controller->json_response( 123, $request ) );
    117         $this->assertEquals( 'Not implemented', $legacy_controller->json_response( array(), $request ) );
     115        $this->assertEquals( get_status_header_desc( 501 ), $legacy_controller->json_response( null, $request ) );
     116        $this->assertEquals( get_status_header_desc( 501 ), $legacy_controller->json_response( 123, $request ) );
     117        $this->assertEquals( get_status_header_desc( 501 ), $legacy_controller->json_response( array(), $request ) );
    118118    }
    119119
Note: See TracChangeset for help on using the changeset viewer.