Automattic\WooCommerce\Internal\Admin\Logging\FileV2
FileController::export_multiple_files()
Create a zip archive of log files and stream it to the browser.
Метод класса: FileController{}
Хуков нет.
Возвращает
WP_Error|null
. Only returns something if there is an error.
Использование
$FileController = new FileController(); $FileController->export_multiple_files( $file_ids );
- $file_ids(массив) (обязательный)
- An array of file IDs (file basename without the hash).
Код FileController::export_multiple_files() FileController::export multiple files WC 9.7.1
public function export_multiple_files( array $file_ids ) { $files = $this->get_files_by_id( $file_ids ); if ( count( $files ) < 1 ) { return new WP_Error( 'wc_logs_invalid_file', __( 'Could not access the specified files.', 'woocommerce' ) ); } $temp_dir = get_temp_dir(); if ( ! is_dir( $temp_dir ) || ! wp_is_writable( $temp_dir ) ) { return new WP_Error( 'wc_logs_invalid_directory', __( 'Could not write to the temp directory. Try downloading files one at a time instead.', 'woocommerce' ) ); } require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $path = trailingslashit( $temp_dir ) . 'woocommerce_logs_' . gmdate( 'Y-m-d_H-i-s' ) . '.zip'; $file_paths = array_map( fn( $file ) => $file->get_path(), $files ); $archive = new PclZip( $path ); $archive->create( $file_paths, PCLZIP_OPT_REMOVE_ALL_PATH ); $exporter = new FileExporter( $path ); return $exporter->emit_file(); }