Merge pull request #1874 from IanDelMar/get-list-item-separator

Add understrap_get_list_item_separator()
This commit is contained in:
Brian Coords 2022-09-28 20:49:10 -07:00 committed by GitHub
commit b943899d88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 4 deletions

View File

@ -92,8 +92,7 @@ if ( ! function_exists( 'understrap_categories_list' ) ) {
* Displays a list of categories.
*/
function understrap_categories_list() {
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( esc_html__( ', ', 'understrap' ) );
$categories_list = get_the_category_list( understrap_get_list_item_separator() );
if ( $categories_list && understrap_categorized_blog() ) {
/* translators: %s: Categories of current post */
printf( '<span class="cat-links">' . esc_html__( 'Posted in %s', 'understrap' ) . '</span>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@ -106,8 +105,7 @@ if ( ! function_exists( 'understrap_tags_list' ) ) {
* Displays a list of tags.
*/
function understrap_tags_list() {
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', esc_html__( ', ', 'understrap' ) );
$tags_list = get_the_tag_list( '', understrap_get_list_item_separator() );
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
/* translators: %s: Tags of current post */
printf( '<span class="tags-links">' . esc_html__( 'Tagged %s', 'understrap' ) . '</span>', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@ -323,3 +321,21 @@ if ( ! function_exists( 'understrap_link_pages' ) ) {
wp_link_pages( $args );
}
}
if ( ! function_exists( 'understrap_get_list_item_separator' ) ) {
/**
* Retrieves the localized list item separator.
*
* `wp_get_list_item_separator()` has been introduced in WP 6.0.0. For WP
* versions lower than 6.0.0 we have to use a custom translation.
*
* @return string Localized list item separator.
*/
function understrap_get_list_item_separator() {
if ( function_exists( 'wp_get_list_item_separator' ) ) {
return esc_html( wp_get_list_item_separator() );
}
/* translators: used between list items, there is a space after the comma */
return esc_html__( ', ', 'understrap' );
}
}

View File

@ -75,6 +75,7 @@
<element value="get_the_title"/>
<element value="get_the_archive_title"/>
<element value="get_the_archive_description"/>
<element value="understrap_get_list_item_separator"/>
</property>
</properties>
</rule>