protected function validate_settings() { if (!$this->can_save()) { return; } if (!$this->settings['regenerate']) { unset($this->settings['regenerate']); if (defined('DOING_AJAX') && DOING_AJAX && !empty($_POST['module']) && $this->get_id() === $_POST['module']) { // Request to modify just this module. $this->set_can_save(false); if (ITSEC_Modules::get_setting('global', 'write_files')) { $this->add_error(new WP_Error('itsec-wordpress-salts-skipping-regeneration-empty-checkbox', __('You must check the Change WordPress Salts checkbox in order to change the WordPress salts.', 'better-wp-security'))); } else { $this->add_error(new WP_Error('itsec-wordpress-salts-skipping-regeneration-write-files-disabled', __('The "Write to Files" setting is disabled in Global Settings. In order to use this feature, you must enable the "Write to Files" setting.', 'better-wp-security'))); } } return; } unset($this->settings['regenerate']); require_once dirname(__FILE__) . '/utilities.php'; $result = ITSEC_WordPress_Salts_Utilities::generate_new_salts(); if (is_wp_error($result)) { $this->add_error($result); $this->set_can_save(false); } else { $this->add_message(__('The WordPress salts were successfully regenerated.', 'better-wp-security')); $this->settings['last_generated'] = ITSEC_Core::get_current_time_gmt(); ITSEC_Response::force_logout(); } }
protected function validate_settings() { if (!$this->can_save()) { return; } $previous_settings = ITSEC_Modules::get_settings($this->get_id()); if ($this->settings['admin'] !== $previous_settings['admin']) { ITSEC_Response::regenerate_wp_config(); if ($this->settings['admin']) { ITSEC_Response::force_logout(); } } }
protected function validate_settings() { if (!$this->can_save()) { return; } if (empty($this->settings['new_username']) || 'admin' === $this->settings['new_username']) { $this->settings['new_username'] = null; } if (is_null($this->settings['new_username']) && false === $this->settings['change_id']) { return; } $result = $this->change_admin_user($this->settings['new_username'], $this->settings['change_id']); if ($result) { $this->add_message(__('The user was successfully updated.', 'better-wp-security')); ITSEC_Response::set_show_default_success_message(false); ITSEC_Response::force_logout(); } else { $this->set_can_save(false); $this->add_error(new WP_Error('itsec-admin-user-failed-change-admin-user', __('The user was unable to be successfully updated. This could be due to a plugin or server configuration conflict.', 'better-wp-security'))); ITSEC_Response::set_show_default_error_message(false); } }