Compare commits

...

19 commits

Author SHA1 Message Date
feibisi
64748fe6ff Add new service modules and enhance initialization
Added new service classes: Maintenance, Acceleration, Adblock, Avatar, Database, Fonts, Performance, and related templates and assets. Updated Service/Base.php to conditionally instantiate service classes only if they exist. Improved Service/Memory.php and Service/Monitor.php with better settings handling and update logic. Enhanced Service/Setting.php to simplify framework title usage. These changes modularize features and improve plugin extensibility and reliability.
2025-07-29 17:58:24 +08:00
莫蒂奇
70af2db0f5
Update wp-china-yes.php
更新插件名称
2025-05-08 01:47:19 +08:00
feibisi
8beff870f2 docs: Update CHANGELOG 2025-02-05 03:05:14 +00:00
feng
bfec4c147e
Update readme.md 2025-02-05 10:58:27 +08:00
feng
6083aa8057
Update readme.md 2025-02-05 10:39:35 +08:00
feng
f9a7968c00 补充版权声明及更新日志 TXT 2025-01-02 15:28:13 +08:00
feng
5370b07c36 升级至 3.8 版本 2025-01-02 10:36:40 +08:00
feng
8d3a71414d Update readme.md 2024-12-21 13:11:29 +08:00
feng
7e08f33923 Update readme.md 2024-12-21 13:10:25 +08:00
feng
fdce4da05e Update readme.md 2024-12-21 13:07:24 +08:00
feng
eda5b77a48 Merge branch 'master' of https://github.com/WenPai-org/wp-china-yes 2024-12-21 12:51:19 +08:00
feng
9ea04f6ac4 添加 iconsax 图标 2024-12-21 12:50:20 +08:00
feng
33e0545965
Update readme.md 2024-12-21 12:34:21 +08:00
feng
071d022ccf
Update readme.md 2024-12-21 12:33:36 +08:00
feng
8c29188c1b Create iconsax-icons.php 2024-12-21 12:25:04 +08:00
feng
f2a89c42da 升级新 UI 及域名替换
更新域名wp-china-yes.com 到 wpcy.com
2024-12-21 12:06:40 +08:00
耗子
a500ff9b6d
feat: 使用fa5 2024-12-12 23:58:22 +08:00
耗子
25fdf04fcc
feat: check hook before clear 2024-12-08 02:50:27 +08:00
devhaozi
435ffd6980 docs: Update CHANGELOG 2024-11-19 10:19:27 +00:00
105 changed files with 4196 additions and 1160 deletions

View file

@ -2,6 +2,30 @@
All notable changes to `WP-China-Yes` will be documented in this file.
## v3.8 - 2025-02-05
* 文派叶子 v3.8 重大更新全新UI 设计更接近 WordPress 原生体验。
1. 替换业务域名 WP-China-Yes.com 为新域名 WPCY.COM
2. 修复 adminCDN 支持 jsDelivr 加速无效等问题;
3. 新增 Bootstrap CDN 转接至 adminCDN 加速支持;
4. 新增 Windfonts 中文排版优化:支持段首空格 2em
5. 新增 Windfonts 中文排版优化:支持文本内容对齐;
6. 新增 [脉云维护] 菜单并支持WP系统状态监控可在页脚位置显示内存、CPU用量等信息
7. 新增 [欢迎使用] 用户引导页面,更清晰的功能指导和简介。
8. 新增 [建站工具] 文派·寻鹿建站套件展示页面,内容待完善。
9. 优化 [萌芽加速] 设置,与 WordPress 程序端加速选项分离便于添加后续项目;
10. 优化 [关于插件] 页面更简约的赞助商 Logo 和贡献者名单展示。
11. 补充 changelog.txt 文本文件,跟随插件副本分发。
12. 补充 copyright.txt 版权文件,跟随插件副本分发。
## v3.7.1 - 2024-11-19
1. 性能优化
2. 修复监控无法关闭的问题
**Full Changelog**: https://github.com/WenPai-org/wp-china-yes/compare/v3.6.5...v3.7.1
## v3.6.5 - 2024-08-23
1. 优化 CLI 判断

2
Plugin.php Normal file → Executable file
View file

