Allow `the_title_attribute()` to receive a `post` argument, and use this in `get_adjacent_post_rel_link()` to make sure tags are stripped from the title output there.
Fixes #24232. git-svn-id: https://develop.svn.wordpress.org/trunk@24783 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
76ecd259fd
commit
d8310e4c7e
|
@ -1220,16 +1220,15 @@ function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $ex
|
|||
if ( empty($post) )
|
||||
return;
|
||||
|
||||
if ( empty($post->post_title) )
|
||||
$post_title = the_title_attribute( array( 'echo' => false, 'post' => $post ) );
|
||||
|
||||
if ( empty( $post_title ) )
|
||||
$post_title = $previous ? __('Previous Post') : __('Next Post');
|
||||
else
|
||||
$post_title = $post->post_title;
|
||||
|
||||
$date = mysql2date(get_option('date_format'), $post->post_date);
|
||||
|
||||
$title = str_replace('%title', $post_title, $title);
|
||||
$title = str_replace('%date', $date, $title);
|
||||
$title = apply_filters('the_title', $title, $post->ID);
|
||||
|
||||
$link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
|
||||
$link .= esc_attr( $title );
|
||||
|
|
|
@ -69,15 +69,15 @@ function the_title($before = '', $after = '', $echo = true) {
|
|||
* @return string|null Null on failure or display. String when echo is false.
|
||||
*/
|
||||
function the_title_attribute( $args = '' ) {
|
||||
$title = get_the_title();
|
||||
$defaults = array('before' => '', 'after' => '', 'echo' => true, 'post' => get_post() );
|
||||
$r = wp_parse_args($args, $defaults);
|
||||
extract( $r, EXTR_SKIP );
|
||||
|
||||
$title = get_the_title( $post );
|
||||
|
||||
if ( strlen($title) == 0 )
|
||||
return;
|
||||
|
||||
$defaults = array('before' => '', 'after' => '', 'echo' => true);
|
||||
$r = wp_parse_args($args, $defaults);
|
||||
extract( $r, EXTR_SKIP );
|
||||
|
||||
$title = $before . $title . $after;
|
||||
$title = esc_attr(strip_tags($title));
|
||||
|
||||
|
|
Loading…
Reference in New Issue