问题描述
我正在尝试仅更改阿拉伯语的 wordpress 管理菜单,但是当我使用以下功能时,它会更改所有语言 - 英语和阿拉伯语
<?PHP
/**
* GeneratePress child theme functions and deFinitions.
*
* Add your custom PHP in this file.
* Only edit this file if you have direct access to it on your server (to fix errors if they happen).
*/
function wd_admin_menu_rename() {
global $menu; // Global to get menu array
$menu[5][0] = 'أعلانات'; // Change name of posts to Ads
}
add_action( 'admin_menu','wd_admin_menu_rename' );
如何只为使用阿拉伯语仪表板的用户更改它?
解决方法
function wd_admin_menu_rename() {
// check for site language
$lang = get_option('WPLANG');
if($lang == 'ar')
{
global $menu; // Global to get menu array
$menu[5][0] = 'أعلانات'; // Change name of posts to Ads
}
}
add_action( 'admin_menu','wd_admin_menu_rename' );