在wp-login.php中更改“<-back to”网站的标题

时间:2016-01-21 作者:Gareth Bolton

wp login页面上的登录表单。php在底部有一个标题,上面写着“返回网站名称”<;-这个标题然后总是重定向到主页,但我希望标题只是写着“返回网站名称”,所以我只希望删除“<;-”。

我想这需要在函数中添加一个钩子。php,但我不知道如何在网上搜索,也找不到任何东西。

任何建议请告诉我,谢谢!

1 个回复
SO网友:jas

请将以下代码添加到functions.php 要删除&larr; 从翻译的字符串:

/**
 * Remove &larr; from the \'&larr; Back to %s\' translation
 */
add_action( \'login_init\', function()
{
    add_filter( \'gettext\', \'wpse_back_to_site_text\', 10, 2 );
} );

function wpse_back_to_site_text( $translated, $untranslated )
{
    // Target the untranslated string
    if( \'&larr; Back to %s\' === $untranslated )
    {
        // Remove the filter callback
        remove_filter( current_filter(), __FUNCTION__ );

        // Modify the translation
        $translated = __( \'Back to %s\' );
    }
    return $translated;
}
我们在哪里开始我们的习惯gettext 筛选器回调,仅在login_init 钩子,将其限制为登录页面。

详情请参见sourcedetails

相关推荐