| 478 | |
| 479 | /** |
| 480 | * Test the <rss> element to make sure its present and populated |
| 481 | * with the modified version of the title. |
| 482 | * |
| 483 | * @ticket 13867 |
| 484 | */ |
| 485 | function test_rss_element_title() { |
| 486 | add_filter( 'rss_comments_page_title', array( $this, 'apply_rss_title_filter' ), 10, 2 ); |
| 487 | add_filter( 'rss_comments_item_title', array( $this, 'apply_rss_comment_item_title_filter' ), 10, 2 ); |
| 488 | $this->go_to( '/comments/feed/' ); |
| 489 | $feed = $this->do_rss2_comments(); |
| 490 | $xml = xml_to_array( $feed ); |
| 491 | |
| 492 | // Get the <rss> child element of <xml>. |
| 493 | $rss = xml_find( $xml, 'rss' ); |
| 494 | error_log( print_r( $rss, true) ); |
| 495 | $this->assertEquals( 'Filtered Title', $rss[0]['child'][0]['child'][0]['content'] ); |
| 496 | $this->assertEquals( 'Filtered Item Title', $rss[0]['child'][0]['child'][8]['child'][0]['content'] ); |
| 497 | } |
| 498 | |
| 499 | /** |
| 500 | * Apply the rss comments title filter. |
| 501 | * |
| 502 | * @ticket 13867 |
| 503 | */ |
| 504 | function apply_rss_title_filter( $item_title, $the_title_rss ) { |
| 505 | $item_title = 'Filtered Title'; |
| 506 | return $item_title; |
| 507 | } |
| 508 | |
| 509 | /** |
| 510 | * Apply the rss comments item title filter. |
| 511 | * |
| 512 | * @ticket 13867 |
| 513 | */ |
| 514 | function apply_rss_comment_item_title_filter( $item_title, $comment_post ) { |
| 515 | $item_title = 'Filtered Item Title'; |
| 516 | return $item_title; |
| 517 | } |
| 518 | |
| 519 | /** |
| 520 | * This is a bit of a hack used to buffer feed comments content. |
| 521 | */ |
| 522 | function do_rss2_comments() { |
| 523 | ob_start(); |
| 524 | // Nasty hack! In the future it would better to leverage do_feed( 'rss2' ). |
| 525 | global $post; |
| 526 | try { |
| 527 | @require( ABSPATH . 'wp-includes/feed-rss2-comments.php' ); |
| 528 | $out = ob_get_clean(); |
| 529 | } catch ( Exception $e ) { |
| 530 | $out = ob_get_clean(); |
| 531 | throw($e); |
| 532 | } |
| 533 | return $out; |
| 534 | } |