Ai
1 Star 7 Fork 2

阿锋/Blocksy Feng

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
functions.php 3.46 KB
一键复制 编辑 原始数据 按行查看 历史
<?php
// 父主题 style.css
// add_action( 'wp_enqueue_scripts', function () {
// wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
// });
// 是否开启维护模式
$maintenanceMode = false;
function wp_maintenance_mode(){
if(!current_user_can('edit_themes') || !is_user_logged_in()){
wp_die('<h1 style="color:red">站点搬迁稍后访问</h1><p algin="center">买了阿里云99元的ECS,正在搬迁稍后访问。</p><p algin="center">预计2023年11月13日15:06:27前完成</p>');
}else {
echo '<h1>!!!当前是维护模式!!!</h1> <hr />';
}
}
if ($maintenanceMode) {
add_action('get_header', 'wp_maintenance_mode');
}
// 獲取版本号
$theme_version = wp_get_theme()->get('Version');
define('BLOCKSY_FENG_VERSION', $theme_version);
// 配置项
$config = [
];
if (is_admin()) {
// 管理后台
}else {
// 添加css & js
add_action('wp_enqueue_scripts', function () {
wp_enqueue_style('blocksy-feng-highlight-css', get_stylesheet_directory_uri() . '/dist/hljs/styles/atom-one-dark.min.css', array(), BLOCKSY_FENG_VERSION);
// 子主题 style.css
wp_enqueue_style('blocksy-feng-style', get_stylesheet_uri(), array(), BLOCKSY_FENG_VERSION);
wp_enqueue_script('blocksy-feng-highlight-js', get_stylesheet_directory_uri() . '/dist/hljs/highlight.min.js', array(), BLOCKSY_FENG_VERSION, true);
// wp_enqueue_script('blocksy-feng-highlight-js-copy', get_stylesheet_directory_uri() . '/dist/hljs/highlightjs-copy-button.min.js', array(), BLOCKSY_FENG_VERSION, true);
// wp_enqueue_script('blocksy-feng-highlight-js-ln', get_stylesheet_directory_uri() . '/dist/hljs/highlight.ln.min.js', array(), BLOCKSY_FENG_VERSION, true);
// 子主题 style.js
wp_enqueue_script('blocksy-feng-script', get_stylesheet_directory_uri() . '/style.js', array(), BLOCKSY_FENG_VERSION, false);
});
}
// 文章末尾添加内容
function add_custom_content_to_end($content) {
// 仅在前台单篇文章页显示,且排除摘要、Feed 等
if (is_single() && in_the_loop() && is_main_query()) {
$custom_qrcode_content = '<figure class="wp-block-image size-large has-custom-border"><img fetchpriority="high" decoding="async" width="1280" height="545" src="https://feng.pub/wp-content/uploads/2025/03/1741610316-「FENG.PUB」微信公众号二维码名片-1280x545.png" alt="" class="has-border-color wp-image-8054" style="border-color:var(--theme-palette-color-5);border-width:1px;border-radius:10px" srcset="https://feng.pub/wp-content/uploads/2025/03/1741610316-「FENG.PUB」微信公众号二维码名片-1280x545.png 1280w, https://feng.pub/wp-content/uploads/2025/03/1741610316-「FENG.PUB」微信公众号二维码名片-960x409.png 960w, https://feng.pub/wp-content/uploads/2025/03/1741610316-「FENG.PUB」微信公众号二维码名片-768x327.png 768w, https://feng.pub/wp-content/uploads/2025/03/1741610316-「FENG.PUB」微信公众号二维码名片-1536x654.png 1536w, https://feng.pub/wp-content/uploads/2025/03/1741610316-「FENG.PUB」微信公众号二维码名片.png 1880w" sizes="(max-width: 1280px) 100vw, 1280px" data-fancybox="img-0" data-src="https://feng.pub/wp-content/uploads/2025/03/1741610316-「FENG.PUB」微信公众号二维码名片.png"></figure>';
return $content . $custom_qrcode_content;
}
return $content;
}
add_filter('the_content', 'add_custom_content_to_end');
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/ouros/blocksy-feng.git
git@gitee.com:ouros/blocksy-feng.git
ouros
blocksy-feng
Blocksy Feng
master

搜索帮助