Update paginate_links() with 4 new arguments

Context

The current implementation of paginate_links( $args = '' ) is a bit of a mess and misses a few crucial features.
Instead of hacking core or messing around with filters that are not supposed to do what I need the function to do, I did (use it myself on several plugins) “replace” that function by basically creating a new custom function (better_paginate_links) that I use in my plugins.

Now I would like to ask the community if the changes I made to the function in my own plugins, would be welcome in core, so we can push it.
The code is ready to be PRd, so no big work required other than review.
Nothing existing gets destroyed, only new features added.
The changes are useful for example when using Bootstrap or simply wanting more control over the HTML generated by the function.

New Features

These new args are added:

@type string $li_classes Classes to be added to each LIST element. Default: empty. Accepts: valid HTML classes.
@type string $ul_classes Classes to be added to the UL element. Default: empty. Accepts: valid HTML classes.
@type string $a_classes Classes to be added to each a href element. Default: empty. Accepts: valid HTML classes.
@type string $current_classes Classes to be added to each span (aria current) element. Default: empty. Accepts: valid HTML classes.

This allows you to control the generated HTML lists, ul and a href classes without having to use a (totally unperformant) filter to alter the HTML produced and add eventual classes you might need for example for a proper Bootstrap Pagination.

Will you be able to help with the implementation?

Already done, battle tested.
Just need to PR it.

Lets see if we can gather a few votes for this. If it is generally agreed that no votes are needed, we can also just comment a yay and I can still PR it.

Voted, this makes sense. Working with pagination in WordPress can be difficult.

These should be added as new values accepted for the existing $args array that this function receives, rather than new parameters to the paginate_links function.

The reason is that if we add new parameters to functions, and then WP ends up also adding a different new parameter to the same function, we have a mess and no way to retain compatibility. When there is another way to achieve something like this without changing a function signature it is best to do it that way. The $args arrays are perfect for this.

As long as it’s done that way, then no problem here.

1 Like

Yeah same here

New $args array member, function arguments don’t change per se

1 Like

PR:

3 Likes

Great job @smileBeda. Since this petition has a pull request now, I’ve updated its status and will set it to close to release votes. Any discussions related to PR should be done on GitHub.

2 Likes

This topic was automatically closed after 5 days. New replies are no longer allowed.