BMM
BMM

Reputation: 710

Removing action added by a plugin in Wordpress

I am using Popup Maker plugin for Wordpress and I am trying to prevent it to load on a particular page using the functions.php file of a child theme.

I've located in the plugin's directory the file popup-maker.php which contains the following line at the end:

 add_action( 'plugins_loaded', 'popmake_initialize', 0 );

If I remove / comment this line, the popup will not fire, so I guess this is the action I need to remove. I have read the WP codex and numerous posts but still can't get it to work.

Right now I am stuck at this (function I have added in my child theme's functions.php file):

function remove_popmaker() {
    remove_action('plugins_loaded', 'popmake_initialize', 0);
    }

add_action( 'init', 'remove_popmaker', 1 );

PS: I am using shopkeeper theme and Woocommerce.

All help appreciated, thanks.

Upvotes: 2

Views: 7876

Answers (3)

Daniel Iser
Daniel Iser

Reputation: 441

@BMM - Without knowing the use case as to why you need to disable the entire plugin on one page its hard to give you the best answer.

For example if you simply wanted a single popup to not show on one page you can use the conditions panel to add a negative condition using the (!) button. Click it to turn it red and you will check for the opposite of a condition, so (!) Page Selected: Page xyz would prevent it from loading on that page.

Alternatively you can create your own custom conditions allowing you to add that condition to any popup.

Lastly if you wanted to unhook it just from the front end you can simply remove the rendering & script handlers

remove_action( 'wp_footer', 'popmake_render_popups', 1 );
remove_action( 'wp_head', 'popmake_script_loading_enabled' );

And if you want to prevent the queries as well

remove_action( 'wp_enqueue_scripts', 'popmake_preload_popups', 11 );

Hope that helps.

Upvotes: 0

Oleksii Shevchenko
Oleksii Shevchenko

Reputation: 71

There is a way I managed to do this:

add_action('wp', 'disableEmailPopup');
function disableEmailPopup () {
    global $post;
    if ($post->ID === 11625249) return remove_action( 'wp_enqueue_scripts', 'popmake_load_site_scripts');
}

Upvotes: 0

David
David

Reputation: 5937

you are adding a action to init which is after plugins_loaded so you cannot remove a action after it has run.

you can try the same action but you will have to do this from a plugin

remove_action( 'plugins_loaded', 'remove_popmaker', 0 );

But i suspect actions added before yours will be run after, this may be unpredictable if not you may have to code a MUplugin (google this).

Upvotes: 2

Related Questions