WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 7 weeks ago

Last modified 13 days ago

#44018 closed enhancement (fixed)

Adding a filter in paginate_links function

Reported by: re.ardestani Owned by: audrasjb
Milestone: 5.7 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch commit has-dev-note
Focuses: template Cc:

Description

Possible to add a filter at the end of paginate_links function similar to this: http://take.ms/eBEyB

It's beneficial for developers to change anything from links, HTML, ... in the final output.

In my case, I want to change the HTML class so I can easily make it Bootstrap pagination friendly.

Attachments (2)

44018.diff (469 bytes) - added by sabernhardt 3 months ago.
adding proposed filter, with docblock
44018.1.diff (2.5 KB) - added by audrasjb 7 weeks ago.
Adds $args parameter for better flexibility

Download all attachments as: .zip

Change History (14)

@sabernhardt
3 months ago

adding proposed filter, with docblock

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


3 months ago

#2 @noisysocks
3 months ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 5.7

#3 @sabernhardt
3 months ago

I think the filter could have a better name than paginate_links_output, though I haven't thought of one. I would have used paginate_links if it weren't taken already.

#4 @audrasjb
2 months ago

  • Keywords commit added

I tested the patch, it still applies cleanly and I was able to filter the paginate links HTML output using the following test filter:

add_filter( 'paginate_links_output', function( $r ) { return 'test'; } );

Marking this for commit.

#5 @audrasjb
2 months ago

  • Keywords needs-dev-note added

This will need a quick note in the Miscellaneous changes dev note.

#6 @SergeyBiryukov
7 weeks ago

I think the filter should also receive the $args array as a second parameter, for more flexibility. I can add that on commit.

#7 @audrasjb
7 weeks ago

  • Owner set to audrasjb
  • Status changed from new to accepted

Hmm yes @SergeyBiryukov you're right. Adding a new patch right now.

@audrasjb
7 weeks ago

Adds $args parameter for better flexibility

#8 @SergeyBiryukov
7 weeks ago

  • Component changed from General to Posts, Post Types
  • Focuses template added

#9 @SergeyBiryukov
7 weeks ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 49976:

Posts, Post Types: Introduce a filter paginate_links() output.

Props sabernhardt, audrasjb, re.ardestani.
Fixes #44018.

#10 @sabernhardt
3 weeks ago

#52530 was marked as a duplicate.

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


2 weeks ago

Note: See TracTickets for help on using tickets.