Make WordPress Core


Ignore:
Timestamp:
01/24/2025 01:30:27 PM (4 months ago)
Author:
swissspidy
Message:

Posts, Post Types: Embeds: Add new embeddable argument to post types.

This new argument, which defaults to the value of public, can be used to determine whether a post can be embedded using oEmbed. A new is_post_embeddable() function is added to easily check this.

Props pampfelimetten, swissspidy, bradleyt, DrewAPicture, gadelhas, mukesh27.
Fixes #35567.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/oembed/discovery.php

    r58286 r59700  
    8686        $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
    8787    }
     88
     89    /**
     90     * @ticket 35567
     91     */
     92    public function test_wp_oembed_add_discovery_links_non_embeddable_post_type_output_should_be_empty() {
     93        register_post_type( 'not_embeddable', array( 'embeddable' => false ) );
     94
     95        $post = self::factory()->post->create_and_get(
     96            array(
     97                'post_type' => 'not_embeddable',
     98            )
     99        );
     100
     101        $this->assertFalse( get_oembed_response_data( $post, 100 ) );
     102    }
    88103}
Note: See TracChangeset for help on using the changeset viewer.