Files
Sophia-After-Dark/header.php
2025-05-20 23:47:21 -07:00

91 lines
2.9 KiB
PHP

<?php
/**
* The header for our theme
*
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package Sophia After Dark
* @since 1.0.0
*/
?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="https://gmpg.org/xfn/11">
<?php
// Set default author for home page OG metadata
$author_id = (int) get_option( 'sophia_after_dark_home_og_user', 1 );
$author_bio = get_the_author_meta( 'description', $author_id );
if ( is_front_page() ) {
$home_og_image = get_option( 'sophia_after_dark_home_og_image' );
if ( $home_og_image ) {
printf( '<meta property="og:image" content="%s" />' . "\n", esc_url( $home_og_image ) );
}
printf( '<meta property="og:title" content="%s" />' . "\n", esc_attr( get_bloginfo( 'name' ) . ' - ' . get_bloginfo( 'description' ) ) );
printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( $author_bio ) );
printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( home_url( '/' ) ) );
} elseif ( is_singular() ) {
global $post;
$thumbnail_url = get_template_directory_uri() . '/assets/images/default-og-image.webp';
if ( has_post_thumbnail( $post?->ID ) ) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'og-image-size' );
if ( ! empty( $image[0] ) ) {
$thumbnail_url = $image[0];
}
}
printf( '<meta property="og:image" content="%s" />' . "\n", esc_url( $thumbnail_url ) );
printf( '<meta property="og:title" content="%s" />' . "\n", esc_attr( get_the_title() ) );
printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( get_the_excerpt() ) );
printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( get_permalink() ) );
}
wp_head();
?>
</head>
<body <?php body_class(); ?>>
<?php
if ( function_exists( 'wp_body_open' ) ) {
wp_body_open();
} else {
do_action( 'wp_body_open' ); // Backwards compatibility for < WP 5.2
}
do_action( 'sophia_after_dark_before_page' );
?>
<div id="page" class="site">
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'sophia-after-dark' ); ?></a>
<?php
// Top Header
if ( get_theme_mod( 'sophia_after_dark_enable_top_header', false ) ) {
do_action( 'sophia_after_dark_top_header' );
}
// Main Header
do_action( 'sophia_after_dark_main_header' );
// Front page slider or inner page header
if ( is_front_page() ) {
do_action( 'sophia_after_dark_front_slider_section' );
} else {
do_action( 'sophia_after_dark_innerpage_header' );
}
?>
<div id="content" class="site-content">
<div class="sad-container">