Make WordPress Core

Changeset 47886


Ignore:
Timestamp:
06/02/2020 05:03:06 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src/wp-content/themes
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyeleven/content-featured.php

    r47808 r47886  
    3434        <?php
    3535        /* translators: Used between list items, there is a space after the comma. */
    36         $tag_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
     36        $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
    3737
    38         if ( '' !== $tag_list ) {
     38        if ( $tags_list && ! is_wp_error( $tags_list ) ) {
    3939            /* translators: 1: Category list, 2: Tag list, 3: Post permalink, 4: Post title. */
    4040            $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' );
     
    4848            /* translators: Used between list items, there is a space after the comma. */
    4949            get_the_category_list( __( ', ', 'twentyeleven' ) ),
    50             $tag_list,
     50            $tags_list,
    5151            esc_url( get_permalink() ),
    5252            the_title_attribute( 'echo=0' )
  • trunk/src/wp-content/themes/twentyeleven/content-gallery.php

    r47122 r47886  
    7171    <footer class="entry-meta">
    7272        <?php $show_sep = false; ?>
     73
    7374        <?php
    74             /* translators: Used between list items, there is a space after the comma. */
    75             $categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
     75        /* translators: Used between list items, there is a space after the comma. */
     76        $categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
     77
    7678        if ( $categories_list ) :
    7779            ?>
     
    8486        </span>
    8587        <?php endif; // End if categories. ?>
     88
    8689        <?php
    87             /* translators: Used between list items, there is a space after the comma. */
    88             $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
    89         if ( $tags_list ) :
     90        /* translators: Used between list items, there is a space after the comma. */
     91        $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
     92
     93        if ( $tags_list && ! is_wp_error( $tags_list ) ) :
    9094            if ( $show_sep ) :
    9195                ?>
  • trunk/src/wp-content/themes/twentyeleven/content-image.php

    r47122 r47886  
    5656            <div class="entry-meta">
    5757                <?php
    58                     /* translators: Used between list items, there is a space after the comma. */
    59                     $categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
     58                /* translators: Used between list items, there is a space after the comma. */
     59                $categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
     60
    6061                if ( $categories_list ) :
    6162                    ?>
     
    6768                </span>
    6869                <?php endif; // End if categories. ?>
     70
    6971                <?php
    70                     /* translators: Used between list items, there is a space after the comma. */
    71                     $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
    72                 if ( $tags_list ) :
     72                /* translators: Used between list items, there is a space after the comma. */
     73                $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
     74
     75                if ( $tags_list && ! is_wp_error( $tags_list ) ) :
    7376                    ?>
    7477                <span class="tag-links">
  • trunk/src/wp-content/themes/twentyeleven/content-quote.php

    r47122 r47886  
    4747        <footer class="entry-meta">
    4848            <?php $show_sep = false; ?>
     49
    4950            <?php
    50                 /* translators: Used between list items, there is a space after the comma. */
    51                 $categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
     51            /* translators: Used between list items, there is a space after the comma. */
     52            $categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
     53
    5254            if ( $categories_list ) :
    5355                ?>
     
    6062            </span>
    6163            <?php endif; // End if categories. ?>
     64
    6265            <?php
    63                 /* translators: Used between list items, there is a space after the comma. */
    64                 $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
    65             if ( $tags_list ) :
     66            /* translators: Used between list items, there is a space after the comma. */
     67            $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
     68
     69            if ( $tags_list && ! is_wp_error( $tags_list ) ) :
    6670                if ( $show_sep ) :
    6771                    ?>
  • trunk/src/wp-content/themes/twentyeleven/content-single.php

    r47808 r47886  
    3838
    3939        /* translators: Used between list items, there is a space after the comma. */
    40         $tag_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
     40        $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
    4141
    42         if ( '' !== $tag_list ) {
     42        if ( $tags_list && ! is_wp_error( $tags_list ) ) {
    4343            /* translators: 1: Categories list, 2: Tag list, 3: Permalink, 4: Post title, 5: Author name, 6: Author URL. */
    4444            $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' );
    45         } elseif ( '' !== $categories_list ) {
     45        } elseif ( $categories_list ) {
    4646            /* translators: 1: Categories list, 2: Tag list, 3: Permalink, 4: Post title, 5: Author name, 6: Author URL. */
    4747            $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' );
     
    5454            $utility_text,
    5555            $categories_list,
    56             $tag_list,
     56            $tags_list,
    5757            esc_url( get_permalink() ),
    5858            the_title_attribute( 'echo=0' ),
  • trunk/src/wp-content/themes/twentyeleven/content.php

    r47808 r47886  
    5353        <footer class="entry-meta">
    5454            <?php $show_sep = false; ?>
     55
    5556            <?php if ( is_object_in_taxonomy( get_post_type(), 'category' ) ) : // Hide category text when not supported. ?>
    5657                <?php
    5758                /* translators: Used between list items, there is a space after the comma. */
    5859                $categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
     60
    5961                if ( $categories_list ) :
    6062                    ?>
     
    6870                <?php endif; // End if categories. ?>
    6971            <?php endif; // End if is_object_in_taxonomy( get_post_type(), 'category' ). ?>
     72
    7073            <?php if ( is_object_in_taxonomy( get_post_type(), 'post_tag' ) ) : // Hide tag text when not supported. ?>
    7174                <?php
    7275                /* translators: Used between list items, there is a space after the comma. */
    7376                $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
    74                 if ( $tags_list ) :
     77
     78                if ( $tags_list && ! is_wp_error( $tags_list ) ) :
    7579                    if ( $show_sep ) :
    7680                        ?>
  • trunk/src/wp-content/themes/twentynineteen/inc/template-tags.php

    r47122 r47886  
    9797            /* translators: Used between list items, there is a space after the comma. */
    9898            $tags_list = get_the_tag_list( '', __( ', ', 'twentynineteen' ) );
    99             if ( $tags_list ) {
     99            if ( $tags_list && ! is_wp_error( $tags_list ) ) {
    100100                printf(
    101101                    /* translators: 1: SVG icon. 2: Posted in label, only visible to screen readers. 3: List of tags. */
  • trunk/src/wp-content/themes/twentyten/functions.php

    r47597 r47886  
    631631    function twentyten_posted_in() {
    632632        // Retrieves tag list of current post, separated by commas.
    633         $tag_list = get_the_tag_list( '', ', ' );
    634         if ( $tag_list && ! is_wp_error( $tag_list ) ) {
     633        $tags_list = get_the_tag_list( '', ', ' );
     634
     635        if ( $tags_list && ! is_wp_error( $tags_list ) ) {
    635636            /* translators: 1: Category name, 2: Tag name, 3: Post permalink, 4: Post title. */
    636637            $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' );
     
    642643            $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
    643644        }
     645
    644646        // Prints the string, replacing the placeholders.
    645647        printf(
    646648            $posted_in,
    647649            get_the_category_list( ', ' ),
    648             $tag_list,
     650            $tags_list,
    649651            get_permalink(),
    650652            the_title_attribute( 'echo=0' )
  • trunk/src/wp-content/themes/twentyten/loop.php

    r47808 r47886  
    177177                    <span class="meta-sep">|</span>
    178178                <?php endif; ?>
     179
    179180                <?php
    180                     $tags_list = get_the_tag_list( '', ', ' );
    181                 if ( $tags_list ) :
     181                $tags_list = get_the_tag_list( '', ', ' );
     182                if ( $tags_list && ! is_wp_error( $tags_list ) ) :
    182183                    ?>
    183184                <span class="tag-links">
     
    189190                <span class="meta-sep">|</span>
    190191                <?php endif; ?>
     192
    191193                <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
     194
    192195                <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
    193196            </div><!-- .entry-utility -->
  • trunk/src/wp-content/themes/twentythirteen/functions.php

    r47808 r47886  
    490490
    491491        /* translators: Used between list items, there is a space after the comma. */
    492         $tag_list = get_the_tag_list( '', __( ', ', 'twentythirteen' ) );
    493         if ( $tag_list ) {
    494             echo '<span class="tags-links">' . $tag_list . '</span>';
     492        $tags_list = get_the_tag_list( '', __( ', ', 'twentythirteen' ) );
     493        if ( $tags_list && ! is_wp_error( $tags_list ) ) {
     494            echo '<span class="tags-links">' . $tags_list . '</span>';
    495495        }
    496496
  • trunk/src/wp-content/themes/twentytwelve/functions.php

    r47808 r47886  
    502502
    503503        /* translators: Used between list items, there is a space after the comma. */
    504         $tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
     504        $tags_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
    505505
    506506        $date = sprintf(
     
    520520        );
    521521
    522         if ( $tag_list ) {
     522        if ( $tags_list && ! is_wp_error( $tags_list ) ) {
    523523            /* translators: 1: Category name, 2: Tag name, 3: Date, 4: Author display name. */
    524524            $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' );
     
    534534            $utility_text,
    535535            $categories_list,
    536             $tag_list,
     536            $tags_list,
    537537            $date,
    538538            $author
Note: See TracChangeset for help on using the changeset viewer.