Skip to content

Commit

Permalink
change for coze
Browse files Browse the repository at this point in the history
  • Loading branch information
Aranoch committed May 2, 2024
1 parent fee561e commit a21c508
Show file tree
Hide file tree
Showing 24 changed files with 314 additions and 44 deletions.
7 changes: 5 additions & 2 deletions comments.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php if ( post_password_required() || ! comments_open() ) {
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
if ( post_password_required() || ! comments_open() ) {
return;
} ?>
}
?>

<section id="comments"></section>
<script>
Expand Down
40 changes: 14 additions & 26 deletions footer.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php if ( ! defined( 'ABSPATH' ) ) { exit; } ?>
</div><!-- content -->
</main><!-- main -->
</section><!-- core -->

<footer id="footer">
<div class="d-flex flex-center justify-between flex-wrap">
<div class='left'>
<span>&copy; <?= date( 'Y' ) ?> <a
href="<?= get_bloginfo( 'url' ) ?>"><?= get_bloginfo( 'name' ) ?></a></span>
<span>&copy; <?= date( 'Y' ) ?> <a href="<?= get_bloginfo( 'url' ) ?>"><?= get_bloginfo( 'name' ) ?></a></span>
</div>
<div class='right'>
<span>Theme by <a class="theme-name" href="https://biji.io" target="_blank"><?= THEME_NAME ?></a></span>
Expand All @@ -23,32 +23,11 @@
</div>

<div class="scroll-tools mr-2">
<div class="dropdown" hover-show perspective>
<div class="dropdown">
<a class="btn btn-link btn-action uni-bg bg-blur uni-shadow dropdown-toggle flex-center"
href="javascript:void(0);" tabindex="0">
<i class="czs-clothes-l"></i>
href="/wp-admin" target="_blank" tabindex="0">
<i class="czs-fingerprint-l"></i>
</a>
<ul class="menu menu-left mode-switch uni-card uni-bg bg-blur uni-shadow text-center" @click="toggleSkinMode">
<li v-for="item of modeList" class="menu-item">
<a class="flex-center" :data-mode="item.mode" href="javascript:void(0);">
<i :class="[item.icon, 'mr-1']"></i>{{ item.name }}
</a>
</li>
</ul>
</div>
<div style="height: 0.4rem;"></div>
<div class="dropdown" hover-show perspective>
<a class="btn btn-link btn-action uni-bg bg-blur uni-shadow dropdown-toggle flex-center"
href="javascript:void(0);" tabindex="0">
<i class="czs-earth"></i>
</a>
<ul class="menu menu-left mode-switch uni-card uni-bg bg-blur uni-shadow" @click="toggleLanguage">
<li v-for="item of langList" class="menu-item">
<a class="flex-center" :data-mode="item.mode" href="javascript:void(0);">
<i :class="[item.icon, 'mr-1']"></i>{{ item.name }}
</a>
</li>
</ul>
</div>
<div style="height: 0.4rem;"></div>
<a class="scroll-top btn btn-link btn-action uni-bg bg-blur uni-shadow flex-center"
Expand Down Expand Up @@ -82,6 +61,15 @@ function _exReload() {
</script>
</div>
<?php wp_footer(); ?>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?92ba59e5187e2c9598faab7f5f25b51e";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<!--网站效率:<?php timer_stop( 4 ); ?>秒内查询了<?= get_num_queries(); ?>次数据库-->
</body>

Expand Down
5 changes: 4 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
ini_set( 'display_errors', 1 );
if ( version_compare( $GLOBALS['wp_version'], '5.9', '<' ) ) {
wp_die( 'Please upgrade to version 5.9 or higher' );
Expand All @@ -17,6 +18,8 @@

include_once( 'inc/base-customized.php' ); // 定制优化

include_once( 'inc/theme-customized.php' ); // 二次定制

// 挂载脚本
function biji_enqueue_scripts() {
// WP自带图标
Expand Down Expand Up @@ -51,7 +54,7 @@ function biji_enqueue_scripts() {
'rest' => rest_url(),
'nonce' => wp_create_nonce( 'wp_rest' ),
'pjax' => get_theme_mod( 'biji_setting_pjax', true ),
'lang' => get_locale(),
'lang' => 'en',
] );
}

Expand Down
44 changes: 42 additions & 2 deletions header.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php if ( ! defined( 'ABSPATH' ) ) { exit; } ?>
<!DOCTYPE html>
<html class="<?php the_skin_mode(); ?>">

Expand All @@ -15,25 +16,64 @@
}
</style>
<?php endif; ?>
<!-- Google Tag Manager -->
<script> (function(w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f); })(window, document, 'script', 'dataLayer', 'GTM-WZSCMBL6');</script>
<!-- End Google Tag Manager -->
</head>

