WordPress.org

Make WordPress Core

Opened 7 weeks ago

Last modified 6 weeks ago

#42733 new defect (bug)

WordPress Embed URLs don't work for draft and scheduled posts with pretty permalinks

Reported by: Frank Klein Owned by:
Milestone: 5.0 Priority: normal
Severity: normal Version:
Component: Embeds Keywords: needs-patch needs-unit-tests
Focuses: Cc:

Description

This came up during work on #41451. Two tests fail with is_embed is false but is expected to be true:

  • Tests_Embed_Template::test_oembed_output_draft_post
  • Tests_Embed_Template::test_oembed_output_scheduled_post

Without pretty permalinks, the return of get_post_embed_url() is http://example.org/?p=8&embed=true. This URL is recognised as an embed URL when the request is parsed.

But with pretty permalinks enabled, the return is http://example.org/?p=8/embed/. This is not recognised as an embed URL.

The reason for the mixed URL structure seems to be get_permalink(). This function does not return pretty permalinks for draft or future posts, see https://core.trac.wordpress.org/browser/tags/4.9/src/wp-includes/link-template.php#L165

Change History (1)

#1 @swissspidy
6 weeks ago

  • Keywords needs-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to 5.0

Yeah it'd be great if get_post_embed_url() could get some improvement to make the URLs correct for such posts.

Note: See TracTickets for help on using tickets.