@ -45,7 +45,7 @@ class Plugin {
*/
add_filter( sprintf( '%splugin_action_links', is_multisite() ? 'network_admin_' : '' ), function ( $links, $plugin = '' ) {
$links[] = '<a target="_blank" href="https://translate.wenpai.org/projects/plugins/' . substr( $plugin, 0, strpos( $plugin, '/' ) ) . '/">参与翻译</a>';
$links[] = '<a target="_blank" href="https://wp-china-yes.com/plugins/' . substr( $plugin, 0, strpos( $plugin, '/' ) ) . '/">去广告</a>';
$links[] = '<a target="_blank" href="https://wpcy.com/plugins/' . substr( $plugin, 0, strpos( $plugin, '/' ) ) . '/">去广告</a>';
return $links;
}, 10, 2 );

169
Service/123-Maintenance.php Executable file
View file

@ -0,0 +1,169 @@
<?php
namespace WenPai\ChinaYes\Service;
defined('ABSPATH') || exit;
use function WenPai\ChinaYes\get_settings;
class Maintenance {
private $settings;
private $allowed_pages = [
'wp-login.php',
'wp-register.php',
'wp-cron.php',
'async-upload.php',
'admin-ajax.php'
];
public function __construct() {
// 使用更早的钩子并设置高优先级
add_action('plugins_loaded', [$this, 'init'], 1);
}
public function init() {
$this->settings = get_settings();
// 仅在调试模式下输出调试信息
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('Maintenance Settings Raw: ' . print_r($this->settings, true));
error_log('Maintenance Mode Value: ' . var_export($this->settings['maintenance_mode'], true));
}
// 如果维护模式启用,挂载相关钩子
if ($this->settings['maintenance_mode']) {
add_action('template_redirect', [$this, 'check_maintenance_mode'], 1);
add_action('admin_bar_menu', [$this, 'add_admin_bar_notice'], 100);
add_action('init', [$this, 'check_ajax_maintenance'], 1);
}
}
public function check_ajax_maintenance() {
if (wp_doing_ajax() && !current_user_can('manage_options')) {
wp_die('维护模式已启用');
}
}
public function check_maintenance_mode() {
// 如果是命令行环境,直接返回
if (php_sapi_name() === 'cli') {
return;
}
// 如果是管理员,直接返回
if (current_user_can('manage_options')) {
return;
}
// 检查是否是允许的页面
global $pagenow;
if (in_array($pagenow, $this->allowed_pages)) {
return;
}
// 检查是否是后台请求
if (is_admin()) {
return;
}
// 检查是否是 REST API 请求
if (defined('REST_REQUEST') && REST_REQUEST) {
return;
}
// 检查是否是 AJAX 请求
if (wp_doing_ajax()) {
return;
}
// 显示维护页面
$this->show_maintenance_page();
}
private function show_maintenance_page() {
$maintenance_settings = $this->settings['maintenance_settings'] ?? [];
$title = $maintenance_settings['maintenance_title'] ?? '网站维护中';
$heading = $maintenance_settings['maintenance_heading'] ?? '网站维护中';
$message = $maintenance_settings['maintenance_message'] ?? '网站正在进行例行维护,请稍后访问。感谢您的理解与支持!';
// 添加基本的样式
$style = '
<style>
body {
background: #f1f1f1;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
.maintenance-wrapper {
text-align: center;
padding: 50px 20px;
max-width: 800px;
margin: 100px auto;
background: white;
border-radius: 5px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.maintenance-wrapper h1 {
color: #333;
font-size: 36px;
margin-bottom: 20px;
}
.maintenance-wrapper h2 {
color: #666;
font-size: 24px;
margin-bottom: 30px;
}
.maintenance-message {
color: #555;
line-height: 1.6;
font-size: 16px;
}
</style>
';
$output = $style . sprintf(
'<div class="maintenance-wrapper">
<h1>%s</h1>
<h2>%s</h2>
<div class="maintenance-message">%s</div>
</div>',
esc_html($heading),
esc_html($title),
wp_kses_post($message)
);
// 设置维护模式响应头
if (!headers_sent()) {
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 3600');
header('Content-Type: text/html; charset=utf-8');
}
// 确保输出被清空
if (ob_get_level()) {
ob_end_clean();
}
wp_die($output, $title, [
'response' => 503,
'back_link' => false
]);
}
public function add_admin_bar_notice($wp_admin_bar) {
if (!current_user_can('manage_options')) {
return;
}
// 添加调试信息
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('Admin bar notice added for maintenance mode.');
}
$wp_admin_bar->add_node([
'id' => 'maintenance-mode-notice',
'title' => '<span style="color: #ff0000;">维护模式已启用</span>',
'href' => admin_url('admin.php?page=wp-china-yes#tab=脉云维护')
]);
}
}

256
Service/Acceleration.php Executable file
View file

@ -0,0 +1,256 @@
<?php
namespace WenPai\ChinaYes\Service;
defined('ABSPATH') || exit;
use function WenPai\ChinaYes\get_settings;
class Acceleration {
private $settings;
public function __construct() {
$this->settings = get_settings();
$this->init();
}
/**
* 初始化 admincdn 功能
*/
private function init() {
if (!empty($this->settings['admincdn'])) {
add_action('wp_head', function () {
echo "<!-- 此站点使用的前端静态资源库由萌芽加速adminCDN提供智能加速转接基于文派叶子 WPCY.COM -->\n";
}, 1);
}
$this->load_admincdn();
}
/**
* 加载 admincdn 功能
*/
private function load_admincdn() {
// 确保 $this->settings 中包含必要的键
$this->settings['admincdn_files'] = $this->settings['admincdn_files'] ?? [];
$this->settings['admincdn_public'] = $this->settings['admincdn_public'] ?? [];
$this->settings['admincdn_dev'] = $this->settings['admincdn_dev'] ?? [];
// WordPress 核心静态文件链接替换
if (is_admin() && !(defined('DOING_AJAX') && DOING_AJAX)) {
if (
in_array('admin', (array) $this->settings['admincdn']) &&
!stristr($GLOBALS['wp_version'], 'alpha') &&
!stristr($GLOBALS['wp_version'], 'beta') &&
!stristr($GLOBALS['wp_version'], 'RC')
) {
// 禁用合并加载,以便于使用公共资源节点
global $concatenate_scripts;
$concatenate_scripts = false;
$this->page_str_replace('init', 'preg_replace', [
'~' . home_url('/') . '(wp-admin|wp-includes)/(css|js)/~',
sprintf('https://wpstatic.admincdn.com/%s/$1/$2/', $GLOBALS['wp_version'])
]);
}
}
// 前台静态加速
if (in_array('frontend', (array) $this->settings['admincdn_files'])) {
$this->page_str_replace('template_redirect', 'preg_replace', [
'#(?<=[(\"\'])(?:' . quotemeta(home_url()) . ')?/(?:((?:wp-content|wp-includes)[^\"\')]+\.(css|js)[^\"\')]+))(?=[\"\')])#',
'https://public.admincdn.com/$0'
]);
}
// Google 字体替换
if (in_array('googlefonts', (array) $this->settings['admincdn_public'])) {
$this->page_str_replace('init', 'str_replace', [
'fonts.googleapis.com',
'googlefonts.admincdn.com'
]);
}
// Google 前端公共库替换
if (in_array('googleajax', (array) $this->settings['admincdn_public'])) {
$this->page_str_replace('init', 'str_replace', [
'ajax.googleapis.com',
'googleajax.admincdn.com'
]);
}
// CDNJS 前端公共库替换
if (in_array('cdnjs', (array) $this->settings['admincdn_public'])) {
$this->page_str_replace('init', 'str_replace', [
'cdnjs.cloudflare.com/ajax/libs',
'cdnjs.admincdn.com'
]);
}
// jsDelivr 前端公共库替换
if (in_array('jsdelivr', (array) $this->settings['admincdn_public'])) {
$this->page_str_replace('init', 'str_replace', [
'cdn.jsdelivr.net',
'jsd.admincdn.com'
]);
}
// BootstrapCDN 前端公共库替换
if (in_array('bootstrapcdn', (array) $this->settings['admincdn_public'])) {
$this->page_str_replace('init', 'str_replace', [
'maxcdn.bootstrapcdn.com',
'jsd.admincdn.com'
]);
}
// Emoji 资源加速 - 使用 Twitter Emoji
if (in_array('emoji', (array) $this->settings['admincdn_files'])) {
$this->replace_emoji();
}
// WordPress.org 预览资源加速
if (in_array('sworg', (array) $this->settings['admincdn_files'])) {
$this->replace_sworg();
}
// React 前端库加速
if (in_array('react', (array) $this->settings['admincdn_dev'])) {
$this->page_str_replace('init', 'str_replace', [
'unpkg.com/react',
'jsd.admincdn.com/npm/react'
]);
}
// jQuery 前端库加速
if (in_array('jquery', (array) $this->settings['admincdn_dev'])) {
$this->page_str_replace('init', 'str_replace', [
'code.jquery.com',
'jsd.admincdn.com/npm/jquery'
]);
}
// Vue.js 前端库加速
if (in_array('vuejs', (array) $this->settings['admincdn_dev'])) {
$this->page_str_replace('init', 'str_replace', [
'unpkg.com/vue',
'jsd.admincdn.com/npm/vue'
]);
}
// DataTables 前端库加速
if (in_array('datatables', (array) $this->settings['admincdn_dev'])) {
$this->page_str_replace('init', 'str_replace', [
'cdn.datatables.net',
'jsd.admincdn.com/npm/datatables.net'
]);
}
// Tailwind CSS 加速
if (in_array('tailwindcss', (array) $this->settings['admincdn_dev'])) {
$this->page_str_replace('init', 'str_replace', [
'unpkg.com/tailwindcss',
'jsd.admincdn.com/npm/tailwindcss'
]);
}
}
/**
* 替换 Emoji 资源
*/
private function replace_emoji() {
// 禁用 WordPress 默认的 emoji 处理
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_styles', 'print_emoji_styles');
remove_filter('the_content_feed', 'wp_staticize_emoji');
remove_filter('comment_text_rss', 'wp_staticize_emoji');
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
// 替换 emoji 图片路径
$this->page_str_replace('init', 'str_replace', [
's.w.org/images/core/emoji',
'jsd.admincdn.com/npm/@twemoji/api/dist'
]);
// 替换 wpemojiSettings 配置
add_action('wp_head', function () {
?>
<script>
window._wpemojiSettings = {
"baseUrl": "https://jsd.admincdn.com/npm/@twemoji/api@15.0.3/dist/72x72/",
"ext": ".png",
"svgUrl": "https://jsd.admincdn.com/npm/@twemoji/api@15.0.3/dist/svg/",
"svgExt": ".svg",
"source": {
"concatemoji": "<?php echo includes_url('js/wp-emoji-release.min.js'); ?>"
}
};
</script>
<?php
}, 1);
}
/**
* 替换 WordPress.org 预览资源
*/
private function replace_sworg() {
$this->page_str_replace('init', 'str_replace', [
'ts.w.org',
'ts.wenpai.net'
]);
// 替换主题预览图片 URL
add_filter('theme_screenshot_url', function ($url) {
if (strpos($url, 'ts.w.org') !== false) {
$url = str_replace('ts.w.org', 'ts.wenpai.net', $url);
}
return $url;
});
// 过滤主题 API 响应
add_filter('themes_api_result', function ($res, $action, $args) {
if (is_object($res) && !empty($res->screenshots)) {
foreach ($res->screenshots as &$screenshot) {
if (isset($screenshot->src)) {
$screenshot->src = str_replace('ts.w.org', 'ts.wenpai.net', $screenshot->src);
}
}
}
return $res;
}, 10, 3);
// 替换页面内容
add_action('admin_init', function () {
ob_start(function ($content) {
return str_replace('ts.w.org', 'ts.wenpai.net', $content);
});
});
// 确保前台内容替换
add_action('template_redirect', function () {
ob_start(function ($content) {
return str_replace('ts.w.org', 'ts.wenpai.net', $content);
});
});
}
/**
* 页面字符串替换
*
* @param string $hook 钩子名称
* @param string $replace_func 替换函数
* @param array $param 替换参数
*/
private function page_str_replace($hook, $replace_func, $param) {
if (php_sapi_name() == 'cli') {
return;
}
add_action($hook, function () use ($replace_func, $param) {
ob_start(function ($buffer) use ($replace_func, $param) {
$param[] = $buffer;
return call_user_func_array($replace_func, $param);
});
}, PHP_INT_MAX);
}
}

46
Service/Adblock.php Executable file
View file

@ -0,0 +1,46 @@
<?php
namespace WenPai\ChinaYes\Service;
defined('ABSPATH') || exit;
use function WenPai\ChinaYes\get_settings;
/**
* Class Adblock
* 广告拦截服务
* @package WenPai\ChinaYes\Service
*/
class Adblock {
private $settings;
public function __construct() {
$this->settings = get_settings();
$this->init();
}
/**
* 初始化广告拦截功能
*/
private function init() {
if (!empty($this->settings['adblock']) && $this->settings['adblock'] == 'on') {
add_action('admin_head', [$this, 'load_adblock']);
}
}
/**
* 加载广告拦截
*/
public function load_adblock() {
// 处理广告拦截规则
foreach ((array) $this->settings['adblock_rule'] as $rule) {
if (empty($rule['enable']) || empty($rule['selector'])) {
continue;
}
echo sprintf('<style>%s{display:none!important;}</style>',
htmlspecialchars_decode($rule['selector'])
);
}
}
}

98
Service/Avatar.php Executable file
View file

@ -0,0 +1,98 @@
<?php
namespace WenPai\ChinaYes\Service;
defined('ABSPATH') || exit;
use function WenPai\ChinaYes\get_settings;
/**
* Class Avatar
* 初认头像服务
* @package WenPai\ChinaYes\Service
*/
class Avatar {
private $settings;
public function __construct() {
$this->settings = get_settings();
$this->init();
}
/**
* 初始化初认头像功能
*/
private function init() {
if (!empty($this->settings['cravatar'])) {
add_filter('user_profile_picture_description', [$this, 'set_user_profile_picture_for_cravatar'], 1);
add_filter('avatar_defaults', [$this, 'set_defaults_for_cravatar'], 1);
add_filter('um_user_avatar_url_filter', [$this, 'get_cravatar_url'], 1);
add_filter('bp_gravatar_url', [$this, 'get_cravatar_url'], 1);
add_filter('get_avatar_url', [$this, 'get_cravatar_url'], 1);
}
}
/**
* 获取 Cravatar URL
*/
public function get_cravatar_url($url) {
switch ($this->settings['cravatar']) {
case 'cn':
return $this->replace_avatar_url($url, 'cn.cravatar.com');
case 'global':
return $this->replace_avatar_url($url, 'en.cravatar.com');
case 'weavatar':
return $this->replace_avatar_url($url, 'weavatar.com');
default:
return $url;
}
}
/**
* 替换头像 URL
*/
public function replace_avatar_url($url, $domain) {
$sources = array(
'www.gravatar.com',
'0.gravatar.com',
'1.gravatar.com',
'2.gravatar.com',
's.gravatar.com',
'secure.gravatar.com',
'cn.gravatar.com',
'en.gravatar.com',
'gravatar.com',
'sdn.geekzu.org',
'gravatar.duoshuo.com',
'gravatar.loli.net',
'dn-qiniu-avatar.qbox.me'
);
return str_replace($sources, $domain, $url);
}
/**
* 设置 WordPress 讨论设置中的默认 LOGO 名称
*/
public function set_defaults_for_cravatar($avatar_defaults) {
if ($this->settings['cravatar'] == 'weavatar') {
$avatar_defaults['gravatar_default'] = 'WeAvatar';
} else {
$avatar_defaults['gravatar_default'] = '初认头像';
}
return $avatar_defaults;
}
/**
* 设置个人资料卡中的头像上传地址
*/
public function set_user_profile_picture_for_cravatar() {
if ($this->settings['cravatar'] == 'weavatar') {
return '<a href="https://weavatar.com" target="_blank">您可以在 WeAvatar 修改您的资料图片</a>';
} else {
return '<a href="https://cravatar.com" target="_blank">您可以在初认头像修改您的资料图片</a>';
}
}
}

46
Service/Base.php Normal file → Executable file
View file

@ -11,16 +11,38 @@ defined( 'ABSPATH' ) || exit;
*/
class Base {
public function __construct() {
// 加速服务
new Super();
// 监控服务
new Monitor();
// 更新服务
new Update();
if ( is_admin() ) {
// 设置服务
new Setting();
}
}
public function __construct() {
// 确保所有类文件都存在后再实例化
if (class_exists(__NAMESPACE__ . '\Super')) {
new Super();
}
if (class_exists(__NAMESPACE__ . '\Monitor')) {
new Monitor();
}
if (class_exists(__NAMESPACE__ . '\Memory')) {
new Memory();
}
if (class_exists(__NAMESPACE__ . '\Update')) {
new Update();
}
if (class_exists(__NAMESPACE__ . '\Database')) {
new Database();
}
if (class_exists(__NAMESPACE__ . '\Acceleration')) {
new Acceleration();
}
if (class_exists(__NAMESPACE__ . '\Maintenance')) {
new Maintenance();
}
if ( is_admin() && class_exists(__NAMESPACE__ . '\Setting')) {
new Setting();
}
}
}

0
Service/Comments.php Executable file
View file

92
Service/Database.php Executable file
View file

@ -0,0 +1,92 @@
<?php
namespace WenPai\ChinaYes\Service;
defined( 'ABSPATH' ) || exit;
use function WenPai\ChinaYes\get_settings;
/**
* Class Database
* 数据库工具服务
* @package WenPai\ChinaYes\Service
*/
class Database {
private $settings;
public function __construct() {
$this->settings = get_settings();
// 如果启用了数据库工具,则允许访问数据库修复工具
if ( ! empty( $this->settings['enable_db_tools'] ) && $this->settings['enable_db_tools'] ) {
define( 'WP_ALLOW_REPAIR', true );
}
// 处理调试常量
$this->handle_debug_constants();
// 安全相关常量
$this->handle_security_constants();
}
/**
* 处理调试模式相关常量
*/
private function handle_debug_constants() {
if ( ! empty( $this->settings['enable_debug'] ) && $this->settings['enable_debug'] ) {
// 只有在常量未定义时才定义
if ( ! defined( 'WP_DEBUG' ) ) {
define( 'WP_DEBUG', true );
}
if ( ! empty( $this->settings['debug_options']['wp_debug_log'] ) && ! defined( 'WP_DEBUG_LOG' ) ) {
define( 'WP_DEBUG_LOG', true );
}
if ( ! empty( $this->settings['debug_options']['wp_debug_display'] ) && ! defined( 'WP_DEBUG_DISPLAY' ) ) {
define( 'WP_DEBUG_DISPLAY', true );
}
if ( ! empty( $this->settings['debug_options']['script_debug'] ) && ! defined( 'SCRIPT_DEBUG' ) ) {
define( 'SCRIPT_DEBUG', true );
}
if ( ! empty( $this->settings['debug_options']['save_queries'] ) && ! defined( 'SAVEQUERIES' ) ) {
define( 'SAVEQUERIES', true );
}
} else {
// 禁用调试模式时的默认值
if ( ! defined( 'WP_DEBUG' ) ) {
define( 'WP_DEBUG', false );
}
if ( ! defined( 'WP_DEBUG_LOG' ) ) {
define( 'WP_DEBUG_LOG', false );
}
if ( ! defined( 'WP_DEBUG_DISPLAY' ) ) {
define( 'WP_DEBUG_DISPLAY', false );
}
if ( ! defined( 'SCRIPT_DEBUG' ) ) {
define( 'SCRIPT_DEBUG', false );
}
if ( ! defined( 'SAVEQUERIES' ) ) {
define( 'SAVEQUERIES', false );
}
}
}
/**
* 处理安全相关常量
*/
private function handle_security_constants() {
if ( ! empty( $this->settings['disallow_file_edit'] ) && ! defined( 'DISALLOW_FILE_EDIT' ) ) {
define( 'DISALLOW_FILE_EDIT', $this->settings['disallow_file_edit'] );
}
if ( ! empty( $this->settings['disallow_file_mods'] ) && ! defined( 'DISALLOW_FILE_MODS' ) ) {
define( 'DISALLOW_FILE_MODS', $this->settings['disallow_file_mods'] );
}
if ( ! empty( $this->settings['force_ssl_admin'] ) && ! defined( 'FORCE_SSL_ADMIN' ) ) {
define( 'FORCE_SSL_ADMIN', $this->settings['force_ssl_admin'] );
}
if ( ! empty( $this->settings['force_ssl_login'] ) && ! defined( 'FORCE_SSL_LOGIN' ) ) {
define( 'FORCE_SSL_LOGIN', $this->settings['force_ssl_login'] );
}
}
}

131
Service/Fonts.php Executable file
View file

@ -0,0 +1,131 @@
<?php
namespace WenPai\ChinaYes\Service;
defined('ABSPATH') || exit;
use function WenPai\ChinaYes\get_settings;
/**
* Class Fonts
* 文风字体服务
* @package WenPai\ChinaYes\Service
*/
class Fonts {
private $settings;
public function __construct() {
$this->settings = get_settings();
$this->init();
}
/**
* 初始化文风字体功能
*/
private function init() {
if (!empty($this->settings['windfonts']) && $this->settings['windfonts'] != 'off') {
$this->load_typography();
}
if (!empty($this->settings['windfonts']) && $this->settings['windfonts'] == 'optimize') {
add_action('init', function () {
wp_enqueue_style('windfonts-optimize', CHINA_YES_PLUGIN_URL . 'assets/css/fonts.css', [], CHINA_YES_VERSION);
});
}
if (!empty($this->settings['windfonts']) && $this->settings['windfonts'] == 'on') {
add_action('wp_head', [$this, 'load_windfonts']);
add_action('admin_head', [$this, 'load_windfonts']);
}
if (!empty($this->settings['windfonts']) && $this->settings['windfonts'] == 'frontend') {
add_action('wp_head', [$this, 'load_windfonts']);
}
}
/**
* 加载文风字体
*/
public function load_windfonts() {
echo <<<HTML
<link rel="preconnect" href="//cn.windfonts.com">
<!-- 此中文网页字体由文风字体Windfonts免费提供您可以自由引用请务必保留此授权许可标注 https://wenfeng.org/license -->
HTML;
$loaded = [];
foreach ((array) $this->settings['windfonts_list'] as $font) {
if (empty($font['enable'])) {
continue;
}
if (empty($font['family'])) {
continue;
}
if (in_array($font['css'], $loaded)) {
continue;
}
echo sprintf(<<<HTML
<link rel="stylesheet" type="text/css" href="%s">
<style>
%s {
font-style: %s;
font-weight: %s;
font-family: '%s',sans-serif!important;
}
</style>
HTML
,
$font['css'],
htmlspecialchars_decode($font['selector']),
$font['style'],
$font['weight'],
$font['family']
);
$loaded[] = $font['css'];
}
}
/**
* 加载排印优化
*/
public function load_typography() {
// 支持中文排版段首缩进 2em
if (in_array('indent', (array) $this->settings['windfonts_typography'])) {
add_action('wp_head', function () {
echo '<style>
.entry-content p {
text-indent: 2em;
}
.entry-content .wp-block-group p,
.entry-content .wp-block-columns p,
.entry-content .wp-block-media-text p,
.entry-content .wp-block-quote p {
text-indent: 0;
}
</style>';
});
}
// 支持中文排版两端对齐
if (in_array('align', (array) $this->settings['windfonts_typography'])) {
add_action('wp_head', function () {
if (is_single()) { // 仅在文章页面生效
echo '<style>
.entry-content p {
text-align: justify;
}
.entry-content .wp-block-group p,
.entry-content .wp-block-columns p,
.entry-content .wp-block-media-text p,
.entry-content .wp-block-quote p {
text-align: unset !important;
}
.entry-content .wp-block-columns .has-text-align-center {
text-align: center !important;
}
</style>';
}
});
}
}
}

0
Service/Mail.php Executable file
View file

136
Service/Maintenance.php Executable file
View file

@ -0,0 +1,136 @@
<?php
namespace WenPai\ChinaYes\Service;
defined('ABSPATH') || exit;
use function WenPai\ChinaYes\get_settings;
class Maintenance {
private $settings;
public function __construct() {
$this->settings = get_settings();
// 维护模式检查
if (!empty($this->settings['maintenance_mode'])) {
add_action('template_redirect', [$this, 'check_maintenance_mode']);
add_action('admin_bar_menu', [$this, 'add_admin_bar_notice'], 100);
}
// 仪表盘统计信息
if (!empty($this->settings['disk']) && $this->settings['disk']) {
add_action('dashboard_glance_items', [$this, 'add_dashboard_stats']);
add_action('admin_head', [$this, 'add_admin_css']);
}
// 添加登录记录钩子
add_action('wp_login', [$this, 'record_last_login'], 10, 2);
}
// 添加 CSS 样式
public function add_admin_css() {
$screen = get_current_screen();
if ($screen->id === 'dashboard') {
echo '<style>
#dashboard_right_now .stat-item span.dashicons {
margin: 0 3px 0 -25px;
background: white;
position: relative;
z-index: 1;
}
</style>';
}
}
public function add_dashboard_stats($items) {
if (!is_array($items)) {
$items = array();
}
// 获取显示选项设置
$display_options = $this->settings['disk_display'] ?? [];
// 媒体文件统计
if (in_array('media_num', $display_options)) {
$media_count = wp_count_posts('attachment')->inherit;
$items['media'] = sprintf(
'<a href="%s" class="stat-item"><span class="dashicons dashicons-format-gallery"></span> %s</a>',
admin_url('upload.php'),
sprintf(_n('%d 个媒体', '%d 个媒体', $media_count), $media_count)
);
}
// 管理员统计
if (in_array('admin_num', $display_options)) {
$admin_count = count(get_users(['role' => 'administrator', 'fields' => 'ID']));
$items['admins'] = sprintf(
'<a href="%s" class="stat-item"><span class="dashicons dashicons-shield-alt"></span> %s</a>',
admin_url('users.php?role=administrator'),
sprintf(_n('%d 个管理员', '%d 个管理员', $admin_count), $admin_count)
);
}
// 用户总数统计
if (in_array('user_num', $display_options)) {
$total_users = count(get_users(['fields' => 'ID']));
$items['users'] = sprintf(
'<a href="%s" class="stat-item"><span class="dashicons dashicons-groups"></span> %s</a>',
admin_url('users.php'),
sprintf(_n('%d 个用户', '%d 个用户', $total_users), $total_users)
);
}
// 磁盘使用统计
$disk_info = $this->get_disk_usage_info();
if (in_array('disk_usage', $display_options)) {
$items['disk_usage'] = sprintf(
'<span class="stat-item"><span class="dashicons dashicons-database"></span> 磁盘用量:%s / %s</span>',
size_format($disk_info['used']),
size_format($disk_info['total'])
);
}
if (in_array('disk_limit', $display_options)) {
$items['disk_free'] = sprintf(
'<span class="stat-item"><span class="dashicons dashicons-chart-area"></span> 剩余空间:%s (%s%%)</span>',
size_format($disk_info['free']),
round(($disk_info['free'] / $disk_info['total']) * 100, 2)
);
}
// 上次登录时间
if (in_array('lastlogin', $display_options)) {
$current_user_id = get_current_user_id();
$last_login = get_user_meta($current_user_id, 'last_login', true);
$items['lastlogin'] = sprintf(
'<span class="stat-item"><span class="dashicons dashicons-clock"></span> 上次登录:%s</span>',
$last_login ? date('Y.m.d H:i:s', $last_login) : '从未登录'
);
}
return $items;
}
private function get_disk_usage_info() {
$disk_info = get_transient('disk_usage_info');
if (false === $disk_info) {
$upload_dir = wp_upload_dir();
$disk_total = disk_total_space($upload_dir['basedir']);
$disk_free = disk_free_space($upload_dir['basedir']);
$disk_used = $disk_total - $disk_free;
$disk_info = [
'used' => $disk_used,
'total' => $disk_total,
'free' => $disk_free,
];
set_transient('disk_usage_info', $disk_info, HOUR_IN_SECONDS);
}
return $disk_info;
}
public function record_last_login($user_login, $user) {
update_user_meta($user->ID, 'last_login', time());
}
}

