Make WordPress Core

Ticket #47574: 47574.2.diff

File 47574.2.diff, 1.8 KB (added by goaroundagain, 6 years ago)

Now with unit tests

  • src/wp-includes/embed.php

    diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php
    index 76d937cd6c..2f64ae5344 100644
    a b function get_oembed_response_data( $post, $width ) { 
    506506                return false;
    507507        }
    508508
    509         if ( 'publish' !== get_post_status( $post ) ) {
     509        if ( ! get_post_status_object( get_post_status( $post ) )->public ) {
    510510                return false;
    511511        }
    512512
  • tests/phpunit/tests/oembed/getResponseData.php

    diff --git a/tests/phpunit/tests/oembed/getResponseData.php b/tests/phpunit/tests/oembed/getResponseData.php
    index de96211f87..5966c8e250 100644
    a b class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    128128                $this->assertFalse( get_oembed_response_data( $post, 100 ) );
    129129        }
    130130
     131        /**
     132         * @ticket 47574
     133         */
     134        function test_getoembed_response_data_with_public_true_custom_post_status() {
     135                // Custom status with public=true.
     136                register_post_status( 'public', array( 'public' => true ) );
     137
     138                $post = self::factory()->post->create_and_get(
     139                        array(
     140                                'post_status' => 'public',
     141                        )
     142                );
     143
     144                $this->assertNotFalse( get_oembed_response_data( $post, 100 ) );
     145
     146                _unregister_post_status( 'public' );
     147        }
     148
     149        /**
     150         * @ticket 47574
     151         */
     152        function test_getoembed_response_data_with_public_false_custom_post_status() {
     153                // Custom status with public=false.
     154                register_post_status( 'privatfoo', array( 'public' => false ) );
     155
     156                $post = self::factory()->post->create_and_get(
     157                        array(
     158                                'post_status' => 'privatfoo',
     159                        )
     160                );
     161
     162                $this->assertFalse( get_oembed_response_data( $post, 100 ) );
     163
     164                _unregister_post_status( 'privatfoo' );
     165        }
     166
    131167        function test_get_oembed_response_data_maxwidth_too_high() {
    132168                $post = self::factory()->post->create_and_get();
    133169