[wp-trac] [WordPress Trac] #18674: Filter in adjacent_post_link is broken
WordPress Trac
wp-trac at lists.automattic.com
Thu Sep 15 18:41:03 UTC 2011
#18674: Filter in adjacent_post_link is broken
--------------------------+-----------------------------
Reporter: Otto42 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Permalinks | Version: 3.2.1
Severity: normal | Keywords:
--------------------------+-----------------------------
A filter in the adjacent_post_link function looks like this:
{{{
$adjacent = $previous ? 'previous' : 'next';
echo apply_filters( "{$adjacent}_post_link", $format, $link );
}}}
The intent here seems fairly clear, in that the $format and $link
variables are arguments to the original function call.
However, the function itself overwrites both of those variables before it
ever gets there. The result is that both $format and $link are useless by
this point, and so you can't create a different link with the same format
as the original call wanted. All you can do is to replace it entirely,
without knowing what format was wanted.
So as it stands, these arguments to the filter are more than a little
useless.
To fix this, adjacent_post_link shouldn't overwrite its own arguments
here, so it can pass the information further on to the filter.
Furthermore, the filter itself should be an actual filter, passing the
$format and $link as second and third arguments to the function.
Patch upcoming.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18674>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list