mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
In paginate_links(), improve handling of custom pagination query vars.
Custom pagination query vars, as provided in the 'base' parameter, must be detected in the current page URL and removed before generating fresh pagination links. The logic introduced in this changeset ensures that these custom query vars are properly detected in cases where the 'format' param contains a `#`. This is a follow-up to [31203] #30831. Fixes #31939. git-svn-id: https://develop.svn.wordpress.org/trunk@32359 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -311,4 +311,24 @@ EXPECTED;
|
||||
|
||||
$this->assertContains( "<span class='page-numbers current'>3</span>", $links );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 31939
|
||||
*/
|
||||
public function test_custom_base_query_arg_should_be_stripped_from_current_url_before_generating_pag_links() {
|
||||
// Fake the current URL: example.com?foo
|
||||
$request_uri = $_SERVER['REQUEST_URI'];
|
||||
$_SERVER['REQUEST_URI'] = add_query_arg( 'foo', '', $request_uri );
|
||||
|
||||
$links = paginate_links( array(
|
||||
'base' => add_query_arg( 'foo', '%_%', home_url() ),
|
||||
'format' => '%#%',
|
||||
'total' => 5,
|
||||
'current' => 1,
|
||||
'type' => 'array',
|
||||
) );
|
||||
|
||||
$page_2_url = home_url() . '?foo=2';
|
||||
$this->assertContains( "<a class='page-numbers' href='$page_2_url'>2</a>", $links );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user