Skip to content

Commit

Permalink
feat: bump version 3.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Aug 23, 2024
1 parent ce02646 commit 4a7c871
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Plugin {

/**
* 创建一个插件实例
* 创建插件实例
*/
public function __construct() {
new Base();
Expand Down
11 changes: 11 additions & 0 deletions Service/Monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public function __construct() {
* 初始化
*/
public function init() {
if ( $this->settings['monitor'] != 'on' ) {
return;
}
// 检查应用市场可用性
if ( ! wp_next_scheduled( 'wp_china_yes_maybe_check_store' ) && $this->settings['store'] != 'off' ) {
wp_schedule_event( time(), 'hourly', 'wp_china_yes_maybe_check_store' );
Expand Down Expand Up @@ -141,6 +144,14 @@ public function maybe_check_admincdn() {
$this->update_settings();
}
}
// jsDelivr 公共库
if ( ! empty( $this->settings['admincdn']['jsdelivr'] ) ) {
$response = wp_remote_get( 'https://jsd.admincdn.com/npm/[email protected]/dist/jquery.slim.min.js' );
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
unset( $this->settings['admincdn']['jsdelivr'] );
$this->update_settings();
}
}
}

/**
Expand Down
24 changes: 19 additions & 5 deletions Service/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public function admin_init() {
'frontend' => '前台加速',
'googlefonts' => 'Google 字体',
'googleajax' => 'Google 前端公共库',
'cdnjs' => 'CDNJS 前端公共库'
'cdnjs' => 'CDNJS 前端公共库',
'jsdelivr' => 'jsDelivr 公共库',
]
],
[
Expand All @@ -75,19 +76,20 @@ public function admin_init() {
'options' => [
'cn' => '默认线路',
'global' => '国际线路',
'weavatar' => '备用源(WeAvatar)',
'weavatar' => '备用源(<a href="https://weavatar.com/" target="_blank">WeAvatar</a>',
'off' => '不启用'
]
],
[
'name' => 'windfonts',
'label' => __( '文风字体', 'wp-china-yes' ),
'desc' => __( '<a href="https://windfonts.com/" target="_blank">文风字体(Windfonts)</a>即将为您的网页渲染中文字体并对主题、插件内的字体进行加速。',
'desc' => __( '<a href="https://windfonts.com/" target="_blank">文风字体(Windfonts)</a>为您的网页渲染中文字体并对主题、插件内的字体进行加速;优化模式可优化浏览器字体调用',
'wp-china-yes' ),
'type' => 'radio',
'default' => 'off',
'options' => [
'off' => '即将上线',
'optimize' => '优化模式',
'off' => '不启用',
]
],
[
Expand All @@ -101,6 +103,18 @@ public function admin_init() {
'off' => '即将上线',
]
],
[
'name' => 'monitor',
'label' => __( '自动监控', 'wp-china-yes' ),
'desc' => __( '<a href="https://wp-china-yes.com/ads" target="_blank">文派叶子🍃(WP-China-Yes)</a>支持自动监控各加速节点可用性,当节点不可用时自动切换至可用节点或关闭加速,以保证您的网站正常访问。',
'wp-china-yes' ),
'type' => 'radio',
'default' => 'on',
'options' => [
'on' => '启用',
'off' => '不启用',
]
],
]
];

Expand Down Expand Up @@ -166,7 +180,7 @@ public function setting_page() {

echo <<<HTML
<div class="settings-footer">
<p><strong>提示:</strong>插件会定期检查节点可用性,并在节点不可用时自动切换至可用节点,以保证您的网站正常访问。如您发现设置项被自动切换,可在此页面重新设置。</p>
<p><strong>提示:</strong>插件会定期检查节点可用性,并在节点不可用时自动切换至可用节点,以保证您的网站正常访问。如您发现设置项被自动切换,可重新设置或关闭自动监控功能。</p>
<p><strong>帮助:</strong>您可以随时在此处调整个性化设置以便适应不同的业务场景,萌新请保持默认即可。此项目的发展离不开您的支持和建议,<a href="https://wp-china-yes.com/contact" target="_blank">查看联系方式</a>。</p>
</div>
</div>
Expand Down
19 changes: 19 additions & 0 deletions Service/Super.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ public function __construct() {
'cdnjs.admincdn.com'
] );
}

/**
* jsDelivr 前端公共库替换
*/
if ( ! empty( $this->settings['admincdn']['jsdelivr'] ) ) {
$this->page_str_replace( 'str_replace', [
'cdn.jsdelivr.net',
'jsd.admincdn.com'
] );
}
}

/**
Expand All @@ -211,6 +221,15 @@ public function __construct() {
add_filter( 'bp_gravatar_url', [ $this, 'get_cravatar_url' ], 1 );
add_filter( 'get_avatar_url', [ $this, 'get_cravatar_url' ], 1 );
}

/**
* 文风字体
*/
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 );
} );
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions assets/css/fonts.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/css/setting.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
font-family: "Source Han Sans SC", "Noto Sans CJK SC", "Source Han Sans CN", "Noto Sans SC", "Source Han Sans TC", "Noto Sans CJK TC", sans-serif, -apple-system, "Noto Sans", "Helvetica Neue", Helvetica, "Nimbus Sans L", Arial, "Liberation Sans", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Source Han Sans CN", "Microsoft YaHei", "Wenquanyi Micro Hei", "WenQuanYi Zen Hei", "ST Heiti", SimHei, "WenQuanYi Zen Hei Sharp", sans-serif;
font-family: -apple-system, "Noto Sans", "Helvetica Neue", Helvetica, "Nimbus Sans L", Arial, "Liberation Sans", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Source Han Sans CN", "Microsoft YaHei", "Wenquanyi Micro Hei", "WenQuanYi Zen Hei", "ST Heiti", SimHei, "WenQuanYi Zen Hei Sharp", sans-serif;
}

#wpcontent, #wpfooter {
Expand Down
1 change: 1 addition & 0 deletions helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ function get_settings() {
'cravatar' => 'cn',
'windfonts' => 'off',
'adblock' => 'off',
'monitor' => 'on',
] );
}
4 changes: 2 additions & 2 deletions wp-china-yes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: 文派叶子 🍃(WP-China-Yes)是中国 WordPress 生态基础设施软件,犹如落叶新芽,生生不息。
* Author: 文派开源
* Author URI: https://wp-china-yes.com
* Version: 3.6.2
* Version: 3.6.3
* License: GPLv3 or later
* Text Domain: wp-china-yes
* Domain Path: /languages
Expand All @@ -19,7 +19,7 @@

defined( 'ABSPATH' ) || exit;

define( 'CHINA_YES_VERSION', '3.6.2' );
define( 'CHINA_YES_VERSION', '3.6.3' );
define( 'CHINA_YES_PLUGIN_FILE', __FILE__ );
define( 'CHINA_YES_PLUGIN_URL', plugin_dir_url( CHINA_YES_PLUGIN_FILE ) );
define( 'CHINA_YES_PLUGIN_PATH', plugin_dir_path( CHINA_YES_PLUGIN_FILE ) );
Expand Down

0 comments on commit 4a7c871

Please sign in to comment.