<body>
<div id="app" :class="['layout', animation, '<?= ( $_background ? 'less-animation' : '' ) ?>']" style="display: none;"
v-show="true">
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WZSCMBL6" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<header id="header" class="flex-center justify-between">
<hgroup class="logo" itemprop="publisher" itemscope="" itemtype="https://schema.org/Organization">
<h1 class="fullname" itemprop="logo" itemscope="" itemtype="https://schema.org/ImageObject">
<a href="<?php bloginfo( 'url' ); ?>"><?php bloginfo( 'name' ); ?></a>
<a class="flex-center" href="<?php bloginfo( 'url' ); ?>">
<svg class="slogo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<path d="M11.4,85.1l.18.09s.12.06.2.11c.32.14.68.22,1.06.23h.17s7.35,0,7.35,0c.84,0,1.62-.32,2.22-.91.59-.59.91-1.37.91-2.2,0-1.72-1.41-3.12-3.14-3.12h-4.25v-18.73c.02-.3,0-.57-.04-.79-.16-.97-.67-1.76-1.42-2.23l-.37-.29-6.81-6.81,7.57-7.58c.38-.34.66-.73.83-1.16.08-.19.11-.35.15-.5l.04-.14c.04-.23.06-.57.05-.86v-18.99h4.25c1.76,0,3.14-1.32,3.14-3.02,0-.83-.32-1.6-.9-2.17-.59-.58-1.38-.9-2.22-.9l-7.39.05c-.39,0-.78.08-1.16.23-.1.06-.18.11-.25.14l-.17.08c-.07.03-.13.06-.19.1-.12.08-.24.2-.36.31l-.16.13c-.09.1-.19.23-.29.37l-.08.11c-.07.12-.14.26-.2.39l-.07.13c-.04.1-.06.21-.08.31-.02.1-.06.2-.09.31-.02.1-.06.22-.09.33-.01.03,0,0,0-.05-.02.22-.07.41-.12.56l.09,20.57L.9,48.08c-.6.6-.91,1.41-.9,2.28v.05s0,.05,0,.05c-.03.87.3,1.69.92,2.31l8.82,8.89-.09,20.4c.05.15.1.35.12.57,0,.07.02.13.03.2.04.1.08.2.11.3.04.14.07.26.11.37.03.06.07.12.09.19.05.11.11.23.18.35l.11.16c.09.13.18.24.27.34.05.04.11.09.16.13.12.11.23.22.36.31.07.05.14.08.21.11Z" />
<path d="M96.71,50.28c.03-.98-.3-1.8-.92-2.42l-8.81-8.89.09-20.4c-.05-.15-.1-.35-.12-.57,0-.06-.02-.12-.03-.19-.05-.11-.08-.22-.11-.32-.03-.12-.06-.24-.1-.35-.04-.07-.07-.13-.1-.2-.06-.12-.12-.24-.18-.35l-.1-.14c-.08-.12-.18-.24-.28-.34-.05-.04-.11-.09-.16-.13-.12-.11-.24-.22-.37-.31-.08-.05-.15-.08-.23-.12l-.13-.07c-.07-.04-.16-.08-.24-.13-.29-.12-.65-.2-1.03-.22h-.17s-7.35,0-7.35,0c-.84,0-1.62.32-2.22.91-.59.59-.91,1.37-.91,2.2,0,1.72,1.41,3.12,3.14,3.12h4.25v18.74c-.02.3,0,.56.04.78.16.97.67,1.76,1.42,2.23l.37.29,6.81,6.81-7.57,7.58c-.38.34-.66.73-.83,1.16-.08.19-.11.34-.15.5l-.04.15c-.04.23-.06.57-.05.85v19h-4.25c-1.76,0-3.14,1.32-3.14,3.02,0,.83.32,1.6.91,2.17.59.58,1.38.9,2.22.9l7.39-.05c.39,0,.78-.08,1.15-.22l.43-.23c.07-.03.14-.06.2-.1.1-.07.23-.19.36-.31l.15-.13c.09-.1.2-.23.29-.37l.08-.11c.07-.12.14-.26.2-.39l.06-.13c.04-.11.06-.22.09-.33.02-.09.05-.19.09-.29.02-.11.06-.22.09-.33.01-.03,0,.01,0,.06.02-.23.07-.43.12-.58l-.09-20.56,8.84-8.89c.59-.6.91-1.41.89-2.29Z" />
<path d="M66.15,2.66c-.38-.31-.95-.67-1.51-.67h-.24s-21.12-1.99-21.12-1.99c-.05,0-.11.02-.17.03-.05,0-.1.02-.15.02-.15.06-.3.1-.44.13-.13.02-.25.05-.36.09-.06.02-.12.06-.19.09l-.38.18c-.13.07-.27.18-.4.28l-.15.11c-.08.07-.19.19-.32.34l-.08.09c-.09.12-.17.26-.24.38l-.08.13c-.06.13-.09.25-.13.36-.02.06-.05.13-.08.2,0,.02,0,.06-.01.1l-.03.19c-.02.09-.04.19-.06.28l-7.23,78.65c-.14.92.1,1.8.68,2.48l9.51,11.3c.04.06.07.12.11.18.6.72,1.48,1.13,2.41,1.13h0c.74,0,1.44-.25,2.01-.73l11.49-9.66c.12-.1.25-.23.39-.41l.07-.09c.4-.54.6-1.11.63-1.73l5.55-60.43.05-.18c.06-.22.1-.4.11-.54.01-.14,0-.3-.01-.51l-.02-.19,1.55-16.88c.09-1.03-.34-2.04-1.15-2.7ZM54.1,80.55l-14.83-1.28,5.06-55.05,14.82,1.29-5.06,55.05ZM59.73,19.27l-14.82-1.28,1.04-11.32,14.82,1.29-1.04,11.31Z" />
</svg>
<?php bloginfo( 'name' ); ?>
</a>
</h1>
<meta itemprop="name" content="<?php bloginfo( 'name' ); ?>">
<meta itemprop="url" content="<?php bloginfo( 'url' ); ?>">
</hgroup>
<section class="header__right d-flex">
<form method="get" action="<?php bloginfo( 'url' ); ?>" class="search">
<form method="get" action="<?php bloginfo( 'url' ); ?>" class="search" style="margin-right:10px;">
<input class="search-key btn btn-link btn-action right-btn uni-bg uni-shadow" name="s" placeholder="Please enter..." type="text"
required="required"/>
<i class="text-small czs-search-l flex-center"></i>
</form>
<div class="dropdown" hover-show perspective style="margin-right:10px;">
<a class="btn btn-link btn-action uni-bg bg-blur uni-shadow dropdown-toggle flex-center"
href="javascript:void(0);" tabindex="0">
<i class="text-small czs-sun flex-center"></i>
</a>
<ul class="menu menu-left mode-switch uni-card uni-bg bg-blur uni-shadow text-center" @click="toggleSkinMode" style="min-width: 120px;">
<li v-for="item of modeList" class="menu-item">
<a class="flex-center" :data-mode="item.mode" href="javascript:void(0);">
<i :class="[item.icon, 'mr-1 mt-1']"></i>{{ item.name }}
</a>
</li>
</ul>
</div>
<div class="dropdown" hover-show perspective>
<a class="btn btn-link btn-action uni-bg bg-blur uni-shadow dropdown-toggle flex-center"
href="javascript:void(0);" tabindex="0">
<i class="czs-earth"></i>
</a>
<ul class="menu menu-left mode-switch uni-card uni-bg bg-blur uni-shadow" @click="toggleLanguage" style="min-width: 130px;">
<li v-for="item of langList" class="menu-item">
<a class="flex-center" :data-mode="item.mode" href="javascript:void(0);">
<i :class="[item.icon, 'mr-1']"></i>{{ item.name }}
</a>
</li>
</ul>
</div>
<a class="btn btn-link btn-action right-btn uni-bg uni-shadow menu-btn off-canvas-toggle flex-center ml-2" href="#aside">
<i class="text-large czs-menu-l flex-center"></i>
</a>
Expand Down
1 change: 1 addition & 0 deletions inc/article-content.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php if ( ! defined( 'ABSPATH' ) ) { exit; } ?>
<!-- Content -->
<article class="article" itemscope="itemscope" itemtype="http://schema.org/Article">
<?php
Expand Down
1 change: 1 addition & 0 deletions inc/article-header.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php if ( ! defined( 'ABSPATH' ) ) { exit; } ?>
<header class="article-header">
<h1 itemprop="headline" class="article-title h2 mb-2"><?php the_title(); ?></h1>
<ul class="article-info d-flex text-gray reset-ul m-0">
Expand Down
1 change: 1 addition & 0 deletions inc/base-customized.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
// 移除非必要的头部文件
remove_action( 'wp_head', 'feed_links_extra', 3 ); // 额外的feed,例如category, tag页
remove_action( 'wp_head', 'wp_generator' ); // 隐藏wordpress版本
Expand Down
2 changes: 2 additions & 0 deletions inc/core-notes.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }

