Bundled Themes: Consistently check for WP_Error before outputting get_the_tag_list().

Some themes already had these checks in place as a result of [41756], but not others.

Props sixhours, davidakennedy, SergeyBiryukov.
Fixes #39860.

git-svn-id: https://develop.svn.wordpress.org/trunk@47886 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-06-02 17:03:06 +00:00
parent 49f03fff79
commit ffd5d37c77
11 changed files with 55 additions and 35 deletions

View File

@ -33,9 +33,9 @@ global $feature_class;
<footer class="entry-meta">
<?php
/* translators: Used between list items, there is a space after the comma. */
$tag_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
if ( '' !== $tag_list ) {
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
/* translators: 1: Category list, 2: Tag list, 3: Post permalink, 4: Post title. */
$utility_text = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' );
} else {
@ -47,7 +47,7 @@ global $feature_class;
$utility_text,
/* translators: Used between list items, there is a space after the comma. */
get_the_category_list( __( ', ', 'twentyeleven' ) ),
$tag_list,
$tags_list,
esc_url( get_permalink() ),
the_title_attribute( 'echo=0' )
);

View File

@ -70,9 +70,11 @@
<footer class="entry-meta">
<?php $show_sep = false; ?>
<?php
/* translators: Used between list items, there is a space after the comma. */
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
/* translators: Used between list items, there is a space after the comma. */
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
if ( $categories_list ) :
?>
<span class="cat-links">
@ -83,10 +85,12 @@
?>
</span>
<?php endif; // End if categories. ?>
<?php
/* translators: Used between list items, there is a space after the comma. */
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
if ( $tags_list ) :
/* translators: Used between list items, there is a space after the comma. */
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
if ( $tags_list && ! is_wp_error( $tags_list ) ) :
if ( $show_sep ) :
?>
<span class="sep"> | </span>

View File

@ -55,8 +55,9 @@
</div><!-- .entry-meta -->
<div class="entry-meta">
<?php
/* translators: Used between list items, there is a space after the comma. */
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
/* translators: Used between list items, there is a space after the comma. */
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
if ( $categories_list ) :
?>
<span class="cat-links">
@ -66,10 +67,12 @@
?>
</span>
<?php endif; // End if categories. ?>
<?php
/* translators: Used between list items, there is a space after the comma. */
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
if ( $tags_list ) :
/* translators: Used between list items, there is a space after the comma. */
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
if ( $tags_list && ! is_wp_error( $tags_list ) ) :
?>
<span class="tag-links">
<?php

View File

@ -46,9 +46,11 @@
<footer class="entry-meta">
<?php $show_sep = false; ?>
<?php
/* translators: Used between list items, there is a space after the comma. */
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
/* translators: Used between list items, there is a space after the comma. */
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
if ( $categories_list ) :
?>
<span class="cat-links">
@ -59,10 +61,12 @@
?>
</span>
<?php endif; // End if categories. ?>
<?php
/* translators: Used between list items, there is a space after the comma. */
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
if ( $tags_list ) :
/* translators: Used between list items, there is a space after the comma. */
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
if ( $tags_list && ! is_wp_error( $tags_list ) ) :
if ( $show_sep ) :
?>
<span class="sep"> | </span>

View File

