Skip to content

Commit

Permalink
new : array as string if one value
Browse files Browse the repository at this point in the history
  • Loading branch information
encreinformatique committed Feb 14, 2022
1 parent b8ccefe commit 26c2950
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contact-form-reinerouge.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Author URI: https://tousleshoraires.com
Text Domain: contact-form-rr7
Domain Path: /languages/
Version: 1.2
Version: 1.3
*/

if (!defined('ABSPATH')) {
Expand Down
1 change: 1 addition & 0 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ final class Collection
{
public const DOMAIN = 'contact-form-rr7';
public const NAME = 'ReineRouge - Contact Form 7 add-on';
public const VERSION = '1.3';

/**
* Instance
Expand Down
22 changes: 22 additions & 0 deletions src/Exporter/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ private function computeFields(array $form_data): array
unset($form_data[$rr_form_city]);
}

$form_data = $this->arrayAsString($form_data);

return $form_data;
}

Expand All @@ -212,4 +214,24 @@ private function mandatoryFields(array $form_data): array

return $form_data;
}

/**
* Transform the arrays into string value only if array length is equal to 1.
*
* @param array $form_data Array of data from CF7
*
* @return array
*
* @since 1.3.0
*/
private function arrayAsString(array $form_data): array
{
foreach ($form_data as $field => $value) {
if (\is_array($value) && \count($value) === 1) {
$form_data[$field] = $value;
}
}

return $form_data;
}
}

0 comments on commit 26c2950

Please sign in to comment.