Embeds: Allow posts with a public custom post status to be embedded.

Previously, only posts with the `publish` status could be embedded.

Props goaroundagain, peterwilsoncc, poena.
Fixes #47574.

git-svn-id: https://develop.svn.wordpress.org/trunk@50401 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2021-02-22 13:21:26 +00:00
parent 04b26cf226
commit 6479ea9af8
2 changed files with 49 additions and 2 deletions
@@ -2,6 +2,7 @@
/**
* @group oembed
* @covers ::get_oembed_response_data
*/
class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
function test_get_oembed_response_data_non_existent_post() {
@@ -128,6 +129,51 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
$this->assertFalse( get_oembed_response_data( $post, 100 ) );
}
/**
* @ticket 47574
*/
function test_get_oembed_response_data_with_public_true_custom_post_status() {
// Custom status with 'public' => true.
register_post_status( 'public', array( 'public' => true ) );
$post = self::factory()->post->create_and_get(
array(
'post_status' => 'public',
)
);
$this->assertNotFalse( get_oembed_response_data( $post, 100 ) );
}
/**
* @ticket 47574
*/
function test_get_oembed_response_data_with_public_false_custom_post_status() {
// Custom status with 'public' => false.
register_post_status( 'private_foo', array( 'public' => false ) );
$post = self::factory()->post->create_and_get(
array(
'post_status' => 'private_foo',
)
);
$this->assertFalse( get_oembed_response_data( $post, 100 ) );
}
/**
* @ticket 47574
*/
function test_get_oembed_response_data_with_unregistered_custom_post_status() {
$post = self::factory()->post->create_and_get(
array(
'post_status' => 'unknown_foo',
)
);
$this->assertFalse( get_oembed_response_data( $post, 100 ) );
}
function test_get_oembed_response_data_maxwidth_too_high() {
$post = self::factory()->post->create_and_get();