Skip to content

Commit

Permalink
fix site transient for gdpr field response
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhungate committed Sep 21, 2020
1 parent 5f1151f commit 9b13927
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions includes/api/class-mailchimp-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1596,13 +1596,13 @@ public function getCachedGDPRFields($list_id, $minutes = 5)
$GDPRfields = get_site_transient($transient);

// only return the values if it's a false - or an array
if ($GDPRfields === false || is_array($GDPRfields)) return $GDPRfields;
if (is_array($GDPRfields)) return $GDPRfields;

try {
$GDPRfields = $this->getGDPRFields($list_id);
set_site_transient($transient, $GDPRfields, 60 * $minutes);
} catch (\Exception $e) {
$GDPRfields = false;
$GDPRfields = array();
}

return $GDPRfields;
Expand Down
3 changes: 2 additions & 1 deletion includes/class-mailchimp-woocommerce-newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public function applyNewsletterField($checkout)
$checkbox .= '</p>';
$checkbox .= '<div class="clear"></div>';

if ($GDPRfields) {
// only render these fields if it's an array that has valid data.
if (!empty($GDPRfields) && is_array($GDPRfields)) {
$checkbox .= "<div id='mailchimp-gdpr-fields'><p>";
$checkbox .= __('Please select all the ways you would like to hear from us', 'mailchimp-for-woocommerce');
$checkbox .= "<div class='clear'></div>";
Expand Down

0 comments on commit 9b13927

Please sign in to comment.