Skip to content

How to Remove WordPress Actions Filters Added by the Plugin

khungate edited this page Jul 25, 2023 · 5 revisions

Removing WordPress Actions Filters Added by the Plugin

Welcome to the guide on Removing WordPress Actions Filters Added by the Plugin in the MailChimp for WooCommerce Integration. This guide will help you understand how to customize various plugin functions by using the typical “remove_action” + “add_action” to replace our events with custom functions of your own.

Overview

Why This Feature?

Advanced users needed a way to have full control over rendering the newsletter checkbox, enabling/disabling Abandoned Cart tracking, etc. This feature provides more control and options to override certain areas of the plugin without impacting future updates.

Solution

Exposing Classes as Globals

We provided a way for users to remove our action by exposing the following classes as globals:

MailChimp_WooCommerce_Admin::instance();
MailChimp_Newsletter::instance();
MailChimp_Service::instance();

Using the 'singleton pattern', one can reference the correct object instance while removing actions without having to change the plugin core files.

Implementation

Removing Filters

Please reference the official WordPress documentation for removing filters here.

Here's an example of how to remove an action:

$service = MailChimp_Newsletter::instance();
remove_action('woocommerce_register_form', array($service, 'applyNewsletterField'), 10);