Make WordPress Core

Ticket #37011: 37011.6.diff

File 37011.6.diff, 2.4 KB (added by sabernhardt, 3 years ago)

aria-current option for linked logo

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

     
    10211021                        'class' => 'custom-logo',
    10221022                );
    10231023
    1024                 if ( is_front_page() ) {
     1024                $unlink_homepage_logo = get_theme_support( 'custom-logo', 'unlink-homepage-logo' ) ? true : false;
     1025
     1026                if ( is_front_page() && $unlink_homepage_logo ) {
    10251027                        /*
    10261028                         * If on the home page, set the logo alt attribute to an empty string,
    10271029                         * as the image is decorative and doesn't need its purpose to be described.
     
    10551057                 */
    10561058                $image = wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr );
    10571059
    1058                 if ( is_front_page() ) {
     1060                if ( is_front_page() && $unlink_homepage_logo ) {
    10591061                        // If on the home page, don't link the logo to home.
    10601062                        $html = sprintf(
    10611063                                '<span class="custom-logo-link">%1$s</span>',
     
    10621064                                $image
    10631065                        );
    10641066                } else {
     1067                        $aria_current = is_front_page() ? ' aria-current="page"' : '';
    10651068                        $html = sprintf(
    1066                                 '<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
     1069                                '<a href="%1$s" class="custom-logo-link" rel="home"%2$s>%3$s</a>',
    10671070                                esc_url( home_url( '/' ) ),
     1071                                $aria_current,
    10681072                                $image
    10691073                        );
    10701074                }
  • src/wp-includes/theme.php

     
    24722472 * @since 5.3.0 Formalized the existing and already documented `...$args` parameter
    24732473 *              by adding it to the function signature.
    24742474 * @since 5.5.0 The `core-block-patterns` feature was added and is enabled by default.
     2475 * @since 5.5.0 The `custom-logo` feature now also accepts `unlink-homepage-logo`.
    24752476 *
    24762477 * @global array $_wp_theme_features
    24772478 *
     
    25382539                                $args = array( 0 => array() );
    25392540                        }
    25402541                        $defaults = array(
    2541                                 'width'       => null,
    2542                                 'height'      => null,
    2543                                 'flex-width'  => false,
    2544                                 'flex-height' => false,
    2545                                 'header-text' => '',
     2542                                'width'                => null,
     2543                                'height'               => null,
     2544                                'flex-width'           => false,
     2545                                'flex-height'          => false,
     2546                                'header-text'          => '',
     2547                                'unlink-homepage-logo' => false,
    25462548                        );
    25472549                        $args[0]  = wp_parse_args( array_intersect_key( $args[0], $defaults ), $defaults );
    25482550