[wp-trac] [WordPress Trac] #12247: wp_link_pages link_before link_after used wrong and not just with <a> tags
WordPress Trac
wp-trac at lists.automattic.com
Tue Feb 16 08:54:17 UTC 2010
#12247: wp_link_pages link_before link_after used wrong and not just with <a> tags
--------------------------+-------------------------------------------------
Reporter: openmtl | Owner:
Type: defect (bug) | Status: new
Priority: low | Milestone: Unassigned
Component: Themes | Version: 2.9.1
Severity: trivial | Keywords: has-patch
--------------------------+-------------------------------------------------
In the function wp_link_pages() in /wp-includes/post-template.php then
there is an illogical use of the link_before and link_after options. The
function states that....
{{{
* 'link_before' - Default is '' (string). The html or text to prepend to
each
* Pages link inside the <a> tag.
* 'link_after' - Default is '' (string). The html or text to append to
each
* Pages link inside the <a> tag.
}}}
but this actually wraps around any page number irrespective of it of has
the 'a' href tag or not i.e. the current page that you are on which is not
an 'a' tag also gets this link_before and link_after styling. That is
wrong. The fix is easy. In post-template.php remove the lines 590 to 594
where it says,
{{{
$output .= $link_before;
$output .= $j;
$output .= $link_after;
if ( ($i != $page) || ((!$more) && ($page==1)) )
$output .= '</a>';
}}}
then change this to e.g.,
{{{
if ( ($i != $page) || ((!$more) && ($page==1)) ) {
$output .= $link_before;
$output .= $j;
$output .= $link_after;
$output .= '</a>';
} else {
$output .= $j;
}
}}}
I've tested this on 2.9.1 and the effect is that BEFORE my patch if
$link_before and $link_after is used then all the numbers of the
(sub)pages at the bottom of a page get the characters before and after,
e.g.,
['''1'''] [''2''] ['''3'''] ['''4'''] ['''5''']
whereas if my patch is added then, correctly, only those subpages that
actually are 'a' tags get the text before and after e.g. it looks like,
['''1''']'' 2'' ['''3'''] ['''4'''] ['''5''']
Also that function should really also style non-links too but thats a new
feature not a bug.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/12247>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list