Created
December 22, 2013 10:08
-
-
Save skylarkcob/8080539 to your computer and use it in GitHub Desktop.
Chỉnh sửa lại giao diện và thông báo trang đăng nhập WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Sau Login | |
* Plugin URI: http://hocwp.net | |
* Description: You can use this plugin to create a custom login page. | |
* Version: 1.2 | |
* Author: Sau Hi | |
* Author URI: http://hocwp.net | |
* License: GNU General Public License v3.0 | |
*/ | |
// Change logo url | |
function change_logo_url() | |
{ | |
return home_url('/'); | |
} | |
add_filter( 'login_headerurl', 'change_logo_url' ); | |
// Change logo title | |
function change_logo_title() | |
{ | |
return get_bloginfo('description'); | |
} | |
add_filter( 'login_headertitle', 'change_logo_title' ); | |
// Change logo image | |
function change_logo_image() | |
{ | |
echo '<link media="all" type="text/css" href="'.plugins_url('css/style.css', __FILE__).'" id="sau-login-css" rel="stylesheet">'; | |
} | |
add_action( 'login_enqueue_scripts', 'change_logo_image' ); | |
function custom_login_message($message) | |
{ | |
$action = $_REQUEST['action']; | |
if($action == 'register') | |
{ | |
$message = '<p class="message register">Đăng ký làm thành viên.</p>'; | |
} | |
elseif($action == 'lostpassword') | |
{ | |
$message = '<p class="message">Hãy điền vào địa chỉ email của bạn để lấy lại mật khẩu.</p>'; | |
} | |
return $message; | |
} | |
add_filter('login_message', 'custom_login_message'); | |
function custom_login_error($error) | |
{ | |
if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'lostpassword') | |
{ | |
$error = '<strong>Lỗi:</strong> Xin vui lòng nhập chính xác địa chỉ email.'; | |
} | |
elseif(isset($_REQUEST['registration']) && $_REQUEST['registration'] == 'disabled') | |
{ | |
$error = '<strong>Lỗi:</strong> Hệ thống không cho phép đăng ký tài khoản.'; | |
} | |
else | |
{ | |
$error = '<strong>Đăng nhập thất bại:</strong> Xin vui lòng nhập đúng tên tài khoản và mật khẩu của bạn.'; | |
} | |
return $error; | |
} | |
add_filter( 'login_errors', 'custom_login_error' ); | |
function change_form_text( $translation, $text ) | |
{ | |
if ( 'Username' == $text ) { return 'Tên tài khoản'; } | |
if ( 'Password' == $text ) { return 'Mật khẩu'; } | |
if ( 'Remember Me' == $text ) { return 'Nhớ đăng nhập'; } | |
if ( 'Log In' == $text || 'Log in' == $text ) { return 'Đăng nhập'; } | |
if ( 'Lost your password?' == $text ) { return 'Quên mật khẩu?'; } | |
if ( '← Back to %s' == $text ) { return 'Quay lại trang chủ'; } | |
if ( 'Register' == $text ) { return 'Đăng ký'; } | |
if ( 'E-mail' == $text ) { return 'Địa chỉ email'; } | |
if ( 'A password will be e-mailed to you.' == $text ) { return 'Mật khẩu sẽ được chuyển đến email của bạn.'; } | |
if ( 'Username or E-mail:' == $text ) { return 'Tên tài khoản hoặc địa chỉ email'; } | |
if ( 'Get New Password' == $text ) { return 'Nhận mật khẩu mới'; } | |
if ( 'You are now logged out.' == $text ) { return 'Bạn đã đăng xuất khỏi hệ thống.'; } | |
return $translation; | |
} | |
add_filter( 'gettext', 'change_form_text', 10, 2 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment