[wp-trac] [WordPress Trac] #19640: adjacent_post_link filter hook missing $post
WordPress Trac
wp-trac at lists.automattic.com
Wed Dec 21 18:42:53 UTC 2011
#19640: adjacent_post_link filter hook missing $post
--------------------------+-----------------------------
Reporter: tychay | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.3
Severity: minor | Keywords:
--------------------------+-----------------------------
wp-includes/link-template.php, line 1369
is:
apply_filters( "{$adjacent}_post_link", $format, $link );
should be:
apply_filters( "{$adjacent}_post_link", $format, $link, $post );
Reason:
Users may want to do replacement in post link that requires information
about the post. For instance, inserting the author into the link. Example,
if the post link format contains "%author" the following code will inject
the author name of the next/previous post into it.
function advent_author_format_link($format, $link, $post) {
$author = get_userdata($post->post_author);
$format = str_replace('%author', $author->display_name, $format);
return $format;
return array(
'format' => $format,
'post' => $post,
);
}
add_action('previous_post_link', 'advent_author_format_link', 10, 3);
add_action('next_post_link', 'advent_author_format_link', 10, 3);
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19640>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list