nonce; if (!$nonce) { return new WP_Error('nonce_not_found', esc_html__('Nonce not found.', 'aesirx-consent')); } // Validate network using extracted details $validate_nonce = parent::aesirx_analytics_validate_string($nonce, $params['wallet'], $params['request']['signature']); if (!$validate_nonce || is_wp_error($validate_nonce)) { return new WP_Error('validation_error', esc_html__('Nonce is not valid', 'aesirx-consent')); } if (isset($params['token']) && $params['token']) { $validate_contract = parent::aesirx_analytics_validate_contract($params['token']); if (!$validate_contract || is_wp_error($validate_contract)) { return new WP_Error('validation_error', esc_html__('Contract is not valid', 'aesirx-consent')); } } // Expire the consent $expiration = gmdate('Y-m-d H:i:s'); $consent_uuid = sanitize_text_field($params['consent_uuid']); $result = parent::aesirx_analytics_expired_consent($consent_uuid, $expiration); if ($result === false || is_wp_error($result)) { return new WP_Error('update_failed', esc_html__('Failed to update consent expiration.', 'aesirx-consent')); } // Update the nonce to None (NULL in this context) $result = parent::aesirx_analytics_update_nonce($network, $wallet, null); if ($result === false) { return new WP_Error('nonce_update_failed', esc_html__('Failed to update nonce.', 'aesirx-consent')); } return true; } }