Skip to content

Commit

Permalink
Merge pull request #582 from tomusborne/feature/add-read-more-filters
Browse files Browse the repository at this point in the history
Feature: Add read more label filters
  • Loading branch information
tomusborne authored Nov 8, 2023
2 parents 8ccb7d3 + 0e7695d commit 06c18a9
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions inc/structure/post-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,8 @@ function generate_excerpt_more( $more ) {
' ... <a title="%1$s" class="read-more" href="%2$s" aria-label="%4$s">%3$s</a>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) ),
__( 'Read more', 'generatepress' ),
sprintf(
/* translators: Aria-label describing the read more button */
_x( 'More on %s', 'more on post title', 'generatepress' ),
the_title_attribute( 'echo=0' )
)
generate_get_read_more_text(),
generate_get_read_more_aria_label()
)
);
}
Expand All @@ -481,12 +477,8 @@ function generate_content_more( $more ) {
'<p class="read-more-container"><a title="%1$s" class="read-more content-read-more" href="%2$s" aria-label="%4$s">%3$s</a></p>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) . apply_filters( 'generate_more_jump', '#more-' . get_the_ID() ) ),
__( 'Read more', 'generatepress' ),
sprintf(
/* translators: Aria-label describing the read more button */
_x( 'More on %s', 'more on post title', 'generatepress' ),
the_title_attribute( 'echo=0' )
)
generate_get_read_more_text(),
generate_get_read_more_aria_label()
)
);
}
Expand Down Expand Up @@ -577,3 +569,31 @@ function generate_do_post_navigation( $template ) {
generate_content_nav( 'nav-below' );
}
}

/**
* Returns the read more text for our posts.
*
* @since 3.4.0
*/
function generate_get_read_more_text() {
return apply_filters(
'generate_excerpt_more_text',
__( 'Read more', 'generatepress' )
);
}

/**
* Returns the read more `aria-label` for our posts.
*
* @since 3.4.0
*/
function generate_get_read_more_aria_label() {
return apply_filters(
'generate_excerpt_more_aria_label',
sprintf(
/* translators: Aria-label describing the read more button */
_x( 'Read more about %s', 'read more about post title', 'generatepress' ),
the_title_attribute( 'echo=0' )
)
);
}

0 comments on commit 06c18a9

Please sign in to comment.