open( $tmp_file, ZipArchive::CREATE | ZipArchive::OVERWRITE ) ) { wp_die( esc_html__( 'Could not open temporary engine file matrix layer safely.', 'af-translate' ) ); } $zip->addFile( $po_target, basename( $po_target ) ); // Match and inject compiled binary machine code pairs automatically if ( file_exists( $mo_target ) ) { $is_mo_safe = false; if ( class_exists( 'AF_Translate_Path_Validator' ) ) { $is_mo_safe = AF_Translate_Path_Validator::validate_containment( $mo_target, false ); } elseif ( class_exists( 'AF_Translate_Project_Config' ) ) { $is_mo_safe = AF_Translate_Project_Config::validate_file_path_containment( $mo_target ); } if ( $is_mo_safe ) { $zip->addFile( $mo_target, basename( $mo_target ) ); } } $zip->close(); // 4. CRITICAL: Purge Active Output Buffer Layers to Secure ZIP Integrity while ( ob_get_level() ) { ob_end_clean(); } // 5. Emit Stream Transmission Payload Control Headers header( 'Content-Type: application/zip' ); header( 'Content-Disposition: attachment; filename="' . basename( $zip_name ) . '"' ); header( 'Content-Length: ' . filesize( $tmp_file ) ); header( 'Pragma: no-cache' ); header( 'Expires: 0' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile -- Direct file stream passthru required for memory-efficient browser download proxying. readfile( $tmp_file ); wp_delete_file( $tmp_file ); exit; } }