$api_args ); if ( ! is_wp_error($request) ) { $request = json_decode( wp_remote_retrieve_body($request) ); // Set Status if ( ! empty($request) ) { if ($request->status == 'subscribed') { wp_send_json_success(array( 'action' => 'wpr_form_builder_mailchimp', 'status' => 'success', 'message' => 'Mailchimp subscription was successful', 'request' => $request )); } else { wp_send_json_error([ 'action' => 'wpr_form_builder_mailchimp', 'status' => 'error', 'message' => 'Mailchimp subscription failed', 'request' => $request ]); } } } else { wp_send_json_error([ 'action' => 'wpr_form_builder_mailchimp', 'status' => 'error', 'message' => 'Mailchimp subscription failed', 'request' => $request ]); } } public static function group_ids_to_interests_array($group_ids) { $interests_array = []; foreach ($group_ids as $group_id) { $interests_array[$group_id] = true; } return $interests_array; } } new WPR_Subscribe_Mailchimp();ings.service.signup-link-cache'); $logger = $c->get('woocommerce.logger.woocommerce'); assert($logger instanceof LoggerInterface); $logger->info('Flushing API caches...'); foreach ($caches as $cache_id) { $cache = $c->get($cache_id); assert($cache instanceof Cache); $cache->flush(); } }); /** * Filters the request arguments to add the `'PayPal-Partner-Attribution-Id'` header. * * This ensures that all API requests include the appropriate BN code retrieved * from the `PartnerAttribution` helper. Using this approach avoids the need * for extensive refactoring of existing classes that use the `RequestTrait`. * * The filter is applied in {@see RequestTrait::request()} before making an API request. * * @see PartnerAttribution::get_bn_code() Retrieves the BN code dynamically. * @see RequestTrait::request() Where the filter `ppcp_request_args` is applied. */ add_filter('ppcp_request_args', static function (array $args) use ($c) { if (isset($args['headers']['PayPal-Partner-Attribution-Id'])) { return $args; } $partner_attribution = $c->get('api.helper.partner-attribution'); assert($partner_attribution instanceof PartnerAttribution); if (!isset($args['headers']) || !is_array($args['headers'])) { $args['headers'] = array(); } $args['headers']['PayPal-Partner-Attribution-Id'] = $partner_attribution->get_bn_code(); return $args; }); return \true; } }