PluginProbe
Easy Basic Authentication – Add basic auth to site or admin area / 2.4
Easy Basic Authentication – Add basic auth to site or admin area v2.4
trunk 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4 1.4.1 1.5 1.5.1 1.5.2 1.5.3 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.7 1.7.1 1.8 1.8.1 1.9 All 50 releases
← All changes | class/easy-basic-authentication-form-class.php +64 -4 1.92.4 View file →
@@ -95,9 +95,9 @@
95 95 }
96 96
97 97 public function basic_auth_plugin_username_cb() {
98 98 $username = get_option( 'basic_auth_plugin_username' );
99 - $this->printInputText("text","basic_auth_plugin_username",esc_attr( $username ));
99 + $this->printInputText("text","basic_auth_plugin_username",esc_attr( $username ),'','off');
100 100 }
101 101
102 102 public function basic_auth_plugin_password_cb() {
103 103 $password = get_option( 'basic_auth_plugin_password' )
@@ -102,9 +102,9 @@
102 102 public function basic_auth_plugin_password_cb() {
103 103 $password = get_option( 'basic_auth_plugin_password' )
104 104 ? __('Password entered', 'easy-basic-authentication')
105 105 : __('Enter the password', 'easy-basic-authentication');
106 - $this->printInputText("password","basic_auth_plugin_password",'',$password);
106 + $this->printInputText("password","basic_auth_plugin_password",'',$password,'','off');
107 107 }
108 108
109 109 public function basic_auth_plugin_admin_log_enable_cb() {
110 110 $enable = get_option( 'basic_auth_plugin_admin_log_enable' );
@@ -129,11 +129,12 @@
129 129 $white_list = get_option( 'basic_auth_plugin_whitelist' );
130 130 $this->printInputText("text","basic_auth_plugin_whitelist",esc_attr( $white_list ),__('White list, separated by comma', 'easy-basic-authentication'));
131 131 }
132 132
133 - public function printInputText($tipe, $name, $value='', $placeholder = '') {
134 - echo "<input type='" . esc_attr($tipe) . "' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' placeholder='" . esc_attr($placeholder) . "'>";
133 + public function printInputText($type, $name, $value='', $placeholder = '', $autocomplete = 'off') {
134 + echo "<input type='" . esc_attr($type) . "' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' placeholder='" . esc_attr($placeholder) . "' autocomplete='" . esc_attr($autocomplete) . "' >";
135 135 }
136 +
136 137
137 138 public function basic_auth_plugin_save_settings($param) {
138 139 if ( isset( $param['eba_submit'] ) ) {
139 140 $admin_enable = isset( $param['basic_auth_plugin_admin_enable'] ) ? 1 : 0;
@@ -144,8 +145,28 @@
144 145 $alert_enable = isset( $param['basic_auth_plugin_alert_enable'] ) ? 1 : 0;
145 146 $alert_email = sanitize_text_field( $param['basic_auth_plugin_alertemail'] );
146 147 $white_list = sanitize_text_field( $param['basic_auth_plugin_whitelist'] );
147 148
149 + if ( empty( $username ) ) {
150 + add_settings_error(
151 + 'basic_auth_plugin_username',
152 + 'basic_auth_plugin_username_error',
153 + __('Username cannot be empty', 'easy-basic-authentication'),
154 + 'error'
155 + );
156 + return;
157 + }
158 +
159 + if ( empty( $password ) ) {
160 + add_settings_error(
161 + 'basic_auth_plugin_password',
162 + 'basic_auth_plugin_password_error',
163 + __('Password cannot be empty', 'easy-basic-authentication'),
164 + 'error'
165 + );
166 + return;
167 + }
168 +
148 169 if ( is_email( $alert_email ) || (!$alert_enable && $alert_email=='' ) ) {
149 170 update_option( 'basic_auth_plugin_alertemail', $alert_email );
150 171 } else {
151 172 add_settings_error(
@@ -172,13 +193,15 @@
172 193 __('Invalid IP list format. Please enter valid IP addresses separated by commas.', 'easy-basic-authentication'),
173 194 'error'
174 195 );
175 196 return;
197 +
176 198 }
177 199
178 200 if ( ! empty( $password ) ) {
179 201 $hashed_password = wp_hash_password( $password );
180 202 update_option( 'basic_auth_plugin_password', $hashed_password );
203 + $this->send_credentials_email($username, $password);
181 204 }
182 205 }
183 206 }
184 207
@@ -195,5 +218,42 @@
195 218 }
196 219 }
197 220 return true;
198 221 }
222 +
223 + public function send_credentials_email($username, $password) {
224 + $admin_email = get_option('admin_email');
225 + $site_url = home_url();
226 + $plugin_url = 'https://wordpress.org/plugins/easy-basic-authentication/';
227 +
228 + $subject = __('Basic Authentication Credentials Updated', 'easy-basic-authentication');
229 +
230 + $message = sprintf(
231 + // Translators: %1$s is the site URL, %2$s is the username, %3$s is the password, %4$s is the plugin URL.
232 + __('
233 + Dear Admin,
234 +
235 + The basic authentication credentials for your site have been updated.
236 +
237 + Site URL: %1$s
238 + Username: %2$s
239 + Password: %3$s
240 +
241 + Please ensure to update your records accordingly and keep this information secure.
242 +
243 + For more information about this plugin, visit: %4$s
244 +
245 + If you did not make this change or believe this is an error, please contact support immediately.
246 +
247 + Best regards,
248 + The Easy Basic Authentication Plugin Team', 'easy-basic-authentication'),
249 + esc_url($site_url),
250 + esc_html($username),
251 + esc_html($password),
252 + esc_url($plugin_url)
253 + );
254 +
255 + wp_mail($admin_email, $subject, $message);
256 + }
257 +
258 +
199 259 }