Make WordPress Core

Changeset 35472


Ignore:
Timestamp:
10/31/2015 03:50:23 PM (11 years ago)
Author:
SergeyBiryukov
Message:

Embeds: In get_post_embed_html(), move the optional $post argument after the required $width and $height.

Props swissspidy.
Fixes #34523.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/embed-functions.php

    r35471 r35472  
    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
     
    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.
  • trunk/src/wp-includes/embed-template.php

    r35466 r35472  
    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">
  • trunk/tests/phpunit/tests/oembed/getResponseData.php

    r35242 r35472  
    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    }
     
    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    }
  • trunk/tests/phpunit/tests/oembed/template.php

    r35436 r35472  
    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
     
    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
Note: See TracChangeset for help on using the changeset viewer.