From aad6ea29a6ec5db6379b8d9dc0df36dbf632725e Mon Sep 17 00:00:00 2001 From: sunxiyuan Date: Tue, 14 Jul 2020 11:45:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vendor/loco-translate/src/mvc/AdminRouter.php | 20 ++++--- wp-china-yes.php | 57 +++++++++++++++++-- 2 files changed, 62 insertions(+), 15 deletions(-) diff --git a/vendor/loco-translate/src/mvc/AdminRouter.php b/vendor/loco-translate/src/mvc/AdminRouter.php index cc759fc..4e36c3e 100644 --- a/vendor/loco-translate/src/mvc/AdminRouter.php +++ b/vendor/loco-translate/src/mvc/AdminRouter.php @@ -33,24 +33,25 @@ class Loco_mvc_AdminRouter extends Loco_hooks_Hookable { // main loco pages, hooking only if has permission if( $user->has_cap($cap) ){ - +/* $label = __('Loco Translate','loco-translate'); // translators: Page title for plugin home screen $title = __('Loco, Translation Management','loco-translate'); add_menu_page( $title, $label, $cap, 'loco', $render, 'dashicons-translation' ); // alternative label for first menu item which gets repeated from top level add_submenu_page( 'loco', $title, __('Home','loco-translate'), $cap, 'loco', $render ); - - $label = __('Themes','loco-translate'); - // translators: Page title for theme translations - $title = __('Theme translations ‹ Loco','loco-translate'); - add_submenu_page( 'loco', $title, $label, $cap, 'loco-theme', $render ); - - $label = __('Plugins', 'loco-translate'); +*/ + $label = __('插件翻译校准', 'loco-translate'); // translators: Page title for plugin translations $title = __('Plugin translations ‹ Loco','loco-translate'); - add_submenu_page( 'loco', $title, $label, $cap, 'loco-plugin', $render ); + add_submenu_page( 'wpcy', $title, $label, $cap, 'loco-plugin', $render, 1 ); + $label = __('主题翻译校准','loco-translate'); + // translators: Page title for theme translations + $title = __('Theme translations ‹ Loco','loco-translate'); + add_submenu_page( 'wpcy', $title, $label, $cap, 'loco-theme', $render, 2 ); + +/* $label = __('WordPress', 'loco-translate'); // translators: Page title for core WordPress translations $title = __('Core translations ‹ Loco', 'loco-translate'); @@ -71,6 +72,7 @@ class Loco_mvc_AdminRouter extends Loco_hooks_Hookable { $title = __('User options','loco-translate'); add_submenu_page( 'loco', $title, __('Settings','loco-translate'), $cap, 'loco-config-user', $render ); } +*/ } } diff --git a/wp-china-yes.php b/wp-china-yes.php index 7095edf..77f2a9e 100644 --- a/wp-china-yes.php +++ b/wp-china-yes.php @@ -9,10 +9,55 @@ * License URI: http://www.gnu.org/licenses/gpl-3.0.html */ -if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { - require __DIR__ . '/vendor/autoload.php'; -} +if (is_admin()) { + /** + * 使用Composer作PHP文件自动加载 + */ + if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { + require __DIR__ . '/vendor/autoload.php'; + } -if ( file_exists( __DIR__ . '/vendor/loco-translate/loco.php' ) ) { - require __DIR__ . '/vendor/loco-translate/loco.php'; -} \ No newline at end of file + /** + * WP-China-Yes的翻译校准基于Loco Translate插件开发,这里通过引入入口文件的方式激活该插件的二次开发版 + */ + if ( file_exists( __DIR__ . '/vendor/loco-translate/loco.php' ) ) { + require __DIR__ . '/vendor/loco-translate/loco.php'; + } + + + /** + * 菜单注册 + */ + add_action('admin_menu', function () { + add_menu_page( + '本土化', + '本土化', + '', + 'wpcy' + ); + + add_submenu_page( + 'wpcy', + '系统本土化', + '系统本土化', + 'manage_options', + 'wpcy-setting', + function () { + echo 'a'; + }, + 0 + ); + + add_submenu_page( + 'wpcy', + '关于', + '关于', + 'manage_options', + 'wpcy-about', + function () { + echo 'a'; + }, + 3 + ); + }); +}