$sanitized_context, 'error_message' => $sanitized_error_message, 'timestamp' => $sanitized_timestamp ); $sanitized_errors = array_map( function( $error ) { return array( 'context' => sanitize_text_field( $error['context'] ), 'error_message' => sanitize_text_field( $error['error_message'] ), 'timestamp' => sanitize_text_field( $error['timestamp'] ), ); }, $errors ); // Update the option with the new error log update_option('cmplz_wsc_logs', $sanitized_errors, false); } /** * Retrieves all logged errors from the WordPress options. * * @return array The array of logged errors. */ public function get_errors_log(): array { // Retrieve the errors stored in the WordPress option return get_option('cmplz_wsc_logs', array()); } /** * Clears all logged errors from the WordPress options. */ public function clear_errors_log(): void { // Delete the option to clear all stored errors delete_option('cmplz_wsc_logs'); } } }