Feeds: Avoid notices in `get_post_comments_feed_link()`.

When an feed request is made to a non-existent page, surpress the notice.

Props dd32, SergeyBiryukov, mukesh27, hellofromTonya.
Fixes #52814.


Built from https://develop.svn.wordpress.org/trunk@51121


git-svn-id: http://core.svn.wordpress.org/trunk@50730 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
antpb 2021-06-08 23:00:59 +00:00
parent bdbda4c306
commit bb041c2503
2 changed files with 9 additions and 3 deletions

View File

@ -735,7 +735,7 @@ function get_feed_link( $feed = '' ) {
* @param int $post_id Optional. Post ID. Default is the ID of the global `$post`.
* @param string $feed Optional. Feed type. Possible values include 'rss2', 'atom'.
* Default is the value of get_default_feed().
* @return string The permalink for the comments feed for the given post.
* @return string The permalink for the comments feed for the given post on success, empty string on failure.
*/
function get_post_comments_feed_link( $post_id = 0, $feed = '' ) {
$post_id = absint( $post_id );
@ -748,7 +748,13 @@ function get_post_comments_feed_link( $post_id = 0, $feed = '' ) {
$feed = get_default_feed();
}
$post = get_post( $post_id );
$post = get_post( $post_id );
// Bail out if the post does not exist.
if ( ! $post instanceof WP_Post ) {
return '';
}
$unattached = 'attachment' === $post->post_type && 0 === (int) $post->post_parent;
if ( get_option( 'permalink_structure' ) ) {

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.8-alpha-51120';
$wp_version = '5.8-alpha-51121';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.