header.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. /**
  3. * The header for our theme.
  4. *
  5. * This is the template that displays all of the <head> section and everything up until <div id="content">
  6. *
  7. * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
  8. *
  9. * @package Akina
  10. */
  11. $mashiro_logo = iro_opt('mashiro_logo');
  12. ?>
  13. <?php header('X-Frame-Options: SAMEORIGIN'); ?>
  14. <!DOCTYPE html>
  15. <!--
  16. ◢\  ☆   /◣
  17.    ∕  ﹨ ╰╮∕  ﹨
  18.    ▏  ~~′′~~  |
  19.    ﹨/        \∕
  20.     ∕   ●    ● \
  21. == ○ ∴·╰╯ ∴ ○ ==
  22.   ╭──╮     ╭──╮
  23. ╔═ ∪∪∪═Mashiro&Hitomi═∪∪∪═╗
  24. -->
  25. <html <?php language_attributes(); ?>>
  26. <head>
  27. <meta name="theme-color">
  28. <meta charset="<?php bloginfo('charset'); ?>">
  29. <!--<meta name="viewport" content="width=device-width, initial-scale=1">-->
  30. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  31. <?php
  32. if (iro_opt('iro_meta') == true) {
  33. $keywords = '';
  34. $description = '';
  35. if (is_singular()) {
  36. $keywords = '';
  37. $tags = get_the_tags();
  38. $categories = get_the_category();
  39. if ($tags) {
  40. foreach ($tags as $tag) {
  41. $keywords .= $tag->name . ',';
  42. };
  43. };
  44. if ($categories) {
  45. foreach ($categories as $category) {
  46. $keywords .= $category->name . ',';
  47. };
  48. };
  49. $description = mb_strimwidth(str_replace("\r\n", '', strip_tags($post->post_content)), 0, 240, '…');
  50. } else {
  51. $keywords = iro_opt('iro_meta_keywords');
  52. $description = iro_opt('iro_meta_description');
  53. };
  54. ?>
  55. <meta name="description" content="<?php echo $description; ?>" />
  56. <meta name="keywords" content="<?php echo $keywords; ?>" />
  57. <?php } ?>
  58. <link rel="shortcut icon" href="<?php echo iro_opt('favicon_link', ''); ?>" />
  59. <meta http-equiv="x-dns-prefetch-control" content="on">
  60. <?php
  61. if (is_home()) {
  62. //预载资源
  63. //id需要一致,使pjax可以完成自动替换
  64. global $core_lib_basepath;
  65. ?>
  66. <link id="entry-content-css" rel="prefetch" as="style" href="<?= $core_lib_basepath . '/css/theme/' . (iro_opt('entry_content_style') == 'sakurairo' ? 'sakura' : 'github') . '.css?ver=' . IRO_VERSION ?>" />
  67. <link rel="prefetch" as="script" href="<?= $core_lib_basepath . '/js/page.js?ver=' . IRO_VERSION ?>" />
  68. <?php
  69. }
  70. ?>
  71. <?php wp_head(); ?>
  72. <link rel="stylesheet" href="https://<?php echo iro_opt('gfonts_api', 'fonts.loli.net'); ?>/css?family=Merriweather+Sans|Noto+Serif|Noto+Serif+SC|Noto+Sans+SC|Ubuntu:400,700<?php echo iro_opt('gfonts_add_name'); ?>&display=swap" media="all">
  73. <script type="text/javascript">
  74. if (!!window.ActiveXObject || "ActiveXObject" in window) { //is IE?
  75. alert('朋友,IE浏览器未适配哦~\n如果是 360、QQ 等双核浏览器,请关闭 IE 模式!');
  76. }
  77. </script>
  78. <?php if (iro_opt('google_analytics_id', '')) : ?>
  79. <!-- Global site tag (gtag.js) - Google Analytics -->
  80. <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo iro_opt('google_analytics_id', ''); ?>"></script>
  81. <script>
  82. window.dataLayer = window.dataLayer || [];
  83. function gtag() {dataLayer.push(arguments)}
  84. gtag('js', new Date());
  85. gtag('config', '<?php echo iro_opt('google_analytics_id', ''); ?>');
  86. </script>
  87. <?php endif; ?>
  88. <?php echo iro_opt("site_header_insert"); ?>
  89. </head>
  90. <body <?php body_class(); ?>>
  91. <?php if (iro_opt('preload_animation', 'true')) : ?>
  92. <div id="preload">
  93. <li data-id="3" class="active">
  94. <div id="preloader_3"></div>
  95. </li>
  96. </div>
  97. <?php endif; ?>
  98. <div class="scrollbar" id="bar"></div>
  99. <header class="site-header no-select" role="banner">
  100. <div class="site-top">
  101. <div class="site-branding">
  102. <?php if (iro_opt('iro_logo') && !iro_opt('mashiro_logo_option', false)) { ?>
  103. <div class="site-title">
  104. <a href="<?php bloginfo('url'); ?>"><img src="<?php echo iro_opt('iro_logo'); ?>"></a>
  105. </div>
  106. <?php } else { ?>
  107. <span class="site-title">
  108. <span class="logolink moe-mashiro">
  109. <a href="<?php bloginfo('url'); ?>">
  110. <ruby>
  111. <span class="sakuraso"><?php echo $mashiro_logo['text_a']; ?></span>
  112. <span class="no"><?php echo $mashiro_logo['text_b']; ?></span>
  113. <span class="shironeko"><?php echo iro_opt('logo_text'); ?><?php echo $mashiro_logo['text_c']; ?></span>
  114. <rp></rp>
  115. <rt class="chinese-font"><?php echo $mashiro_logo['text_secondary']; ?></rt>
  116. <rp></rp>
  117. </ruby>
  118. </a>
  119. </span>
  120. </span>
  121. <?php } ?>
  122. <!-- logo end -->
  123. </div><!-- .site-branding -->
  124. <?php header_user_menu();
  125. if (iro_opt('nav_menu_search') == '1') { ?>
  126. <div class="searchbox"><i class="iconfont js-toggle-search iconsearch icon-search"></i></div>
  127. <?php } ?>
  128. <div class="lower"><?php if (iro_opt('nav_menu_display') == 'fold') { ?>
  129. <div id="show-nav" class="showNav">
  130. <div class="line line1"></div>
  131. <div class="line line2"></div>
  132. <div class="line line3"></div>
  133. </div><?php } ?>
  134. <nav><?php wp_nav_menu(array('depth' => 2, 'theme_location' => 'primary', 'container' => false)); ?></nav><!-- #site-navigation -->
  135. </div>
  136. </div>
  137. </header><!-- #masthead -->
  138. <div class="openNav no-select">
  139. <div class="iconflat no-select">
  140. <div class="icon"></div>
  141. </div>
  142. </div><!-- m-nav-bar -->
  143. <section id="main-container">
  144. <?php
  145. if (iro_opt('cover_switch')) {
  146. $filter = iro_opt('random_graphs_filter');
  147. ?>
  148. <div class="headertop <?php echo $filter; ?>">
  149. <?php get_template_part('layouts/imgbox'); ?>
  150. </div>
  151. <?php } ?>
  152. <div id="page" class="site wrapper">
  153. <?php
  154. $use_as_thumb = get_post_meta(get_the_ID(), 'use_as_thumb', true); //'true','only',(default)
  155. if ($use_as_thumb != 'only') {
  156. $cover_type = get_post_meta(get_the_ID(), 'cover_type', true);
  157. if ($cover_type == 'hls') {
  158. the_video_headPattern(true);
  159. } elseif ($cover_type == 'normal') {
  160. the_video_headPattern(false);
  161. } else {
  162. the_headPattern();
  163. }
  164. } else {
  165. the_headPattern();
  166. } ?>
  167. <div id="content" class="site-content">