--- a/wp/wp-includes/embed.php Fri Sep 05 18:40:08 2025 +0200
+++ b/wp/wp-includes/embed.php Fri Sep 05 18:52:52 2025 +0200
@@ -331,11 +331,12 @@
* Adds oEmbed discovery links in the head element of the website.
*
* @since 4.4.0
+ * @since 6.8.0 Output was adjusted to only embed if the post supports it.
*/
function wp_oembed_add_discovery_links() {
$output = '';
- if ( is_singular() ) {
+ if ( is_singular() && is_post_embeddable() ) {
$output .= '<link rel="alternate" title="' . _x( 'oEmbed (JSON)', 'oEmbed resource link name' ) . '" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
if ( class_exists( 'SimpleXMLElement' ) ) {
@@ -538,11 +539,12 @@
* Retrieves the oEmbed response data for a given post.
*
* @since 4.4.0
+ * @since 6.8.0 Output was adjusted to only embed if the post type supports it.
*
* @param WP_Post|int $post Post ID or post object.
* @param int $width The requested width.
- * @return array|false Response data on success, false if post doesn't exist
- * or is not publicly viewable.
+ * @return array|false Response data on success, false if post doesn't exist,
+ * is not publicly viewable or post type is not embeddable.
*/
function get_oembed_response_data( $post, $width ) {
$post = get_post( $post );
@@ -556,6 +558,10 @@
return false;
}
+ if ( ! is_post_embeddable( $post ) ) {
+ return false;
+ }
+
/**
* Filters the allowed minimum and maximum widths for the oEmbed response.
*
@@ -721,7 +727,7 @@
}
if ( $thumbnail_id ) {
- list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 99999 ) );
+ list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 0 ) );
$data['thumbnail_url'] = $thumbnail_url;
$data['thumbnail_width'] = $thumbnail_width;
$data['thumbnail_height'] = $thumbnail_height;