WordPress.org

Make WordPress Core

Ticket #37011: 37011.2.diff

File 37011.2.diff, 1.6 KB (added by sabernhardt, 19 months ago)

maintaining a container element, revising conditional logic, updating function information

  • src/wp-includes/general-template.php

     
    939939}
    940940
    941941/**
    942  * Returns a custom logo, linked to home.
     942 * Returns a custom logo, linked to home when on another page.
    943943 *
    944944 * @since 4.5.0
     945 * @since 5.5.0 Removed link on the home or front page.
    945946 *
    946947 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
    947948 * @return string Custom logo markup.
     
    976977                 * If the alt attribute is not empty, there's no need to explicitly pass
    977978                 * it because wp_get_attachment_image() already adds the alt attribute.
    978979                 */
    979                 $html = sprintf(
    980                         '<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
    981                         esc_url( home_url( '/' ) ),
    982                         wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
    983                 );
     980                if ( is_front_page() ) {
     981                        // If on the home or front page, don’t link the logo to home.
     982                        $html = sprintf(
     983                                '<span class="custom-logo-link">%1$s</span>',
     984                                wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
     985                        );
     986                } else {
     987                        $html = sprintf(
     988                                '<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
     989                                esc_url( home_url( '/' ) ),
     990                                wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
     991                        );
     992                }
    984993        } elseif ( is_customize_preview() ) {
    985994                // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
    986995                $html = sprintf(