-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathheader.php
109 lines (89 loc) · 5.25 KB
/
header.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="anonymous">
<link rel="dns-prefetch" href="https://fonts.googleapis.com">
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
<?php
// get material icons setting
$material_icons_setting = get_theme_mod( 'hovercraft_material_icons', 'classic_only' );
// map available material icons
$material_icons_map = array(
'classic_only' => 'Material+Icons',
'classic_and_outlined' => 'Material+Icons&family=Material+Icons+Outlined',
'classic_and_outlined_and_two_toned' => 'Material+Icons&family=Material+Icons+Outlined&family=Material+Icons+Two+Tone',
);
// output material icons if not 'none' and valid
if ( $material_icons_setting !== 'none' && isset( $material_icons_map[ $material_icons_setting ] ) ) {
?><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=<?php echo esc_attr( $material_icons_map[ $material_icons_setting ] ); ?>&display=block"><?php
} ?>
<?php
// get font awesome setting
$font_awesome_setting = get_theme_mod( 'hovercraft_font_awesome', 'none' );
// map available font awesome versions
$font_awesome_map = array(
'version_6' => 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css',
'version_5' => 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css',
'version_4' => 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/all.min.css',
);
// output font awesome if not 'none' and valid
if ( $font_awesome_setting !== 'none' && isset( $font_awesome_map[ $font_awesome_setting ] ) ) {
?><link rel="stylesheet" href="<?php echo esc_url( $font_awesome_map[ $font_awesome_setting ] ); ?>"><?php
} ?>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono&display=block">
<?php
// inline parent theme's stylesheet
$parent_style_path = get_template_directory() . '/style.css';
if ( is_readable( $parent_style_path ) ) {
?><style><?php readfile( $parent_style_path ); ?></style><?php
} ?>
<?php
// inline child theme's stylesheet
$child_style_path = get_stylesheet_directory() . '/style.css';
if ( is_readable( $child_style_path ) ) {
?><style><?php readfile( $child_style_path ); ?></style><?php
} ?>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<?php get_template_part( 'template-parts/header/mobile-menu' ); ?>
<div id="container"><!-- main container -->
<?php if ( is_active_sidebar( 'hovercraft_topbar_left' ) || is_active_sidebar( 'hovercraft_topbar_right' ) ) : ?>
<div id="topbar">
<div class="inner">
<?php
// disable widget titles for topbar
add_filter( 'widget_title', '__return_false' );
if ( is_active_sidebar( 'hovercraft_topbar_left' ) && is_active_sidebar( 'hovercraft_topbar_right' ) ) : ?>
<div class="topbar-left">
<?php dynamic_sidebar( 'hovercraft_topbar_left' ); ?>
</div><!-- topbar-left -->
<div class="topbar-right">
<?php dynamic_sidebar( 'hovercraft_topbar_right' ); ?>
</div><!-- topbar-right -->
<?php else : ?>
<div class="topbar-center">
<?php
if ( is_active_sidebar( 'hovercraft_topbar_left' ) ) {
dynamic_sidebar( 'hovercraft_topbar_left' );
} else {
dynamic_sidebar( 'hovercraft_topbar_right' );
}
?>
</div><!-- topbar-center -->
<?php endif;
// restore widget titles after topbar
remove_filter( 'widget_title', '__return_false' ); ?>
<div class="clear"></div><!-- clear floats -->
</div><!-- inner -->
</div><!-- topbar -->
<?php endif; ?>
<!-- Ref: ChatGPT -->
<!-- Ref: https://stackoverflow.com/questions/13903918/apply-widget-title-filter-only-to-wordpress-widgets-from-a-certain-sidebar -->
<!-- Ref: https://wordpress.stackexchange.com/questions/419686/how-to-retrieve-blog-language-without-any-region-locale-attached -->
<!-- Ref: https://stackoverflow.com/questions/48021086/how-to-avoid-font-awesome-loading-jumping-when-opening-a-page -->
<!-- Ref: https://www.smashingmagazine.com/2021/05/reduce-font-loading-impact-css-descriptors/ -->