@ -37,12 +37,12 @@
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
/* translators: Used between list items, there is a space after the comma. */
$tag_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
if ( '' !== $tag_list ) {
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
/* translators: 1: Categories list, 2: Tag list, 3: Permalink, 4: Post title, 5: Author name, 6: Author URL. */
$utility_text = __( 'This entry was posted in %1$s and tagged %2$s by <a href="%6$s">%5$s</a>. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' );
} elseif ( '' !== $categories_list ) {
} elseif ( $categories_list ) {
/* translators: 1: Categories list, 2: Tag list, 3: Permalink, 4: Post title, 5: Author name, 6: Author URL. */
$utility_text = __( 'This entry was posted in %1$s by <a href="%6$s">%5$s</a>. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' );
} else {
@ -53,7 +53,7 @@
printf(
$utility_text,
$categories_list,
$tag_list,
$tags_list,
esc_url( get_permalink() ),
the_title_attribute( 'echo=0' ),
get_the_author(),

View File

@ -52,10 +52,12 @@
<footer class="entry-meta">
<?php $show_sep = false; ?>
<?php if ( is_object_in_taxonomy( get_post_type(), 'category' ) ) : // Hide category text when not supported. ?>
<?php
/* translators: Used between list items, there is a space after the comma. */
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
if ( $categories_list ) :
?>
<span class="cat-links">
@ -67,11 +69,13 @@
</span>
<?php endif; // End if categories. ?>
<?php endif; // End if is_object_in_taxonomy( get_post_type(), 'category' ). ?>
<?php if ( is_object_in_taxonomy( get_post_type(), 'post_tag' ) ) : // Hide tag text when not supported. ?>
<?php
/* translators: Used between list items, there is a space after the comma. */
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
if ( $tags_list ) :
if ( $tags_list && ! is_wp_error( $tags_list ) ) :
if ( $show_sep ) :
?>
<span class="sep"> | </span>

View File

@ -96,7 +96,7 @@ if ( ! function_exists( 'twentynineteen_entry_footer' ) ) :
/* translators: Used between list items, there is a space after the comma. */
$tags_list = get_the_tag_list( '', __( ', ', 'twentynineteen' ) );
if ( $tags_list ) {
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
printf(
/* translators: 1: SVG icon. 2: Posted in label, only visible to screen readers. 3: List of tags. */
'<span class="tags-links">%1$s<span class="screen-reader-text">%2$s </span>%3$s</span>',

View File

@ -630,8 +630,9 @@ if ( ! function_exists( 'twentyten_posted_in' ) ) :
*/
function twentyten_posted_in() {
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list( '', ', ' );
if ( $tag_list && ! is_wp_error( $tag_list ) ) {
$tags_list = get_the_tag_list( '', ', ' );
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
/* translators: 1: Category name, 2: Tag name, 3: Post permalink, 4: Post title. */
$posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
@ -641,11 +642,12 @@ if ( ! function_exists( 'twentyten_posted_in' ) ) :
/* translators: 3: Post permalink, 4: Post title. */
$posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
}
// Prints the string, replacing the placeholders.
printf(
$posted_in,
get_the_category_list( ', ' ),
$tag_list,
$tags_list,
get_permalink(),
the_title_attribute( 'echo=0' )
);

View File

@ -176,9 +176,10 @@ while ( have_posts() ) :
</span>
<span class="meta-sep">|</span>
<?php endif; ?>
<?php
$tags_list = get_the_tag_list( '', ', ' );
if ( $tags_list ) :
$tags_list = get_the_tag_list( '', ', ' );
if ( $tags_list && ! is_wp_error( $tags_list ) ) :
?>
<span class="tag-links">
<?php
@ -188,7 +189,9 @@ while ( have_posts() ) :
</span>
<span class="meta-sep">|</span>
<?php endif; ?>
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-utility -->
</div><!-- #post-<?php the_ID(); ?> -->

View File

@ -489,9 +489,9 @@ if ( ! function_exists( 'twentythirteen_entry_meta' ) ) :
}
/* translators: Used between list items, there is a space after the comma. */
$tag_list = get_the_tag_list( '', __( ', ', 'twentythirteen' ) );
if ( $tag_list ) {
echo '<span class="tags-links">' . $tag_list . '</span>';
$tags_list = get_the_tag_list( '', __( ', ', 'twentythirteen' ) );
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
echo '<span class="tags-links">' . $tags_list . '</span>';
}
// Post author.

View File

@ -501,7 +501,7 @@ if ( ! function_exists( 'twentytwelve_entry_meta' ) ) :
$categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );
/* translators: Used between list items, there is a space after the comma. */
$tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
$tags_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
$date = sprintf(
'<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
@ -519,7 +519,7 @@ if ( ! function_exists( 'twentytwelve_entry_meta' ) ) :
get_the_author()
);
if ( $tag_list ) {
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
/* translators: 1: Category name, 2: Tag name, 3: Date, 4: Author display name. */
$utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
} elseif ( $categories_list ) {
@ -533,7 +533,7 @@ if ( ! function_exists( 'twentytwelve_entry_meta' ) ) :
printf(
$utility_text,
$categories_list,
$tag_list,
$tags_list,
$date,
$author
);