Skip to content

Pagniation links with/without trailing slashes.#8591

Open
peterwilsoncc wants to merge 10 commits intoWordPress:trunkfrom
peterwilsoncc:fix/61393-pagination-urls-take-two
Open

Pagniation links with/without trailing slashes.#8591
peterwilsoncc wants to merge 10 commits intoWordPress:trunkfrom
peterwilsoncc:fix/61393-pagination-urls-take-two

Conversation

@peterwilsoncc
Copy link
Contributor

Second pass at https://core.trac.wordpress.org/ticket/61393


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@peterwilsoncc peterwilsoncc force-pushed the fix/61393-pagination-urls-take-two branch from 212dd21 to 6c628cd Compare March 26, 2025 22:43
@peterwilsoncc peterwilsoncc marked this pull request as ready for review March 26, 2025 23:39
@github-actions
Copy link

github-actions bot commented Mar 26, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props peterwilsoncc, westonruter, audrasjb, juanmaguitar.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@peterwilsoncc peterwilsoncc force-pushed the fix/61393-pagination-urls-take-two branch from 34cf831 to c9bfda4 Compare October 28, 2025 01:39
@peterwilsoncc peterwilsoncc force-pushed the fix/61393-pagination-urls-take-two branch from c9bfda4 to b6a01bf Compare November 6, 2025 23:11
ozgursar added a commit to ozgursar/wordpress-develop that referenced this pull request Jan 12, 2026
@peterwilsoncc peterwilsoncc force-pushed the fix/61393-pagination-urls-take-two branch 2 times, most recently from 1f2dd39 to 6f57e5b Compare January 12, 2026 23:29
@westonruter westonruter requested a review from Copilot January 13, 2026 01:25
array(
'taxonomy' => 'category',
'name' => 'Categorized',
array( 'slug' => 'categorized' ),
Copy link
Member

@westonruter westonruter Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? I think it is not read properly. I tried supplying array( 'slug' => 'foo-bar-baz' ) and it still has a slug of categorized since it was derived from the name. I think this is unnecessary:

Suggested change
array( 'slug' => 'categorized' ),

Otherwise, I've seen the slug being defined one level up, for example:

$orig_args = array(
'name' => 'Original Name',
'description' => 'Original Description',
'slug' => 'original-slug',
'taxonomy' => 'nav_menu',
);
$this->menu_id = self::factory()->term->create( $orig_args );

(Props Gemini for pointing this out.)

Comment on lines +524 to +529
array( 'foo=bar', 'foo=bar/' ),
array( 'foo=bar', 'foo=bar%2F' ),
array( 'foo=bar%2F', 'foo=bar' ),

array( 's=post', 's=post/' ),
array( 's=post', 's=post%2F' ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a test case when there is no query string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a test case when there is no query string?

An empty query string gets dropped so the output is covered above.

This comment was marked as resolved.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@juanmaguitar
Copy link

@peterwilsoncc thanks for working on this ticket!
There's some pending feedback to address. Do you think we can move forward with this PR in time for WP 7.0 RC1?

@peterwilsoncc peterwilsoncc force-pushed the fix/61393-pagination-urls-take-two branch from e262810 to e6b6553 Compare March 13, 2026 02:01
@peterwilsoncc peterwilsoncc force-pushed the fix/61393-pagination-urls-take-two branch from d339b21 to 76fc55e Compare March 13, 2026 03:00
Comment on lines 4671 to 4673

// Append the format placeholder to the base URL.
$pagenum_link = trailingslashit( $url_parts[0] ) . '%_%';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be deleted since it is immediately overwritten, yes?

Suggested change
$pagenum_link = trailingslashit( $url_parts[0] ) . '%_%';

Copy link
Member

@westonruter westonruter Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggestion didn't come through right in GitHub. I mean these lines can be removed:

// Append the format placeholder to the base URL.
$pagenum_link = trailingslashit( $url_parts[0] ) . '%_%';

* Ensures sites not using trailing slashes get links in the form
* `/page/2` rather than `/page/2/`. On these sites, linking to the
* URL with a trailing slash will results in a 301 redirect from the
* incorrect URL to the correctly formattted one. This presents an
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* incorrect URL to the correctly formattted one. This presents an
* incorrect URL to the correctly formatted one. This presents an

/*
* Ensures sites not using trailing slashes get links in the form
* `/page/2` rather than `/page/2/`. On these sites, linking to the
* URL with a trailing slash will results in a 301 redirect from the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* URL with a trailing slash will results in a 301 redirect from the
* URL with a trailing slash will result in a 301 redirect from the

while ( $processor->next_tag( 'A' ) ) {
++$found_links;
$href = $processor->get_attribute( 'href' );
$this->assertStringEndsNotWith( '/', $href, "Pagination links should end with a trailing slash, found: $href" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->assertStringEndsNotWith( '/', $href, "Pagination links should end with a trailing slash, found: $href" );
$this->assertStringEndsNotWith( '/', $href, "Pagination links should not end with a trailing slash, found: $href" );

* @dataProvider data_query_strings
*
* @param string $query_string Query string.
* @param string $unexpected Unexpected query string.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused param.

Suggested change
* @param string $unexpected Unexpected query string.

* @dataProvider data_query_strings
*
* @param string $query_string Query string.
* @param string $unexpected Unexpected query string.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused.

Suggested change
* @param string $unexpected Unexpected query string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants