Example #1
0
 protected function validate_settings()
 {
     if (!$this->can_save()) {
         return;
     }
     $forbidden_slugs = array('admin', 'login', 'wp-login.php', 'dashboard', 'wp-admin');
     if (in_array($this->settings['slug'], $forbidden_slugs)) {
         $this->add_error(__('The Login Slug cannot be "%1$s" as WordPress uses that slug.', 'better-wp-security'));
         $this->set_can_save(false);
         return;
     }
     if ($this->settings['enabled'] && $this->settings['slug'] !== $this->previous_settings['slug']) {
         $url = get_site_url() . '/' . $this->settings['slug'];
         ITSEC_Response::add_message(sprintf(__('The Hide Backend feature is now active. Your new login URL is <strong><code>%1$s</code></strong>. Please note this may be different than what you sent as the URL was sanitized to meet various requirements. A reminder has also been sent to the notification email addresses set in iThemes Security\'s Global settings.', 'better-wp-security'), esc_url($url)));
     } else {
         if ($this->settings['enabled'] && !$this->previous_settings['enabled']) {
             $url = get_site_url() . '/' . $this->settings['slug'];
             ITSEC_Response::add_message(sprintf(__('The Hide Backend feature is now active. Your new login URL is <strong><code>%1$s</code></strong>. A reminder has also been sent to the notification email addresses set in iThemes Security\'s Global settings.', 'better-wp-security'), esc_url($url)));
         } else {
             if (!$this->settings['enabled'] && $this->previous_settings['enabled']) {
                 $url = get_site_url() . '/wp-login.php';
                 ITSEC_Response::add_message(sprintf(__('The Hide Backend feature is now disabled. Your new login URL is <strong><code>%1$s</code></strong>. A reminder has also been sent to the notification email addresses set in iThemes Security\'s Global settings.', 'better-wp-security'), esc_url($url)));
             }
         }
     }
     if (isset($url)) {
         $this->send_new_login_url($url);
         ITSEC_Response::prevent_modal_close();
     }
     if ($this->settings['enabled'] !== $this->previous_settings['enabled'] || $this->settings['slug'] !== $this->previous_settings['slug'] || $this->settings['register'] !== $this->previous_settings['register']) {
         ITSEC_Response::regenerate_server_config();
     }
     ITSEC_Response::reload_module($this->get_id());
 }