Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions gravity-forms/gw-zip-files.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public function create_zip( $files = array(), $destination = '', $overwrite = fa

public function get_zip_paths( $entry, $type = false ) {

$filename = $this->get_zip_filename( $entry['id'] );
$filename = $this->get_zip_filename( $entry );
$paths = GFFormsModel::get_file_upload_path( $entry['form_id'], $filename );

foreach ( $paths as &$path ) {
Expand All @@ -315,8 +315,12 @@ public function get_zip_paths( $entry, $type = false ) {
return $type ? rgar( $paths, $type ) : $paths;
}

public function get_zip_filename( $entry_id ) {
return $this->get_slug( $this->_args['zip_name'], $entry_id, $this->_args['field_ids'] ) . '.zip';
public function get_zip_filename( $entry ) {
$form_id = $entry['form_id'];
$form = GFAPI::get_form( $form_id );
// replace merge tags in the zip file name
$zip_name = GFCommon::replace_variables( $this->_args['zip_name'], $form, $entry, false, false, false, 'text' );
return $this->get_slug( $zip_name, false, $this->_args['field_ids'] ) . '.zip';
}

public function get_meta_key( $entry_id = false ) {
Expand Down Expand Up @@ -475,7 +479,7 @@ public function add_zip_as_attachment( $notification, $form, $entry ) {
new GW_Zip_Files(
array(
'form_id' => 123,
'zip_name' => 'my-sweet-archive',
'zip_name' => 'my-sweet-archive', // supports merge tags
'notifications' => array( '5f4668ec2afbb' ),
)
);
Loading