Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
feat: remove cc domain
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed May 31, 2023
1 parent e993021 commit 3939d85
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 50 deletions.
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

## 简介

由于 LitePress 及其所属的 WP-China-Yes 项目已近乎"脑死亡",故产生了本项目。

我们的终极目标是打造一个本土化的 WordPress,包括应用市场、翻译、文档等方面。这需要非常大量的开发工作。

如果你也对此感兴趣且熟悉 WordPress 开发 / Vue 开发 / Golang 开发,欢迎通过下方的联系方式加入我们。
平台当前正在积极开发中,已有成果可在 [WePublish.cn](https://wepublish.cn/) 了解。

如果你也对此感兴趣且熟悉 WordPress 开发 / Vue 开发 / Golang 开发 / PHP 开发,欢迎通过下方的联系方式加入我们。

## 功能

- [x] 优化 WordPress 相关服务在中国大陆的访问速度
- [x] 优化 WordPress 后台加载速度
- [x] 优化 Gravatar 头像加载速度
- [x] 替换 Gravatar 头像为 WeAvatar 头像
- [x] 优化 谷歌字体 加载速度
- [x] 优化 谷歌前端库 加载速度
- [x] 优化 CDNJS 加载速度
Expand All @@ -27,14 +27,22 @@

## 问题反馈

请在`Issues`页面提交问题反馈,注意[提问的智慧](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md)
对于 WordPress 相关的问题,可在 [WePublish社区论坛](https://wepublish.cn/forum) 提问寻求帮助。

对于此插件自身问题,可在`Issues`页面提交问题反馈,注意[提问的智慧](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md)

交流QQ群:[12370907](https://jq.qq.com/?_wv=1027&k=I1oJKSTH) | QQ频道:[耗子](https://pd.qq.com/s/fyol46wfy)

## 赞助商

### 服务器

- [盾云](https://www.ddunyun.com/)

### CDN

- [盾云CDN](http://cdn.ddunyun.com/)

- [又拍云](https://www.upyun.com/)

#### 接受云资源和资金赞助,可通过QQ群咨询联系
7 changes: 3 additions & 4 deletions inc/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ public function admin_init() {
array(
'name' => 'weavatar',
'label' => __( 'WeAvatar头像', 'wp-china-plus' ),
'desc' => __( '替换Gravatar头像为<a href="https://weavatar.com" target="_blank">WeAvatar</a>头像,WeAvatar致力于打造多端多元化的统一头像服务<br><b>若您网站不符合大陆相关法规要求,建议使用cc域名,否则有可能导致网站被拉黑无法使用</b>',
'desc' => __( '替换Gravatar头像为<a href="https://weavatar.com" target="_blank">WeAvatar</a>头像,WeAvatar致力于打造多端多元化的统一头像服务',
'wp-china-plus' ),
'type' => 'radio',
'default' => 'on',
'options' => array(
'on' => '启用(com域名)',
'cc' => '启用(cc域名)',
'on' => '启用',
'off' => '禁用'
)
),
Expand Down Expand Up @@ -176,7 +175,7 @@ public function admin_init() {
'name' => 'sponsor',
'label' => __( '赞助商', 'wp-china-plus' ),
'type' => 'html',
'html' => __( '<h4>感谢以下赞助商的支持:</h4><p><a href="http://cdn.ddunyun.com/" target="_blank">盾云CDN</a></p>',
'html' => __( '<h4>感谢以下赞助商的支持:</h4><p><a href="https://www.ddunyun.com/" target="_blank">盾云</a></p><p><a href="http://cdn.ddunyun.com/" target="_blank">盾云CDN</a></p><p><a href="https://www.upyun.com/" target="_blank">又拍云</a></p>',
'wp-china-plus' )
)
)
Expand Down
47 changes: 8 additions & 39 deletions inc/service/class-super.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,12 @@ public function __construct() {
add_filter( 'user_profile_picture_description', [ $this, 'set_user_profile_picture_for_weavatar' ], 1 );
add_filter( 'avatar_defaults', [ $this, 'set_defaults_for_weavatar' ], 1 );

if ( $setting->get_option( 'weavatar', 'wp_china_plus_setting', 'on' ) != 'cc' ) {
add_filter( 'um_user_avatar_url_filter', [ $this, 'get_weavatar_com_url' ], 1 );
add_filter( 'bp_gravatar_url', [ $this, 'get_weavatar_com_url' ], 1 );
add_filter( 'get_avatar_url', [ $this, 'get_weavatar_com_url' ], 1 );
add_filter( 'um_user_avatar_url_filter', [ $this, 'get_weavatar_com_url' ], PHP_INT_MAX );
add_filter( 'bp_gravatar_url', [ $this, 'get_weavatar_com_url' ], PHP_INT_MAX );
add_filter( 'get_avatar_url', [ $this, 'get_weavatar_com_url' ], PHP_INT_MAX );
} else {
add_filter( 'um_user_avatar_url_filter', [ $this, 'get_weavatar_cc_url' ], 1 );
add_filter( 'bp_gravatar_url', [ $this, 'get_weavatar_cc_url' ], 1 );
add_filter( 'get_avatar_url', [ $this, 'get_weavatar_cc_url' ], 1 );
add_filter( 'um_user_avatar_url_filter', [ $this, 'get_weavatar_cc_url' ], PHP_INT_MAX );
add_filter( 'bp_gravatar_url', [ $this, 'get_weavatar_cc_url' ], PHP_INT_MAX );
add_filter( 'get_avatar_url', [ $this, 'get_weavatar_cc_url' ], PHP_INT_MAX );
}
add_filter( 'um_user_avatar_url_filter', [ $this, 'get_weavatar_url' ], 1 );
add_filter( 'bp_gravatar_url', [ $this, 'get_weavatar_url' ], 1 );
add_filter( 'get_avatar_url', [ $this, 'get_weavatar_url' ], 1 );
add_filter( 'um_user_avatar_url_filter', [ $this, 'get_weavatar_url' ], PHP_INT_MAX );
add_filter( 'bp_gravatar_url', [ $this, 'get_weavatar_url' ], PHP_INT_MAX );
add_filter( 'get_avatar_url', [ $this, 'get_weavatar_url' ], PHP_INT_MAX );
}

/**
Expand All @@ -153,9 +144,9 @@ public function __construct() {
}

/**
* 头像替换函数(com域名)
* 头像替换函数
*/
function get_weavatar_com_url( $url ) {
function get_weavatar_url( $url ) {
$sources = array(
'www.gravatar.com',
'0.gravatar.com',
Expand All @@ -168,33 +159,11 @@ function get_weavatar_com_url( $url ) {
'gravatar.duoshuo.com',
'gravatar.loli.net',
'cravatar.cn',
'weavatar.cc',
);

return str_replace( $sources, 'weavatar.com', $url );
}

/**
* 头像替换函数(cc域名)
*/
function get_weavatar_cc_url( $url ) {
$sources = array(
'www.gravatar.com',
'0.gravatar.com',
'1.gravatar.com',
'2.gravatar.com',
'secure.gravatar.com',
'cn.gravatar.com',
'gravatar.com',
'sdn.geekzu.org',
'gravatar.duoshuo.com',
'gravatar.loli.net',
'weavatar.com',
);

return str_replace( $sources, 'weavatar.cc', $url );
}

/**
* WordPress讨论设置中的默认LOGO名称替换函数
*/
Expand Down
4 changes: 2 additions & 2 deletions wp-china-plus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: 一个轻量级插件,用于改善WordPress在中国大陆的使用体验。
* Author: 耗子开源
* Author URI: https://github.com/HaoZi-Team/WP-China-Plus
* Version: 2.0.3
* Version: 2.0.4
* License: GPLv3 or later
* Text Domain: wp-china-plus
* Domain Path: /languages
Expand All @@ -22,7 +22,7 @@
use HaoZiTeam\WP_CHINA_PLUS\Inc\Plugin;
use HaoZiTeam\Autoload;

const VERSION = '2.0.3';
const VERSION = '2.0.4';
const PLUGIN_FILE = __FILE__;

// 加载自动加载器
Expand Down

0 comments on commit 3939d85

Please sign in to comment.