Make WordPress Core

Opened 8 years ago

Last modified 4 years ago

#39251 new defect (bug)

Support end_size=0 in paginate_links()

Reported by: danielbachhuber's profile danielbachhuber Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch has-unit-tests
Focuses: Cc:

Description (last modified by danielbachhuber)

Passing end_size=0 produces one link when I'd expect it to produce zero links.

When using paginate_links() on the homepage of a site with thousands of posts, having an end size link of 1885, etc. is a bit crazy.

Attachments (1)

39251.patch (1.9 KB) - added by birgire 7 years ago.

Download all attachments as: .zip

Change History (5)

#1 @danielbachhuber
8 years ago

  • Description modified (diff)

@birgire
7 years ago

#3 @birgire
7 years ago

  • Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed

This:

$links = paginate_links( array(
    'total'         => 10,
    'current'       => 5,
    'mid_size'      => 1,
    'end_size'      => 0,
) );

will generate:

Previous 1 ... 4 [5] 6 ... 10 Next

but with 39251.patch it generates:

Previous ... 4 [5] 6 ... Next

PS:

We might get a better control if we supported e.g. arrays like:

'end_size' => array( 1, 0 ),  // left and right parts
'mid_size' => array( 1, 2 ),  // left and right parts

to generate:

Previous 1 ... 4 [5] 6 7 ... Next

Just thinking out loud, I wonder if it would be more flexible with e.g.

echo paginate_links( array(
        'walker'  	=> new RomanNumeralsPaginator,
) );

where the default paginator class would handle paginating objects and mimic some parts of the wp_nav_menu().

... or something more suitable than a walker.

But maybe it would be too much ;-)

Last edited 7 years ago by birgire (previous) (diff)

#4 @kriskl
4 years ago

Hi, any chance of adding the patch to this bug in the next / future release?

Last edited 4 years ago by kriskl (previous) (diff)
Note: See TracTickets for help on using tickets.