I experienced a similar problem with an Ajax request. There are a couple of important things to note.
Allow me to first state the obvious:
Make sure that your code using the option_active_plugins
filter is inside your mu-plugins
folder. It will not work for if your plugin is a regular plugin. Not even if you name it aaaa-first-plugin.
Now for the problem I faced:
I had written my function like this:
add_filter( 'option_active_plugins', function ( $wp_enabled_plugins ) {
// Quit immediately if in admin area.
if ( is_admin() ) {
return $wp_enabled_plugins;
}
// do other stuff
});
The problem is that when doing an AJAX call, is_admin()
returns true. So I changed it to:
if ( is_admin() && !DOING_AJAX ) { ... }
Everything works fine for me now. Hope it helps someone.