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 { |
| 67 | 67 | $post_id = url_to_postid( $request['url'] ); |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | | * Filter the determined post id. |
| | 70 | * Filter the determined post ID. |
| 71 | 71 | * |
| 72 | 72 | * @since 4.4.0 |
| 73 | 73 | * |
| 74 | 74 | * @param int $post_id The post ID. |
| 75 | | * @param string $url The requestd URL. |
| | 75 | * @param string $url The requested URL. |
| 76 | 76 | */ |
| 77 | 77 | $post_id = apply_filters( 'oembed_request_post_id', $post_id, $request['url'] ); |
| 78 | 78 | |
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' ) { |
| 446 | 446 | * |
| 447 | 447 | * @since 4.4.0 |
| 448 | 448 | * |
| 449 | | * @param int|WP_Post $post Optional. Post ID or object. Default is global `$post`. |
| 450 | 449 | * @param int $width The width for the response. |
| 451 | 450 | * @param int $height The height for the response. |
| | 451 | * @param int|WP_Post $post Optional. Post ID or object. Default is global `$post`. |
| 452 | 452 | * @return string|false Embed code on success, false if post doesn't exist. |
| 453 | 453 | */ |
| 454 | | function get_post_embed_html( $post = null, $width, $height ) { |
| | 454 | function get_post_embed_html( $width, $height, $post = null ) { |
| 455 | 455 | $post = get_post( $post ); |
| 456 | 456 | |
| 457 | 457 | if ( ! $post ) { |
| … |
… |
JS; |
| 510 | 510 | * |
| 511 | 511 | * @since 4.4.0 |
| 512 | 512 | * |
| 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. |
| 514 | 514 | * @param int $width The requested width. |
| 515 | 515 | * @return array|false Response data on success, false if post doesn't exist. |
| 516 | 516 | */ |
| 517 | | function get_oembed_response_data( $post = null, $width ) { |
| | 517 | function get_oembed_response_data( $post, $width ) { |
| 518 | 518 | $post = get_post( $post ); |
| 519 | 519 | |
| 520 | 520 | if ( ! $post ) { |
| … |
… |
function get_oembed_response_data_rich( $data, $post, $width, $height ) { |
| 590 | 590 | $data['width'] = absint( $width ); |
| 591 | 591 | $data['height'] = absint( $height ); |
| 592 | 592 | $data['type'] = 'rich'; |
| 593 | | $data['html'] = get_post_embed_html( $post, $width, $height ); |
| | 593 | $data['html'] = get_post_embed_html( $width, $height, $post ); |
| 594 | 594 | |
| 595 | 595 | // Add post thumbnail to response if available. |
| 596 | 596 | $thumbnail_id = false; |
diff --git src/wp-includes/embed-template.php src/wp-includes/embed-template.php
index 120ae3b..5af9cb6 100644
|
|
|
if ( have_posts() ) : |
| 184 | 184 | </p> |
| 185 | 185 | </div> |
| 186 | 186 | <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> |
| 188 | 188 | |
| 189 | 189 | <p class="wp-embed-share-description"> |
| 190 | 190 | <?php _e( 'Copy and paste this code into your site to embed' ); ?> |
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 { |
| 25 | 25 | 'type' => 'rich', |
| 26 | 26 | 'width' => 400, |
| 27 | 27 | 'height' => 225, |
| 28 | | 'html' => get_post_embed_html( $post, 400, 225 ), |
| | 28 | 'html' => get_post_embed_html( 400, 225, $post ), |
| 29 | 29 | ), $data ); |
| 30 | 30 | } |
| 31 | 31 | |
| … |
… |
class Tests_oEmbed_Response_Data extends WP_UnitTestCase { |
| 54 | 54 | 'type' => 'rich', |
| 55 | 55 | 'width' => 400, |
| 56 | 56 | 'height' => 225, |
| 57 | | 'html' => get_post_embed_html( $post, 400, 225 ), |
| | 57 | 'html' => get_post_embed_html( 400, 225, $post ), |
| 58 | 58 | ), $data ); |
| 59 | 59 | } |
| 60 | 60 | |
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 { |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | 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 ) ); |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | function test_get_post_embed_html() { |
| … |
… |
class Tests_Embed_Template extends WP_UnitTestCase { |
| 245 | 245 | |
| 246 | 246 | $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>'; |
| 247 | 247 | |
| 248 | | $this->assertStringEndsWith( $expected, get_post_embed_html( $post_id, 200, 200 ) ); |
| | 248 | $this->assertStringEndsWith( $expected, get_post_embed_html( 200, 200, $post_id ) ); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | function test_add_host_js() { |