0
Service/Media.php Executable file
View file

273
Service/Memory.php Executable file
View file

@ -0,0 +1,273 @@
<?php
namespace WenPai\ChinaYes\Service;
defined( 'ABSPATH' ) || exit;
use function WenPai\ChinaYes\get_settings;
/**
* Class Memory
* 显示服务器 IP 和内存使用情况
* @package WenPai\ChinaYes\Service
*/
class Memory {
private $memory = [];
private $server_ip_address = '';
private $os_info = '';
private $debug_status = '';
private $cpu_usage = null;
private $mysql_version = '';
public function __construct() {
$settings = get_settings();
if (!empty($settings['memory'])) {
add_action('plugins_loaded', [$this, 'initialize']);
}
register_activation_hook(CHINA_YES_PLUGIN_FILE, [$this, 'check_php_version']);
}
/**
* 初始化插件
*/
public function initialize() {
add_action('init', [$this, 'check_memory_limit']);
add_filter('admin_footer_text', [$this, 'add_footer']);
}
/**
* 获取操作系统信息
*/
private function get_os_info() {
$os = php_uname('s');
// 转换为更直观的名称
switch (strtolower($os)) {
case 'linux':
return 'Linux';
case 'darwin':
return 'macOS';
case 'windows nt':
return 'Windows';
default:
return $os;
}
}
/**
* 获取调试状态
*/
private function get_debug_status() {
if (defined('WP_DEBUG') && true === WP_DEBUG) {
return '<strong><font color="#F60">' . __('WP_DEBUG', 'wp-china-yes') . '</font></strong>';
}
return '<span style="text-decoration: line-through;">' . __('WP_DEBUG', 'wp-china-yes') . '</span>';
}
/**
* 获取 CPU 使用率
*/
private function get_cpu_usage() {
if (function_exists('sys_getloadavg') && is_callable('sys_getloadavg')) {
$load = sys_getloadavg();
return round($load[0] * 100 / 4, 2); // 假设是4核CPU
}
return false;
}
/**
* 获取 MySQL 版本
*/
private function get_mysql_version() {
global $wpdb;
return $wpdb->get_var("SELECT VERSION()");
}
/**
* 检查 PHP 内存限制
*/
public function check_memory_limit() {
$this->memory['limit'] = (int) ini_get('memory_limit');
}
/**
* 检查内存使用情况
*/
private function check_memory_usage() {
$this->memory['usage'] = function_exists('memory_get_peak_usage')
? round(memory_get_peak_usage(true) / 1024 / 1024, 2)
: 0;
if (!empty($this->memory['usage']) && !empty($this->memory['limit'])) {
$this->memory['percent'] = round($this->memory['usage'] / $this->memory['limit'] * 100, 0);
$this->memory['color'] = $this->get_memory_color($this->memory['percent']);
}
}
/**
* 获取内存使用率的颜色
*/
private function get_memory_color($percent) {
if ($percent > 90) {
return 'font-weight:bold;color:red';
} elseif ($percent > 75) {
return 'font-weight:bold;color:#E66F00';
}
return 'font-weight:normal;';
}
/**
* 格式化 WordPress 内存限制
*/
private function format_wp_limit($size) {
$unit = strtoupper(substr($size, -1));
$value = (int) substr($size, 0, -1);
switch ($unit) {
case 'P': $value *= 1024;
case 'T': $value *= 1024;
case 'G': $value *= 1024;
case 'M': $value *= 1024;
case 'K': $value *= 1024;
}
return $value;
}
/**
* 获取 WordPress 内存限制
*/
private function check_wp_limit() {
$memory = $this->format_wp_limit(WP_MEMORY_LIMIT);
return $memory ? size_format($memory) : __('N/A', 'wp-china-yes');
}
/**
* 添加信息到管理界面页脚
*/
public function add_footer($content) {
$settings = get_settings();
// 设置默认显示选项
$default_options = [
'memory_usage',
'wp_limit',
'server_ip',
];
// 如果设置为空或不是数组,使用默认选项
$display_options = isset($settings['memory_display']) && is_array($settings['memory_display'])
? $settings['memory_display']
: $default_options;
// 如果 memory 设置未启用,直接返回原始内容
if (empty($settings['memory'])) {
return $content;
}
$this->check_memory_usage();
$this->server_ip_address = $_SERVER['SERVER_ADDR'] ?? ($_SERVER['LOCAL_ADDR'] ?? '');
$this->os_info = $this->get_os_info();
$footer_parts = [];
// 内存使用量
if (in_array('memory_usage', $display_options)) {
$footer_parts[] = sprintf('%s: %s %s %s MB (<span style="%s">%s%%</span>)',
__('Memory', 'wp-china-yes'),
$this->memory['usage'],
__('of', 'wp-china-yes'),
$this->memory['limit'],
$this->memory['color'],
$this->memory['percent']
);
}
// WP内存限制
if (in_array('wp_limit', $display_options)) {
$footer_parts[] = sprintf('%s: %s',
__('WP LIMIT', 'wp-china-yes'),
$this->check_wp_limit()
);
}
// 服务器IP和主机名
if (in_array('server_ip', $display_options)) {
$hostname_part = in_array('hostname', $display_options) ? " (" . gethostname() . ")" : "";
$footer_parts[] = sprintf('IP: %s%s',
$this->server_ip_address,
$hostname_part
);
}
// 操作系统信息
if (in_array('os_info', $display_options)) {
$footer_parts[] = sprintf('OS: %s', $this->os_info);
}
// PHP信息
if (in_array('php_info', $display_options)) {
$footer_parts[] = sprintf('PHP: %s @%sBitOS',
PHP_VERSION,
PHP_INT_SIZE * 8
);
}
// Debug状态
if (in_array('debug_status', $display_options)) {
$footer_parts[] = $this->get_debug_status();
}
// CPU使用率
if (in_array('cpu_usage', $display_options)) {
$cpu_usage = $this->get_cpu_usage();
if ($cpu_usage !== false) {
$footer_parts[] = sprintf('CPU: %s%%', $cpu_usage);
}
}
// MySQL版本
if (in_array('mysql_version', $display_options)) {
$footer_parts[] = sprintf('MySQL: %s', $this->get_mysql_version());
}
if (!empty($footer_parts)) {
$content .= ' | WPCY - ' . implode(' | ', $footer_parts);
}
return $content;
}
/**
* 检查 PHP 版本
*/
public function check_php_version() {
if (version_compare(PHP_VERSION, '7.0', '<')) {
deactivate_plugins(plugin_basename(CHINA_YES_PLUGIN_FILE));
wp_die(
sprintf(
'<h1>%s</h1><p>%s</p>',
__('插件无法激活PHP 版本过低', 'wp-china-yes'),
__('请升级 PHP 至 7.0 或更高版本。', 'wp-china-yes')
),
__('PHP 版本错误', 'wp-china-yes'),
['back_link' => true]
);
}
}
/**
* 更新设置
*/
private function update_settings() {
if ( is_multisite() ) {
update_site_option( 'wp_china_yes', $this->settings );
} else {
update_option( 'wp_china_yes', $this->settings, true );
}
}
}

