diff --git a/Plugin.php b/Plugin.php index 1d3f726..1e5d455 100644 --- a/Plugin.php +++ b/Plugin.php @@ -38,7 +38,7 @@ class Plugin { * 插件加载时执行 */ public function plugins_loaded() { - load_plugin_textdomain( 'wp-china-yes', false, plugin_dir_path( PLUGIN_FILE ) . 'languages' ); + load_plugin_textdomain( 'wp-china-yes', false, CHINA_YES_PLUGIN_PATH . 'languages' ); add_action( 'admin_notices', [ $this, 'admin_notices' ] ); } diff --git a/Service/Setting.php b/Service/Setting.php index c997e92..32818ba 100644 --- a/Service/Setting.php +++ b/Service/Setting.php @@ -17,6 +17,7 @@ class Setting { public function __construct() { $this->setting_api = new API(); add_action( 'admin_init', [ $this, 'admin_init' ] ); + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_assets' ] ); add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', [ $this, 'admin_menu' ] ); } @@ -108,6 +109,16 @@ class Setting { $this->setting_api->admin_init(); } + /** + * 加载后台资源 + */ + public function enqueue_admin_assets( $hook_suffix ) { + if ( strpos( $hook_suffix, 'wp-china-yes' ) === false ) { + return; + } + wp_enqueue_style( 'wpcy-admin', CHINA_YES_PLUGIN_URL . 'assets/css/setting.css', [], CHINA_YES_VERSION ); + } + /** * 挂载设置页面 */ @@ -139,174 +150,69 @@ class Setting { * 设置页面模版 */ public function setting_page() { - echo '
-

文派叶子🍃(WP-China-Yes)

'; - echo '

将您的 WordPress 接入本土生态体系,这将为您提供一个更贴近中国人使用习惯的 WordPress。

100% 开源代码,一起参与文派(WordPress)软件国产化进程,打造属于您自己的开源自助建站程序。

'; echo << - 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; -} - #wpcontent, #wpfooter { - background-color: #ffffff; - } - .container { - display: flex; - flex-wrap: wrap; - width: 100%; - } - .left-column, .right-column { - width: 100%; - } - .right-column { - padding: 20px; - display: flex; - flex-direction: column; - gap: 20px; - } - .card { - background-color: #fff; - padding: 10%; - border-radius: 10px; - text-transform: none; - border: 0px solid #c3c4c7; - font-size: 14px; - line-height: 2; - box-shadow: 0 0.375rem 1.5rem 0 rgba(141, 153, 165, 0.13); - } - - .card h3 { - margin-top: 0; - font-size: 18px; - font-weight: 400; - } - .card a, .left-column a { - text-decoration: none; - } - .card-body, .card-footer { - margin: 10px 0; - } - - .card-footer a.button.button-primary { - padding: 1% 5%; - margin-top: 10px; - } - .form-table th { - width: 120px; - padding: 5% 0; - } - .form-table td { - padding: 5% 0; - } - .wpcy-settings-header { - padding-top: 20px; - max-width: 1280px; - margin: 0 auto; - line-height: 1.5; - } - .wpcy-settings-title-section { - padding: 1% 0; - } - .wpcy-settings-title-section h3 { - font-size: large; - } - .wpcy-settings-title-section h4 { - font-size: large; - font-weight: 400; - } - .wpcy-settings-footer p { - font-size: x-small; - line-height: 2; - } - .sponsor-logos { - display: flex; - flex-wrap: wrap; - justify-content: center; - } - - .sponsor-logos img { - width: 26%; - margin-bottom: 30px; - display: block; - margin-left: auto; - margin-right: auto; - height: fit-content; - } - - @media screen and (max-width: 782px){ - .auto-fold #wpcontent { - padding: 10px; - } - } - @media (min-width: 768px) { - .container { - flex-wrap: nowrap; - max-width: 1280px; - margin: 0 auto; - } - .left-column { - width: 70%; - } - .right-column { - width: 30%; - } - } - +
+
+

文派叶子🍃(WP-China-Yes)

+
+

将您的 WordPress 接入本土生态体系,这将为您提供一个更贴近中国人使用习惯的 WordPress。

+

100% 开源代码,一起参与文派(WordPress)软件国产化进程,打造属于您自己的开源自助建站程序。

+
-
+
HTML; $this->setting_api->show_navigation(); $this->setting_api->show_forms(); echo << -

提示:插件会定期检查节点可用性,并在节点不可用时自动切换至可用节点,以保证您的网站正常访问。如您发现设置项被自动切换,可在此页面重新设置。

-

帮助:您可以随时在此处调整个性化设置以便适应不同的业务场景,萌新请保持默认即可。此项目的发展离不开您的支持和建议,查看联系方式

-
-
-
-
-

项目简介

-
- 文派叶子 🍃(WP-China-Yes)是一款不可多得的 WordPress 系统底层优化和生态基础设施软件。项目起源于 2019 年,专为解决困扰了中国互联网数十年的特色问题而存在。此为文派开源(WenPai.org)的一部分。 -
- +
-
-

赞助商

- - +
+
+

项目简介

+
+ 文派叶子 🍃(WP-China-Yes)是一款不可多得的 WordPress 系统底层优化和生态基础设施软件。项目起源于 2019 年,专为解决困扰了中国互联网数十年的特色问题而存在。此为文派开源(WenPai.org)的一部分。 +
+ +
+
+

赞助商

+ + +
+
- -
HTML; diff --git a/Service/Super.php b/Service/Super.php index fc55de4..d3b0ee4 100644 --- a/Service/Super.php +++ b/Service/Super.php @@ -217,8 +217,10 @@ class Super { * WordPress.Org 替换 */ public function filter_wordpress_org( $preempt, $args, $url ) { - if ( ( ! strpos( $url, 'api.wordpress.org' ) && ! strpos( $url, - 'downloads.wordpress.org' ) ) ) { + if ( $preempt || isset( $args['_wp_china_yes'] ) ) { + return $preempt; + } + if ( ( ! strpos( $url, 'api.wordpress.org' ) && ! strpos( $url, 'downloads.wordpress.org' ) ) ) { return $preempt; } @@ -240,6 +242,8 @@ class Super { $url = str_replace( 'https://', 'http://', $url ); } + $args['_wp_china_yes'] = true; + return wp_remote_request( $url, $args ); } diff --git a/Service/Update.php b/Service/Update.php index c8a5951..daccdd7 100644 --- a/Service/Update.php +++ b/Service/Update.php @@ -5,7 +5,6 @@ namespace WenPai\ChinaYes\Service; defined( 'ABSPATH' ) || exit; use YahnisElsts\PluginUpdateChecker\v5\PucFactory; -use const WenPai\ChinaYes\PLUGIN_FILE; /** * Class Update @@ -17,7 +16,7 @@ class Update { public function __construct() { PucFactory::buildUpdateChecker( 'https://api.wenpai.org/china-yes/version-check', - PLUGIN_FILE, + CHINA_YES_PLUGIN_FILE, 'wp-china-yes' ); } diff --git a/assets/css/setting.css b/assets/css/setting.css new file mode 100644 index 0000000..de2b0e5 --- /dev/null +++ b/assets/css/setting.css @@ -0,0 +1,120 @@ +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; +} + +#wpcontent, #wpfooter { + background-color: #ffffff; +} + +.notice { + background-color: #f5f5f5; +} + +.container { + display: flex; + flex-wrap: wrap; + width: 100%; +} + +.left-column, .right-column { + width: 100%; +} + +.right-column { + padding: 20px; + display: flex; + flex-direction: column; + gap: 20px; +} + +.card { + background-color: #fff; + padding: 10%; + border-radius: 10px; + text-transform: none; + border: 0px solid #c3c4c7; + font-size: 14px; + line-height: 2; + box-shadow: 0 0.375rem 1.5rem 0 rgba(141, 153, 165, 0.13); +} + +.card h3 { + margin-top: 0; + font-size: 18px; + font-weight: 400; +} + +.card a, .left-column a { + text-decoration: none; +} + +.card-body, .card-footer { + margin: 10px 0; +} + +.card-footer a.button.button-primary { + padding: 1% 5%; + margin-top: 10px; +} + +.form-table th { + width: 120px; + padding: 5% 0; +} + +.form-table td { + padding: 5% 0; +} + +.settings-header { + padding-top: 20px; + max-width: 1280px; + margin: 0 auto; + line-height: 1.5; +} + +.settings-title-section { + padding: 1% 0; +} + +.settings-footer p { + font-size: 12px; + line-height: 2; +} + +.sponsor-logos { + display: flex; + flex-wrap: wrap; + justify-content: center; +} + +.sponsor-logos img { + width: 26%; + margin-bottom: 30px; + display: block; + margin-left: auto; + margin-right: auto; + height: fit-content; +} + +@media screen and (max-width: 782px) { + .auto-fold #wpcontent { + padding: 10px; + } +} + +@media (min-width: 768px) { + .container { + flex-wrap: nowrap; + max-width: 1280px; + margin: 0 auto; + } + + .left-column { + width: 70%; + } + + .right-column { + width: 30%; + } +} \ No newline at end of file diff --git a/wp-china-yes.php b/wp-china-yes.php index 3752e6d..54094cc 100644 --- a/wp-china-yes.php +++ b/wp-china-yes.php @@ -19,15 +19,16 @@ namespace WenPai\ChinaYes; defined( 'ABSPATH' ) || exit; -const VERSION = '3.6.1'; -const PLUGIN_FILE = __FILE__; -const PLUGIN_DIR = __DIR__; +define( 'CHINA_YES_VERSION', '3.6.1' ); +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 ) ); -require_once( plugin_dir_path( __FILE__ ) . 'vendor/autoload.php' ); +require_once( plugin_dir_path( CHINA_YES_PLUGIN_FILE ) . 'vendor/autoload.php' ); // 注册插件激活钩子 -register_activation_hook( PLUGIN_FILE, [ Plugin::class, 'activate' ] ); +register_activation_hook( CHINA_YES_PLUGIN_FILE, [ Plugin::class, 'activate' ] ); // 注册插件删除钩子 -register_uninstall_hook( PLUGIN_FILE, [ Plugin::class, 'uninstall' ] ); +register_uninstall_hook( CHINA_YES_PLUGIN_FILE, [ Plugin::class, 'uninstall' ] ); new Plugin();