Skip to content

Commit 88d029a

Browse files
committed
refactor: replace bloginfo() calls with direct variable usage for site name and description
1 parent 5f5b651 commit 88d029a

8 files changed

Lines changed: 55 additions & 80 deletions

File tree

src/wp-content/themes/twentyeleven/header.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,14 @@
8282
$is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) );
8383
$site_name = get_bloginfo( 'name' );
8484
$site_description = get_bloginfo( 'description' );
85-
86-
if ( $site_name || $site_description ) :
85+
86+
if ( $site_name ) :
8787
?>
88-
<?php if ( $site_name ) : ?>
89-
<h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>><?php bloginfo( 'name' ); ?></a></span></h1>
90-
<?php endif; ?>
88+
<h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>><?php echo $site_name; ?></a></span></h1>
89+
<?php endif; ?>
9190

92-
<?php if ( $site_description ) : ?>
93-
<h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
94-
<?php endif; ?>
91+
<?php if ( $site_description ) : ?>
92+
<h2 id="site-description"><?php echo $site_description; ?></h2>
9593
<?php endif; ?>
9694
</hgroup>
9795

src/wp-content/themes/twentyfifteen/header.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,17 @@
3636
$is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) );
3737
$site_name = get_bloginfo( 'name' );
3838

39-
if ( $site_name && is_front_page() && is_home() ) :
40-
?>
41-
<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>
42-
<?php elseif ( $site_name ) : ?>
43-
<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>><?php bloginfo( 'name' ); ?></a></p>
44-
<?php
45-
endif;
39+
if ( $site_name && is_front_page() && is_home() ) : ?>
40+
<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>
41+
<?php elseif ( $site_name ) : ?>
42+
<p 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></p>
43+
<?php endif;
44+
45+
$description = get_bloginfo( 'description', 'display' );
46+
if ( $description || is_customize_preview() ) : ?>
47+
<p class="site-description"><?php echo $description; ?></p>
48+
<?php endif; ?>
4649

47-
$description = get_bloginfo( 'description', 'display' );
48-
if ( $description || is_customize_preview() ) :
49-
?>
50-
<p class="site-description"><?php echo $description; ?></p>
51-
<?php
52-
endif;
53-
?>
5450
<button class="secondary-toggle"><?php _e( 'Menu and widgets', 'twentyfifteen' ); ?></button>
5551
</div><!-- .site-branding -->
5652
</header><!-- .site-header -->

src/wp-content/themes/twentyfourteen/header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
$site_name = get_bloginfo( 'name' );
5555
if ( $site_name ) :
5656
?>
57-
<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>
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>
5858
<?php endif; ?>
5959

6060
<div class="search-toggle">

src/wp-content/themes/twentyseventeen/template-parts/header/site-branding.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,15 @@
1919
$is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) );
2020
$site_name = get_bloginfo( 'name' );
2121

22-
if ( $site_name && is_front_page() ) :
23-
?>
24-
<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>
25-
<?php
26-
elseif ( $site_name ) :
27-
?>
28-
<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>><?php bloginfo( 'name' ); ?></a></p>
29-
<?php
30-
endif;
22+
if ( $site_name && is_front_page() ) : ?>
23+
<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>
24+
<?php elseif ( $site_name ) : ?>
25+
<p 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></p>
26+
<?php endif;
3127

3228
$description = get_bloginfo( 'description', 'display' );
3329

34-
if ( $description || is_customize_preview() ) :
35-
?>
30+
if ( $description || is_customize_preview() ) : ?>
3631
<p class="site-description"><?php echo $description; ?></p>
3732
<?php endif; ?>
3833
</div><!-- .site-branding-text -->

src/wp-content/themes/twentysixteen/header.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,14 @@
4040
$is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) );
4141
$site_name = get_bloginfo( 'name' );
4242

