Skip to content

Commit 2b2b29a

Browse files
committed
Explore refactors in post-template
1 parent 97139af commit 2b2b29a

1 file changed

Lines changed: 24 additions & 14 deletions

File tree

src/wp-includes/post-template.php

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -296,19 +296,21 @@ function get_the_content( $more_link_text = null, $strip_teaser = false, $post =
296296
}
297297

298298
if ( null === $more_link_text ) {
299-
$more_link_text = sprintf(
300-
'<span aria-label="%1$s">%2$s</span>',
301-
sprintf(
302-
/* translators: %s: Post title. */
303-
__( 'Continue reading %s' ),
304-
the_title_attribute(
305-
array(
306-
'echo' => false,
307-
'post' => $_post,
299+
$more_link_text = WP_HTML::render(
300+
'<span aria-label="</%label>"></%title></span>',
301+
array(
302+
'label' => sprintf(
303+
/* translators: %s: Post title. */
304+
__( 'Continue reading %s' ),
305+
the_title_attribute(
306+
array(
307+
'echo' => false,
308+
'post' => $_post,
309+
)
308310
)
309-
)
310-
),
311-
__( '(more&hellip;)' )
311+
),
312+
'title' => __( '(more&hellip;)' ),
313+
)
312314
);
313315
}
314316

@@ -359,9 +361,17 @@ function get_the_content( $more_link_text = null, $strip_teaser = false, $post =
359361

360362
if ( count( $content ) > 1 ) {
361363
if ( $elements['more'] ) {
362-
$output .= '<span id="more-' . $_post->ID . '"></span>' . $content[1];
364+
$output .= WP_HTML::render( '<span id="more-</%id>"></span>', array( 'id' => $_post->ID ) );
365+
$output .= $content[1];
363366
} else {
364367
if ( ! empty( $more_link_text ) ) {
368+
$link_html = WP_HTML::render(
369+
'<a href="</%post_link>" class="more-link"></%link_text></a>',
370+
array(
371+
'post_link' => get_permalink( $_post ) . "#more-{$_post->ID}",
372+
'link_text' => $more_link_text,
373+
)
374+
);
365375

366376
/**
367377
* Filters the Read More link text.
@@ -371,7 +381,7 @@ function get_the_content( $more_link_text = null, $strip_teaser = false, $post =
371381
* @param string $more_link_element Read More link element.
372382
* @param string $more_link_text Read More text.
373383
*/
374-
$output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink( $_post ) . "#more-{$_post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
384+
$output .= apply_filters( 'the_content_more_link', $link_html, $more_link_text );
375385
}
376386
$output = force_balance_tags( $output );
377387
}

0 commit comments

Comments
 (0)