LLMS_Privacy_Exporters::maybe_add_export_files( string $archive_pathname, string $archive_url, string $html_report_pathname, int $request_id )
Add files to the zip file for a data export request Adds certificate files into the /certificates/ directory within the archive
Description Description
Parameters Parameters
- $archive_pathname
-
(string) (Required) full path to the zip archive
- $archive_url
-
(string) (Required) full uri to the zip archive
- $html_report_pathname
-
(string) (Required) full path to the .html file within the archive
- $request_id
-
(int) (Required) WP Post ID of the export request
Return Return
(void)
Source Source
File: includes/privacy/class-llms-privacy-exporters.php
public static function maybe_add_export_files( $archive_pathname, $archive_url, $html_report_pathname, $request_id ) { if ( ! class_exists( 'ZipArchive' ) ) { return; } $request = wp_get_user_request_data( $request_id ); $student = self::get_student_by_email( $request->email ); if ( ! $student ) { return; } $certs = self::get_student_certificates( $student ); if ( ! $certs ) { return; } $zip = new ZipArchive(); $delete = array(); if ( true === $zip->open( $archive_pathname ) ) { foreach ( $certs as $cert ) { $filepath = LLMS()->certificates()->get_export( $cert->get( 'id' ), true ); $delete[ $cert->certificate_id ] = $filepath; if ( is_wp_error( $filepath ) ) { continue; } $zip->addFile( $filepath, '/certificates/' . basename( $filepath ) ); } } $zip->close(); // cleanup all files foreach ( $delete as $id => $path ) { wp_delete_file( $path ); delete_post_meta( $id, '_llms_export_filepath' ); } }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.18.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: