header.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 Sakurairo
  10. */
  11. // Prevent direct access to the file
  12. if (!defined('ABSPATH')) {
  13. exit; // Exit if accessed directly
  14. }
  15. $mashiro_logo = iro_opt('mashiro_logo');
  16. $vision_resource_basepath = iro_opt('vision_resource_basepath');
  17. header('X-Frame-Options: SAMEORIGIN');
  18. ?>
  19. <!DOCTYPE html>
  20. <!--
  21. ◢\  ☆   /◣
  22.    ∕  ﹨ ╰╮∕  ﹨
  23.    ▏  ~~′′~~  |
  24.    ﹨/        \∕
  25.     ∕   ●    ● \
  26. == ○ ∴·╰╯ ∴ ○ ==
  27.   ╭──╮     ╭──╮
  28. ╔═ ∪∪∪═Mashiro&Hitomi═∪∪∪═╗
  29. -->
  30. <html <?php language_attributes(); ?>>
  31. <head>
  32. <meta name="theme-color">
  33. <meta charset="<?php bloginfo('charset'); ?>">
  34. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  35. <link rel="stylesheet" href="https://s4.zstatic.net/ajax/libs/font-awesome/6.6.0/css/all.min.css" type="text/css" media="all"/>
  36. <?php
  37. if (iro_opt('iro_meta')) {
  38. $keywords = iro_opt('iro_meta_keywords');
  39. $description = iro_opt('iro_meta_description');
  40. if (is_singular()) {
  41. $tags = get_the_tags();
  42. if ($tags) {
  43. $keywords = implode(',', array_column($tags, 'name'));
  44. }
  45. if (!empty($post->post_content)) {
  46. $description = trim(mb_strimwidth(preg_replace('/\s+/', ' ', strip_tags($post->post_content)), 0, 240, '…'));
  47. }
  48. }
  49. if (is_category()) {
  50. $categories = get_the_category();
  51. if ($categories) {
  52. $keywords = implode(',', array_column($categories, 'name'));
  53. }
  54. $description = trim(category_description()) ?: $description;
  55. }
  56. ?>
  57. <meta name="description" content="<?= esc_attr($description); ?>" />
  58. <meta name="keywords" content="<?= esc_attr($keywords); ?>" />
  59. <?php } ?>
  60. <link rel="shortcut icon" href="<?= esc_url(iro_opt('favicon_link', '')); ?>" />
  61. <meta http-equiv="x-dns-prefetch-control" content="on">
  62. <?php
  63. if (is_home()) {
  64. global $core_lib_basepath;
  65. ?>
  66. <link id="entry-content-css" rel="prefetch" as="style" href="<?= esc_url($core_lib_basepath . '/css/theme/' . (iro_opt('entry_content_style') == 'sakurairo' ? 'sakura' : 'github') . '.css?ver=' . IRO_VERSION) ?>" />
  67. <link rel="prefetch" as="script" href="<?= esc_url($core_lib_basepath . '/js/page.js?ver=' . IRO_VERSION) ?>" />
  68. <?php
  69. }
  70. ?>
  71. <?php wp_head(); ?>
  72. <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?>|<?php bloginfo('description'); ?>" href="<?php bloginfo('rss2_url'); ?>" />
  73. <link rel="stylesheet" href="https://<?= esc_attr(iro_opt('gfonts_api', 'fonts.googleapis.com')); ?>/css?family=Noto+Serif+SC|Noto+Sans+SC|Dela+Gothic+One|Fira+Code<?= esc_attr(iro_opt('gfonts_add_name')); ?>&display=swap" media="all">
  74. <script type="text/javascript">
  75. if (!!window.ActiveXObject || "ActiveXObject" in window) { //is IE?
  76. alert('朋友,IE浏览器未适配哦~\n如果是 360、QQ 等双核浏览器,请关闭 IE 模式!(Are you using IE? Some of the web elements might be broken, please use the latest browser to access!)');
  77. }
  78. </script>
  79. <?php if (iro_opt('google_analytics_id')) : ?>
  80. <!-- Global site tag (gtag.js) - Google Analytics -->
  81. <script async src="https://www.googletagmanager.com/gtag/js?id=<?= esc_attr(iro_opt('google_analytics_id')); ?>"></script>
  82. <script>
  83. window.dataLayer = window.dataLayer || [];
  84. function gtag() {dataLayer.push(arguments)}
  85. gtag('js', new Date());
  86. gtag('config', '<?= esc_attr(iro_opt('google_analytics_id')); ?>');
  87. </script>
  88. <?php endif; ?>
  89. <?= iro_opt("site_header_insert"); ?>
  90. <?php if (iro_opt('poi_pjax')): ?>
  91. <script>
  92. const srcs = `
  93. <?php echo iro_opt("pjax_keep_loading"); ?>
  94. `;
  95. document.addEventListener("pjax:complete", () => {
  96. srcs.split(/[\n,]+/).forEach(path => {
  97. path = path.trim();
  98. if (!path) return;
  99. if (path.endsWith('.js')) {
  100. const script = document.createElement('script');
  101. script.src = path;
  102. script.async = true;
  103. document.body.appendChild(script);
  104. } else if (path.endsWith('.css')) {
  105. const style = document.createElement('link');
  106. style.rel = 'stylesheet';
  107. style.href = path;
  108. document.head.appendChild(style);
  109. }
  110. });
  111. });
  112. </script>
  113. <?php endif; ?>
  114. </head>
  115. <body <?php body_class(); ?>>
  116. <?php if (iro_opt('preload_animation', 'true')) : ?>
  117. <div id="preload">
  118. <li data-id="3" class="active">
  119. <div id="preloader_3"></div>
  120. </li>
  121. </div>
  122. <?php endif; ?>
  123. <div class="scrollbar" id="bar"></div>
  124. <header class="site-header no-select" role="banner">
  125. <div class="site-top">
  126. <div class="site-branding">
  127. <?php if (iro_opt('iro_logo') && !iro_opt('mashiro_logo_option', false)) { ?>
  128. <div class="site-title">
  129. <a href="<?php echo bloginfo('url'); ?>"><img alt="<?= esc_attr(get_option('blogname')); ?>" src="<?= esc_url(iro_opt('iro_logo')); ?>"></a>
  130. </div>
  131. <?php } else { ?>
  132. <span class="site-title">
  133. <span class="logolink moe-mashiro">
  134. <a href="<?= bloginfo('url'); ?>">
  135. <ruby>
  136. <span class="sakuraso"><?= esc_html($mashiro_logo['text_a'] ?? ""); ?></span>
  137. <span class="no"><?= esc_html($mashiro_logo['text_b'] ?? ""); ?></span>
  138. <span class="shironeko"><?= esc_html($mashiro_logo['text_c'] ?? ""); ?></span>
  139. <rp></rp>
  140. <rt class="chinese-font"><?= esc_html($mashiro_logo['text_secondary'] ?? ""); ?></rt>
  141. <rp></rp>
  142. </ruby>
  143. </a>
  144. </span>
  145. </span>
  146. <?php } ?>
  147. <!-- logo end -->
  148. </div><!-- .site-branding -->
  149. <?php header_user_menu();
  150. if (iro_opt('nav_menu_search') == '1') { ?>
  151. <div class="searchbox js-toggle-search"><i class="fa-solid fa-magnifying-glass"></i></div>
  152. <?php } ?>
  153. <div class="lower"><?php if (iro_opt('nav_menu_display') == 'fold') { ?>
  154. <div id="show-nav" class="showNav">
  155. <div class="line line1"></div>
  156. <div class="line line2"></div>
  157. <div class="line line3"></div>
  158. </div><?php } ?>
  159. <nav><?php wp_nav_menu(['depth' => 2, 'theme_location' => 'primary', 'container' => false]); ?></nav><!-- #site-navigation -->
  160. </div>
  161. </div>
  162. </header><!-- #masthead -->
  163. <div class="openNav no-select">
  164. <div class="iconflat no-select" style="padding: 30px;">
  165. <div class="icon"></div>
  166. </div>
  167. </div><!-- m-nav-bar -->
  168. <section id="main-container">
  169. <?php
  170. if (iro_opt('cover_switch')) {
  171. $filter = iro_opt('random_graphs_filter');
  172. ?>
  173. <div class="headertop <?= esc_attr($filter); ?>">
  174. <?php get_template_part('layouts/imgbox'); ?>
  175. </div>
  176. <?php } ?>
  177. <div id="page" class="site wrapper">
  178. <?php
  179. $use_as_thumb = get_post_meta(get_the_ID(), 'use_as_thumb', true); //'true','only',(default)
  180. if ($use_as_thumb != 'only') {
  181. $cover_type = get_post_meta(get_the_ID(), 'cover_type', true);
  182. if ($cover_type == 'hls') {
  183. the_video_headPattern(true);
  184. } elseif ($cover_type == 'normal') {
  185. the_video_headPattern(false);
  186. } else {
  187. the_headPattern();
  188. }
  189. } else {
  190. the_headPattern();
  191. } ?>
  192. <div id="content" class="site-content">