Ticket #19902: 19902.4.diff
File 19902.4.diff, 1.9 KB (added by , 9 years ago) |
---|
-
src/wp-includes/link-template.php
1124 1124 if ( ! $post_type_obj = get_post_type_object( $post_type ) ) 1125 1125 return false; 1126 1126 1127 if ( 'post' === $post_type ) { 1128 $show_on_front = get_option( 'show_on_front' ); 1129 $page_for_posts = get_option( 'page_for_posts' ); 1130 1131 if ( 'page' == $show_on_front && $page_for_posts ) { 1132 $link = get_permalink( $page_for_posts ); 1133 } else { 1134 $link = get_home_url(); 1135 } 1136 /** This filter is documented in wp-includes/link-template.php */ 1137 return apply_filters( 'post_type_archive_link', $link, $post_type ); 1138 } 1139 1127 1140 if ( ! $post_type_obj->has_archive ) 1128 1141 return false; 1129 1142 -
tests/phpunit/tests/link/getPostTypeArchiveLink.php
1 <?php 2 /** 3 * @group link 4 */ 5 class Tests_Link_GetPostTypeArchiveLink extends WP_UnitTestCase { 6 7 /** 8 * @ticket 19902 9 */ 10 public function test_get_post_archive_link_with_post_archive_on_front_page() { 11 update_option( 'show_on_front', 'posts' ); 12 $actual = get_post_type_archive_link( 'post' ); 13 $expected = get_home_url(); 14 $this->assertSame( $expected, $actual ); 15 } 16 17 /** 18 * @ticket 19902 19 */ 20 public function test_get_post_archive_link_with_post_archive_on_a_blog_page() { 21 $page_for_posts = $this->factory->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ); 22 update_option( 'show_on_front', 'page' ); 23 update_option( 'page_for_posts', $page_for_posts ); 24 $actual = get_post_type_archive_link( 'post' ); 25 $expected = get_permalink( $page_for_posts ); 26 $this->assertSame( $expected, $actual ); 27 } 28 }