43-
if ( $site_name && is_front_page() && is_home() ) :
44-
?>
45-
<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>
46-
<?php
47-
elseif ( $site_name ) :
48-
?>
49-
<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>><?php bloginfo( 'name' ); ?></a></p>
50-
<?php
51-
endif;
43+
if ( $site_name && is_front_page() && is_home() ) : ?>
44+
<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>
45+
<?php elseif ( $site_name ) : ?>
46+
<p 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></p>
47+
<?php endif;
5248

5349
$description = get_bloginfo( 'description', 'display' );
54-
if ( $description || is_customize_preview() ) :
55-
?>
50+
if ( $description || is_customize_preview() ) : ?>
5651
<p class="site-description"><?php echo $description; ?></p>
5752
<?php endif; ?>
5853
</div><!-- .site-branding -->

src/wp-content/themes/twentyten/header.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,19 @@
7474
$site_name = get_bloginfo( 'name' );
7575
$site_description = get_bloginfo( 'description' );
7676

77-
if ( $site_name || $site_description ) :
78-
?>
79-
<?php if ( $site_name ) : ?>
80-
<<?php echo $heading_tag; ?> id="site-title">
81-
<span>
82-
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>><?php bloginfo( 'name' ); ?></a>
83-
</span>
84-
</<?php echo $heading_tag; ?>>
85-
<?php endif; ?>
77+
if ( $site_name ) : ?>
78+
<<?php echo $heading_tag; ?> id="site-title">
79+
<span>
80+
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>><?php echo $site_name; ?></a>
81+
</span>
82+
</<?php echo $heading_tag; ?>>
83+
<?php endif;
8684

87-
<?php if ( $site_description ) : ?>
88-
<div id="site-description"><?php bloginfo( 'description' ); ?></div>
89-
<?php endif; ?>
90-
<?php endif; ?>
85+
if ( $site_description ) : ?>
86+
<div id="site-description"><?php echo $site_description; ?></div>
87+
<?php endif;
9188

92-
<?php
93-
// Compatibility with versions of WordPress prior to 3.4.
89+
// Compatibility with versions of WordPress prior to 3.4.
9490
if ( function_exists( 'get_custom_header' ) ) {
9591
/*
9692
* We need to figure out what the minimum width should be for our featured image.

src/wp-content/themes/twentythirteen/header.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,15 @@
3434
$site_name = get_bloginfo( 'name' );
3535
$site_description = get_bloginfo( 'description' );
3636

37-
if ( $site_name || $site_description ) :
38-
?>
39-
<a class="home-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>>
40-
<?php if ( $site_name ) : ?>
41-
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
42-
<?php endif; ?>
43-
<?php if ( $site_description ) : ?>
44-
<h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
45-
<?php endif; ?>
46-
</a>
47-
<?php endif; ?>
37+
?>
38+
<a class="home-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>>
39+
<?php if ( $site_name ) : ?>
40+
<h1 class="site-title"><?php echo $site_name; ?></h1>
41+
<?php endif; ?>
42+
<?php if ( $site_description ) : ?>
43+
<h2 class="site-description"><?php echo $site_description; ?></h2>
44+
<?php endif; ?>
45+
</a>
4846

4947
<div id="navbar" class="navbar">
5048
<nav id="site-navigation" class="navigation main-navigation">

src/wp-content/themes/twentytwelve/header.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,13 @@
4141
$is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) );
4242
$site_name = get_bloginfo( 'name' );
4343
$site_description = get_bloginfo( 'description' );
44+
45+
if ( $site_name ) : ?>
46+
<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>
47+
<?php endif;
4448

45-
if ( $site_name || $site_description ) :
46-
?>
47-
<?php if ( $site_name ) : ?>
48-
<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>
49-
<?php endif; ?>
50-
51-
<?php if ( $site_description ) : ?>
52-
<h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
53-
<?php endif; ?>
49+
if ( $site_description ) : ?>
50+
<h2 class="site-description"><?php echo $site_description; ?></h2>
5451
<?php endif; ?>
5552
</hgroup>
5653

0 commit comments

Comments
 (0)