Rewrite header.php for 2.0.0

- Add wp_head(), body_class() and wp_body_open().
- Drop the hardcoded <title>; title-tag now handles it.
- Add a skip link as the first element in <body>.
- Wrap the header in <header class="site-header"> and the menu in
  <nav class="site-nav">. The existing #nav-grid and .header-menu-class
  hooks are untouched.
- Skip the icon <link> and the logo <img> when there is no site icon, and
  give the logo image an empty alt (the site name text follows it in the
  same link, so the image is decorative).
- Open <main id="main"> after the header.
- Keep the viewport meta tag.
This commit is contained in:
ai-bot committed 2026-10-14 08:33:37 +00:00
1 parent 3e772c5547
commit 1469cd7f02
1 file changed
+32 -15
+32 -15
View File
@@ -1,28 +1,45 @@
<?php
/**
* Site header.
*
* @package Super_Simple_WP_Theme
*/
$sswt_site_icon = get_site_icon_url();
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo("charset"); ?>">
<title><?php bloginfo("name"); ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="<?php bloginfo("stylesheet_url"); ?>" />
<link rel="icon" href="<?php echo get_site_icon_url(); ?>">
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php if ( $sswt_site_icon ) : ?>
<link rel="icon" href="<?php echo esc_url( $sswt_site_icon ); ?>">
<?php endif; ?>
<?php wp_head(); ?>
</head>
<body>
<header>
<nav>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<a class="skip-link screen-reader-text" href="#main"><?php esc_html_e( 'Hopp til innhald', 'super-simple-wp-theme' ); ?></a>
<header class="site-header">
<nav class="site-nav" aria-label="<?php esc_attr_e( 'Hovudmeny', 'super-simple-wp-theme' ); ?>">
<div id="nav-grid">
<div class="logo">
<a href="<?php echo home_url(); ?>">
<img src="<?php echo get_site_icon_url(); ?>" />
<span><?php bloginfo("name"); ?></span>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php if ( $sswt_site_icon ) : ?>
<img src="<?php echo esc_url( $sswt_site_icon ); ?>" alt="">
<?php endif; ?>
<span><?php bloginfo( 'name' ); ?></span>
</a>
</div>
<?php
wp_nav_menu( array(
"theme_location" => "header-menu",
"container_class" => "header-menu-class" ) );
wp_nav_menu(
array(
'theme_location' => 'header-menu',
'container_class' => 'header-menu-class',
)
);
?>
</div>
</nav>
</header>
<main id="main" class="site-main">