Ticket #2702: 2702.4.diff
File 2702.4.diff, 5.4 KB (added by , 9 years ago) |
---|
-
src/includes/common/formatting.php
389 389 $r = preg_replace( '#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r ); 390 390 return $r; 391 391 } 392 393 /** 394 * Removes the first page query string &paged=1 395 * 396 * @since 397 * 398 * @return string The query string for the first page 399 */ 400 function bbp_pagination_paged_1_replace( $matches ){ 401 return str_replace( '&paged=1', '', $matches[0] ); 402 } -
src/includes/replies/template.php
273 273 if ( bbp_use_pretty_urls() ) { 274 274 $bbp->reply_query->pagination_links = str_replace( bbp_get_paged_slug() . '/1/', '', $bbp->reply_query->pagination_links ); 275 275 } else { 276 $bbp->reply_query->pagination_links = str_replace( '&paged=1', '', $bbp->reply_query->pagination_links ); 276 $bbp->reply_query->pagination_links = preg_replace_callback( '/&paged=1[^0-9]/', 277 'bbp_pagination_paged_1_replace', 278 $bbp->reply_query->pagination_links ); 277 279 } 278 280 } 279 281 } -
src/includes/topics/template.php
908 908 if ( bbp_use_pretty_urls() ) { 909 909 $pagination_links = str_replace( bbp_get_paged_slug() . '/1/', '', $pagination_links ); 910 910 } else { 911 $pagination_links = str_replace( '&paged=1', '', $pagination_links ); 911 $pagination_links = preg_replace_callback( '/&paged=1[^0-9]/', 912 'bbp_pagination_paged_1_replace', 913 $pagination_links ); 912 914 } 913 915 914 916 // Add before and after to pagination links -
tests/phpunit/testcases/replies/template/loop.php
21 21 } 22 22 23 23 /** 24 * @ticket BBP2702 25 */ 26 public function test_replies_pagination_when_pages_are_greater_than_nine() { 27 28 $bbp = bbpress(); 29 30 if ( is_multisite() ) { 31 $this->markTestSkipped( 'Skipping URL tests in multiste for now.' ); 32 } 33 34 $f = $this->factory->forum->create(); 35 $t = $this->factory->topic->create( array( 36 'post_parent' => $f, 37 'topic_meta' => array( 38 'forum_id' => $f, 39 ), 40 ) ); 41 42 $r = $this->factory->reply->create_many( 15, array( 43 'post_parent' => $t, 44 'reply_meta' => array( 45 'forum_id' => $f, 46 'topic_id' => $t, 47 ), 48 ) ); 49 50 // Default query args from bbp_has_replies are going to be used as the args 51 $args = array( 52 'posts_per_page' => 1, // use 1 per page for testing 53 ); 54 55 $request_uri = $_SERVER['REQUEST_URI']; 56 $_SERVER['REQUEST_URI'] = add_query_arg( 'topic=' . $t, '', $request_uri ); 57 58 // test unpretty permalinks (default) 59 bbp_has_replies( $args ); 60 61 $paged_link = $_SERVER['REQUEST_URI'] . '&paged='; 62 $page2 = $paged_link . '2'; 63 $page16 = $paged_link . '16'; 64 65 $expected =<<<EXPECTED 66 <span class='page-numbers current'>1</span> 67 <a class='page-numbers' href='$page2'>2</a> 68 <span class="page-numbers dots">…</span> 69 <a class='page-numbers' href='$page16'>16</a> 70 <a class="next page-numbers" href="$page2">→</a> 71 EXPECTED; 72 73 $links = bbp_get_topic_pagination_links(); 74 $this->assertEquals( $expected, $links ); 75 76 $_SERVER['REQUEST_URI'] = $request_uri; 77 78 } 79 80 81 /** 24 82 * @covers ::bbp_replies 25 83 * @todo Implement test_bbp_replies(). 26 84 */ -
tests/phpunit/testcases/topics/template/loop.php
21 21 } 22 22 23 23 /** 24 * @ticket BBP2702 25 */ 26 public function test_topics_pagination_when_pages_are_greater_than_nine() { 27 28 $bbp = bbpress(); 29 30 if ( is_multisite() ) { 31 $this->markTestSkipped( 'Skipping URL tests in multiste for now.' ); 32 } 33 34 $f = $this->factory->forum->create(); 35 $t = $this->factory->topic->create_many( 15, array( 36 'post_parent' => $f, 37 'topic_meta' => array( 38 'forum_id' => $f, 39 ), 40 ) ); 41 42 // Default query args from bbp_has_replies are going to be used as the args 43 $args = array( 44 'posts_per_page' => 1, // use 1 per page for testing 45 ); 46 47 $request_uri = $_SERVER['REQUEST_URI']; 48 $_SERVER['REQUEST_URI'] = add_query_arg( 'forum=' . $f, '', $request_uri ); 49 50 // test unpretty permalinks (default) 51 bbp_has_replies( $args ); 52 53 $paged_link = $_SERVER['REQUEST_URI'] . '&paged='; 54 $page2 = $paged_link . '2'; 55 $page15 = $paged_link . '15'; 56 57 $expected =<<<EXPECTED 58 <span class='page-numbers current'>1</span> 59 <a class='page-numbers' href='$page2'>2</a> 60 <span class="page-numbers dots">…</span> 61 <a class='page-numbers' href='$page15'>15</a> 62 <a class="next page-numbers" href="$page2">→</a> 63 EXPECTED; 64 65 $links = bbp_get_topic_pagination_links(); 66 $this->assertEquals( $expected, $links ); 67 68 $_SERVER['REQUEST_URI'] = $request_uri; 69 70 } 71 72 /** 24 73 * @covers ::bbp_topics 25 74 * @todo Implement test_bbp_topics(). 26 75 */