Preserve the $format and $link arguments for passing to the previous|next_post_link filter. Pass $post to the filter.

Props Otto42, helenyhou
fixes #19640 #18764


git-svn-id: http://core.svn.wordpress.org/trunk@21802 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2012-09-10 21:36:06 +00:00
parent 3205818a04
commit 43a9a11ef9

View File

@ -1370,9 +1370,9 @@ function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_cate
else
$post = get_adjacent_post( $in_same_cat, $excluded_categories, $previous );
if ( !$post )
return;
if ( ! $post ) {
$output = '';
} else {
$title = $post->post_title;
if ( empty( $post->post_title ) )
@ -1383,14 +1383,16 @@ function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_cate
$rel = $previous ? 'prev' : 'next';
$string = '<a href="' . get_permalink( $post ) . '" rel="'.$rel.'">';
$link = str_replace('%title', $title, $link);
$link = str_replace('%date', $date, $link);
$link = $string . $link . '</a>';
$inlink = str_replace( '%title', $title, $link );
$inlink = str_replace( '%date', $date, $inlink );
$inlink = $string . $inlink . '</a>';
$format = str_replace('%link', $link, $format);
$output = str_replace( '%link', $inlink, $format );
}
$adjacent = $previous ? 'previous' : 'next';
echo apply_filters( "{$adjacent}_post_link", $format, $link );
echo apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post );
}
/**