Make WordPress Core

Ticket #52814: 52814.diff

File 52814.diff, 1.8 KB (added by dd32, 4 years ago)
  • link-template.php

    function get_feed_link( $feed = '' ) { 
    723723         * @param string $output The feed permalink.
    724724         * @param string $feed   The feed type. Possible values include 'rss2', 'atom',
    725725         *                       or an empty string for the default feed type.
    726726         */
    727727        return apply_filters( 'feed_link', $output, $feed );
    728728}
    729729
    730730/**
    731731 * Retrieves the permalink for the post comments feed.
    732732 *
    733733 * @since 2.2.0
    734734 *
    735735 * @param int    $post_id Optional. Post ID. Default is the ID of the global `$post`.
    736736 * @param string $feed    Optional. Feed type. Possible values include 'rss2', 'atom'.
    737737 *                        Default is the value of get_default_feed().
    738  * @return string The permalink for the comments feed for the given post.
     738 * @return string|false The permalink for the comments feed for the given post.
    739739 */
    740740function get_post_comments_feed_link( $post_id = 0, $feed = '' ) {
    741741        $post_id = absint( $post_id );
    742742
    743743        if ( ! $post_id ) {
    744744                $post_id = get_the_ID();
    745745        }
    746746
    747747        if ( empty( $feed ) ) {
    748748                $feed = get_default_feed();
    749749        }
    750750
    751         $post       = get_post( $post_id );
     751        $post = get_post( $post_id );
     752        if ( ! $post ) {
     753                return false;
     754        }
     755
    752756        $unattached = 'attachment' === $post->post_type && 0 === (int) $post->post_parent;
    753757
    754758        if ( get_option( 'permalink_structure' ) ) {
    755759                if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post_id ) {
    756760                        $url = _get_page_link( $post_id );
    757761                } else {
    758762                        $url = get_permalink( $post_id );
    759763                }
    760764
    761765                if ( $unattached ) {
    762766                        $url = home_url( '/feed/' );
    763767                        if ( get_default_feed() !== $feed ) {
    764768                                $url .= "$feed/";
    765769                        }
    766770                        $url = add_query_arg( 'attachment_id', $post_id, $url );