2.12 ログイン画面の表示修正

 ログイン画面で“パスワードをお忘れですか ?”をクリックすると、WordPressシステムからメールがユーザーに自動送信されます。操作方法が一般ユーザーにはわかりづらいですし、どのみち管理者が対応することになるので非表示にします。

 直接関係する適当なフックがなく、スタイルシートにも適当なものがないため、翻訳を修正します。利用しているフックは、翻訳のフックです。
 下記の修正を行います。
 ・“パスワードをお忘れですか ?”を削除
 ・“(サイト名)へ戻る”をついでに削除
 ・“エラー: 無効なユーザー名です。 パスワードをお忘れですか ?”を修正
 ・“エラー: 入力されたユーザー名 ○○ のパスワードが違います。パスワードをお忘れですか ?”を修正

コード

// --------------------------------
// ログイン画面の表示修正
// --------------------------------
function hk_functions_gettext( $translations, $text ) {
    global $pagenow;
    if ( $pagenow != 'wp-login.php' )            return $translations;
    if ( $text == 'Lost your password?' )        return '';
    if ( $text == '← Back to %s' )          return '';
    if ( $text == '<strong>ERROR</strong>: Invalid username. <a href="%s">Lost your password?</a>' )
        return '<strong>エラー</strong>: 無効なユーザー名です。';
    if ( $text == '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s">Lost your password?</a>' )
        return '<strong>エラー</strong>: 入力されたパスワードが違います。';
    return $translations;
}
add_filter( 'gettext', 'hk_functions_gettext', 10, 2 );

 このプログラムをお使いになる場合は、お使いになる方の自己責任でお願いします。

更新日:2015/11/13
掲載日:2015/11/13