function note_custom_init() {
// 注册Note类型
register_post_type( 'note', [
Expand Down
2 changes: 2 additions & 0 deletions inc/core-rest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }

// 校验nonce,防止滥用接口
function check_nonce() {
$nonce = $_REQUEST['_wpnonce'] ?? ( $_SERVER['HTTP_X_WP_NONCE'] ?? '' );
Expand Down
57 changes: 57 additions & 0 deletions inc/core-settings.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }

// 主题设置选项
function theme_customize_register( $wp_customize ) {
$category_checkbox = "";
Expand Down Expand Up @@ -320,6 +322,61 @@ function bijiHandleExcludeChange(result = []) {
]
],
]
],
[
"id" => "biji_opt",
"args" => [
'title' => '优化设置',
'description' => $style,
'priority' => 103,
],
"settings" => [
[
"id" => "biji_opt_remove_admin_bar",
"setting" => [ "default" => true ],
"control" => [
'label' => '移除Admin bar',
'description' => '此选项可以帮助你全局移除Admin Bar工具栏,所有人包括管理员都看不到。',
'type' => 'checkbox',
]
],
[
"id" => "biji_opt_disable_texturize",
"setting" => [ "default" => true ],
"control" => [
'label' => '禁用字符转码',
'description' => '禁用字符换成格式化的 HTML 实体功能。',
'type' => 'checkbox',
]
],
[
"id" => "biji_opt_remove_head_links",
"setting" => [ "default" => true ],
"control" => [
'label' => '移除头部代码',
'description' => 'WordPress会在页面的头部输出了一些link和meta标签代码,这些代码没什么作用,并且存在安全隐患,建议移除WordPress页面头部中无关紧要的代码。',
'type' => 'checkbox',
]
],
[
"id" => "biji_opt_remove_help_tabs",
"setting" => [ "default" => true ],
"control" => [
'label' => '移除帮助按钮',
'description' => '移除后台界面右上角的帮助',
'type' => 'checkbox',
]
],
[
"id" => "biji_opt_no_admin",
"setting" => [ "default" => true ],
"control" => [
'label' => '禁用 admin',
'description' => '禁止使用 admin 用户名尝试登录 WordPress',
'type' => 'checkbox',
]
],
]
]
];

