WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 20 months ago

#18604 closed enhancement (wontfix)

New hook for paginate_links() result

Reported by: lightningspirit Owned by: lightningspirit
Milestone: Priority: normal
Severity: major Version: 3.3
Component: Formatting Keywords: has-patch dev-feedback
Focuses: Cc:

Description

I'd like to propose two new hooks to paginate_links() in http://core.trac.wordpress.org/browser/trunk/wp-includes/general-template.php#L1950

This two hooks paginate_links_array and paginate_links_html will allow plugins to add, remove or alter html and links in admin pagination output, including the media uploader.

Background: sites with more than a thousand media objects have 140+ pages in media uploader interface. I had to be able to create a input box to enter page number manually.

Attachments (3)

general-template.patch (811 bytes) - added by lightningspirit 4 years ago.
This patch add two new filters at end of paginate_links()
paginate_links_hooks.png (4.6 KB) - added by lightningspirit 4 years ago.
The paginate_links() hooks allow this
18604.diff (1020 bytes) - added by lightningspirit 3 years ago.
New hook for paginate_links() "paginate_links_{$context}". Added $context variable for developers to be able to apply filters for paginate_links() in diferent contextes. Added $context = 'media-upload' for paginate_links() argument for developers to be able to hack the pagination result in the wp-admin/media-upload.php aka Media Library.

Download all attachments as: .zip

Change History (12)

@lightningspirit4 years ago

This patch add two new filters at end of paginate_links()

@lightningspirit4 years ago

The paginate_links() hooks allow this

comment:1 @scribu4 years ago

  • Keywords ux-feedback removed

If we're going to add a filter there, it should also pass the parameters that paginate_links() received.

And the 'paginate_links_array' filter should be applied only once, before the switch statement.

comment:2 @scribu4 years ago

Also, your screenshot is puzzling. Since WP 3.1, the pagination in the admin has been revamped, adding an input for the current page, like you mentioned.

comment:3 @scribu4 years ago

Oh, you mean the pagination links on the Media Library tab?

We should update them to the new style, which can be seen when going to /wp-admin/edit.php for example.

comment:4 @lightningspirit4 years ago

Oh okay, I think updating to the new style will be better than revamping this one. Should I create a new ticket?

comment:5 @scribu4 years ago

Yeah, you should make a new ticket; the filters might be a good idea on their own.

comment:6 @sirzooro4 years ago

  • Cc sirzooro added

@lightningspirit3 years ago

New hook for paginate_links() "paginate_links_{$context}". Added $context variable for developers to be able to apply filters for paginate_links() in diferent contextes. Added $context = 'media-upload' for paginate_links() argument for developers to be able to hack the pagination result in the wp-admin/media-upload.php aka Media Library.

comment:7 @lightningspirit3 years ago

  • Keywords dev-feedback added
  • Severity changed from normal to major
  • Version changed from 3.3 to 3.4

This patch adds a new filter hook in paginate_links() function based on context passed through the argument of the function call.

Provides developers the ability to filter the ouptut/result of paginate_links() on diferent contextes!

I've added the context 'media-upload' in the call of media-upload.php file. This way developers can hack the pagination to, for example, provide a more suitable pagination UI if the Media Library have displayed a lot of pages.

comment:8 @helenyhou3 years ago

  • Version changed from 3.4 to 3.3

Version number indicates when the bug was initially introduced/reported.

comment:9 @nacin20 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Seems like this is no longer applicable as of 3.5. lightningspirit, if there is still a desire (after all these years) for a filter in paginate_links() generally, feel free to reopen. I will mention though that paginate_links() is a low-level utility function that can be used by any context (paginating a post, or comments, or whatever), and it's possible that it's probably just not a good idea.

Note: See TracTickets for help on using tickets.