forked from ghboke/CorePressWPTheme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.php
242 lines (216 loc) · 7.88 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
233
234
235
236
237
238
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="Referrer" content="origin"/>
<?php
global $set;
if ($set['code']['headcode'] != null) {
echo base64_decode($set['code']['headcode']);
}
if ($set['code']['css'] != null) {
echo "<style>" . base64_decode($set['code']['css']) . "</style>";
}
if ($set['code']['alifront'] != null) {
echo '<style>.icon {width: 18px; height: 18px;vertical-align: -3px;fill: currentColor;overflow: hidden;}</style>';
}
if ($set['theme']['bagimg'] != null) {
if (!is_page_template('page-login.php') && !is_page_template('page-reg.php')) {
if ($set['theme']['bagimg_showtype'] == 1) {
echo "<style>html, body, #app {background-image: url('{$set['theme']['bagimg']}')!important;background-position: center center;background-attachment: fixed;background-size: cover;}</style>";
} else {
echo "<style>html, body, #app {background-image: url('{$set['theme']['bagimg']}')!important;background-position: center center;background-attachment: fixed;}</style>";
}
}
}
if ($set['routine']['favicon'] != null) {
?>
<link rel="icon" href="<?php echo $set['routine']['favicon'] ?>" type="image/x-icon"/>
<?php
}
?>
<style>
:root {
--Maincolor: <?php echo $set['theme']['themeColor']?> !important;
--MaincolorHover: <?php echo $set['theme']['themeHoverColor']?> !important;
--fontSelectedColor: <?php echo $set['theme']['fontSelectedColor']?> !important;
}
</style>
<?php
if ($set['module']['preventred'] == 1) {
if (is_wx_qq()) {
die('网站不支持QQ或者微信内访问,请点击右上角菜单,使用外部浏览器打开网站');
}
}
if ($set['theme']['font'] != 'no') {
echo '<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/ghboke/corepresscdn@master/static/lib/font/' . $set['theme']['font'] . '/font.css">';
?>
<style>
html, textarea {
font-family: <?php echo $set['theme']['font']?>, PingFang\ SC, Hiragino\ Sans\ GB, Microsoft\ YaHei, STHeiti, WenQuanYi\ Micro\ Hei, Helvetica, Arial, sans-serif !important;
}
</style>
<?php
}
file_load_css('main-mobile.css');
loadiconfont_by_cdn();
file_load_css('main.css');
file_load_js('jquery.min.js');
wp_head();
if ($set['module']['imglazyload'] == 1) {
file_load_js('jquery.lazyload.min.js');
}
file_load_js('tools.js');
if (is_home()) {
file_load_lib('swiper/swiper.min.css', 'css');
file_load_lib('swiper/swiper.min.js', 'js');
}
global $set;
if (is_home()) {
if ($set['seo']['openseo'] == 1) {
if ($set['seo']['indextitle'] != '') {
$title = $set['seo']['indextitle'];
} else {
$title = get_bloginfo('name');
}
} else {
$title = get_bloginfo('name');
}
} elseif (is_single() || is_page()) {
if ($set['post']['imgradius'] == 1) {
?>
<style>
.post-content-post img {
border-radius: 10px;
}
</style>
<?php
}
if ($set['post']['imgshadow'] == 1) {
?>
<style>
post-content-content img {
box-shadow: 0 0 5px 0 rgba(0, 0, 0, .1);
}
</style>
<?php
}
file_load_js('qrcode.min.js');
file_load_js('clipboard.min.js');
file_load_css('comment-module.css');
file_load_css('post-content.css');
file_load_lib('fancybox/jquery.fancybox.min.css', 'css');
file_load_lib('fancybox/jquery.fancybox.min.js', 'js');
file_load_lib('fancybox/init.js', 'js');
if ($set['module']['highlight'] == 1) {
file_load_lib('highlight/highlight.min.js', 'js');
if ($set['module']['highlighttheme'] == 1) {
file_load_lib('highlight/style/corepress-dark.css', 'css');
} else {
file_load_lib('highlight/style/corepress.css', 'css');
}
}
if ($set['seo']['openseo'] == 1) {
$delimiter = $set['seo']['title_delimiter'];
if ($set['seo']['titlestyle'] == 'site_title') {
$title = get_bloginfo('name') . $delimiter . get_the_title();
} elseif ($set['seo']['titlestyle'] == 'title_site') {
$title = get_the_title() . $delimiter . get_bloginfo('name');
} else {
$title = get_the_title();
}
} else {
$title = get_the_title();
}
} elseif (is_category() || is_tag()) {
$delimiter = $set['seo']['title_delimiter'];
if ($set['seo']['openseo'] == 1) {
if ($set['seo']['titlestyle'] == 'site_title') {
$title = get_bloginfo('name') . $delimiter . single_cat_title('', false);
} elseif ($set['seo']['titlestyle'] == 'title_site') {
$title = single_cat_title('', false) . $delimiter . get_bloginfo('name');
} else {
$title = single_cat_title('', false);
}
} else {
$title = single_cat_title('', false);
}
} elseif (is_author()) {
$delimiter = $set['seo']['title_delimiter'];
if ($set['seo']['openseo'] == 1) {
if ($set['seo']['titlestyle'] == 'site_title') {
$title = get_bloginfo('name') . $delimiter . get_the_author() . '的文章';
} elseif ($set['seo']['titlestyle'] == 'title_site') {
$title = get_the_author() . '的文章' . $delimiter . get_bloginfo('name');
} else {
$title = get_the_author() . '的文章';
}
} else {
$title = get_the_author() . '的文章';
}
} else {
if ($set['seo']['openseo'] == 1) {
$delimiter = $set['seo']['title_delimiter'];
$title = wp_title($delimiter, false, 'right');
} else {
$title = wp_title('»', false, 'right');
}
}
echo "<title>{$title}</title>";
$keywords = '';
$description = '';
if (is_home()) {
if ($set['seo']['description'] != null) {
$description = $set['seo']['description'];
} else {
$description = get_bloginfo('description');
}
if ($set['seo']['keyword'] != null) {
$keywords = $set['seo']['keyword'];
}
} else if (is_single() || is_page()) {
global $post;
global $corepress_post_meta;
$corepress_post_meta = json_decode(get_post_meta($post->ID, 'corepress_post_meta', true), true);
if (empty($corepress_post_meta['seo']['open'])) {
$corepress_post_meta['seo']['open'] = 0;
}
if (empty($corepress_post_meta['closesidebar'])) {
$corepress_post_meta['closesidebar'] = 0;
}
if (empty($corepress_post_meta['postrighttag']['open'])) {
$corepress_post_meta['postrighttag']['open'] = 0;
}
if (empty($corepress_post_meta['catalog'])) {
$corepress_post_meta['catalog'] = 0;
}
if ($corepress_post_meta['seo']['open'] == 1) {
$description = $corepress_post_meta['seo']['description'];
$keywords = $corepress_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 ($set['seo']['openseo'] == 1) {
if (post_password_required() == false) {
?>
<meta name="keywords" content="<?php echo $keywords; ?>"/>
<meta name="description" content="<?php echo $description; ?>"/>
<?php
}
}
?>