Ejemplo n.º 1
0
 public function set_all($settings)
 {
     $retval = array('old_settings' => $this->settings, 'new_settings' => $this->settings, 'errors' => array(), 'messages' => array(), 'saved' => false);
     $validator = ITSEC_Modules::get_validator($this->get_id());
     if (is_null($validator)) {
         $retval['errors'][] = new WP_Error('itsec-settings-missing-validator-for-' . $this->get_id(), sprintf(__('The data validator for %1$s is missing. Data for the module cannot be saved without the validator. This error could indicate a bad install of iThemes Security. Please remove the plugin and reinstall it. If this message persists, please contact support and send them this error message.', 'better-wp-security'), $this->get_id()));
     } else {
         $validator->validate($settings);
         $retval['errors'] = $validator->get_errors();
         $retval['messages'] = $validator->get_messages();
         if ($validator->can_save()) {
             $this->settings = $validator->get_settings();
             ITSEC_Storage::set($this->get_id(), $this->settings);
             $this->after_save();
             $this->handle_settings_changes($retval['old_settings']);
             $retval['new_settings'] = $this->settings;
             $retval['saved'] = true;
         } else {
             ITSEC_Response::set_success(false);
         }
     }
     ITSEC_Response::add_errors($retval['errors']);
     ITSEC_Response::add_messages($retval['messages']);
     return $retval;
 }
Ejemplo n.º 2
0
 public function handle_form_post($data)
 {
     require_once dirname(__FILE__) . '/utility.php';
     if (isset($data['change_prefix']) && 'yes' === $data['change_prefix']) {
         $result = ITSEC_Database_Prefix_Utility::change_database_prefix();
         ITSEC_Response::add_errors($result['errors']);
         ITSEC_Response::reload_module($this->id);
         if (false === $result['new_prefix']) {
             ITSEC_Response::set_success(false);
         } else {
             /* translators: 1: New database table prefix */
             ITSEC_Response::add_message(sprintf(__('The database table prefix was successfully changed to <code>%1$s</code>.', 'better-wp-security'), $result['new_prefix']));
         }
     }
 }
Ejemplo n.º 3
0
 public function handle_form_post($data)
 {
     require_once dirname(__FILE__) . '/utility.php';
     if (!empty($data['new_directory_name'])) {
         $results = ITSEC_Content_Directory_Utility::change_content_directory($data['new_directory_name']);
         if (is_wp_error($results)) {
             ITSEC_Response::add_error($results);
             ITSEC_Response::add_error(new WP_Error('itsec-content-directory-settings-page-unable-to-change-content-directory', __('Unable to change the content directory. If the above error cannot be fixed, you may need to manually change the content directory. Instructions on how to change the content directory manually can be found <a href="https://codex.wordpress.org/Editing_wp-config.php#Moving_wp-content_folder">here</a>.', 'better-wp-security')));
             ITSEC_Response::set_success(false);
         } else {
             /* translators: 1: New directory name */
             ITSEC_Response::add_message(sprintf(__('The content directory was successfully changed to <code>%1$s</code>.', 'better-wp-security'), $results));
             ITSEC_Response::reload_module($this->id);
         }
     } else {
         if (isset($data['undo_change']) && 'yes' === $data['undo_change']) {
             $results = ITSEC_Content_Directory_Utility::change_content_directory('wp-content');
             if (is_wp_error($results)) {
                 ITSEC_Response::add_error($results);
                 ITSEC_Response::add_error(new WP_Error('itsec-content-directory-settings-page-unable-to-undo-content-directory-change', __('Unable to change the content directory back to <code>wp-content</code>. If the above error cannot be fixed, you may need to manually change the content directory. Instructions on how to change the content directory manually can be found <a href="https://codex.wordpress.org/Editing_wp-config.php#Moving_wp-content_folder">here</a>.', 'better-wp-security')));
                 ITSEC_Response::set_success(false);
             } else {
                 /* translators: 1: New directory name */
                 ITSEC_Response::add_message(sprintf(__('The content directory was successfully changed back to <code>%1$s</code>.', 'better-wp-security'), $results));
                 ITSEC_Response::reload_module($this->id);
             }
         }
     }
 }