private function set_translation_strings() { $this->translations = array('save_settings' => __('Save Settings', 'better-wp-security'), 'close_settings' => __('Close', 'better-wp-security'), 'show_settings' => __('Configure Settings', 'better-wp-security'), 'hide_settings' => __('Hide Settings', 'better-wp-security'), 'show_description' => __('Learn More', 'better-wp-security'), 'hide_description' => __('Hide Details', 'better-wp-security'), 'show_information' => __('Show Details', 'better-wp-security'), 'activate' => __('Enable', 'better-wp-security'), 'deactivate' => __('Disable', 'better-wp-security'), 'error' => __('Error', 'better-wp-security'), 'successful_save' => __('Settings saved successfully for %1$s.', 'better-wp-security'), 'ajax_invalid' => new WP_Error('itsec-settings-page-invalid-ajax-response', __('An "invalid format" error prevented the request from completing as expected. The format of data returned could not be recognized. This could be due to a plugin/theme conflict or a server configuration issue.', 'better-wp-security')), 'ajax_forbidden' => new WP_Error('itsec-settings-page-forbidden-ajax-response: %1$s "%2$s"', __('A "request forbidden" error prevented the request from completing as expected. The server returned a 403 status code, indicating that the server configuration is prohibiting this request. This could be due to a plugin/theme conflict or a server configuration issue. Please try refreshing the page and trying again. If the request continues to fail, you may have to alter plugin settings or server configuration that could account for this AJAX request being blocked.', 'better-wp-security')), 'ajax_not_found' => new WP_Error('itsec-settings-page-not-found-ajax-response: %1$s "%2$s"', __('A "not found" error prevented the request from completing as expected. The server returned a 404 status code, indicating that the server was unable to find the requested admin-ajax.php file. This could be due to a plugin/theme conflict, a server configuration issue, or an incomplete WordPress installation. Please try refreshing the page and trying again. If the request continues to fail, you may have to alter plugin settings, alter server configurations, or reinstall WordPress.', 'better-wp-security')), 'ajax_server_error' => new WP_Error('itsec-settings-page-server-error-ajax-response: %1$s "%2$s"', __('A "internal server" error prevented the request from completing as expected. The server returned a 500 status code, indicating that the server was unable to complete the request due to a fatal PHP error or a server problem. This could be due to a plugin/theme conflict, a server configuration issue, a temporary hosting issue, or invalid custom PHP modifications. Please check your server\'s error logs for details about the source of the error and contact your hosting company for assistance if required.', 'better-wp-security')), 'ajax_unknown' => new WP_Error('itsec-settings-page-ajax-error-unknown: %1$s "%2$s"', __('An unknown error prevented the request from completing as expected. This could be due to a plugin/theme conflict or a server configuration issue.', 'better-wp-security')), 'ajax_timeout' => new WP_Error('itsec-settings-page-ajax-error-timeout: %1$s "%2$s"', __('A timeout error prevented the request from completing as expected. The site took too long to respond. This could be due to a plugin/theme conflict or a server configuration issue.', 'better-wp-security')), 'ajax_parsererror' => new WP_Error('itsec-settings-page-ajax-error-parsererror: %1$s "%2$s"', __('A parser error prevented the request from completing as expected. The site sent a response that jQuery could not process. This could be due to a plugin/theme conflict or a server configuration issue.', 'better-wp-security'))); foreach ($this->translations as $key => $message) { if (is_wp_error($message)) { $messages = ITSEC_Response::get_error_strings($message); $this->translations[$key] = $messages[0]; } } }
public function handle_ajax_request($data) { global $itsec_backup; if (!isset($itsec_backup)) { require_once 'class-itsec-backup.php'; $itsec_backup = new ITSEC_Backup(); $itsec_backup->run(); } $result = $itsec_backup->do_backup(true); $message = ''; if (is_wp_error($result)) { $errors = ITSEC_Response::get_error_strings($result); foreach ($errors as $error) { $message .= '<div class="error inline"><p><strong>' . $error . '</strong></p></div>'; } } else { if (is_string($result)) { $message = '<div class="updated fade inline"><p><strong>' . $result . '</strong></p></div>'; } else { $message = '<div class="error inline"><p><strong>' . sprintf(__('The backup request returned an unexpected response. It returned a response of type <code>%1$s</code>.', 'better-wp-security'), gettype($result)) . '</strong></p></div>'; } } ITSEC_Response::set_response($message); }