Good day! just wondering if you can help me out? I was trying to create a code for functions.php if the user currently lands on a specific page, thus the plugin will turn deactivated, but if the user re jumps on other pages, the plugin would be re activated.
Here's my code.
function disable_plugins(){
if( is_page(2690) ) {
deactivate_plugins( '/popup-maker/popup-maker.php');
} else {
//reactivate the plugin
}
} add_filter('option_active_plugins', 'disable_plugins');
Good day! just wondering if you can help me out? I was trying to create a code for functions.php if the user currently lands on a specific page, thus the plugin will turn deactivated, but if the user re jumps on other pages, the plugin would be re activated.
Here's my code.
function disable_plugins(){
if( is_page(2690) ) {
deactivate_plugins( '/popup-maker/popup-maker.php');
} else {
//reactivate the plugin
}
} add_filter('option_active_plugins', 'disable_plugins');
Instead of deactivating the plugin completely (which would deactivate it everywhere on your site) look at the plugin's code and determine what JS and CSS it is enqueuing. Then in your theme's functions.php
you can dequeue that plugin's JS/CSS - but only on whatever pages you want to disable the plugin on.
So for example, for the plugin Authorizer, if you want to remove the CSS from two pages, "about" and "contact":
add_action('wp_print_styles', 'wpse_317011_dequeue_authorizer');
function wpse_317011_dequeue_authorizer() {
if(is_page('about') || is_page('contact')) {
wp_dequeue_style('authorizer-public-css');
wp_deregister_style('authorizer-public-css');
}
}
Just replace authorizer-public-css
with whatever CSS file you need to from your specific plugin. And dequeue JS as well, if that's needed.
Other conditionals like is_singular()
work here too in case it's not just Pages you're dealing with.