using option_active_plugins ends up deactivating plugin permanently
-
Hi,
I was trying to deactivate a plugin programmatically for backend URLs like: /wp-admin/post.php?post=123&action=elementor using the option_active_plugins HOOK. I placed the code under /wp-content/mu-plugins/ and tested it, only to find out that the plugin gets deactivated permanently. What am I missing?
add_filter( ‘option_active_plugins’, function ($plugins) {
if (
strpos($_SERVER[‘REQUEST_URI’], ‘/wp-admin/’) !== false
&& (isset($_GET[‘action’]) && $_GET[‘action’] == ‘elementor’)
&& isset($_GET[‘post’])
&& $_SERVER[‘REQUEST_METHOD’] == ‘GET’
) {
$denylist_plugins = [
“wp-data-access/wp-data-access.php”,
];
foreach ( $plugins as $key => $plugin ) {
if ( in_array( $plugin, $denylist_plugins ) ) {
unset($plugins[$key]);
continue;
}
}
}
return $plugins;
}, 888, 1);
- You must be logged in to reply to this topic.