File: /www/wwwroot/vietktv.vn/wp-content/themes/binhvu/header.php
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="robots" content="index, follow" />
<meta name="revisit-after" content="1 days" />
<?php
// ====== Helpers an toàn cho ACF ======
if (!function_exists('vkt_safe_get_field')) {
function vkt_safe_get_field($key, $post_id = 'option', $default = '') {
return function_exists('get_field') ? get_field($key, $post_id) : $default;
}
}
if (!function_exists('vkt_safe_the_field')) {
function vkt_safe_the_field($key, $post_id = 'option') {
if (function_exists('the_field')) the_field($key, $post_id);
}
}
// Robots cho trang search (có thể dời vào hook nếu vẫn báo notice)
if (function_exists('is_search') && is_search()) {
echo '<meta name="robots" content="noindex, nofollow" />';
}
// SEO meta cơ bản từ ACF Options (an toàn khi thiếu ACF)
if (function_exists('is_home') && is_home()) : ?>
<?php $meta_desc = vkt_safe_get_field('meta_description', 'option'); ?>
<?php $meta_keyw = vkt_safe_get_field('meta_keyword', 'option'); ?>
<?php if (!empty($meta_desc)) : ?>
<meta name="description" content="<?php echo esc_attr($meta_desc); ?>"/>
<?php endif; ?>
<?php if (!empty($meta_keyw)) : ?>
<meta name="keywords" content="<?php echo esc_attr($meta_keyw); ?>"/>
<?php endif; ?>
<title><?php echo esc_html( vkt_safe_get_field('home_title', 'option', get_bloginfo('name')) ); ?></title>
<?php else: ?>
<title><?php wp_title(''); ?></title>
<?php endif; ?>
<?php wp_head(); ?>
<link href="https://fonts.googleapis.com/css?family=Roboto|Pacifico" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<?php
// Favicon: ưu tiên ACF, fallback site icon
$favicon = vkt_safe_get_field('favicon', 'option');
if (!$favicon && function_exists('get_site_icon_url')) {
$favicon = get_site_icon_url();
}
if ($favicon) : ?>
<link rel="shortcut icon" href="<?php echo esc_url($favicon); ?>">
<?php endif; ?>
<?php
// Code header tùy biến từ ACF (nếu có)
$code_header = vkt_safe_get_field('code_header', 'option');
if (!empty($code_header)) {
// In thẳng vì có thể chứa script/meta tùy biến của bạn
echo $code_header; // phấn đấu chỉ cho admin chèn code tin cậy
}
?>
</head>
<body <?php body_class(); ?>>
<div id="page">
<header>
<div class="header-top">
<div class="container-fluid">
<div class="row">
<div class="col-md-4 col-sm-6 top-name-company">
<?php
// Logo: ACF 'logo' (option) -> site icon -> text
$logo_url = vkt_safe_get_field('logo', 'option');
if (!$logo_url && function_exists('get_site_icon_url')) {
$logo_url = get_site_icon_url();
}
$home_href = esc_url( home_url('/') );
$site_name = esc_attr( get_bloginfo('name') );
?>
<?php if (function_exists('is_home') && is_home()) : ?>
<h1 style="margin:0;">
<a href="<?php echo $home_href; ?>" title="<?php echo $site_name; ?>">
<?php if ($logo_url): ?>
<img src="<?php echo esc_url($logo_url); ?>" alt="<?php echo $site_name; ?>" title="<?php echo $site_name; ?>"/>
<?php else: ?>
<?php echo $site_name; ?>
<?php endif; ?>
</a>
</h1>
<?php else: ?>
<h2 style="margin:0;">
<a href="<?php echo $home_href; ?>" title="<?php echo $site_name; ?>">
<?php if ($logo_url): ?>
<img src="<?php echo esc_url($logo_url); ?>" alt="<?php echo $site_name; ?>" title="<?php echo $site_name; ?>"/>
<?php else: ?>
<?php echo $site_name; ?>
<?php endif; ?>
</a>
</h2>
<?php endif; ?>
</div>
<div class="col-md-4 col-sm-6 hidden-xs">
<div class="smart-search search-form3 search-form5">
<form role="search" method="get" class="smart-search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<input type="hidden" name="post_type" value="product">
<input type="text" name="s" value="<?php echo esc_attr( get_search_query() ); ?>" placeholder="Nhập từ khóa tìm kiếm" required/>
<input type="submit" value=" ">
</form>
</div>
</div>
<div class="col-md-4 col-sm-12 hidden-xs">
<div class="wrap-cart-info">
<div class="h_social chudam">
<div style="position: relative;height: 32px;display: inline-block;top:0px;right: 0;" id="b_ol">
<div style="cursor: pointer;">Hỗ trợ trực tuyến </div>
<div class="support_content " style="display: none;">
<div class="support_box">
<div class="css_box"><div class="cssText"></div></div>
</div>
<div class="clear_fix"></div>
<span style="float:left;margin-top:20px;display:block;font-weight:bold;width:100%;color:#0086f1;">
Để được hỗ trợ kỹ thuật Quý khách vui lòng gọi
<?php vkt_safe_the_field('hotline','option'); ?>
</span>
</div>
</div>
</div>
</div>
</div>
</div><!-- .row -->
</div><!-- .container-fluid -->
</div><!-- .header-top -->
<div class="menu-site">
<div class="container-fluid">
<div class="row">
<div class="hidden-md hidden-lg hidden-sm">
<div class="col-xs-2 break-col text-center">
<a href="#menu" class="btn btn-show-menu hidden-md hidden-lg"><i class="fa fa-bars"></i></a>
</div>
<div class="col-xs-10">
<div class="smart-search search-form3 search-form5">
<form role="search" method="get" class="smart-search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<input type="hidden" name="post_type" value="product">
<input type="text" name="s" value="<?php echo esc_attr( get_search_query() ); ?>" placeholder="Nhập từ khóa tìm kiếm" required/>
<input type="submit" value=" ">
</form>
</div>
</div>
</div>
<div class="menu-box">
<div class="bg-menu hidden-md hidden-lg"></div>
<div class="col-sm-3 col-md-3 pull-left hidden-xs">
<div class="wrap-cat-pro">
<div class="category-dropdown hidden-dropdown right-category-dropdown">
<h2 class="title-category-dropdown"><span>DANH MỤC SẢN PHẨM</span></h2>
</div>
<?php
wp_nav_menu( array(
'theme_location' => 'category_nav',
'container' => 'div',
'container_class' => 'vertical-menu-menu',
'menu_class' => 'menu',
'menu_id' => 'menu-vertical-menu-1',
));
?>
</div>
</div>
<div class="col-md-9 col-sm-9 wrap-menu-primary">
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'container' => 'div',
'container_class' => 'menu-menu-chinh-container',
'menu_class' => 'main-menu',
'menu_id' => 'menu-menu-chinh'
));
?>
</div>
</div><!-- .menu-box -->
</div><!-- .row -->
</div><!-- .container-fluid -->
</div><!-- .menu-site -->
</header>