Make WordPress Core

Ticket #44124: 44124.1.diff

File 44124.1.diff, 2.2 KB (added by ianbelanger, 7 years ago)

Updated diff to move foreach inside is_countable() condition

  • src/wp-admin/custom-header.php

     
    283283                        $type    = 'uploaded';
    284284                }
    285285
    286                 if ( 1 < count( $headers ) ) {
     286                if ( is_countable( $headers ) && count( $headers ) > 1 ) {
    287287                        echo '<div class="random-header">';
    288288                        echo '<label><input name="default-header" type="radio" value="random-' . $type . '-image"' . checked( is_random_header_image( $type ), true, false ) . ' />';
    289289                        _e( '<strong>Random:</strong> Show a different image on each page.' );
    290290                        echo '</label>';
    291291                        echo '</div>';
    292                 }
    293292
    294                 echo '<div class="available-headers">';
    295                 foreach ( $headers as $header_key => $header ) {
    296                         $header_thumbnail = $header['thumbnail_url'];
    297                         $header_url       = $header['url'];
    298                         $header_alt_text  = empty( $header['alt_text'] ) ? '' : $header['alt_text'];
    299                         echo '<div class="default-header">';
    300                         echo '<label><input name="default-header" type="radio" value="' . esc_attr( $header_key ) . '" ' . checked( $header_url, get_theme_mod( 'header_image' ), false ) . ' />';
    301                         $width = '';
    302                         if ( ! empty( $header['attachment_id'] ) ) {
    303                                 $width = ' width="230"';
     293                        echo '<div class="available-headers">';
     294                        foreach ( $headers as $header_key => $header ) {
     295                                $header_thumbnail = $header['thumbnail_url'];
     296                                $header_url       = $header['url'];
     297                                $header_alt_text  = empty( $header['alt_text'] ) ? '' : $header['alt_text'];
     298                                echo '<div class="default-header">';
     299                                echo '<label><input name="default-header" type="radio" value="' . esc_attr( $header_key ) . '" ' . checked( $header_url, get_theme_mod( 'header_image' ), false ) . ' />';
     300                                $width = '';
     301                                if ( ! empty( $header['attachment_id'] ) ) {
     302                                        $width = ' width="230"';
     303                                }
     304                                echo '<img src="' . set_url_scheme( $header_thumbnail ) . '" alt="' . esc_attr( $header_alt_text ) . '"' . $width . ' /></label>';
     305                                echo '</div>';
    304306                        }
    305                         echo '<img src="' . set_url_scheme( $header_thumbnail ) . '" alt="' . esc_attr( $header_alt_text ) . '"' . $width . ' /></label>';
    306                         echo '</div>';
     307                        echo '<div class="clear"></div></div>';
    307308                }
    308                 echo '<div class="clear"></div></div>';
    309309        }
    310310
    311311        /**