一般情况,WordPress是默认不支持中文名称注册,这时候需要加个中文昵称的提醒,我是不建议修改文件让支持中文名称注册的,毕竟可能会遇到一些人瞎起名。今天就为大家分享在WordPress主页页面跳出一些文字提示教程。

要修改Wordpress注册页面的“在这个站点注册”文字,是可以修改wp-login.php文件或者语言文件来实现的。修改wp-login.php文件,如果系统更新,就得重新改一次,修改语言文件有点麻烦,同样也有更新覆盖的问题。

剩下的方法就是改代码了,同样修改主题的functions.php,也可以以插件代码形式加入,不过还是直接改functions.php方便。需要用到Wordpress的gettext钩子,比如:

//替换文字

function my_text_strings( $translated_text, $text, $domain ) {

switch ( $translated_text ) {

case \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’在这个站点注册\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ :

$translated_text = __( \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’请不要用中文名称\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’register_form\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ );

break;

}

return $translated_text;

}

add_filter( \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’gettext\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’my_text_strings\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, 20, 3 );

这段代码应该适用Wordpress系统全部文字替换,主要找到对应的函数就行,比如修改woocommerce商城里面的文字提示:

function my_text_strings( $translated_text, $text, $domain ) {

switch ( $translated_text ) {

case \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Sale!\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ :

$translated_text = __( \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Clearance!\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’woocommerce\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ );

break;

case \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Add to cart\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ :

$translated_text = __( \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Add to basket\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’woocommerce\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ );

break;

case \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Related Products\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ :

$translated_text = __( \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Check out these related products\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’woocommerce\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ );

break;

}

return $translated_text;

}

add_filter( \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’gettext\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’my_text_strings\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, 20, 3 );

相关新闻

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

联系我们

联系我们

151-1101-0018

在线咨询:
邮件:30115776@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
关注微信
分享本页
返回顶部