[wp-trac] [WordPress Trac] #54703: Remove comment feed link if get_post_comments_feed_link() returns empty

WordPress Trac noreply at wordpress.org
Thu Dec 30 21:54:19 UTC 2021


#54703: Remove comment feed link if get_post_comments_feed_link() returns empty
-------------------------------------+-----------------------
 Reporter:  barryceelen              |       Owner:  (none)
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  6.0
Component:  Feeds                    |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  template
-------------------------------------+-----------------------

Comment (by costdev):

 @rachelbaker Excellent point.

 Taking a look at the post type equivalent, it returns `string|false`.
 However, at the end, it returns the result of a filter which handles the
 link - therefore it's possible that this could be an empty string.

 So, instead of the `Issue #2` conditional above, we can instead change the
 conditional further down this function (L3201) from `isset()` to `!
 empty()` to cover both undefined and empty values:

 {{{#!php
 if ( isset( $title ) && isset( $href ) } {
     //...

 to:

 if ( ! empty( $title ) && ! empty( $href ) ) {
 }}}

 Since the `$title` can be set via `$args`, we should be checking that it
 isn't empty either. A custom title doesn't require any of the `sprintf()`
 tokens to be included in it.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54703#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list