-
Notifications
You must be signed in to change notification settings - Fork 26
/
header.php
232 lines (217 loc) · 7.77 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php if (is_home()) {
bloginfo('name');
echo " - ";
bloginfo('description');
} else if (is_category()) {
single_cat_title();
echo " - ";
bloginfo('name');
} else if (is_single()) {
single_post_title();
echo " - ";
bloginfo('name');
} else if (is_search()) {
echo "搜索结果";
echo " - ";
bloginfo('name');
} else if (is_404()) {
echo "页面未找到";
} else if (is_tag()) {
single_tag_title();
echo " - ";
bloginfo('name');
} else {
wp_title('', true);
echo " - ";
bloginfo('name');
} ?></title>
<?php
global $set;
$options = get_option('baolog_framework');
$keywords = $options['baolog-keywords'];
$description = $options['baolog-description'];
if (is_home()) {
if ($description == null) {
$description = get_bloginfo('description');
}
} else if (is_single() || is_page()) {
global $post;
global $baolog_post_meta;
$baolog_post_meta = json_decode(get_post_meta($post->ID, 'baolog_post_meta', true), true);
if (empty($baolog_post_meta['seo']['open'])) {
$baolog_post_meta['seo']['open'] = 0;
}
if (empty($baolog_post_meta['closesidebar'])) {
$baolog_post_meta['closesidebar'] = 0;
}
if (empty($baolog_post_meta['postrighttag']['open'])) {
$baolog_post_meta['postrighttag']['open'] = 0;
}
if (empty($baolog_post_meta['catalog'])) {
$baolog_post_meta['catalog'] = 0;
}
if ($baolog_post_meta['seo']['open'] == 1) {
$description = $baolog_post_meta['seo']['description'];
$keywords = $baolog_post_meta['seo']['keywords'];
} else {
$description = str_replace("\n", "", mb_strimwidth(strip_tags($post->post_content), 0, 200, "…", 'utf-8'));
$tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag) {
$keywords = $keywords . $tag->name . ", ";
}
$keywords = rtrim($keywords, ', ');
}
} elseif (is_tag()) {
// 标签的description可以到后台 - 文章 - 标签,修改标签的描述
$description = tag_description();
$keywords = single_tag_title('', false);
} elseif (is_category()) {
$description = category_description();
$keywords = single_tag_title('', false);
}
$description = trim(strip_tags($description));
$keywords = trim(strip_tags($keywords));
if (post_password_required() == false) {
?><meta name="keywords" content="<?php echo $keywords; ?>"/>
<meta name="description" content="<?php echo $description; ?>"/>
<?php
}
?><meta name="renderer" content="webkit"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>"/>
<link rel="shortcut icon" href="<?php
$options = get_option('baolog_framework');
echo $options['baolog-favicon'];
?>">
<link rel="icon" sizes="32x32" href="<?php
$options = get_option('baolog_framework');
echo $options['baolog-favicon'];
?>">
<link rel="Bookmark" href="<?php
$options = get_option('baolog_framework');
echo $options['baolog-favicon'];
?>">
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/ghboke/corepresscdn@master/static/lib/fontawesome5pro/css/all.min.css?v=5.6">
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/bootstrap.css">
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/baolog.css">
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/huux-notice.css" name="huux_notice">
<?php wp_head(); ?>
<style>
table.nav_tag_list {
margin-bottom: 0.2rem;
}
table.nav_tag_list td {
padding: 0.3rem;
}
table.nav_tag_list td a {
margin-right: 0.2rem;
}
.nav_tag_list .active {
font-weight: normal
}
.tag_option {
border: 1px solid #bbb;
padding: 1px 10px;
border-radius: 10px;
text-decoration: none;
}
.tag_option:active,
.tag_option.active {
border: 1px solid #000;
background: #000;
color: #fff;
text-decoration: none;
}
</style>
<style type="text/css" data-model="huux_hlight">
.huux_thread_hlight_style1 {
color: #D9534D;
font-weight: normal
}
.huux_thread_hlight_style2 {
color: #F0AD4E;
font-weight: normal
}
.huux_thread_hlight_style3 {
color: #5BC0DE;
font-weight: normal
}
.huux_thread_hlight_style4 {
color: #5CB85C;
font-weight: normal
}
.huux_thread_hlight_style5 {
color: #337AB7;
font-weight: normal
}
</style>
<style class="mpa-style-fix ImageGatherer">
.FotorFrame {
position: fixed !important
}
</style>
<style class="mpa-style-fix SideFunctionPanel">
.weui-desktop-online-faq__wrp {
top: 304px !important;
bottom: unset !important
}
.weui-desktop-online-faq__wrp .weui-desktop-online-faq__switch {
width: 38px !important
}
</style>
</head>
<!--刷新缓存-->
<?php flush(); ?>
<div class="header mb-3">
<div class="container">
<div class="jumbotron bg-white mb-0 text-center hidden-sm">
<h1><a href="<?php echo get_option('home'); ?>"><?php bloginfo('name') ?></a></h1>
<span class="text-grey"><?php
$options = get_option('baolog_framework');
echo $options['baolog-description'];
?></span>
</div>
<div class="d-sm-none d-block text-center mt-4">
<h2><a href="<?php echo get_option('home'); ?>"><?php bloginfo('name') ?></a></h2>
</div>
<!--primary menu-->
<nav class="row">
<?php
if (has_nav_menu('menu_primary')) {
wp_nav_menu(array(
'theme_location' => 'menu_primary',
'container_class' => 'col-sm-8 px-0',
'menu_class' => 'nav sm-center',
'menu_id' => 'menu-primary-items',
'fallback_cb' => '', 'depth' => 2,
'walker' => new baolog_Walker_Nav_Menu())
);
} else {
echo '<div class="col-sm-8 px-0">
<ul class="nav sm-center">
<li class="nav-item">
<a class="nav-link" href="' . get_option('home') . '">
首页 </a>
</li>';
echo '<li class="nav-item">
<a class="nav-link" href="' . get_option('home') . '/wp-admin/nav-menus.php">
请到后台添加导航(我是主导航)</a>
</li>';
echo '</ul></div>';
}
?>
<!--搜索-->
<div class="col-sm-4">
<?php get_search_form(); ?>
</div>
</nav>
</div>
</div>