[wp-trac] [WordPress Trac] #24606: Paginate links' "base" default value causes page 2 to display links incorrectly.
WordPress Trac
noreply at wordpress.org
Wed Jun 19 13:33:50 UTC 2013
#24606: Paginate links' "base" default value causes page 2 to display links
incorrectly.
--------------------------+-----------------------------
Reporter: Nessworthy | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.5.1
Severity: normal | Keywords:
--------------------------+-----------------------------
Let's say if I called the following:
{{{
echo paginate_links( array(
'current' => $current_page, // must be 2 to replicate
'total' => $total_pages, // e.g. 5
) );
}}}
The following results in 'previous' and '1' page links becoming equal to
the current URL. This means that if 'current' is being taken from the URL
directly, the two links will always be equal to the second page.
Dissecting the source {{{ general-template.php:1922 }}}, I can see that
there is a check in the code where, if the current page is 2, it changes
how the link is displayed. Here's the line:
{{{
$link = str_replace('%_%', 2 == $current ? '' : $format, $base);
}}}
So, using the default settings and setting the current page as two,
{{{ $link }}} becomes an empty string.
This is because the default ({{{'%_%'}}}) is being replaced by an empty
string instead of {{{ $format }}}.
Because link then doesn't contain the placeholder needed to show the
intended page number, it remains empty when the next line is ran:
{{{ $link = str_replace('%#%', $current - 1, $link); }}}
If no additional data is appended via. add args / add fragment, the string
remains empty at the time of output, which browsers then default it to the
current page URL.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/24606>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list