Ticket #9134: 9134-v4.diff
| File 9134-v4.diff, 3.9 KB (added by , 10 years ago) |
|---|
-
src/wp-includes/feed-atom.php
78 78 * @since 2.0.0 79 79 */ 80 80 do_action( 'atom_entry' ); 81 82 if ( has_comments_link() ) : 81 83 ?> 82 84 <link rel="replies" type="<?php bloginfo_rss('html_type'); ?>" href="<?php the_permalink_rss() ?>#comments" thr:count="<?php echo get_comments_number()?>"/> 83 85 <link rel="replies" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link(0, 'atom') ); ?>" thr:count="<?php echo get_comments_number()?>"/> 84 86 <thr:total><?php echo get_comments_number()?></thr:total> 87 <?php endif; ?> 85 88 </entry> 86 89 <?php endwhile ; ?> 87 90 </feed> -
src/wp-includes/feed-rss2.php
83 83 <item> 84 84 <title><?php the_title_rss() ?></title> 85 85 <link><?php the_permalink_rss() ?></link> 86 <?php if ( has_comments_link() ) : ?> 86 87 <comments><?php comments_link_feed(); ?></comments> 88 <?php endif; ?> 87 89 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate> 88 90 <dc:creator><![CDATA[<?php the_author() ?>]]></dc:creator> 89 91 <?php the_category_rss('rss2') ?> … … 100 102 <content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded> 101 103 <?php endif; ?> 102 104 <?php endif; ?> 105 <?php if ( has_comments_link() ) : ?> 103 106 <wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss> 104 107 <slash:comments><?php echo get_comments_number(); ?></slash:comments> 108 <?php endif; ?> 105 109 <?php rss_enclosure(); ?> 106 110 <?php 107 111 /** -
src/wp-includes/feed.php
260 260 } 261 261 262 262 /** 263 * Whether we have to show comments links because the post type supports it and comments are open 264 * @param int|WP_Post|null $post Optional. Post ID or post object. Default is global $post. 265 * @return bool 266 */ 267 function has_comments_link( $post = null ) { 268 $has_comments_link = ( post_type_supports( get_post_type( $post ), 'comments' ) && comments_open( $post ) ); 269 270 return apply_filters( 'has_comments_link', $has_comments_link ); 271 } 272 273 /** 263 274 * Display the feed GUID for the current comment. 264 275 * 265 276 * @since 2.5.0 -
tests/phpunit/tests/feed/rss2.php
148 148 $comments_link = xml_find( $items[$key]['child'], 'comments' ); 149 149 $this->assertEquals( get_permalink( $post) . '#respond', $comments_link[0]['content'] ); 150 150 151 // Ticket https://core.trac.wordpress.org/ticket/9134 152 $this->assertTrue( has_comments_link() ); 153 151 154 // pub date 152 155 $pubdate = xml_find( $items[$key]['child'], 'pubDate' ); 153 156 $this->assertEquals( strtotime( $post->post_date_gmt ), strtotime( $pubdate[0]['content'] ) ); … … 201 204 $this->assertEquals( html_entity_decode( get_post_comments_feed_link( $post->ID) ), $comment_rss[0]['content'] ); 202 205 } 203 206 } 207 208 // @ticket 9134 209 function test_has_comments_link() { 210 $post_id = wp_insert_post( 211 array( 212 'post_author' => 1, 213 'post_status' => 'publish', 214 'post_content' => rand_str(), 215 'post_title' => rand_str(), 216 'post_status' => 'open' 217 ) 218 ); 219 $this->assertTrue( has_comments_link( $post_id ) ); 220 221 $post_id = wp_insert_post( 222 array( 223 'post_author' => 1, 224 'post_status' => 'publish', 225 'post_content' => rand_str(), 226 'post_title' => rand_str(), 227 'comment_status' => 'closed' 228 ) 229 ); 230 $this->assertFalse( has_comments_link( $post_id ) ); 231 } 204 232 }