Make WordPress Core

Ticket #52683: 52683.diff

File 52683.diff, 1.8 KB (added by sabernhardt, 3 years ago)

checking for user-defined "more" text in the_content_more_link, updating comments and docs

  • src/wp-content/themes/twentytwentyone/inc/template-functions.php

     
    134134 */
    135135function twenty_twenty_one_continue_reading_text() {
    136136        $continue_reading = sprintf(
    137                 /* translators: %s: Name of current post. */
     137                /* translators: %s: Post title. Only visible to screen readers. */
    138138                esc_html__( 'Continue reading %s', 'twentytwentyone' ),
    139139                the_title( '<span class="screen-reader-text">', '</span>', false )
    140140        );
     
    160160 * Creates the continue reading link.
    161161 *
    162162 * @since Twenty Twenty-One 1.0
     163 * @since Twenty Twenty-One 1.6 Checks for user-defined "more" text.
    163164 */
    164 function twenty_twenty_one_continue_reading_link() {
     165function twenty_twenty_one_continue_reading_link( $more_link, $more_link_text ) {
    165166        if ( ! is_admin() ) {
    166                 return '<div class="more-link-container"><a class="more-link" href="' . esc_url( get_permalink() ) . '#more-' . esc_attr( get_the_ID() ) . '">' . twenty_twenty_one_continue_reading_text() . '</a></div>';
     167                $continue_reading_text = ( $more_link_text === twenty_twenty_one_continue_reading_text() ) ? twenty_twenty_one_continue_reading_text() : $more_link_text;
     168                return '<div class="more-link-container"><a class="more-link" href="' . esc_url( get_permalink() ) . '#more-' . esc_attr( get_the_ID() ) . '">' . $continue_reading_text . '</a></div>';
    167169        }
    168170}
    169171
    170 // Filter the excerpt more link.
    171 add_filter( 'the_content_more_link', 'twenty_twenty_one_continue_reading_link' );
     172// Filter the content more link.
     173add_filter( 'the_content_more_link', 'twenty_twenty_one_continue_reading_link', 10, 2 );
    172174
    173175if ( ! function_exists( 'twenty_twenty_one_post_title' ) ) {
    174176        /**