AffiliateWP 2.7.2 has been released

It was a busy week this week in core development. We shipped AffiliateWP 2.7.1 on Monday and followed that up with another small 2.7.2 release yesterday.

Here is the combined changelog:

  • New: Add specialized cookie handling for the Pantheon edge network
  • Improved: Notate in the System Info log whether the site is running on the Pantheon edge network
  • Improved: Pass the referral object to the affwp_auto_complete_referral filter
  • Improved: Add select2 to core for add-ons to use
  • Fixed: affwp_is_affiliate query variable only works in admin areas

Pantheon cookie policy

Of particular note in these releases is full compatibility with Pantheon’s cookie naming policy. To support this compatibility, we’ve introduced a new helper method to the tracking class, get_cookie_name(), which will prefix any built-in and third-party cookies with ‘wp-‘ when Pantheon is detected.

get_cookie_name() usage

Integrating third-party cookies with get_cookie_name() is straightforward. Cookie names can be supplied to the helper via a new affwp_get_cookie_name filter:

add_filter( 'affwp_get_cookie_name', function( $cookie_name, $cookie_type ) {
    if ( 'foo' === $cookie_type ) {
        $cookie_name = 'bar';
    }
    return $cookie_name;
}, 10, 2 );

Once the filter callback is hooked up, usage is simple:

$cookie_name = affiliate_wp()->tracking->get_cookie_name( 'foo' );
if ( isset( $_COOKIE[ $cookie_name ] ) ) ...

Due to the typical longevity of cookies in AffiliateWP, we chose to take a cautious route with adding support for Pantheon’s policy.

After some discussions with their team, we opted to go the route of serving special cookie names when we can detect Pantheon, but otherwise sticking with the existing cookie names.

AffiliateWP and several add-ons have been updated to leverage the get_cookie_name() helper rather than using hard-coded cookie names going forward.

Other improvements & fixes

Other improvements and fixes in this release run the gamut of bundling 4.0.x of the select2 JavaScript library in core AffiliateWP (mostly for the benefit of add-ons), making the affwp_is_affiliate query variable usable outside the admin, and improving the usefulness of the affwp_auto_complete_referral hook by passing it a copy of the current referral object.

That’s about it for core improvement this week.

If you’re interested in helping us test the bleeding edge of core development, we recently shipped AffiliateWP 2.8 Alpha 2 and are busy prepping Alpha 3 for release early next week. Alpha 2 includes some awesome improvements for formatting dynamic coupons in more familiar ways; you should check it out!

Leave a Reply

Your email address will not be published. Required fields are marked *