WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 days ago

#44269 new defect (bug)

Add optional parameter $merge_args into paginate_links function

Reported by: andrepoandrade Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 2.1
Component: General Keywords: reporter-feedback
Focuses: Cc:

Description

I'm passing a query arg that exists on args in current url, but the value passed by parameter is different. What happens is that the value of query arg passed as tabname is overwritten by value into current url arg.

I suggest an optional parameter called $merge_args and default value as true, in this way, all necessary query args to build pagination links should be passed by add_args and nothing is overwrite.

<?php
function paginate_links( $args = '', $merge_args = true ) {
...
...
    if ( isset( $url_parts[1] ) ) {
        ...
        ...
        if($merge_args)
        {
            $args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $url_query_args ) );
        }
    }
}

Attachments (1)

general-template.php (135.8 KB) - added by andrepoandrade 3 years ago.
File general-template.php with modified paginate_links function

Download all attachments as: .zip

Change History (4)

@andrepoandrade
3 years ago

File general-template.php with modified paginate_links function

This ticket was mentioned in Slack in #core by noisysocks. View the logs.


5 days ago

#2 @peterwilsoncc
5 days ago

  • Keywords reporter-feedback added
  • Version changed from 4.9.5 to 2.1

@andrepoandrade Hello, and a belated welcome to trac!

This was discussed in a triage session today.

Are you able to provide a little more details about the use case you have in mind? It might be helpful to include some sample URLs to demonstrate how you'd like the new argument to affect them.

Thanks.

#3 @markparnell
3 days ago

#44331 was marked as a duplicate.

Note: See TracTickets for help on using tickets.