PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/component/security-tweaks/class-change-admin.php +34 -17 5.4.1 → 6.3.0 View file →
@@ -92,25 +92,25 @@
92 92 *
93 93 * @return bool|WP_Error on failure
94 94 */
95 95 private function validate( $username ) {
96 - if ( empty( $username ) ) {
97 - return new WP_Error( 'defender_invalid_username', esc_html__( 'The username can\'t be empty!', 'defender-security' ) );
96 + if ( ! is_string( $username ) || '' === $username ) {
97 + return new WP_Error( 'defender_invalid_username', wp_strip_all_tags( __( 'The username can\'t be empty!', 'defender-security' ) ) );
98 98 }
99 99
100 100 if ( 'admin' === strtolower( $username ) ) {
101 101 return new WP_Error(
102 102 'defender_invalid_username',
103 - esc_html__( 'You can\'t use admin as a username again!', 'defender-security' )
103 + wp_strip_all_tags( __( 'You can\'t use admin as a username again!', 'defender-security' ) )
104 104 );
105 105 }
106 106
107 107 if ( ! validate_username( $username ) ) {
108 - return new WP_Error( 'defender_invalid_username', esc_html__( 'The username is invalid!', 'defender-security' ) );
108 + return new WP_Error( 'defender_invalid_username', wp_strip_all_tags( __( 'The username is invalid!', 'defender-security' ) ) );
109 109 }
110 110
111 111 if ( username_exists( $username ) ) {
112 - return new WP_Error( 'defender_invalid_username', esc_html__( 'The username already exists!', 'defender-security' ) );
112 + return new WP_Error( 'defender_invalid_username', wp_strip_all_tags( __( 'The username already exists!', 'defender-security' ) ) );
113 113 }
114 114
115 115 return true;
116 116 }
@@ -193,9 +193,9 @@
193 193 *
194 194 * @return string
195 195 */
196 196 public function get_label(): string {
197 - return esc_html__( 'Change default admin user account', 'defender-security' );
197 + return esc_html__( 'Change admin account', 'defender-security' );
198 198 }
199 199
200 200 /**
201 201 * Get the error reason.
@@ -202,9 +202,14 @@
202 202 *
203 203 * @return string
204 204 */
205 205 public function get_error_reason(): string {
206 - return esc_html__( 'You have a user account with the admin username.', 'defender-security' );
206 + return wp_kses(
207 + __( '<strong>Your account uses the default “admin” username,</strong> and may attract login attacks.', 'defender-security' ),
208 + array(
209 + 'strong' => array(),
210 + )
211 + );
207 212 }
208 213
209 214 /**
210 215 * Return a summary data of this tweak.
@@ -211,21 +216,33 @@
211 216 *
212 217 * @return array
213 218 */
214 219 public function to_array(): array {
220 + $admin_user = $this->get_user_with_admin_username();
221 + $current_user = wp_get_current_user();
222 + $username = $admin_user ? $admin_user->user_login : $current_user->user_login;
223 + $error_reason = wp_kses(
224 + sprintf(
225 + /* translators: %s: Username. */
226 + __( '<strong>Your account uses the default "%s" username,</strong> and may attract login attacks.', 'defender-security' ),
227 + esc_html( $username )
228 + ),
229 + array(
230 + 'strong' => array(),
231 + )
232 + );
233 +
215 234 return array(
216 235 'slug' => $this->slug,
217 236 'title' => $this->get_label(),
218 - 'errorReason' => $this->get_error_reason(),
219 - 'successReason' => esc_html__(
220 - 'You don\'t have a user account with the default admin username, great!',
221 - 'defender-security'
237 + 'errorReason' => $error_reason,
238 + 'successReason' => wp_strip_all_tags( __( 'Username is up to date.', 'defender-security' ) ),
239 + 'misc' => array(
240 + 'show_revert_button' => false,
241 + 'show_action_button' => true,
242 + 'admin_username' => $username,
222 243 ),
223 - 'misc' => array( 'host' => defender_get_hostname() ),
224 - 'bulk_description' => esc_html__(
225 - 'Using the default admin username is widely considered bad practice and opens you up to the easitest form of entry to your website. We will create new admin username for you.',
226 - 'defender-security'
227 - ),
228 - 'bulk_title' => esc_html__( 'Admin User', 'defender-security' ),
244 + 'bulk_description' => wp_strip_all_tags( __( 'Brute force attacks often rely on common usernames and guessed passwords. Create a new admin username to make your site harder to target and help protect your login area.', 'defender-security' ) ),
245 + 'bulk_title' => wp_strip_all_tags( __( 'Admin User', 'defender-security' ) ),
229 246 );
230 247 }
231 248 }