## 修 Prism is not defined
首页控制台报 `Uncaught ReferenceError: Prism is not defined`,来源是
wp-editormd 插件(不是本主题):它在 Prism 脚本加载之前就无条件执行了
`Prism.plugins.autoloader.languages_path = "..."`。
线上页面里的真实顺序:
第 668 行 该赋值语句
第 695 行 prism-core.min.js
第 696 行 prism-autoloader.min.js
在 `wp_head` 优先级 0 垫一个最小空壳 `window.Prism`(含 plugins.autoloader
这条访问链路),让那句赋值有地方可写。已核对 prism-core.min.js 源码:它开头
只读 `u.Prism.manual` 与 `u.Prism.disableWorkerMessageHandler`,结尾
`global.Prism = Prism` 整体覆盖 —— 空壳必定被真实对象替换,不承担持久职责,
只为吸收那条过早的赋值。已用 jsdom 验证:去掉空壳重现原始报错,加上后消失,
且之后 `Prism.highlightAll` 仍可正常调用。
## 项目地址统一到 code.yangyq.net
原作者署名、原主题地址、README、语言包、JS 里的控制台横幅全部换成自建仓库地址。
LICENSE 文件保持原样不动(MIT 要求保留原始版权声明)。
## CDN 分支改成拿不到就回退本地
原来的 `g_cdn` 分支指向 `cdn.jsdelivr.net/gh/vtrois/kratos`,本仓库在自建
Gitea 上,jsDelivr 只认 github/npm/wordpress,实测该地址 404。现改为仅在
`YANG_THEME_CDN_REPO` 常量存在时才走 CDN,否则一律用
`get_template_directory_uri()`。留一个 404 的地址比留空更危险:页面能开、
样式全丢,极难排查。
## 顺带
- `.gitattributes` 补 `*.mo binary`:原来是靠"含 NUL"启发式判定,不是契约
- `update.json` 的版本号跟进到 3.2.5
- `kratos.min.js` / `kratos.min.css` 用压缩器重新生成,不手工改产物
82 lines
3.7 KiB
PHP
82 lines
3.7 KiB
PHP
<?php
|
|
/**
|
|
* 主题页眉
|
|
* @author Yongquan Yang <yangyq.net>
|
|
* @license MIT License
|
|
* @version 2020.06.21
|
|
*/
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="zh-cn">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<title><?php wp_title( '-', true, 'right' ); ?></title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
<meta name="format-detection" content="telphone=no, email=no">
|
|
<meta name="keywords" content="<?php echo keywords(); ?>">
|
|
<meta name="description" itemprop="description" content="<?php echo description(); ?>">
|
|
<meta name="theme-color" content="<?php echo kratos_option('g_chrome', '#282a2c'); ?>">
|
|
<link rel="shortcut icon" href="<?php echo kratos_option('g_icon'); ?>">
|
|
<?php wp_head(); wp_print_scripts('jquery'); mourning(); ?>
|
|
</head>
|
|
<?php flush(); ?>
|
|
<body>
|
|
<div class="k-header">
|
|
<nav class="k-nav navbar navbar-expand-lg navbar-light fixed-top" <?php if(kratos_option('top_select', 'banner') !== 'banner'){ echo 'style="background:' . kratos_option('top_color', '#24292e') .'"';} ?>>
|
|
<div class="container">
|
|
<a class="navbar-brand" href="<?php echo get_option('home'); ?>">
|
|
<?php
|
|
if (kratos_option('g_logo')){
|
|
echo '<img src="' . kratos_option('g_logo') . '">';
|
|
}else{
|
|
bloginfo('name');
|
|
}
|
|
?>
|
|
</a>
|
|
<?php if ( has_nav_menu('header_menu') ) { ?>
|
|
<button class="navbar-toggler navbar-toggler-right" id="navbutton" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="line first-line"></span>
|
|
<span class="line second-line"></span>
|
|
<span class="line third-line"></span>
|
|
</button>
|
|
<?php }
|
|
if ( has_nav_menu('header_menu') ) {
|
|
wp_nav_menu( array(
|
|
'theme_location' => 'header_menu',
|
|
'depth' => 2,
|
|
'container' => 'div',
|
|
'container_class' => 'collapse navbar-collapse',
|
|
'container_id' => 'navbarResponsive',
|
|
'menu_class' => 'navbar-nav ml-auto',
|
|
'walker' => new WP_Bootstrap_Navwalker(),
|
|
) );
|
|
}
|
|
?>
|
|
</div>
|
|
</nav>
|
|
<?php if(kratos_option('top_select', 'banner') == 'banner'){ ?>
|
|
<div class="banner">
|
|
<div class="overlay"></div>
|
|
<div class="content text-center" style="background-image: url(<?php
|
|
if(!kratos_option('top_img')){
|
|
$img = ASSET_PATH . '/assets/img/background.png';
|
|
} else {
|
|
$img = kratos_option('top_img', ASSET_PATH . '/assets/img/background.png');
|
|
}
|
|
echo $img; ?>);">
|
|
<div class="introduce animated fadeInUp">
|
|
<?php
|
|
if (is_category() || is_tag()) {
|
|
echo '<div class="title">' . single_cat_title('', false) . '</div>';
|
|
echo '<div class="mate">' . strip_tags(category_description()) . '</div>';
|
|
} else {
|
|
echo '<div class="title">' . kratos_option('top_title', 'Kratos') . '</div>';
|
|
echo '<div class="mate">' . kratos_option('top_describe', __('一款专注于用户阅读体验的响应式博客主题', 'kratos')) . '</div>';
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
</div>
|