-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: disable mailchimp-for-woocommerce plugin campaign tracking cook…
…ie (#618)
- Loading branch information
1 parent
153e4a0
commit 99310cb
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* Mailchimp for WooCommerce integration class. | ||
* | ||
* @package Newspack | ||
*/ | ||
|
||
namespace Newspack; | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
/** | ||
* Main class. | ||
*/ | ||
class Mailchimp_For_WooCommerce { | ||
/** | ||
* Initialize hooks and filters. | ||
*/ | ||
public static function init() { | ||
// MC4WC fires it's hook at priority 10 so we need to move quicker. | ||
add_action( 'init', [ __CLASS__, 'remove_campaign_tracking_cookie' ], 9 ); | ||
} | ||
|
||
/** | ||
* Disable the cookie added by the Mailchimp for WooCommerce (MC4WC) plugin when on | ||
* a Newspack site because the cookie causes performance issues when logged out. | ||
*/ | ||
public static function remove_campaign_tracking_cookie() { | ||
// Don't do anything unless we know the MC4WC plugin is active. | ||
if ( ! \class_exists( '\MailChimp_Service' ) ) { | ||
return; | ||
} | ||
|
||
// Remove entirely the hook that sets the cookie. | ||
$service = \MailChimp_Service::instance(); | ||
remove_action( 'init', [ $service, 'handleCampaignTracking' ] ); | ||
} | ||
} | ||
Mailchimp_For_WooCommerce::init(); |