WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/09/2019 01:30:32 AM (2 months ago)
Author:
pento
Message:

Feeds: Introduce the get_self_link() function.

Corresponds to the self_link() template function.

This matches other feed template functions, using one function to get the value, and a different function to echo it.

Props jojotjebaby, mobeen-abdullah, donmhico, audrasjb, dshanske.
Fixes #44838.

File:
1 edited

Legend:

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

    r45753 r45772  
    617617
    618618/**
     619 * Returns the link for the currently displayed feed.
     620 *
     621 * @since 5.3.0
     622 *
     623 * @return string Correct link for the atom:self element.
     624 */
     625function get_self_link() {
     626    $host = @parse_url( home_url() );
     627    return set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] ) );
     628}
     629
     630/**
    619631 * Display the link for the currently displayed feed in a XSS safe way.
    620632 *
     
    624636 */
    625637function self_link() {
    626     $host = @parse_url( home_url() );
    627638    /**
    628639     * Filters the current feed URL.
     
    635646     * @param string $feed_link The link for the feed with set URL scheme.
    636647     */
    637     echo esc_url( apply_filters( 'self_link', set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) );
     648    echo esc_url( apply_filters( 'self_link', get_self_link() ) );
    638649}
    639650
Note: See TracChangeset for help on using the changeset viewer.