header.php 6.2 KB

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