Permalinks: Ensure pagination links are consistent with permalink structure.

This changeset ensures that pagination links stay consistent with the chosen permalink structure. When the permalink structure uses a trailing slash, pagination permalinks contain one as well, but when the permalink structure doesn't use trailing slash, then pagination links should not use a trailing slash.

This makes use of `user_trailingslashit()` with a `paged` value for the `type_of_url` parameter.

Props hmbashar, huzaifaalmesbah, rejaulalomkhan, mai21, rahulsprajapati, martinkrcho, ankitkumarshah, adamsilverstein, sourabhjain.
Fixes #61393.


Built from https://develop.svn.wordpress.org/trunk@59966


git-svn-id: http://core.svn.wordpress.org/trunk@59308 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb
2025-03-11 11:11:32 +00:00
parent c5bd4c18b4
commit e7f4ec0694
2 changed files with 4 additions and 1 deletions

View File

@@ -4713,6 +4713,7 @@ function paginate_links( $args = '' ) {
$link = add_query_arg( $add_args, $link ); $link = add_query_arg( $add_args, $link );
} }
$link .= $args['add_fragment']; $link .= $args['add_fragment'];
$link = get_option( 'permalink_structure' ) ? user_trailingslashit( $link, 'paged' ) : $link;
$page_links[] = sprintf( $page_links[] = sprintf(
'<a class="prev page-numbers" href="%s">%s</a>', '<a class="prev page-numbers" href="%s">%s</a>',
@@ -4745,6 +4746,7 @@ function paginate_links( $args = '' ) {
$link = add_query_arg( $add_args, $link ); $link = add_query_arg( $add_args, $link );
} }
$link .= $args['add_fragment']; $link .= $args['add_fragment'];
$link = get_option( 'permalink_structure' ) ? user_trailingslashit( $link, 'paged' ) : $link;
$page_links[] = sprintf( $page_links[] = sprintf(
'<a class="page-numbers" href="%s">%s</a>', '<a class="page-numbers" href="%s">%s</a>',
@@ -4769,6 +4771,7 @@ function paginate_links( $args = '' ) {
$link = add_query_arg( $add_args, $link ); $link = add_query_arg( $add_args, $link );
} }
$link .= $args['add_fragment']; $link .= $args['add_fragment'];
$link = get_option( 'permalink_structure' ) ? user_trailingslashit( $link, 'paged' ) : $link;
$page_links[] = sprintf( $page_links[] = sprintf(
'<a class="next page-numbers" href="%s">%s</a>', '<a class="next page-numbers" href="%s">%s</a>',

View File

@@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.8-beta1-59965'; $wp_version = '6.8-beta1-59966';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.