967 | | /* |
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(). |
970 | | */ |
971 | | $image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true ); |
972 | | if ( empty( $image_alt ) ) { |
973 | | $custom_logo_attr['alt'] = get_bloginfo( 'name', 'display' ); |
| 968 | if ( is_front_page() ) { |
| 969 | /* |
| 970 | * If on the home page, set the logo alt attribute to an empty string, |
| 971 | * as the image is decorative and doesn't need its purpose to be described. |
| 972 | */ |
| 973 | $custom_logo_attr['alt'] = ''; |
| 974 | } else { |
| 975 | /* |
| 976 | * If the logo alt attribute is empty, get the site title and explicitly pass it |
| 977 | * to the attributes used by wp_get_attachment_image(). |
| 978 | */ |
| 979 | $image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true ); |
| 980 | if ( empty( $image_alt ) ) { |
| 981 | $custom_logo_attr['alt'] = get_bloginfo( 'name', 'display' ); |
| 982 | } |
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 | | ); |
| 989 | $image = wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr ); |
| 990 | |
| 991 | if ( is_front_page() ) { |
| 992 | // If on the home page, don't link the logo to home. |
| 993 | $html = sprintf( |
| 994 | '<span class="custom-logo-link">%1$s</span>', |
| 995 | $image |
| 996 | ); |
| 997 | } else { |
| 998 | $html = sprintf( |
| 999 | '<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>', |
| 1000 | esc_url( home_url( '/' ) ), |
| 1001 | $image |
| 1002 | ); |
| 1003 | } |