Make WordPress Core

Ticket #34523: 34523.2.diff

File 34523.2.diff, 5.2 KB (added by swissspidy, 11 years ago)
  • src/wp-includes/class-wp-oembed-controller.php

    diff --git src/wp-includes/class-wp-oembed-controller.php src/wp-includes/class-wp-oembed-controller.php
    index 0db5340..409cf18 100644
    final class WP_oEmbed_Controller { 
    6767                $post_id = url_to_postid( $request['url'] );
    6868
    6969                /**
    70                  * Filter the determined post id.
     70                 * Filter the determined post ID.
    7171                 *
    7272                 * @since 4.4.0
    7373                 *
    7474                 * @param int    $post_id The post ID.
    75                  * @param string $url     The requestd URL.
     75                 * @param string $url     The requested URL.
    7676                 */
    7777                $post_id = apply_filters( 'oembed_request_post_id', $post_id, $request['url'] );
    7878
  • src/wp-includes/embed-functions.php

    diff --git src/wp-includes/embed-functions.php src/wp-includes/embed-functions.php
    index 2f430b5..ba8b08d 100644
    function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) { 
    446446 *
    447447 * @since 4.4.0
    448448 *
    449  * @param int|WP_Post $post   Optional. Post ID or object. Default is global `$post`.
    450449 * @param int         $width  The width for the response.
    451450 * @param int         $height The height for the response.
     451 * @param int|WP_Post $post   Optional. Post ID or object. Default is global `$post`.
    452452 * @return string|false Embed code on success, false if post doesn't exist.
    453453 */
    454 function get_post_embed_html( $post = null, $width, $height ) {
     454function get_post_embed_html( $width, $height, $post = null ) {
    455455        $post = get_post( $post );
    456456
    457457        if ( ! $post ) {
    JS; 
    510510 *
    511511 * @since 4.4.0
    512512 *
    513  * @param WP_Post|int $post  Optional. Post object or ID. Default is global `$post`.
     513 * @param WP_Post|int $post  Post object or ID.
    514514 * @param int         $width The requested width.
    515515 * @return array|false Response data on success, false if post doesn't exist.
    516516 */
    517 function get_oembed_response_data( $post = null, $width ) {
     517function get_oembed_response_data( $post, $width ) {
    518518        $post = get_post( $post );
    519519
    520520        if ( ! $post ) {
    function get_oembed_response_data_rich( $data, $post, $width, $height ) { 
    590590        $data['width']  = absint( $width );
    591591        $data['height'] = absint( $height );
    592592        $data['type']   = 'rich';
    593         $data['html']   = get_post_embed_html( $post, $width, $height );
     593        $data['html']   = get_post_embed_html( $width, $height, $post );
    594594
    595595        // Add post thumbnail to response if available.
    596596        $thumbnail_id = false;
  • src/wp-includes/embed-template.php

    diff --git src/wp-includes/embed-template.php src/wp-includes/embed-template.php
    index 120ae3b..5af9cb6 100644
    if ( have_posts() ) : 
    184184                                                        </p>
    185185                                                </div>
    186186                                                <div id="wp-embed-share-tab-html" class="wp-embed-share-tab" role="tabpanel" aria-labelledby="wp-embed-share-tab-button-html" aria-hidden="true">
    187                                                         <textarea class="wp-embed-share-input" tabindex="0" readonly><?php echo esc_textarea( get_post_embed_html( null, 600, 400 ) ); ?></textarea>
     187                                                        <textarea class="wp-embed-share-input" tabindex="0" readonly><?php echo esc_textarea( get_post_embed_html( 600, 400 ) ); ?></textarea>
    188188
    189189                                                        <p class="wp-embed-share-description">
    190190                                                                <?php _e( 'Copy and paste this code into your site to embed' ); ?>
  • tests/phpunit/tests/oembed/getResponseData.php

    diff --git tests/phpunit/tests/oembed/getResponseData.php tests/phpunit/tests/oembed/getResponseData.php
    index 6dcdcbd..4a5c4f7 100644
    class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    2525                        'type'          => 'rich',
    2626                        'width'         => 400,
    2727                        'height'        => 225,
    28                         'html'          => get_post_embed_html( $post, 400, 225 ),
     28                        'html'          => get_post_embed_html( 400, 225, $post ),
    2929                ), $data );
    3030        }
    3131
    class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    5454                        'type'          => 'rich',
    5555                        'width'         => 400,
    5656                        'height'        => 225,
    57                         'html'          => get_post_embed_html( $post, 400, 225 ),
     57                        'html'          => get_post_embed_html( 400, 225, $post ),
    5858                ), $data );
    5959        }
    6060
  • tests/phpunit/tests/oembed/template.php

    diff --git tests/phpunit/tests/oembed/template.php tests/phpunit/tests/oembed/template.php
    index 644a6d5..ca07035 100644
    class Tests_Embed_Template extends WP_UnitTestCase { 
    236236        }
    237237
    238238        function test_get_post_embed_html_non_existent_post() {
    239                 $this->assertFalse( get_post_embed_html( 0, 200, 200 ) );
    240                 $this->assertFalse( get_post_embed_html( null, 200, 200 ) );
     239                $this->assertFalse( get_post_embed_html( 200, 200, 0 ) );
     240                $this->assertFalse( get_post_embed_html( 200, 200 ) );
    241241        }
    242242
    243243        function test_get_post_embed_html() {
    class Tests_Embed_Template extends WP_UnitTestCase { 
    245245
    246246                $expected = '<iframe sandbox="allow-scripts" security="restricted" src="' . esc_url( get_post_embed_url( $post_id ) ) . '" width="200" height="200" title="Embedded WordPress Post" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>';
    247247
    248                 $this->assertStringEndsWith( $expected, get_post_embed_html( $post_id, 200, 200 ) );
     248                $this->assertStringEndsWith( $expected, get_post_embed_html( 200, 200, $post_id ) );
    249249        }
    250250
    251251        function test_add_host_js() {