diff --git a/Service/123-Maintenance.php b/Service/123-Maintenance.php
new file mode 100755
index 0000000..77e3be5
--- /dev/null
+++ b/Service/123-Maintenance.php
@@ -0,0 +1,169 @@
+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 = '
+
+ ';
+
+ $output = $style . sprintf(
+ '
',
+ 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' => '维护模式已启用',
+ 'href' => admin_url('admin.php?page=wp-china-yes#tab=脉云维护')
+ ]);
+ }
+}
\ No newline at end of file
diff --git a/Service/Acceleration.php b/Service/Acceleration.php
new file mode 100755
index 0000000..f2c481b
--- /dev/null
+++ b/Service/Acceleration.php
@@ -0,0 +1,256 @@
+settings = get_settings();
+ $this->init();
+ }
+
+ /**
+ * 初始化 admincdn 功能
+ */
+ private function init() {
+ if (!empty($this->settings['admincdn'])) {
+ add_action('wp_head', function () {
+ echo "\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 () {
+ ?>
+
+ 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);
+ }
+}
\ No newline at end of file
diff --git a/Service/Adblock.php b/Service/Adblock.php
new file mode 100755
index 0000000..38fb60e
--- /dev/null
+++ b/Service/Adblock.php
@@ -0,0 +1,46 @@
+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('',
+ htmlspecialchars_decode($rule['selector'])
+ );
+ }
+ }
+}
\ No newline at end of file
diff --git a/Service/Avatar.php b/Service/Avatar.php
new file mode 100755
index 0000000..f6c08a7
--- /dev/null
+++ b/Service/Avatar.php
@@ -0,0 +1,98 @@
+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 '您可以在 WeAvatar 修改您的资料图片';
+ } else {
+ return '您可以在初认头像修改您的资料图片';
+ }
+ }
+}
\ No newline at end of file
diff --git a/Service/Base.php b/Service/Base.php
index 4da50cc..2d73d43 100755
--- a/Service/Base.php
+++ b/Service/Base.php
@@ -11,18 +11,38 @@ defined( 'ABSPATH' ) || exit;
*/
class Base {
- public function __construct() {
- // 加速服务
- new Super();
- // 监控服务
- new Monitor();
- // 内存服务
- new Memory();
- // 更新服务
- 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();
+ }
+ }
}
diff --git a/Service/Comments.php b/Service/Comments.php
new file mode 100755
index 0000000..e69de29
diff --git a/Service/Database.php b/Service/Database.php
new file mode 100755
index 0000000..f527338
--- /dev/null
+++ b/Service/Database.php
@@ -0,0 +1,92 @@
+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'] );
+ }
+ }
+}
diff --git a/Service/Fonts.php b/Service/Fonts.php
new file mode 100755
index 0000000..4c310d2
--- /dev/null
+++ b/Service/Fonts.php
@@ -0,0 +1,131 @@
+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;
+
+ $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
+ ,
+ $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 '';
+ });
+ }
+
+ // 支持中文排版两端对齐
+ if (in_array('align', (array) $this->settings['windfonts_typography'])) {
+ add_action('wp_head', function () {
+ if (is_single()) { // 仅在文章页面生效
+ echo '';
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/Service/Mail.php b/Service/Mail.php
new file mode 100755
index 0000000..e69de29
diff --git a/Service/Maintenance.php b/Service/Maintenance.php
new file mode 100755
index 0000000..996cacf
--- /dev/null
+++ b/Service/Maintenance.php
@@ -0,0 +1,136 @@
+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 '';
+ }
+ }
+
+ 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(
+ ' %s',
+ 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(
+ ' %s',
+ 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(
+ ' %s',
+ 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(
+ ' 磁盘用量:%s / %s',
+ size_format($disk_info['used']),
+ size_format($disk_info['total'])
+ );
+ }
+
+ if (in_array('disk_limit', $display_options)) {
+ $items['disk_free'] = sprintf(
+ ' 剩余空间:%s (%s%%)',
+ 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(
+ ' 上次登录:%s',
+ $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());
+ }
+}
\ No newline at end of file
diff --git a/Service/Media.php b/Service/Media.php
new file mode 100755
index 0000000..e69de29
diff --git a/Service/Memory.php b/Service/Memory.php
index 23a1115..881d379 100755
--- a/Service/Memory.php
+++ b/Service/Memory.php
@@ -45,10 +45,6 @@ class Memory {
// 转换为更直观的名称
switch (strtolower($os)) {
case 'linux':
- if (file_exists('/etc/os-release')) {
- $content = parse_ini_file('/etc/os-release');
- return $content['PRETTY_NAME'] ?? 'Linux';
- }
return 'Linux';
case 'darwin':
return 'macOS';
@@ -152,8 +148,18 @@ class Memory {
*/
public function add_footer($content) {
$settings = get_settings();
- // 确保 memory_display 是数组,如果不是则使用空数组
- $display_options = is_array($settings['memory_display'] ?? []) ? $settings['memory_display'] : [];
+
+ // 设置默认显示选项
+ $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'])) {
@@ -165,6 +171,7 @@ public function add_footer($content) {
$this->os_info = $this->get_os_info();
$footer_parts = [];
+
// 内存使用量
if (in_array('memory_usage', $display_options)) {
@@ -251,4 +258,16 @@ public function add_footer($content) {
);
}
}
+
+
+ /**
+ * 更新设置
+ */
+ private function update_settings() {
+ if ( is_multisite() ) {
+ update_site_option( 'wp_china_yes', $this->settings );
+ } else {
+ update_option( 'wp_china_yes', $this->settings, true );
+ }
+ }
}
diff --git a/Service/Monitor.php b/Service/Monitor.php
index c6d3b44..4f234cc 100755
--- a/Service/Monitor.php
+++ b/Service/Monitor.php
@@ -1,171 +1,172 @@
-settings = get_settings();
- wp_clear_scheduled_hook( 'wp_china_yes_maybe_check_store' ); // TODO 下个版本移除
- wp_clear_scheduled_hook( 'wp_china_yes_maybe_check_cravatar' ); // TODO 下个版本移除
- wp_clear_scheduled_hook( 'wp_china_yes_maybe_check_admincdn' ); // TODO 下个版本移除
- if ( $this->settings['monitor'] ) {
- // 站点网络下只在主站运行
- if ( is_main_site() ) {
- add_action( 'init', [ $this, 'init' ] );
- add_action( 'wp_china_yes_monitor', [
- $this,
- 'run_monitor'
- ] );
- }
- } else {
- wp_clear_scheduled_hook( 'wp_china_yes_monitor' );
- }
- }
-
- /**
- * 初始化
- */
- public function init() {
- if ( ! wp_next_scheduled( 'wp_china_yes_monitor' ) ) {
- wp_schedule_event( time(), 'hourly', 'wp_china_yes_monitor' );
- }
- }
-
- /**
- * 运行监控
- */
- public function run_monitor() {
- if ( $this->settings['store'] != 'off' ) {
- $this->maybe_check_store();
- }
- if ( $this->settings['cravatar'] != 'off' ) {
- $this->maybe_check_cravatar();
- }
- if ( ! empty( $this->settings['admincdn'] ) ) {
- $this->maybe_check_admincdn();
- }
- }
-
- /**
- * 检查应用市场可用性
- */
- public function maybe_check_store() {
- $test_url = 'https://api.wenpai.net/china-yes/version-check';
- if ( $this->settings['store'] == 'proxy' ) {
- $test_url = 'https://api.wpmirror.com/core/version-check/1.7/';
- }
- $response = wp_remote_get( $test_url );
- if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- if ( $this->settings['store'] == 'wenpai' ) {
- $this->settings['store'] = 'proxy';
- } elseif ( $this->settings['store'] == 'proxy' ) {
- $this->settings['store'] = 'off';
- }
- $this->update_settings();
- }
- }
-
- /**
- * 检查初认头像可用性
- */
- public function maybe_check_cravatar() {
- $test_url = 'https://cn.cravatar.com/avatar/';
- switch ( $this->settings['cravatar'] ) {
- case 'global':
- $test_url = 'https://en.cravatar.com/avatar/';
- break;
- case 'weavatar':
- $test_url = 'https://weavatar.com/avatar/';
- break;
- }
- $response = wp_remote_get( $test_url );
- if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- if ( $this->settings['cravatar'] == 'cn' ) {
- $this->settings['cravatar'] = 'global';
- } elseif ( $this->settings['cravatar'] == 'global' ) {
- $this->settings['cravatar'] = 'weavatar';
- } elseif ( $this->settings['cravatar'] == 'weavatar' ) {
- $this->settings['cravatar'] = 'cn';
- }
- $this->update_settings();
- }
- }
-
- /**
- * 检查萌芽加速可用性
- */
- public function maybe_check_admincdn() {
- // 后台加速
- if ( in_array( 'admin', $this->settings['admincdn'] ) ) {
- $response = wp_remote_get( 'https://wpstatic.admincdn.com/6.7/wp-includes/js/wp-sanitize.min.js' );
- if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'admin' ] ) );
- $this->update_settings();
- }
- }
- // 前台加速
- if ( in_array( 'frontend', $this->settings['admincdn'] ) ) {
- $url = network_site_url( '/wp-includes/js/wp-sanitize.min.js' );
- $response = wp_remote_get( 'https://public.admincdn.com/' . $url );
- if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'frontend' ] ) );
- $this->update_settings();
- }
- }
- // Google 字体
- if ( in_array( 'googlefonts', $this->settings['admincdn'] ) ) {
- $response = wp_remote_get( 'https://googlefonts.admincdn.com/css?family=Roboto:400,700' );
- if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'googlefonts' ] ) );
- $this->update_settings();
- }
- }
- // Google 前端公共库
- if ( in_array( 'googleajax', $this->settings['admincdn'] ) ) {
- $response = wp_remote_get( 'https://googleajax.admincdn.com/ajax/libs/jquery/3.7.1/jquery.slim.min.js' );
- if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'googleajax' ] ) );
- $this->update_settings();
- }
- }
- // CDNJS 前端公共库
- if ( in_array( 'cdnjs', $this->settings['admincdn'] ) ) {
- $response = wp_remote_get( 'https://cdnjs.admincdn.com/jquery/3.7.1/jquery.slim.min.js' );
- if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'cdnjs' ] ) );
- $this->update_settings();
- }
- }
- // jsDelivr 公共库
- if ( in_array( 'jsdelivr', $this->settings['admincdn'] ) ) {
- $response = wp_remote_get( 'https://jsd.admincdn.com/npm/jquery@3.7.1/dist/jquery.slim.min.js' );
- if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'jsdelivr' ] ) );
- $this->update_settings();
- }
- }
- }
-
- /**
- * 更新设置
- */
- private function update_settings() {
- if ( is_multisite() ) {
- update_site_option( 'wp_china_yes', $this->settings );
- } else {
- update_option( 'wp_china_yes', $this->settings, true );
- }
- }
-}
+settings = get_settings();
+ wp_clear_scheduled_hook( 'wp_china_yes_maybe_check_store' ); // TODO 下个版本移除
+ wp_clear_scheduled_hook( 'wp_china_yes_maybe_check_cravatar' ); // TODO 下个版本移除
+ wp_clear_scheduled_hook( 'wp_china_yes_maybe_check_admincdn' ); // TODO 下个版本移除
+ if ( $this->settings['monitor'] ) {
+ // 站点网络下只在主站运行
+ if ( is_main_site() ) {
+ add_action( 'init', [ $this, 'init' ] );
+ add_action( 'wp_china_yes_monitor', [
+ $this,
+ 'run_monitor'
+ ] );
+ }
+ } else {
+ wp_clear_scheduled_hook( 'wp_china_yes_monitor' );
+ }
+}
+
+ /**
+ * 初始化
+ */
+ public function init() {
+ if ( ! wp_next_scheduled( 'wp_china_yes_monitor' ) ) {
+ wp_schedule_event( time(), 'hourly', 'wp_china_yes_monitor' );
+ }
+ }
+
+ /**
+ * 运行监控
+ */
+ public function run_monitor() {
+ if ( $this->settings['store'] != 'off' ) {
+ $this->maybe_check_store();
+ }
+ if ( $this->settings['cravatar'] != 'off' ) {
+ $this->maybe_check_cravatar();
+ }
+ if ( ! empty( $this->settings['admincdn'] ) ) {
+ $this->maybe_check_admincdn();
+ }
+ }
+
+ /**
+ * 检查应用市场可用性
+ */
+ public function maybe_check_store() {
+ $test_url = 'https://api.wenpai.net/china-yes/version-check';
+ if ( $this->settings['store'] == 'proxy' ) {
+ $test_url = 'https://api.wpmirror.com/core/version-check/1.7/';
+ }
+ $response = wp_remote_get( $test_url );
+ if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
+ if ( $this->settings['store'] == 'wenpai' ) {
+ $this->settings['store'] = 'proxy';
+ } elseif ( $this->settings['store'] == 'proxy' ) {
+ $this->settings['store'] = 'off';
+ }
+ $this->update_settings();
+ }
+ }
+
+ /**
+ * 检查初认头像可用性
+ */
+ public function maybe_check_cravatar() {
+ $test_url = 'https://cn.cravatar.com/avatar/';
+ switch ( $this->settings['cravatar'] ) {
+ case 'global':
+ $test_url = 'https://en.cravatar.com/avatar/';
+ break;
+ case 'weavatar':
+ $test_url = 'https://weavatar.com/avatar/';
+ break;
+ }
+ $response = wp_remote_get( $test_url );
+ if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
+ if ( $this->settings['cravatar'] == 'cn' ) {
+ $this->settings['cravatar'] = 'global';
+ } elseif ( $this->settings['cravatar'] == 'global' ) {
+ $this->settings['cravatar'] = 'weavatar';
+ } elseif ( $this->settings['cravatar'] == 'weavatar' ) {
+ $this->settings['cravatar'] = 'cn';
+ }
+ $this->update_settings();
+ }
+ }
+
+ /**
+ * 检查萌芽加速可用性
+ */
+ public function maybe_check_admincdn() {
+ // 后台加速
+ if ( in_array( 'admin', $this->settings['admincdn'] ) ) {
+ $response = wp_remote_get( 'https://wpstatic.admincdn.com/6.7/wp-includes/js/wp-sanitize.min.js' );
+ if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
+ $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'admin' ] ) );
+ $this->update_settings();
+ }
+ }
+ // 前台加速
+ if ( in_array( 'frontend', $this->settings['admincdn'] ) ) {
+ $url = network_site_url( '/wp-includes/js/wp-sanitize.min.js' );
+ $response = wp_remote_get( 'https://public.admincdn.com/' . $url );
+ if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
+ $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'frontend' ] ) );
+ $this->update_settings();
+ }
+ }
+ // Google 字体
+ if ( in_array( 'googlefonts', $this->settings['admincdn'] ) ) {
+ $response = wp_remote_get( 'https://googlefonts.admincdn.com/css?family=Roboto:400,700' );
+ if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
+ $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'googlefonts' ] ) );
+ $this->update_settings();
+ }
+ }
+ // Google 前端公共库
+ if ( in_array( 'googleajax', $this->settings['admincdn'] ) ) {
+ $response = wp_remote_get( 'https://googleajax.admincdn.com/ajax/libs/jquery/3.7.1/jquery.slim.min.js' );
+ if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
+ $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'googleajax' ] ) );
+ $this->update_settings();
+ }
+ }
+ // CDNJS 前端公共库
+ if ( in_array( 'cdnjs', $this->settings['admincdn'] ) ) {
+ $response = wp_remote_get( 'https://cdnjs.admincdn.com/jquery/3.7.1/jquery.slim.min.js' );
+ if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
+ $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'cdnjs' ] ) );
+ $this->update_settings();
+ }
+ }
+ // jsDelivr 公共库
+ if ( in_array( 'jsdelivr', $this->settings['admincdn'] ) ) {
+ $response = wp_remote_get( 'https://jsd.admincdn.com/npm/jquery@3.7.1/dist/jquery.slim.min.js' );
+ if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
+ $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'jsdelivr' ] ) );
+ $this->update_settings();
+ }
+ }
+ }
+
+
+ /**
+ * 更新设置
+ */
+ private function update_settings() {
+ if ( is_multisite() ) {
+ update_site_option( 'wp_china_yes', $this->settings );
+ } else {
+ update_option( 'wp_china_yes', $this->settings, true );
+ }
+ }
+}
diff --git a/Service/Performance.php b/Service/Performance.php
new file mode 100755
index 0000000..a4abe2d
--- /dev/null
+++ b/Service/Performance.php
@@ -0,0 +1,2 @@
+prefix, [
- 'framework_title' => sprintf( '%s v%s', $this->settings['custom_name'], CHINA_YES_VERSION ),
+ 'framework_title' => $this->settings['custom_name'],
'menu_hidden' => $this->settings['hide'],
'menu_title' => $this->settings['custom_name'],
'menu_slug' => 'wp-china-yes',
@@ -59,24 +59,31 @@ private function get_settings_page_url() {
'async_webfont' => true,
'database' => is_multisite() ? 'network' : '',
] );
-
+
+ // 获取启用的 sections
+ $enabled_sections = $this->settings['enabled_sections'] ?? ['welcome', 'store', 'admincdn', 'cravatar', 'other', 'about'];
+
+ if (in_array('welcome', $enabled_sections)) {
+ $settings_page_url = $this->get_settings_page_url();
+ ob_start();
+ include CHINA_YES_PLUGIN_PATH . 'templates/welcome-section.php';
+ $welcome_content = ob_get_clean();
+
WP_CHINA_YES::createSection( $this->prefix, [
'title' => '欢迎使用',
'icon' => 'icon icon-home-1',
'fields' => [
[
'type' => 'content',
- 'content' =>
- << 原生体验
文派叶子🍃(WP-China-Yes)是一款不可多得的 WordPress 系统底层优化和生态基础设施软件。

特色功能
* 100% 兼容 WP 程序及分支发行版本,更多优秀插件待您体验。
网站加速
优化加速插件多如牛毛,为何文派叶子如此与众不同?
进一步了解 ↗ 翻译推送
高质量翻译中文本地化翻译由文派开源官方提供,欢迎参与改进。
本地化改进 ↗ 加入我们
关注文派茶馆 WPTEA.com 公众号以及订阅我们的时事通讯即可接收独家内容、提示和更新。

-HTML,
+ 'content' =>$welcome_content,
]
],
] );
-
+ }
+ if (in_array('store', $enabled_sections)) {
WP_CHINA_YES::createSection( $this->prefix, [
- 'title' => '加速设置',
- 'icon' => 'icon icon-flash-1',
+ 'title' => '应用市场',
+ 'icon' => 'icon icon-shop',
'fields' => [
[
'id' => 'store',
@@ -94,41 +101,108 @@ HTML,
'wp-china-yes' ),
],
[
- 'id' => 'admincdn',
- 'type' => 'checkbox',
- 'title' => __( '萌芽加速', 'wp-china-yes' ),
- 'inline' => true,
- 'options' => [
- 'googlefonts' => 'Google 字体',
- 'googleajax' => 'Google 前端库',
- 'cdnjs' => 'CDNJS 前端库',
- 'jsdelivr' => 'jsDelivr 前端库',
- 'bootstrapcdn' => 'Bootstrap 前端库'
- ],
- 'default' => [
- 'admin' => 'admin',
- ],
- 'subtitle' => '是否启用萌芽加速',
- 'desc' => __( '萌芽加速(adminCDN)将 WordPress 插件依赖的静态文件切换为公共资源,解决卡顿、加载慢等问题。您可按需启用加速项目,更多细节控制和功能,请查看推荐设置。',
- 'wp-china-yes' ),
+ 'id' => 'bridge',
+ 'type' => 'switcher',
+ 'default' => true,
+ 'title' => '云桥更新',
+ 'subtitle' => '是否启用更新加速',
+ 'desc' => __( '文派云桥(wpbridge)托管更新和应用分发渠道,可解决因 WordPress 社区分裂导致的混乱、旧应用无法更新,频繁 API 请求拖慢网速等问题。',
+ 'wp-china-yes' ),
],
[
- 'id' => 'admincdn',
- 'type' => 'checkbox',
- 'title' => __( '文件加速', 'wp-china-yes' ),
- 'inline' => true,
- 'options' => [
- 'admin' => '后台加速',
- 'frontend' => '前台加速',
- ],
- 'default' => [
- 'admin' => 'admin',
- ],
- 'subtitle' => '是否启用文件加速',
- 'desc' => __( '专为 WordPress 系统内置依赖的静态资源进行加速,加快网站访问速度,如遇异常请停用对应选项。',
- 'wp-china-yes' ),
+ 'id' => 'arkpress',
+ 'type' => 'switcher',
+ 'default' => false,
+ 'title' => '联合存储库',
+ 'subtitle' => '自动监控加速节点可用性',
+ 'desc' => __( 'ArkPress.org 支持自动监控各加速节点可用性,当节点不可用时自动切换至可用节点或关闭加速,以保证您的网站正常访问',
+ 'wp-china-yes' ),
],
-
+ ],
+ ] );
+ }
+
+ if (in_array('admincdn', $enabled_sections)) {
+ WP_CHINA_YES::createSection($this->prefix, [
+ 'title' => '萌芽加速',
+ 'icon' => 'icon icon-flash-1',
+ 'fields' => [
+ [
+ 'id' => 'admincdn_public',
+ 'type' => 'checkbox',
+ 'title' => __('萌芽加速', 'wp-china-yes'),
+ 'inline' => true,
+ 'options' => [
+ 'googlefonts' => 'Google 字体',
+ 'googleajax' => 'Google 前端库',
+ 'cdnjs' => 'CDNJS 前端库',
+ 'jsdelivr' => 'jsDelivr 前端库',
+ 'bootstrapcdn' => 'Bootstrap 前端库',
+ ],
+ 'default' => [
+ 'googlefonts' => 'googlefonts',
+ 'googleajax' => '',
+ 'cdnjs' => '',
+ 'jsdelivr' => '',
+ 'bootstrapcdn' => '',
+ ],
+ 'subtitle' => '是否启用萌芽加速',
+ 'desc' => __('萌芽加速(adminCDN)将 WordPress 插件依赖的静态文件切换为公共资源,解决卡顿、加载慢等问题。您可按需启用加速项目,更多细节控制和功能,请查看推荐设置。',
+ 'wp-china-yes'),
+ ],
+ [
+ 'id' => 'admincdn_files',
+ 'type' => 'checkbox',
+ 'title' => __('文件加速', 'wp-china-yes'),
+ 'inline' => true,
+ 'options' => [
+ 'admin' => '后台加速',
+ 'frontend' => '前台加速',
+ 'emoji' => 'Emoji加速',
+ 'sworg' => '预览加速',
+ ],
+ 'default' => [
+ 'admin' => 'admin',
+ 'frontend' => '',
+ 'emoji' => 'emoji',
+ 'sworg' => '',
+ ],
+ 'subtitle' => '是否启用文件加速',
+ 'desc' => __('专为 WordPress 系统内置依赖的静态资源进行加速,加快网站访问速度,如遇异常请停用对应选项。预览加速可在不切换应用市场时加速插件目录预览截图。',
+ 'wp-china-yes'),
+ ],
+ [
+ 'id' => 'admincdn_dev',
+ 'type' => 'checkbox',
+ 'title' => __('开发加速', 'wp-china-yes'),
+ 'inline' => true,
+ 'options' => [
+ 'react' => 'React 前端库',
+ 'jquery' => 'jQuery 前端库',
+ 'vuejs' => 'Vue.js 前端库',
+ 'datatables' => 'DataTables 前端库',
+ 'tailwindcss' => 'Tailwind CSS'
+ ],
+ 'default' => [
+ 'react' => '',
+ 'jquery' => 'jquery',
+ 'vuejs' => '',
+ 'datatables' => '',
+ 'tailwindcss' => '',
+ ],
+ 'subtitle' => '是否启用文件加速',
+ 'desc' => __('部分高级 WordPress 插件主题会包含最新前端资源,可在此勾选对应的 adminCDN 子库专项加速。',
+ 'wp-china-yes'),
+ ],
+ ],
+ ]);
+}
+
+ if (in_array('cravatar', $enabled_sections)) {
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '初认头像',
+ 'icon' => 'icon icon-profile-circle',
+ 'fields' => [
[
'id' => 'cravatar',
'type' => 'radio',
@@ -147,7 +221,9 @@ HTML,
],
],
] );
-
+ }
+
+ if (in_array('windfonts', $enabled_sections)) {
WP_CHINA_YES::createSection( $this->prefix, [
'title' => '文风字体',
'icon' => 'icon icon-text',
@@ -168,28 +244,6 @@ HTML,
'desc' => __( '文风字体(Windfonts)为您的网站增添无限活力。专为中文网页设计,旨在提升用户阅读体验和视觉享受。新手使用请先查看字体使用说明。',
'wp-china-yes' ),
],
- [
- 'id' => 'windfonts_typography',
- 'type' => 'checkbox',
- 'title' => __( '排印优化', 'wp-china-yes' ),
- 'inline' => true,
- 'options' => [
- 'corner' => '直角括号',
- 'space' => '文本空格',
- 'punctuation' => '标点显示',
- 'indent' => '段首缩进',
- 'align' => '两端对齐',
- ],
- 'default' => '',
- 'subtitle' => '是否启用排印优化',
- 'desc' => __( '文风字体排印优化可提升中文网页的视觉美感,适用于正式内容的网站。',
- 'wp-china-yes' ),
- 'dependency' => [
- 'windfonts',
- 'any',
- 'on,frontend,optimize',
- ],
- ],
[
'id' => 'windfonts_list',
'type' => 'group',
@@ -271,81 +325,407 @@ HTML,
],
],
[
- 'type' => 'content',
- 'content' => '默认字体适配规则跟随插件更新,插件更新后可删除字体重新添加以获取最新适配规则',
+ 'id' => 'windfonts_typography',
+ 'type' => 'checkbox',
+ 'title' => __( '排印优化', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'corner' => '直角括号',
+ 'space' => '文本空格',
+ 'punctuation' => '标点显示',
+ 'indent' => '段首缩进',
+ 'align' => '两端对齐',
+ ],
+ 'default' => '',
+ 'subtitle' => '是否启用排印优化',
+ 'desc' => __( '文风字体排印优化可提升中文网页的视觉美感,适用于正式内容的网站。',
+ 'wp-china-yes' ),
+ ],
+ [
+ 'id' => 'windfonts_typography',
+ 'type' => 'checkbox',
+ 'title' => __( '英文美化', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'align' => '排版优化',
+ 'corner' => '去双空格',
+ 'space' => '避免孤行',
+ 'punctuation' => '避免寡行',
+ 'indent' => '中英标点',
+ ],
+ 'default' => '',
+ 'subtitle' => '是否启用英文美化',
+ 'desc' => __( 'Windfonts 英文优化可提升英文网页的视觉美感,适用于多语内容网站。',
+ 'wp-china-yes' ),
],
],
] );
+ }
+ if (in_array('motucloud', $enabled_sections)) {
WP_CHINA_YES::createSection( $this->prefix, [
- 'title' => '广告屏蔽',
- 'icon' => 'icon icon-eye-slash',
+ 'title' => '墨图云集',
+ 'icon' => 'icon icon-gallery',
'fields' => [
[
- 'id' => 'adblock',
+ 'id' => 'motucloud',
'type' => 'radio',
- 'title' => __( '广告屏蔽', 'wp-china-yes' ),
+ 'title' => __( '墨图云集', 'wp-china-yes' ),
'inline' => true,
'options' => [
- 'on' => '启用',
- 'off' => '不启用',
+ 'cn' => '默认线路',
+ 'global' => '国际线路',
+ 'weavatar' => '备用源(WeAvatar.com)',
+ 'off' => '不启用'
],
- 'default' => 'off',
- 'subtitle' => '是否启用后台广告屏蔽',
- 'desc' => __( '文派叶子🍃(WPCY)独家特色功能,让您拥有清爽整洁的 WordPress 后台,清除各类常用插件侵入式后台广告、通知及无用信息,拿回后台控制权。',
+ 'default' => 'cn',
+ 'subtitle' => '是否启用墨图云集',
+ 'desc' => __( '墨图云集(MotuCloud)Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。可自选加速线路。',
'wp-china-yes' ),
],
- [
- 'id' => 'adblock_rule',
- 'type' => 'group',
- 'title' => '规则列表',
- 'subtitle' => '使用的广告屏蔽规则列表',
- 'desc' => __( '支持添加多条广告屏蔽规则',
- 'wp-china-yes' ),
-
- 'button_title' => '添加规则',
- 'accordion_title_number' => true,
- 'dependency' => [
- 'adblock',
- 'any',
- 'on',
- ],
- 'fields' => [
- [
- 'id' => 'name',
- 'type' => 'text',
- 'title' => __( '规则名称', 'wp-china-yes' ),
- 'subtitle' => '自定义规则名称',
- 'desc' => __( '自定义规则名称,方便识别',
- 'wp-china-yes' ),
- 'default' => '默认规则',
- ],
- [
- 'id' => 'selector',
- 'type' => 'textarea',
- 'title' => __( '应用元素', 'wp-china-yes' ),
- 'subtitle' => '规则应用元素',
- 'desc' => __( '设置规则应用的广告元素(CSS 选择器)',
- 'wp-china-yes' ),
- 'default' => '.wpseo_content_wrapper #sidebar-container, .yoast_premium_upsell, #wpseo-local-seo-upsell, .yoast-settings-section-upsell, #rank_math_review_plugin_notice, #bwp-get-social, .bwp-button-paypal, #bwp-sidebar-right, .tjcc-custom-css #postbox-container-1, .settings_page_wpcustomtaxfilterinadmin #postbox-container-1, #duplicate-post-notice #newsletter-subscribe-form, div[id^="dnh-wrm"], .notice-info.dst-notice, #googleanalytics_terms_notice, .fw-brz-dismiss, div.elementor-message[data-notice_id="elementor_dev_promote"], .notice-success.wpcf7r-notice, .dc-text__block.disable__comment__alert, #ws_sidebar_pro_ad, .pa-new-feature-notice, #redux-connect-message, .frash-notice-email, .frash-notice-rate, #smush-box-pro-features, #wp-smush-bulk-smush-upsell-row, #easy-updates-manager-dashnotice, #metaslider-optin-notice, #extendifysdk_announcement, .ml-discount-ad, .mo-admin-notice, .post-smtp-donation, div[data-dismissible="notice-owa-sale-forever"], .neve-notice-upsell, #pagelayer_promo, #simple-custom-post-order-epsilon-review-notice, .sfsi_new_prmium_follw, div.fs-slug-the-events-calendar[data-id="connect_account"], .tribe-notice-event-tickets-install, div.notice[data-notice="webp-converter-for-media"], .webpLoader__popup.webpPopup, .put-dismiss-notice, .wp-mail-smtp-review-notice, #wp-mail-smtp-pro-banner, body div.promotion.fs-notice, .analytify-review-thumbnail, .analytify-review-notice, .jitm-banner.is-upgrade-premium, div[data-name*="wbcr_factory_notice_adverts"], .sui-subscription-notice, #sui-cross-sell-footer, .sui-cross-sell-modules, .forminator-rating-notice, .sui-dashboard-upsell-upsell, .anwp-post-grid__rate, .cff-settings-cta, .cff-header-upgrade-notice, .cff_notice.cff_review_notice_step_1, .cff_get_pro_highlight, .aal-install-elementor, #ws_sidebar_pro_ad, .bold-timeline-lite-feedback-notice-wrapper, #elementskit-lite-go-pro-noti2ce, #elementskit-lite-_plugin_rating_msg_used_in_day, .yarpp-review-notice, #prli_review_notice, #webdados_invoicexpress_nag, #vc_license-activation-notice, .villatheme-dashboard.updated, #njt-FileBird-review, .notice[data-dismissible="pro_release_notice"], #thwvsf_review_request_notice, .wpdeveloper-review-notice, div[data-notice_type="tinvwl-user-review"], div[data-notice_type="tinvwl-user-premium"], #sg-backup-review-wrapper, .notice-wpmet-jhanda-getgenie-cross-promo, .notice-getgenie-go-pro-noti2ce, .notice-wpmet-jhanda-Summer2023, .thwcfd-review-wrapper, .woo-permalink-manager-banner, div.notice.bundle-notice, div.notice[data-dismissible="notice-owa-upgrade-forever"], .wpsm-acc-r-review-notice, .wpsm_ac_h_i, .edac-review-notice, .notice-iworks-rate, #monterinsights-admin-menu-tooltip, .monsterinsights-floating-bar, #monterinsights-admin-menu-tooltip, .exactmetrics-floating-bar, #metform-unsupported-metform-pro-version, .lwptocRate, .wpsm-tabs-b-review-notice, .quadlayers_woocommerce-direct-checkout_notice_delay, .iworks-rate-notice, #metform-_plugin_rating_msg_used_in_day, [id^="wpmet-jhanda-"], #wpmet-stories, #ti-optml-notice-helper, .menu-icon-dashboard-notice, .catch-bells-admin-notice, .wpdt-bundles-notice, .td-admin-web-services, .cf-plugin-popup, .wpzinc-review-media-library-organizer, .oxi-image-notice',
- 'sanitize' => false,
- ],
- [
- 'id' => 'enable',
- 'type' => 'switcher',
- 'title' => __( '启用规则', 'wp-china-yes' ),
- 'subtitle' => '是否启用该规则',
- 'default' => true,
- ],
- ],
- ],
- [
- 'type' => 'content',
- 'content' => '默认规则跟随插件更新,插件更新后可删除规则重新添加以获取更多最新屏蔽规则,出现异常,请尝试先停用规则排查原因。',
- ],
],
] );
+ }
+ if (in_array('fewmail', $enabled_sections)) {
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '飞秒邮箱',
+ 'icon' => 'icon icon-sms-tracking',
+ 'fields' => [
+ [
+ 'id' => 'fewmail',
+ 'type' => 'radio',
+ 'title' => __( '飞秒邮箱', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'cn' => '默认线路',
+ 'global' => '国际线路',
+ 'weavatar' => '备用源(WeAvatar.com)',
+ 'off' => '不启用'
+ ],
+ 'default' => 'cn',
+ 'subtitle' => '是否启用飞秒邮箱',
+ 'desc' => __( '飞秒邮箱(FewMail)Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。可自选加速线路。',
+ 'wp-china-yes' ),
+ ],
+ ],
+ ] );
+ }
+
+
+ if (in_array('wordyeah', $enabled_sections)) {
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '无言会语',
+ 'icon' => 'icon icon-message-text',
+ 'fields' => [
+ [
+ 'id' => 'wordyeah',
+ 'type' => 'radio',
+ 'title' => __( '无言会语', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'cn' => '审核评论',
+ 'global' => '强化评论',
+ 'ban' => '禁用评论',
+ 'off' => '不启用'
+ ],
+ 'default' => 'cn',
+ 'subtitle' => '是否启用无言会语',
+ 'desc' => __( '无言会语(WordYeah)Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。可自选加速线路。',
+ 'wp-china-yes' ),
+ ],
+ ],
+ ] );
+ }
+
+
+ if (in_array('blocks', $enabled_sections)) {
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '笔笙区块',
+ 'icon' => 'icon icon-document-1',
+ 'fields' => [
+ [
+ 'id' => 'bisheng',
+ 'type' => 'radio',
+ 'title' => __( '笔笙区块', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'cn' => '审核评论',
+ 'global' => '强化评论',
+ 'ban' => '禁用评论',
+ 'off' => '不启用'
+ ],
+ 'default' => 'cn',
+ 'subtitle' => '是否启用笔笙区块',
+ 'desc' => __( '笔笙区块(Bisheng)Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。可自选加速线路。',
+ 'wp-china-yes' ),
+ ],
+ ],
+ ] );
+ }
+
+
+ if (in_array('deerlogin', $enabled_sections)) {
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '灯鹿用户',
+ 'icon' => 'icon icon-user-tick',
+ 'fields' => [
+ [
+ 'id' => 'deerlogin',
+ 'type' => 'radio',
+ 'title' => __( '灯鹿用户', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'cn' => '默认线路',
+ 'global' => '国际线路',
+ 'off' => '不启用'
+ ],
+ 'default' => 'cn',
+ 'subtitle' => '是否启用灯鹿用户',
+ 'desc' => __( '灯鹿用户(DeerLogin)Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。可自选加速线路。',
+ 'wp-china-yes' ),
+ ],
+ ],
+ ] );
+ }
+
+
+
+ if (in_array('waimao', $enabled_sections)) {
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '跨飞外贸',
+ 'icon' => 'icon icon-chart-success',
+ 'fields' => [
+ [
+ 'id' => 'waimao',
+ 'type' => 'radio',
+ 'title' => __( '灯鹿用户', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'cn' => '默认线路',
+ 'global' => '国际线路',
+ 'off' => '不启用'
+ ],
+ 'default' => 'cn',
+ 'subtitle' => '是否启用灯鹿用户',
+ 'desc' => __( '灯鹿用户(DeerLogin)Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。可自选加速线路。',
+ 'wp-china-yes' ),
+ ],
+ ],
+ ] );
+ }
+
+
+
+ if (in_array('woocn', $enabled_sections)) {
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => 'Woo电商',
+ 'icon' => 'icon icon-shopping-cart',
+ 'fields' => [
+ [
+ 'id' => 'woocn',
+ 'type' => 'radio',
+ 'title' => __( 'Woo电商', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'cn' => '默认线路',
+ 'global' => '国际线路',
+ 'off' => '不启用'
+ ],
+ 'default' => 'cn',
+ 'subtitle' => '是否启用灯鹿用户',
+ 'desc' => __( '灯鹿用户(DeerLogin)Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。可自选加速线路。',
+ 'wp-china-yes' ),
+ ],
+ ],
+ ] );
+ }
+
+
+
+ if (in_array('lelms', $enabled_sections)) {
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '乐尔达思',
+ 'icon' => 'icon icon-teacher',
+ 'fields' => [
+ [
+ 'id' => 'lelms',
+ 'type' => 'radio',
+ 'title' => __( '乐尔达思', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'cn' => '默认线路',
+ 'global' => '国际线路',
+ 'off' => '不启用'
+ ],
+ 'default' => 'cn',
+ 'subtitle' => '是否启用乐尔达思',
+ 'desc' => __( '乐尔达思(LeLMS)Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。可自选加速线路。',
+ 'wp-china-yes' ),
+ ],
+ ],
+ ] );
+ }
+
+
+
+ if (in_array('wapuu', $enabled_sections)) {
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '瓦普文创',
+ 'icon' => 'icon icon-ticket-discount',
+ 'fields' => [
+ [
+ 'id' => 'wapuu',
+ 'type' => 'radio',
+ 'title' => __( '瓦普文创', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'cn' => '默认线路',
+ 'global' => '国际线路',
+ 'off' => '不启用'
+ ],
+ 'default' => 'cn',
+ 'subtitle' => '是否启用瓦普文创',
+ 'desc' => __( '瓦普文创(Wapuu)Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。可自选加速线路。',
+ 'wp-china-yes' ),
+ ],
+ ],
+ ] );
+ }
+
+
+if (in_array('adblock', $enabled_sections)) {
+WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '广告拦截',
+ 'icon' => 'icon icon-eye-slash',
+ 'fields' => [
+ [
+ 'id' => 'adblock',
+ 'type' => 'radio',
+ 'title' => __( '广告拦截', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'on' => '启用',
+ 'off' => '不启用',
+ ],
+ 'default' => 'off',
+ 'subtitle' => '是否启用后台广告拦截',
+ 'desc' => __( '文派叶子🍃(WPCY.COM)独家特色功能,让您拥有清爽整洁的 WordPress 后台,清除各类常用插件侵入式后台广告、通知及无用信息,拿回后台控制权。',
+ 'wp-china-yes' ),
+ ],
+ [
+ 'id' => 'adblock_rule',
+ 'type' => 'group',
+ 'title' => '规则列表',
+ 'subtitle' => '使用的广告拦截规则列表',
+ 'desc' => __( '默认规则跟随插件更新,插件更新后可删除规则重新添加以获取更多最新拦截规则,出现异常,请尝试先停用规则排查原因。',
+ 'wp-china-yes' ),
+ 'button_title' => '添加规则',
+ 'accordion_title_number' => true,
+ 'dependency' => [
+ 'adblock',
+ 'any',
+ 'on',
+ ],
+ 'fields' => [
+ [
+ 'id' => 'name',
+ 'type' => 'text',
+ 'title' => __( '规则名称', 'wp-china-yes' ),
+ 'subtitle' => '自定义规则名称',
+ 'desc' => __( '自定义规则名称,方便识别',
+ 'wp-china-yes' ),
+ 'default' => '默认规则',
+ ],
+ [
+ 'id' => 'selector',
+ 'type' => 'textarea',
+ 'title' => __( '应用元素', 'wp-china-yes' ),
+ 'subtitle' => '规则应用元素',
+ 'desc' => __( '设置规则应用的广告元素(CSS 选择器)',
+ 'wp-china-yes' ),
+ 'default' => '.wpseo_content_wrapper',
+ 'sanitize' => false,
+ ],
+ [
+ 'id' => 'enable',
+ 'type' => 'switcher',
+ 'title' => __( '启用规则', 'wp-china-yes' ),
+ 'subtitle' => '是否启用该规则',
+ 'default' => true,
+ ],
+ ],
+ ],
+ ],
+] );
+ }
+
+
+if (in_array('notice', $enabled_sections)) {
+WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '通知管理',
+ 'icon' => 'icon icon-notification-bing',
+ 'fields' => [
+ [
+ 'id' => 'notice_block',
+ 'type' => 'radio',
+ 'title' => __('通知管理', 'wp-china-yes'),
+ 'inline' => true,
+ 'options' => [
+ 'on' => '启用',
+ 'off' => '不启用',
+ ],
+ 'default' => 'off',
+ 'subtitle' => '是否启用后台通知管理',
+ 'desc' => __('管理和控制 WordPress 后台各类通知的显示。', 'wp-china-yes'),
+ ],
+ [
+ 'id' => 'disable_all_notices',
+ 'type' => 'switcher',
+ 'title' => __('禁用所有通知', 'wp-china-yes'),
+ 'subtitle' => '一键禁用所有后台通知',
+ 'default' => false,
+ 'dependency' => ['notice_block', '==', 'on'],
+ ],
+ [
+ 'id' => 'notice_control',
+ 'type' => 'checkbox',
+ 'title' => __('选择性禁用', 'wp-china-yes'),
+ 'inline' => true,
+ 'subtitle' => '选择需要禁用的通知类型',
+ 'desc' => __('可以按住 Ctrl/Command 键进行多选', 'wp-china-yes'),
+ 'chosen' => true,
+ 'multiple' => true,
+ 'options' => [
+ 'core' => '核心更新通知',
+ 'error' => '错误通知',
+ 'warning' => '警告通知',
+ 'info' => '信息通知',
+ 'success' => '成功通知',
+ ],
+ 'dependency' => ['notice_block|disable_all_notices', '==|==', 'on|false'],
+ 'default' => [],
+ ],
+ [
+ 'id' => 'notice_method',
+ 'type' => 'radio',
+ 'title' => __('禁用方式', 'wp-china-yes'),
+ 'inline' => true,
+ 'options' => [
+ 'hook' => '移除钩子(推荐)',
+ 'css' => 'CSS隐藏',
+ 'both' => '双重保险',
+ ],
+ 'default' => 'hook',
+ 'dependency' => ['notice_block|disable_all_notices', '==|==', 'on|false'],
+ ],
+ ],
+] );
+ }
+
+
+
+ if (in_array('plane', $enabled_sections)) {
WP_CHINA_YES::createSection( $this->prefix, [
'title' => '飞行模式',
'icon' => 'icon icon-airplane',
@@ -371,7 +751,6 @@ HTML,
'subtitle' => '飞行模式使用的 URL 屏蔽规则列表',
'desc' => __( '支持添加多条 URL 屏蔽规则',
'wp-china-yes' ),
-
'button_title' => '添加规则',
'accordion_title_number' => true,
'dependency' => [
@@ -411,8 +790,9 @@ HTML,
]
],
] );
+ }
-
+if (in_array('monitor', $enabled_sections)) {
WP_CHINA_YES::createSection( $this->prefix, [
'title' => '脉云维护',
'icon' => 'icon icon-story',
@@ -431,7 +811,7 @@ WP_CHINA_YES::createSection( $this->prefix, [
'type' => 'switcher',
'default' => true,
'title' => '系统监控',
- 'subtitle' => '自动监控站点系统运行状态',
+ 'subtitle' => '自动监控系统运行状态',
'desc' => __( '支持在管理后台页脚中显示系统运行状态,包括内存使用、CPU负载、MySQL版本、调试状态等信息',
'wp-china-yes' ),
],
@@ -442,73 +822,399 @@ WP_CHINA_YES::createSection( $this->prefix, [
'inline' => true,
'options' => [
'memory_usage' => '内存使用量',
- 'wp_limit' => 'WP内存限制',
- 'server_ip' => '服务器IP',
- 'hostname' => '主机名',
+ 'wp_limit' => '内存限制',
+ 'server_ip' => '服务器 IP',
+ 'hostname' => '主机名称',
'os_info' => '操作系统',
- 'php_info' => 'PHP信息',
+ 'mysql_version'=> 'MySQL版本',
'cpu_usage' => 'CPU使用率',
'debug_status' => '调试状态',
- 'mysql_version'=> 'MySQL版本'
+ 'php_info' => 'PHP 版本'
],
'default' => [
'memory_usage',
'wp_limit',
'server_ip',
- 'os_info',
'php_info',
- 'cpu_usage',
- 'debug_status',
- 'mysql_version'
],
'subtitle' => '选择页脚要显示的信息',
'desc' => __( '为网站维护人员提供参考依据,无需登录服务器即可查看相关信息参数','wp-china-yes' ),
'dependency' => ['memory', '==', 'true'],
],
[
- 'type' => 'content',
- 'content' => '启用隐藏设置前请务必的保存或收藏当前设置页面 URL,否则您将无法再次进入插件设置页面',
+ 'id' => 'disk',
+ 'type' => 'switcher',
+ 'default' => true,
+ 'title' => '站点监控',
+ 'subtitle' => '自动监控站点运行状态',
+ 'desc' => __( '支持在管理后台页脚中显示系统运行状态,包括内存使用、CPU负载、MySQL版本、调试状态等信息',
+ 'wp-china-yes' ),
+ ],
+ [
+ 'id' => 'disk_display',
+ 'type' => 'checkbox',
+ 'title' => __( '显示参数', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'disk_usage' => '磁盘用量',
+ 'disk_limit' => '剩余空间',
+ 'media_num' => '媒体数量',
+ 'admin_num' => '管理数量',
+ 'user_num' => '用户数量',
+ 'lastlogin' => '上次登录',
+ ],
+ 'default' => [
+ 'disk_usage',
+ 'disk_limit',
+ 'media_num',
+ 'admin_num',
+ ],
+ 'subtitle' => '选择概览要显示的信息',
+ 'desc' => __( '为网站管理人员提供参考依据,进入后台仪表盘即可查看相关信息参数','wp-china-yes' ),
+ 'dependency' => ['disk', '==', 'true'],
+ ],
+[
+ 'id' => 'maintenance_mode',
+ 'type' => 'switcher',
+ 'default' => false,
+ 'title' => '启用维护模式',
+ 'subtitle' => '启用或禁用网站维护模式',
+ 'desc' => __( '启用后,网站将显示维护页面,只有管理员可以访问。', 'wp-china-yes' ),
+],
+[
+ 'id' => 'maintenance_settings',
+ 'type' => 'fieldset',
+ 'title' => '维护模式设置',
+ 'fields' => [
+ [
+ 'id' => 'maintenance_title',
+ 'type' => 'text',
+ 'title' => '页面标题',
+ 'default' => '网站维护中',
+ ],
+ [
+ 'id' => 'maintenance_heading',
+ 'type' => 'text',
+ 'title' => '主标题',
+ 'default' => '网站维护中',
+ ],
+ [
+ 'id' => 'maintenance_message',
+ 'type' => 'textarea',
+ 'title' => '维护说明',
+ 'default' => '网站正在进行例行维护,请稍后访问。感谢您的理解与支持!',
+ ],
+ ],
+ 'dependency' => ['maintenance_mode', '==', 'true'],
+]
+
+ ],
+] );
+ }
+
+ if (in_array('security', $enabled_sections)) {
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '雨滴安全',
+ 'icon' => 'icon icon-shield',
+ 'fields' => [
+ [
+ 'id' => 'yoodefender',
+ 'type' => 'radio',
+ 'title' => __( '雨滴安全', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'cn' => '默认线路',
+ 'global' => '国际线路',
+ 'off' => '不启用'
+ ],
+ 'default' => 'cn',
+ 'subtitle' => '是否启用雨滴安全',
+ 'desc' => __( '雨滴安全(YooDefender)安全设置可以帮助增强 WordPress 的安全性,请根据实际需求启用相关选项。更多选项请安装 WPBan 插件。可自选加速线路。',
+ 'wp-china-yes' ),
+ ],
+ [
+ 'id' => 'disallow_file_edit',
+ 'type' => 'switcher',
+ 'title' => __( '禁用文件编辑', 'wp-china-yes' ),
+ 'subtitle' => '禁用 WordPress 后台的主题和插件编辑器',
+ 'default' => true,
+ 'desc' => __( '启用后,用户无法通过 WordPress 后台编辑主题和插件文件。', 'wp-china-yes' ),
+ ],
+ [
+ 'id' => 'disallow_file_mods',
+ 'type' => 'switcher',
+ 'title' => __( '禁用文件修改', 'wp-china-yes' ),
+ 'subtitle' => '禁止用户安装、更新或删除主题和插件',
+ 'default' => false,
+ 'desc' => __( '启用后,用户无法通过 WordPress 后台安装、更新或删除主题和插件。', 'wp-china-yes' ),
],
],
] );
-
+ }
+ if (in_array('performance', $enabled_sections)) {
WP_CHINA_YES::createSection( $this->prefix, [
- 'title' => '品牌白标',
- 'icon' => 'icon icon-password-check',
- 'fields' => [
+ 'title' => '性能优化',
+ 'icon' => 'icon icon-speedometer',
+ 'fields' => [
+ [
+ 'id' => 'performance',
+ 'type' => 'switcher',
+ 'title' => __( '性能优化', 'wp-china-yes' ),
+ 'subtitle' => '是否启用性能优化',
+ 'default' => true,
+ 'desc' => __( '性能优化设置可以帮助提升 WordPress 的运行效率,请根据服务器配置合理调整。', 'wp-china-yes' ),
+ ],
+
+ [
+ 'id' => 'wp_memory_limit',
+ 'type' => 'text',
+ 'title' => __( '内存限制', 'wp-china-yes' ),
+ 'subtitle' => '设置 WordPress 内存限制',
+ 'default' => '40M',
+ 'desc' => __( '设置 WordPress 的内存限制,例如 64M、128M、256M 等。', 'wp-china-yes' ),
+ 'dependency' => ['performance', '==', 'true'],
+
+ ],
+ [
+ 'id' => 'wp_max_memory_limit',
+ 'type' => 'text',
+ 'title' => __( '后台内存限制', 'wp-china-yes' ),
+ 'subtitle' => '设置 WordPress 后台内存限制',
+ 'default' => '256M',
+ 'desc' => __( '设置 WordPress 后台的内存限制,例如 128M、256M、512M 等。', 'wp-china-yes' ),
+ 'dependency' => ['performance', '==', 'true'],
+
+ ],
+ [
+ 'id' => 'wp_post_revisions',
+ 'type' => 'number',
+ 'title' => __( '文章修订版本', 'wp-china-yes' ),
+ 'subtitle' => '控制文章修订版本的数量',
+ 'default' => -1, // -1 表示启用所有修订版本
+ 'desc' => __( '设置为 0 禁用修订版本,或设置为一个固定值(如 5)限制修订版本数量。', 'wp-china-yes' ),
+ 'dependency' => ['performance', '==', 'true'],
+
+ ],
+ [
+ 'id' => 'autosave_interval',
+ 'type' => 'number',
+ 'title' => __( '自动保存间隔', 'wp-china-yes' ),
+ 'subtitle' => '设置文章自动保存的时间间隔(秒)',
+ 'default' => 60,
+ 'desc' => __( '设置文章自动保存的时间间隔,默认是 60 秒。', 'wp-china-yes' ),
+ 'dependency' => ['performance', '==', 'true'],
+
+ ],
+ ],
+
+] );
+ }
+
+ if (in_array('brand', $enabled_sections)) {
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '品牌白标',
+ 'icon' => 'icon icon-password-check',
+ 'fields' => [
+ [
+ 'id' => 'custom_name',
+ 'type' => 'text',
+ 'title' => '品牌白标',
+ 'subtitle' => '自定义插件显示品牌名',
+ 'desc' => __( '专为 WordPress 建站服务商和代理机构提供的自定义品牌 OEM 功能,输入您的品牌词启用后生效', 'wp-china-yes' ),
+ 'default' => "文派叶子",
+ ],
+ [
+ 'id' => 'header_logo',
+ 'type' => 'media',
+ 'title' => '品牌 Logo',
+ 'subtitle' => '自定义插件显示品牌 Logo',
+ 'library' => 'image',
+ 'desc' => '上传或选择媒体库的图片作为品牌 Logo',
+ 'default' => ['url' => plugins_url('wp-china-yes/assets/images/wpcy-logo.png')], // 设置默认 Logo
+ ],
[
- 'id' => 'custom_name',
- 'type' => 'text',
- 'title' => '品牌白标',
- 'subtitle' => '自定义插件显示品牌名',
- 'desc' => __( '专为 WordPress 建站服务商和代理机构提供的自定义品牌 OEM 功能,输入您的品牌词启用后生效',
+ 'id' => 'hide_option',
+ 'type' => 'switcher',
+ 'default' => false,
+ 'title' => '隐藏设置',
+ 'subtitle' => '隐藏插件设置信息',
+ 'desc' => __( '如果您不希望让客户知道本站启用了文派叶子🍃(WPCY.COM)插件及服务,可开启此选项。',
'wp-china-yes' ),
- 'default' => "WP-China-Yes",
],
- [
- 'type' => 'content',
- 'content' => '启用隐藏设置前请务必的保存或收藏当前设置页面 URL,否则您将无法再次进入插件设置页面',
- ],
- ],
- ] );
-
+ [
+ 'id' => 'hide_elements',
+ 'type' => 'checkbox',
+ 'title' => '隐藏元素',
+ 'subtitle' => '选择需要隐藏的元素',
+ 'desc' => __( '注意:启用[隐藏菜单]前请务必保存或收藏当前设置页面 URL,否则将无法再次进入插件页面', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'hide_logo' => '隐藏 Logo',
+ 'hide_title' => '隐藏插件名',
+ 'hide_version' => '隐藏版本号',
+ 'hide_copyright' => '隐藏版权',
+ 'hide_menu' => '隐藏菜单',
+ ],
+ 'default' => [], // 默认不隐藏任何元素
+ 'dependency' => ['hide_option', '==', 'true'], // 只有在 hide 为 true 时显示
+ ],
+ [
+ 'id' => 'enable_custom_rss',
+ 'type' => 'switcher',
+ 'title' => '品牌新闻',
+ 'subtitle' => '是否启用定制新闻源',
+ 'desc' => '启用后,您可以自定义[文派茶馆]新闻源,输入自己的 RSS 源之后即可显示信息流。',
+ 'default' => false
+ ],
+ [
+ 'id' => 'custom_rss_url',
+ 'type' => 'text',
+ 'title' => '自定义 RSS 源',
+ 'subtitle' => '添加自定义 RSS 新闻源',
+ 'desc' => '请输入有效的 RSS Feed URL,长期无更新时会恢复显示默认新闻源。',
+ 'dependency' => ['enable_custom_rss', '==', true]
+ ],
+ [
+ 'id' => 'custom_rss_refresh',
+ 'type' => 'select',
+ 'title' => 'RSS 刷新频率',
+ 'options' => [
+ '1800' => '30分钟',
+ '3600' => '1小时',
+ '7200' => '2小时',
+ '14400' => '4小时',
+ '28800' => '8小时'
+ ],
+ 'default' => '3600',
+ 'dependency' => ['enable_custom_rss', '==', true]
+ ],
+ [
+ 'id' => 'rss_display_options',
+ 'type' => 'checkbox',
+ 'inline' => true,
+ 'title' => 'RSS 显示选项',
+ 'subtitle' => '选择需要显示的内容',
+ 'options' => [
+ 'show_date' => '显示日期',
+ 'show_summary' => '显示摘要',
+ 'show_footer' => '显示页脚',
+ ],
+ 'default' => ['show_date', 'show_summary', 'show_footer'], // 默认全部勾选
+ 'dependency' => ['enable_custom_rss', '==', true]
+ ],
+
+ ],
+]);
+ }
+
WP_CHINA_YES::createSection( $this->prefix, [
'title' => '其他设置',
'icon' => 'icon icon-setting',
'fields' => [
- [
- 'id' => 'hide',
- 'type' => 'switcher',
- 'default' => false,
- 'title' => '隐藏设置',
- 'subtitle' => '隐藏插件设置入口',
- 'desc' => __( '如果您不希望让客户知道本站启用了文派叶子🍃(WP-China-Yes)插件及服务,可开启此选项',
- 'wp-china-yes' ),
- ],
- ],
+ [
+ 'id' => 'enable_debug',
+ 'type' => 'switcher',
+ 'title' => __( '调试模式', 'wp-china-yes' ),
+ 'subtitle' => '启用或禁用调试模式',
+ 'default' => false,
+ 'desc' => __( '启用后,WordPress 将显示 PHP 错误、警告和通知。临时使用完毕后,请保持禁用此选项。', 'wp-china-yes' ),
+ ],
+ [
+ 'id' => 'debug_options',
+ 'type' => 'checkbox',
+ 'title' => __( '调试选项', 'wp-china-yes' ),
+ 'subtitle' => '选择要启用的调试功能',
+ 'dependency' => [ 'enable_debug', '==', 'true' ],
+ 'options' => [
+ 'wp_debug_log' => 'WP_DEBUG_LOG 记录日志',
+ 'wp_debug_display' => 'WP_DEBUG_DISPLAY 页面显示调试信息',
+ 'script_debug' => 'SCRIPT_DEBUG 加载未压缩的前端资源',
+ 'save_queries' => 'SAVEQUERIES 记录数据库查询 ',
+ ],
+ 'default' => [
+ 'wp_debug_log' => true,
+ ],
+ 'desc' => __( '注意:调试模式仅适用于开发和测试环境,不建议在生产环境中长时间启用。选择要启用的调试功能,适用于开发和测试环境。', 'wp-china-yes' ),
+ ],
+ [
+ 'id' => 'enable_db_tools',
+ 'type' => 'switcher',
+ 'title' => __( '数据库工具', 'wp-china-yes' ),
+ 'subtitle' => '启用或禁用数据库工具',
+ 'default' => false,
+ 'desc' => __( '启用后,您可以在下方访问数据库修复工具。定期使用完毕后,请保持禁用此选项。', 'wp-china-yes' ),
+ ],
+ [
+ 'id' => 'db_tools_link',
+ 'type' => 'content',
+ 'title' => __( '数据库修复工具', 'wp-china-yes' ),
+ 'subtitle' => '打开数据库修复工具',
+ 'dependency' => [ 'enable_db_tools', '==', 'true' ],
+ 'content' => '' . esc_html__( '打开数据库修复工具', 'wp-china-yes' ) . '',
+ ],
+[
+ 'id' => 'enable_sections',
+ 'type' => 'switcher',
+ 'title' => '高级定制',
+ 'subtitle' => '启用或禁用功能选项卡',
+ 'default' => true,
+ 'desc' => __( '启用后,您可以在下方选用文派叶子功能,特别提醒:禁用对应功能后再次启用需重新设置。', 'wp-china-yes' ),
+],
+[
+ 'id' => 'enabled_sections',
+ 'type' => 'checkbox',
+ 'title' => '功能选项卡',
+ 'subtitle' => '选择要显示的功能选项卡',
+ 'inline' => true,
+ 'options' => [
+ 'store' => '应用市场',
+ 'admincdn' => '萌芽加速',
+ 'cravatar' => '初认头像',
+ 'windfonts' => '文风字体',
+ 'motucloud' => '墨图云集',
+ 'fewmail' => '飞秒邮箱',
+ 'wordyeah' => '无言会语',
+ 'blocks' => '笔笙区块',
+ 'deerlogin' => '灯鹿用户',
+ 'waimao' => '跨飞外贸',
+ 'woocn' => 'Woo电商',
+ 'lelms' => '乐尔达思',
+ 'wapuu' => '瓦普文创',
+ 'adblock' => '广告拦截',
+ 'notice' => '通知管理',
+ 'plane' => '飞行模式',
+ 'monitor' => '脉云维护',
+ 'forums' => '赛博论坛',
+ 'monitor' => '脉云维护',
+ 'forms' => '重力表单',
+ 'panel' => '天控面板',
+ 'security' => '雨滴安全',
+ 'domain' => '蛋叮域名',
+ 'performance' => '性能优化',
+ 'brand' => '品牌白标',
+ 'sms' => '竹莺短信',
+ 'chat' => '点洽客服',
+ 'translate' => '文脉翻译',
+ 'ecosystem' => '生态系统',
+ 'deer' => '建站套件',
+ 'docs' => '帮助文档',
+ 'about' => '关于插件',
+ 'welcome' => '欢迎使用'
+ ],
+ 'default' => ['welcome', 'store', 'admincdn', 'cravatar', 'other', 'about'],
+ 'desc' => '选择要在设置页面显示的功能选项卡,未选择的选项卡将被隐藏',
+ 'dependency' => ['enable_sections', '==', 'true'],
+]
+
+ ],
] );
+ if (in_array('deer', $enabled_sections)) {
+ $settings_page_url = $this->get_settings_page_url();
+ ob_start();
+ include CHINA_YES_PLUGIN_PATH . 'templates/website-section.php';
+ $website_content = ob_get_clean();
WP_CHINA_YES::createSection( $this->prefix, [
'title' => '建站套件',
@@ -516,49 +1222,58 @@ WP_CHINA_YES::createSection( $this->prefix, [
'fields' => [
[
'type' => 'content',
- 'content' =>
- << 开源建站
文派寻鹿🦌(WP Deer)建站套件是由文派科技官方提供的企业建站产品集合,代码均为 100% GPL 开源,无任何加密隐藏。
-HTML,
+ 'content' =>$website_content,
]
],
] );
+ }
+
+
+ if (in_array('docs', $enabled_sections)) {
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '帮助文档',
+ 'icon' => 'icon icon-lifebuoy',
+ 'fields' => [
+ [
+ 'id' => 'docs',
+ 'type' => 'radio',
+ 'title' => __( '帮助文档', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'cn' => '默认线路',
+ 'global' => '国际线路',
+ 'off' => '不启用'
+ ],
+ 'default' => 'cn',
+ 'subtitle' => '是否启用灯鹿用户',
+ 'desc' => __( '灯鹿用户(DeerLogin)Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。可自选加速线路。',
+ 'wp-china-yes' ),
+ ],
+ ],
+ ] );
+ }
-
+ if (in_array('about', $enabled_sections)) {
+ $settings_page_url = $this->get_settings_page_url();
+ ob_start();
+ include CHINA_YES_PLUGIN_PATH . 'templates/about-section.php';
+ $about_content = ob_get_clean();
+
WP_CHINA_YES::createSection( $this->prefix, [
'title' => '关于插件',
'icon' => 'icon icon-info-circle',
'fields' => [
[
'type' => 'content',
- 'content' =>
- <<
-
项目简介
文派(WordPress)中国本土化项目始于 2019 年,由 文派叶子🍃(WPCY) 插件开启,其前身为 WP-China-Yes。
-
-
2023 年 5 月,文派科技完成对该项目的收购,并对其进行了全面的品牌重塑。
-
赞助支持
特别感谢以下企业品牌对文派项目提供的资金资源支持。早期伙伴未来有机会共享文派生态资源,期待社会各界参与。
开发 & 贡献者
100% 开源代码,诚邀您一起参与文派 (WordPress) 软件国产化进程,打造属于自己的开源自助建站程序。
-HTML,
+ 'content' =>$about_content,
]
],
] );
}
-
+ }
+
/**
* 加载后台资源
*/
@@ -582,6 +1297,8 @@ HTML,
return $plugins;
} );
+
+
// 插件页设置
add_filter( 'plugin_action_links', function ( $links, $file ) {
if ( 'wp-china-yes/wp-china-yes.php' !== $file ) {
@@ -595,4 +1312,4 @@ HTML,
return $links;
}, 10, 2 );
}
-}
+}
\ No newline at end of file
diff --git a/Service/Super.php b/Service/Super.php
index 7f664ca..8298bef 100755
--- a/Service/Super.php
+++ b/Service/Super.php
@@ -31,148 +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;
- } );
- } );
- 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 <<
-
-
-
+ }
+ echo <<
+ #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;
+ }
+
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();
- }
+ });
+ });
+}
/**
* 初认头像
@@ -214,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' ] );
+ }
+}
/**
* 飞行模式
@@ -223,70 +235,7 @@ 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', [
- 'cdn.jsdelivr.net',
- 'jsd.admincdn.com'
- ] );
- }
-
- /**
- * BootstrapCDN 前端公共库替换
- */
- if ( in_array( 'bootstrapcdn', (array) $this->settings['admincdn'] ) ) {
- $this->page_str_replace( 'init', 'str_replace', [
- 'maxcdn.bootstrapcdn.com',
- 'jsd.admincdn.com'
- ] );
- }
- }
/**
@@ -470,6 +419,7 @@ HTML
// 支持中文排版两端对齐
if ( in_array( 'align', (array) $this->settings['windfonts_typography'] ) ) {
add_action( 'wp_head', function () {
+ if ( is_single() ) { // 仅在文章页面生效
echo '';
+ }
} );
}
}
- /**
- * 加载广告拦截
- */
- public function load_adblock() {
- foreach ( (array) $this->settings['adblock_rule'] as $rule ) {
- if ( empty( $rule['enable'] ) ) {
- continue;
- }
- if ( empty( $rule['selector'] ) ) {
- continue;
- }
- echo sprintf( <<
- %s {
- display: none!important;
- }
-
-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( '',
+ 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 '';
+ 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 '';
+ }
+}
+
+/**
+ * 移除所有管理通知
+ */
+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');
+ }
+
+}
+
+
/**
* 加载飞行模式
diff --git a/assets/css/setting.css b/assets/css/setting.css
index f69d956..f64de46 100755
--- a/assets/css/setting.css
+++ b/assets/css/setting.css
@@ -82,7 +82,7 @@
margin-right: 0px;
}
-.wp_china_yes-field.wp_china_yes-field-radio, .wp_china_yes-field-checkbox, .wp_china_yes-field-group, .wp_china_yes-field-switcher, .wp_china_yes-field-text {
+.wp_china_yes-field {
padding: 8%;
background-color: #ffffff;
margin: 5% 0;
@@ -90,10 +90,32 @@
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;
@@ -108,9 +130,8 @@
.wp_china_yes-field+.wp_china_yes-field {
border-top: 0px solid #eee;
}
-
-.wp_china_yes-field.wp_china_yes-field-content {
- padding: 0px;
+.wp_china_yes-field-fieldset .wp_china_yes-fieldset-content {
+ border: 0px solid #ccd0d4;
}
.wp_china_yes-section-title {
diff --git a/assets/images/wpcy-logo.png b/assets/images/wpcy-logo.png
new file mode 100755
index 0000000..2f8f132
Binary files /dev/null and b/assets/images/wpcy-logo.png differ
diff --git a/assets/js/script.js b/assets/js/script.js
new file mode 100755
index 0000000..dbaad87
--- /dev/null
+++ b/assets/js/script.js
@@ -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('请先填写 RSS 源地址');
+ return;
+ }
+
+ button.prop("disabled", true);
+ result.html("测试中...");
+
+ $.post(ajaxurl, {
+ action: "test_rss_feed",
+ _ajax_nonce: '',
+ feed_url: feedUrl
+ })
+ .done(function(response) {
+ result.html(response.success ?
+ '' + response.data + '' :
+ '' + response.data + ''
+ );
+ })
+ .fail(function() {
+ result.html('测试失败');
+ })
+ .always(function() {
+ button.prop("disabled", false);
+ });
+ });
+ });
diff --git a/changelog.txt b/changelog.txt
old mode 100644
new mode 100755
diff --git a/composer.json b/composer.json
old mode 100644
new mode 100755
diff --git a/composer.lock b/composer.lock
old mode 100644
new mode 100755
diff --git a/copyright.txt b/copyright.txt
old mode 100644
new mode 100755
index 558b6d2..df51603
--- a/copyright.txt
+++ b/copyright.txt
@@ -1,28 +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 🍃 (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 协议的前提下,尊重文派科技的各项合法权益,包括 (不限于) 版权、商标、专利、知识产权、商誉等…
-
-
-
+-----------------------------------------------------------------------------------------
+**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 协议的前提下,尊重文派科技的各项合法权益,
+包括 (不限于) 版权、商标、专利、知识产权、商誉等…
+
+
+
diff --git a/framework/classes/admin-options.class.php b/framework/classes/admin-options.class.php
index 3a9cb9d..152624f 100755
--- a/framework/classes/admin-options.class.php
+++ b/framework/classes/admin-options.class.php
@@ -497,9 +497,19 @@ if ( ! class_exists( 'WP_CHINA_YES_Options' ) ) {
echo '';
echo ( $has_nav && $nav_type === 'normal' ) ? '' : '';
diff --git a/templates/about-section.php b/templates/about-section.php
new file mode 100755
index 0000000..ffbf1ed
--- /dev/null
+++ b/templates/about-section.php
@@ -0,0 +1,48 @@
+
+
+
+
+
项目简介
+
文派(WordPress)中国本土化项目始于 2019 年,由 文派叶子🍃(WPCY) 插件开启,其前身为 WP-China-Yes。
+
+
+
2023 年 4 月,文派科技完成对该项目的收购,并对其进行了全面的品牌重塑。
+
+
+
+
+
赞助支持
+
特别感谢以下企业品牌对文派项目提供的资金资源支持。早期伙伴未来有机会共享文派生态资源,期待社会各界参与。
+
+
+
+
+
+
+
开发 & 贡献者
+
100% 开源代码,诚邀您一起参与文派 (WordPress) 软件国产化进程,打造属于自己的开源自助建站程序。
+
+
+
+
+
+
diff --git a/templates/maintenance-default.php b/templates/maintenance-default.php
new file mode 100755
index 0000000..9f314bf
--- /dev/null
+++ b/templates/maintenance-default.php
@@ -0,0 +1,20 @@
+// templates/maintenance-default.php
+
+>
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/website-section.php b/templates/website-section.php
new file mode 100755
index 0000000..9b31c7f
--- /dev/null
+++ b/templates/website-section.php
@@ -0,0 +1,21 @@
+
+
+
+
+
开源建站
+
文派寻鹿🦌(WP Deer)建站套件是由文派科技官方提供的企业建站产品集合,代码均为 100% GPL 开源,无任何加密隐藏。
+
+
+
+
+
+
diff --git a/templates/welcome-section.php b/templates/welcome-section.php
new file mode 100755
index 0000000..b3f8783
--- /dev/null
+++ b/templates/welcome-section.php
@@ -0,0 +1,56 @@
+
+
+
+
+
原生体验
+
文派叶子🍃(WP-China-Yes)是一款不可多得的 WordPress 系统底层优化和生态基础设施软件。
+
+

+
+
特色功能
+
+
* 100% 兼容 WP 程序及分支发行版本,更多优秀插件待您体验。
+
+
+
+
+
网站加速
+
优化加速插件多如牛毛,为何文派叶子如此与众不同?
进一步了解 ↗
+
+
翻译推送
+
高质量翻译中文本地化翻译由文派开源官方提供,欢迎参与改进。
本地化改进 ↗
+
+
广告屏蔽
+
呈现清爽整洁的网站后台,清除侵入式后台广告、无用信息。
获取广告规则 ↗
+
+
+
+
加入我们
+
关注文派茶馆 WPTEA.com 公众号以及订阅我们的时事通讯即可接收独家内容、提示和更新。
+

+
+
+
+
diff --git a/wp-china-yes.php b/wp-china-yes.php
index 9f05e67..d45f19b 100755
--- a/wp-china-yes.php
+++ b/wp-china-yes.php
@@ -1,10 +1,10 @@