WordPress.org

Make WordPress Core

Opened 6 months ago

Last modified 2 months ago

#47574 reviewing defect (bug)

Public custom post status cannot be embedded

Reported by: goaroundagain Owned by: SergeyBiryukov
Milestone: Future Release Priority: normal
Severity: normal Version: 5.2.2
Component: Embeds Keywords: has-unit-tests has-patch
Focuses: Cc:
PR Number:

Description

Currently it is not possible to embend any post with a custom post status, even when the custom post status is set to

'public' => true

From register_post_status: https://codex.wordpress.org/Function_Reference/register_post_status
public: (bool) (optional) Whether posts of this status should be shown in the front end of the site.

For this reason, all post with a custom post status set to public should be embeddable.

The reason why thats not possible is in get_oembed_response_data: https://developer.wordpress.org/reference/functions/get_oembed_response_data/

if ( 'publish' !== get_post_status( $post ) ) {
    return false;
}

It just checks if the post status is "publish" and not if "public" on the post status object is set to "true".

To support custom public post status, this could be a solution:

if ( true !== get_post_status_object( get_post_status( $post ) )->public ) {
    return false;
}

Another possibility would be to provide a custom filter:

if ( true !== in_array( get_post_status( $post ), apply_filters( 'oembed_post_status', array( 'publish' ) ) ) {
    return false;
}

Attachments (3)

47574.diff (408 bytes) - added by goaroundagain 6 months ago.
47574.2.diff (1.8 KB) - added by goaroundagain 6 months ago.
Now with unit tests
47574.3.diff (2.1 KB) - added by goaroundagain 6 months ago.
If the post status is not registered, treat it as a nonpublic

Download all attachments as: .zip

Change History (9)

@goaroundagain
6 months ago

@goaroundagain
6 months ago

Now with unit tests

#1 @goaroundagain
6 months ago

  • Keywords has-unit-tests has-patch added

@goaroundagain
6 months ago

If the post status is not registered, treat it as a nonpublic

#2 @SergeyBiryukov
6 months ago

  • Milestone changed from Awaiting Review to 5.3

#3 @SergeyBiryukov
4 months ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

Related: #47911

#4 @davidbaumwald
2 months ago

@SergeyBiryukov Is this one going to make it in time for 5.3 RC1?

This ticket was mentioned in Slack in #core by marybaum. View the logs.


2 months ago

#6 @marybaum
2 months ago

  • Milestone changed from 5.3 to Future Release
Note: See TracTickets for help on using tickets.