3
Service/Monitor.php Normal file → Executable file
View file

@ -32,7 +32,7 @@ class Monitor {
} else {
wp_clear_scheduled_hook( 'wp_china_yes_monitor' );
}
}
}
/**
* 初始化
@ -157,6 +157,7 @@ class Monitor {
}
}
}
/**
* 更新设置

2
Service/Performance.php Executable file
View file

@ -0,0 +1,2 @@
<?php

1214
Service/Setting.php Normal file → Executable file

File diff suppressed because it is too large Load diff

513
Service/Super.php Normal file → Executable file
View file

@ -31,152 +31,152 @@ class Super {
/**
* 添加「文派茶馆」小组件
*/
if ( is_admin() ) {
add_action( 'wp_dashboard_setup', function () {
global $wp_meta_boxes;
if ( is_admin() ) {
add_action( 'wp_dashboard_setup', function () {
global $wp_meta_boxes;
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] );
wp_add_dashboard_widget( 'wenpai_tea', '文派茶馆', function () {
echo <<<HTML
<div class="wordpress-news hide-if-no-js">
<div class="rss-widget">
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] );
wp_add_dashboard_widget( 'wenpai_tea', '文派茶馆', function () {
$default_rss_url = 'https://wptea.com/feed/';
$custom_rss_url = $this->settings['custom_rss_url'] ?? '';
$refresh_interval = $this->settings['custom_rss_refresh'] ?? 3600;
$rss_display_options = $this->settings['rss_display_options'] ?? ['show_date', 'show_summary', 'show_footer'];
if (!is_array($rss_display_options)) {
$rss_display_options = explode(',', $rss_display_options);
}
// 获取默认的 RSS 源内容
$default_rss = fetch_feed($default_rss_url);
$default_items = [];
if (!is_wp_error($default_rss)) {
$default_items = $default_rss->get_items(0, 5);
}
$custom_items = [];
$custom_rss = null;
$custom_rss_latest_date = 0;
if (!empty($custom_rss_url)) {
$transient_key = 'wenpai_tea_custom_rss_' . md5($custom_rss_url);
$cached_custom_items = get_transient($transient_key);
if (false === $cached_custom_items) {
$custom_rss = fetch_feed($custom_rss_url);
if (!is_wp_error($custom_rss)) {
$custom_items = $custom_rss->get_items(0, 2);
if (!empty($custom_items)) {
$custom_rss_latest_date = $custom_items[0]->get_date('U');
}
set_transient($transient_key, $custom_items, $refresh_interval);
}
} else {
$custom_items = $cached_custom_items;
if (!empty($custom_items)) {
$custom_rss_latest_date = $custom_items[0]->get_date('U');
}
}
}
$three_days_ago = time() - (3 * 24 * 60 * 60);
if ($custom_rss_latest_date > $three_days_ago) {
$items = array_merge(array_slice($default_items, 0, 3), $custom_items);
} else {
$items = array_slice($default_items, 0, 5);
}
if (is_wp_error($custom_rss)) {
$items = array_slice($default_items, 0, 5);
}
echo <<<HTML
<div class="wordpress-news hide-if-no-js">
<div class="rss-widget">
HTML;
wp_widget_rss_output( 'https://wptea.com/feed/', [
'items' => 5,
'show_summary' => 1,
] );
echo <<<HTML
</div>
</div>
<p class="community-events-footer">
<a href="https://wenpai.org/" target="_blank">文派开源</a>
|
<a href="https://wenpai.org/support" target="_blank">支持论坛</a>
|
<a href="https://translate.wenpai.org/" target="_blank">翻译平台</a>
|
<a href="https://wptea.com/instructions-for-submission/" target="_blank">文章投稿</a>
|
<a href="https://wp-china-yes.com/document/news-source" target="_blank">自选新闻源</a>
</p>
<style>
#wenpai_tea .rss-widget {
font-size:13px;
padding:0 12px
}
#wenpai_tea .rss-widget:last-child {
border-bottom:none;
padding-bottom:8px
}
#wenpai_tea .rss-widget a {
font-weight:400
}
#wenpai_tea .rss-widget span,
#wenpai_tea .rss-widget span.rss-date {
color:#646970
}
#wenpai_tea .rss-widget span.rss-date {
margin-left:12px
}
#wenpai_tea .rss-widget ul li {
padding:4px 0;
margin:0
}
#wenpai_tea .community-events-footer a {
line-height: 2;
padding: 0.5em;
}
</style>
foreach ($items as $item) {
echo '<div class="rss-item">';
echo '<a href="' . esc_url($item->get_permalink()) . '" target="_blank">' . esc_html($item->get_title()) . '</a>';
if (in_array('show_date', $rss_display_options)) {
echo '<span class="rss-date">' . esc_html($item->get_date('Y.m.d')) . '</span>';
}
if (in_array('show_summary', $rss_display_options)) {
echo '<div class="rss-summary">' . esc_html(wp_trim_words($item->get_description(), 45, '...')) . '</div>';
}
echo '</div>';
}
echo <<<HTML
</div>
</div>
HTML;
} );
} );
add_action( 'wp_network_dashboard_setup', function () {
global $wp_meta_boxes;
unset( $wp_meta_boxes['dashboard-network']['side']['core']['dashboard_primary'] );
wp_add_dashboard_widget( 'wenpai_tea', '文派茶馆', function () {
echo <<<HTML
<div class="wordpress-news hide-if-no-js">
<div class="rss-widget">
if (in_array('show_footer', $rss_display_options)) {
echo <<<HTML
<p class="community-events-footer">
<a href="https://wenpai.org/" target="_blank">文派开源</a>
|
<a href="https://wenpai.org/support" target="_blank">支持论坛</a>
|
<a href="https://translate.wenpai.org/" target="_blank">翻译平台</a>
|
<a href="https://wptea.com/newsletter/" target="_blank">订阅推送</a>
</p>
HTML;
wp_widget_rss_output( 'https://wptea.com/feed/', [
'items' => 5,
'show_summary' => 1,
] );
echo <<<HTML
</div>
</div>
<p class="community-events-footer">
<a href="https://wenpai.org/" target="_blank">文派开源</a>
|
<a href="https://wenpai.org/support" target="_blank">支持论坛</a>
|
<a href="https://translate.wenpai.org/" target="_blank">翻译平台</a>
|
<a href="https://wptea.com/instructions-for-submission/" target="_blank">文章投稿</a>
|
<a href="https://wptea.com/document/news-source/" target="_blank">自选新闻源</a>
</p>
<style>
#wenpai_tea .rss-widget {
font-size:13px;
padding:0 12px
}
#wenpai_tea .rss-widget:last-child {
border-bottom:none;
padding-bottom:8px
}
#wenpai_tea .rss-widget a {
font-weight:400
}
#wenpai_tea .rss-widget span,
#wenpai_tea .rss-widget span.rss-date {
color:#646970
}
#wenpai_tea .rss-widget span.rss-date {
margin-left:12px
}
#wenpai_tea .rss-widget ul li {
padding:4px 0;
margin:0
}
#wenpai_tea .community-events-footer a {
line-height: 2;
padding: 0.5em;
}
</style>
}
echo <<<HTML
<style>
#wenpai_tea .rss-widget {
padding: 0 12px;
}
#wenpai_tea .rss-widget:last-child {
border-bottom: none;
padding-bottom: 8px;
}
#wenpai_tea .rss-item {
margin-bottom: 10px;
padding-bottom: 10px;
border-bottom: 1px solid #eee;
}
#wenpai_tea .rss-item:last-child {
border-bottom: none;
margin-bottom: 0;
padding-bottom: 0;
}
#wenpai_tea .rss-item a {
text-decoration: none;
display: block;
margin-bottom: 5px;
}
#wenpai_tea .rss-date {
color: #666;
font-size: 12px;
display: block;
margin-bottom: 8px;
}
#wenpai_tea .rss-summary {
color: #444;
font-size: 13px;
line-height: 1.5;
}
#wenpai_tea .community-events-footer {
margin-top: 15px;
padding-top: 15px;
padding-bottom: 5px;
border-top: 1px solid #eee;
text-align: center;
}
#wenpai_tea .community-events-footer a {
text-decoration: none;
margin: 0 5px;
}
#wenpai_tea .community-events-footer a:hover {
text-decoration: underline;
}
</style>
HTML;
} );
} );
}
/**
* WordPress 核心静态文件链接替换
*/
if ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
if (
in_array( 'admin', (array) $this->settings['admincdn'] ) &&
! stristr( $GLOBALS['wp_version'], 'alpha' ) &&
! stristr( $GLOBALS['wp_version'], 'beta' ) &&
! stristr( $GLOBALS['wp_version'], 'RC' )
) {
// 禁用合并加载,以便于使用公共资源节点
global $concatenate_scripts;
$concatenate_scripts = false;
$this->page_str_replace( 'init', 'preg_replace', [
'~' . home_url( '/' ) . '(wp-admin|wp-includes)/(css|js)/~',
sprintf( 'https://wpstatic.admincdn.com/%s/$1/$2/', $GLOBALS['wp_version'] )
] );
}
}
/**
* adminCDN
*/
if ( ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
$this->load_admincdn();
}
});
});
}
/**
* 初认头像
@ -218,6 +218,14 @@ HTML;
add_action( 'admin_head', [ $this, 'load_adblock' ] );
}
}
/**
* 通知管理
*/
if ( ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
if ( ! empty( $this->settings['notice_block'] ) && $this->settings['notice_block'] == 'on' ) {
add_action( 'admin_head', [ $this, 'load_notice_management' ] );
}
}
/**
* 飞行模式
@ -227,60 +235,8 @@ HTML;
}
}
/**
* 加载 adminCDN
*/
public function load_admincdn() {
/**
* 前台静态加速
*/
if ( in_array( 'frontend', (array) $this->settings['admincdn'] ) ) {
$this->page_str_replace( 'template_redirect', 'preg_replace', [
'#(?<=[(\"\'])(?:' . quotemeta( home_url() ) . ')?/(?:((?:wp-content|wp-includes)[^\"\')]+\.(css|js)[^\"\')]+))(?=[\"\')])#',
'https://public.admincdn.com/$0'
] );
}
/**
* Google 字体替换
*/
if ( in_array( 'googlefonts', (array) $this->settings['admincdn'] ) ) {
$this->page_str_replace( 'init', 'str_replace', [
'fonts.googleapis.com',
'googlefonts.admincdn.com'
] );
}
/**
* Google 前端公共库替换
*/
if ( in_array( 'googleajax', (array) $this->settings['admincdn'] ) ) {
$this->page_str_replace( 'init', 'str_replace', [
'ajax.googleapis.com',
'googleajax.admincdn.com'
] );
}
/**
* CDNJS 前端公共库替换
*/
if ( in_array( 'cdnjs', (array) $this->settings['admincdn'] ) ) {
$this->page_str_replace( 'init', 'str_replace', [
'cdnjs.cloudflare.com/ajax/libs',
'cdnjs.admincdn.com'
] );
}
/**
* jsDelivr 前端公共库替换
*/
if ( in_array( 'jsdelivr', (array) $this->settings['admincdn'] ) ) {
$this->page_str_replace( 'init', 'str_replace', [
'jsd.admincdn.com',
'jsd.admincdn.com'
] );
}
}
/**
* 加载文风字体
@ -442,31 +398,156 @@ HTML
remove_filter( $qmr_work_tag, 'wptexturize' );
}
}
// 支持中文排版段首缩进 2em
if ( in_array( 'indent', (array) $this->settings['windfonts_typography'] ) ) {
add_action( 'wp_head', function () {
echo '<style>
.entry-content p {
text-indent: 2em;
}
.entry-content .wp-block-group p,
.entry-content .wp-block-columns p,
.entry-content .wp-block-media-text p,
.entry-content .wp-block-quote p {
text-indent: 0;
}
</style>';
} );
}
// 支持中文排版两端对齐
if ( in_array( 'align', (array) $this->settings['windfonts_typography'] ) ) {
add_action( 'wp_head', function () {
if ( is_single() ) { // 仅在文章页面生效
echo '<style>
.entry-content p {
text-align: justify;
}
.entry-content .wp-block-group p,
.entry-content .wp-block-columns p,
.entry-content .wp-block-media-text p,
.entry-content .wp-block-quote p {
text-align: unset !important;
}
.entry-content .wp-block-columns .has-text-align-center {
text-align: center !important;
}
</style>';
}
} );
}
}
/**
* 加载广告拦截
*/
public function load_adblock() {
foreach ( (array) $this->settings['adblock_rule'] as $rule ) {
if ( empty( $rule['enable'] ) ) {
continue;
}
if ( empty( $rule['selector'] ) ) {
continue;
}
echo sprintf( <<<HTML
<style>
%s {
display: none!important;
}
</style>
HTML
,
htmlspecialchars_decode( $rule['selector'] )
);
}
}
/**
* 加载广告拦截
*/
public function load_adblock() {
if (empty($this->settings['adblock']) || $this->settings['adblock'] !== 'on') {
return;
}
// 处理广告拦截规则
foreach ( (array) $this->settings['adblock_rule'] as $rule ) {
if ( empty( $rule['enable'] ) || empty( $rule['selector'] ) ) {
continue;
}
echo sprintf( '<style>%s{display:none!important;}</style>',
htmlspecialchars_decode( $rule['selector'] )
);
}
}
/**
* 加载通知管理
*/
public function load_notice_management() {
// 首先检查是否启用通知管理功能
if (empty($this->settings['notice_block']) || $this->settings['notice_block'] !== 'on') {
return;
}
// 检查是否启用全局禁用
if (!empty($this->settings['disable_all_notices'])) {
$this->disable_all_notices();
echo '<style>.notice,.notice-error,.notice-warning,.notice-success,.notice-info,.updated,.error,.update-nag{display:none!important;}</style>';
return;
}
// 处理选择性禁用
$selected_notices = $this->settings['notice_control'] ?? [];
$notice_method = $this->settings['notice_method'] ?? 'hook';
if (!empty($selected_notices)) {
// 处理钩子移除
if (in_array($notice_method, ['hook', 'both'])) {
$this->disable_selected_notices($selected_notices);
}
// 处理 CSS 隐藏
if (in_array($notice_method, ['css', 'both'])) {
$this->apply_notice_css($selected_notices);
}
}
}
/**
* 应用通知 CSS 隐藏
*/
private function apply_notice_css($selected_notices) {
$selectors = [];
foreach ($selected_notices as $type) {
switch ($type) {
case 'error':
$selectors[] = '.notice-error,.error';
break;
case 'warning':
$selectors[] = '.notice-warning';
break;
case 'success':
$selectors[] = '.notice-success,.updated';
break;
case 'info':
$selectors[] = '.notice-info';
break;
case 'core':
$selectors[] = '.update-nag';
break;
}
}
if (!empty($selectors)) {
echo '<style>' . implode(',', $selectors) . '{display:none!important;}</style>';
}
}
/**
* 移除所有管理通知
*/
private function disable_all_notices() {
remove_all_actions('admin_notices');
remove_all_actions('all_admin_notices');
remove_all_actions('user_admin_notices');
remove_all_actions('network_admin_notices');
}
/**
* 禁用选定的通知类型
*/
private function disable_selected_notices($types) {
if (in_array('core', $types)) {
remove_action('admin_notices', 'update_nag', 3);
remove_action('admin_notices', 'maintenance_nag', 10);
add_filter('pre_site_transient_update_core', '__return_null');
add_filter('pre_site_transient_update_plugins', '__return_null');
add_filter('pre_site_transient_update_themes', '__return_null');
}
}
/**
* 加载飞行模式

0
Service/Update.php Normal file → Executable file
View file

0
assets/css/fonts.css Normal file → Executable file
View file

360
assets/css/setting.css Normal file → Executable file
View file

@ -1,26 +1,64 @@
#wpcontent {
padding-left: 0px;
}
#wpbody-content {
padding-bottom: 0px;
}
#wpfooter {
display: none;
}
@media only screen and (max-width: 782px) {
.wp_china_yes-nav-normal+.wp_china_yes-content {
margin-left: 0!important;
}
.wp_china_yes-header-inner h1 {
margin-bottom: 20px;
}
.auto-fold #wpcontent {
padding-left: 0px;
}
.wp_china_yes-field-text input {
width: 100%;
}
}
.wp-core-ui .button, .wp-core-ui .button-primary, .wp-core-ui .button-secondary {
border-radius: 1px;
}
.sponsor-logos {
display: block;
flex-wrap: wrap;
justify-content: center;
margin: 24px 0;
grid-gap: 24px;
grid-template-columns: repeat(7, minmax(0, 1fr));
align-items: center;
}
.sponsor-logos img {
flex-basis: calc(20% - 10px);
max-width: 85px;
margin: 14px;
max-width: 80px;
margin: 13px;
height: auto;
}
.contributors-name {
margin-top: 0;
margin-bottom: 0;
padding: 12px;
padding: 20px 0;
color: #dcdcde;
display: block;
flex-wrap: wrap;
display: flex;
grid-gap: 22px;
}
.contributors-name a {
line-height: 2;
padding: 0.5em;
.wp_china_yes-content {
position: relative;
background-color: #f1f1f1;
}
.wp_china_yes-content a {
@ -33,21 +71,91 @@
}
.wp_china_yes-options {
background-color: #fff;
padding: 1%;
background-color: #ffffff;
border-radius: 10px;
text-transform: none;
line-height: 2;
box-shadow: 0 0.375rem 1.5rem 0 rgba(141, 153, 165, 0.13);
max-width: 1100px;
margin: 2rem auto;
}
.wp_china_yes-options {
margin-top: 0px;
margin-right: 0px;
}
.wp_china_yes-field {
padding: 8%;
background-color: #ffffff;
margin: 5% 0;
border-radius: 1px;
box-shadow: 0 0 0 1px #ccd0d4, 0 1px 1px 1px rgba(0, 0, 0, .04);
}
.wp_china_yes-field.wp_china_yes-field-content {
padding: 0;
background-color: rgba(255, 255, 255, 0);
margin: 0;
border-radius: 0;
box-shadow: unset;
}
.wp_china_yes-field-checkbox .wp_china_yes--inline-list li, .wp_china_yes-field-radio .wp_china_yes--inline-list li {
margin-right: 20px;
}
.wp_china_yes-copyright p {
font-size: 12px;
color: #999;
}
.wp_china_yes-copyright {
float: left;
margin-top: 25px;
margin-bottom: 35px;
text-align: center;
width: 100%;
font-size: 12px;
zoom: 90%;
}
.wp_china_yes-section {
margin: 50px auto;
max-width: 1000px;
background-color: #f1f1f1;
}
.wp_china_yes-field {
position: relative;
border: 0px solid #ccd0d4;
}
.wp_china_yes-field+.wp_china_yes-field {
border-top: 0px solid #eee;
}
.wp_china_yes-field-fieldset .wp_china_yes-fieldset-content {
border: 0px solid #ccd0d4;
}
.wp_china_yes-section-title {
padding: 20px 30px;
background-color: #fff;
border-top: 0 solid #f5f5f5;
border-bottom: 1px solid #f5f5f5;
border-bottom: 0px solid #eee;
box-shadow: 0 0 0 1px #ccd0d4, 0 1px 1px 1px rgba(0, 0, 0, .04);
}
.wp_china_yes-section-title h3 {
font-size: 14px;
font-weight: 400;
}
.wp_china_yes-section-title .wp_china_yes-section-icon {
margin-right: 10px;
width: 20px;
height: 24px;
line-height: 20px;
font-size: 20px;
text-align: center;
display: inline-block;
vertical-align: middle;
}
.wp_china_yes-field-subheading {
@ -63,14 +171,18 @@
background: #ffffff;
}
.wp_china_yes-theme-light .wp_china_yes-nav-background {
background-color: #ffffff;
border-right: 1px solid #f5f5f5;
border-right: 1px solid #dddddd;
flex-direction: column;
min-height: 100vh;
}
.wp_china_yes-theme-light .wp_china_yes-footer {
border-top: 1px solid #fff;
background: #ffffff;
display: none;
}
.wp_china_yes-field-heading {
@ -78,24 +190,71 @@
background-color: #ffffff;
}
.wp_china_yes-nav-normal {
width: 205px;
padding-left: 20px;
}
.wp_china_yes-nav {
padding: 20px;
}
.wp_china_yes-nav-background {
width: 250px;
}
.wp_china_yes-nav ul li a {
font-size: 13px;
position: relative;
display: block;
padding: 10px 15px;
margin: 5px;
text-decoration: none;
transition-property: color, background;
transition-duration: .2s;
transition-timing-function: ease;
}
.wp_china_yes-nav .wp_china_yes-tab-icon {
margin-right: 10px;
width: 20px;
height: 24px;
line-height: 20px;
font-size: 20px;
text-align: center;
display: inline-block;
vertical-align: middle;
}
.wp_china_yes-theme-light .wp_china_yes-nav ul li a {
background-color: #ffffff;
}
.wp_china_yes-theme-light .wp_china_yes-nav ul li a:hover {
color: #3858e9;
background-color: #f1f1f1;
}
.wp_china_yes-submessage-normal {
border-color: #ffffff;
background-color: #ffffff;
}
.wp_china_yes-field + .wp_china_yes-field {
border-top: 1px solid #ffffff;
.wp_china_yes-nav-normal+.wp_china_yes-content {
margin-left: 248px;
}
.wp_china_yes-search-all .wp_china_yes-content, .wp_china_yes-show-all .wp_china_yes-content {
margin-left: 0;
}
.wp_china_yes-theme-light .wp_china_yes-nav-normal > ul li a {
border-bottom: 1px solid #f5f5f5;
border-right: 1px solid #f5f5f5;
border-bottom: 0px solid #f5f5f5;
border-right: 0px solid #f5f5f5;
}
.wp_china_yes-theme-light .wp_china_yes-nav ul li .wp_china_yes-active {
color: #111;
background-color: #f5f5f7;
background: #f5f5f7;
}
.wp_china_yes-field-group .wp_china_yes-cloneable-header-icon {
font-size: 10px;
}
@ -116,28 +275,37 @@
.wp_china_yes-field-group .wp_china_yes-cloneable-title {
border: 1px solid #ccd0d4;
background-color: #ffffff;
border-radius: 8px;
border-radius: 1px;
}
.wp_china_yes-field-group .wp_china_yes-cloneable-content {
border: 0 solid #ffffff;
background-color: #ffffff;
padding: 0;
border-top: 1px solid #ffffff;
}
.wp_china_yes-field-group .wp_china_yes-cloneable-content>.wp_china_yes-field {
padding: 15px;
margin: 20px;
}
.wp_china_yes-sticky .wp_china_yes-header-inner {
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, .1);
border-bottom: 1px solid #dddddd;
background: #ffffff;
}
.wp_china_yes-sticky .wp_china_yes-header-inner {
position: fixed;
box-shadow: unset;
}
.wp_china_yes-warning-primary {
color: #fff !important;
border-color: #2c3338 !important;
background: #2c3338 !important;
color: #5e77ec !important;
border-color: #5e77ec !important;
background: #ffffff !important;
}
.wp_china_yes-warning-primary:focus, .wp_china_yes-warning-primary:hover {
border-color: #1d2327 !important;
background: #1d2327 !important;
border-color: #3858e9 !important;
background: #ffffff !important;
}
.wp_china_yes-field-switcher .wp_china_yes--switcher:not(.wp_china_yes--active) {
@ -148,3 +316,139 @@
margin-right: -2px;
margin-bottom: -1px;
}
@media screen and (max-width: 600px) {
.wpcy-about__grid {
grid-template-columns: 1fr!important;
}
}
span.wpcy-icon-inner {
line-height: 1px;
font-size: 28px;
color: #000000;
}
span.wpcy-icon-inner-list {
line-height: 0px;
font-size: 24px;
color: #000000;
}
.wpcy-about__grid {
margin: 24px auto;
display: grid;
grid-gap: 24px;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.wpcy-kit__grid {
margin: 24px auto;
display: grid;
grid-gap: 24px;
grid-template-columns: repeat(1, minmax(0, 1fr));
}
.column.wpcy-kit-banner {
padding: 6% 6% 3%!important;
}
.wpcy-about__grid .column {
padding: 10%;
background-color: #ffffff;
border-radius: 1px;
box-shadow: 0 0 0 1px #ccd0d4, 0 1px 1px 1px rgba(0, 0, 0, .04);
display: flex;
flex-direction: column;
align-items: flex-start;
}
.wpcy-about__grid.columns-1 {
grid-template-columns: repeat(1, minmax(0, 1fr));
}
.wpcy-about__grid.columns-3 {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.wpcy-about__grid .column > svg {
width: 30px;
height: 30px;
margin-left: -3px;
}
.wpcy-buttons {
margin-top: 4px;
margin-bottom: 32px;
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.wpcy-banner img {
max-width: 100%;
width: 100%;
height: auto;
margin-top: auto;
vertical-align: middle;
}
.components-button.has-icon {
justify-content: center;
min-width: 36px;
padding: 6px;
}
.components-button.has-icon.has-text {
gap: 4px;
justify-content: start;
padding-left: 8px;
padding-right: 12px;
}
.wpcy-about__list li a:not(:hover) {
text-decoration: none;
}
.components-button {
align-items: center;
-webkit-appearance: none;
background: none;
border: 0;
border-radius: 2px;
box-sizing: border-box;
color: var(--wp-components-color-foreground, #1e1e1e);
cursor: pointer;
display: inline-flex
;
font-family: inherit;
font-size: 13px;
font-weight: 400;
height: 36px;
margin: 0;
padding: 6px 12px;
text-decoration: none;
transition: box-shadow .1s linear;
}
.components-button.button-link {
background: none;
border: 0;
border-radius: 0;
box-shadow: none;
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
height: auto;
margin: 0;
outline: none;
padding: 0;
text-align: left;
text-decoration: underline;
transition-duration: .05s;
transition-property: border, background, color;
transition-timing-function: ease-in-out;
}
.components-button.button-primary {
display: inline-flex;
padding: 6px 12px;
}
.components-button.button-secondary {
background: #0000;
display: inline-flex;
padding: 6px 12px;
}

BIN
assets/images/qr-banner.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
assets/images/website-banner.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
assets/images/wpcy-logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

33
assets/js/script.js Executable file
View file

@ -0,0 +1,33 @@
jQuery(document).ready(function($) {
$("#test-rss-feed").click(function() {
var button = $(this);
var result = $("#rss-test-result");
var feedUrl = $("#custom_rss_url").val();
if (!feedUrl) {
result.html('<span style="color: red;">请先填写 RSS 源地址</span>');
return;
}
button.prop("disabled", true);
result.html("测试中...");
$.post(ajaxurl, {
action: "test_rss_feed",
_ajax_nonce: '<?php echo wp_create_nonce("wp_china_yes_nonce"); ?>',
feed_url: feedUrl
})
.done(function(response) {
result.html(response.success ?
'<span style="color: green;">' + response.data + '</span>' :
'<span style="color: red;">' + response.data + '</span>'
);
})
.fail(function() {
result.html('<span style="color: red;">测试失败</span>');
})
.always(function() {
button.prop("disabled", false);
});
});
});

325
changelog.txt Executable file
View file

@ -0,0 +1,325 @@
IMPORTANT:
-----------------------------------------------------------------------------------------
Please be sure to read the Important Update Notes before you update:
https://wpcy.com/document/important-update-information/
We are always proactive in preventing security issues, however nobody can assume they will never come up.
This is why we highly recommend to stay up to date with each new theme version and plugins.
重要提示:
-----------------------------------------------------------------------------------------
在更新之前,请务必阅读重要更新说明:
https://wpcy.com/document/important-update-information/
我们始终致力于积极防范安全问题,但没有人能完全避免潜在风险。
因此,我们强烈建议您密切关注每个主题和插件的新版本更新,以确保安全性和功能的最佳状态。
-----------------------------------------------------------------------------------------
v3.8 - 2025-01-01
-----------------------------------------------------------------------------------------
* 文派叶子 v3.8 重大更新全新UI 设计更接近 WordPress 原生体验。
1. 替换业务域名 WP-China-Yes.com 为新域名 WPCY.COM
2. 修复 adminCDN 支持 jsDelivr 加速无效等问题;
3. 新增 Bootstrap CDN 转接至 adminCDN 加速支持;
4. 新增 Windfonts 中文排版优化:支持段首空格 2em
5. 新增 Windfonts 中文排版优化:支持文本内容对齐;
6. 新增 [脉云维护] 菜单并支持WP系统状态监控可在页脚位置显示内存、CPU用量等信息
7. 新增 [欢迎使用] 用户引导页面,更清晰的功能指导和简介。
8. 新增 [建站工具] 文派·寻鹿建站套件展示页面,内容待完善。
9. 优化 [萌芽加速] 设置,与 WordPress 程序端加速选项分离便于添加后续项目;
10. 优化 [关于插件] 页面更简约的赞助商 Logo 和贡献者名单展示。
11. 补充 changelog.txt 文本文件,跟随插件副本分发。
12. 补充 copyright.txt 版权文件,跟随插件副本分发。
-----------------------------------------------------------------------------------------
v3.7.1 - 2024-11-19
-----------------------------------------------------------------------------------------
1. 性能优化
2. 修复监控无法关闭的问题
-----------------------------------------------------------------------------------------
v3.6.5 - 2024-08-23
-----------------------------------------------------------------------------------------
1. 优化 CLI 判断
2. 回退替换钩子修改
-----------------------------------------------------------------------------------------
v3.6.4 - 2024-08-23
-----------------------------------------------------------------------------------------
1. WP-CLI 下不运行 adminCDN 部分,防止影响缓冲区。
2. 部分文案调整支持多语言。
-----------------------------------------------------------------------------------------
v3.6.3 - 2024-08-23
-----------------------------------------------------------------------------------------
1. 为自动监控功能添加开关
2. adminCDN 支持 jsDelivr 加速
3. Windfonts 支持优化模式开关
**adminCDN 的 jsd 加速默认屏蔽 gh 端点,如有主题插件作者需要使用请联系加白。**
-----------------------------------------------------------------------------------------
v3.6.2 - 2024-03-09
-----------------------------------------------------------------------------------------
1. UI 重构
2. 修复市场加速导致 Beta 测试插件失效的问题
3. 更新接口及测试 URL
-----------------------------------------------------------------------------------------
v3.6.1 - 2024-03-08
-----------------------------------------------------------------------------------------
1. 重构全部代码
2. 应用市场调整为[文派开源](https://wenpai.org)
3. 加速服务调整为[萌芽加速](https://admincdn.com)
4. 头像调整为[初认头像](https://cravatar.com)
5. 支持自动检测节点可用性
-----------------------------------------------------------------------------------------
发展历史
-----------------------------------------------------------------------------------------
- 2019 年 2022 年 @薇晓朵 为 WP 中文本地化项目提供各项赞助支持,期间陆续数十万的资金。
- 2022 年起至 2023 年 3 月,原有 LitePress 及 WP 中文本土化社区项目进入维护状态,不再活跃;
- 2023 年 3 月由 @薇晓朵Weixiaoduo.com联系原项目团队咨询相关发展情况得知已无继续开发此项目的意向。
- 此时文派开源WenPai.org项目也处于筹备启动基础设施建设阶段。
-----------------------------------------------------------------------------------------
项目重启
-----------------------------------------------------------------------------------------
- 了解到此项目实际情况并商议后文派广州科技有限公司决定收购此项目并启动旗下————文派开源WenPai.org
- 2023 年 4 月 10 日文派科技公布收购 LitePress 社区声明 https://wpcy.com/news/acquisition-announcement
- 2023 年 4 月 25 日 WP-China-Yes 发布中文品牌词——“文派叶子”,寓意生生不息。
- 2023 年 5 月 LitePress 、Cravatar 、WP-China-Yes 等项目重启,进入正式交接重启开发阶段。
-----------------------------------------------------------------------------------------
投资机构:汉中菲比斯网络技术有限公司
-----------------------------------------------------------------------------------------
投资项目文派WordPress中国生态基础设施建设、文派开源中国本土化 WordPress 发行版及社区建设。
投资金额:一百万人民币(一期)
基础资源:三百个 WP 行业属性稀缺域名资源,以及 “文派” 品牌、商标、软著、专利等知识产权。
-----------------------------------------------------------------------------------------
委托机构:文派(广州)科技有限公司
-----------------------------------------------------------------------------------------
技术支持:薇晓朵团队 - Weixiaoduo.com
营销支持:莫蒂奇团队 - Modiqi.com
-----------------------------------------------------------------------------------------
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooooo&&B&oooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooo#B&oo&#B#ooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooBG&o#BBB&oooooooooooooooooooooooooooooooooooooooooo
ooooooooooooooooooooooooooooooooo#BGGBG#&ooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooo#BGGGGGG&ooooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooo&&#GGGGGB&oooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooBGGGGGGGB##&&&&&#####&&oooooooooooooooooooooooooooooo
ooooooooooooooooooooooooooooooooo&GGGGGGGGGGGGGGGGGGGGGGBB#ooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooo#GGGGGGGGGGGGGGGGGGGGGG&#ooooooooooooooooooooooooooo
ooooooooooooooooooooooooooooooooooo#GGGGGGGGGGGGGGGGGGGG#ooooooooooooooooooooooooooooo
ooooooooooooooooooooooooooooooooooooo#BGGGGGGGBB##&BGGGGB&oooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooGGG&ooooooooo#GGBBGB&oooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooo#GBGooooooooooo&GBooG#oooooooooooooooooooooooooo
ooooooooooooooooooooooooooooooooooooooooG#oooooooooooB#ooo##oooooooooooooooooooooooooo
ooooooooooooooooooooooooooooooooooooooo#G#ooooooooooo&G&oo##oooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooB#&&oooooooooB#oooo##oooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooooooooooooooo#&oooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooo##———— www.feibisi.com ————##ooooooooooooooooooooooooooooooo
ooooooooooooooooooooooooooo####菲比斯 · 品味简单生活####ooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
ooooooooooo此项目于 2023 年 4 月重启由菲比斯公司提供了初始一百万启动投资。ooooooooooo
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
-----------------------------------------------------------------------------------------
2022 年 ~ 2023 年 3 月
-----------------------------------------------------------------------------------------
此项目及 LitePress 社区发展已停滞,前景不明。
-----------------------------------------------------------------------------------------
v3.5.5 - 2022-11-15 此为前团队发布最后一版。
-----------------------------------------------------------------------------------------
修复
1. 仓库源替换代码优先级过低被覆盖的问题
重构
1. 去掉 CDNJS 功能;
2. 修改 WP China 标志为 LitePress
3. 替换各种加速节点链接为 LitePress 维护的地址
-----------------------------------------------------------------------------------------
v3.5.4 - 2024-03-08
-----------------------------------------------------------------------------------------
特性
1. CDNJS加速功能
-----------------------------------------------------------------------------------------
v3.5.3 - 2024-03-08
-----------------------------------------------------------------------------------------
修复
1. 核心功能无法在 Cron 环境中运行的问题
-----------------------------------------------------------------------------------------
v3.5.2 - 2024-03-08
-----------------------------------------------------------------------------------------
修复
1. 留下测试代码
2. 当未拦截到 API 请求时直接返回 WordPress 到底是什么响应值,而不是 false该问题会导致其他插件无法调用 pre_http_request 过滤器
-----------------------------------------------------------------------------------------
v3.5.1 - 2021-10-01
-----------------------------------------------------------------------------------------
修复
1. 不为 LitePress 替换后台资源
2. 完善Cravatar头像夺取机制
-----------------------------------------------------------------------------------------
v3.5.0 - 2021-09-05
-----------------------------------------------------------------------------------------
特性
1. 将“本土应用市场”更改为“LitePress 应用市场”,进而对接 LitePress 翻译平台
2. “参与翻译”按钮全局生效
-----------------------------------------------------------------------------------------
v3.4.1 - 2021-08-15
-----------------------------------------------------------------------------------------
修复
1. 不为处于RC版本的WordPress替换后台静态资源
2. 替换默认头像处的Gravatar字样
3. 替换个人资料卡中的头像设置说明
-----------------------------------------------------------------------------------------
v3.4.0 - 2021-07-27
-----------------------------------------------------------------------------------------
特性
1. 将 Gravatar 头像替换方案由反代更改为 Cravatar任何开发者均可在自己的产品中集成 Cravatar 头像服务)
修复
2. 修复了某些情况下无法替换 Gravatar 头像的问题
-----------------------------------------------------------------------------------------
v3.4.0 - 2021-07-27
-----------------------------------------------------------------------------------------
1. 修复:管理后台加速功能因用户反馈问题较多,故暂时默认关闭
2. 修复后台加速功能误对处于测试状态的WordPress起作用的问题
-----------------------------------------------------------------------------------------
v3.3.1 - 2020-10-28
-----------------------------------------------------------------------------------------
1. 修复:管理后台加速功能因用户反馈问题较多,故暂时默认关闭
2. 修复后台加速功能误对处于测试状态的WordPress起作用的问题
-----------------------------------------------------------------------------------------
v3.3.0 - 2020-10-14
-----------------------------------------------------------------------------------------
1. 特性:当使用“本土应用市场”时为插件列表中的所有插件追加“翻译校准”链接
-----------------------------------------------------------------------------------------
v3.2.0 - 2020-10-07
-----------------------------------------------------------------------------------------
1. 特性:支持谷歌前端公共库加速
2. 特性:细化管理界面设置的颗粒度
-----------------------------------------------------------------------------------------
v3.1.3 - 2020-09-18
-----------------------------------------------------------------------------------------
1. 修复多站点模式下可以在子站点激活插件的BUG
2. 修复多站点模式下无法保存配置的BUG
-----------------------------------------------------------------------------------------
v3.1.2 - 2020-08-30
-----------------------------------------------------------------------------------------
1. 修复兼容WordPress多站点模式只在主控上显示设置项
2. 修复:插件更新后设置项被覆盖的问题
-----------------------------------------------------------------------------------------
v3.1.1 - 2020-08-27
-----------------------------------------------------------------------------------------
特性
1. 增加管理后台加速功能原理是将WordPress核心依赖的静态文件切换为公共资源这将极大的加快管理后台访问速度^_^
2. 增加”不接管应用市场“选项
修复
1. 对AJAX加载的场景做了较为详尽的适配节约每一点服务器资源
-----------------------------------------------------------------------------------------
v3.0.0 - 2020-08-15
-----------------------------------------------------------------------------------------
1. 使用WordPress默认组件重写设置页面
2. 增加Gravatar加速支持
3. 增加谷歌字体加速支持
4. 对接本土应用市场这个应用市场与本土翻译平台深度整合可以大家进行基于AI翻译+人工辅助调整的全量汉化支持(技术试验)
5. “仓库源-主源”更名为“官方应用市场镜像”
6. 移除“自定义源”功能
7. 移除“资源”
8. 删除仪表盘赞助商列表
-----------------------------------------------------------------------------------------
v2.1.0 - 2020-04-11
-----------------------------------------------------------------------------------------
1. 取消社区源选择功能,只保留主源和备源
2. 禁止设置页的tab
3. 在仪表盘上放置了赞助者名单展示小部件(可关闭)
-----------------------------------------------------------------------------------------
v2.0.3 - 2020-03-20
-----------------------------------------------------------------------------------------
1. 修复修改仓库源后刷新页面无法正确展示源信息的问题
-----------------------------------------------------------------------------------------
v2.0.2 - 2020-03-18
-----------------------------------------------------------------------------------------
1. RepairAPI接口编写的不规范的问题#7
-----------------------------------------------------------------------------------------
v2.0.1 - 2020-03-18
-----------------------------------------------------------------------------------------
1. 修复插件无法在使用子目录部署的 WordPress 上运行的问题#6
-----------------------------------------------------------------------------------------
v2.0.0 - 2020-03-12
-----------------------------------------------------------------------------------------
从这个版本开始WP-China-是第一次拥有了图形化设置界面
1. 社区资源
2. 来源支持
-----------------------------------------------------------------------------------------
v1.0.1 - 2020-03-12
-----------------------------------------------------------------------------------------
1. 核心功能

0
composer.json Normal file → Executable file
View file

0
composer.lock generated Normal file → Executable file
View file

36
copyright.txt Executable file
View file

@ -0,0 +1,36 @@
-----------------------------------------------------------------------------------------
**Copyright © 2025 WenPai.cn (Guangzhou) Technology Co., Ltd.**
-----------------------------------------------------------------------------------------
**Compliance Terms**
Everyone is free to use WenPai open-source software.However, in China, when using WenPai software,
you must adhere to the GPL open-source license, respect the intellectual property rights of others,
and prioritize compliance with Chinese laws in case of any conflicts.
**Fork Declaration**
To ensure the long-term availability of various Wenpai (WordPress) infrastructure components,
individuals with the necessary capabilities are welcome to establish their own service sources
or fork WenPai Leaf 🍃 WP-China-Yes (WPCY) to create their own versions.
**The Only Requirement:**
While strictly adhering to the GPL license, you must respect all lawful rights of WenPai Technology,
including (but not limited to) copyrights, trademarks, patents, intellectual property, goodwill, and more.
-----------------------------------------------------------------------------------------
**版权所有 © 2025 年 文派(广州)科技有限公司**
-----------------------------------------------------------------------------------------
**合规条款**
任何人都可以自由使用文派开源软件,但在中国,当您使用文派软件时,您应在遵守 GPL 开源协议的同时,
尊重他人的知识产权,同时有违背中国法律的情况时皆以中国法律为准。
**分叉声明**
为保障各项文派 WordPress 基础设施的长久可用性,
欢迎有能力的人自建各类服务源以及分叉文派叶子🍃WPCY来制作您自己的版本
**唯一要求:**
在严格遵守 GPL 协议的前提下,尊重文派科技的各项合法权益,
包括 (不限于) 版权、商标、专利、知识产权、商誉等…

0
framework/assets/css/style-rtl.min.css vendored Normal file → Executable file
View file

0
framework/assets/css/style.min.css vendored Normal file → Executable file
View file

0
framework/assets/images/checkerboard.png Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Before After
Before After

0
framework/assets/images/wp-logo.svg Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 940 B

After

Width:  |  Height:  |  Size: 940 B

Before After
Before After

0
framework/assets/images/wp-plugin-logo.svg Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 482 B

After

Width:  |  Height:  |  Size: 482 B

Before After
Before After

0
framework/assets/js/main.min.js vendored Normal file → Executable file
View file

0
framework/assets/js/plugins.min.js vendored Normal file → Executable file
View file

0
framework/classes/abstract.class.php Normal file → Executable file
View file

27
framework/classes/admin-options.class.php Normal file → Executable file
View file

@ -497,9 +497,19 @@ if ( ! class_exists( 'WP_CHINA_YES_Options' ) ) {
echo '<div class="wp_china_yes-header'. esc_attr( $sticky_class ) .'">';
echo '<div class="wp_china_yes-header-inner">';
echo '<div class="wp_china_yes-header-left">';
echo '<h1>'. $this->args['framework_title'] .'</h1>';
echo '</div>';
echo '<div class="wp_china_yes-header-left">';
$hide_elements = !empty($this->options['hide_elements']) ? $this->options['hide_elements'] : [];
if (!in_array('hide_logo', $hide_elements)) {
$logo_url = !empty($this->options['header_logo']['url']) ? $this->options['header_logo']['url'] : plugins_url('wp-china-yes/assets/images/wpcy-logo.png');
echo '<img src="' . esc_url($logo_url) . '" alt="WPCY Logo" class="wp-china-yes-logo" style="float: left; height: 26px; vertical-align: middle; margin-right: 10px;" />';
}
if (!in_array('hide_title', $hide_elements)) {
echo '<h1>'. $this->args['framework_title'] .'</h1>';
}
if (!in_array('hide_version', $hide_elements)) {
echo '<small> &nbsp; v' . CHINA_YES_VERSION . '</small>';
}
echo '</div>';
echo '<div class="wp_china_yes-header-right">';
@ -572,6 +582,12 @@ if ( ! class_exists( 'WP_CHINA_YES_Options' ) ) {
echo '</ul>';
echo '<div class="wp_china_yes-copyright">';
echo '<p>Copyright © 2025 · WPCY.COM</p>';
echo '<p>文派叶子·生生不息</p>';
echo '</div>';
echo '</div>';
}
@ -625,8 +641,13 @@ if ( ! class_exists( 'WP_CHINA_YES_Options' ) ) {
echo '</div>';
echo '<div class="wp_china_yes-copyright">';
echo '<p>此服务由 文派开源WenPai.org 提供生态接入。</p>';
echo '</div>';
echo '<div class="clear"></div>';
echo '</div>';
echo ( $has_nav && $nav_type === 'normal' ) ? '<div class="wp_china_yes-nav-background"></div>' : '';

0
framework/classes/fields.class.php Normal file → Executable file
View file

4
framework/classes/setup.class.php Normal file → Executable file
View file

@ -577,6 +577,10 @@ if ( ! class_exists( 'WP_CHINA_YES_Setup' ) ) {
wp_enqueue_style( 'wp_china_yes-fa5-v4-shims', 'https://jsd.admincdn.com/npm/@fortawesome/fontawesome-free@5.15.4/css/v4-shims.min.css', array(), '5.15.5', 'all' );
}
// Iconsax font icon loader
wp_enqueue_style( 'wp_china_yes-iconsax', 'https://jsd.admincdn.com/npm/iconsax-font-icon@1.1.0/dist/icons.min.css', array(), '1.1.0', 'all' );
// Check for developer mode
$min = ( self::$premium && SCRIPT_DEBUG ) ? '' : '.min';

0
framework/fields/accordion/accordion.php Normal file → Executable file
View file

0
framework/fields/background/background.php Normal file → Executable file
View file

0
framework/fields/backup/backup.php Normal file → Executable file
View file

0
framework/fields/border/border.php Normal file → Executable file
View file

0
framework/fields/button_set/button_set.php Normal file → Executable file
View file

0
framework/fields/callback/callback.php Normal file → Executable file
View file

0
framework/fields/checkbox/checkbox.php Normal file → Executable file
View file

0
framework/fields/code_editor/code_editor.php Normal file → Executable file
View file

0
framework/fields/color/color.php Normal file → Executable file
View file

0
framework/fields/color_group/color_group.php Normal file → Executable file
View file

0
framework/fields/content/content.php Normal file → Executable file
View file

0
framework/fields/date/date.php Normal file → Executable file
View file

0
framework/fields/datetime/datetime.php Normal file → Executable file
View file

0
framework/fields/dimensions/dimensions.php Normal file → Executable file
View file

0
framework/fields/fieldset/fieldset.php Normal file → Executable file
View file

0
framework/fields/gallery/gallery.php Normal file → Executable file
View file

0
framework/fields/group/group.php Normal file → Executable file
View file

0
framework/fields/heading/heading.php Normal file → Executable file
View file

0
framework/fields/icon/fa4-icons.php Normal file → Executable file
View file

0
framework/fields/icon/fa5-icons.php Normal file → Executable file
View file

0
framework/fields/icon/icon.php Normal file → Executable file
View file

File diff suppressed because one or more lines are too long

0
framework/fields/image_select/image_select.php Normal file → Executable file
View file

0
framework/fields/index.php Normal file → Executable file
View file

0
framework/fields/link/link.php Normal file → Executable file
View file

0
framework/fields/link_color/link_color.php Normal file → Executable file
View file

0
framework/fields/map/map.php Normal file → Executable file
View file

0
framework/fields/media/media.php Normal file → Executable file
View file

0
framework/fields/notice/notice.php Normal file → Executable file
View file

0
framework/fields/number/number.php Normal file → Executable file
View file

0
framework/fields/palette/palette.php Normal file → Executable file
View file

0
framework/fields/radio/radio.php Normal file → Executable file
View file

0
framework/fields/repeater/repeater.php Normal file → Executable file
View file

0
framework/fields/select/select.php Normal file → Executable file
View file

0
framework/fields/slider/slider.php Normal file → Executable file
View file

0
framework/fields/sortable/sortable.php Normal file → Executable file
View file

0
framework/fields/sorter/sorter.php Normal file → Executable file
View file

0
framework/fields/spacing/spacing.php Normal file → Executable file
View file

0
framework/fields/spinner/spinner.php Normal file → Executable file
View file

0
framework/fields/subheading/subheading.php Normal file → Executable file
View file

0
framework/fields/submessage/submessage.php Normal file → Executable file
View file

0
framework/fields/switcher/switcher.php Normal file → Executable file
View file

0
framework/fields/tabbed/tabbed.php Normal file → Executable file
View file

0
framework/fields/text/text.php Normal file → Executable file
View file

0
framework/fields/textarea/textarea.php Normal file → Executable file
View file

0
framework/fields/typography/google-fonts.php Normal file → Executable file
View file

0
framework/fields/typography/typography.php Normal file → Executable file
View file

0
framework/fields/upload/upload.php Normal file → Executable file
View file

0
framework/fields/wp_editor/wp_editor.php Normal file → Executable file
View file

0
framework/functions/actions.php Normal file → Executable file
View file

0
framework/functions/customize.php Normal file → Executable file
View file

0
framework/functions/helpers.php Normal file → Executable file
View file

0
framework/functions/sanitize.php Normal file → Executable file
View file

0
framework/functions/validate.php Normal file → Executable file
View file

0
framework/functions/walker.php Normal file → Executable file
View file

0
framework/index.php Normal file → Executable file
View file

0
framework/languages/zh_CN.mo Normal file → Executable file
View file

1344
framework/languages/zh_CN.po Normal file → Executable file

File diff suppressed because it is too large Load diff

1
helpers.php Normal file → Executable file
View file

@ -20,6 +20,7 @@ function get_settings() {
'plane' => 'off',
'plane_rule' => [],
'monitor' => true,
'memory' => true,
'hide' => false,
'custom_name' => 'WP-China-Yes',
] );

View file

@ -1,10 +1,15 @@
# WP-China-Yes
## 开源 WordPress 中国网站加速器。
文派叶子 🍃WP-China-Yes是中国 WordPress 生态基础设施软件,犹如落叶新芽,生生不息。
文派叶子 🍃WPCY.COM是中国 WordPress 生态基础设施软件犹如落叶新芽生生不息。专为解决困扰了中国互联网数十年的特色问题而存在。此为文派开源WenPai.org的一部分。
<a href="#"><img height="auto" src="https://wpcy.com/wp-content/uploads/2024/12/wpcy-home-img.png"></a>
## 简介
文派叶子 🍃WPCY.COM是一款不可多得的 WordPress 系统底层优化和生态基础设施软件。文派WordPress中国本土化项目始于 2019 年,由 文派叶子🍃WPCY 插件开启,其前身为 WP-China-Yes。
2023 年 4 月,文派科技完成对该项目的收购,并对其进行了全面的品牌重塑。
文派叶子 🍃WP-China-Yes是一款不可多得的 WordPress 系统底层优化和生态基础设施软件。项目起源于 2019 年专为解决困扰了中国互联网数十年的特色问题而存在。此为文派开源WenPai.org的一部分。
## 功能
@ -12,10 +17,18 @@
- [x] 优化 WordPress 后台加载速度
- [x] 优化 WordPress 前台加载速度
- [x] 移除后台无用请求与组件
- [x] 替换 Gravatar 头像为[初认头像](https://cravatar.com/)
- [x] 替换 Gravatar 头像为 Cravatar [初认头像](https://cravatar.com/)
- [x] 优化 谷歌字体 加载速度
- [x] 优化 谷歌前端库 加载速度
- [x] 优化 CDNJS 加载速度
- [x] 优化 Jsdelivr 加载速度
- [x] 集成 WPMirror 镜像更新源
- [x] 集成 Windfonts 中文网页 Webfonts [文风字体](https://windfonts.com)
- [x] 集成 adminCDN 前端公共库 [萌芽加速](https://admincdn.com)
- [x] 启用 飞行模式 可屏蔽外部 API 请求
- [x] 启用 节点监控 可自动切换加速节点
- [x] 启用 品牌白标 可自定义 OEM 插件品牌
## 安装
@ -33,12 +46,8 @@
## 赞助商
<a href="#"><img height="80" src="https://wp-china-yes.com/wp-content/uploads/2023/08/feibisi-logo.png"></a>
<a href="#"><img height="80" src="https://wp-china-yes.com/wp-content/uploads/2023/08/shujue-logo.png"></a>
<a href="#"><img height="80" src="https://wp-china-yes.com/wp-content/uploads/2023/08/upyun-logo.png"></a>
<a href="#"><img height="80" src="https://wp-china-yes.com/wp-content/uploads/2023/08/wenpai-logo@2X.png"></a>
<a href="#"><img height="80" src="https://wp-china-yes.com/wp-content/uploads/2023/08/wpsaas-logo.png"></a>
<a href="#"><img height="80" src="https://wp-china-yes.com/wp-content/uploads/2023/08/lingding-logo.png"></a>
<a href="#"><img height="80" src="https://wp-china-yes.com/wp-content/uploads/2023/08/weixiaoduo-logo-2020.png"></a>
<a href="#"><img height="80" src="https://wp-china-yes.com/wp-content/uploads/2023/08/modiqi-logo.png"></a>
<a href="#"><img height="80" src="https://wp-china-yes.com/wp-content/uploads/2023/08/kekechong-logo-1.png"></a>
<a href="#"><img height="auto" src="https://wpcy.com/wp-content/uploads/2024/12/20241221-122843@2x.png"></a>
---
**Copyright © 2025 · WPCY.COM , All Rights Reserved. 文派 (广州) 科技有限公司;**

Some files were not shown because too many files have changed in this diff Show more