Make WordPress Core

Opened 6 years ago

Closed 4 years ago

Last modified 3 years ago

#44018 closed enhancement (fixed)

Adding a filter in paginate_links function

Reported by: reardestani's profile re.ardestani Owned by: audrasjb's profile 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 4 years ago.
adding proposed filter, with docblock
44018.1.diff (2.5 KB) - added by audrasjb 4 years ago.
Adds $args parameter for better flexibility

Download all attachments as: .zip

Change History (14)

@sabernhardt
4 years ago

adding proposed filter, with docblock

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


4 years ago

#2 @noisysocks
4 years ago

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

#3 @sabernhardt
4 years 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
4 years 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
4 years ago

  • Keywords needs-dev-note added

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

#6 @SergeyBiryukov
4 years 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
4 years ago

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

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

@audrasjb
4 years ago

Adds $args parameter for better flexibility

#8 @SergeyBiryukov
4 years ago

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

#9 @SergeyBiryukov
4 years 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 years ago

#52530 was marked as a duplicate.

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


3 years ago

Note: See TracTickets for help on using tickets.