forked from WenPai-org/wp-china-yes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,126 additions
and
437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: 报告问题 (Bug Report) | ||
description: 创建一个报告以帮助我们改进 (Create a report to help us improve) | ||
title: "[Bug Report]: " | ||
labels: ["bug"] | ||
|
||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
**请仅使用 简体中文 或 英文 进行填写** | ||
**Please only use Simplified Chinese or English to fill in** | ||
- type: checkboxes | ||
id: checks | ||
attributes: | ||
label: 在提问之前 (Before asking) | ||
description: | | ||
提问之前,先回答几个小问题。 | ||
Before asking questions, answer a few quick questions. | ||
options: | ||
- label: 我已经搜索了现有的 Issues 和 Discussions (I've searched the existing Issues and Discussions) | ||
required: true | ||
- label: 我已经阅读了 README 中除版本记录以外的所有内容 (I've read everything in the README except the version notes) | ||
required: true | ||
- label: 我在提问题之前至少花费了 5 分钟来思考和准备 (I spend at least 5 minutes thinking and preparing before asking a question) | ||
required: true | ||
- label: 这个问题出现在最新版的 WP-China-Yes 上 (This question appears on the latest version of WP-China-Yes) | ||
required: false | ||
- label: 我使用过旧版的 WP-China-Yes 并且没有出现这个问题 (I've used an older version of WP-China-Yes and didn't have this problem) | ||
required: false | ||
- label: 这个问题出现了至少 3 次 (This question has occurred at least 3 times) | ||
required: false | ||
- type: textarea | ||
id: describe | ||
attributes: | ||
label: 描述问题 (Describe the problem) | ||
description: | | ||
简明概要地描述你遇到的问题。 | ||
Briefly describe the problem you are having. | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: expected | ||
attributes: | ||
label: 预期行为 (Expected behavior) | ||
description: | | ||
简明概要地描述你期望发生的事情。 | ||
Briefly describe what you expect to happen. | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: reproduce | ||
attributes: | ||
label: 如何复现 (How to reproduce) | ||
description: | | ||
重现该问题的详细步骤。 | ||
Detailed steps to reproduce the problem. | ||
value: | | ||
1. 安装 WP-China-Yes | ||
2. 设置 '...' | ||
3. 点击 '...' | ||
4. 出现问题 | ||
validations: | ||
required: false | ||
- type: textarea | ||
id: logs | ||
attributes: | ||
label: 相关日志 (Related logs) | ||
description: | | ||
请复制并粘贴任何相关的日志输出。 | ||
Please copy and paste any relevant log output. | ||
可以把文件拖入这个区域以添加日志文件。 | ||
Files can be dragged into this area to add log files. | ||
日志文件可通过开启 WordPress 的调试模式获取。 | ||
Log files can be accessed by enabling WordPress debug mode. | ||
render: Text | ||
validations: | ||
required: false | ||
- type: textarea | ||
id: screenshots | ||
attributes: | ||
label: 截图 (Screenshots) | ||
description: | | ||
如果有,添加屏幕截图可帮助更快定位你的问题。 | ||
If so, adding screenshots can help locate your issue faster. | ||
可以复制图片后在此区域内粘贴以添加图片。 | ||
Pictures can be copied and pasted in this area to add pictures. | ||
如有必要,使用马赛克遮盖敏感信息。 | ||
Use a mosaic to obscure sensitive information if necessary. | ||
validations: | ||
required: false | ||
- type: textarea | ||
id: others | ||
attributes: | ||
label: 还有别的吗 (Anything else) | ||
description: | | ||
运行环境?浏览器?WordPress 版本?相关的配置?链接?参考资料? | ||
Environment? Browser? WordPress version? Related configuration? Link? References? | ||
任何能让我们对你所遇到的问题有更多了解的东西。 | ||
Anything that can give us more insight into the problem you're having. | ||
validations: | ||
required: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
blank_issues_enabled: false | ||
contact_links: | ||
- name: 讨论、问答和非项目问题 (Discussions, questions, and non-project issues) | ||
url: https://jq.qq.com/?_wv=1027&k=I1oJKSTH | ||
about: 其他不明之处,请移步我们的QQ群 12370907 (For other unclear things, please move to our qq group 12370907) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: 功能请求 (Feature request) | ||
description: 为这个项目提出一个想法 (Suggest an idea for this project) | ||
title: "[Feature Request]: " | ||
labels: ["enhancement"] | ||
|
||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
**请仅使用 简体中文 或 英文 进行填写** | ||
**Please only use Simplified Chinese or English to fill in** | ||
- type: checkboxes | ||
attributes: | ||
label: 在提问之前 (Before asking) | ||
description: | | ||
提问之前,先回答几个小问题。 | ||
Before asking questions, answer a few quick questions. | ||
options: | ||
- label: 我已经搜索了全部 Issues 和 Commits (I have searched all Issues and Commits) | ||
required: true | ||
- label: 它们当中没有我将要提交的新功能 (None of them have new feature that I'm going to submit) | ||
required: true | ||
- type: textarea | ||
id: feature | ||
attributes: | ||
label: 描述功能 (Describe feature) | ||
description: | | ||
简明概要地描述你的新功能,以及它将解决什么问题。 | ||
Briefly describe your new feature and what problem it will solve. | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: workflow | ||
attributes: | ||
label: 工作流程 (Workflow) | ||
description: | | ||
请向我们提供有关该功能的实现流程。 | ||
Please provide us with the implementation flow for this feature. | ||
value: | | ||
1. 新建文件 .... | ||
2. 添加函数 .... | ||
3. ... | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: others | ||
attributes: | ||
label: 还有别的吗 (Anything else) | ||
description: | | ||
运行环境?浏览器?WordPress 版本?相关的配置?链接?参考资料? | ||
Environment? Browser? WordPress version? Related configuration? Link? References? | ||
任何能让我们对该功能的实现有更多帮助的东西。 | ||
Anything that can help us more with the implementation of this feature. | ||
validations: | ||
required: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: "Update Changelog" | ||
|
||
on: | ||
release: | ||
types: [released] | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
|
||
- name: Update Changelog | ||
uses: stefanzweifel/changelog-updater-action@v1 | ||
with: | ||
latest-version: ${{ github.event.release.tag_name }} | ||
release-notes: ${{ github.event.release.body }} | ||
|
||
- name: Commit updated CHANGELOG | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
branch: main | ||
commit_message: "docs: Update CHANGELOG" | ||
file_pattern: CHANGELOG.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Changelog | ||
|
||
All notable changes to `WP-China-Yes` will be documented in this file. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
namespace WenPai\ChinaYes; | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
use WenPai\ChinaYes\Service\Base; | ||
use WenPai\ChinaYes\Service\Setting; | ||
|
||
class Plugin { | ||
|
||
/** | ||
* 创建一个插件实例 | ||
*/ | ||
public function __construct() { | ||
new Base(); | ||
new Setting(); | ||
add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] ); | ||
} | ||
|
||
/** | ||
* 插件激活时执行 | ||
*/ | ||
public static function activate() { | ||
// 兼容性检测 | ||
self::check(); | ||
} | ||
|
||
/** | ||
* 插件删除时执行 | ||
*/ | ||
public static function uninstall() { | ||
// 清除设置 | ||
is_multisite() ? delete_site_option( 'wp_china_yes' ) : delete_option( 'wp_china_yes' ); | ||
} | ||
|
||
/** | ||
* 插件加载时执行 | ||
*/ | ||
public function plugins_loaded() { | ||
load_plugin_textdomain( 'wp-china-yes', false, plugin_dir_path( PLUGIN_FILE ) . 'languages' ); | ||
add_action( 'admin_notices', [ $this, 'admin_notices' ] ); | ||
} | ||
|
||
/** | ||
* 插件兼容性检测函数 | ||
*/ | ||
public static function check() { | ||
$notices = []; | ||
if ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) { | ||
deactivate_plugins( 'wp-china-yes/wp-china-yes.php' ); | ||
$notices[] = '<div class="notice notice-error"><p>' . sprintf( __( 'WP-China-Yes 插件需要 PHP 5.6.0 或更高版本,当前版本为 %s,插件已自动禁用。', | ||
'wp-china-yes' ), | ||
PHP_VERSION ) . '</p></div>'; | ||
} | ||
if ( is_plugin_active( 'wp-china-no/wp-china-no.php' ) ) { | ||
deactivate_plugins( 'wp-china-no/wp-china-no.php' ); | ||
$notices[] = '<div class="notice notice-error is-dismissible"> | ||
<p><strong>' . __( '检测到旧版插件 WP-China-No,已自动禁用!', 'wp-china-yes' ) . '</strong></p> | ||
</div>'; | ||
} | ||
if ( is_plugin_active( 'wp-china-plus/wp-china-plus.php' ) ) { | ||
deactivate_plugins( 'wp-china-plus/wp-china-plus.php' ); | ||
$notices[] = '<div class="notice notice-error is-dismissible"> | ||
<p><strong>' . __( '检测到不兼容的插件 WP-China-Plus,已自动禁用!', 'wp-china-yes' ) . '</strong></p> | ||
</div>'; | ||
} | ||
if ( is_plugin_active( 'kill-429/kill-429.php' ) ) { | ||
deactivate_plugins( 'kill-429/kill-429.php' ); | ||
$notices[] = '<div class="notice notice-error is-dismissible"> | ||
<p><strong>' . __( '检测到不兼容的插件 Kill 429,已自动禁用!', 'wp-china-yes' ) . '</strong></p> | ||
</div>'; | ||
|
||
} | ||
// 代理服务器检测 | ||
if ( defined( 'WP_PROXY_HOST' ) || defined( 'WP_PROXY_PORT' ) ) { | ||
$notices[] = '<div class="notice notice-warning is-dismissible"> | ||
<p><strong>' . __( '检测到已在 WordPress 配置文件中设置代理服务器,这可能会导致插件无法正常工作!', | ||
'wp-china-yes' ) . '</strong></p> | ||
</div>'; | ||
} | ||
|
||
set_transient( 'wp-china-yes-admin-notices', $notices, 10 ); | ||
} | ||
|
||
/** | ||
* 输出管理后台提示信息 | ||
*/ | ||
public function admin_notices() { | ||
$notices = get_transient( 'wp-china-yes-admin-notices' ); | ||
if ( $notices ) { | ||
foreach ( $notices as $notice ) { | ||
echo $notice; | ||
} | ||
delete_transient( 'wp-china-yes-admin-notices' ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace WenPai\ChinaYes\Service; | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
/** | ||
* Class Base | ||
* 插件主服务 | ||
* @package WenPai\ChinaYes\Service | ||
*/ | ||
class Base { | ||
|
||
public function __construct() { | ||
/** | ||
* 插件列表页中所有插件增加「参与翻译」链接 | ||
*/ | ||
add_filter( sprintf( '%splugin_action_links', is_multisite() ? 'network_admin_' : '' ), function ( $links, $plugin = '' ) { | ||
$links[] = '<a target="_blank" href="https://translate.wenpai.org/projects/plugins/' . substr( $plugin, 0, strpos( $plugin, '/' ) ) . '/">参与翻译</a>'; | ||
|
||
return $links; | ||
}, 10, 2 ); | ||
|
||
// 加速服务 | ||
new Super(); | ||
// 更新服务 | ||
new Update(); | ||
} | ||
} |
Oops, something went wrong.