Expand Down
2 changes: 2 additions & 0 deletions inc/core.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }

include_once( 'core-rest.php' ); // AJAX接口
include_once( 'core-notes.php' ); // 笔记
include_once( 'core-settings.php' ); // 主题设置
Expand Down
71 changes: 71 additions & 0 deletions inc/theme-customized.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }

// 绕过 CDN 代理IP获取客户真实IP地址
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
$list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
$_SERVER['REMOTE_ADDR'] = $list[0];
}
# --------------------------------------------------------------------
# 移除admin bar
# --------------------------------------------------------------------
if(get_theme_mod('biji_opt_remove_admin_bar', true)){
add_filter('show_admin_bar', '__return_false');
}
# --------------------------------------------------------------------
# 屏蔽字符转码
# --------------------------------------------------------------------
if(get_theme_mod('biji_opt_disable_texturize', true)){
add_filter('run_wptexturize', '__return_false');
}
# --------------------------------------------------------------------
# 禁用登录页语言切换
# --------------------------------------------------------------------
add_filter('login_display_language_dropdown', '__return_false');

# --------------------------------------------------------------------
# 移除 WP_Head 无关紧要的代码
# --------------------------------------------------------------------
if(get_theme_mod('biji_opt_remove_head_links', true)){
remove_action( 'wp_head', 'wp_generator'); //删除 head 中的 WP 版本号
foreach (['rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head'] as $action) {
remove_action( $action, 'the_generator' );
}
remove_action( 'wp_head', 'rsd_link' ); //删除 head 中的 RSD LINK
remove_action( 'wp_head', 'wlwmanifest_link' ); //删除 head 中的 Windows Live Writer 的适配器?
remove_action( 'wp_head', 'feed_links_extra', 3 ); //删除 head 中的 Feed 相关的link
remove_action( 'wp_head', 'index_rel_link' ); //删除 head 中首页,上级,开始,相连的日志链接
remove_action( 'wp_head', 'parent_post_rel_link', 10);
remove_action( 'wp_head', 'start_post_rel_link', 10);
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10);
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); //删除 head 中的 shortlink
remove_action( 'wp_head', 'rest_output_link_wp_head', 10); // 删除头部输出 WP RSET API 地址
remove_action( 'template_redirect', 'wp_shortlink_header', 11); //禁止短链接 Header 标签。
remove_action( 'template_redirect', 'rest_output_link_header', 11); // 禁止输出 Header Link 标签。
}
# --------------------------------------------------------------------
# 移除后台界面右上角的帮助
# --------------------------------------------------------------------
if(get_theme_mod('biji_opt_remove_help_tabs', true)){
if(is_admin()){
add_action('in_admin_header', function(){
global $current_screen;
$current_screen->remove_help_tabs();
});
}
}
# --------------------------------------------------------------------
# 禁止使用 admin 用户名尝试登录
# --------------------------------------------------------------------
if(get_theme_mod('no_admin',true)){
add_filter( 'wp_authenticate', function ($user){
if($user == 'admin') exit;
});

add_filter('sanitize_user', function ($username, $raw_username, $strict){
if($raw_username == 'admin' || $username == 'admin'){
exit;
}
return $username;
}, 10, 3);
}
1 change: 1 addition & 0 deletions inc/theme-update-checker.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Theme Update Checker Library 1.2
* https://w-shadow.com/
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php get_header(); ?>
<?php if ( ! defined( 'ABSPATH' ) ) { exit; } get_header(); ?>
<!-- 文章列表 -->
<div class="article-list">
<?php if ( have_posts() ) {
Expand Down
1 change: 1 addition & 0 deletions page-archive.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
/*
Template Name: 文章归档
*/
Expand Down
Loading

0 comments on commit a21c508

Please sign in to comment.