PluginProbe
Admin and Site Enhancements (ASE) / 7.5.3
Admin and Site Enhancements (ASE) v7.5.3
9.1.1 9.1.0 9.0.2 9.0.1 9.0.0 8.9.2 8.9.1 8.9.0 8.8.8 8.8.7 8.8.6 8.8.5 8.8.4 8.8.3 8.8.2 8.8.1 8.8.0 8.7.3 8.7.2 8.7.1 8.2.1 8.2.2 8.2.3 8.3.0 8.3.1 All 273 releases
admin-site-enhancements / classes / class-login-id-type.php
class-login-id-type.php
80 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ASENHA\Classes;
4
5 use WP_Error;
6
7 /**
8 * Class for Login ID Type module
9 *
10 * @since 6.9.5
11 */
12 class Login_ID_Type {
13
14 /**
15 * Change default label on login form
16 *
17 * @param array $defaults an array of default login form arguments
18 * @link https://plugins.trac.wordpress.org/browser/xo-security/tags/3.7.1/inc/class-xo-security.php
19 * @since 6.8.0
20 */
21 public function change_login_form_defaults( $defaults ) {
22 $defaults['label_username'] = __( 'Username', 'admin-site-enhancements' );
23 return $defaults;
24 }
25
26 /**
27 * Filter for gettext.
28 *
29 * @param string $translation Translated text.
30 * @param string $text Text to translate.
31 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
32 * @link https://plugins.trac.wordpress.org/browser/xo-security/tags/3.7.1/inc/class-xo-security.php
33 * @since 6.8.0
34 */
35 public function gettext_login_id_username( $translation, $text, $domain ) {
36 global $pagenow;
37 if ( 'wp-login.php' === $pagenow ) {
38 if ( 'default' === $domain && 'Username or Email Address' === $text ) {
39 $translation = __( 'Username', 'admin-site-enhancements' );
40 }
41 }
42 return $translation;
43 }
44
45 /**
46 * Filter for authenticate.
47 *
48 * @param WP_User|Mixed $user user object if authenticated.
49 * @param String $username username.
50 * @return WP_User|Mixed authenticated user or error.
51 * @link https://plugins.trac.wordpress.org/browser/xo-security/tags/3.7.1/inc/class-xo-security.php
52 * @since 6.8.0
53 */
54 public function authenticate_email( $user, $username ) {
55 if ( null !== $user && ! is_wp_error( $user ) && $user->user_email !== $username ) {
56 $user = new WP_Error( 'invalid_username', __( '<strong>Error:</strong> Invalid email or incorrect password.', 'admin-site-enhancements' ) );
57 }
58 return $user;
59 }
60
61 /**
62 * Filter for gettext.
63 *
64 * @param string $translation Translated text.
65 * @param string $text Text to translate.
66 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
67 * @return WP_User|Mixed authenticated user or error.
68 * @link https://plugins.trac.wordpress.org/browser/xo-security/tags/3.7.1/inc/class-xo-security.php
69 */
70 public function gettext_login_id_email( $translation, $text, $domain ) {
71 global $pagenow;
72 if ( 'wp-login.php' === $pagenow ) {
73 if ( 'default' === $domain && 'Username or Email Address' === $text ) {
74 $translation = __( 'Email', 'admin-site-enhancements' );
75 }
76 }
77 return $translation;
78 }
79
80 }