Make WordPress Core

Ticket #37011: 37011.3.alt.diff

File 37011.3.alt.diff, 2.3 KB (added by SergeyBiryukov, 4 years ago)
  • src/wp-includes/general-template.php

     
    940940}
    941941
    942942/**
    943  * Returns a custom logo, linked to home.
     943 * Returns a custom logo, linked to home.
    944944 *
    945945 * @since 4.5.0
     946
    946947 *
    947948 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
    948949 * @return string Custom logo markup.
     
    965966                );
    966967
    967968                /*
    968                  * If the logo alt attribute is empty, get the site title and explicitly
    969                  * pass it to the attributes used by wp_get_attachment_image().
     969                 * If the logo alt attribute is empty, get the site title and explicitly
     970                 * to the attributes used by wp_get_attachment_image().
    970971                 */
    971972                $image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
    972973                if ( empty( $image_alt ) ) {
     
    974975                }
    975976
    976977                /*
    977                  * If the alt attribute is not empty, there's no need to explicitly pass
    978                  * it because wp_get_attachment_image() already adds the alt attribute.
     978                 * If the alt attribute is not empty, there's no need to explicitly pass
     979                 * because wp_get_attachment_image() already adds the alt attribute.
    979980                 */
    980                 $html = sprintf(
    981                         '<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
    982                         esc_url( home_url( '/' ) ),
    983                         wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
    984                 );
     981                $image = wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr );
     982
     983                if ( is_front_page() ) {
     984                        // If on the home page, don't link the logo to home.
     985                        $html = sprintf(
     986                                '<span class="custom-logo-link">%1$s</span>',
     987                                $image
     988                        );
     989                } else {
     990                        $html = sprintf(
     991                                '<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
     992                                esc_url( home_url( '/' ) ),
     993                                $image
     994                        );
     995                }
    985996        } elseif ( is_customize_preview() ) {
    986997                // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
    987998                $html = sprintf(
     
    10071018}
    10081019
    10091020/**
    1010  * Displays a custom logo, linked to home.
     1021 * Displays a custom logo, linked to home.
    10111022 *
    10121023 * @since 4.5.0
    10131024 *