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
+43 -26
+43 -26
View File
@@ -1,28 +1,45 @@
<?php
/**
* Site header.
*
* @package Super_Simple_WP_Theme
*/
$sswt_site_icon = get_site_icon_url();
?>
<!DOCTYPE html> <!DOCTYPE html>
<html <?php language_attributes(); ?>> <html <?php language_attributes(); ?>>
<head> <head>
<meta charset="<?php bloginfo("charset"); ?>"> <meta charset="<?php bloginfo( 'charset' ); ?>">
<title><?php bloginfo("name"); ?></title> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <?php if ( $sswt_site_icon ) : ?>
<link rel="stylesheet" href="<?php bloginfo("stylesheet_url"); ?>" /> <link rel="icon" href="<?php echo esc_url( $sswt_site_icon ); ?>">
<link rel="icon" href="<?php echo get_site_icon_url(); ?>"> <?php endif; ?>
</head> <?php wp_head(); ?>
<body> </head>
<header> <body <?php body_class(); ?>>
<nav> <?php wp_body_open(); ?>
<div id="nav-grid"> <a class="skip-link screen-reader-text" href="#main"><?php esc_html_e( 'Hopp til innhald', 'super-simple-wp-theme' ); ?></a>
<div class="logo"> <header class="site-header">
<a href="<?php echo home_url(); ?>"> <nav class="site-nav" aria-label="<?php esc_attr_e( 'Hovudmeny', 'super-simple-wp-theme' ); ?>">
<img src="<?php echo get_site_icon_url(); ?>" /> <div id="nav-grid">
<span><?php bloginfo("name"); ?></span> <div class="logo">
</a> <a href="<?php echo esc_url( home_url( '/' ) ); ?>">
</div> <?php if ( $sswt_site_icon ) : ?>
<?php <img src="<?php echo esc_url( $sswt_site_icon ); ?>" alt="">
wp_nav_menu( array( <?php endif; ?>
"theme_location" => "header-menu", <span><?php bloginfo( 'name' ); ?></span>
"container_class" => "header-menu-class" ) ); </a>
?> </div>
<?php
</div> wp_nav_menu(
</nav> array(
</header> 'theme_location' => 'header-menu',
'container_class' => 'header-menu-class',
)
);
?>
</div>
</nav>
</header>
<main id="main" class="site-main">