Make WordPress Core

Changeset 58286


Ignore:
Timestamp:
06/02/2024 10:00:26 PM (5 months ago)
Author:
audrasjb
Message:

Embeds: Add titles to alternate resource links for oEmbed and REST API.

This changeset makes the following changes:

Props edent, kadamwhite, TimothyBlynJacobs, joedolson, swissspidy, sabernhardt.
Fixes #59006.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/embed.php

    r58143 r58286  
    337337
    338338    if ( is_singular() ) {
    339         $output .= '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
     339        $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";
    340340
    341341        if ( class_exists( 'SimpleXMLElement' ) ) {
    342             $output .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
     342            $output .= '<link rel="alternate" title="' . _x( 'oEmbed (XML)', 'oEmbed resource link name' ) . '" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
    343343        }
    344344    }
  • trunk/src/wp-includes/rest-api.php

    r58267 r58286  
    10081008
    10091009    if ( $resource ) {
    1010         printf( '<link rel="alternate" type="application/json" href="%s" />', esc_url( rest_url( $resource ) ) );
     1010        printf(
     1011            '<link rel="alternate" title="%1$s" type="application/json" href="%2$s" />',
     1012            _x( 'JSON', 'REST API resource link name' ),
     1013            esc_url( rest_url( $resource ) )
     1014        );
    10111015    }
    10121016}
     
    10331037
    10341038    if ( $resource ) {
    1035         header( sprintf( 'Link: <%s>; rel="alternate"; type="application/json"', sanitize_url( rest_url( $resource ) ) ), false );
     1039        header(
     1040            sprintf(
     1041                'Link: <%1$s>; rel="alternate"; title="%2$s"; type="application/json"',
     1042                sanitize_url( rest_url( $resource ) ),
     1043                _x( 'JSON', 'REST API resource link name' )
     1044            ),
     1045            false
     1046        );
    10361047    }
    10371048}
  • trunk/tests/phpunit/tests/oembed/controller.php

    r58235 r58286  
    128128                    'code' => 200,
    129129                ),
    130                 'body'     => '<html><head><link rel="alternate" type="application/json+oembed" href="' . self::UNTRUSTED_PROVIDER_URL . '" /></head><body></body></html>',
     130                'body'     => '<html><head><link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . self::UNTRUSTED_PROVIDER_URL . '" /></head><body></body></html>',
    131131            );
    132132        }
  • trunk/tests/phpunit/tests/oembed/discovery.php

    r52010 r58286  
    3333        $this->assertQueryTrue( 'is_front_page', 'is_singular', 'is_page' );
    3434
    35         $expected  = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
    36         $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
     35        $expected  = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
     36        $expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
    3737
    3838        $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
     
    4646        $this->assertQueryTrue( 'is_single', 'is_singular' );
    4747
    48         $expected  = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
    49         $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
     48        $expected  = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
     49        $expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
    5050
    5151        $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
     
    6161        $this->assertQueryTrue( 'is_page', 'is_singular' );
    6262
    63         $expected  = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
    64         $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
     63        $expected  = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
     64        $expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
    6565
    6666        $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
     
    8181        $this->assertQueryTrue( 'is_attachment', 'is_singular', 'is_single' );
    8282
    83         $expected  = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
    84         $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
     83        $expected  = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
     84        $expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
    8585
    8686        $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
Note: See TracChangeset for help on using the changeset viewer.