Make WordPress Core


Ignore:
Timestamp:
07/18/2025 03:29:06 AM (13 months ago)
Author:
joedolson
Message:

Bundled Theme: Prevent output of empty title tags.

In Twenty Ten, Twenty Eleven, Twenty Twelve, Twenty Thirteen, Twenty Fourteen, Twenty Fifteen, Twenty Sixteen, Twenty Seventeen, and Twenty Twenty, an empty site title would result in an empty heading and/or an empty link in the site header. These can pollute the heading hierarchy and add a un-named link in screen reader navigation.

Prevent the output of wrapping tags if site title or site description have no value.

Props tsquez, audrasjb, sabernhardt, rehanali, sukhendu2002, dilipbheda, sirlouen, joedolson.
Fixes #44656.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfourteen/header.php

    r59991 r60483  
    5151        <header id="masthead" class="site-header">
    5252                <div class="header-main">
    53                         <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>><?php bloginfo( 'name' ); ?></a></h1>
     53                        <?php
     54                        $site_name = get_bloginfo( 'name', 'display' );
     55                        if ( $site_name ) :
     56                                ?>
     57                                <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>><?php echo $site_name; ?></a></h1>
     58                        <?php endif; ?>
    5459
    5560                        <div class="search-toggle">
Note: See TracChangeset for help on using the changeset viewer.