Changeset 53125
- Timestamp:
- 04/11/2022 05:01:04 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r53087 r53125 3154 3154 $post = get_post( $id ); 3155 3155 3156 if ( comments_open() || pings_open() || $post->comment_count > 0 ) { 3157 $title = sprintf( $args['singletitle'], get_bloginfo( 'name' ), $args['separator'], the_title_attribute( array( 'echo' => false ) ) ); 3158 $href = get_post_comments_feed_link( $post->ID ); 3156 /** This filter is documented in wp-includes/general-template.php */ 3157 $show_comments_feed = apply_filters( 'feed_links_show_comments_feed', true ); 3158 3159 if ( $show_comments_feed && ( comments_open() || pings_open() || $post->comment_count > 0 ) ) { 3160 $title = sprintf( $args['singletitle'], get_bloginfo( 'name' ), $args['separator'], the_title_attribute( array( 'echo' => false ) ) ); 3161 $feed_link = get_post_comments_feed_link( $post->ID ); 3162 3163 if ( $feed_link ) { 3164 $href = $feed_link; 3165 } 3159 3166 } 3160 3167 } elseif ( is_post_type_archive() ) { -
trunk/tests/phpunit/tests/general/feedLinksExtra.php
r53033 r53125 511 511 $this->assertSame( $expected, get_echo( 'feed_links_extra' ) ); 512 512 } 513 514 /** 515 * @ticket 54703 516 */ 517 public function test_feed_links_extra_should_output_nothing_when_show_comments_feed_filter_returns_false() { 518 add_filter( 'feed_links_show_comments_feed', '__return_false' ); 519 520 $this->go_to( get_the_permalink( self::$post_with_comment_id ) ); 521 $this->assertEmpty( get_echo( 'feed_links_extra' ) ); 522 } 523 524 /** 525 * @dataProvider data_feed_links_extra_should_output_nothing_when_post_comments_feed_link_is_falsy 526 * 527 * @ticket 54703 528 * 529 * @param string $callback The callback to use for the 'post_comments_feed_link' filter. 530 */ 531 public function test_feed_links_extra_should_output_nothing_when_post_comments_feed_link_is_falsy( $callback ) { 532 add_filter( 'post_comments_feed_link', $callback ); 533 534 $this->go_to( get_the_permalink( self::$post_with_comment_id ) ); 535 $this->assertEmpty( get_echo( 'feed_links_extra' ) ); 536 } 537 538 /** 539 * Data provider. 540 * 541 * @return array 542 */ 543 public function data_feed_links_extra_should_output_nothing_when_post_comments_feed_link_is_falsy() { 544 return array( 545 'empty string' => array( 'callback' => '__return_empty_string' ), 546 'empty array' => array( 'callback' => '__return_empty_array' ), 547 'zero int' => array( 'callback' => '__return_zero' ), 548 'zero float' => array( 'callback' => array( $this, 'cb_return_zero_float' ) ), 549 'zero string' => array( 'callback' => array( $this, 'cb_return_zero_string' ) ), 550 'null' => array( 'callback' => '__return_null' ), 551 'false' => array( 'callback' => '__return_false' ), 552 ); 553 } 554 555 /** 556 * Callback that returns 0.0. 557 * 558 * @return float 0.0. 559 */ 560 public function cb_return_zero_float() { 561 return 0.0; 562 } 563 564 /** 565 * Callback that returns '0'. 566 * 567 * @return string '0'. 568 */ 569 public function cb_return_zero_string() { 570 return '0'; 571 } 572 573 /** 574 * @ticket 54703 575 */ 576 public function test_feed_links_extra_should_output_the_comments_feed_link_when_show_comments_feed_filter_returns_true() { 577 add_filter( 'feed_links_show_comments_feed', '__return_true' ); 578 579 $this->go_to( get_the_permalink( self::$post_with_comment_id ) ); 580 $this->assertNotEmpty( get_echo( 'feed_links_extra' ) ); 581 } 513 582 }
Note: See TracChangeset
for help on using the changeset viewer.